From 64f3199582c8908acb106fbc0a7070395653e00f Mon Sep 17 00:00:00 2001 From: Laurent Bigonville Date: Sun, 15 Dec 2019 20:02:02 +0100 Subject: [PATCH 01/20] Remove python(2) binding and disable nut-monitor package for now as it depends on unmaintained pygtk (Closes: #885358, #937169) --- debian/changelog | 7 ++++++ debian/control | 48 ++++++++++++++------------------------- debian/python-nut.install | 1 - debian/rules | 2 +- 4 files changed, 25 insertions(+), 33 deletions(-) delete mode 100644 debian/python-nut.install diff --git a/debian/changelog b/debian/changelog index f6cf025..d8ec98d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +nut (2.7.4-11) UNRELEASED; urgency=medium + + * Remove python(2) binding and disable nut-monitor package for now as it + depends on unmaintained pygtk (Closes: #885358, #937169) + + -- Laurent Bigonville Sun, 15 Dec 2019 20:00:53 +0100 + nut (2.7.4-10) unstable; urgency=medium * debian/libnutscan1.symbols: hurd-i386 is not built with ipmi support and diff --git a/debian/control b/debian/control index 713fe22..8ef29c9 100644 --- a/debian/control +++ b/debian/control @@ -15,7 +15,6 @@ Build-Depends: debhelper (>= 12), libsnmp-dev | libsnmp9-dev, libusb-dev (>= 0.1.8), libwrap0-dev (>= 7.6), - python (>= 2.6.6-3~), python3 Build-Depends-Indep: asciidoc (>= 8.6.3), asciidoc-dblatex, @@ -261,19 +260,6 @@ Description: network UPS tools - development files for the scanner library . This package provides the development files for the scanner library. -Package: python-nut -Section: python -Architecture: all -Depends: ${misc:Depends}, ${python:Depends} -Description: network UPS tools - Python bindings for NUT server - Network UPS Tools (NUT) is a client/server monitoring system that - allows computers to share uninterruptible power supply (UPS) and - power distribution unit (PDU) hardware. Clients access the hardware - through the server, and are notified whenever the power status - changes. - . - This package provides Python bindings to connect to NUT server. - Package: python3-nut Section: python Architecture: all @@ -287,23 +273,23 @@ Description: network UPS tools - Python3 bindings for NUT server . This package provides Python3 bindings to connect to NUT server. -Package: nut-monitor -Architecture: all -Depends: python-glade2, - python-gobject-2, - python-gtk2, - python-nut, - ${misc:Depends}, - ${python:Depends} -Recommends: python-notify -Description: network UPS tools - GUI application to monitor UPS status - Network UPS Tools (NUT) is a client/server monitoring system that - allows computers to share uninterruptible power supply (UPS) and - power distribution unit (PDU) hardware. Clients access the hardware - through the server, and are notified whenever the power status - changes. - . - This package provides nut-monitor, a GUI application to monitor UPS status. +#Package: nut-monitor +#Architecture: all +#Depends: python-glade2, +# python-gobject-2, +# python-gtk2, +# python-nut, +# ${misc:Depends}, +# ${python:Depends} +#Recommends: python-notify +#Description: network UPS tools - GUI application to monitor UPS status +# Network UPS Tools (NUT) is a client/server monitoring system that +# allows computers to share uninterruptible power supply (UPS) and +# power distribution unit (PDU) hardware. Clients access the hardware +# through the server, and are notified whenever the power status +# changes. +# . +# This package provides nut-monitor, a GUI application to monitor UPS status. Package: libups-nut-perl Section: perl diff --git a/debian/python-nut.install b/debian/python-nut.install deleted file mode 100644 index fa24bc5..0000000 --- a/debian/python-nut.install +++ /dev/null @@ -1 +0,0 @@ -scripts/python/module/PyNUT.py usr/share/pyshared/ diff --git a/debian/rules b/debian/rules index f8482c1..09ce27b 100755 --- a/debian/rules +++ b/debian/rules @@ -33,7 +33,7 @@ ifneq ($(shell which asciidoc),) endif %: - dh $@ --no-parallel --with python2 --with python3 + dh $@ --no-parallel --with python3 override_dh_auto_configure: dh_auto_configure -- $(DEB_CONFIGURE_EXTRA_FLAGS) From a4d3d4fb1e35059639f4dc0b7094089ef500354d Mon Sep 17 00:00:00 2001 From: Laurent Bigonville Date: Sun, 15 Dec 2019 20:04:41 +0100 Subject: [PATCH 02/20] debian/control: Add support for the Build-Profile --- debian/changelog | 3 ++- debian/control | 11 ++++++----- debian/rules | 2 ++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index d8ec98d..beb903f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,8 +2,9 @@ nut (2.7.4-11) UNRELEASED; urgency=medium * Remove python(2) binding and disable nut-monitor package for now as it depends on unmaintained pygtk (Closes: #885358, #937169) + * debian/control: Add support for the Build-Profile - -- Laurent Bigonville Sun, 15 Dec 2019 20:00:53 +0100 + -- Laurent Bigonville Sun, 15 Dec 2019 20:04:18 +0100 nut (2.7.4-10) unstable; urgency=medium diff --git a/debian/control b/debian/control index 8ef29c9..5095b77 100644 --- a/debian/control +++ b/debian/control @@ -16,11 +16,11 @@ Build-Depends: debhelper (>= 12), libusb-dev (>= 0.1.8), libwrap0-dev (>= 7.6), python3 -Build-Depends-Indep: asciidoc (>= 8.6.3), - asciidoc-dblatex, - dblatex (>= 0.2.5), - docbook-xsl, - libxml2-utils +Build-Depends-Indep: asciidoc (>= 8.6.3) , + asciidoc-dblatex , + dblatex (>= 0.2.5) , + docbook-xsl , + libxml2-utils Standards-Version: 4.4.0 Homepage: https://networkupstools.org/ Vcs-Browser: https://salsa.debian.org/debian/nut @@ -157,6 +157,7 @@ Architecture: all Section: doc Depends: ${misc:Depends} Suggests: doc-base +Build-Profiles: Description: network UPS tools - documentation Network UPS Tools (NUT) is a client/server monitoring system that allows computers to share uninterruptible power supply (UPS) and diff --git a/debian/rules b/debian/rules index 09ce27b..7f77ca1 100755 --- a/debian/rules +++ b/debian/rules @@ -98,6 +98,7 @@ override_dh_auto_install-arch: install -D -m 644 debian/source_nut.py $(CURDIR)/debian/tmp/usr/share/apport/package-hooks/source_nut-client.py override_dh_auto_install-indep: +ifeq ($(filter nodoc,$(DEB_BUILD_PROFILES)),) #install documentation mkdir -p $(CURDIR)/debian/tmp/usr/share/doc/nut-doc/pdf mkdir -p $(CURDIR)/debian/tmp/usr/share/doc/nut-doc/html @@ -108,6 +109,7 @@ override_dh_auto_install-indep: nf=`basename $${f} | sed 's/\(.*\)\.chunked/\1/'`; \ cp -a $${f} $(CURDIR)/debian/tmp/usr/share/doc/nut-doc/html/$${nf}/; \ done +endif # install apport hooks install -D -m 644 debian/source_nut.py $(CURDIR)/debian/tmp/usr/share/apport/package-hooks/source_nut.py From f1c2ba98823e28b0c9682b5beba7d03c4a69f95f Mon Sep 17 00:00:00 2001 From: Laurent Bigonville Date: Sun, 15 Dec 2019 20:31:06 +0100 Subject: [PATCH 03/20] debian/patches/0013-fix-doc-build.patch: Fix the documentation build with asciidoc >= 0.9 --- debian/changelog | 4 +++- debian/patches/0013-fix-doc-build.patch | 18 ++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 debian/patches/0013-fix-doc-build.patch diff --git a/debian/changelog b/debian/changelog index beb903f..87456aa 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,8 +3,10 @@ nut (2.7.4-11) UNRELEASED; urgency=medium * Remove python(2) binding and disable nut-monitor package for now as it depends on unmaintained pygtk (Closes: #885358, #937169) * debian/control: Add support for the Build-Profile + * debian/patches/0013-fix-doc-build.patch: Fix the documentation build with + asciidoc >= 0.9 - -- Laurent Bigonville Sun, 15 Dec 2019 20:04:18 +0100 + -- Laurent Bigonville Sun, 15 Dec 2019 20:49:11 +0100 nut (2.7.4-10) unstable; urgency=medium diff --git a/debian/patches/0013-fix-doc-build.patch b/debian/patches/0013-fix-doc-build.patch new file mode 100644 index 0000000..9aeba8c --- /dev/null +++ b/debian/patches/0013-fix-doc-build.patch @@ -0,0 +1,18 @@ +Description: Fix the documentation build with asciidoc >= 0.9 +Author: Laurent Bigonville +Last-Update: 2019-12-15 + +--- a/docs/Makefile.am ++++ b/docs/Makefile.am +@@ -91,10 +91,7 @@ packager-guide.html packager-guide.chunk + # variable ASCIIDOC_VERBOSE to "-v", ie: + # $ ASCIIDOC_VERBOSE=-v make + A2X_COMMON_OPTS = $(ASCIIDOC_VERBOSE) --attribute icons \ +- --xsltproc-opts "--nonet" \ +- --xsltproc-opts "--stringparam nut.localdate \"`TZ=UTC date +%Y-%m-%d -d @$(SOURCE_DATE_EPOCH)`\"" \ +- --xsltproc-opts "--stringparam nut.localtime \"`TZ=UTC date +%H:%M:%S -d @$(SOURCE_DATE_EPOCH)`\"" \ +- --xsltproc-opts "--stringparam nut.nutversion \"@PACKAGE_VERSION@\"" \ ++ --xsltproc-opts "--nonet --stringparam nut.localdate \"`TZ=UTC date +%Y-%m-%d -d @$(SOURCE_DATE_EPOCH)`\" --stringparam nut.localtime \"`TZ=UTC date +%H:%M:%S -d @$(SOURCE_DATE_EPOCH)`\" --stringparam nut.nutversion \"@PACKAGE_VERSION@\"" \ + --attribute iconsdir=$(srcdir)/images \ + --attribute=badges \ + --attribute=external_title \ diff --git a/debian/patches/series b/debian/patches/series index ee943a6..50dc917 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -10,3 +10,4 @@ 0010-fix-nutscanner-ftbfs.patch 0011-use-pkgconfig-module.patch 0012-add-AEG-PROTECT-NAS-support.patch +0013-fix-doc-build.patch From 0d0ddec73532f5ab9fa2296cb55b6985530c5ec7 Mon Sep 17 00:00:00 2001 From: Laurent Bigonville Date: Sun, 15 Dec 2019 21:15:32 +0100 Subject: [PATCH 04/20] Disable python3-nut package for now as it's broken with python3 --- debian/changelog | 3 ++- debian/control | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/debian/changelog b/debian/changelog index 87456aa..c88489c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,8 +5,9 @@ nut (2.7.4-11) UNRELEASED; urgency=medium * debian/control: Add support for the Build-Profile * debian/patches/0013-fix-doc-build.patch: Fix the documentation build with asciidoc >= 0.9 + * Disable python3-nut package for now as it's broken with python3 - -- Laurent Bigonville Sun, 15 Dec 2019 20:49:11 +0100 + -- Laurent Bigonville Sun, 15 Dec 2019 21:14:48 +0100 nut (2.7.4-10) unstable; urgency=medium diff --git a/debian/control b/debian/control index 5095b77..8f1ddad 100644 --- a/debian/control +++ b/debian/control @@ -261,18 +261,18 @@ Description: network UPS tools - development files for the scanner library . This package provides the development files for the scanner library. -Package: python3-nut -Section: python -Architecture: all -Depends: ${misc:Depends}, ${python3:Depends} -Description: network UPS tools - Python3 bindings for NUT server - Network UPS Tools (NUT) is a client/server monitoring system that - allows computers to share uninterruptible power supply (UPS) and - power distribution unit (PDU) hardware. Clients access the hardware - through the server, and are notified whenever the power status - changes. - . - This package provides Python3 bindings to connect to NUT server. +#Package: python3-nut +#Section: python +#Architecture: all +#Depends: ${misc:Depends}, ${python3:Depends} +#Description: network UPS tools - Python3 bindings for NUT server +# Network UPS Tools (NUT) is a client/server monitoring system that +# allows computers to share uninterruptible power supply (UPS) and +# power distribution unit (PDU) hardware. Clients access the hardware +# through the server, and are notified whenever the power status +# changes. +# . +# This package provides Python3 bindings to connect to NUT server. #Package: nut-monitor #Architecture: all From 5c60ced7db6ae30087554a8fcec4ea1ca487bf88 Mon Sep 17 00:00:00 2001 From: Laurent Bigonville Date: Sun, 15 Dec 2019 21:22:17 +0100 Subject: [PATCH 05/20] Release to unstable --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index c88489c..f999cdd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -nut (2.7.4-11) UNRELEASED; urgency=medium +nut (2.7.4-11) unstable; urgency=medium * Remove python(2) binding and disable nut-monitor package for now as it depends on unmaintained pygtk (Closes: #885358, #937169) @@ -7,7 +7,7 @@ nut (2.7.4-11) UNRELEASED; urgency=medium asciidoc >= 0.9 * Disable python3-nut package for now as it's broken with python3 - -- Laurent Bigonville Sun, 15 Dec 2019 21:14:48 +0100 + -- Laurent Bigonville Sun, 15 Dec 2019 21:22:13 +0100 nut (2.7.4-10) unstable; urgency=medium From dcb5203681c592c61cd65d503362001ad6aad538 Mon Sep 17 00:00:00 2001 From: Laurent Bigonville Date: Thu, 30 Jan 2020 00:58:18 +0100 Subject: [PATCH 06/20] Port autopkgtests to python3, taken from Ubuntu, thanks to them and Dimitri John Ledkov (Closes: #937169) --- debian/changelog | 7 ++++ debian/tests/control | 2 +- debian/tests/nut | 2 +- debian/tests/test-nut.py | 18 ++++---- debian/tests/testlib.py | 90 ++++++++++++++++++++-------------------- 5 files changed, 63 insertions(+), 56 deletions(-) diff --git a/debian/changelog b/debian/changelog index f999cdd..e523303 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +nut (2.7.4-12) unstable; urgency=medium + + * Port autopkgtests to python3, taken from Ubuntu, thanks to them and + Dimitri John Ledkov (Closes: #937169) + + -- Laurent Bigonville Thu, 30 Jan 2020 01:06:14 +0100 + nut (2.7.4-11) unstable; urgency=medium * Remove python(2) binding and disable nut-monitor package for now as it diff --git a/debian/tests/control b/debian/tests/control index fc0a7ad..0f68e27 100644 --- a/debian/tests/control +++ b/debian/tests/control @@ -1,3 +1,3 @@ Tests: nut -Depends: lsb-release, netcat, nut-client, nut-server, psmisc, python +Depends: lsb-release, netcat, nut-client, nut-server, psmisc, python3 Restrictions: needs-root diff --git a/debian/tests/nut b/debian/tests/nut index 598cde8..b367bba 100644 --- a/debian/tests/nut +++ b/debian/tests/nut @@ -3,4 +3,4 @@ # Testing nut #------------ set -e -python `dirname $0`/test-nut.py 2>&1 +python3 `dirname $0`/test-nut.py 2>&1 diff --git a/debian/tests/test-nut.py b/debian/tests/test-nut.py index af8dc69..ffbec80 100644 --- a/debian/tests/test-nut.py +++ b/debian/tests/test-nut.py @@ -75,7 +75,7 @@ try: except ImportError: class PrivateNutTest(object): '''Empty class''' - print >>sys.stdout, "Skipping private tests" + print("Skipping private tests") class NutTestCommon(testlib.TestlibCase): @@ -161,7 +161,7 @@ FINALDELAY 0 testlib.create_fill(self.notifyscript, ''' #! /bin/bash -echo "$*" > ''' + self.notifylog + '\n', mode=0755) +echo "$*" > ''' + self.notifylog + '\n', mode=0o755) # dummy-ups absolutely needs a data file, even if empty testlib.config_replace('/etc/nut/dummy.dev', ''' @@ -230,7 +230,7 @@ UPSMON_OPTIONS="" rc, report = testlib.cmd([self.initscript, 'start']) expected = 0 result = 'Got exit code %d, expected %d\n' % (rc, expected) - self.assertEquals(expected, rc, result + report) + self.assertEqual(expected, rc, result + report) time.sleep(2) def _stop(self): @@ -238,14 +238,14 @@ UPSMON_OPTIONS="" rc, report = testlib.cmd([self.initscript, 'stop']) expected = 0 result = 'Got exit code %d, expected %d\n' % (rc, expected) - self.assertEquals(expected, rc, result + report) + self.assertEqual(expected, rc, result + report) def _reload(self): '''Reload NUT''' rc, report = testlib.cmd([self.initscript, 'force-reload']) expected = 0 result = 'Got exit code %d, expected %d\n' % (rc, expected) - self.assertEquals(expected, rc, result + report) + self.assertEqual(expected, rc, result + report) def _restart(self): '''Restart NUT''' @@ -261,7 +261,7 @@ UPSMON_OPTIONS="" self._skipped("init script does not support status command") expected = 1 result = 'Got exit code %d, expected %d\n' % (rc, expected) - self.assertEquals(expected, rc, result + report) + self.assertEqual(expected, rc, result + report) def _testDaemons(self, daemons): '''Daemons running''' @@ -379,7 +379,7 @@ printf '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\n' | nc -q 1 127.0.0.1 sleep 1 dd if=/dev/urandom count=64 | nc -q 1 127.0.0.1 3493 ''' - testlib.create_fill(script, contents, mode=0755) + testlib.create_fill(script, contents, mode=0o755) rc, report = testlib.cmd([script]) # It should not have crashed. Let's see if it did @@ -414,9 +414,9 @@ if __name__ == '__main__': # suite.addTest(unittest.TestLoader().loadTestsFromTestCase(MyPrivateTest)) else: - print '''Usage: + print('''Usage: test-nut.py [-v] basic tests -''' +''') sys.exit(1) rc = unittest.TextTestRunner(verbosity=2).run(suite) if not rc.wasSuccessful(): diff --git a/debian/tests/testlib.py b/debian/tests/testlib.py index fe0a622..bc72b07 100644 --- a/debian/tests/testlib.py +++ b/debian/tests/testlib.py @@ -22,7 +22,6 @@ import string, random, crypt, subprocess, pwd, grp, signal, time, unittest, tempfile, shutil, os, os.path, re, glob import sys, socket, gzip from stat import * -from encodings import string_escape import warnings warnings.filterwarnings('ignore', message=r'.*apt_pkg\.TagFile.*', category=DeprecationWarning) @@ -77,7 +76,7 @@ def _save_backup(path): def config_copydir(path): if os.path.exists(path) and not os.path.isdir(path): - raise OSError, "'%s' is not a directory" % (path) + raise OSError("'%s' is not a directory" % (path)) _restore_backup(path) pathbackup = path + '.autotest' @@ -90,13 +89,13 @@ def config_replace(path,contents,append=False): if os.path.exists(path): _save_backup(path) if append: - contents = file(path).read() + contents + contents = open(path).read() + contents open(path, 'w').write(contents) def config_comment(path, field): _save_backup(path) contents = "" - for line in file(path): + for line in open(path).readlines(): if re.search("^\s*%s\s*=" % (field), line): line = "#" + line contents += line @@ -112,7 +111,7 @@ def config_set(path, field, value, spaces=True): else: setting = '%s=%s\n' % (field, value) found = False - for line in file(path): + for line in open(path).readlines(): if re.search("^\s*%s\s*=" % (field), line): found = True line = setting @@ -155,20 +154,20 @@ def timeout(secs, f, *args): def require_nonroot(): if os.geteuid() == 0: - print >>sys.stderr, "This series of tests should be run as a regular user with sudo access, not as root." + print("This series of tests should be run as a regular user with sudo access, not as root.", file=sys.stderr) sys.exit(1) def require_root(): if os.geteuid() != 0: - print >>sys.stderr, "This series of tests should be run with root privileges (e.g. via sudo)." + print("This series of tests should be run with root privileges (e.g. via sudo).", file=sys.stderr) sys.exit(1) def require_sudo(): if os.geteuid() != 0 or os.environ.get('SUDO_USER', None) == None: - print >>sys.stderr, "This series of tests must be run under sudo." + print("This series of tests must be run under sudo.", file=sys.stderr) sys.exit(1) if os.environ['SUDO_USER'] == 'root': - print >>sys.stderr, 'Please run this test using sudo from a regular user. (You ran sudo from root.)' + print('Please run this test using sudo from a regular user. (You ran sudo from root.)', file=sys.stderr) sys.exit(1) def random_string(length,lower=False): @@ -190,14 +189,14 @@ def mkstemp_fill(contents,suffix='',prefix='testlib-',dir=None): handle, name = tempfile.mkstemp(suffix=suffix,prefix=prefix,dir=dir) os.close(handle) - handle = file(name,"w+") + handle = open(name,"w+") handle.write(contents) handle.flush() handle.seek(0) return handle, name -def create_fill(path, contents, mode=0644): +def create_fill(path, contents, mode=0o644): '''Safely create a page''' # make the temp file in the same dir as the destination file so we # don't get invalid cross-device link errors when we rename @@ -342,7 +341,7 @@ def ubuntu_release(): return "UNKNOWN" if size > 1024*1024: - raise IOError, 'Could not open "%s" (too big)' % f + raise IOError('Could not open "%s" (too big)' % f) try: fh = open("/etc/lsb-release", 'r') @@ -364,8 +363,8 @@ def cmd(command, input = None, stderr = subprocess.STDOUT, stdout = subprocess.P a textual error if it failed.''' try: - sp = subprocess.Popen(command, stdin=stdin, stdout=stdout, stderr=stderr, close_fds=True, preexec_fn=subprocess_setup) - except OSError, e: + sp = subprocess.Popen(command, stdin=stdin, stdout=stdout, stderr=stderr, close_fds=True, preexec_fn=subprocess_setup, universal_newlines=True) + except OSError as e: return [127, str(e)] out, outerr = sp.communicate(input) @@ -382,7 +381,7 @@ def cmd_pipe(command1, command2, input = None, stderr = subprocess.STDOUT, stdin try: sp1 = subprocess.Popen(command1, stdin=stdin, stdout=subprocess.PIPE, stderr=stderr, close_fds=True) sp2 = subprocess.Popen(command2, stdin=sp1.stdout, stdout=subprocess.PIPE, stderr=stderr, close_fds=True) - except OSError, e: + except OSError as e: return [127, str(e)] out = sp2.communicate(input)[0] @@ -407,7 +406,7 @@ def cwd_has_enough_space(cdir, total_bytes): cdir = os.getcwd() while cdir != '/': - if not mounts.has_key(cdir): + if cdir not in mounts: cdir = os.path.dirname(cdir) continue if kb < mounts[cdir]: @@ -650,7 +649,7 @@ def is_kdeinit_running(): # check for it. rc, report = cmd(['ps', 'x']) if 'kdeinit4 Running' not in report: - print >>sys.stderr, ("kdeinit not running (you may start/stop any KDE application then run this script again)") + print(("kdeinit not running (you may start/stop any KDE application then run this script again)"), file=sys.stderr) return False return True @@ -660,7 +659,7 @@ def get_pkgconfig_flags(libs=[]): rc, pkg_config = cmd(['pkg-config', '--cflags', '--libs'] + libs) expected = 0 if rc != expected: - print >>sys.stderr, 'Got exit code %d, expected %d\n' % (rc, expected) + print('Got exit code %d, expected %d\n' % (rc, expected), file=sys.stderr) assert(rc == expected) return pkg_config.split() @@ -750,8 +749,8 @@ class TestlibManager(object): # Load LSB release file self.lsb_release = dict() if not os.path.exists('/usr/bin/lsb_release') and not os.path.exists('/bin/lsb_release'): - raise OSError, "Please install 'lsb-release'" - for line in subprocess.Popen(['lsb_release','-a'],stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()[0].splitlines(): + raise OSError("Please install 'lsb-release'") + for line in subprocess.Popen(['lsb_release','-a'],stdout=subprocess.PIPE,stderr=subprocess.PIPE, universal_newlines=True).communicate()[0].splitlines(): field, value = line.split(':',1) value=value.strip() field=field.strip() @@ -768,7 +767,7 @@ class TestlibManager(object): self.lsb_release['Distributor ID'] = "Ubuntu" self.lsb_release['Release'] = 8.04 else: - raise OSError, "Unknown version of HP MIE" + raise OSError("Unknown version of HP MIE") # FIXME: hack to assume a most-recent release if we're not # running under Ubuntu. @@ -789,7 +788,7 @@ class TestlibManager(object): elif machine.startswith('arm'): self.dpkg_arch = 'armel' else: - raise ValueError, "Unknown machine type '%s'" % (machine) + raise ValueError("Unknown machine type '%s'" % (machine)) else: self.dpkg_arch = cmd(['dpkg','--print-architecture'])[1].strip() @@ -800,7 +799,8 @@ class TestlibManager(object): versig = '/proc/version_signature' if os.path.exists(versig): self.kernel_is_ubuntu = True - self.kernel_version_signature = file(versig).read().strip() + with open(versig) as f: + self.kernel_version_signature = f.read().strip() self.kernel_version_ubuntu = self.kernel_version elif os.path.exists('/usr/bin/dpkg'): # this can easily be inaccurate but is only an issue for Dapper @@ -829,14 +829,14 @@ class TestlibManager(object): kernel = self.kernel_version_ubuntu if kernel != self.kernel_version_signature: kernel += " (%s)" % (self.kernel_version_signature) - print >>sys.stdout, "Running test: '%s' distro: '%s %.2f' kernel: '%s' arch: '%s' uid: %d/%d SUDO_USER: '%s')" % ( \ + print("Running test: '%s' distro: '%s %.2f' kernel: '%s' arch: '%s' uid: %d/%d SUDO_USER: '%s')" % ( \ sys.argv[0], self.lsb_release['Distributor ID'], self.lsb_release['Release'], kernel, self.dpkg_arch, os.geteuid(), os.getuid(), - os.environ.get('SUDO_USER', '')) + os.environ.get('SUDO_USER', '')), file=sys.stdout) sys.stdout.flush() # Additional heuristics @@ -848,7 +848,7 @@ class TestlibManager(object): # time.sleep(0.5) def hello(self, msg): - print >>sys.stderr, "Hello from %s" % (msg) + print("Hello from %s" % (msg), file=sys.stderr) # The central instance manager = TestlibManager() @@ -885,11 +885,11 @@ class TestlibCase(unittest.TestCase): if self.lsb_release['Release'] == 8.04 and rc == 255 and len(out) > 0: rc = 0 result = 'Got exit code %d, expected %d:\n%s\n' % (rc, expected, report) - self.assertEquals(expected, rc, result) + self.assertEqual(expected, rc, result) filetype = '^%s$' % (filetype) result = 'File type reported by file: [%s], expected regex: [%s]\n' % (out, filetype) - self.assertNotEquals(None, re.search(filetype, out), result) + self.assertNotEqual(None, re.search(filetype, out), result) def yank_commonname_from_cert(self, certfile): '''Extract the commonName from a given PEM''' @@ -905,12 +905,12 @@ class TestlibCase(unittest.TestCase): def announce(self, text): if self.my_verbosity: - print >>sys.stdout, "(%s) " % (text), + print("(%s) " % (text), end=' ', file=sys.stdout) sys.stdout.flush() def make_clean(self): rc, output = self.shell_cmd(['make','clean']) - self.assertEquals(rc, 0, output) + self.assertEqual(rc, 0, output) def get_makefile_compiler(self): # Find potential compiler name @@ -929,7 +929,7 @@ class TestlibCase(unittest.TestCase): compiler = self.get_makefile_compiler() rc, output = self.shell_cmd(['make',target]) - self.assertEquals(rc, expected, 'rc(%d)!=%d:\n' % (rc, expected) + output) + self.assertEqual(rc, expected, 'rc(%d)!=%d:\n' % (rc, expected) + output) self.assertTrue('%s ' % (compiler) in output, 'Expected "%s":' % (compiler) + output) return output @@ -954,13 +954,13 @@ class TestlibCase(unittest.TestCase): '''Test a shell command matches a specific exit code''' rc, report, out = self._testlib_shell_cmd(args, stdin=stdin, stdout=stdout, stderr=stderr) result = 'Got exit code %d, expected %d\n' % (rc, expected) - self.assertEquals(expected, rc, msg + result + report) + self.assertEqual(expected, rc, msg + result + report) def assertShellExitNotEquals(self, unwanted, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, msg=""): '''Test a shell command doesn't match a specific exit code''' rc, report, out = self._testlib_shell_cmd(args, stdin=stdin, stdout=stdout, stderr=stderr) result = 'Got (unwanted) exit code %d\n' % rc - self.assertNotEquals(unwanted, rc, msg + result + report) + self.assertNotEqual(unwanted, rc, msg + result + report) def assertShellOutputContains(self, text, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, msg="", invert=False): '''Test a shell command contains a specific output''' @@ -976,12 +976,12 @@ class TestlibCase(unittest.TestCase): rc, report, out = self._testlib_shell_cmd(args, stdin=stdin, stdout=stdout, stderr=stderr) result = 'Got exit code %d. Looking for exact text "%s" (%s)\n' % (rc, text, " ".join(args)) if not invert: - self.assertEquals(text, out, msg + result + report) + self.assertEqual(text, out, msg + result + report) else: - self.assertNotEquals(text, out, msg + result + report) + self.assertNotEqual(text, out, msg + result + report) if expected != None: result = 'Got exit code %d. Expected %d (%s)\n' % (rc, expected, " ".join(args)) - self.assertEquals(rc, expected, msg + result + report) + self.assertEqual(rc, expected, msg + result + report) def _word_find(self, report, content, invert=False): '''Check for a specific string''' @@ -994,20 +994,20 @@ class TestlibCase(unittest.TestCase): def _test_sysctl_value(self, path, expected, msg=None, exists=True): sysctl = '/proc/sys/%s' % (path) - self.assertEquals(exists, os.path.exists(sysctl), sysctl) + self.assertEqual(exists, os.path.exists(sysctl), sysctl) value = None if exists: - value = int(file(sysctl).read()) + value = int(open(sysctl).read()) report = "%s is not %d: %d" % (sysctl, expected, value) if msg: report += " (%s)" % (msg) - self.assertEquals(value, expected, report) + self.assertEqual(value, expected, report) return value def set_sysctl_value(self, path, desired): sysctl = '/proc/sys/%s' % (path) self.assertTrue(os.path.exists(sysctl),"%s does not exist" % (sysctl)) - file(sysctl,'w').write(str(desired)) + open(sysctl,'w').write(str(desired)) self._test_sysctl_value(path, desired) def kernel_at_least(self, introduced): @@ -1031,7 +1031,7 @@ class TestGroup: self.group = None if group: if group_exists(group): - raise ValueError, 'group name already exists' + raise ValueError('group name already exists') else: while(True): group = random_string(7,lower=lower) @@ -1063,11 +1063,11 @@ class TestUser: self.login = None if os.geteuid() != 0: - raise ValueError, "You must be root to run this test" + raise ValueError("You must be root to run this test") if login: if login_exists(login): - raise ValueError, 'login name already exists' + raise ValueError('login name already exists') else: while(True): login = 't' + random_string(7,lower=lower) @@ -1114,7 +1114,7 @@ class TestUser: '''Add user to the specified group name''' rc, report = cmd(['usermod', '-G', group, self.login]) if rc != 0: - print report + print(report) assert rc == 0 # Timeout handler using alarm() from John P. Speno's Pythonic Avocado @@ -1140,5 +1140,5 @@ class TimeoutFunction: return result def main(): - print "hi" + print("hi") unittest.main() From f308b5c62d466b44a498745a3b23cc9421f4199e Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Thu, 9 Jul 2020 10:47:27 +0200 Subject: [PATCH 07/20] Retirement of Arnaud Quette from the Debian project Signed-off-by: Arnaud Quette --- debian/changelog | 6 ++++++ debian/control | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index e523303..62042ba 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +nut (2.7.4-13) UNRELEASED; urgency=medium + + * Retirement of Arnaud Quette from the Debian project + + -- Arnaud Quette Thu, 09 Jul 2020 10:46:22 +0200 + nut (2.7.4-12) unstable; urgency=medium * Port autopkgtests to python3, taken from Ubuntu, thanks to them and diff --git a/debian/control b/debian/control index 8f1ddad..c0386fa 100644 --- a/debian/control +++ b/debian/control @@ -1,8 +1,7 @@ Source: nut Section: admin Priority: optional -Maintainer: Arnaud Quette -Uploaders: Laurent Bigonville +Maintainer: Laurent Bigonville Build-Depends: debhelper (>= 12), dh-python, libfreeipmi-dev (>= 0.8.5) [!hurd-i386], From b0cb2b77bb7fc8453dccf29edac1549fdf1727b7 Mon Sep 17 00:00:00 2001 From: Debian Janitor Date: Thu, 9 Jul 2020 21:54:17 +0100 Subject: [PATCH 08/20] Trim trailing whitespace. Changes-By: lintian-brush Fixes: lintian: trailing-whitespace See-also: https://lintian.debian.org/tags/trailing-whitespace.html --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 62042ba..1bc69ee 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,6 @@ nut (2.7.4-13) UNRELEASED; urgency=medium - * Retirement of Arnaud Quette from the Debian project + * Retirement of Arnaud Quette from the Debian project -- Arnaud Quette Thu, 09 Jul 2020 10:46:22 +0200 From 7e3876e1c67ad476ab96e167d0e26e1e3ddb0e9e Mon Sep 17 00:00:00 2001 From: Debian Janitor Date: Thu, 9 Jul 2020 21:55:02 +0100 Subject: [PATCH 09/20] Set upstream metadata fields: Bug-Database, Bug-Submit (from ./configure), Name (from ./configure), Repository, Repository-Browse. Changes-By: lintian-brush Fixes: lintian: upstream-metadata-file-is-missing See-also: https://lintian.debian.org/tags/upstream-metadata-file-is-missing.html Fixes: lintian: upstream-metadata-missing-bug-tracking See-also: https://lintian.debian.org/tags/upstream-metadata-missing-bug-tracking.html Fixes: lintian: upstream-metadata-missing-repository See-also: https://lintian.debian.org/tags/upstream-metadata-missing-repository.html --- debian/changelog | 5 +++++ debian/upstream/metadata | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 debian/upstream/metadata diff --git a/debian/changelog b/debian/changelog index 1bc69ee..51691c4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,12 @@ nut (2.7.4-13) UNRELEASED; urgency=medium + [ Arnaud Quette ] * Retirement of Arnaud Quette from the Debian project + [ Debian Janitor ] + * Set upstream metadata fields: Bug-Database, Bug-Submit (from ./configure), + Name (from ./configure), Repository, Repository-Browse. + -- Arnaud Quette Thu, 09 Jul 2020 10:46:22 +0200 nut (2.7.4-12) unstable; urgency=medium diff --git a/debian/upstream/metadata b/debian/upstream/metadata new file mode 100644 index 0000000..6e031b2 --- /dev/null +++ b/debian/upstream/metadata @@ -0,0 +1,6 @@ +--- +Name: nut +Bug-Database: https://github.com/networkupstools/nut/issues +Bug-Submit: https://github.com/networkupstools/nut/issues +Repository: https://github.com/networkupstools/nut.git +Repository-Browse: https://github.com/networkupstools/nut From 9f7a21edb35fc2092ca590a9a84671aeed38b916 Mon Sep 17 00:00:00 2001 From: Sergio Durigan Junior Date: Tue, 25 Aug 2020 14:21:22 -0400 Subject: [PATCH 10/20] d/libnutclient0.symbols: Update file, and fix FTBFS. Closes: #957614 --- debian/libnutclient0.symbols | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/debian/libnutclient0.symbols b/debian/libnutclient0.symbols index 8487ec8..4e7c579 100644 --- a/debian/libnutclient0.symbols +++ b/debian/libnutclient0.symbols @@ -155,18 +155,14 @@ libnutclient.so.0 libnutclient0 #MINVER# nutclient_tcp_is_connected@Base 2.7.3 nutclient_tcp_reconnect@Base 2.7.3 nutclient_tcp_set_timeout@Base 2.7.3 - (c++)"std::_Rb_tree, std::less, std::allocator >::_M_erase(std::_Rb_tree_node*)@Base" 2.7.3 (c++)"std::_Rb_tree, std::less, std::allocator >::_M_erase(std::_Rb_tree_node*)@Base" 2.7.3 - (c++)"std::_Rb_tree, std::less, std::allocator >::_M_erase(std::_Rb_tree_node*)@Base" 2.7.3 (c++)"std::_Rb_tree, std::allocator >, std::__cxx11::basic_string, std::allocator >, std::_Identity, std::allocator > >, std::less, std::allocator > >, std::allocator, std::allocator > > >::_M_erase(std::_Rb_tree_node, std::allocator > >*)@Base" 2.7.3 (c++)"std::_Rb_tree, std::allocator >, std::__cxx11::basic_string, std::allocator >, std::_Identity, std::allocator > >, std::less, std::allocator > >, std::allocator, std::allocator > > >::find(std::__cxx11::basic_string, std::allocator > const&)@Base" 2.7.3 (c++)"std::_Rb_tree, std::allocator >, std::pair, std::allocator > const, std::vector, std::allocator >, std::allocator, std::allocator > > > >, std::_Select1st, std::allocator > const, std::vector, std::allocator >, std::allocator, std::allocator > > > > >, std::less, std::allocator > >, std::allocator, std::allocator > const, std::vector, std::allocator >, std::allocator, std::allocator > > > > > >::_M_erase(std::_Rb_tree_node, std::allocator > const, std::vector, std::allocator >, std::allocator, std::allocator > > > > >*)@Base" 2.7.3 - (c++|optional=templinst|arch=amd64 arm64 hppa ia64 m68k mips64el ppc64el riscv64 sh4 sparc64 x32)"std::_Rb_tree, std::allocator >, std::pair, std::allocator > const, std::vector, std::allocator >, std::allocator, std::allocator > > > >, std::_Select1st, std::allocator > const, std::vector, std::allocator >, std::allocator, std::allocator > > > > >, std::less, std::allocator > >, std::allocator, std::allocator > const, std::vector, std::allocator >, std::allocator, std::allocator > > > > > >::_M_get_insert_hint_unique_pos(std::_Rb_tree_const_iterator, std::allocator > const, std::vector, std::allocator >, std::allocator, std::allocator > > > > >, std::__cxx11::basic_string, std::allocator > const&)@Base" 2.7.4 + (c++|optional=templinst)"std::_Rb_tree, std::allocator >, std::pair, std::allocator > const, std::vector, std::allocator >, std::allocator, std::allocator > > > >, std::_Select1st, std::allocator > const, std::vector, std::allocator >, std::allocator, std::allocator > > > > >, std::less, std::allocator > >, std::allocator, std::allocator > const, std::vector, std::allocator >, std::allocator, std::allocator > > > > > >::_M_get_insert_hint_unique_pos(std::_Rb_tree_const_iterator, std::allocator > const, std::vector, std::allocator >, std::allocator, std::allocator > > > > >, std::__cxx11::basic_string, std::allocator > const&)@Base" 2.7.4 (c++)"std::_Rb_tree, std::allocator >, std::pair, std::allocator > const, std::vector, std::allocator >, std::allocator, std::allocator > > > >, std::_Select1st, std::allocator > const, std::vector, std::allocator >, std::allocator, std::allocator > > > > >, std::less, std::allocator > >, std::allocator, std::allocator > const, std::vector, std::allocator >, std::allocator, std::allocator > > > > > >::_M_get_insert_unique_pos(std::__cxx11::basic_string, std::allocator > const&)@Base" 2.7.3 - (c++|optional=templinst)"std::_Rb_tree_iterator, std::allocator > const, std::vector, std::allocator >, std::allocator, std::allocator > > > > > std::_Rb_tree, std::allocator >, std::pair, std::allocator > const, std::vector, std::allocator >, std::allocator, std::allocator > > > >, std::_Select1st, std::allocator > const, std::vector, std::allocator >, std::allocator, std::allocator > > > > >, std::less, std::allocator > >, std::allocator, std::allocator > const, std::vector, std::allocator >, std::allocator, std::allocator > > > > > >::_M_emplace_hint_unique, std::allocator > const&>, std::tuple<> >(std::_Rb_tree_const_iterator, std::allocator > const, std::vector, std::allocator >, std::allocator, std::allocator > > > > >, std::piecewise_construct_t const&, std::tuple, std::allocator > const&>&&, std::tuple<>&&)@Base" 2.7.4-9~ (c++)"std::__cxx11::basic_string, std::allocator > std::operator+, std::allocator >(char const*, std::__cxx11::basic_string, std::allocator > const&)@Base" 2.7.3 (c++)"std::pair, bool> std::_Rb_tree, std::less, std::allocator >::_M_insert_unique(nut::Variable&&)@Base" 2.7.3 - (c++)"std::pair, std::allocator > >, bool> std::_Rb_tree, std::allocator >, std::__cxx11::basic_string, std::allocator >, std::_Identity, std::allocator > >, std::less, std::allocator > >, std::allocator, std::allocator > > >::_M_insert_unique, std::allocator > const&>(std::__cxx11::basic_string, std::allocator > const&)@Base" 2.7.3 (c++)"std::vector, std::allocator >, std::allocator, std::allocator > > >::operator=(std::vector, std::allocator >, std::allocator, std::allocator > > > const&)@Base" 2.7.3 (c++)"std::vector, std::allocator >, std::allocator, std::allocator > > >::~vector()@Base" 2.7.3 (c++)"std::vector, std::allocator >, std::allocator, std::allocator > > >, std::allocator, std::allocator >, std::allocator, std::allocator > > > > >::~vector()@Base" 2.7.3 @@ -188,11 +184,8 @@ libnutclient.so.0 libnutclient0 #MINVER# (c++)"typeinfo name for nut::TcpClient@Base" 2.7.3 (c++)"typeinfo name for nut::TimeoutException@Base" 2.7.3 (c++)"typeinfo name for nut::UnknownHostException@Base" 2.7.3 - (c++|optional=templinst)"void std::__cxx11::basic_string, std::allocator >::_M_construct(char const*, char const*, std::forward_iterator_tag)@Base" 2.7.4-9~ - (c++|optional=templinst)"void std::__cxx11::basic_string, std::allocator >::_M_construct(char*, char*, std::forward_iterator_tag)@Base" 2.7.4-9~ - (c++|optional=templinst|arch=amd64 arm64 x32)"void std::vector, std::allocator >, std::allocator, std::allocator > > >::_M_realloc_insert, std::allocator > >(__gnu_cxx::__normal_iterator, std::allocator >*, std::vector, std::allocator >, std::allocator, std::allocator > > > >, std::__cxx11::basic_string, std::allocator >&&)@Base" 2.7.4-9~ - (c++)"void std::vector, std::allocator >, std::allocator, std::allocator > > >::_M_realloc_insert, std::allocator > const&>(__gnu_cxx::__normal_iterator, std::allocator >*, std::vector, std::allocator >, std::allocator, std::allocator > > > >, std::__cxx11::basic_string, std::allocator > const&)@Base" 2.7.4-5.1~ - (c++)"void std::vector, std::allocator >, std::allocator, std::allocator > > >, std::allocator, std::allocator >, std::allocator, std::allocator > > > > >::_M_realloc_insert, std::allocator >, std::allocator, std::allocator > > > >(__gnu_cxx::__normal_iterator, std::allocator >, std::allocator, std::allocator > > >*, std::vector, std::allocator >, std::allocator, std::allocator > > >, std::allocator, std::allocator >, std::allocator, std::allocator > > > > > >, std::vector, std::allocator >, std::allocator, std::allocator > > >&&)@Base" 2.7.4-5.1~ + (c++|optional=templinst)"void std::vector, std::allocator >, std::allocator, std::allocator > > >::_M_realloc_insert, std::allocator > const&>(__gnu_cxx::__normal_iterator, std::allocator >*, std::vector, std::allocator >, std::allocator, std::allocator > > > >, std::__cxx11::basic_string, std::allocator > const&)@Base" 2.7.4 + (c++|optional=templinst)"void std::vector, std::allocator >, std::allocator, std::allocator > > >, std::allocator, std::allocator >, std::allocator, std::allocator > > > > >::_M_realloc_insert, std::allocator >, std::allocator, std::allocator > > > >(__gnu_cxx::__normal_iterator, std::allocator >, std::allocator, std::allocator > > >*, std::vector, std::allocator >, std::allocator, std::allocator > > >, std::allocator, std::allocator >, std::allocator, std::allocator > > > > > >, std::vector, std::allocator >, std::allocator, std::allocator > > >&&)@Base" 2.7.4 (c++)"vtable for nut::Client@Base" 2.7.3 (c++)"vtable for nut::IOException@Base" 2.7.3 (c++)"vtable for nut::NotConnectedException@Base" 2.7.3 @@ -201,3 +194,6 @@ libnutclient.so.0 libnutclient0 #MINVER# (c++)"vtable for nut::TcpClient@Base" 2.7.3 (c++)"vtable for nut::TimeoutException@Base" 2.7.3 (c++)"vtable for nut::UnknownHostException@Base" 2.7.3 + (c++|optional=templinst)"void std::vector, std::allocator >, std::allocator, std::allocator > > >::_M_realloc_insert, std::allocator > >(__gnu_cxx::__normal_iterator, std::allocator >*, std::vector, std::allocator >, std::allocator, std::allocator > > > >, std::__cxx11::basic_string, std::allocator >&&)@Base" 2.7.4 + (c++|optional=templinst|arch=s390x mipsel armhf)"std::pair, std::allocator > >, bool> std::_Rb_tree, std::allocator >, std::__cxx11::basic_string, std::allocator >, std::_Identity, std::allocator > >, std::less, std::allocator > >, std::allocator, std::allocator > > >::_M_insert_unique, std::allocator > const&>(std::__cxx11::basic_string, std::allocator > const&)@Base" 2.7.4 + (c++|optional=templinst|arch=!s390x !mipsel !armhf)"std::set, std::allocator >, std::less, std::allocator > >, std::allocator, std::allocator > > >::insert(std::__cxx11::basic_string, std::allocator > const&)@Base" 2.7.4 From 82a1e36d60d952cd1b14da902b76a7c27f80da30 Mon Sep 17 00:00:00 2001 From: Sergio Durigan Junior Date: Tue, 25 Aug 2020 14:23:14 -0400 Subject: [PATCH 11/20] Update changelog for 2.7.4-13 release --- debian/changelog | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 62042ba..f22e3a6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,12 @@ nut (2.7.4-13) UNRELEASED; urgency=medium + [ Arnaud Quette ] * Retirement of Arnaud Quette from the Debian project - -- Arnaud Quette Thu, 09 Jul 2020 10:46:22 +0200 + [ Sergio Durigan Junior ] + * d/libnutclient0.symbols: Update file, and fix FTBFS. (Closes: #957614) + + -- Sergio Durigan Junior Tue, 25 Aug 2020 14:23:07 -0400 nut (2.7.4-12) unstable; urgency=medium From c3b8fd580f80d5196fc2b5a0ddbce5436598c664 Mon Sep 17 00:00:00 2001 From: Laurent Bigonville Date: Thu, 15 Oct 2020 12:16:40 +0200 Subject: [PATCH 12/20] Release to unstable --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index fac34e0..c235416 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -nut (2.7.4-13) UNRELEASED; urgency=medium +nut (2.7.4-13) unstable; urgency=medium [ Arnaud Quette ] * Retirement of Arnaud Quette from the Debian project @@ -10,7 +10,7 @@ nut (2.7.4-13) UNRELEASED; urgency=medium [ Sergio Durigan Junior ] * d/libnutclient0.symbols: Update file, and fix FTBFS. (Closes: #957614) - -- Sergio Durigan Junior Tue, 25 Aug 2020 14:23:07 -0400 + -- Laurent Bigonville Thu, 15 Oct 2020 12:16:34 +0200 nut (2.7.4-12) unstable; urgency=medium From 889a404ef51cda49c0b5f80bf7fde64f7b59c734 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Thu, 14 Oct 2021 11:00:56 +0100 Subject: [PATCH 13/20] d/patches: add patch to fix FTBFS with g++-11 (closes: #984260) Dynamic exception specifications are obsolete and g++-11 throws errors when it find them. Upstream has removed them. This commit adds the upstream patch, rebased to apply against the source of the Debian pacakge. --- ...xception-specifications-from-clients.patch | 980 ++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 981 insertions(+) create mode 100644 debian/patches/0014-Remove-dynamic-exception-specifications-from-clients.patch diff --git a/debian/patches/0014-Remove-dynamic-exception-specifications-from-clients.patch b/debian/patches/0014-Remove-dynamic-exception-specifications-from-clients.patch new file mode 100644 index 0000000..9ec6e35 --- /dev/null +++ b/debian/patches/0014-Remove-dynamic-exception-specifications-from-clients.patch @@ -0,0 +1,980 @@ +From fab323320d5b955ed034b2eea390a9bbb549e8e5 Mon Sep 17 00:00:00 2001 +From: Peter Klein +Date: Thu, 11 Jun 2020 02:32:13 +0000 +Subject: [PATCH] Remove dynamic exception specifications from + clients/nutclient.cpp + +These are invalid in c++17 and must be removed for compatibility with +modern compilers. +--- + clients/nutclient.cpp | 146 +++++++++++++++---------------- + clients/nutclient.h | 195 +++++++++++++++++++++--------------------- + 2 files changed, 167 insertions(+), 174 deletions(-) + +diff --git a/clients/nutclient.cpp b/clients/nutclient.cpp +index b597e0e1e6c1..f5f0b70ef297 100644 +--- a/clients/nutclient.cpp ++++ b/clients/nutclient.cpp +@@ -96,18 +96,18 @@ + public: + Socket(); + +- void connect(const std::string& host, int port)throw(nut::IOException); ++ void connect(const std::string& host, int port); + void disconnect(); + bool isConnected()const; + + void setTimeout(long timeout); + bool hasTimeout()const{return _tv.tv_sec>=0;} + +- size_t read(void* buf, size_t sz)throw(nut::IOException); +- size_t write(const void* buf, size_t sz)throw(nut::IOException); ++ size_t read(void* buf, size_t sz); ++ size_t write(const void* buf, size_t sz); + +- std::string read()throw(nut::IOException); +- void write(const std::string& str)throw(nut::IOException); ++ std::string read(); ++ void write(const std::string& str); + + + private: +@@ -129,7 +129,7 @@ + _tv.tv_sec = timeout; + } + +-void Socket::connect(const std::string& host, int port)throw(nut::IOException) ++void Socket::connect(const std::string& host, int port) + { + int sock_fd; + struct addrinfo hints, *res, *ai; +@@ -298,7 +298,7 @@ + return _sock!=INVALID_SOCKET; + } + +-size_t Socket::read(void* buf, size_t sz)throw(nut::IOException) ++size_t Socket::read(void* buf, size_t sz) + { + if(!isConnected()) + { +@@ -325,7 +325,7 @@ + return (size_t) res; + } + +-size_t Socket::write(const void* buf, size_t sz)throw(nut::IOException) ++size_t Socket::write(const void* buf, size_t sz) + { + if(!isConnected()) + { +@@ -352,7 +352,7 @@ + return (size_t) res; + } + +-std::string Socket::read()throw(nut::IOException) ++std::string Socket::read() + { + std::string res; + char buff[256]; +@@ -383,7 +383,7 @@ + } + } + +-void Socket::write(const std::string& str)throw(nut::IOException) ++void Socket::write(const std::string& str) + { + // write(str.c_str(), str.size()); + // write("\n", 1); +@@ -408,13 +408,13 @@ + { + } + +-bool Client::hasDevice(const std::string& dev)throw(NutException) ++bool Client::hasDevice(const std::string& dev) + { + std::set devs = getDeviceNames(); + return devs.find(dev) != devs.end(); + } + +-Device Client::getDevice(const std::string& name)throw(NutException) ++Device Client::getDevice(const std::string& name) + { + if(hasDevice(name)) + return Device(this, name); +@@ -422,7 +422,7 @@ + return Device(NULL, ""); + } + +-std::set Client::getDevices()throw(NutException) ++std::set Client::getDevices() + { + std::set res; + +@@ -435,13 +435,13 @@ + return res; + } + +-bool Client::hasDeviceVariable(const std::string& dev, const std::string& name)throw(NutException) ++bool Client::hasDeviceVariable(const std::string& dev, const std::string& name) + { + std::set names = getDeviceVariableNames(dev); + return names.find(name) != names.end(); + } + +-std::map > Client::getDeviceVariableValues(const std::string& dev)throw(NutException) ++std::map > Client::getDeviceVariableValues(const std::string& dev) + { + std::map > res; + +@@ -455,7 +455,7 @@ + return res; + } + +-bool Client::hasDeviceCommand(const std::string& dev, const std::string& name)throw(NutException) ++bool Client::hasDeviceCommand(const std::string& dev, const std::string& name) + { + std::set names = getDeviceCommandNames(dev); + return names.find(name) != names.end(); +@@ -477,7 +477,7 @@ + // Do not connect now + } + +-TcpClient::TcpClient(const std::string& host, int port)throw(IOException): ++TcpClient::TcpClient(const std::string& host, int port): + Client(), + _socket(new internal::Socket) + { +@@ -489,14 +489,14 @@ + delete _socket; + } + +-void TcpClient::connect(const std::string& host, int port)throw(IOException) ++void TcpClient::connect(const std::string& host, int port) + { + _host = host; + _port = port; + connect(); + } + +-void TcpClient::connect()throw(nut::IOException) ++void TcpClient::connect() + { + _socket->connect(_host, _port); + } +@@ -532,19 +532,18 @@ + } + + void TcpClient::authenticate(const std::string& user, const std::string& passwd) +- throw(NutException) + { + detectError(sendQuery("USERNAME " + user)); + detectError(sendQuery("PASSWORD " + passwd)); + } + +-void TcpClient::logout()throw(NutException) ++void TcpClient::logout() + { + detectError(sendQuery("LOGOUT")); + _socket->disconnect(); + } + +-Device TcpClient::getDevice(const std::string& name)throw(NutException) ++Device TcpClient::getDevice(const std::string& name) + { + try + { +@@ -560,7 +559,7 @@ + return Device(this, name); + } + +-std::set TcpClient::getDeviceNames()throw(NutException) ++std::set TcpClient::getDeviceNames() + { + std::set res; + +@@ -576,12 +575,12 @@ + return res; + } + +-std::string TcpClient::getDeviceDescription(const std::string& name)throw(NutException) ++std::string TcpClient::getDeviceDescription(const std::string& name) + { + return get("UPSDESC", name)[0]; + } + +-std::set TcpClient::getDeviceVariableNames(const std::string& dev)throw(NutException) ++std::set TcpClient::getDeviceVariableNames(const std::string& dev) + { + std::set set; + +@@ -594,7 +593,7 @@ + return set; + } + +-std::set TcpClient::getDeviceRWVariableNames(const std::string& dev)throw(NutException) ++std::set TcpClient::getDeviceRWVariableNames(const std::string& dev) + { + std::set set; + +@@ -607,17 +606,17 @@ + return set; + } + +-std::string TcpClient::getDeviceVariableDescription(const std::string& dev, const std::string& name)throw(NutException) ++std::string TcpClient::getDeviceVariableDescription(const std::string& dev, const std::string& name) + { + return get("DESC", dev + " " + name)[0]; + } + +-std::vector TcpClient::getDeviceVariableValue(const std::string& dev, const std::string& name)throw(NutException) ++std::vector TcpClient::getDeviceVariableValue(const std::string& dev, const std::string& name) + { + return get("VAR", dev + " " + name); + } + +-std::map > TcpClient::getDeviceVariableValues(const std::string& dev)throw(NutException) ++std::map > TcpClient::getDeviceVariableValues(const std::string& dev) + { + + std::map > map; +@@ -634,13 +633,13 @@ + return map; + } + +-void TcpClient::setDeviceVariable(const std::string& dev, const std::string& name, const std::string& value)throw(NutException) ++void TcpClient::setDeviceVariable(const std::string& dev, const std::string& name, const std::string& value) + { + std::string query = "SET VAR " + dev + " " + name + " " + escape(value); + detectError(sendQuery(query)); + } + +-void TcpClient::setDeviceVariable(const std::string& dev, const std::string& name, const std::vector& values)throw(NutException) ++void TcpClient::setDeviceVariable(const std::string& dev, const std::string& name, const std::vector& values) + { + std::string query = "SET VAR " + dev + " " + name; + for(size_t n=0; n TcpClient::getDeviceCommandNames(const std::string& dev)throw(NutException) ++std::set TcpClient::getDeviceCommandNames(const std::string& dev) + { + std::set cmds; + +@@ -663,32 +662,32 @@ + return cmds; + } + +-std::string TcpClient::getDeviceCommandDescription(const std::string& dev, const std::string& name)throw(NutException) ++std::string TcpClient::getDeviceCommandDescription(const std::string& dev, const std::string& name) + { + return get("CMDDESC", dev + " " + name)[0]; + } + +-void TcpClient::executeDeviceCommand(const std::string& dev, const std::string& name)throw(NutException) ++void TcpClient::executeDeviceCommand(const std::string& dev, const std::string& name) + { + detectError(sendQuery("INSTCMD " + dev + " " + name)); + } + +-void TcpClient::deviceLogin(const std::string& dev)throw(NutException) ++void TcpClient::deviceLogin(const std::string& dev) + { + detectError(sendQuery("LOGIN " + dev)); + } + +-void TcpClient::deviceMaster(const std::string& dev)throw(NutException) ++void TcpClient::deviceMaster(const std::string& dev) + { + detectError(sendQuery("MASTER " + dev)); + } + +-void TcpClient::deviceForcedShutdown(const std::string& dev)throw(NutException) ++void TcpClient::deviceForcedShutdown(const std::string& dev) + { + detectError(sendQuery("FSD " + dev)); + } + +-int TcpClient::deviceGetNumLogins(const std::string& dev)throw(NutException) ++int TcpClient::deviceGetNumLogins(const std::string& dev) + { + std::string num = get("NUMLOGINS", dev)[0]; + return atoi(num.c_str()); +@@ -696,7 +695,7 @@ + + + std::vector TcpClient::get +- (const std::string& subcmd, const std::string& params) throw(NutException) ++ (const std::string& subcmd, const std::string& params) + { + std::string req = subcmd; + if(!params.empty()) +@@ -714,7 +713,7 @@ + } + + std::vector > TcpClient::list +- (const std::string& subcmd, const std::string& params) throw(NutException) ++ (const std::string& subcmd, const std::string& params) + { + std::string req = subcmd; + if(!params.empty()) +@@ -748,13 +747,13 @@ + } + } + +-std::string TcpClient::sendQuery(const std::string& req)throw(IOException) ++std::string TcpClient::sendQuery(const std::string& req) + { + _socket->write(req); + return _socket->read(); + } + +-void TcpClient::detectError(const std::string& req)throw(NutException) ++void TcpClient::detectError(const std::string& req) + { + if(req.substr(0,3)=="ERR") + { +@@ -954,47 +953,44 @@ + return getName()getDeviceDescription(getName()); + } + + std::vector Device::getVariableValue(const std::string& name) +- throw(NutException) + { + return getClient()->getDeviceVariableValue(getName(), name); + } + + std::map > Device::getVariableValues() +- throw(NutException) + { + return getClient()->getDeviceVariableValues(getName()); + } + +-std::set Device::getVariableNames()throw(NutException) ++std::set Device::getVariableNames() + { + return getClient()->getDeviceVariableNames(getName()); + } + +-std::set Device::getRWVariableNames()throw(NutException) ++std::set Device::getRWVariableNames() + { + return getClient()->getDeviceRWVariableNames(getName()); + } + +-void Device::setVariable(const std::string& name, const std::string& value)throw(NutException) ++void Device::setVariable(const std::string& name, const std::string& value) + { + getClient()->setDeviceVariable(getName(), name, value); + } + + void Device::setVariable(const std::string& name, const std::vector& values) +- throw(NutException) + { + getClient()->setDeviceVariable(getName(), name, values); + } + + + +-Variable Device::getVariable(const std::string& name)throw(NutException) ++Variable Device::getVariable(const std::string& name) + { + if(getClient()->hasDeviceVariable(getName(), name)) + return Variable(this, name); +@@ -1002,7 +998,7 @@ + return Variable(NULL, ""); + } + +-std::set Device::getVariables()throw(NutException) ++std::set Device::getVariables() + { + std::set set; + +@@ -1015,7 +1011,7 @@ + return set; + } + +-std::set Device::getRWVariables()throw(NutException) ++std::set Device::getRWVariables() + { + std::set set; + +@@ -1028,12 +1024,12 @@ + return set; + } + +-std::set Device::getCommandNames()throw(NutException) ++std::set Device::getCommandNames() + { + return getClient()->getDeviceCommandNames(getName()); + } + +-std::set Device::getCommands()throw(NutException) ++std::set Device::getCommands() + { + std::set cmds; + +@@ -1046,7 +1042,7 @@ + return cmds; + } + +-Command Device::getCommand(const std::string& name)throw(NutException) ++Command Device::getCommand(const std::string& name) + { + if(getClient()->hasDeviceCommand(getName(), name)) + return Command(this, name); +@@ -1054,26 +1050,26 @@ + return Command(NULL, ""); + } + +-void Device::executeCommand(const std::string& name)throw(NutException) ++void Device::executeCommand(const std::string& name) + { + getClient()->executeDeviceCommand(getName(), name); + } + +-void Device::login()throw(NutException) ++void Device::login() + { + getClient()->deviceLogin(getName()); + } + +-void Device::master()throw(NutException) ++void Device::master() + { + getClient()->deviceMaster(getName()); + } + +-void Device::forcedShutdown()throw(NutException) ++void Device::forcedShutdown() + { + } + +-int Device::getNumLogins()throw(NutException) ++int Device::getNumLogins() + { + return getClient()->deviceGetNumLogins(getName()); + } +@@ -1141,22 +1137,22 @@ + return getName() Variable::getValue()throw(NutException) ++std::vector Variable::getValue() + { + return getDevice()->getClient()->getDeviceVariableValue(getDevice()->getName(), getName()); + } + +-std::string Variable::getDescription()throw(NutException) ++std::string Variable::getDescription() + { + return getDevice()->getClient()->getDeviceVariableDescription(getDevice()->getName(), getName()); + } + +-void Variable::setValue(const std::string& value)throw(NutException) ++void Variable::setValue(const std::string& value) + { + getDevice()->setVariable(getName(), value); + } + +-void Variable::setValues(const std::vector& values)throw(NutException) ++void Variable::setValues(const std::vector& values) + { + getDevice()->setVariable(getName(), values); + } +@@ -1225,12 +1221,12 @@ + return getName()getClient()->getDeviceCommandDescription(getDevice()->getName(), getName()); + } + +-void Command::execute()throw(NutException) ++void Command::execute() + { + getDevice()->executeCommand(getName()); + } +--- a/clients/nutclient.h ++++ b/clients/nutclient.h +@@ -51,9 +51,9 @@ + { + public: + NutException(const std::string& msg):_msg(msg){} +- virtual ~NutException() throw() {} +- virtual const char * what() const throw() {return this->_msg.c_str();} +- virtual std::string str() const throw() {return this->_msg;} ++ virtual ~NutException() {} ++ virtual const char * what() const noexcept {return this->_msg.c_str();} ++ virtual std::string str() const noexcept {return this->_msg;} + private: + std::string _msg; + }; +@@ -65,7 +65,7 @@ + { + public: + SystemException(); +- virtual ~SystemException() throw() {} ++ virtual ~SystemException() {} + private: + static std::string err(); + }; +@@ -78,7 +78,7 @@ + { + public: + IOException(const std::string& msg):NutException(msg){} +- virtual ~IOException() throw() {} ++ virtual ~IOException() {} + }; + + /** +@@ -88,7 +88,7 @@ + { + public: + UnknownHostException():IOException("Unknown host"){} +- virtual ~UnknownHostException() throw() {} ++ virtual ~UnknownHostException() {} + }; + + /** +@@ -98,7 +98,7 @@ + { + public: + NotConnectedException():IOException("Not connected"){} +- virtual ~NotConnectedException() throw() {} ++ virtual ~NotConnectedException() {} + }; + + /** +@@ -108,7 +108,7 @@ + { + public: + TimeoutException():IOException("Timeout"){} +- virtual ~TimeoutException() throw() {} ++ virtual ~TimeoutException() {} + }; + + /** +@@ -132,13 +132,13 @@ + * \todo Is his method is global to all connection protocol or is it specific to TCP ? + * \note Actually, authentication fails only if already set, not if bad values are sent. + */ +- virtual void authenticate(const std::string& user, const std::string& passwd)throw(NutException)=0; ++ virtual void authenticate(const std::string& user, const std::string& passwd)=0; + + /** + * Disconnect from the NUTD server. + * \todo Is his method is global to all connection protocol or is it specific to TCP ? + */ +- virtual void logout()throw(NutException)=0; ++ virtual void logout()=0; + + /** + * Device manipulations. +@@ -151,29 +151,29 @@ + * \param name Name of the device. + * \return The device. + */ +- virtual Device getDevice(const std::string& name)throw(NutException); ++ virtual Device getDevice(const std::string& name); + /** + * Retrieve the list of all devices supported by UPSD server. + * \return The set of supported devices. + */ +- virtual std::set getDevices()throw(NutException); ++ virtual std::set getDevices(); + /** + * Test if a device is supported by the NUTD server. + * \param dev Device name. + * \return true if supported, false otherwise. + */ +- virtual bool hasDevice(const std::string& dev)throw(NutException); ++ virtual bool hasDevice(const std::string& dev); + /** + * Retrieve names of devices supported by NUTD server. + * \return The set of names of supported devices. + */ +- virtual std::set getDeviceNames()throw(NutException)=0; ++ virtual std::set getDeviceNames()=0; + /** + * Retrieve the description of a device. + * \param name Device name. + * \return Device description. + */ +- virtual std::string getDeviceDescription(const std::string& name)throw(NutException)=0; ++ virtual std::string getDeviceDescription(const std::string& name)=0; + /** \} */ + + /** +@@ -186,54 +186,54 @@ + * \param dev Device name + * \return Variable names + */ +- virtual std::set getDeviceVariableNames(const std::string& dev)throw(NutException)=0; ++ virtual std::set getDeviceVariableNames(const std::string& dev)=0; + /** + * Retrieve names of read/write variables supported by a device. + * \param dev Device name + * \return RW variable names + */ +- virtual std::set getDeviceRWVariableNames(const std::string& dev)throw(NutException)=0; ++ virtual std::set getDeviceRWVariableNames(const std::string& dev)=0; + /** + * Test if a variable is supported by a device. + * \param dev Device name + * \param name Variable name + * \return true if the variable is supported. + */ +- virtual bool hasDeviceVariable(const std::string& dev, const std::string& name)throw(NutException); ++ virtual bool hasDeviceVariable(const std::string& dev, const std::string& name); + /** + * Retrieve the description of a variable. + * \param dev Device name + * \param name Variable name + * \return Variable description if provided. + */ +- virtual std::string getDeviceVariableDescription(const std::string& dev, const std::string& name)throw(NutException)=0; ++ virtual std::string getDeviceVariableDescription(const std::string& dev, const std::string& name)=0; + /** + * Retrieve values of a variable. + * \param dev Device name + * \param name Variable name + * \return Variable values (usually one) if available. + */ +- virtual std::vector getDeviceVariableValue(const std::string& dev, const std::string& name)throw(NutException)=0; ++ virtual std::vector getDeviceVariableValue(const std::string& dev, const std::string& name)=0; + /** + * Retrieve values of all variables of a device. + * \param dev Device name + * \return Variable values indexed by variable names. + */ +- virtual std::map > getDeviceVariableValues(const std::string& dev)throw(NutException); ++ virtual std::map > getDeviceVariableValues(const std::string& dev); + /** + * Intend to set the value of a variable. + * \param dev Device name + * \param name Variable name + * \param value Variable value + */ +- virtual void setDeviceVariable(const std::string& dev, const std::string& name, const std::string& value)throw(NutException)=0; ++ virtual void setDeviceVariable(const std::string& dev, const std::string& name, const std::string& value)=0; + /** + * Intend to set the value of a variable. + * \param dev Device name + * \param name Variable name + * \param value Variable value + */ +- virtual void setDeviceVariable(const std::string& dev, const std::string& name, const std::vector& values)throw(NutException)=0; ++ virtual void setDeviceVariable(const std::string& dev, const std::string& name, const std::vector& values)=0; + /** \} */ + + /** +@@ -246,27 +246,27 @@ + * \param dev Device name + * \return Command names + */ +- virtual std::set getDeviceCommandNames(const std::string& dev)throw(NutException)=0; ++ virtual std::set getDeviceCommandNames(const std::string& dev)=0; + /** + * Test if a command is supported by a device. + * \param dev Device name + * \param name Command name + * \return true if the command is supported. + */ +- virtual bool hasDeviceCommand(const std::string& dev, const std::string& name)throw(NutException); ++ virtual bool hasDeviceCommand(const std::string& dev, const std::string& name); + /** + * Retrieve the description of a command. + * \param dev Device name + * \param name Command name + * \return Command description if provided. + */ +- virtual std::string getDeviceCommandDescription(const std::string& dev, const std::string& name)throw(NutException)=0; ++ virtual std::string getDeviceCommandDescription(const std::string& dev, const std::string& name)=0; + /** + * Intend to execute a command. + * \param dev Device name + * \param name Command name + */ +- virtual void executeDeviceCommand(const std::string& dev, const std::string& name)throw(NutException)=0; ++ virtual void executeDeviceCommand(const std::string& dev, const std::string& name)=0; + /** \} */ + + /** +@@ -277,15 +277,15 @@ + * Log the current user (if authenticated) for a device. + * \param dev Device name. + */ +- virtual void deviceLogin(const std::string& dev)throw(NutException)=0; ++ virtual void deviceLogin(const std::string& dev)=0; + /** + * Retrieve the number of user longged in the specified device. + * \param dev Device name. + * \return Number of logged-in users. + */ +- virtual int deviceGetNumLogins(const std::string& dev)throw(NutException)=0; +- virtual void deviceMaster(const std::string& dev)throw(NutException)=0; +- virtual void deviceForcedShutdown(const std::string& dev)throw(NutException)=0; ++ virtual int deviceGetNumLogins(const std::string& dev)=0; ++ virtual void deviceMaster(const std::string& dev)=0; ++ virtual void deviceForcedShutdown(const std::string& dev)=0; + + protected: + Client(); +@@ -309,7 +309,7 @@ + * \param host Server host name. + * \param port Server port. + */ +- TcpClient(const std::string& host, int port = 3493)throw(nut::IOException); ++ TcpClient(const std::string& host, int port = 3493); + ~TcpClient(); + + /** +@@ -317,13 +317,13 @@ + * \param host Server host name. + * \param port Server port. + */ +- void connect(const std::string& host, int port = 3493)throw(nut::IOException); ++ void connect(const std::string& host, int port = 3493); + + /** + * Connect to the server. + * Host name and ports must have already set (usefull for reconnection). + */ +- void connect()throw(nut::IOException); ++ void connect(); + + /** + * Test if the connection is active. +@@ -358,39 +358,37 @@ + */ + int getPort()const; + +- virtual void authenticate(const std::string& user, const std::string& passwd)throw(NutException); +- virtual void logout()throw(NutException); ++ virtual void authenticate(const std::string& user, const std::string& passwd); ++ virtual void logout(); + +- virtual Device getDevice(const std::string& name)throw(NutException); +- virtual std::set getDeviceNames()throw(NutException); +- virtual std::string getDeviceDescription(const std::string& name)throw(NutException); +- +- virtual std::set getDeviceVariableNames(const std::string& dev)throw(NutException); +- virtual std::set getDeviceRWVariableNames(const std::string& dev)throw(NutException); +- virtual std::string getDeviceVariableDescription(const std::string& dev, const std::string& name)throw(NutException); +- virtual std::vector getDeviceVariableValue(const std::string& dev, const std::string& name)throw(NutException); +- virtual std::map > getDeviceVariableValues(const std::string& dev)throw(NutException); +- virtual void setDeviceVariable(const std::string& dev, const std::string& name, const std::string& value)throw(NutException); +- virtual void setDeviceVariable(const std::string& dev, const std::string& name, const std::vector& values)throw(NutException); +- +- virtual std::set getDeviceCommandNames(const std::string& dev)throw(NutException); +- virtual std::string getDeviceCommandDescription(const std::string& dev, const std::string& name)throw(NutException); +- virtual void executeDeviceCommand(const std::string& dev, const std::string& name)throw(NutException); +- +- virtual void deviceLogin(const std::string& dev)throw(NutException); +- virtual void deviceMaster(const std::string& dev)throw(NutException); +- virtual void deviceForcedShutdown(const std::string& dev)throw(NutException); +- virtual int deviceGetNumLogins(const std::string& dev)throw(NutException); ++ virtual Device getDevice(const std::string& name); ++ virtual std::set getDeviceNames(); ++ virtual std::string getDeviceDescription(const std::string& name); ++ ++ virtual std::set getDeviceVariableNames(const std::string& dev); ++ virtual std::set getDeviceRWVariableNames(const std::string& dev); ++ virtual std::string getDeviceVariableDescription(const std::string& dev, const std::string& name); ++ virtual std::vector getDeviceVariableValue(const std::string& dev, const std::string& name); ++ virtual std::map > getDeviceVariableValues(const std::string& dev); ++ virtual void setDeviceVariable(const std::string& dev, const std::string& name, const std::string& value); ++ virtual void setDeviceVariable(const std::string& dev, const std::string& name, const std::vector& values); ++ ++ virtual std::set getDeviceCommandNames(const std::string& dev); ++ virtual std::string getDeviceCommandDescription(const std::string& dev, const std::string& name); ++ virtual void executeDeviceCommand(const std::string& dev, const std::string& name); ++ ++ virtual void deviceLogin(const std::string& dev); ++ virtual void deviceMaster(const std::string& dev); ++ virtual void deviceForcedShutdown(const std::string& dev); ++ virtual int deviceGetNumLogins(const std::string& dev); + + protected: +- std::string sendQuery(const std::string& req)throw(nut::IOException); +- static void detectError(const std::string& req)throw(nut::NutException); ++ std::string sendQuery(const std::string& req); ++ static void detectError(const std::string& req); + +- std::vector get(const std::string& subcmd, const std::string& params = "") +- throw(nut::NutException); ++ std::vector get(const std::string& subcmd, const std::string& params = ""); + +- std::vector > list(const std::string& subcmd, const std::string& params = "") +- throw(nut::NutException); ++ std::vector > list(const std::string& subcmd, const std::string& params = ""); + + static std::vector explode(const std::string& str, size_t begin=0); + static std::string escape(const std::string& str); +@@ -455,92 +453,92 @@ + /** + * Retrieve the description of the devce if specified. + */ +- std::string getDescription()throw(NutException); ++ std::string getDescription(); + + /** + * Intend to retrieve the value of a variable of the device. + * \param name Name of the variable to get. + * \return Value of the variable, if available. + */ +- std::vector getVariableValue(const std::string& name)throw(NutException); ++ std::vector getVariableValue(const std::string& name); + /** + * Intend to retrieve values of all variables of the devices. + * \return Map of all variables values indexed by their names. + */ +- std::map > getVariableValues()throw(NutException); ++ std::map > getVariableValues(); + /** + * Retrieve all variables names supported by the device. + * \return Set of available variable names. + */ +- std::set getVariableNames()throw(NutException); ++ std::set getVariableNames(); + /** + * Retrieve all Read/Write variables names supported by the device. + * \return Set of available Read/Write variable names. + */ +- std::set getRWVariableNames()throw(NutException); ++ std::set getRWVariableNames(); + /** + * Intend to set the value of a variable of the device. + * \param name Variable name. + * \param value New variable value. + */ +- void setVariable(const std::string& name, const std::string& value)throw(NutException); ++ void setVariable(const std::string& name, const std::string& value); + /** + * Intend to set values of a variable of the device. + * \param name Variable name. + * \param value New variable values. + */ +- void setVariable(const std::string& name, const std::vector& values)throw(NutException); ++ void setVariable(const std::string& name, const std::vector& values); + + /** + * Retrieve a Variable object representing the specified variable. + * \param name Variable name. + * \return Variable object. + */ +- Variable getVariable(const std::string& name)throw(NutException); ++ Variable getVariable(const std::string& name); + /** + * Retrieve Variable objects representing all variables available for the device. + * \return Set of Variable objects. + */ +- std::set getVariables()throw(NutException); ++ std::set getVariables(); + /** + * Retrieve Variable objects representing all Read/Write variables available for the device. + * \return Set of Variable objects. + */ +- std::set getRWVariables()throw(NutException); ++ std::set getRWVariables(); + + /** + * Retrieve names of all commands supported by the device. + * \return Set of available command names. + */ +- std::set getCommandNames()throw(NutException); ++ std::set getCommandNames(); + /** + * Retrieve objects for all commands supported by the device. + * \return Set of available Command objects. + */ +- std::set getCommands()throw(NutException); ++ std::set getCommands(); + /** + * Retrieve an object representing a command of the device. + * \param name Command name. + * \return Command object. + */ +- Command getCommand(const std::string& name)throw(NutException); ++ Command getCommand(const std::string& name); + /** + * Intend to execute a command on the device. + * \param name Command name. + */ +- void executeCommand(const std::string& name)throw(NutException); ++ void executeCommand(const std::string& name); + + /** + * Login current client's user for the device. + */ +- void login()throw(NutException); +- void master()throw(NutException); +- void forcedShutdown()throw(NutException); ++ void login(); ++ void master(); ++ void forcedShutdown(); + /** + * Retrieve the number of logged user for the device. + * \return Number of users. + */ +- int getNumLogins()throw(NutException); ++ int getNumLogins(); + + protected: + Device(Client* client, const std::string& name); +@@ -603,23 +601,23 @@ + * Intend to retrieve variable value. + * \return Value of the variable. + */ +- std::vector getValue()throw(NutException); ++ std::vector getValue(); + /** + * Intend to retireve variable description. + * \return Variable description if provided. + */ +- std::string getDescription()throw(NutException); ++ std::string getDescription(); + + /** + * Intend to set a value to the variable. + * \param value New variable value. + */ +- void setValue(const std::string& value)throw(NutException); ++ void setValue(const std::string& value); + /** + * Intend to set (multiple) values to the variable. + * \param value New variable values. + */ +- void setValues(const std::vector& values)throw(NutException); ++ void setValues(const std::vector& values); + + protected: + Variable(Device* dev, const std::string& name); +@@ -683,13 +681,13 @@ + * Intend to retireve command description. + * \return Command description if provided. + */ +- std::string getDescription()throw(NutException); ++ std::string getDescription(); + + /** + * Intend to retrieve command description. + * \return Command description if provided. + */ +- void execute()throw(NutException); ++ void execute(); + + protected: + Command(Device* dev, const std::string& name); +-- +2.33.0 + diff --git a/debian/patches/series b/debian/patches/series index 50dc917..677ad2c 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -11,3 +11,4 @@ 0011-use-pkgconfig-module.patch 0012-add-AEG-PROTECT-NAS-support.patch 0013-fix-doc-build.patch +0014-Remove-dynamic-exception-specifications-from-clients.patch From 9830c31430fb2cbbbcb24bfb9064563e89cfe2ad Mon Sep 17 00:00:00 2001 From: Laurent Bigonville Date: Sat, 6 Nov 2021 18:22:27 +0100 Subject: [PATCH 14/20] debian/control: Bump Standards-Version to 4.6.0 (no further changes) --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index c0386fa..7ba656b 100644 --- a/debian/control +++ b/debian/control @@ -20,7 +20,7 @@ Build-Depends-Indep: asciidoc (>= 8.6.3) , dblatex (>= 0.2.5) , docbook-xsl , libxml2-utils -Standards-Version: 4.4.0 +Standards-Version: 4.6.0 Homepage: https://networkupstools.org/ Vcs-Browser: https://salsa.debian.org/debian/nut Vcs-Git: https://salsa.debian.org/debian/nut.git From a9054f19361a4e43eb42da86d254bbb51814b4b3 Mon Sep 17 00:00:00 2001 From: Laurent Bigonville Date: Sat, 6 Nov 2021 18:33:07 +0100 Subject: [PATCH 15/20] debian/source_nut.py: Change the shebang to python3 --- debian/source_nut.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/source_nut.py b/debian/source_nut.py index 1dd5fd5..b5088f1 100644 --- a/debian/source_nut.py +++ b/debian/source_nut.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 '''nut Apport interface From fc7f4b43c12fa605d54677eb0e3fe7d9b3820346 Mon Sep 17 00:00:00 2001 From: Laurent Bigonville Date: Sat, 6 Nov 2021 18:41:42 +0100 Subject: [PATCH 16/20] Release to unstable --- debian/changelog | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/debian/changelog b/debian/changelog index c235416..d7749e3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,14 @@ +nut (2.7.4-14) unstable; urgency=medium + + [ Jeremy Sowden ] + * d/patches: add patch to fix FTBFS with g++-11 (closes: #984260) + + [ Laurent Bigonville ] + * debian/control: Bump Standards-Version to 4.6.0 (no further changes) + * debian/source_nut.py: Change the shebang to python3 + + -- Laurent Bigonville Sat, 06 Nov 2021 18:41:33 +0100 + nut (2.7.4-13) unstable; urgency=medium [ Arnaud Quette ] From b2b0c9995af976e129c25c449ffe4c9dc6381b0e Mon Sep 17 00:00:00 2001 From: lagertonne Date: Wed, 29 Jun 2022 12:37:36 +0200 Subject: [PATCH 17/20] new upstream 2.8.0 --- ChangeLog | 16704 +++++++++++- INSTALL | 316 +- INSTALL.nut | 63 +- MAINTAINERS | 2 +- Makefile.am | 267 +- Makefile.in | 427 +- NEWS | 542 +- README | 90 +- TODO | 4 +- UPGRADING | 130 +- aclocal.m4 | 548 +- clients/Makefile.am | 61 +- clients/Makefile.in | 378 +- clients/cgilib.c | 13 +- clients/cgilib.h | 4 + clients/nutclient.cpp | 742 +- clients/nutclient.h | 341 +- clients/nutclientmem.cpp | 252 + clients/nutclientmem.h | 118 + clients/status.h | 9 +- clients/upsc.c | 29 +- clients/upsclient.c | 344 +- clients/upsclient.h | 47 +- clients/upscmd.c | 148 +- clients/upsimage.c | 161 +- clients/upsimagearg.h | 20 +- clients/upslog.c | 74 +- clients/upslog.h | 11 +- clients/upsmon.c | 583 +- clients/upsmon.h | 54 +- clients/upsrw.c | 225 +- clients/upssched-cmd | 13 +- clients/upssched.c | 165 +- clients/upssched.h | 4 + clients/upsset.c | 118 +- clients/upsstats.c | 65 +- clients/upsstats.h | 4 + common/Makefile.am | 40 +- common/Makefile.in | 221 +- common/common.c | 580 +- common/parseconf.c | 47 +- common/setenv.c | 3 +- common/snprintf.c | 519 +- common/state.c | 31 +- common/str.c | 60 +- common/strerror.c | 15 + common/upsconf.c | 6 +- conf/Makefile.am | 24 + conf/Makefile.in | 102 +- conf/hosts.conf.sample | 2 +- conf/nut.conf.sample | 11 +- conf/ups.conf.sample | 163 +- conf/upsd.conf.sample | 73 +- conf/upsd.users.sample | 33 +- conf/upsmon.conf.sample.in | 197 +- conf/upssched.conf.sample.in | 25 +- conf/upsset.conf.sample | 14 +- conf/upsstats-single.html.sample | 41 +- conf/upsstats.html.sample | 66 +- config.guess | 692 +- config.sub | 310 +- configure | 22692 +++++++++++++--- configure.ac | 2195 +- data/Makefile.am | 13 + data/Makefile.in | 89 +- data/cmdvartab | 6 +- data/driver.list.in | 473 +- data/html/Makefile.am | 6 +- data/html/Makefile.in | 81 +- data/html/header.html.in | 2 +- depcomp | 10 +- docs/FAQ.txt | 333 +- docs/Makefile.am | 344 +- docs/Makefile.in | 452 +- docs/acknowledgements.txt | 62 +- docs/asciidoc.txt | 19 + docs/cables.txt | 18 +- docs/cables/Makefile.am | 2 + docs/cables/Makefile.in | 566 + docs/cables/apc-rs500-serial.txt | 2 +- docs/cables/ge-imv-victron.txt | 6 +- docs/cables/powerware.txt | 4 +- docs/cables/repotec.txt | 6 +- docs/cables/sms.txt | 6 +- docs/ci-farm-lxc-setup.txt | 693 + docs/config-notes.txt | 571 +- docs/config-prereqs.txt | 848 + docs/configure.txt | 495 +- docs/contact-closure.txt | 16 +- docs/daisychain.txt | 220 + docs/design.txt | 89 +- docs/developer-guide.txt | 47 +- docs/developers.txt | 782 +- docs/documentation.txt | 41 +- docs/download.txt | 101 +- docs/features.txt | 151 +- docs/hid-subdrivers.txt | 108 +- docs/history.txt | 203 +- docs/images/advanced.png | Bin 45511 -> 49233 bytes docs/images/bizarre.png | Bin 48365 -> 52703 bytes docs/macros.txt | 10 +- docs/man/Makefile.am | 543 +- docs/man/Makefile.in | 859 +- docs/man/adelsystem_cbi.8 | 160 + docs/man/adelsystem_cbi.txt | 111 + docs/man/al175.8 | 10 +- docs/man/al175.txt | 12 +- docs/man/apcsmart-old.8 | 18 +- docs/man/apcsmart-old.txt | 20 +- docs/man/apcsmart.8 | 82 +- docs/man/apcsmart.txt | 93 +- docs/man/apcupsd-ups.8 | 36 +- docs/man/apcupsd-ups.txt | 19 +- docs/man/asem.8 | 48 +- docs/man/asem.txt | 21 +- docs/man/bcmxcp.8 | 14 +- docs/man/bcmxcp.txt | 21 +- docs/man/bcmxcp_usb.8 | 36 +- docs/man/bcmxcp_usb.txt | 28 +- docs/man/belkin.8 | 15 +- docs/man/belkin.txt | 21 +- docs/man/belkinunv.8 | 20 +- docs/man/belkinunv.txt | 45 +- docs/man/bestfcom.8 | 44 +- docs/man/bestfcom.txt | 16 +- docs/man/bestfortress.8 | 34 +- docs/man/bestfortress.txt | 14 +- docs/man/bestuferrups.8 | 35 +- docs/man/bestuferrups.txt | 13 +- docs/man/bestups.8 | 41 +- docs/man/bestups.txt | 56 +- docs/man/blazer-common.txt | 33 +- docs/man/blazer_ser.8 | 59 +- docs/man/blazer_usb.8 | 66 +- docs/man/clone.8 | 51 +- docs/man/clone.txt | 38 +- docs/man/dummy-ups.8 | 189 +- docs/man/dummy-ups.txt | 232 +- docs/man/etapro.8 | 8 +- docs/man/etapro.txt | 8 + docs/man/everups.8 | 8 +- docs/man/everups.txt | 8 +- docs/man/gamatronic.8 | 8 +- docs/man/gamatronic.txt | 6 + docs/man/generic_modbus.8 | 355 + docs/man/generic_modbus.txt | 247 + docs/man/genericups.8 | 55 +- docs/man/genericups.txt | 149 +- docs/man/hosts.conf.5 | 10 +- docs/man/hosts.conf.txt | 1 + docs/man/huawei-ups2000.8 | 489 + docs/man/huawei-ups2000.txt | 364 + docs/man/isbmex.8 | 8 +- docs/man/isbmex.txt | 4 + docs/man/ivtscd.8 | 8 +- docs/man/ivtscd.txt | 8 + docs/man/libnutclient.3 | 10 +- docs/man/libnutclient.txt | 2 + docs/man/libnutclient_commands.3 | 125 +- docs/man/libnutclient_commands.txt | 54 +- docs/man/libnutclient_devices.3 | 78 +- docs/man/libnutclient_devices.txt | 27 +- docs/man/libnutclient_general.3 | 13 +- docs/man/libnutclient_general.txt | 5 +- docs/man/libnutclient_misc.3 | 67 +- docs/man/libnutclient_misc.txt | 40 +- docs/man/libnutclient_tcp.3 | 58 +- docs/man/libnutclient_tcp.txt | 40 +- docs/man/libnutclient_variables.3 | 115 +- docs/man/libnutclient_variables.txt | 69 +- docs/man/libupsclient-config.1 | 8 +- docs/man/libupsclient-config.txt | 9 +- docs/man/liebert-esp2.8 | 63 +- docs/man/liebert-esp2.txt | 34 +- docs/man/liebert.8 | 10 +- docs/man/liebert.txt | 4 + docs/man/macosx-ups.8 | 38 +- docs/man/macosx-ups.txt | 16 +- docs/man/masterguard.8 | 18 +- docs/man/masterguard.txt | 26 +- docs/man/metasys.8 | 8 +- docs/man/metasys.txt | 12 +- docs/man/mge-shut.8 | 10 +- docs/man/mge-shut.txt | 8 +- docs/man/mge-utalk.8 | 184 +- docs/man/mge-utalk.txt | 40 +- docs/man/microdowell.8 | 8 +- docs/man/microdowell.txt | 8 +- docs/man/microsol-apc.8 | 146 + docs/man/microsol-apc.txt | 73 + docs/man/netxml-ups.8 | 15 +- docs/man/netxml-ups.txt | 28 +- docs/man/nut-driver-enumerator.8 | 158 + docs/man/nut-driver-enumerator.txt | 150 + docs/man/nut-ipmipsu.8 | 32 +- docs/man/nut-ipmipsu.txt | 9 +- docs/man/nut-recorder.8 | 11 +- docs/man/nut-recorder.txt | 13 +- docs/man/nut-scanner.8 | 33 +- docs/man/nut-scanner.txt | 25 +- docs/man/nut.conf.5 | 66 +- docs/man/nut.conf.txt | 12 +- docs/man/nutclient_authenticate.3 | 2 +- docs/man/nutclient_destroy.3 | 2 +- docs/man/nutclient_device_forced_shutdown.3 | 2 +- docs/man/nutclient_device_login.3 | 2 +- docs/man/nutclient_device_master.3 | 2 +- docs/man/nutclient_execute_device_command.3 | 2 +- ...nutclient_get_device_command_description.3 | 2 +- docs/man/nutclient_get_device_commands.3 | 2 +- docs/man/nutclient_get_device_description.3 | 2 +- docs/man/nutclient_get_device_num_logins.3 | 2 +- docs/man/nutclient_get_device_rw_variables.3 | 2 +- ...utclient_get_device_variable_description.3 | 2 +- .../nutclient_get_device_variable_values.3 | 2 +- docs/man/nutclient_get_device_variables.3 | 2 +- docs/man/nutclient_get_devices.3 | 2 +- docs/man/nutclient_has_device.3 | 2 +- docs/man/nutclient_has_device_command.3 | 2 +- docs/man/nutclient_has_device_variable.3 | 2 +- docs/man/nutclient_logout.3 | 2 +- .../man/nutclient_set_device_variable_value.3 | 2 +- .../nutclient_set_device_variable_values.3 | 2 +- docs/man/nutclient_tcp_create_client.3 | 2 +- docs/man/nutclient_tcp_disconnect.3 | 2 +- docs/man/nutclient_tcp_get_timeout.3 | 2 +- docs/man/nutclient_tcp_is_connected.3 | 2 +- docs/man/nutclient_tcp_reconnect.3 | 2 +- docs/man/nutclient_tcp_set_timeout.3 | 2 +- docs/man/nutdrv_atcl_usb.8 | 22 +- docs/man/nutdrv_atcl_usb.txt | 44 +- docs/man/nutdrv_qx.8 | 233 +- docs/man/nutdrv_qx.txt | 121 +- docs/man/nutdrv_siemens_sitop.8 | 269 + docs/man/nutdrv_siemens_sitop.txt | 201 + docs/man/nutscan.3 | 21 +- docs/man/nutscan.txt | 29 +- docs/man/nutscan_add_device_to_device.3 | 23 +- docs/man/nutscan_add_device_to_device.txt | 36 +- docs/man/nutscan_add_option_to_device.3 | 22 +- docs/man/nutscan_add_option_to_device.txt | 34 +- docs/man/nutscan_cidr_to_ip.3 | 21 +- docs/man/nutscan_cidr_to_ip.txt | 22 +- docs/man/nutscan_display_parsable.3 | 55 +- docs/man/nutscan_display_parsable.txt | 24 +- docs/man/nutscan_display_ups_conf.3 | 14 +- docs/man/nutscan_display_ups_conf.txt | 14 +- docs/man/nutscan_free_device.3 | 19 +- docs/man/nutscan_free_device.txt | 17 +- docs/man/nutscan_get_serial_ports_list.3 | 23 +- docs/man/nutscan_get_serial_ports_list.txt | 37 +- docs/man/nutscan_init.3 | 21 +- docs/man/nutscan_init.txt | 25 +- docs/man/nutscan_new_device.3 | 19 +- docs/man/nutscan_new_device.txt | 18 +- docs/man/nutscan_scan_avahi.3 | 24 +- docs/man/nutscan_scan_avahi.txt | 32 +- docs/man/nutscan_scan_eaton_serial.3 | 16 +- docs/man/nutscan_scan_eaton_serial.txt | 20 +- docs/man/nutscan_scan_ipmi.3 | 26 +- docs/man/nutscan_scan_ipmi.txt | 30 +- docs/man/nutscan_scan_nut.3 | 21 +- docs/man/nutscan_scan_nut.txt | 26 +- docs/man/nutscan_scan_snmp.3 | 21 +- docs/man/nutscan_scan_snmp.txt | 52 +- docs/man/nutscan_scan_usb.3 | 14 +- docs/man/nutscan_scan_usb.txt | 13 +- docs/man/nutscan_scan_xml_http.txt | 36 - ...l_http.3 => nutscan_scan_xml_http_range.3} | 31 +- docs/man/nutscan_scan_xml_http_range.txt | 54 + docs/man/nutupsdrv.8 | 903 +- docs/man/nutupsdrv.txt | 171 +- docs/man/oneac.8 | 34 +- docs/man/oneac.txt | 18 +- docs/man/optiups.8 | 45 +- docs/man/optiups.txt | 33 +- docs/man/phoenixcontact_modbus.8 | 254 + docs/man/phoenixcontact_modbus.txt | 107 + docs/man/pijuice.8 | 167 + docs/man/pijuice.txt | 88 + docs/man/powercom.8 | 61 +- docs/man/powercom.txt | 59 +- docs/man/powerman-pdu.8 | 32 +- docs/man/powerman-pdu.txt | 12 +- docs/man/powerpanel.8 | 15 +- docs/man/powerpanel.txt | 23 +- docs/man/rhino.8 | 10 +- docs/man/rhino.txt | 10 +- docs/man/richcomm_usb.8 | 32 +- docs/man/richcomm_usb.txt | 19 +- docs/man/riello_ser.8 | 8 +- docs/man/riello_ser.txt | 6 +- docs/man/riello_usb.8 | 8 +- docs/man/riello_usb.txt | 6 +- docs/man/safenet.8 | 10 +- docs/man/safenet.txt | 13 +- docs/man/skel.txt | 12 +- docs/man/snmp-ups.8 | 151 +- docs/man/snmp-ups.txt | 103 +- docs/man/socomec_jbus.8 | 196 + docs/man/socomec_jbus.txt | 166 + docs/man/solis.8 | 12 +- docs/man/solis.txt | 10 +- docs/man/tripplite.8 | 30 +- docs/man/tripplite.txt | 14 +- docs/man/tripplite_usb.8 | 46 +- docs/man/tripplite_usb.txt | 67 +- docs/man/tripplitesu.8 | 8 +- docs/man/tripplitesu.txt | 8 + docs/man/ups.conf.5 | 89 +- docs/man/ups.conf.txt | 85 +- docs/man/upsc.8 | 12 +- docs/man/upsc.txt | 8 +- docs/man/upscli_add_host_cert.3 | 12 +- docs/man/upscli_add_host_cert.txt | 9 +- docs/man/upscli_cleanup.3 | 12 +- docs/man/upscli_cleanup.txt | 7 +- docs/man/upscli_connect.3 | 14 +- docs/man/upscli_connect.txt | 18 +- docs/man/upscli_disconnect.3 | 14 +- docs/man/upscli_disconnect.txt | 11 +- docs/man/upscli_fd.3 | 14 +- docs/man/upscli_fd.txt | 10 +- docs/man/upscli_get.3 | 68 +- docs/man/upscli_get.txt | 57 +- docs/man/upscli_init.3 | 26 +- docs/man/upscli_init.txt | 26 +- docs/man/upscli_list_next.3 | 14 +- docs/man/upscli_list_next.txt | 9 +- docs/man/upscli_list_start.3 | 32 +- docs/man/upscli_list_start.txt | 8 +- docs/man/upscli_readline.3 | 24 +- docs/man/upscli_readline.txt | 24 +- docs/man/upscli_readline_timeout.3 | 1 + docs/man/upscli_sendline.3 | 24 +- docs/man/upscli_sendline.txt | 22 +- docs/man/upscli_sendline_timeout.3 | 1 + docs/man/upscli_splitaddr.3 | 10 +- docs/man/upscli_splitaddr.txt | 3 +- docs/man/upscli_splitname.3 | 10 +- docs/man/upscli_splitname.txt | 5 +- docs/man/upscli_ssl.3 | 10 +- docs/man/upscli_strerror.3 | 12 +- docs/man/upscli_strerror.txt | 2 +- docs/man/upscli_upserror.3 | 10 +- docs/man/upscli_upserror.txt | 2 +- docs/man/upsclient.3 | 10 +- docs/man/upsclient.txt | 14 +- docs/man/upscmd.8 | 28 +- docs/man/upscmd.txt | 26 +- docs/man/upscode2.8 | 36 +- docs/man/upscode2.txt | 17 +- docs/man/upsd.8 | 854 +- docs/man/upsd.conf.5 | 92 +- docs/man/upsd.conf.txt | 77 +- docs/man/upsd.txt | 64 +- docs/man/upsd.users.5 | 22 +- docs/man/upsd.users.txt | 20 +- docs/man/upsdrvctl.8 | 37 +- docs/man/upsdrvctl.txt | 15 +- docs/man/upsdrvsvcctl.8 | 206 + docs/man/upsdrvsvcctl.txt | 205 + docs/man/upsimage.cgi.8 | 34 +- docs/man/upsimage.cgi.txt | 5 +- docs/man/upslog.8 | 26 +- docs/man/upslog.txt | 24 +- docs/man/upsmon.8 | 71 +- docs/man/upsmon.conf.5 | 104 +- docs/man/upsmon.conf.txt | 127 +- docs/man/upsmon.txt | 129 +- docs/man/upsrw.8 | 37 +- docs/man/upsrw.txt | 27 +- docs/man/upssched.8 | 10 +- docs/man/upssched.conf.5 | 12 +- docs/man/upssched.conf.txt | 3 +- docs/man/upssched.txt | 6 +- docs/man/upsset.cgi.8 | 10 +- docs/man/upsset.cgi.txt | 5 +- docs/man/upsset.conf.5 | 10 +- docs/man/upsset.conf.txt | 10 +- docs/man/upsstats.cgi.8 | 10 +- docs/man/upsstats.cgi.txt | 1 + docs/man/upsstats.html.5 | 12 +- docs/man/upsstats.html.txt | 7 +- docs/man/usbhid-ups.8 | 144 +- docs/man/usbhid-ups.txt | 140 +- docs/man/victronups.8 | 56 +- docs/man/victronups.txt | 23 +- docs/net-protocol.txt | 149 +- docs/new-clients.txt | 80 +- docs/new-drivers.txt | 230 +- docs/nut-names.txt | 230 +- docs/nut-qa.txt | 66 +- docs/nut.dict | 3006 +- docs/nutdrv_qx-subdrivers.txt | 45 +- docs/outlets.txt | 21 +- docs/packager-guide.txt | 115 +- docs/scheduling.txt | 46 +- docs/security.txt | 160 +- docs/snmp-subdrivers.txt | 10 +- docs/snmp.txt | 12 +- docs/sock-protocol.txt | 36 +- docs/solaris-usb.txt | 231 + docs/support.txt | 63 +- docs/user-manual.txt | 36 +- drivers/Makefile.am | 190 +- drivers/Makefile.in | 1798 +- drivers/adelsystem_cbi.c | 1344 + drivers/adelsystem_cbi.h | 531 + drivers/al175.c | 195 +- drivers/apc-ats-mib.c | 396 +- drivers/apc-ats-mib.h | 0 drivers/apc-hid.c | 162 +- drivers/apc-hid.h | 4 +- drivers/apc-iem-mib.h | 19 + drivers/apc-mib.c | 149 +- drivers/apc-mib.h | 10 +- drivers/apc-pdu-mib.c | 972 + drivers/apc-pdu-mib.h | 31 + drivers/apcsmart-old.c | 160 +- drivers/apcsmart-old.h | 51 +- drivers/apcsmart.c | 365 +- drivers/apcsmart.h | 33 +- drivers/apcsmart_tabs.c | 129 +- drivers/apcsmart_tabs.h | 6 +- drivers/apcupsd-ups.c | 69 +- drivers/apcupsd-ups.h | 19 +- drivers/arduino-hid.c | 148 + drivers/arduino-hid.h | 31 + drivers/asem.c | 80 +- drivers/baytech-mib.c | 65 +- drivers/bcmxcp.c | 1120 +- drivers/bcmxcp.h | 13 +- drivers/bcmxcp_io.h | 12 +- drivers/bcmxcp_ser.c | 192 +- drivers/bcmxcp_ser.h | 22 + drivers/bcmxcp_usb.c | 225 +- drivers/belkin-hid.c | 67 +- drivers/belkin-hid.h | 4 +- drivers/belkin.c | 55 +- drivers/belkinunv.c | 255 +- drivers/bestfcom.c | 262 +- drivers/bestfortress.c | 128 +- drivers/bestpower-mib.c | 27 +- drivers/bestuferrups.c | 616 +- drivers/bestups.c | 51 +- drivers/blazer.c | 99 +- drivers/blazer.h | 7 +- drivers/blazer_ser.c | 18 +- drivers/blazer_usb.c | 204 +- drivers/clone-outlet.c | 29 +- drivers/clone.c | 54 +- drivers/compaq-mib.c | 165 +- drivers/cps-hid.c | 79 +- drivers/cyberpower-mib.c | 135 +- drivers/delta_ups-hid.c | 323 + drivers/delta_ups-hid.h | 31 + drivers/delta_ups-mib.c | 54 +- drivers/dstate.c | 692 +- drivers/dstate.h | 24 +- drivers/dummy-ups.c | 278 +- drivers/dummy-ups.h | 11 +- ...{eaton-ats-mib.c => eaton-ats16-nm2-mib.c} | 261 +- drivers/eaton-ats16-nm2-mib.h | 30 + drivers/eaton-ats16-nmc-mib.c | 275 + drivers/eaton-ats16-nmc-mib.h | 30 + drivers/eaton-ats30-mib.c | 372 + drivers/eaton-ats30-mib.h | 29 + drivers/eaton-mib.c | 750 - drivers/eaton-mib.h | 13 - drivers/eaton-pdu-genesis2-mib.c | 95 + drivers/eaton-pdu-genesis2-mib.h | 32 + drivers/eaton-pdu-marlin-helpers.c | 91 + drivers/eaton-pdu-marlin-helpers.h | 29 + drivers/eaton-pdu-marlin-mib.c | 1366 + drivers/eaton-pdu-marlin-mib.h | 32 + drivers/eaton-pdu-pulizzi-mib.c | 142 + drivers/eaton-pdu-pulizzi-mib.h | 33 + drivers/eaton-pdu-revelation-mib.c | 182 + drivers/eaton-pdu-revelation-mib.h | 32 + drivers/emerson-avocent-pdu-mib.c | 191 + drivers/emerson-avocent-pdu-mib.h | 31 + drivers/etapro.c | 10 +- drivers/ever-hid.c | 787 + drivers/ever-hid.h | 32 + drivers/everups.c | 16 +- drivers/explore-hid.c | 15 +- drivers/gamatronic.c | 431 +- drivers/gamatronic.h | 211 +- drivers/generic_modbus.c | 1099 + drivers/generic_modbus.h | 111 + drivers/genericups.c | 78 +- drivers/genericups.h | 77 +- drivers/hidparser.c | 360 +- drivers/hidparser.h | 27 +- drivers/hidtypes.h | 186 +- drivers/hpe-pdu-mib.c | 899 + drivers/hpe-pdu-mib.h | 30 + drivers/huawei-mib.c | 159 +- drivers/huawei-ups2000.c | 2122 ++ drivers/idowell-hid.c | 9 +- drivers/ietf-mib.c | 129 +- drivers/isbmex.c | 331 +- drivers/ivtscd.c | 22 +- drivers/legrand-hid.c | 236 + drivers/legrand-hid.h | 30 + drivers/libhid.c | 419 +- drivers/libhid.h | 40 +- drivers/libshut.c | 714 +- drivers/libshut.h | 118 +- drivers/libusb.h | 66 - drivers/{libusb.c => libusb0.c} | 374 +- drivers/libusb1.c | 907 + drivers/liebert-esp2.c | 296 +- drivers/liebert-hid.c | 24 +- drivers/liebert-hid.h | 2 +- drivers/liebert.c | 9 +- drivers/macosx-ups.c | 9 +- drivers/main.c | 472 +- drivers/main.h | 10 +- drivers/masterguard.c | 777 +- drivers/metasys.c | 344 +- drivers/mge-hid.c | 321 +- drivers/mge-mib.c | 181 +- drivers/mge-shut.c | 1455 - drivers/mge-shut.h | 523 - drivers/mge-utalk.c | 208 +- drivers/mge-utalk.h | 25 +- drivers/mge-xml.c | 288 +- drivers/mge-xml.h | 2 +- drivers/microdowell.c | 243 +- drivers/microdowell.h | 574 +- drivers/microsol-apc.c | 188 + drivers/microsol-apc.h | 230 + drivers/microsol-common.c | 809 + drivers/microsol-common.h | 67 + drivers/netvision-mib.c | 116 +- drivers/netxml-ups.c | 128 +- drivers/netxml-ups.h | 6 +- drivers/nut-ipmi.h | 15 +- drivers/nut-ipmipsu.c | 22 +- drivers/nut-libfreeipmi.c | 150 +- drivers/nut_libusb.h | 111 + drivers/nutdrv_atcl_usb.c | 277 +- drivers/nutdrv_qx.c | 1810 +- drivers/nutdrv_qx.h | 34 +- drivers/nutdrv_qx_ablerex.c | 440 + drivers/nutdrv_qx_ablerex.h | 30 + drivers/nutdrv_qx_bestups.c | 120 +- drivers/nutdrv_qx_blazer-common.c | 83 +- drivers/nutdrv_qx_hunnox.c | 138 + drivers/nutdrv_qx_hunnox.h | 30 + drivers/nutdrv_qx_masterguard.c | 1090 + drivers/nutdrv_qx_masterguard.h | 29 + drivers/nutdrv_qx_mecer.c | 36 +- drivers/nutdrv_qx_q1.c | 2 +- drivers/nutdrv_qx_q1.h | 2 +- drivers/nutdrv_qx_voltronic-qs-hex.c | 82 +- drivers/nutdrv_qx_voltronic-qs.c | 12 + drivers/nutdrv_qx_voltronic.c | 470 +- drivers/nutdrv_siemens_sitop.c | 298 + drivers/oneac.c | 184 +- drivers/oneac.h | 7 +- drivers/openups-hid.c | 39 +- drivers/optiups.c | 138 +- drivers/phoenixcontact_modbus.c | 192 + drivers/pijuice.c | 853 + drivers/powercom-hid.c | 67 +- drivers/powercom.c | 547 +- drivers/powercom.h | 51 +- drivers/powerman-pdu.c | 29 +- drivers/powerp-bin.c | 97 +- drivers/powerp-bin.h | 2 +- drivers/powerp-txt.c | 103 +- drivers/powerp-txt.h | 2 +- drivers/powerpanel.c | 10 +- drivers/powerpanel.h | 7 +- drivers/powervar-hid.c | 147 + drivers/powervar-hid.h | 30 + drivers/powerware-mib.c | 557 +- drivers/raritan-pdu-mib.c | 94 +- drivers/raritan-px2-mib.c | 586 + .../{eaton-ats-mib.h => raritan-px2-mib.h} | 10 +- drivers/rhino.c | 823 +- drivers/richcomm_usb.c | 293 +- drivers/riello.c | 130 +- drivers/riello.h | 22 +- drivers/riello_ser.c | 124 +- drivers/riello_usb.c | 214 +- drivers/safenet.c | 21 +- drivers/safenet.h | 5 + drivers/salicru-hid.c | 276 + drivers/salicru-hid.h | 30 + drivers/serial.c | 137 +- drivers/serial.h | 30 +- drivers/skel.c | 13 +- drivers/snmp-ups-helpers.c | 106 + drivers/snmp-ups.c | 2995 +- drivers/snmp-ups.h | 268 +- drivers/socomec_jbus.c | 492 + drivers/solis.c | 1021 +- drivers/solis.h | 79 +- drivers/tripplite-hid.c | 28 +- drivers/tripplite-hid.h | 2 +- drivers/tripplite.c | 142 +- drivers/tripplite.h | 4 + drivers/tripplite_usb.c | 350 +- drivers/tripplitesu.c | 75 +- drivers/upscode2.c | 529 +- drivers/upsdrvctl.c | 134 +- drivers/upshandler.h | 8 +- drivers/usb-common.c | 135 +- drivers/usb-common.h | 434 +- drivers/usbhid-ups.c | 684 +- drivers/usbhid-ups.h | 43 +- drivers/victronups.c | 213 +- drivers/xppc-mib.c | 55 +- include/Makefile.am | 39 +- include/Makefile.in | 122 +- include/attribute.h | 73 +- include/common.h | 115 +- include/config.h.in | 564 +- include/extstate.h | 44 +- include/nut_float.h | 54 + include/nut_platform.h | 8 +- include/nut_stdint.h | 39 +- include/parseconf.h | 2 +- include/proto.h | 29 +- include/state.h | 12 +- include/str.h | 19 +- include/timehead.h | 29 +- include/upsconf.h | 29 +- install-sh | 414 +- lib/Makefile.am | 5 +- lib/Makefile.in | 86 +- lib/README | 4 +- lib/libnutclientstub.pc.in | 13 + lib/libupsclient.pc.in | 5 +- ltmain.sh | 5670 ++-- m4/ax_c___attribute__.m4 | 134 + m4/ax_c_pragmas.m4 | 983 + m4/ax_check_compile_flag.m4 | 61 + m4/ax_compare_version.m4 | 0 m4/ax_run_or_link_ifelse.m4 | 21 + m4/libtool.m4 | 2549 +- m4/ltoptions.m4 | 127 +- m4/ltsugar.m4 | 7 +- m4/ltversion.m4 | 12 +- m4/lt~obsolete.m4 | 7 +- m4/nut_arg_with.m4 | 14 +- m4/nut_check_asciidoc.m4 | 87 +- m4/nut_check_cppcheck.m4 | 34 + m4/nut_check_headers_windows.m4 | 193 + m4/nut_check_libavahi.m4 | 46 +- m4/nut_check_libfreeipmi.m4 | 39 +- m4/nut_check_libgd.m4 | 113 +- m4/nut_check_libmodbus.m4 | 187 + m4/nut_check_libneon.m4 | 37 +- m4/nut_check_libnetsnmp.m4 | 282 +- m4/nut_check_libnss.m4 | 56 +- m4/nut_check_libopenssl.m4 | 40 +- m4/nut_check_libpowerman.m4 | 50 +- m4/nut_check_libusb.m4 | 334 +- m4/nut_check_libwrap.m4 | 2 + m4/nut_check_pkgconfig.m4 | 91 + m4/nut_check_python.m4 | 128 + m4/nut_compiler_family.m4 | 241 + m4/nut_func_getnameinfo_argtypes.m4 | 96 + m4/nut_report_feature.m4 | 9 + m4/nut_stash_warnings.m4 | 77 + m4/nut_type_socklen_t.m4 | 61 +- missing | 16 +- scripts/Aix/nut.init.in | 171 + scripts/Makefile.am | 4 +- scripts/Makefile.in | 77 +- scripts/Solaris/Makefile.am | 103 +- scripts/Solaris/Makefile.in | 433 +- scripts/Solaris/README | 38 + scripts/Solaris/makelocal.sh | 12 +- scripts/Solaris/nut-driver-enumerator.xml.in | 178 + scripts/Solaris/nut-driver.xml.in | 124 + scripts/Solaris/nut-monitor.xml.in | 127 + scripts/Solaris/nut-server.xml.in | 154 + scripts/Solaris/nut.in | 29 +- scripts/Solaris/nut.xml.in | 102 + scripts/Solaris/pkginfo.in | 2 +- scripts/Solaris/postinstall.in | 129 +- scripts/Solaris/postremove.in | 19 + scripts/Solaris/precheck.py.in | 48 + scripts/Solaris/preinstall.in | 23 + scripts/Solaris/preproto.pl.in | 39 + scripts/Solaris/preremove.in | 67 +- scripts/Solaris/svc-nut-monitor.in | 56 + scripts/Solaris/svc-nut-server.in | 64 + scripts/augeas/Makefile.am | 45 +- scripts/augeas/Makefile.in | 220 +- scripts/augeas/README | 6 +- ...psconf-aug.py => gen-nutupsconf-aug.py.in} | 12 +- scripts/augeas/nutupsconf.aug.in | 64 + scripts/augeas/nutupsdconf.aug.in | 6 +- scripts/augeas/nutupsdusers.aug.in | 2 +- scripts/augeas/tests/test_nut.aug | 26 +- scripts/devd/Makefile.am | 12 + scripts/devd/Makefile.in | 88 +- scripts/devd/nut-usb.conf.in | 244 +- scripts/hotplug/Makefile.am | 10 + scripts/hotplug/Makefile.in | 86 +- scripts/hotplug/libhid.usermap | 74 +- scripts/perl/Nut.pm | 7 +- scripts/python/Makefile.am | 33 +- scripts/python/Makefile.in | 122 +- scripts/python/README | 17 +- .../{NUT-Monitor => NUT-Monitor-py2gtk2.in} | 8 +- scripts/python/app/NUT-Monitor-py3qt5.in | 944 + scripts/python/app/README | 56 +- .../python/app/icons/256x256/nut-monitor.png | Bin 0 -> 16860 bytes .../app/{ => icons/48x48}/nut-monitor.png | Bin .../python/app/icons/64x64/nut-monitor.png | Bin 0 -> 2653 bytes .../python/app/icons/scalable/nut-monitor.svg | 490 + .../python/app/nut-monitor-py2gtk2.desktop | 11 + scripts/python/app/nut-monitor-py3qt5.desktop | 11 + scripts/python/app/nut-monitor.appdata.xml | 22 +- scripts/python/app/nut-monitor.desktop | 12 - scripts/python/app/ui/aboutdialog1.ui | 108 + scripts/python/app/ui/dialog1.ui | 89 + scripts/python/app/ui/dialog2.ui | 98 + scripts/python/app/{ => ui}/gui-1.3.glade | 0 scripts/python/app/ui/window1.ui | 473 + .../python/module/{PyNUT.py => PyNUT.py.in} | 183 +- ...test_nutclient.py => test_nutclient.py.in} | 17 +- scripts/subdriver/gen-snmp-subdriver.sh | 673 +- scripts/subdriver/gen-usbhid-subdriver.sh | 14 +- scripts/systemd/Makefile.am | 31 +- scripts/systemd/Makefile.in | 273 +- scripts/systemd/README | 7 +- scripts/systemd/nut-common.tmpfiles.in | 5 + scripts/systemd/nut-driver-enumerator.path.in | 7 + .../systemd/nut-driver-enumerator.service.in | 30 + scripts/systemd/nut-driver.service.in | 10 - scripts/systemd/nut-driver.target | 8 + scripts/systemd/nut-driver@.service.in | 67 + scripts/systemd/nut-monitor.service.in | 21 +- scripts/systemd/nut-server.service.in | 24 +- scripts/systemd/nut.target | 8 + scripts/systemd/nutshutdown.in | 23 +- scripts/udev/Makefile.am | 10 + scripts/udev/Makefile.in | 88 +- scripts/udev/nut-usbups.rules.in | 94 +- scripts/ufw/Makefile.am | 2 + scripts/ufw/Makefile.in | 569 + scripts/upower/95-upower-hid.rules | 147 +- scripts/upsdrvsvcctl/Makefile.am | 13 + scripts/upsdrvsvcctl/Makefile.in | 574 + scripts/upsdrvsvcctl/README | 11 + scripts/upsdrvsvcctl/nut-driver-enumerator.sh | 1391 + .../upsdrvsvcctl/nut-driver-enumerator.sh.in | 1391 + scripts/upsdrvsvcctl/upsdrvsvcctl | 196 + scripts/upsdrvsvcctl/upsdrvsvcctl.in | 196 + server/Makefile.am | 16 +- server/Makefile.in | 173 +- server/conf.c | 143 +- server/conf.h | 6 + server/desc.c | 2 + server/desc.h | 26 + server/netcmds.h | 20 +- server/neterr.h | 40 + server/netget.c | 39 +- server/netget.h | 30 +- server/netinstcmd.c | 68 +- server/netinstcmd.h | 30 +- server/netlist.c | 8 +- server/netlist.h | 30 +- server/netmisc.c | 17 +- server/netmisc.h | 36 +- server/netset.c | 86 +- server/netset.h | 30 +- server/netssl.c | 277 +- server/netssl.h | 13 +- server/netuser.c | 58 +- server/netuser.h | 45 +- server/nut_ctype.h | 17 + server/sockdebug.c | 12 +- server/sstate.c | 99 +- server/sstate.h | 8 +- server/stype.h | 6 +- server/upsd.c | 588 +- server/upsd.h | 30 +- server/upstype.h | 8 +- server/user-data.h | 9 + server/user.c | 35 +- server/user.h | 9 + test-driver | 31 +- tests/Makefile.am | 110 +- tests/Makefile.in | 602 +- tests/NIT/Makefile.am | 26 + tests/NIT/Makefile.in | 585 + tests/NIT/README | 17 + tests/NIT/nit.sh | 853 + tests/cpputest-client.cpp | 415 + tests/cpputest.cpp | 53 +- tests/example.cpp | 25 +- tests/getvaluetest.c | 282 + tests/nut-driver-enumerator-test--ups.conf | 71 + tests/nut-driver-enumerator-test.sh | 314 + tests/nutclienttest.cpp | 525 + tests/nutlogtest.c | 65 + tools/Makefile.am | 99 +- tools/Makefile.in | 175 +- ...og2changelog.py => gitlog2changelog.py.in} | 26 +- tools/nut-ddl-dump.sh | 20 +- tools/nut-dumpdiff.sh | 35 + tools/nut-recorder.sh | 2 +- tools/nut-scanner/Makefile.am | 99 +- tools/nut-scanner/Makefile.in | 447 +- tools/nut-scanner/README | 2 + tools/nut-scanner/nut-scan.h | 60 +- tools/nut-scanner/nut-scanner.c | 740 +- tools/nut-scanner/nutscan-device.c | 58 +- tools/nut-scanner/nutscan-device.h | 6 +- tools/nut-scanner/nutscan-display.c | 51 +- tools/nut-scanner/nutscan-init.c | 195 +- tools/nut-scanner/nutscan-init.h | 2 + tools/nut-scanner/nutscan-ip.c | 270 +- tools/nut-scanner/nutscan-ip.h | 14 +- tools/nut-scanner/nutscan-serial.c | 87 +- tools/nut-scanner/nutscan-snmp.h | 69 +- tools/nut-scanner/nutscan-usb.h | 73 +- tools/nut-scanner/scan_avahi.c | 266 +- tools/nut-scanner/scan_eaton_serial.c | 336 +- tools/nut-scanner/scan_ipmi.c | 114 +- tools/nut-scanner/scan_nut.c | 431 +- tools/nut-scanner/scan_snmp.c | 916 +- tools/nut-scanner/scan_usb.c | 357 +- tools/nut-scanner/scan_xml_http.c | 631 +- tools/{nut-snmpinfo.py => nut-snmpinfo.py.in} | 64 +- tools/nut-usbinfo.pl | 137 +- 836 files changed, 137090 insertions(+), 30018 deletions(-) create mode 100644 clients/nutclientmem.cpp create mode 100644 clients/nutclientmem.h create mode 100644 docs/asciidoc.txt create mode 100644 docs/cables/Makefile.am create mode 100644 docs/cables/Makefile.in create mode 100644 docs/ci-farm-lxc-setup.txt create mode 100644 docs/config-prereqs.txt create mode 100644 docs/daisychain.txt create mode 100644 docs/man/adelsystem_cbi.8 create mode 100644 docs/man/adelsystem_cbi.txt create mode 100644 docs/man/generic_modbus.8 create mode 100644 docs/man/generic_modbus.txt create mode 100644 docs/man/huawei-ups2000.8 create mode 100644 docs/man/huawei-ups2000.txt create mode 100644 docs/man/microsol-apc.8 create mode 100644 docs/man/microsol-apc.txt create mode 100644 docs/man/nut-driver-enumerator.8 create mode 100644 docs/man/nut-driver-enumerator.txt create mode 100644 docs/man/nutdrv_siemens_sitop.8 create mode 100644 docs/man/nutdrv_siemens_sitop.txt delete mode 100644 docs/man/nutscan_scan_xml_http.txt rename docs/man/{nutscan_scan_xml_http.3 => nutscan_scan_xml_http_range.3} (54%) create mode 100644 docs/man/nutscan_scan_xml_http_range.txt create mode 100644 docs/man/phoenixcontact_modbus.8 create mode 100644 docs/man/phoenixcontact_modbus.txt create mode 100644 docs/man/pijuice.8 create mode 100644 docs/man/pijuice.txt create mode 100644 docs/man/socomec_jbus.8 create mode 100644 docs/man/socomec_jbus.txt create mode 100644 docs/man/upscli_readline_timeout.3 create mode 100644 docs/man/upscli_sendline_timeout.3 create mode 100644 docs/man/upsdrvsvcctl.8 create mode 100644 docs/man/upsdrvsvcctl.txt create mode 100644 docs/solaris-usb.txt create mode 100644 drivers/adelsystem_cbi.c create mode 100644 drivers/adelsystem_cbi.h mode change 100755 => 100644 drivers/apc-ats-mib.c mode change 100755 => 100644 drivers/apc-ats-mib.h create mode 100644 drivers/apc-iem-mib.h create mode 100644 drivers/apc-pdu-mib.c create mode 100644 drivers/apc-pdu-mib.h create mode 100644 drivers/arduino-hid.c create mode 100644 drivers/arduino-hid.h create mode 100644 drivers/bcmxcp_ser.h create mode 100644 drivers/delta_ups-hid.c create mode 100644 drivers/delta_ups-hid.h rename drivers/{eaton-ats-mib.c => eaton-ats16-nm2-mib.c} (57%) create mode 100644 drivers/eaton-ats16-nm2-mib.h create mode 100644 drivers/eaton-ats16-nmc-mib.c create mode 100644 drivers/eaton-ats16-nmc-mib.h create mode 100644 drivers/eaton-ats30-mib.c create mode 100644 drivers/eaton-ats30-mib.h delete mode 100644 drivers/eaton-mib.c delete mode 100644 drivers/eaton-mib.h create mode 100644 drivers/eaton-pdu-genesis2-mib.c create mode 100644 drivers/eaton-pdu-genesis2-mib.h create mode 100644 drivers/eaton-pdu-marlin-helpers.c create mode 100644 drivers/eaton-pdu-marlin-helpers.h create mode 100644 drivers/eaton-pdu-marlin-mib.c create mode 100644 drivers/eaton-pdu-marlin-mib.h create mode 100644 drivers/eaton-pdu-pulizzi-mib.c create mode 100644 drivers/eaton-pdu-pulizzi-mib.h create mode 100644 drivers/eaton-pdu-revelation-mib.c create mode 100644 drivers/eaton-pdu-revelation-mib.h create mode 100644 drivers/emerson-avocent-pdu-mib.c create mode 100644 drivers/emerson-avocent-pdu-mib.h create mode 100644 drivers/ever-hid.c create mode 100644 drivers/ever-hid.h create mode 100644 drivers/generic_modbus.c create mode 100644 drivers/generic_modbus.h create mode 100644 drivers/hpe-pdu-mib.c create mode 100644 drivers/hpe-pdu-mib.h create mode 100644 drivers/huawei-ups2000.c create mode 100644 drivers/legrand-hid.c create mode 100644 drivers/legrand-hid.h delete mode 100644 drivers/libusb.h rename drivers/{libusb.c => libusb0.c} (55%) create mode 100644 drivers/libusb1.c delete mode 100644 drivers/mge-shut.c delete mode 100644 drivers/mge-shut.h create mode 100644 drivers/microsol-apc.c create mode 100644 drivers/microsol-apc.h create mode 100644 drivers/microsol-common.c create mode 100644 drivers/microsol-common.h create mode 100644 drivers/nut_libusb.h create mode 100755 drivers/nutdrv_qx_ablerex.c create mode 100755 drivers/nutdrv_qx_ablerex.h create mode 100644 drivers/nutdrv_qx_hunnox.c create mode 100644 drivers/nutdrv_qx_hunnox.h create mode 100644 drivers/nutdrv_qx_masterguard.c create mode 100644 drivers/nutdrv_qx_masterguard.h create mode 100644 drivers/nutdrv_siemens_sitop.c create mode 100644 drivers/phoenixcontact_modbus.c create mode 100644 drivers/pijuice.c create mode 100755 drivers/powervar-hid.c create mode 100755 drivers/powervar-hid.h create mode 100644 drivers/raritan-px2-mib.c rename drivers/{eaton-ats-mib.h => raritan-px2-mib.h} (82%) create mode 100644 drivers/salicru-hid.c create mode 100644 drivers/salicru-hid.h create mode 100644 drivers/snmp-ups-helpers.c create mode 100644 drivers/socomec_jbus.c create mode 100644 include/nut_float.h create mode 100644 lib/libnutclientstub.pc.in mode change 100644 => 100755 ltmain.sh create mode 100644 m4/ax_c___attribute__.m4 create mode 100644 m4/ax_c_pragmas.m4 create mode 100644 m4/ax_check_compile_flag.m4 mode change 100755 => 100644 m4/ax_compare_version.m4 create mode 100644 m4/ax_run_or_link_ifelse.m4 create mode 100644 m4/nut_check_cppcheck.m4 create mode 100644 m4/nut_check_headers_windows.m4 create mode 100644 m4/nut_check_libmodbus.m4 create mode 100644 m4/nut_check_pkgconfig.m4 create mode 100644 m4/nut_check_python.m4 create mode 100644 m4/nut_compiler_family.m4 create mode 100644 m4/nut_func_getnameinfo_argtypes.m4 create mode 100644 m4/nut_stash_warnings.m4 create mode 100755 scripts/Aix/nut.init.in create mode 100644 scripts/Solaris/README create mode 100644 scripts/Solaris/nut-driver-enumerator.xml.in create mode 100644 scripts/Solaris/nut-driver.xml.in create mode 100644 scripts/Solaris/nut-monitor.xml.in create mode 100644 scripts/Solaris/nut-server.xml.in mode change 100644 => 100755 scripts/Solaris/nut.in create mode 100644 scripts/Solaris/nut.xml.in mode change 100644 => 100755 scripts/Solaris/postinstall.in create mode 100755 scripts/Solaris/postremove.in create mode 100755 scripts/Solaris/precheck.py.in create mode 100755 scripts/Solaris/preinstall.in create mode 100755 scripts/Solaris/preproto.pl.in mode change 100644 => 100755 scripts/Solaris/preremove.in create mode 100755 scripts/Solaris/svc-nut-monitor.in create mode 100755 scripts/Solaris/svc-nut-server.in rename scripts/augeas/{gen-nutupsconf-aug.py => gen-nutupsconf-aug.py.in} (96%) rename scripts/python/app/{NUT-Monitor => NUT-Monitor-py2gtk2.in} (99%) create mode 100755 scripts/python/app/NUT-Monitor-py3qt5.in create mode 100644 scripts/python/app/icons/256x256/nut-monitor.png rename scripts/python/app/{ => icons/48x48}/nut-monitor.png (100%) create mode 100644 scripts/python/app/icons/64x64/nut-monitor.png create mode 100644 scripts/python/app/icons/scalable/nut-monitor.svg create mode 100644 scripts/python/app/nut-monitor-py2gtk2.desktop create mode 100644 scripts/python/app/nut-monitor-py3qt5.desktop delete mode 100644 scripts/python/app/nut-monitor.desktop create mode 100644 scripts/python/app/ui/aboutdialog1.ui create mode 100644 scripts/python/app/ui/dialog1.ui create mode 100644 scripts/python/app/ui/dialog2.ui rename scripts/python/app/{ => ui}/gui-1.3.glade (100%) create mode 100644 scripts/python/app/ui/window1.ui rename scripts/python/module/{PyNUT.py => PyNUT.py.in} (53%) rename scripts/python/module/{test_nutclient.py => test_nutclient.py.in} (68%) create mode 100644 scripts/systemd/nut-common.tmpfiles.in create mode 100644 scripts/systemd/nut-driver-enumerator.path.in create mode 100644 scripts/systemd/nut-driver-enumerator.service.in delete mode 100644 scripts/systemd/nut-driver.service.in create mode 100644 scripts/systemd/nut-driver.target create mode 100644 scripts/systemd/nut-driver@.service.in create mode 100644 scripts/systemd/nut.target mode change 100644 => 100755 scripts/systemd/nutshutdown.in create mode 100644 scripts/ufw/Makefile.am create mode 100644 scripts/ufw/Makefile.in create mode 100644 scripts/upsdrvsvcctl/Makefile.am create mode 100644 scripts/upsdrvsvcctl/Makefile.in create mode 100644 scripts/upsdrvsvcctl/README create mode 100755 scripts/upsdrvsvcctl/nut-driver-enumerator.sh create mode 100755 scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in create mode 100755 scripts/upsdrvsvcctl/upsdrvsvcctl create mode 100755 scripts/upsdrvsvcctl/upsdrvsvcctl.in create mode 100644 tests/NIT/Makefile.am create mode 100644 tests/NIT/Makefile.in create mode 100644 tests/NIT/README create mode 100755 tests/NIT/nit.sh create mode 100644 tests/cpputest-client.cpp create mode 100644 tests/getvaluetest.c create mode 100644 tests/nut-driver-enumerator-test--ups.conf create mode 100755 tests/nut-driver-enumerator-test.sh create mode 100644 tests/nutclienttest.cpp create mode 100644 tests/nutlogtest.c rename tools/{gitlog2changelog.py => gitlog2changelog.py.in} (87%) create mode 100755 tools/nut-dumpdiff.sh rename tools/{nut-snmpinfo.py => nut-snmpinfo.py.in} (71%) diff --git a/ChangeLog b/ChangeLog index 2a1df65..669274b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15853 @@ +2022-04-04 Jim Klimov + + * configure.ac: configure.ac: cut the release of NUT v2.8.0 + * clients/Makefile.am, tools/nut-scanner/Makefile.am: tools/nut- + scanner/Makefile.am, clients/Makefile.am: bump "version-info" for + NUT v2.8.0 Development since 2.7.4 release included changes to + code structure, fought warnings, and might impact ABI/API by the + changes to arguments (specific integer types and size_t vs. + architecture-dependent choice). + +2022-04-26 Jim Klimov + + * docs/nut.dict: docs/nut.dict: update dict + * docs/download.txt: docs/download.txt: link to distro packaging wiki + page on NUT github + * docs/download.txt: docs/download.txt: update links to distro + packaging recipes and their results + * docs/download.txt: docs/download.txt: deprecate buildbot tarballs + * drivers/libusb0.c, drivers/libusb1.c: drivers/libusb{0,1}.c: report + why we could not open any HID devices Closes: #477 + +2022-04-23 Jim Klimov + + * data/driver.list.in: driver.list.in: Add HCL info for PowerWalker + VI 750T/HID (USB) Closes: #774 + * data/driver.list.in: driver.list.in: Add HCL info for PowerWalker + VI 2200 SH and 650 SHL (USB) Closes: #646 + * data/driver.list.in: driver.list.in: Add HCL info for PowerWalker + VI 2200 SHL (USB) Closes: #756 + * data/driver.list.in: driver.list.in: Add HCL info for PowerWalker + VI 650 SH (USB) Closes: #473 + * data/driver.list.in: driver.list.in: Add HCL info for PowerWalker + Basic VI 1000 SB (USB) Closes: #818 + * data/driver.list.in: driver.list.in: Add HCL info for PowerWalker + VI 3000 SCL (USB) Closes: #971 + * data/driver.list.in: driver.list.in: Add HCL info for PowerWalker + VI 1200 SHL (USB) Closes: #1270 + * data/driver.list.in: driver.list.in: Add HCL info for UPS Phasak + model 9465, renamed as P6N (USB) Closes: #1187 + * data/driver.list.in: driver.list.in: Add HCL info for Online-UPS + Xanto S700 [#1279] + * data/driver.list.in: driver.list.in: Add HCL info for Santak + MT*-PRO / Castle C*K (Serial) Closes: #1039 + * data/driver.list.in: driver.list.in: Add HCL info for Digitus + DN-170040, DN-170041, and Voltronic Power GalleonX9-RT LCD-1-3K + (USB) Closes: #1251 + * data/driver.list.in: driver.list.in: Add HCL info for Kebo + UPS-650VA (USB) from DDL + * data/driver.list.in: driver.list.in: Add HCL info for Kebo + UPS-1000D (USB) Closes: #981 + * data/driver.list.in: driver.list.in: Add HCL info for Aviem Pro + 2000VA (USB) Closes: #827 + * data/driver.list.in: driver.list.in: Add HCL info for Digitus + DN-170076 (USB) Closes: #948 + * data/driver.list.in: driver.list.in: Add HCL info for Ippon Back + Basic 850 Euro (USB) Closes: #802 + * data/driver.list.in: driver.list.in: Add HCL info for Energy + Technologies DPK1/1-3 (Serial) Closes: #762 + * data/driver.list.in: driver.list.in: Add HCL info for V7 + UPS1RM2U1500-1E UPS 1500VA Rack Mount 2U (USB) Closes: #716 + * data/driver.list.in: driver.list.in: Add HCL info for Advice PRS850 + and PRV700 Pro (USB) from DDL + * data/driver.list.in: driver.list.in: Add HCL info for Advice Top V + Pro 6-10K (USB) Closes: #744 + * data/driver.list.in: driver.list.in: Add HCL info for Tecnoware UPS + ERA PLUS 1100 (USB) Closes: #747 + * data/driver.list.in: driver.list.in: Add HCL info for Elsist UPS + Nemo2.0 160 (USB) Closes: #719 + * data/driver.list.in: driver.list.in: Add HCL info for Powercom + Raptor 2000 and RPT-600AP (USB) Closes: #633 + * data/driver.list.in: driver.list.in: Add HCL info for Eaton 9PX + 2000 RT (USB) Closes: #540 + * data/driver.list.in: driver.list.in: Add HCL info for Salicru SPS + ONE (USB) Closes: #554 + * data/driver.list.in: driver.list.in: Add HCL info for APC + SMC2200BI-BR (USB) Closes: #557 + * data/driver.list.in: driver.list.in: Update comment for APC Back- + UPS Pro 1000, Model BX1000M (USB) [nut#139] + * data/driver.list.in: driver.list.in: Add HCL info for Liebert + PowerSure PSA 500 series (USB) Closes: #601 + * docs/man/usbhid-ups.txt: docs/man/usbhid-ups.txt: document some + caveats with CyberPower UPSes [issues #520, #1394] + * data/driver.list.in: driver.list.in: Update for CyberPower Systems + OR1500ERM1U [#1338] + * data/driver.list.in: driver.list.in: Update comment for CyberPower + Systems PR1500RT2U [#1191] + * data/driver.list.in: driver.list.in: Add HCL info for CyberPower + Systems CP850PFCLCD (USB) Closes: #605 + * data/driver.list.in: driver.list.in: Add HCL info for CyberPower + Systems BL1250U (USB) Closes: #1012 + * data/driver.list.in: driver.list.in: Add HCL info for CyberPower + Systems RT650EI (USB) Closes: #453 + * data/driver.list.in: driver.list.in: Add HCL info for CyberPower + Systems CP1500PFCLCD (USB) Closes: #520 + * data/driver.list.in: driver.list.in: Add HCL info for CyberPower + Systems BR1000ELCD (USB) Closes: #552 + * data/driver.list.in: driver.list.in: Add HCL info for CyberPower + Systems UT2200E (USB) Closes: #556 + * data/driver.list.in: driver.list.in: Add HCL info for CyberPower + Systems OR500LCDRM1U (USB) Closes: #578 + * data/driver.list.in: driver.list.in: Add HCL info for CyberPower + Systems EC850LCD (USB) Closes: #622 + * data/driver.list.in: driver.list.in: Add HCL info for Guardian LCD + 1500 AP (IGA1500LCD) (Serial) Closes: #449 + * data/driver.list.in: driver.list.in: Add HCL info for Ablerex MARS + MS3000RT (Serial) Closes: #449 + * data/driver.list.in: driver.list.in: Add HCL info for APC AP9584 + Serial-to-USB kit Closes: #181 + * data/driver.list.in: driver.list.in: Update comment for Tripp_Lite + SMX500RT1U (USB) [#584] + * data/driver.list.in: driver.list.in: Add HCL info for Huawei + UPS2000 series (modbus) [#954 #1066 #1198 #1017] + * data/driver.list.in: driver.list.in: Add HCL info for DEXP MIX + 850VA (USB) Closes: #721 + * data/driver.list.in: driver.list.in: Add HCL info for CPC, ARES and + Powercool models with hunnox protocol (USB) Closes: #537 + * data/driver.list.in: driver.list.in: Add HCL info for Greencell + Micropower 600 (USB) Closes: #1080 + * data/driver.list.in: driver.list.in: Add HCL info for Crown CMU- + SP1200IEC (USB) Closes: #1014 + * data/driver.list.in: driver.list.in: Add HCL info for DigiTECH + 650VA (USB) Closes: #674 + * data/driver.list.in: driver.list.in: Add HCL info for Hunnox + devices (and new protocol subdriver) (USB) [#638] + * data/driver.list.in: driver.list.in: Add HCL info for nJoy Aten PRO + 3000 (SNMP) Closes: #1281 + +2022-04-25 Jim Klimov + + * docs/nut.dict: docs/nut.dict: add wc + * docs/nut.dict: docs/nut.dict: add uniq + +2022-04-25 Jim Klimov + + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: add a + CI_BUILDDIR=obj into docs scenario; name "out-of-tree builds" as + such + +2022-04-24 Jim Klimov + + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: run some tests with + CI_BUILDDIR + * .gitignore, ci_build.sh: ci_build.sh: prepare for CI_BUILDDIR=obj + * ci_build.sh: ci_build.sh: introduce CI_BUILDDIR to handle out-of- + tree builds other than distcheck + * docs/man/Makefile.am, docs/man/index.txt, docs/man/nutupsdrv.txt, + docs/man/upsd.txt, docs/nut.dict: docs/man/nutupsdrv.txt + + index.txt + upsd.txt: use {builddir}/linkman-*.txt for included + data + * docs/man/Makefile.am: docs/man/Makefile.am: refactor + LINKMAN_INCLUDE_CONSUMERS + * docs/man/Makefile.am: docs/man/Makefile.am: introduce A2X_VERBOSE + * docs/nut-qa.txt, docs/nut.dict: docs/nut-qa.txt: mention "make + check-NIT-devel" helper target + * docs/man/victronups.txt: docs/man/victronups.txt: update link to + cable pinout Closes: #1371 + * configure.ac: configure.ac: fix enableval vs withval + * drivers/bcmxcp_usb.c, drivers/blazer_usb.c, drivers/nutdrv_qx.c, + drivers/richcomm_usb.c, drivers/riello_usb.c, + drivers/tripplite_usb.c, drivers/usb-common.c, drivers/usb- + common.h, drivers/usbhid-ups.c: drivers/usb-common.{h,c} and USB- + capable drivers: introduce warn_if_bad_usb_port_filename() Closes: + #1368 + * ci_build.sh: ci_build.sh: disable check-NIT by default in CI runs + for now + +2022-04-23 Jim Klimov + + * drivers/main.c: drivers/main.c: simplify detection of PROGNAME="lt- + DRIVERNAME" making it more reliable for some platforms + +2022-04-18 Jim Klimov + + * drivers/cyberpower-mib.c: drivers/cyberpower-mib.c: update + cyberpower_power_status[] with new values [#1377] + +2022-04-23 Jim Klimov + + * data/driver.list.in: Update driver.list.in + +2022-04-23 Jim Klimov + + * configure.ac: configure.ac: fix nut_enable_check_NIT + * ci_build.sh: ci_build.sh: "--enable-check-NIT" and "--enable- + maintainer-mode" for developer builds without a BUILD_TYPE + * ci_build.sh: ci_build.sh: "--enable-check-NIT" for CI builds + * tests/NIT/nit.sh: tests/NIT/nit.sh: fix renaming typo + * tests/NIT/nit.sh: tests/NIT/nit.sh: remove mktemp-ed TESTDIR when + we exit + * tests/NIT/nit.sh: tests/NIT/nit.sh: refactor with TESTDIR + * clients/upssched.c, common/common.c, drivers/clone-outlet.c, + drivers/clone.c, drivers/dstate.c, include/common.h, + server/sockdebug.c, server/sstate.c: check_unix_socket_filename() + to meaningfully abort when our paths are too long + * docs/man/clone.txt, docs/man/dummy-ups.txt: docs/man/clone.txt + + dummy-ups.txt: clarify the dependency caveats Clone drivers do not + require to run after upsd, but may need to start after the "real" + driver whose socket thay leech onto. + * tests/NIT/nit.sh: tests/NIT/nit.sh: limit how long we wait for + UPS1/UPS2 to begin responding + * configure.ac, docs/configure.txt, docs/nut-qa.txt, + tests/NIT/Makefile.am: tests/NIT/Makefile.am + configure.ac: + introduce --enable-check-NIT + * docs/man/dummy-ups.txt: docs/man/dummy-ups.txt: re-wrap long lines + and reword + * docs/man/dummy-ups.txt: docs/man/dummy-ups.txt: highlight that + upsrw can not define new variables + * docs/man/dummy-ups.txt: docs/man/dummy-ups.txt: update notes for + dummy-once mode ability to re-read file only if it changes + * docs/man/dummy-ups.txt: docs/man/dummy-ups.txt: update notes for + dummy-once mode + * docs/man/clone.txt, docs/man/dummy-ups.txt: docs/man/dummy-ups.txt + + clone.txt: cross-link two man pages to remind about similar use- + cases + +2022-04-23 Jim Klimov + + * data/driver.list.in: driver.list.in: Add HCL info for nJoy Keen 600 + (USB) Closes: #867 + +2022-04-22 Jim Klimov + + * tests/NIT/nit.sh: tests/NIT/nit.sh: + testcase_sandbox_upsc_query_timer(): do not waste time if we did + get the answer we want + * tests/NIT/nit.sh: tests/NIT/nit.sh: + testcase_sandbox_upsc_query_timer(): for slower testers out there, + wait one more cycle + * tests/NIT/nit.sh: tests/NIT/nit.sh: ignore message from NSS builds + Those tend to add lines like Init SSL without certificate database + so we should better grep for expected char sequence + +2022-04-22 Paweł Rapkiewicz + + * data/driver.list.in, drivers/ever-hid.c, scripts/upower/95-upower- + hid.hwdb: Confirm support for ECO Pro AVR CDS series EVER UPS This + commit confirms that EVER UPS line 'ECO Pro AVR CDS' is supported + by NUT, from nowon, nut-scanner will recognize EVER Ups as follows: + [nutdev1] driver = "usbhid-ups" port = "auto" vendorid = "2E51" + productid = "0000" product = "ECO PRO AVR CDS" serial = + "XXXXXXXXXXXXXXXXXXXXXXXXX" vendor = "EVER" bus = "003" + +2022-04-22 Jim Klimov + + * tests/NIT/nit.sh: tests/NIT/nit.sh: add + testgroup_sandbox_cppnit_simple_admin() to troubleshoot dummy-ups + data propagation + * tests/NIT/nit.sh: tests/NIT/nit.sh: + testcase_sandbox_start_drivers_after_upsd(): wait for UPS1 and UPS2 + to respond + * tests/cpputest-client.cpp: tests/cpputest-client.cpp: allow up to + 10 seconds for SET VAR to propagate into read-back value + * tests/.gitignore: GitIgnore tests/cppnit binary and logs + * docs/nut.dict: Update nut.dict + * tests/NIT/nit.sh: tests/NIT/nit.sh: refactor test cases into + smaller routines and groups, and allow to select NIT_CASE + optionally + * tests/NIT/nit.sh: tests/NIT/nit.sh: refactor stop_daemons() + * Makefile.am, tests/Makefile.am, tests/NIT/Makefile.am: + tests/NIT/Makefile.am: extend with check-NIT-devel for iterating + * drivers/dstate.c: drivers/dstate.c: log start of processing in + sock_arg() + * drivers/dstate.c: drivers/dstate.c: whitespace fix + * tests/NIT/nit.sh: tests/NIT/nit.sh: allow to tweak NUT_DEBUG_MIN + * tests/cpputest-client.cpp: tests/cpputest-client.cpp: trace values + read back after setting + * tests/cpputest-client.cpp: tests/cpputest-client.cpp: rename "s1" + original value reading + * scripts/python/Makefile.am: scripts/python/Makefile.am: clean *.pyc + and __pycache__/ if present + +2022-04-21 Jim Klimov + + * drivers/dummy-ups.c: drivers/dummy-ups.c: fix dummy-once mode for + relative path in port + * tests/NIT/nit.sh: tests/NIT/nit.sh: name the "dummy.seq" so it + loops by default + * drivers/main.c: drivers/main.c: better fix for handling of libtool- + named binaries + * tests/NIT/nit.sh: tests/NIT/nit.sh: if "Error: Driver not + connected" retry with UPSD started after drivers are running + * drivers/main.c: drivers/main.c: fix the handling of libtool-named + binaries + * tests/NIT/nit.sh: tests/NIT/nit.sh: "sed -i" requires an extension + (may be empty, in BSD must be a separate CLI token, in others must + be same token - not empty is ok for all) + * tests/NIT/nit.sh: tests/NIT/nit.sh: "sed -i" requires an extension + (may be empty, in BSD must be a separate CLI token) + * drivers/dummy-ups.c: drivers/dummy-ups.c: cover exhaustive + case(enum) with pragmas for diametral warnings + * tests/NIT/nit.sh: tests/NIT/nit.sh: extend with mode=... for dummy- + ups [#1385] + * NEWS, UPGRADING, docs/man/dummy-ups.txt, drivers/dummy-ups.c: + dummy-ups: do re-read a "dummy-once" file, though only if it + changes while the driver runs r the commit message for your + changes. Lines starting + * NEWS, UPGRADING, docs/man/dummy-ups.txt, drivers/dummy-ups.c: + dummy-ups: separate MODE_DUMMY_ONCE from MODE_DUMMY_LOOP Closes: + #1385 + * docs/man/dummy-ups.txt: docs/man/dummy-ups.txt: small rewording + * drivers/dummy-ups.c: drivers/dummy-ups.c: refactor "mode" from + random defines to an enum + * common/str.c, include/str.h: include/str.h, common/str.c: add + str_ends_with() + * tests/NIT/nit.sh: tests/NIT/nit.sh: make sure ups.status is not + pre-defined empty in test sandbox + * tests/cpputest-client.cpp: tests/cpputest-client.cpp: + test_auth_user(): bail out if "ups.status" reply is empty + * tests/NIT/nit.sh: tests/NIT/nit.sh: report DEBUG_SLEEP mode more + usefully + * tests/NIT/nit.sh: tests/NIT/nit.sh: spell out 127.0.0.1 and ::1 if + detected supported on local system - do not rely on ping CLI alone + * tests/NIT/nit.sh: tests/NIT/nit.sh: spell out 127.0.0.1 and ::1 if + detected supported on local system + +2022-04-20 Jim Klimov + + * tests/NIT/nit.sh: tests/NIT/nit.sh: report issues more usefully for + troubleshooting CI + * tests/NIT/Makefile.am: tests/NIT/Makefile.am: use more portable + clumsier code + * drivers/main.c: drivers/main.c: accept "lt-PROGNAME" to run + libtool-wrapped builds during development + * tests/NIT/nit.sh: tests/NIT/nit.sh: Avoid dummies with TIMER flip- + flops for cppnit if we can + * tests/Makefile.am: tests/Makefile.am: do not run "cppnit" as part + of TESTS, only give a recipe to build it + * clients/nutclient.h, tests/Makefile.am, tests/NIT/nit.sh, + tests/cpputest-client.cpp: NutActiveClientTest: introduce C++ + NutActiveClientTest for NIT and similar uses + * tests/NIT/nit.sh: tests/NIT/nit.sh: log OVERALL results before + DEBUG_SLEEP + * tests/NIT/nit.sh: tests/NIT/nit.sh: refactor upsd.users passwords + as shell vars to ease reuse + * tests/NIT/nit.sh: tests/NIT/nit.sh: check that test_nutclient.py + was generated before running it; export NUT_PORT just once + * tests/NIT/nit.sh: tests/NIT/nit.sh: embed weak randomization of + NUT_PORT At least this little magic is better than a hardcoded + number: if several CI executors run `make check` at once on same + host, they now have a decent chance to not collide (not guaranteed + though) + * tests/NIT/nit.sh: tests/NIT/nit.sh: let caller customize NUT_PORT + * Makefile.am, configure.ac, tests/Makefile.am, tests/NIT/.gitignore, + tests/NIT/Makefile.am: Add tests/NIT/Makefile.am for + straightforward integration of the test suite + * configure.ac, tests/Makefile.am: configure.ac: fix detection of + cppunit on some platforms Note for posterity: CFLAGS go before + source, LDFLAGS+LIBS after source, in g++ cmdline + * Makefile.am: Makefile.am: fix "make check-docs" and siblings from + root dir + * Makefile.am: Makefile.am: let "make check-NIT" from root dir + * tests/NIT/README, tests/NIT/nit.sh: tests/NIT: warn in + docs/comments that starting pwd should be the BUILDDIR + * tests/Makefile.am: tests/Makefile.am: help check-NIT pass in + distcheck (cleaner) + * tests/NIT/README, tests/NIT/nit.sh: tests/NIT/README: update a bit + * tests/Makefile.am: tests/Makefile.am: help check-NIT pass in + distcheck + * docs/nut-qa.txt: docs/nut-qa.txt: mention NUT NIT and update links + to Ubuntu QART + * tests/NIT/nit.sh: tests/NIT/nit.sh: make some debug noise optional + * tests/NIT/nit.sh: tests/NIT/nit.sh: typo fix for SRCDIR + * tests/NIT/nit.sh: tests/NIT/nit.sh: sanity checks for BUILDDIR + * tests/NIT/nit.sh: tests/NIT/nit.sh: bail out quickly if got no + daemons to run + * tests/Makefile.am: tests/Makefile.am: call NIT suite + * tests/NIT/nit.sh: tests/NIT/nit.sh: document DEBUG_SLEEP a bit + +2022-04-19 Jim Klimov + + * tests/NIT/.gitignore, tests/NIT/README, tests/NIT/nit.sh: NIT: NUT + Integration Tests (usable PoC) [another take at issue #3] + * clients/upsrw.c, docs/man/upsrw.txt: upsrw: accept "-l" for listing + Closes: #1382 + * scripts/python/module/test_nutclient.py.in: test_nutclient.py.in: + allow to override NUT_PORT, NUT_USER, NUT_PASS + * conf/ups.conf.sample: conf/ups.conf.sample: update with info from + docs/man/ups.conf.txt + +2022-04-18 Jim Klimov + + * clients/nutclient.cpp: clients/nutclient.{cpp,h}: + deviceMaster()/devicePrimary(): add fallback handling with the + other keyword [#840, #1374] + * clients/nutclient.cpp, clients/nutclient.h, + clients/nutclientmem.cpp, clients/nutclientmem.h, + docs/man/libnutclient_misc.txt: clients/nutclient{mem}.{cpp,h} + docs/man/libnutclient_misc.txt: add PRIMARY handling [#840] + Closes: #1374 + * clients/nutclient.cpp, clients/nutclient.h, + docs/man/libnutclient_tcp.txt: clients/nutclient.{cpp,h} + docs/man/libnutclient_tcp.txt: fix timeout from long to time_t + Closes: #1376 + * clients/upsc.c, clients/upsclient.c, clients/upsclient.h, + clients/upscmd.c, clients/upsimage.c, clients/upslog.c, + clients/upsmon.h, clients/upsrw.c, clients/upsset.c, + clients/upsstats.c, docs/man/upscli_connect.txt, drivers/dummy- + ups.c: clients/upsclient.{c,h} and many clients + dummy-ups: fix + port from int to uint16_t Closes: #1379 + * docs/man/libnutclient_variables.txt: + docs/man/libnutclient_variables.txt: fix English + * clients/upsclient.h: clients/upsclient.h: fix whitespace + * clients/upsclient.c, clients/upsclient.h, + docs/man/upscli_readline.txt, docs/man/upscli_sendline.txt: + clients/upsclient.{c,h} docs/man/upscli_{read,send}line.txt: fix + timeout from long to time_t Closes: #1373 + * clients/nutclient.cpp, clients/nutclient.h, + docs/man/libnutclient_tcp.txt, docs/nut.dict: + clients/nutclient.{cpp,h}: fix port type from unsigned short to + uint16_t Closes: #1375 + * docs/man/Makefile.am: docs/man/Makefile.am: `$( + + * docs/man/Makefile.am: docs/man/Makefile.am: abstract filenames into + LINKMAN_INCLUDE_GENERATED macro + +2022-04-16 Jim Klimov + + * docs/man/Makefile.am: docs/man/Makefile.am: DOCBUILD_BEGIN: work + around older BSD make not seeing sources not present in builddir + It seems to resolve single-source documents well, but fails to find + the upsd.txt which depends on linkman*-names.txt and build a proper + relative path to it. + * docs/man/Makefile.am: docs/man/Makefile.am: ensure linkman- + drivertool*names.txt are in builddir + * docs/man/Makefile.am: docs/man/Makefile.am: ensure linkman- + drivertool*names.txt are in A2X_OUTDIR + * docs/man/Makefile.am: docs/man/Makefile.am: avoid spurious + regeneration of linkman-drivertool*names.txt whenever we reference + them + * docs/man/Makefile.am: docs/man/Makefile.am: generate linkman- + drivertool*names.txt independent of current dir being srcdir + * ci_build.sh: ci_build.sh: "cat" the "git diff" + +2022-04-15 Jim Klimov + + * docs/man/libnutclient_general.txt, docs/man/libnutclient_misc.txt, + docs/man/libnutclient_tcp.txt, docs/man/libnutclient_variables.txt, + docs/man/libupsclient-config.txt, docs/nut.dict: + docs/man/libnutclient*.txt: wrap long lines, minor rephrase, bullet + points + * docs/man/libnutclient_commands.txt, + docs/man/libnutclient_devices.txt: + docs/man/libnutclient_devices.txt, libnutclient_commands.txt: + synopsis for strarr + * docs/man/libnutclient_devices.txt: + docs/man/libnutclient_devices.txt: wrap long lines, minor rephrase, + bullet points + * docs/man/libnutclient_commands.txt: + docs/man/libnutclient_commands.txt: wrap long lines, minor + rephrase, bullet points; added optional param arg in API + * docs/man/upscli_strerror.txt: docs/man/upscli_strerror.txt: fix + return type modifier to const + * docs/man/upscli_add_host_cert.txt, docs/man/upscli_cleanup.txt, + docs/man/upscli_disconnect.txt, docs/man/upscli_fd.txt, + docs/man/upscli_get.txt, docs/man/upscli_init.txt, + docs/man/upscli_list_next.txt, docs/man/upscli_readline.txt, + docs/man/upscli_sendline.txt, docs/man/upscli_splitaddr.txt: + docs/man/upscli*.txt: wrap long lines, minor rephrase + * docs/man/nutscan_init.txt, docs/man/nutscan_new_device.txt, + docs/man/nutscan_scan_usb.txt: docs/man/nutscan*.txt: document + methods with (void) arg list as such + * docs/man/Makefile.am, docs/man/index.txt, docs/man/nutscan.txt, + docs/man/nutscan_add_device_to_device.txt, + docs/man/nutscan_add_option_to_device.txt, + docs/man/nutscan_cidr_to_ip.txt, + docs/man/nutscan_display_parsable.txt, + docs/man/nutscan_display_ups_conf.txt, + docs/man/nutscan_free_device.txt, + docs/man/nutscan_get_serial_ports_list.txt, + docs/man/nutscan_init.txt, docs/man/nutscan_new_device.txt, + docs/man/nutscan_scan_avahi.txt, + docs/man/nutscan_scan_eaton_serial.txt, + docs/man/nutscan_scan_ipmi.txt, docs/man/nutscan_scan_nut.txt, + docs/man/nutscan_scan_snmp.txt, docs/man/nutscan_scan_usb.txt, + docs/man/nutscan_scan_xml_http.txt, + docs/man/nutscan_scan_xml_http_range.txt: + docs/man/nutscan_scan_xml_http_range.txt: document the method which + got extended from original nutscan_scan_xml_http() doing just a + local broadcast + * docs/man/nutscan_scan_ipmi.txt: docs/man/nutscan_scan_ipmi.txt: + document the method which now is implemented + * docs/man/nutscan.txt, docs/man/nutscan_add_device_to_device.txt, + docs/man/nutscan_add_option_to_device.txt, + docs/man/nutscan_cidr_to_ip.txt, docs/man/nutscan_free_device.txt, + docs/man/nutscan_get_serial_ports_list.txt, + docs/man/nutscan_init.txt, docs/man/nutscan_new_device.txt, + docs/man/nutscan_scan_avahi.txt, + docs/man/nutscan_scan_eaton_serial.txt, + docs/man/nutscan_scan_nut.txt, docs/man/nutscan_scan_snmp.txt, + docs/man/nutscan_scan_usb.txt, docs/man/nutscan_scan_xml_http.txt: + docs/man/nutscan*.txt: wrap long lines, minor rephrase, fix + timeouts to useconds_t + * docs/nut.dict: docs/nut.dict: spellcheck drivertool + * docs/man/apcsmart-old.txt, docs/man/apcsmart.txt, + docs/man/asem.txt, docs/man/bcmxcp_usb.txt, docs/man/liebert- + esp2.txt, docs/man/macosx-ups.txt, docs/man/microsol-apc.txt, + docs/man/nut.conf.txt, docs/man/nutdrv_atcl_usb.txt, + docs/man/nutdrv_qx.txt, docs/man/nutdrv_siemens_sitop.txt, + docs/man/oneac.txt, docs/man/optiups.txt, docs/man/upscode2.txt, + docs/man/usbhid-ups.txt: docs/man/*.txt: reformat AUTHOR(S) and + INTERNET RESOURCES blocks to common style + * docs/man/upsdrvsvcctl.txt: docs/man/upsdrvsvcctl.txt: list Jim + Klimov as the AUTHOR + * docs/man/nut-driver-enumerator.txt: docs/man/nut-driver- + enumerator.txt: list Jim Klimov as the AUTHOR + * docs/man/snmp-ups.txt: docs/man/snmp-ups.txt: list AUTHORS as a + bulleted list and add Jim Klimov + * docs/man/snmp-ups.txt: docs/man/snmp-ups.txt: wrap long lines and + reword a bit + * docs/man/optiups.txt: docs/man/optiups.txt: wrap long lines + * docs/man/phoenixcontact_modbus.txt: + docs/man/phoenixcontact_modbus.txt: wrap long lines + * docs/man/belkinunv.txt: docs/man/belkinunv.txt: add link to + protocol description copy on NUT site + * docs/support.txt: docs/support.txt: mention github instead of + subversion + * docs/man/.gitignore, docs/man/Makefile.am, docs/man/index.txt, + docs/man/nutupsdrv.txt, docs/man/upsd.txt: docs/man/index.txt, + upsd.txt, nutupsdrv.txt: generate the up-to-date list of drivers, + current for each iteration + * docs/man/index.txt, docs/man/nutupsdrv.txt, docs/man/upsd.txt: + docs/man/upsd.txt, nutupsdrv.txt, index.txt: move common + nutupsdrv[8] from the bulk of driver list + * docs/man/nutupsdrv.txt, docs/man/upsd.txt: docs/man/upsd.txt, + nutupsdrv.txt: generate current list of drivers + * docs/man/index.txt: docs/man/index.txt: generate current list of + drivers, separate "Driver Control" title + * docs/man/nutupsdrv.txt, docs/man/upsd.txt: docs/man/upsd.txt, + nutupsdrv.txt: reformat lists of drivers and tools to bullet lists + * docs/Makefile.am: docs/Makefile.am: DOCBUILD_BEGIN: symlink images/ + ONLY for PDF generation + * ci_build.sh: ci_build.sh: add notes to Consider `--enable- + maintainer-mode` + * .gitignore: GitIgnore IDEA metadata files + * docs/.gitignore: GitIgnore more intermediate XML files from docs + generation + +2022-04-14 Jim Klimov + + * docs/man/nutscan_display_parsable.txt, + docs/man/nutscan_display_ups_conf.txt, + docs/man/nutscan_free_device.txt, + docs/man/nutscan_get_serial_ports_list.txt: docs/man/nutscan*.txt: + fix formatting and typos + * docs/man/upscli_get.txt, docs/man/upscli_init.txt, + docs/man/upscli_list_start.txt: docs/man/upscli*.txt: fix sample + source formatting + * docs/man/upsmon.txt: docs/man/upsmon.txt: reword a dangling + sentence + * docs/man/tripplite_usb.txt: docs/man/tripplite_usb.txt: fix + formatting + * docs/man/riello_ser.txt: docs/man/riello_ser.txt: fix formatting + * docs/man/riello_usb.txt: docs/man/riello_usb.txt: fix formatting + * docs/man/snmp-ups.txt: docs/man/snmp-ups.txt: fix sample source + formatting + * docs/man/socomec_jbus.txt: docs/man/socomec_jbus.txt: fix + formatting and typos + * docs/man/Makefile.am, docs/nut.dict: docs/man/Makefile.am: list the + socomec_jbus.txt + * docs/man/pijuice.txt: docs/man/pijuice.txt: fix formatting + * docs/man/nutdrv_qx.txt: docs/man/nutdrv_qx.txt: fix formatting + * docs/man/nutdrv_atcl_usb.txt: docs/man/nutdrv_atcl_usb.txt: fix + formatting + * docs/man/nut.conf.txt: docs/man/nut.conf.txt: fix sample source + formatting + * docs/man/mge-utalk.txt: docs/man/mge-utalk.txt: fix formatting + * docs/man/liebert-esp2.txt: docs/man/liebert-esp2.txt: fix + formatting + * docs/man/clone.txt: docs/man/clone.txt: fix sample source + formatting + * docs/man/bestups.txt, docs/man/blazer-common.txt, + docs/man/masterguard.txt: docs/man/blazer-common.txt, + masterguard.txt, bestups.txt: fix formatting [#1361] + * docs/man/adelsystem_cbi.txt: docs/man/adelsystem_cbi.txt: fix + formatting + * docs/sock-protocol.txt: docs/sock-protocol.txt: fix formatting + * docs/snmp-subdrivers.txt: docs/snmp-subdrivers.txt: small typo + * docs/packager-guide.txt: docs/packager-guide.txt: reshuffle known + names + * docs/nut-qa.txt: docs/nut-qa.txt: list a few more tools we use + * TODO, docs/nut-qa.txt: Fix remaining links to asciidoc.org + * docs/nut-names.txt: docs/nut-names.txt: fix table formatting + * docs/new-clients.txt: docs/new-clients.txt: fix sample source + formatting + * docs/net-protocol.txt: docs/net-protocol.txt: fix version table + formatting + * docs/FAQ.txt: docs/FAQ.txt: fix formatting, extend some notes + * docs/nut.dict: Update nut.dict + * docs/developers.txt: docs/developers.txt: fix formatting, extend + some notes + * docs/developer-guide.txt: docs/developer-guide.txt: fix formatting; + update URL to evolution500.seq + * docs/design.txt: docs/design.txt: fix formatting; note FIXMEs for + documenting TRACKING support + * docs/daisychain.txt: docs/daisychain.txt: fix formatting + * drivers/snmp-ups.h: drivers/snmp-ups.h: update comment to clarify + the meaning of SU_TYPE_DAISY_1 and SU_TYPE_DAISY_2 + * docs/configure.txt: docs/configure.txt: fix formatting, add titles, + extend some notes + * docs/configure.txt: docs/configure.txt: add a section on modbus + drivers + * docs/configure.txt: docs/configure.txt: link to powerman project + * docs/configure.txt: docs/configure.txt: fix formatting, add driver + type titles, extend some notes + * docs/config-prereqs.txt: docs/config-prereqs.txt: fix formatting, + extend some notes + +2022-04-14 Jim Klimov + + * docs/Makefile.am: docs/Makefile.am: A2X_COMMON_OPTS: use "-- + attribute=..." consistently + * docs/Makefile.am: docs/Makefile.am: have "images/" in A2X_OUTDIR + (fallout of #1152) Closes: #1365 + +2022-04-14 Jim Klimov + + * docs/solaris-usb.txt: docs/solaris-usb.txt: drop suggestions about + building special libusb-1.0/0.1 branches + * docs/solaris-usb.txt: docs/solaris-usb.txt: fix formatting, extend + some notes + * docs/solaris-usb.txt: docs/solaris-usb.txt: add a NOTE for USB + drivers ignoring port option [#1368] + * docs/config-notes.txt: docs/config-notes.txt: fix formatting, + extend some notes and warnings, and service-driven life-cycle + * docs/config-notes.txt: docs/config-notes.txt: document + ALLOW_NO_DEVICE for upsd.conf [#766, #837] + * docs/config-notes.txt: docs/config-notes.txt: reformat and extend + the NOTE for USB drivers ignoring port option [#1368] + * ci_build.sh, docs/ci-farm-lxc-setup.txt, docs/nut.dict: docs/ci- + farm-lxc-setup.txt: fix formatting, extend on Jenkins agent setup + * ci_build.sh: ci_build.sh: use "gmake" for "./ci_build.sh + spellcheck" if available and no particular MAKE was requested - + fall back to "make" if "gmake" is not available + +2022-04-13 Jim Klimov + + * docs/asciidoc.txt: docs/asciidoc.txt: update link to the Asciidoc + Manual (and project now on github) + +2022-04-12 Jim Klimov + + * Makefile.am: Makefile.am: define dependencies between recipes for + dist* and package; tarball, sig and checksum filenames + +2022-04-10 Jim Klimov + + * docs/daisychain.txt, docs/man/adelsystem_cbi.txt, + docs/man/al175.txt, docs/man/apcsmart-old.txt, + docs/man/apcsmart.txt, docs/man/apcupsd-ups.txt, docs/man/asem.txt, + docs/man/bcmxcp.txt, docs/man/bcmxcp_usb.txt, docs/man/belkin.txt, + docs/man/belkinunv.txt, docs/man/bestfcom.txt, + docs/man/bestfortress.txt, docs/man/bestuferrups.txt, + docs/man/bestups.txt, docs/man/blazer-common.txt, + docs/man/clone.txt, docs/man/dummy-ups.txt, docs/man/etapro.txt, + docs/man/everups.txt, docs/man/gamatronic.txt, + docs/man/generic_modbus.txt, docs/man/genericups.txt, + docs/man/hosts.conf.txt, docs/man/huawei-ups2000.txt, + docs/man/isbmex.txt, docs/man/ivtscd.txt, + docs/man/libnutclient.txt, docs/man/libnutclient_commands.txt, + docs/man/libnutclient_devices.txt, + docs/man/libnutclient_general.txt, docs/man/libnutclient_misc.txt, + docs/man/libnutclient_tcp.txt, docs/man/libnutclient_variables.txt, + docs/man/libupsclient-config.txt, docs/man/liebert-esp2.txt, + docs/man/liebert.txt, docs/man/macosx-ups.txt, + docs/man/masterguard.txt, docs/man/metasys.txt, docs/man/mge- + shut.txt, docs/man/mge-utalk.txt, docs/man/microdowell.txt, + docs/man/microsol-apc.txt, docs/man/netxml-ups.txt, docs/man/nut- + driver-enumerator.txt, docs/man/nut-ipmipsu.txt, docs/man/nut- + recorder.txt, docs/man/nut-scanner.txt, docs/man/nut.conf.txt, + docs/man/nutdrv_atcl_usb.txt, docs/man/nutdrv_siemens_sitop.txt, + docs/man/nutscan.txt, docs/man/nutscan_add_device_to_device.txt, + docs/man/nutscan_add_option_to_device.txt, + docs/man/nutscan_cidr_to_ip.txt, + docs/man/nutscan_display_parsable.txt, + docs/man/nutscan_display_ups_conf.txt, + docs/man/nutscan_free_device.txt, + docs/man/nutscan_get_serial_ports_list.txt, + docs/man/nutscan_init.txt, docs/man/nutscan_new_device.txt, + docs/man/nutscan_scan_avahi.txt, + docs/man/nutscan_scan_eaton_serial.txt, + docs/man/nutscan_scan_ipmi.txt, docs/man/nutscan_scan_nut.txt, + docs/man/nutscan_scan_snmp.txt, docs/man/nutscan_scan_usb.txt, + docs/man/nutscan_scan_xml_http.txt, docs/man/nutupsdrv.txt, + docs/man/oneac.txt, docs/man/optiups.txt, + docs/man/phoenixcontact_modbus.txt, docs/man/pijuice.txt, + docs/man/powercom.txt, docs/man/powerman-pdu.txt, + docs/man/powerpanel.txt, docs/man/rhino.txt, + docs/man/richcomm_usb.txt, docs/man/riello_ser.txt, + docs/man/riello_usb.txt, docs/man/safenet.txt, docs/man/skel.txt, + docs/man/snmp-ups.txt, docs/man/socomec_jbus.txt, + docs/man/solis.txt, docs/man/tripplite.txt, + docs/man/tripplite_usb.txt, docs/man/tripplitesu.txt, + docs/man/ups.conf.txt, docs/man/upsc.txt, + docs/man/upscli_add_host_cert.txt, docs/man/upscli_cleanup.txt, + docs/man/upscli_connect.txt, docs/man/upscli_disconnect.txt, + docs/man/upscli_get.txt, docs/man/upscli_init.txt, + docs/man/upscli_list_next.txt, docs/man/upscli_list_start.txt, + docs/man/upscli_readline.txt, docs/man/upscli_sendline.txt, + docs/man/upscli_splitname.txt, docs/man/upsclient.txt, + docs/man/upscmd.txt, docs/man/upscode2.txt, docs/man/upsd.conf.txt, + docs/man/upsd.txt, docs/man/upsd.users.txt, docs/man/upsdrvctl.txt, + docs/man/upsdrvsvcctl.txt, docs/man/upsimage.cgi.txt, + docs/man/upslog.txt, docs/man/upsmon.conf.txt, docs/man/upsmon.txt, + docs/man/upsrw.txt, docs/man/upssched.conf.txt, + docs/man/upssched.txt, docs/man/upsset.cgi.txt, + docs/man/upsset.conf.txt, docs/man/upsstats.cgi.txt, + docs/man/upsstats.html.txt, docs/man/usbhid-ups.txt, + docs/man/victronups.txt, docs/nut-names.txt, docs/packager- + guide.txt: docs/man: be sure to keep a blank line after SYNOPSIS + and other titles [#1362] + * docs/FAQ.txt: docs/FAQ.txt: clarify about nutdrv_qx + * UPGRADING: UPGRADING: detail about "OBSOLETION WARNING" for + "Megatec Q*" + * docs/man/bestups.txt, docs/man/blazer-common.txt, + docs/man/masterguard.txt, drivers/bestups.c, drivers/blazer.c, + drivers/masterguard.c: Report deprecation messages when starting + older Qx drivers And document similarly in their man pages + (bestups, blazer, masterguard) + * docs/FAQ.txt, docs/nut.dict: docs/FAQ.txt: add more reasons and + symptoms that a running driver disappears + * docs/FAQ.txt, docs/nut.dict: docs/FAQ.txt: suggest checking Linux + USB HID Quirk [#630] + * ci_build.sh: ci_build.sh: use "gmake" for "./ci_build.sh + spellcheck" if available and no particular MAKE was requested + * docs/FAQ.txt, docs/nut.dict: docs/FAQ.txt: suggest how to pick + drivers for bogus vendor IDs + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: bump version for #1356 + and #1359 + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: bump version for + #584 + * drivers/mge-hid.c: drivers/mge-hid.c: bump version for #1357 + +2022-04-09 Stuart Henderson + + * drivers/usbhid-ups.c: reinstate handling for STATUS(ONLINE) in + usbhid-ups The recent onlinedischarge changes removed support for + some STATUS(ONLINE) cases, affecting at least CP1300EPFCLCD - this + brings them back. + +2022-04-08 Jim Klimov + + * NEWS: NEWS: note Liebert/Phoenixtec vs MGE HID handling of VendorID + 0x06da + * drivers/mge-hid.c: drivers/mge-hid.c: mge_claim(): test that + VendorID==PHOENIXTEC 0x06da has also Vendor or Product containing + "AEG" + * data/driver.list.in: data/driver.list.in: update for "PowerWalker + VFI 2000 TGS" via "usbhid-ups" [#564] + * docs/man/usbhid-ups.txt: docs/man/usbhid-ups.txt: update for "some + PowerWalker models" + +2022-04-08 Jim Klimov + + * NEWS: NEWS: tripplite_usb recognizes "3005" protocol for NUT v2.7.5 + +2022-04-08 Jim Klimov + + * NEWS, docs/nut.dict: NEWS: improve PowerWalker VFI 2000 TGS support + in NUT v2.7.5 + * drivers/liebert-hid.c, drivers/mge-hid.c: drivers/liebert-hid.c: + get PowerWalker VFI 2000 TGS working, read values correctly This + reverts commit c38b45a56a9d1283657d62a9fa1ed1af5daa1ba2 which added + such support into mge-hid.c (at risk to proper support of earlier + handled devices by various vendors), and transplants the new lines + into liebert-hid.c See issue #560 for a HID walk from the device + in question; data like that may help expand liebert-hid.c later + (its table seems to map a lot less field names than mge-hid.c, but + not sure if "true" Liebert/Phoenixtec HID devices support the + rest). + +2022-04-07 Jim Klimov + + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: instcmd(): do not risk + NULL-dereference debugging about "using Path" with a NULL hidpath + (just in case) [#1346] + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: instcmd(): do not risk + NULL-dereference debugging about "using Path" too early [#1346] + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: instcmd(): wrap some + long lines + +2022-04-07 Jim Klimov + + * docs/nut.dict: docs/nut.dict: update spellchecker + * docs/nut.dict: docs/nut.dict: update spellchecker + +2022-04-05 Jim Klimov + + * docs/man/upsmon.conf.txt: docs/man/upsmon.conf.txt: fix markup + (pluses make emphasis and xmllint goes upset) + +2022-04-04 Jim Klimov + + * INSTALL.nut: INSTALL.nut: add another perspective on packages vs + source builds; refer to config-prereqs.txt + * INSTALL.nut: INSTALL.nut: trim trailing spaces + * README: README: trim trailing spaces + * README: README: clarify use of github + * docs/config-prereqs.txt, docs/nut.dict: docs/config-prereqs.txt: + clarify pre-installation of python and perl + * docs/config-prereqs.txt: docs/config-prereqs.txt: clarify that non- + GNU makes should work well + +2022-04-02 Jim Klimov + + * scripts/python/app/NUT-Monitor: scripts/python/app/NUT-Monitor: fix + typo, thank CI + * UPGRADING: UPGRADING: detail the Py2/Py3 packages + * UPGRADING: UPGRADING: make note of systemd and Py2/3 changes on top + for packagers to see + * NEWS: NEWS: detail the split of NUT-Monitor and new wrapper script + * scripts/python/app/README: scripts/python/app/README: update with + sections; list Desktop menu integration and Kudos + * scripts/python/app/.gitignore, scripts/python/app/NUT-Monitor, + scripts/python/app/nut-monitor.desktop: Introduce new NUT-Monitor + name-holder as a wrapping script to pick usable implementation + * scripts/python/app/.gitignore: GitIgnore newly named variants of + NUT-Monitor-py2gtk2 and NUT-Monitor-py3qt5 + * scripts/python/app/README: scripts/python/app/README: document how + to get localized UI in dev/testing + * scripts/python/app/README: scripts/python/app/README: document how + to run UI app in-place + * m4/nut_check_python.m4: m4/nut_check_python.m4: extend list of some + python interpreter filenames + * configure.ac, scripts/python/Makefile.am, scripts/python/app/{NUT- + Monitor.in => NUT-Monitor-py2gtk2.in}, scripts/python/app/nut- + monitor-py2gtk2.desktop, scripts/python/app/nut-monitor.desktop, + scripts/python/app/{ => ui}/gui-1.3.glade, scripts/python/app/{ => + ui}/gui-1.3.glade.h: Rename NUT-Monitor UI app to NUT-Monitor- + py2gtk2 + * configure.ac, scripts/python/Makefile.am, scripts/python/app/{NUT- + Monitor.in => NUT-Monitor-py3qt5.in}, scripts/python/app/nut- + monitor-py3qt5.desktop, scripts/python/app/nut-monitor.desktop: + Rename modernized NUT-Monitor UI app to NUT-Monitor-py3qt5 + +2022-02-21 Luke Dashjr + + * scripts/python/Makefile.am, scripts/python/README, + scripts/python/app/NUT-Monitor.in, scripts/python/app/README, + scripts/python/app/gui-1.3.glade, + scripts/python/app/gui-1.3.glade.h, scripts/python/app/nut- + monitor.desktop, scripts/python/app/ui/aboutdialog1.ui, + scripts/python/app/ui/dialog1.ui, scripts/python/app/ui/dialog2.ui, + scripts/python/app/ui/window1.ui: NUT-Monitor: Port to + Python3+PyQt5 + +2022-02-13 Luke Dashjr + + * scripts/python/app/NUT-Monitor.in: NUT-Monitor: Run py2to3-3.10 + +2022-04-01 Jim Klimov + + * scripts/python/README: scripts/python/README: clarify that + `test_nutclient.py` requires an `upsd` running + * scripts/python/module/PyNUT.py.in: + scripts/python/module/PyNUT.py.in: fix typo (fallout of #840) + * docs/config-prereqs.txt: docs/config-prereqs.txt: fix typos in + OpenIndiana chapter + * NEWS, docs/net-protocol.txt, docs/nut.dict, server/netcmds.h: Add + "PROTVER" as alias to "NETVER" for NUT v2.8.0 Closes: #1347 + +2022-03-31 Jim Klimov + + * Makefile.am, docs/Makefile.am, docs/man/Makefile.am: + {.,docs,docs/man}/Makefile.am: add "all-man" target to build all + possible man pages (vs ones for enabled drivers), and weave this + and check targets to parent makefiles + * ci_build.sh: ci_build.sh: introduce shortcut for + BUILD_TYPE=fightwarn-all + * ci_build.sh: ci_build.sh: in BUILD_TYPE=default-all-errors report + visibly when no failures happened + * m4/nut_compiler_family.m4: m4/nut_compiler_family.m4: treat + /usr/pkg/include as -isystem + * common/parseconf.c, common/str.c, drivers/apcsmart-old.c, + drivers/apcsmart.c, drivers/mge-utalk.c, drivers/serial.c, + drivers/snmp-ups.c, server/conf.c: Cast (size_t)(char) for + isprint(), isspace(), isdigit(), toupper(), etc. who may be macros + and use it as array subscript (due to sys/ctype_inline.h) + +2022-03-30 Jim Klimov + + * autogen.sh: autogen.sh: suggest to export PYTHON=python-x.y + * autogen.sh: autogen.sh: detect more python-x.y filenames + * docs/config-prereqs.txt, docs/nut.dict: docs/config-prereqs.txt: + add chapter for NetBSD 9.2 builder setup + * docs/config-prereqs.txt: docs/config-prereqs.txt: drop bogus + command (copy-paste typo) + +2022-03-29 Jim Klimov + + * .github/pull_request_template.md: Update pull_request_template.md + +2022-03-28 Benjamin Berg + + * scripts/upower/95-upower-hid.hwdb, scripts/upower/95-upower- + hid.rules, tools/nut-usbinfo.pl: tools/nut-usbinfo.pl: Use hwdb for + UPower rules + +2022-03-28 Jim Klimov + + * ci_build.sh: ci_build.sh: recognize more "*bsd" CI_OS_NAME values + * ci_build.sh: ci_build.sh: do not make noise about non-ubiquitous + options to "uname" program + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: set the onlinedischarge + variable based on flag presence + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: drop + DEFAULT_ONLINEDISCHARGE to match "VAR_FLAG" semantics + * docs/nut.dict: docs/nut.dict: add onlinedischarge + * NEWS: NEWS: clarify that NUT 2.8.0 is new name for old planned NUT + 2.7.5 + * NEWS: NEWS: added usbhid-ups onlinedischarge for NUT v2.7.5 + * docs/man/usbhid-ups.txt: docs/man/usbhid-ups.txt: document + onlinedischarge + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: fix var usage for + upsname + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: fix format string for + "onlinedischarge" help + +2022-03-26 Jim Klimov + + * ci_build.sh: ci_build.sh: default to clang if also available when + default gcc is too old + +2022-03-25 Jim Klimov + + * docs/config-prereqs.txt: docs/config-prereqs.txt: update openbsd + tools for man-page builds + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: avoid failure-prone + build toolkits for manpage tests + * m4/nut_compiler_family.m4: m4/nut_compiler_family.m4: avoid + configure noise message + * m4/ax_check_compile_flag.m4: m4/ax_check_compile_flag.m4: extend to + check conftest.err log about unsupported flags + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: define + axisCombos_COMPILER_GCC_TOO_OLD near other compiler-related combos + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: fix scenarios with + "non-fatal warnings" that had BUILD_WARNFATAL=yes anyway (copy- + paste issue) + +2022-03-24 Jim Klimov + + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: avoid even running + axisCombos_GCC_TOO_OLD where we require fatal warnings + * configure.ac: configure.ac: for very old GCC where we are not in + control of warnings, make them non-fatal always (for "auto" level) + * drivers/libhid.c: drivers/libhid.c: clang-3.4 does not know + "-Wtautological-type-limit-compare" either + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: make use of + dsbcStageTimeoutSettings + +2022-03-23 Jim Klimov + + * configure.ac: configure.ac: with nut_enable_warnings=auto, avoid + fatal warnings with GCC 4.3 or older (no support for diags pragmas) + * configure.ac: configure.ac: report initial nut_enable_warnings + (default or argument) + * configure.ac: configure.ac: pre-set nut_enable_warnings=auto by + default (not hardcoded "medium") + * ci_build.sh: ci_build.sh: set BUILD_WARNOPT and BUILD_WARNFATAL to + "auto" for BUILD_TYPE="fightwarn"* shortcuts (survive antique + compilers, default to medium/fatal normally) + * ci_build.sh: ci_build.sh: comment BUILD_WARNOPT setting for + BUILD_TYPE="fightwarn"* shortcuts + * m4/nut_compiler_family.m4: m4/nut_compiler_family.m4: enable back + the "-isystem" tuning to not complain about packaged third-party + headers + * drivers/libhid.c: drivers/libhid.c: make use of + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_TYPE_LIMIT_COMPARE + (clang-6.0.0 of OpenBSD 6.4) + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: introduce + [HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_TYPE_LIMIT_COMPARE + * configure.ac: configure.ac: specify AC_PREREQ([2.64]) + * m4/nut_check_libgd.m4: m4/nut_check_libgd.m4: fix detection of + gdImagePng() with additional link requirements + * configure.ac: configure.ac: document practical requirement for + AC_PREREQ(2.64) + * NEWS, UPGRADING, docs/config-notes.txt, docs/man/upscmd.txt, + docs/man/upsrw.txt: docs, NEWS, UPGRADING: rename 2.7.5 to 2.8.0 in + text that appeared after 2.7.4 + * docs/net-protocol.txt: docs/net-protocol.txt: document "PRIMARY" as + alias to "MASTER" + * docs/net-protocol.txt: docs/net-protocol.txt: bump next release + from 2.7.5 to 2.8.0 + * configure.ac: configure.ac: bump NUT_NETVERSION to 1.3 to match + docs/net-protocol.txt + +2022-03-21 Jim Klimov + + * scripts/subdriver/gen-snmp-subdriver.sh: scripts/subdriver/gen- + snmp-subdriver.sh: fix back markup for mib2nut_info_t lines + Follow-up for #1327 Thanks to @aquette + +2022-03-19 Jim Klimov + + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: qx_ups_walk(): log the + change of estimated remaining runtime + * NEWS: NEWS: nutdrv_qx: enhanced estimation of remaining battery + runtime for NUT v2.7.5 + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: comment about source and + data for estimated runtime corrections + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: fix trailing whitespace + * ci_build.sh: ci_build.sh: when parsing BUILD_TYPE=fightwarn, do not + default NUT_SSL_VARIANTS and NUT_USB_VARIANTS to "auto" - so + building just one variant at most, even if agent supports more + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: snr_command(): adapt to + usb_ctrl_charbuf + +2022-03-16 Jim Klimov + + * drivers/libhid.h, drivers/usbhid-ups.c: drivers/libhid.h, usbhid- + ups.c: define HID_DEV_HANDLE_CLOSED usable for both SHUT and USB + cases + +2022-03-15 Jim Klimov + + * drivers/libusb0.c, drivers/libusb1.c: drivers/libusb{0,1}.c: retry + getting Manufacturer/Product/Serial a few times if failed on the + first Kudos to Sam Varshavchik for proposing this code change in + discussion https://github.com/networkupstools/nut/issues/414 + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: try to close libusb + handle before reconnecting (from discussion of issue #414) + +2022-03-16 Jim Klimov + + * NEWS: NEWS: added driver adelsystem_cbi for NUT v2.7.5 + * drivers/adelsystem_cbi.h: drivers/adelsystem_cbi.h: functions + implemented in a header should be static + * drivers/adelsystem_cbi.c: drivers/adelsystem_cbi.c: extend pragmas + for covered/requred "default" case to work with clang-3.4 + +2022-03-15 Jim Klimov + + * ci_build.sh: ci_build.sh: if we only build USB variant(s), do not + shy away from testing some SSL and whatever drivers we can + +2022-03-15 Jim Klimov + + * docs/config-prereqs.txt: docs/config-prereqs.txt: currently refrain + from clang-13 in OI + * docs/config-prereqs.txt: docs/config-prereqs.txt: mark aspell as + recommended (it is not big) + * docs/config-prereqs.txt: docs/config-prereqs.txt: update + instructions for symlinks on OI + * docs/config-prereqs.txt: docs/config-prereqs.txt: fix typos in + instructions for OpenIndiana, and update for new toolkits available + in 2022 + +2022-03-12 Jim Klimov + + * ci_build.sh: ci_build.sh: add support for CI_CROSSBUILD_HOST and/or + CI_CROSSBUILD_TARGET settings [#1294, #1289, #1334] + * ci_build.sh: ci_build.sh: check for "gd" as one of names gdlib can + go by + * ci_build.sh: ci_build.sh: use PKG_CONFIG variable if provided (fall + back to pkg-config from PATH, but only for this script itself) + [#710] + * drivers/salicru-hid.c: Update salicru-hid.c Cosmetic fixes + * m4/nut_check_libnetsnmp.m4: m4/nut_check_libnetsnmp.m4: improve + checks for actually present priv/auth protocols [#1289] Great + thanks to @eklinedi on GitHub for finding the issue and + investigating ways to fix it + * drivers/snmp-ups.h: drivers/snmp-ups.h: net-snmp after v5.9.1 does + not declare ONE_SEC that our code uses; stash the definiton + * configure.ac, m4/ax_c_pragmas.m4, m4/ax_run_or_link_ifelse.m4, + m4/nut_compiler_family.m4: Introduce m4/ax_run_or_link_ifelse.m4 to + facilitate cross-builds [#1289] + * ci_build.sh: ci_build.sh: report OS_* envvar values if passed by + caller + +2022-03-12 juantonio + + * drivers/salicru-hid.c: Add tested descriptors for Salicru Twin Pro + 2 + +2022-03-12 Jim Klimov + + * ci_build.sh: ci_build.sh: expand a bit CI_OS_HINT detection on + linux systems + +2022-03-11 Jim Klimov + + * m4/nut_compiler_family.m4: m4/nut_compiler_family.m4: quiesce + -Wreserved-identifier (clang 13+) that acts up on system headers + * drivers/riello.c: drivers/riello.c: riello_parse_re(): assign + Pout#W and Pout#VA from pom_long not pom_word + * drivers/belkinunv.c: drivers/belkinunv.c: instcmd(): find use for + "r" to at least report failed cmds + +2022-03-11 Jim Klimov + + * docs/config-prereqs.txt: docs/config-prereqs.txt: rearrange + packages to not require heavy ones by default dependency footprint + (aspell, docs generation and libgd) + * server/netuser.c: server/netuser.c: copy-paste typo fix + * NEWS, UPGRADING: NEWS: rename pending NUT release from 2.7.5 to + 2.8.0 (config files using new keywords are not backwards- + compatible, not usable by old binaries) + * NEWS: NEWS: added battery.mfr.date APC HID UPS setting for NUT + v2.7.5 + * NEWS, docs/nut.dict: NEWS: added socomec_jbus driver for NUT v2.7.5 + * server/netuser.c: server/netuser.c: net_master(): provide more + details about client using deprecated commands + * docs/net-protocol.txt: docs/net-protocol.txt: update for "PRIMARY" + netcmd support (alias of "MASTER") [issue #840] + * NEWS: NEWS: update for "PRIMARY" netcmd support (alias of "MASTER") + [issue #840] + * scripts/python/module/PyNUT.py.in, server/netcmds.h, + server/netuser.c, server/netuser.h: netcmds.h, netuser.{c,h}, + PyNUT.py.in: deprecate protocol "MASTER" command in favor of + "PRIMARY" [issue #840] + * server/upsd.c: server/upsd.c: check_command(): instrument with + upsdebugx() + * server/netuser.c: server/netuser.c: net_login(): instrument with + upsdebugx() + * clients/upsmon.c: clients/upsmon.c: apply_for_primary(): request + elevation by PRIMARY, fall back to MASTER (for older upsd builds) + * NEWS, UPGRADING: NEWS: rename pending NUT release from 2.7.5 to + 2.8.0 (config files using new keywords are not backwards- + compatible, not usable by old binaries) + +2022-03-10 Jim Klimov + + * scripts/subdriver/gen-snmp-subdriver.sh: gen-snmp-subdriver.sh: put + back indented CFILE markup (fix here-docs, instead of + unmaintainable printf) + * scripts/subdriver/gen-snmp-subdriver.sh: gen-snmp-subdriver.sh: fix + valid chars HOSTNAME input (e.g. IP) + +2022-03-10 Jim Klimov + + * scripts/subdriver/gen-snmp-subdriver.sh: Update gen-snmp- + subdriver.sh Quote variable expansions; replace `echo -n` with a + more portable `printf` + +2022-03-10 Arnaud Quette + + * scripts/subdriver/gen-snmp-subdriver.sh: SNMP subdriver generation + script: minor reformatting + * scripts/subdriver/gen-snmp-subdriver.sh: SNMP subdriver generation + script: fixes and improvements + +2022-03-08 Jim Klimov + + * tests/getvaluetest.c: tests/getvaluetest.c: check different methods + to combine two "wire" bytes into a lenght word (follows up for + #1320), hopefully all work the same on all architectures + +2022-03-08 Thanos Chatziathanassiou + + * docs/man/socomec_jbus.txt: some documentatyion fixes + +2022-03-08 Jim Klimov + + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: simplify back the bit- + maths to cast into uint8_t following discussion in #1320 + * drivers/libusb0.c, drivers/libusb1.c: drivers/libusb{0,1}.c: + simplify back the bit-maths to cast into uint8_t following + discussion in #1320 + +2022-03-07 Jim Klimov + + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: fix (commented- + away) hard_shutdown() to "unsigned char" and bit maths similar to + soft_shutdown() + * drivers/riello_usb.c: drivers/riello_usb.c: Get_USB_Packet(): cast + bit maths to (unsigned char) to err on safe side + * drivers/riello_usb.c: drivers/riello_usb.c: whitespace fix + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: upsdrv_initups(): cast + langid calculations to uint16_t (or wider) [similar to #1320] + * drivers/libusb0.c, drivers/libusb1.c: drivers/libusb{1,0}.c: + {nut_}libusb_open(): cast rdlen calculations to uint16_t (or wider) + [follow-up from #1320] + * drivers/libshut.c: drivers/libshut.c: shut_checksum(): address + (usb_ctrl_charbuf)buf as (unsigned char) in bit maths + * drivers/libshut.c: drivers/libshut.c: BYTESWAP(): cast "in" to + (uint16_t) for bit maths and use a full-width mask + * drivers/blazer_usb.c: drivers/blazer_usb.c: upsdrv_initups(): + address (usb_ctrl_charbuf)tbuf as (unsigned char) in bit maths + +2022-03-02 Jim Klimov + + * drivers/snmp-ups.h: drivers/snmp-ups.h: make sure + WITH_SNMP_LKP_FUN_DUMMY is defined + +2022-02-27 Nita Vesa + + * drivers/apc-hid.c, drivers/usbhid-ups.c: APC HID UPS: Add ability + to set battery battery.mfr.date Some APC UPSes allow for setting + battery.mfr.date, so it can be easily referenced later, even if + there were no stickers or papers left to refer to. This patch has + been tested to work with APC Back-UPS ES 550G. + +2022-03-02 Jim Klimov + + * drivers/mge-xml.c: drivers/mge-xml.c: mge_drycontact_info(): avoid + shadowing global variable + +2022-02-28 Nick Briggs + + * drivers/libusb0.c: Cast to unsigned type when interpreting HID + descriptor length bytes (libusb 0.1) The libusb 0.1 interface + definition declares a (signed) char type for control messages. The + HID descriptor length contained within a control message is + intended to be interpreted as a pair of unsigned bytes so we must + cast to uint8_t when doing the arithmetic rather than trip over the + sign bit. Closes #1261, closes #1312. + +2022-02-27 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: extend daisychain + initialization to use optional mapping function Note: ported sub- + set of "snmp-ups.[ch] : add support for extended fun/nuf l2s/s2l + conversions and use it for daisychain initialization" without the + actual 2x2 "fun/nuf l2s/s2l" support here. + +2022-02-27 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: daisychain_init(): add + debug trace + * drivers/eaton-pdu-marlin-helpers.c: drivers/eaton-pdu-marlin- + helpers.c: marlin_device_count_fun(): add debug trace + +2021-11-17 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: su_find_strval(): mark + NUT_UNUSED_VARIABLE(oid2info) when not WITH_SNMP_LKP_FUN + +2022-02-27 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: whitespace fix + +2017-10-11 Jim Klimov + + * drivers/snmp-ups.c: snmp-ups.c : publish device.count==1 too + +2021-10-13 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: su_find_strval() should + consider #if WITH_SNMP_LKP_FUN + +2019-09-25 Arnaud Quette + + * drivers/snmp-ups.c: Fix false positive when communication is lost + +2022-02-27 Jim Klimov + + * drivers/eaton-pdu-marlin-mib.c: drivers/eaton-pdu-marlin-mib.c: + resync comments and use of SU_FLAG_SEMI_STATIC + +2022-02-25 Jim Klimov + + * drivers/eaton-pdu-marlin-mib.c: drivers/eaton-pdu-marlin-mib.c: + break long lines + +2022-02-27 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: avoid stringop-truncation + warning: make sure string is finite + +2021-11-11 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: avoid stringop-truncation + warning + +2021-11-17 Jim Klimov + + * drivers/eaton-pdu-marlin-helpers.c: drivers/eaton-pdu-marlin- + helpers.c: include config.h first + +2021-11-25 Arnaud Quette + + * drivers/powerware-mib.c: Eaton SNMP: also publish ups.load for + 3phase Though there is output.Lx.power.percent, for 3phase, it's + desirable to also have the standard ups.load + +2022-01-12 Arnaud Quette + + * drivers/mge-xml.c: Eaton NMC: fix the non publication of real/power + with 3ph power and realpower for 3ph Lx were not publishing values + when they were 0 + +2021-11-22 Arnaud Quette + + * drivers/mge-xml.c: Eaton XML/PDC: add External Battery Module count + +2021-11-15 Arnaud Quette + + * drivers/eaton-pdu-marlin-mib.c, drivers/powerware-mib.c: Fix + regression on Eaton EMP002 temperature reading (SNMP) Following + the recent addition of the "String reformating function" + (su_find_strval()), a regression appeared on a corner case: when + flagging a data with ST_FLAG_STRING, while the SNMP OID is an int, + and when there is a fun_vp2s() conversion function, a double + conversion is applied, resulting in no value published. This was + limited to one data (temperature.unit) + +2021-06-14 Clappier, Eric + + * drivers/powerware-mib.c, drivers/snmp-ups.c: Add missing outlet + objects for master + +2021-02-01 Clappier, Eric + + * drivers/eaton-pdu-marlin-mib.c, drivers/powerware-mib.c: Fix dry + contacts status for EMP02 + +2022-02-27 Jim Klimov + + * drivers/snmp-ups-helpers.c, drivers/snmp-ups.c: Move + su_temperature_read_fun() from drivers/snmp-ups.c to snmp-ups- + helpers.c + +2021-01-26 Arnaud Quette + + * drivers/eaton-pdu-marlin-mib.c: snmp-ups: fix regression on Eaton + ePDU Fix a regression that caused a mis-determination of the SNMP + base OID index (0 or 1, should be 1). This in turn caused a mis- + iteration over the outlets, from 0 to N-1 instead of 1 to N, which + resulted in the missing Nth outlet (last outlet of the PDU). This + also caused some data refresh issues + +2020-12-16 Clappier, Eric + + * drivers/eaton-pdu-marlin-mib.c, drivers/snmp-ups.c: Add + ambient.n.parent.serial for marlin epdu Regarding dropped code + from snmp-ups.c - per discussion in + https://github.com/42ity/nut/pull/117 this was not a typo: > It is + an intentional change for oid read value issue. > This allows to + actually retrieve an indirection value > (when an Oid points at an + Oid, like stood) + +2020-12-15 Arnaud Quette + + * drivers/eaton-pdu-marlin-mib.c: snmp-ups: Restore legacy Eaton ePDU + switchability info Use a hack to also have switchability for both + the unit and its outlets on legacy Eaton G2 ePDU + +2020-12-15 Clappier, Eric + + * drivers/eaton-pdu-marlin-mib.c, drivers/powerware-mib.c: Change uid + and modbus address name according nut nomenclature + +2020-12-14 Clappier, Eric + + * drivers/powerware-mib.c: Add modbus_address and uuid in snmp-ups/pw + driver + +2019-11-07 Arnaud Quette + + * drivers/powerware-mib.c: SNMP Eaton Gb Network Card: various data + completion * fix reading of input.voltage, related to the ending + ".0", * fix existing commands handling, * add support for the load + segment (managed outlets), including status information and + commands + +2019-09-19 Arnaud Quette + + * drivers/eaton-pdu-marlin-mib.c, drivers/powerware-mib.c: SNMP Eaton + EMP002: handle sensor presence Sensor may not be present (or + connected). However, the values (temperature, humidity, ...) are + still available, but should not be considered + +2022-02-27 Jim Klimov + + * drivers/powerware-mib.c: drivers/powerware-mib.c: update comments + and implem for dummy + eaton_sensor_temperature_unit_fun()/su_temperature_read_fun() from + 42ity/nut + * drivers/eaton-pdu-marlin-mib.c: drivers/eaton-pdu-marlin-mib.c: + update comments and implem for dummy + eaton_sensor_temperature_unit_fun()/su_temperature_read_fun() from + 42ity/nut + * drivers/eaton-pdu-marlin-mib.c, drivers/powerware-mib.c, + drivers/snmp-ups.c, drivers/snmp-ups.h: drivers/snmp-ups.{c,h}: + adjust su_temperature_read_fun() API to that used in NUT master + branch + * drivers/eaton-pdu-marlin-helpers.c, drivers/eaton-pdu-marlin- + helpers.h: drivers/eaton-pdu-marlin-helpers.{c,h}: adjust + eaton_sensor_temperature_unit_fun() API to that used in NUT master + branch + +2019-09-19 Arnaud Quette + + * drivers/eaton-pdu-marlin-helpers.c: SNMP Eaton ePDU: always return + celsius for temperature since the value reading is always adapted + to celsius + +2016-05-25 Jim Klimov + + * drivers/powerware-mib.c: powerware-mib - renamed "ietf_*" and + "eaton_*" lookups to have "pw_*" prefix + +2019-09-12 Arnaud Quette + + * drivers/eaton-pdu-marlin-helpers.c, drivers/eaton-pdu-marlin-mib.c, + drivers/powerware-mib.c, drivers/snmp-ups.c, drivers/snmp-ups.h: + Typo fix: sorry Mr Fahrenheit And thanks to Jim Klimov for the + review! + * drivers/eaton-pdu-marlin-mib.c: Fix compilation warning + +2019-09-09 Arnaud Quette + + * drivers/powerware-mib.c: SNMP Eaton Gb Network Card: support for + EMPDT1H1C2 + +2022-02-27 Jim Klimov + + * drivers/eaton-pdu-marlin-helpers.c: drivers/eaton-pdu-marlin- + helpers.c: fix whitespace + +2017-10-11 Jim Klimov + + * drivers/eaton-pdu-marlin-helpers.c: eaton-pdu-marlin-helpers.c : in + device_count helper do not assume a trailing comma (as last char) + as an extra device + +2019-09-09 Arnaud Quette + + * drivers/eaton-pdu-marlin-helpers.c, drivers/eaton-pdu-marlin- + helpers.h, drivers/eaton-pdu-marlin-mib.c: SNMP Eaton ePDU: support + for EMPDT1H1C2 + * drivers/snmp-ups.c, drivers/snmp-ups.h: snmp-ups: support for + daisychained ambient sensor + +2022-02-27 Jim Klimov + + * drivers/eaton-pdu-marlin-mib.c: drivers/eaton-pdu-marlin-mib.c: + align comments around outlet.%i.name with FTY version + +2017-10-11 Jim Klimov + + * drivers/eaton-pdu-marlin-mib.c: eaton-pdu-marlin-mib.c : preferred + templated outlet.%i.name goes last in MIB + +2018-08-07 Jim Klimov + + * drivers/powerware-mib.c: powerware-mib.c : fix fallout from "snmp- + ups: support newer Genepi management cards" (unused variable + warning) + +2018-08-07 Arnaud Quette + + * drivers/powerware-mib.c: snmp-ups: support newer Genepi management + cards * duplicate some OIDs, with refinement to point at the first + index (i.e ".0" or ".1.0") since otherwise the agent doesn't + respond to queries. This could be fixed at the snmp-ups level later + * fixed "ups.type" (power topology of the UPS) which was pointing + at the output.source or ups.mode + +2022-02-27 Jim Klimov + + * drivers/eaton-pdu-marlin-mib.c: drivers/eaton-pdu-marlin-mib.c: + align with "snmp-ups: Simplify the mapping structure" changes for + input.phases=>input.count + +2017-11-17 Arnaud Quette + + * drivers/eaton-ats16-nmc-mib.c, drivers/eaton-pdu-marlin-mib.c, + drivers/mge-mib.c, drivers/mge-xml.c, drivers/powerware-mib.c: + Modify "open" to "opened" for dry contacts status While "open" is + the best adjective for the opposite of "closed", and thus suitable + for GPI status, this may lead to confusion with the GPO actions + "open|close" Vs the GPI status "opened|closed". These last are also + not inapropriate, since they can refer to the fact that the GPI + state has change due to some external action or event + +2017-11-03 Arnaud Quette + + * drivers/eaton-ats16-nm2-mib.c, drivers/eaton-ats16-nmc-mib.c, + drivers/mge-mib.c, drivers/mge-xml.c, drivers/powerware-mib.c: Add + support for dry contacts to Eaton ATS16 and UPS Add support for + the 2 GPI accessible through EMP001 environmental sensor, connected + to a UPS or ATS16. The same is already available for Eaton ePDU. + This affect the snmp-ups driver (eaton_ats16 and pw/pxgx_ups MIBs), + and the netxml-ups driver + +2022-02-25 Jim Klimov + + * drivers/snmp-ups.h: drivers/snmp-ups.h: avoid "#if" with possibly + not-defined macro + +2018-08-02 Arnaud Quette + + * drivers/eaton-pdu-marlin-mib.c: snmp-ups: Eaton feed color is semi + static + +2018-06-26 Arnaud Quette + + * docs/nut-names.txt, drivers/eaton-pdu-marlin-mib.c: snmp-ups: Eaton + ePDU input.power.nominal is realpower Fix data name, since the + published value is in Watts, so realpower, not power + +2017-10-30 Arnaud Quette + + * drivers/eaton-pdu-marlin-mib.c: eaton-pdu-marlin-mib.c/dmf: add + outlet timers Add support for shutdown and start timers + +2022-02-25 Jim Klimov + + * drivers/eaton-pdu-marlin-mib.c: drivers/eaton-pdu-marlin-mib.c: + relocate outlet.%i.load.off.delay etc like in FTY + * drivers/eaton-pdu-marlin-mib.c: drivers/eaton-pdu-marlin-mib.c: + break long lines like in FTY + * drivers/eaton-pdu-marlin-mib.c: drivers/eaton-pdu-marlin-mib.c: + break long lines + +2017-10-17 Arnaud Quette + + * drivers/eaton-pdu-marlin-mib.c: snmp-ups: fix Eaton ePDU group + phase handling Remove the not needed SU_FLAG_UNIQUE and the + erroneous value lookup structure index + * drivers/eaton-pdu-marlin-helpers.c, drivers/eaton-pdu-marlin- + helpers.h, drivers/eaton-pdu-marlin-mib.c: snmp-ups: simplify Eaton + ePDU group phase handling + +2017-10-11 Jim Klimov + + * drivers/eaton-pdu-marlin-helpers.c, drivers/eaton-pdu-marlin- + helpers.h: eaton-pdu-marlin-* : add support for extended fun/nuf + l2s/s2l conversions + +2017-10-13 Jim Klimov + + * drivers/eaton-pdu-marlin-mib.c: eaton-pdu-marlin-mib.c : updated + comments about input/feed relationship, and daisychain implications + +2017-10-13 Arnaud Quette + + * drivers/eaton-pdu-marlin-mib.c: Problem: Need to fix published feed + variables Solution: Attach 1 feed to the current input + +2017-10-13 Jim Klimov + + * drivers/eaton-pdu-marlin-mib.c: eaton-pdu-marlin-mib.c : fix OID + and raise questions on input.power.nominal + +2017-10-11 Jim Klimov + + * drivers/eaton-pdu-marlin-mib.c: eaton-pdu-marlin-mib.c : Revised + added OIDs with a single-group ePDU Also update line-breaks for + readability and 80-col standard + +2017-10-09 Jim Klimov + + * drivers/eaton-pdu-marlin-helpers.c, drivers/eaton-pdu-marlin- + helpers.h, drivers/eaton-pdu-marlin-mib.c: eaton-pdu-marlin-mib.c / + drivers/eaton-pdu-marlin-helpers.[ch] : Implement conversion func + for "device.count" which returns a comma-separated list + * drivers/eaton-pdu-marlin-helpers.c, drivers/eaton-pdu-marlin- + helpers.h, drivers/eaton-pdu-marlin-mib.c: eaton-pdu-marlin-mib.c / + drivers/eaton-pdu-marlin-helpers.[ch] : Implement conversion func + for "outlet.group.%i.phase" + * docs/nut-names.txt, drivers/eaton-pdu-marlin-mib.c: eaton-pdu- + marlin-mib.c : add basic listing of newly defined OIDs (not a full + solution - some mapping functions are needed and revision of MIB + data types) + +2017-08-30 Jim Klimov + + * drivers/eaton-pdu-marlin-mib.c: Fix typo in OID, noticed by aquette + +2017-08-24 Jim Klimov + + * drivers/eaton-pdu-marlin-mib.c, drivers/snmp-ups.c, drivers/snmp- + ups.h: snmp-ups / eaton-marlin : introduce WITH_SNMP_LKP_FUN to + separate codebases that support these callbacks from those that + currently do not + * drivers/eaton-pdu-marlin-helpers.c, drivers/eaton-pdu-marlin- + helpers.h: eaton-pdu-marlin-helpers.c/h fix + * drivers/eaton-pdu-marlin-helpers.c: eaton-pdu-marlin-helpers.c : + update comments for marlin_outlet_group_phase_fun() + +2017-08-23 Jim Klimov + + * drivers/Makefile.am, drivers/eaton-pdu-marlin-helpers.c, + drivers/eaton-pdu-marlin-helpers.h: Expel the helper function that + interacts with dstate from eaton-pdu-marlin-mib.c to eaton-pdu- + marlin-helpers.c/.h + +2016-05-13 Jim Klimov + + * drivers/Makefile.am, drivers/apc-iem-mib.h, drivers/apc-mib.c, + drivers/apc-mib.h: drivers/apc-iem-mib.h: split some macro + definitions away from apc-mib.h and apc-mib.c and snmp-ups.c + +2017-10-11 Jim Klimov + + * drivers/snmp-ups.c, drivers/snmp-ups.h: snmp-ups.[ch] : introduce + SU_FLAG_SEMI_STATIC + +2022-02-24 Jim Klimov + + * docs/nut.dict: Update nut.dict Update for Adelsystem CBI + +2022-02-24 Jim Klimov + + * NEWS: NEWS: Update synchronous=auto for NUT v2.7.5 + * drivers/dstate.c: drivers/dstate.c: send_to_all(): port + do_synchronous auto=>on fallback from send_to_one() + * drivers/dstate.c: drivers/dstate.c: send_to_one()/send_to_all(): + make the success-report less verbose (level 6) + * drivers/dstate.c: drivers/dstate.c: send_to_one()/send_to_all(): + make the reconnection WARNING more visible + * conf/ups.conf.sample, docs/man/ups.conf.txt, drivers/dstate.c, + drivers/main.c: driver/dstate.c, main.c: extend do_synchronous to + have an "auto" mode (now by default) so reconnections would be sync + * drivers/dstate.c: drivers/dstate.c: send_to_one(): log at level 0 + if write failed (twice maybe) and so driver is disconnecting + * drivers/dstate.c: drivers/dstate.c: send_to_one(): log more details + if throttling down, and if it helped + * drivers/snmp-ups.c: drivers/snmp-ups.c: snmp_ups_walk(): log + "walking device %d" at level 1 now, and without a dot-number (to + avoid confusion) + * drivers/dstate.c: drivers/dstate.c: send_to_one(): try to sleep and + resend failed posting; log the faults (and successes) at level 1 + +2022-02-23 Jim Klimov + + * drivers/dstate.c: drivers/dstate.c: send_to_all() send_to_one(): + clarify "disconnecting" when logging that write failed + * drivers/snmp-ups.c: drivers/snmp-ups.c: update comment for + snmp_ups_walk() for "single" device + * drivers/snmp-ups.c: drivers/snmp-ups.c: snmp_ups_walk(): for + "unitary" (non-daisychain member) devices, walk a ".1" device only + (should end up querying non-templated OIDs anyway) - avoid walking + .0 partially and .1 again for same data + * drivers/snmp-ups.c: drivers/snmp-ups.c: snmp_ups_walk(): log + walking an "unitary" device if not a daisy-chain, for balance + * drivers/snmp-ups.c: drivers/snmp-ups.c: snmp_ups_walk(): only log + "Skipping daisychain device.0" when in daisy-chain context (skip + anyway even for singular devices where we should also walk .1 + anyway) + * drivers/snmp-ups.c: drivers/snmp-ups.c: update heading comments for + daisychain related variables + * drivers/snmp-ups.c: drivers/snmp-ups.c: snmp_ups_walk(): only skip + "device.0" if in daisy-chain mode + * drivers/snmp-ups.c: drivers/snmp-ups.c: update comment for + current_device_number + +2022-02-22 Thanos Chatziathanassiou + + * docs/man/socomec_jbus.txt, drivers/Makefile.am, + drivers/socomec_jbus.c: Added socomec_jbus implementation + +2022-02-22 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: snmp_ups_walk(): fix + taxonomy of "processing daisy-chain device" debug log + +2022-02-19 Jim Klimov + + * drivers/snmp-ups.c, server/upsd.c: drivers/snmp-ups.c + upsdrv_updateinfo(); server/upsd.c driver_free() mainloop(): trace + connection faults and reconnections better + * drivers/dstate.c: drivers/dstate.c: send_to_one(): consistently use + "buflen" + * drivers/dstate.c: drivers/dstate.c: send_to_all/send_to_one: extend + failed-send tracing + +2022-02-19 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: wrap long lines, add + comments + +2022-02-22 Jim Klimov + + * scripts/subdriver/gen-snmp-subdriver.sh: scripts/subdriver/gen- + snmp-subdriver.sh: generate "standard MIB items" into new MIB + mappings Kudos to @aquette for the catch in PR review + +2022-02-21 Luke Dashjr + + * scripts/python/Makefile.am, scripts/python/README, + scripts/python/app/NUT-Monitor.in, scripts/python/app/README, + scripts/python/app/gui-1.3.glade, + scripts/python/app/gui-1.3.glade.h, scripts/python/app/nut- + monitor.desktop, scripts/python/app/ui/aboutdialog1.ui, + scripts/python/app/ui/dialog1.ui, scripts/python/app/ui/dialog2.ui, + scripts/python/app/ui/window1.ui: NUT-Monitor: Port to + Python3+PyQt5 + +2022-02-19 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: su_setOID(): uncomment the + fallback for "device.x.contact" not found as a "contact", and add + another to strip "device.1." => "device." to allow setting non- + templated values to daisy-chain master + * drivers/snmp-ups.c, server/upsd.c: drivers/snmp-ups.c + upsdrv_updateinfo(); server/upsd.c driver_free() mainloop(): trace + connection faults and reconnections better + * drivers/dstate.c: drivers/dstate.c: send_to_one(): consistently use + "buflen" + * drivers/dstate.c: drivers/dstate.c: send_to_all/send_to_one: extend + failed-send tracing + +2022-02-19 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: upsdrv_initups(): check + that there is no daisychain master entry before defining IETF-MIB + fallback defaults for contact/location/description + * drivers/snmp-ups.c: drivers/snmp-ups.c: upsdrv_initups(): comment + and log that IETF-MIB fallback defaults for + contact/location/description are only read once (not updated while + driver runs) + * drivers/snmp-ups.c: drivers/snmp-ups.c: su_ups_get(): fake + current_device_number=1 to su_setinfo() when walking a daisy-chain + with non-templated OID + * drivers/snmp-ups.c: drivers/snmp-ups.c: get_and_process_data(), + su_ups_get(): add tracing logs to make sense of daisy-chain OID + adaptations + * drivers/snmp-ups.c: drivers/snmp-ups.c: wrap long lines, add + comments + * drivers/snmp-ups.c: drivers/snmp-ups.c: su_setinfo(): trace diags + for different code-paths about daisy-chained OID decisions + * drivers/snmp-ups.c: drivers/snmp-ups.c: su_setinfo(): this is not + the place to check for ".%i" after all + +2022-02-18 Jim Klimov + + * tools/nut-dumpdiff.sh: tools/nut-dumpdiff.sh: revise to also strip + frequency measurements + * tools/nut-dumpdiff.sh: tools/nut-dumpdiff.sh: revise to also strip + (load|temperature|humidity) measurements + * docs/documentation.txt: docs/documentation.txt: document tools/nut- + dumpdiff.sh helper + * tools/nut-dumpdiff.sh: tools/nut-dumpdiff.sh: revise to strip just + numeric measurements of (*.power|voltage|current) + * tools/nut-dumpdiff.sh: tools/nut-dumpdiff.sh: extend to not strip + ALL numeric values but ones that are likely measurements + * tools/Makefile.am, tools/nut-dumpdiff.sh: Add tools/nut-dumpdiff.sh + helper + * drivers/snmp-ups.c: drivers/snmp-ups.c: su_setOID(): handle e.g. + "device.contact" as either "device.0.contact" for "all devices" if + OID is templated or NULL, or "device.1.contact" for "master device" + in other cases + * drivers/snmp-ups.c: drivers/snmp-ups.c: su_setOID(): import + (commented away - not deemed necessary so far) fallback for e.g. + "device.x.contact" is not found as a "contact" + * drivers/snmp-ups.c: drivers/snmp-ups.c: su_setinfo(): fix comment + * drivers/snmp-ups.c: drivers/snmp-ups.c: fix "device.varname" for + daisychain 'master' units * su_setinfo(): should not expose + master-specific data (like device.contact coming from IETF un- + templated data points not aware about daisy chains) as if it were + the data specific to every device in the chain; note that for + defaulted data (like device.type="pdu" hardcoded with NULL OID) we + still expose it across the board * su_setOID(): "upsrw ... + device.contact" should change the daisychain master device (for + IETF un-templated data; but in this commit - always) + +2022-02-17 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: su_setOID(): fix mis- + interpretation of "device*" as always a daisy-chain + * drivers/snmp-ups.c: drivers/snmp-ups.c: use "hard-coded" IETF MIB + for read-only access to sysDescr also (only if mib2nut does not yet + define a better value) + * drivers/snmp-ups.c: drivers/snmp-ups.c: use "hard-coded" IETF MIB + for read-only access to sysContact and sysLocation only if mib2nut + does not yet define a better value + * drivers/emerson-avocent-pdu-mib.c: drivers/emerson-avocent-pdu- + mib.c: whitespace fix + * drivers/eaton-pdu-marlin-mib.c: drivers/eaton-pdu-marlin-mib.c: + whitespace fix + * drivers/apc-mib.c: drivers/apc-mib: whitespace fix + * drivers/xppc-mib.c: drivers/xppc-mib.c: whitespace fix + * drivers/apc-ats-mib.c, drivers/apc-mib.c, drivers/baytech-mib.c, + drivers/bestpower-mib.c, drivers/compaq-mib.c, drivers/cyberpower- + mib.c, drivers/delta_ups-mib.c, drivers/eaton-ats16-nm2-mib.c, + drivers/eaton-ats16-nmc-mib.c, drivers/eaton-pdu-genesis2-mib.c, + drivers/eaton-pdu-marlin-mib.c, drivers/eaton-pdu-pulizzi-mib.c, + drivers/eaton-pdu-revelation-mib.c, drivers/emerson-avocent-pdu- + mib.c, drivers/hpe-pdu-mib.c, drivers/huawei-mib.c, drivers/ietf- + mib.c, drivers/mge-mib.c, drivers/netvision-mib.c, + drivers/powerware-mib.c, drivers/raritan-pdu-mib.c, + drivers/raritan-px2-mib.c, drivers/xppc-mib.c: drivers/*-mib.c: + define standard-MIB entries for device.description, contact, + location (RW STRING) + +2016-09-16 Arnaud Quette + + * drivers/snmp-ups.h: snmp-ups: update todo list The addition of + sysContact and sysLocation support is now addressed centrally + * drivers/snmp-ups.c: snmp-ups: add sysContact and sysLocation + support The generic MIB-2 provides system contact and location + information that are now publish respectively as device.contact and + device.location + +2022-02-18 Viktor Kuzmin + + * configure.ac: Fix individual drivers configuration + +2022-02-17 Dimitris Economou + + * drivers/adelsystem_cbi.c: handle covered-switch-default and switch- + enum warnings + * drivers/adelsystem_cbi.h: clean up, fix typos + * drivers/adelsystem_cbi.c: clean up, fix typos + * docs/man/Makefile.am, docs/man/adelsystem_cbi.txt: man page added + +2022-02-17 Jim Klimov + + * clients/upscmd.c, clients/upsrw.c: clients/upsrw.c, upscmd.c: fix + sanity-check of tracking_id length (forgot the nul-byte) + * scripts/systemd/nut-driver@.service.in: scripts/systemd/nut- + driver@.service.in: make sure drivers always try to start and + connect - how ever many attempts that takes + * scripts/systemd/nut-driver@.service.in: scripts/systemd/nut- + driver@.service.in: comment about "Before=nut-driver.target" + constraint + * scripts/systemd/nut-driver@.service.in: scripts/systemd/nut- + driver@.service.in: make sure drivers always try to start and + connect + +2022-02-16 Jim Klimov + + * drivers/libhid.c: drivers/libhid.c: string_to_path(): report + hid_lookup_usage() miss + * drivers/libhid.c: drivers/libhid.c: fix misfire of fightwarn commit + 58e5b49 (string_to_path(): range-check...) Closes: #1286 + * conf/upsd.conf.sample, conf/upsmon.conf.sample.in, + docs/man/upsd.conf.txt, docs/man/upsmon.conf.txt: upsd and upsmon + configuration sample files and man pages: add note about run-time + config reload with DEBUG_MIN setting in sight + +2022-02-16 Jim Klimov + + * clients/upsmon.c: clients/upsmon.c: restructure config reload for + debug_min to be more similar to that in upsd.c + * clients/upsmon.c: clients/upsmon.c: whitespace fix + +2022-02-16 Jim Klimov + + * clients/upsmon.c: clients/upsmon.c: allow upsmon to reload config + and apply its debug_min setting + * common/common.c: common/common.c: writepid(): debug-trace creation + of a PID file + +2022-02-16 Jim Klimov + + * scripts/systemd/nut-server.service.in: scripts/systemd/nut- + server.service.in: reload upsd without PID file [for #1299] + * server/conf.c: server/conf.c: allow upsd to reload config and apply + its debug_min setting + * clients/upsmon.c, docs/man/upsmon.txt: clients/upsmon.c: add "-P + pid" arg handling, and report result of sendsignal(), like in upsd + [for #1299, #123] + * docs/man/upsd.txt, scripts/systemd/nut-server.service.in, + server/upsd.c: upsd.c: add -FF option to stay foregrounded AND + write the PID file, use it in systemd/nut-server.service [for + #1299] + * docs/man/upsd.txt, server/upsd.c: server/upsd.c: add "-P PID" arg + for commands [for #1299] + * common/common.c, include/common.h: include/common.h, common.c: + refactor sendsignalfn() into parsepid() and sendsignalpid() + reusable methods + * server/upsd.c: server/upsd.c: warn about not saving a pid file + * server/upsd.c: server/upsd.c: handle extended return values from + sendsignalfn() to tell more about the error + * common/common.c: common/common.c: sendsignalfn(): if we use sig==0 + to probe that a process runs, no need to send that twice + * common/common.c, include/common.h: include/common.h, common.c: + extend sendsignalfn() return value for more error types + +2022-02-15 Jim Klimov + + * drivers/main.c: drivers/main.c: fix user:group separator in debug + message + * configure.ac: configure.ac: report default/detected + RUN_AS_USER/RUN_AS_GROUP values in help; check if "nobody" group is + not resolvable when "nogroup" us to use it as default RUN_AS_GROUP + instead + * drivers/main.c: drivers/main.c: report whether we succeeded or + failed chown/chmod for sockname + * docs/man/nutupsdrv.txt, docs/man/ups.conf.txt, drivers/main.c: + drivers/main.c: support setting group name for socket file + (ups.conf, CLI -g arg) Closes: #1296 + * drivers/dstate.c, drivers/dstate.h, drivers/main.c: drivers/main.c + + dstate.{c,h}: refactor dstate_init() to return a copy of the + "sockname" path used + * drivers/main.c: drivers/main.c: re-word debug message for "-u name" + overriding built-in or configured values + * drivers/main.c: drivers/main.c: trace do_global_args() and + main_arg() var/val stream + * docs/hid-subdrivers.txt: docs/hid-subdrivers.txt: describe tech for + "Fixing report descriptors" + * docs/hid-subdrivers.txt, docs/nut.dict, drivers/hidtypes.h: + docs/hid-subdrivers.txt: document where USAGE_POW_ and USAGE_BAT_ + macros come from + * drivers/apc-hid.c: drivers/apc-hid.c: apc_fix_report_desc(): + normalize indentations + +2022-02-14 Nick Briggs + + * drivers/apc-hid.c: Update APC HID driver version + * drivers/apc-hid.c: Only indicate report descriptor fixed if it was + actually changed. + +2022-02-14 Jim Klimov + + * docs/man/ups.conf.txt, drivers/main.c: drivers/main.c: allow to + specify a user for each driver via ups.conf Closes: #1288 + * drivers/upsdrvctl.c: drivers/upsdrvctl.c: suggest "-d" when warning + about passing debugging through to actual drivers + * drivers/upsdrvctl.c: drivers/upsdrvctl.c: only warn about passing + debugging through to actual drivers if (nut_debug_level_passthrough + == 0) + * docs/man/upsdrvctl.txt, drivers/upsdrvctl.c: drivers/upsdrvctl: add + "-d" option to pass debug level to drivers Closes: #1036 (Note: + that issue discusses other possible improvements around this + subject, which are synergetic with this one) + +2022-02-13 Luke Dashjr + + * scripts/python/app/NUT-Monitor.in: NUT-Monitor: Run py2to3-3.10 + +2022-02-13 Nick Briggs + + * drivers/apc-hid.c, drivers/cps-hid.c, drivers/hidparser.c, + drivers/hidparser.h, drivers/hidtypes.h: Fix incorrect limits for + input and config voltages in APC report descriptor The Back-UPS XS + 1400U has been observed to report input/config voltage limits that + are appropriate for the North American 120V region even though the + unit is operating in the European or other 220+V region. This + change diagnoses the the problem by checking if the logical maximum + values for UPS.Input.Voltage and UPS.Input.ConfigVoltage are + consistent with the UPS.Input.HighVoltageTransfer and if not, + increases them. A similar problem was reported for CPS units in + the EU region. - introduces #defines for all standard usages in + power system and battery device pages. - moves cps-hid.c + FindReport() to hidparser.c as FindObject_with_ID_Node(). - updates + cps-hid.c to account for new defines/function name - adds + apc_fix_report_desc() to implement change for APC UPS units + +2022-02-11 Jim Klimov + + * NEWS: NEWS: added usbhid-ups "ever-hid" subdriver for NUT v2.7.5 + * docs/man/upsd.conf.txt: docs/man/upsd.conf.txt: document + DISABLE_WEAK_SSL + * NEWS, docs/nut.dict: NEWS: announce "debug_min" options for daemons + in NUT v2.7.5 + * NEWS: NEWS: announce fore-/back-grounding options for daemons in + NUT v2.7.5 + * docs/man/upsd.conf.txt: docs/man/upsd.conf.txt: document optional + "DEBUG_MIN" setting + * conf/upsd.conf.sample: conf/upsd.conf.sample: document optional + "DEBUG_MIN" setting + * conf/upsmon.conf.sample.in: conf/upsmon.conf.sample.in: document + optional "DEBUG_MIN" setting + * conf/ups.conf.sample: conf/ups.conf.sample: document optional + "debug_min" setting + * docs/man/upsmon.conf.txt: docs/man/upsmon.conf.txt: document + optional "DEBUG_MIN" setting + * docs/man/ups.conf.txt: docs/man/ups.conf.txt: document optional + "debug_min" setting + * server/conf.c, server/conf.h, server/upsd.c: server/upsd.c, conf.c: + support "debug_min" from upsd.conf + * clients/upsmon.c: clients/upsmon.c: support "debug_min" from + upsmon.conf + * drivers/main.c: drivers/main.c: comment typo fixes + * docs/man/upslog.txt: docs/man/upslog.txt: fix typo "upsmon" => + "upslog" + * clients/upslog.c: clients/upslog.c: align -F/-B options with + drivers/main.c + * scripts/systemd/nut-monitor.service.in: scripts/systemd/nut- + monitor.service.in: with daemon not backgrounding, "Type=forking" + no longer applies + * docs/man/upsd.txt: docs/man/upsd.txt: document -F/-B for fore/back- + ground enforcement, and that -D only defaults to foregrounding now + (can be overridden) + * server/upsd.c: server/upsd.c: align -F/-B options with + drivers/main.c + * docs/man/upsmon.txt: docs/man/upsmon.txt: document -F/-B for + fore/back-ground enforcement, and that -D only defaults to + foregrounding now (can be overridden) + * clients/upsmon.c: clients/upsmon.c: align -F/-B options with + drivers/main.c + * docs/man/nutupsdrv.txt: docs/man/nutupsdrv.txt: document -F/-B for + fore/back-ground enforcement, and that -D/-d only default to + foregrounding now (can be overridden) + * drivers/main.c: drivers/main.c: update comments + +2019-03-19 Jim Klimov + + * drivers/main.c: drivers/main.c : rearrange handling of configured + nut_debug_level_global vs nut_debug_level_driver vs ultimately used + nut_debug_level + * drivers/main.c: driver/main.c : separate toggles for driver + debugging and backgrounding + +2019-03-18 Jim Klimov + + * drivers/main.c: drivers/main.c : allow to configure debug_min=NUM + to ease service debugging + +2022-02-11 Dimitris Economou + + * drivers/adelsystem_cbi.c, drivers/adelsystem_cbi.h: coding style + changes + +2022-02-10 Jim Klimov + + * .github/pull_request_template.md: .github/pull_request_template.md: + remind to update recipes for new man pages + +2022-02-11 Dimitris Economou + + * drivers/adelsystem_cbi.c: fix parameter hiding global variable + +2022-02-10 Jim Klimov + + * configure.ac: configure.ac: avoid noise about pkg-config not + finding (lib)systemd.pc on systems where it is not installed + * configure.ac: configure.ac: default to detection of + systemdsystemunitdir (and systemdshutdowndir) - "auto" is not a + final option + * configure.ac, docs/configure.txt: configure.ac: default to + detection of systemdsystemunitdir (and systemdshutdowndir), non- + fatal if not found + * configure.ac: configure.ac: fall back from pkg-config queries for + "systemd" to try also "libsystemd" - fix calling "test" + +2022-02-10 Nick Geoghegan + + * drivers/riello_usb.c: Fixes formatting in riello_usb + * drivers/riello_ser.c: Updates riello_ser to version 0.07 + +2022-02-10 Jim Klimov + + * configure.ac: configure.ac: fall back from pkg-config queries for + "systemd" to try also "libsystemd" + * docs/man/Makefile.am: docs/man/Makefile.am: build and install + nutdrv_siemens_sitop man pages + +2022-02-09 Nick Geoghegan + + * drivers/riello_usb.c: Fixes 530 + +2022-02-09 Jim Klimov + + * drivers/nutdrv_qx_masterguard.c: drivers/nutdrv_qx_masterguard.c: + rename non-standard dstate variables to "experimental.*" namespace + Closes: NUT issue #1045 + * drivers/nutdrv_qx_masterguard.c: drivers/nutdrv_qx_masterguard.c: + fix "ups.delay.return" => "ups.delay.start" + * drivers/nutdrv_qx_masterguard.c: drivers/nutdrv_qx_masterguard.c: + whitespace fixes (some long lines) + * docs/packager-guide.txt: docs/packager-guide.txt: update for nut- + linux-i2c and nut-macosx-ups platform-dependent package groups + * docs/packager-guide.txt: docs/packager-guide.txt: fix title for + pkg-nut-modbus + * drivers/ever-hid.c: drivers/ever-hid.c: tag non-standard NUT + variable/command names as "experimental.*" to help identify lacking + mappings and rename some into standard data points + * drivers/ever-hid.c, drivers/ever-hid.h: drivers/ever-hid.{c,h}: + update (C) heading + * drivers/ever-hid.c: drivers/ever-hid.c: print unsigned int as %u + * drivers/ever-hid.c: drivers/ever-hid.c: mark + NUT_UNUSED_VARIABLE(double value) where appropriate + * drivers/ever-hid.c: drivers/ever-hid.c: use complete struct + initializers for info_lkp_t tables; use sentinels; mark static + * drivers/ever-hid.c: drivers/ever-hid.c: ever_alarms_fun(), + ever_workmode_fun(): define "workmode" on top of function + * drivers/ever-hid.c: drivers/ever-hid.c: fix switch/case whitespaces + * drivers/ever-hid.c: drivers/ever-hid.c: fix trailing whitespaces + * drivers/ever-hid.c: drivers/ever-hid.c: wrap some long lines for + readability + * drivers/ever-hid.c: drivers/ever-hid.c: adjust to upstream changes: + config.h goes first, PID/VID are unsigned, got a fix_report_desc() + default + * drivers/everups.c: drivers/everups.c: whitespace fixes; clarify + this is a serial driver (as opposed to ever-hid.c for USB devices) + +2022-02-08 Dimitris Economou + + * drivers/adelsystem_cbi.h: check ifndef READALL_REGS + * drivers/adelsystem_cbi.c: minor fix in upsdrv_updateinfo + * drivers/adelsystem_cbi.c, drivers/adelsystem_cbi.h: fix warning for + initializing structure with flexible array member + +2022-02-08 Jim Klimov + + * configure.ac: configure.ac: error out for unhandled --with- + drivers=xxx names + * configure.ac: configure.ac: improve handling of platform-dependent + (linux-i2c, macosx) drivers - do not default to require them + everywhere + * configure.ac: configure.ac: move --with-drivers=... handling to + before --with-all, and consult drivers/Makefile.am for list names + to require certain dependencies + * drivers/Makefile.am: drivers/Makefile.am: parameterize + POWERMAN_DRIVERLIST and IPMI_DRIVERLIST like others + * configure.ac: configure.ac: move "--with-drivers=name[,name...]" + handling to before we check for third-party dependencies + * clients/upssched.c: clients/upssched.c: sendcmd(): rectify + enclen/buflen sanity checks and usage + * clients/upssched.c: clients/upssched.c: whitespace and comment + fixes + +2022-02-07 Dimitris Economou + + * clients/upssched.c: fix code alignemnt, casting sizeof with ssize_t + +2022-02-07 Jim Klimov + + * scripts/subdriver/gen-usbhid-subdriver.sh: gen-usbhid-subdriver.sh: + suggest "fix_report_desc" in subdriver_t (follow-up to PR #1245) + +2022-02-06 Jim Klimov + + * docs/packager-guide.txt: docs/packager-guide.txt: mention ipmi and + modbus drivers as separate packaging goals + +2022-02-06 Dimitris Economou + + * clients/upssched.c: check zero bytes read from O_NDELAY socket + * clients/upssched.c: fix enc size write on pipeifd, fix parent + select on child's pipefd + * drivers/Makefile.am: adelsystem_cbi header filename fix + +2022-02-05 Jim Klimov + + * docs/nut.dict, docs/support.txt: docs/support.txt: detail abot + GitHub issues and PRs, and IRC channel + * drivers/al175.c, drivers/apc-ats-mib.c, drivers/apc-hid.c, + drivers/apc-mib.c, drivers/apc-pdu-mib.c, drivers/apcsmart-old.c, + drivers/apcsmart.h, drivers/apcupsd-ups.c, drivers/arduino-hid.c, + drivers/asem.c, drivers/baytech-mib.c, drivers/bcmxcp.c, + drivers/bcmxcp_ser.c, drivers/bcmxcp_usb.c, drivers/belkin-hid.c, + drivers/belkin.c, drivers/belkinunv.c, drivers/bestfcom.c, + drivers/bestfortress.c, drivers/bestpower-mib.c, + drivers/bestuferrups.c, drivers/bestups.c, drivers/blazer_ser.c, + drivers/blazer_usb.c, drivers/clone-outlet.c, drivers/clone.c, + drivers/compaq-mib.c, drivers/cps-hid.c, drivers/cyberpower-mib.c, + drivers/delta_ups-hid.c, drivers/delta_ups-mib.c, drivers/dummy- + ups.c, drivers/eaton-ats16-nm2-mib.c, drivers/eaton-ats16-nmc- + mib.c, drivers/eaton-ats30-mib.c, drivers/eaton-pdu-genesis2-mib.c, + drivers/eaton-pdu-marlin-mib.c, drivers/eaton-pdu-pulizzi-mib.c, + drivers/eaton-pdu-revelation-mib.c, drivers/emerson-avocent-pdu- + mib.c, drivers/etapro.c, drivers/everups.c, drivers/explore-hid.c, + drivers/gamatronic.c, drivers/generic_modbus.c, + drivers/genericups.c, drivers/hpe-pdu-mib.c, drivers/huawei-mib.c, + drivers/huawei-ups2000.c, drivers/idowell-hid.c, drivers/ietf- + mib.c, drivers/isbmex.c, drivers/ivtscd.c, drivers/legrand-hid.c, + drivers/libshut.c, drivers/libusb0.c, drivers/libusb1.c, + drivers/liebert-esp2.c, drivers/liebert-hid.c, drivers/liebert.c, + drivers/macosx-ups.c, drivers/masterguard.c, drivers/metasys.c, + drivers/mge-hid.c, drivers/mge-mib.c, drivers/mge-utalk.c, + drivers/microdowell.c, drivers/microsol-apc.c, drivers/netvision- + mib.c, drivers/netxml-ups.c, drivers/nut-ipmipsu.c, + drivers/nutdrv_atcl_usb.c, drivers/nutdrv_qx.c, + drivers/nutdrv_siemens_sitop.c, drivers/oneac.c, drivers/openups- + hid.c, drivers/optiups.c, drivers/phoenixcontact_modbus.c, + drivers/pijuice.c, drivers/powercom-hid.c, drivers/powercom.c, + drivers/powerman-pdu.c, drivers/powerpanel.c, drivers/powervar- + hid.c, drivers/powerware-mib.c, drivers/raritan-pdu-mib.c, + drivers/raritan-px2-mib.c, drivers/rhino.c, drivers/richcomm_usb.c, + drivers/riello_ser.c, drivers/riello_usb.c, drivers/safenet.c, + drivers/salicru-hid.c, drivers/skel.c, drivers/snmp-ups.c, + drivers/solis.c, drivers/tripplite-hid.c, drivers/tripplite.c, + drivers/tripplite_usb.c, drivers/tripplitesu.c, drivers/upscode2.c, + drivers/usbhid-ups.c, drivers/victronups.c, drivers/xppc-mib.c: + drivers: bump versions for all drivers, they could have been + refactored during fightwarn (so might add regressions) without + regard to versioning + * UPGRADING: NEWS: plea to package maintainers to share their + customizations into common uptream + * docs/documentation.txt, docs/nut.dict: documentation.txt: add a + blog by James Ridgway + * docs/documentation.txt: documentation.txt: update with a link to + video by Techno Tim + * docs/documentation.txt: developers.txt: "trac" is AWOL, update the + link to github wiki copy + * docs/developers.txt: developers.txt: "alioth" is AWOL, update the + text + * docs/download.txt: download.txt: "trac" and "alioth" are AWOL, + update the links + +2022-02-05 Dimitris Economou + + * drivers/adelsystem_cbi.c: apply Jim's modbus changes on PR #1239 + +2022-01-23 Jim Klimov + + * ci_build.sh: ci_build.sh: fix CI_FAILFAST to abort after failed + configure scripts + +2022-01-27 Jim Klimov + + * drivers/snmp-ups.c: Revert "drivers/snmp-ups.c: replace + strcmp("short string") with strncmp() (clang-3.4 warns about array + out of bounds)" This reverts commit + d2f7193af42e987f7948e072a963dc7bb1e25dc1. Currently the configure + script should properly avoid the built-in strcmp() versions which + upset current build compiler. Using the range-limited strncmp() has + a downside of matching start-of-string. + * drivers/snmp-ups.c: Revert "drivers/snmp-ups.c: fix strncmp() + limits for "v1" and "v3" checks (copy-pasting typo)" This reverts + commit d0d02d3a70c6544c8ea7868dd63738595f2ae657. Currently the + configure script should properly avoid the built-in strcmp() + versions which upset current build compiler. Using the range- + limited strncmp() has a downside of matching start-of-string. + * clients/upsclient.c, clients/upslog.c, clients/upsmon.c, + clients/upsrw.c, clients/upssched.c, clients/upsset.c, + common/state.c, common/upsconf.c, docs/developers.txt, + docs/nut.dict, drivers/apcsmart-old.c, drivers/apcsmart.c, + drivers/apcupsd-ups.c, drivers/belkin.c, drivers/belkinunv.c, + drivers/bestups.c, drivers/clone-outlet.c, drivers/clone.c, + drivers/dstate.c, drivers/gamatronic.c, drivers/huawei-ups2000.c, + drivers/main.c, drivers/masterguard.c, drivers/mge-utalk.c, + drivers/mge-xml.c, drivers/nutdrv_qx.c, + drivers/nutdrv_qx_bestups.c, drivers/nutdrv_qx_blazer-common.c, + drivers/nutdrv_qx_voltronic-qs-hex.c, drivers/nutdrv_qx_voltronic- + qs.c, drivers/nutdrv_qx_voltronic.c, drivers/oneac.c, + drivers/powercom.c, drivers/powerman-pdu.c, drivers/powerp-txt.c, + drivers/snmp-ups.c, drivers/tripplite_usb.c, drivers/upscode2.c, + drivers/victronups.c, server/conf.c, server/netget.c, + server/netlist.c, server/netset.c, server/user.c, + tests/cpputest.cpp, tools/nut-scanner/nut-scanner.c, tools/nut- + scanner/scan_snmp.c: Revert "Replace strcmp() and strcasecmp() use- + cases for short fixed string args by strncmp() and strncasecmp() + respectively" This reverts commit + a0d5ad57956ebcb5878744acb7657e1356ba0ea8. Currently the configure + script should properly avoid the built-in strcmp() versions which + upset current build compiler. Using the range-limited strncmp() has + a downside of matching start-of-string. + * drivers/snmp-ups.c, tools/nut-scanner/scan_snmp.c: Revert + "tools/nut-scanner/scan_snmp.c, drivers/snmp-ups.c: strcmp() + shorter "SHA" and "AES" and check this is all of the string length" + This reverts commit 57182d51b2954e6b7bb5199f658f38a89ce93648. + Currently the configure script should properly avoid the built-in + strcmp() versions which upset current build compiler. Using the + range-limited strncmp() has a downside of matching start-of-string. + +2022-01-23 Jim Klimov + + * NEWS, UPGRADING: NEWS, UPGRADING: snmp-ups.h flags (bit-mask + macros) changed for NUT v2.7.5 + * drivers/snmp-ups.h: drivers/snmp-ups.h: mib2nut mappings with + "zero" flag value are not illegal + +2022-01-18 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: mib2nut mappings with + "zero" flag value are not illegal Do not yell about them like it's + a bug, after all. + +2022-01-23 Jim Klimov + + * drivers/snmp-ups.h: drivers/snmp-ups.h: redefine bit-flags macros + so they do not overlap (and update some helper-masking macros) + follows up on issue from PR #1177 and aligns with ultimately DMF + (42ity fork) tested changes to help merge that later with less + effort + +2021-11-22 Jim Klimov + + * drivers/snmp-ups.h: drivers/snmp-ups.h: update mask for + SU_TYPE_DAISY() and comments for it and SU_DAISY + +2021-11-13 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: report if an snmp_info[] + entry flag was not defined (is 0) + * drivers/snmp-ups.h: drivers/snmp-ups.h: redefine bit-flags macros + so they do not overlap (and some helper-masking macros) [follow up + on issue from PR #1177] + +2022-01-22 Jim Klimov + + * NEWS: NEWS: drop chapters for "PLANNED NEWS" for releases after + v2.7.5 + * UPGRADING: UPGRADING: highlight libusb-1.0 in NUT v2.7.5 + +2022-01-21 Jim Klimov + + * docs/config-prereqs.txt, docs/nut.dict: docs/config-prereqs.txt: + "libssl-dev" name is more popular nowadays than "openssl-dev" + (Debian and family) + * docs/nut.dict: docs/nut.dict: update for Armac subdriver NEWS + * data/driver.list.in: data/driver.list.in: add PiJuice HAT (big) and + pHAT (Zero) + +2022-01-20 Jim Klimov + + * drivers/snmp-ups.c, tools/nut-scanner/scan_snmp.c: tools/nut- + scanner/scan_snmp.c, drivers/snmp-ups.c: strcmp() shorter "SHA" and + "AES" and check this is all of the string length Alternative: move + matching to end of stack + * NEWS: NEWS: prepare for nutdrv-qx armac merge in 2.7.5 timeline + * NEWS: NEWS: added usbhid-ups fix_report_desc() for NUT v2.7.5 + * NEWS: NEWS: added powercom "nobt" option for NUT v2.7.5 + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: armac_command(): + accomodate "usb_ctrl_charbuf" and formatting changes for libusb-1.0 + support + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: armac_command(): mark as + static method + * drivers/nutdrv_qx_ablerex.c: drivers/nutdrv_qx_ablerex.c: + ablerex_process_status_bits(): mark as static method + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: ablerex_command(): + accomodate "usb_ctrl_charbuf" and formatting changes for libusb-1.0 + support + * ci_build.sh: ci_build.sh: make distcheck (pun intended) less noisy + * ci_build.sh: ci_build.sh: comment a suggestion how to use + BUILD_TYPE=fightwarn typically + * ci_build.sh: ci_build.sh: make distcheck (pun intended) less noisy + * ci_build.sh: ci_build.sh: comment a suggestion how to use + BUILD_TYPE=fightwarn typically + +2022-01-20 Jim Klimov + + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: armac_command(): use + nut_usb_strerror(ret) Match updated libusb-1.0/0.1 API in NUT + master + * drivers/nutdrv_qx.c: Update nutdrv_qx.c Fix nut_usb_strerror(ret) + for new libusb-1.0/0.1 support in master branch + +2022-01-19 Jim Klimov + + * drivers/legrand-hid.c: Update legrand-hid.c Initialize + "fix_report_desc", this file appeared from another PR merged before + #1245 + +2022-01-19 Jim Klimov + + * ci_build.sh: ci_build.sh: provision check_gitignore() calls for DMF + branch build products + * ci_build.sh: ci_build.sh: check_gitignore(): wrap long lines + * ci_build.sh: ci_build.sh: check_gitignore(): add a FILE_GLOB + support + * ci_build.sh: ci_build.sh: optional_dist_clean_check(): copypasta + error, GIT_ARGS not needed in this one + * ci_build.sh: ci_build.sh: fix "MAKE distclean" operations back to + not-quiet, they look weird as a half-muted wall of text + * ci_build.sh: ci_build.sh: fix use of git status $GIT_ARGS + consistently + * drivers/snmp-ups.c: drivers/snmp-ups.c: match_sysoid(): test for + NULL mib2nut[i]->snmp_info (and skip if so) + * drivers/snmp-ups.c: drivers/snmp-ups.c: load_mib2nut(): imply that + skipped value is not a "valid" name in the mapping table (name may + be known, but with no snmp_info attached) + +2022-01-18 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: handle not-loaded snmp_info + without segfaulting + * drivers/snmp-ups.c: drivers/snmp-ups.c: load_mib2nut(): better + tracing of mib_name comparisons + * drivers/snmp-ups.c: drivers/snmp-ups.c: load_mib2nut(): test for + NULL mib2nut[i]->snmp_info (and skip if so) before accounting + mibSeen=TRUE and trying to match_model_OID() + +2022-01-18 Dimitris Economou + + * drivers/adele_cbi.c, drivers/adele_cbi.h: delete duplicates after + rebase + * drivers/{adele_cbi.c => adelsystem_cbi.c}, drivers/{adele_cbi.h => + adelsystem_cbi.h}: rename after rebase + * drivers/{adelsystem_cbi.c => adele_cbi.c}, + drivers/{adelsystem_cbi.h => adele_cbi.h}: rename for rebase + +2022-01-13 Dimitris Economou + + * drivers/adelsystem_cbi.c: try to reconnect on IVALID DATA and + INVALID CRC from read_all_regs + * drivers/adelsystem_cbi.c: try to reconnect on INVALID DATA and + INVALID CRC errors + * drivers/adele_cbi.c, drivers/adele_cbi.h, + drivers/adelsystems_cbi.c, drivers/adelsystems_cbi.h: delete + renamed driver files + * drivers/Makefile.am, drivers/adelsystem_cbi.c, + drivers/adelsystem_cbi.h: filename fixes + * drivers/Makefile.am, drivers/adelsystems_cbi.c, + drivers/adelsystems_cbi.h: adele changed to adelsystems + * drivers/adele_cbi.c, drivers/adele_cbi.h: macro name changes + * drivers/adele_cbi.c, drivers/adele_cbi.h: minor bug fixes + * drivers/adele_cbi.h: modify regs_data memory, devreg enum + rearrangement + +2022-01-12 Dimitris Economou + + * drivers/adele_cbi.c, drivers/adele_cbi.h: some fixes in + read_all_regs approach + * drivers/adele_cbi.c, drivers/adele_cbi.h: read_all_regs aproach + integrated + +2022-01-11 Dimitris Economou + + * drivers/adele_cbi.c, drivers/adele_cbi.h: ghost alarms bug fix, + other bug fixes + +2022-01-10 Dimitris Economou + + * drivers/adele_cbi.c, drivers/adele_cbi.h: first testing release + +2022-01-09 Dimitris Economou + + * drivers/adele_cbi.c, drivers/adele_cbi.h: alrm_t, alrm_ar_t data + structures, construction of upsdrv_updateinfo in progress + +2022-01-08 Dimitris Economou + + * drivers/adele_cbi.c, drivers/adele_cbi.h: structure device data, + code get_dev_state, in progress + +2022-01-07 Dimitris Economou + + * drivers/adele_cbi.h: register status values and masks added + +2022-01-06 Dimitris Economou + + * drivers/adele_cbi.c, drivers/adele_cbi.h: under construction + +2022-01-11 Dimitris Economou + + * drivers/adele_cbi.c, drivers/adele_cbi.h: ghost alarms bug fix, + other bug fixes + +2022-01-10 Dimitris Economou + + * drivers/adele_cbi.c, drivers/adele_cbi.h: first testing release + +2022-01-09 Dimitris Economou + + * drivers/adele_cbi.c, drivers/adele_cbi.h: alrm_t, alrm_ar_t data + structures, construction of upsdrv_updateinfo in progress + +2022-01-08 Dimitris Economou + + * drivers/adele_cbi.c, drivers/adele_cbi.h: structure device data, + code get_dev_state, in progress + +2022-01-07 Dimitris Economou + + * drivers/adele_cbi.h: register status values and masks added + +2022-01-06 Dimitris Economou + + * drivers/Makefile.am: Makefile.am modifications + * drivers/adele_cbi.c, drivers/adele_cbi.h: under construction + +2022-01-18 Dimitris Economou + + * drivers/{adelsystem_cbi.c => adele_cbi.c}, + drivers/{adelsystem_cbi.h => adele_cbi.h}: rename for rebase + +2022-01-18 Jim Klimov + + * drivers/usbhid-ups.h: drivers/usbhid-ups.h: rename pDesc arg to + match wording in usbhid-ups.c + * drivers/hidparser.c, drivers/hidparser.h: drivers/hidparser.{c,h}: + rename pDesc arg/var to avoid shadowing a global variable Pre- + emptively: `extern pDesc` is defined in libhid.h which does not + seem to be used in/along-with hidparser.{c,h} currently - but this + collision may happen later (especially with code-copying around). + * drivers/cps-hid.c: drivers/cps-hid.c: clean up trailing whitespaces + * drivers/cps-hid.c: drivers/cps-hid.c: FindReport() + cps_fix_report_desc(): rename pDesc arg to avoid shadowing a global + variable + * drivers/cps-hid.c: drivers/cps-hid.c: mark non-exported + FindReport() as static + * m4/nut_compiler_family.m4: m4/nut_compiler_family.m4: enhance + NUT_CHECK_COMPILE_FLAG() to run the whole toolchain for "build and + run" when checking CLI option support + * ci_build.sh: ci_build.sh: build_to_only_catch_errors_target(): + CI_PARMAKE_VERBOSITY=silent should not hide warnings + * ci_build.sh: ci_build.sh: do not silent-make initial clean-up (it + is chatty anyway, so let us see the dirs processed) + * ci_build.sh: ci_build.sh: comment verbosity (non-)tweaks for builds + without a BUILD_TYPE + * ci_build.sh: ci_build.sh: report around initial clean-up for + clearer log reading + * ci_build.sh: ci_build.sh: refactor with check_gitignore() + * ci_build.sh: ci_build.sh: refactor ccache_stats() + * ci_build.sh: ci_build.sh: refactor make-verbosity settings and + adjust some for default builds to store less log + +2022-01-18 Jim Klimov + + * tools/nut-scanner/scan_usb.c: tools/nut-scanner/scan_usb.c: avoid + SIGSEGV in libusb-1.0 when running as non-root and device fails to + open (e.g. perms error) + +2022-01-17 Jim Klimov + + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + report in usage() if "library not detected" for a scan option + +2022-01-17 Jim Klimov + + * drivers/generic_modbus.c: drivers/generic_modbus.c: address + -Wmissing-field-initializers complaints for timeval with timeouts + (memset to 0 instead) + * drivers/generic_modbus.c: drivers/generic_modbus.c: address + -Wstrict-prototypes complaints + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: raise the bar for + code quality non-regression, to fail on any (new) warnings in + master branch and PRs to it + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: shut back the + cppcheck-by-default + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: do not allow to + disable delayedIssueAnalysis on "stable branches" + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: enable cppcheck + slowBuild stages generally, not just for "fightwarn" branches + +2022-01-16 Jim Klimov + + * configure.ac: configure.ac: adjust test structure for both built-in + ntohl/htonl and string built-ins (using explicit -Werror -Wno-... + checks) + * configure.ac: configure.ac: adjust test structure for built-in + ntohl/htonl to be similar to that for string built-ins (using + explicit -Werror) + * ci_build.sh: ci_build.sh: do not lose original LDFLAGS + +2022-01-15 Jim Klimov + + * configure.ac: configure.ac: tweak LIBLTDL_CFLAGS same as + LIBNETSNMP_CFLAGS for -Wno-shadow if needed for string methods or + htonl() etc In some builds of the NUT CI farm dynamatrix (possibly + ones without SNMP support), the nutscan-ip.c complains about + "declaration shadows a local variable" -- investigation of which + leads into the macros expanded for common method names on those + systems and/or compiler toolkit versions. This PR hopes to avoid + that situation more extensively. + +2022-01-14 Jim Klimov + + * drivers/snmp-ups.h: drivers/snmp-ups.h: treat DISABLE_MIB_LOADING + more safely + +2022-01-14 Jim Klimov + + * tests/cpputest.cpp, tests/example.cpp, tests/nutclienttest.cpp: + tests/*.cpp: mark overridden class methods as such + * clients/nutclient.h, clients/nutclientmem.h: clients/nutclient.h + + nutclientmem.h: mark overridden class methods as such + +2022-01-13 Jim Klimov + + * configure.ac: configure.ac: adjust test for built-in string + functions (problematic on clang-3.4) to see any warnings and + specifically for unreachable code there + * ci_build.sh: ci_build.sh: relay more build-influencing envvars in + the (Jenkins-logged) printout + * drivers/nut-libfreeipmi.c: drivers/nut-libfreeipmi.c: fix the + range-check and message/comment it better + * drivers/asem.c: drivers/asem.c: macro ACCESS_DEVICE() ends with a + brace; we HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXTRA_SEMI_STMT to + keep the useless trailing ";" for readability + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: add + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXTRA_SEMI_STMT(_BESIDEFUNC) + * drivers/asem.c: drivers/asem.c: declare upsdrv_shutdown() as + noreturn + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: avoid including usb- + common.h twice + +2022-01-13 Dimitris Economou + + * drivers/adelsystem_cbi.c: try to reconnect on IVALID DATA and + INVALID CRC from read_all_regs + * drivers/adelsystem_cbi.c: try to reconnect on INVALID DATA and + INVALID CRC errors + +2022-01-13 Jim Klimov + + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: ask CLANG to reject unknown + pragmas when checking for them + * common/common.c: common/common.c: check for + HAVE_PRAGMA_CLANG_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN + support before use + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: test specifically for HAVE_ + PRAGMA_CLANG_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN(_BESIDEFUNC + ) support + +2022-01-13 Dimitris Economou + + * drivers/adele_cbi.c, drivers/adele_cbi.h, + drivers/adelsystems_cbi.c, drivers/adelsystems_cbi.h: delete + renamed driver files + * drivers/Makefile.am, drivers/adelsystem_cbi.c, + drivers/adelsystem_cbi.h: filename fixes + * drivers/Makefile.am, drivers/adelsystems_cbi.c, + drivers/adelsystems_cbi.h: adele changed to adelsystems + * drivers/adele_cbi.c, drivers/adele_cbi.h: macro name changes + * drivers/adele_cbi.c, drivers/adele_cbi.h: minor bug fixes + * drivers/adele_cbi.h: modify regs_data memory, devreg enum + rearrangement + +2022-01-12 Dimitris Economou + + * drivers/adele_cbi.c, drivers/adele_cbi.h: some fixes in + read_all_regs approach + * drivers/adele_cbi.c, drivers/adele_cbi.h: read_all_regs aproach + integrated + +2022-01-12 Jim Klimov + + * m4/nut_compiler_family.m4: m4/nut_compiler_family.m4: set default + C/C++ standards to GNU dialects for GCC/CLANG + * m4/nut_compiler_family.m4: m4/nut_compiler_family.m4: set default + C/C++ standards to avoid C90-non-compliance warnings noise (on + compilers that can do better than that) + * m4/nut_check_libnetsnmp.m4: m4/nut_check_libnetsnmp.m4: fix a test + from shell to autoscript + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + only evaluate if NUT_HAVE_LIBNETSNMP_* when we build WITH_SNMP + * common/common.c: common/common.c: use + HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: add HAVE_PRAGMA_GCC_DIAGNOS + TIC_IGNORED_UNREACHABLE_CODE_RETURN(_BESIDEFUNC) + * configure.ac, m4/nut_compiler_family.m4: m4/nut_compiler_family.m4 + + configure.ac: refactor NUT_COMPILER_FAMILY_FLAGS_DEFAULT_STANDARD + as a separate method to apply just before we set up warning-level + support + * docs/config-prereqs.txt, docs/nut.dict: docs/config-prereqs.txt: + update dependency package naming for libusb-1.0 on Debian family + * m4/nut_compiler_family.m4: m4/nut_compiler_family.m4: set default + C/C++ standards to GNU dialects for GCC/CLANG + * m4/nut_compiler_family.m4: m4/nut_compiler_family.m4: set default + C/C++ standards to avoid C90-non-compliance warnings noise (on + compilers that can do better than that) + * ci_build.sh: ci_build.sh: comment why ./configure is not without + args + +2022-01-11 Dimitris Economou + + * drivers/adele_cbi.c, drivers/adele_cbi.h: ghost alarms bug fix, + other bug fixes + +2022-01-10 Dimitris Economou + + * drivers/adele_cbi.c, drivers/adele_cbi.h: first testing release + +2022-01-09 Dimitris Economou + + * drivers/adele_cbi.c, drivers/adele_cbi.h: alrm_t, alrm_ar_t data + structures, construction of upsdrv_updateinfo in progress + +2022-01-08 Dimitris Economou + + * drivers/adele_cbi.c, drivers/adele_cbi.h: structure device data, + code get_dev_state, in progress + +2022-01-07 Dimitris Economou + + * drivers/adele_cbi.h: register status values and masks added + +2022-01-06 Dimitris Economou + + * drivers/Makefile.am: Makefile.am modifications + * drivers/adele_cbi.c, drivers/adele_cbi.h: under construction + +2021-09-23 Jim Klimov + + * drivers/generic_modbus.c: drivers/generic_modbus.{c,h}: fix + whitespace style (original fix from master branch) + +2022-01-12 Jim Klimov + + * drivers/generic_modbus.c: drivers/generic_modbus.c: fix whitespace + style (in PR-1239) + +2022-01-12 Arnaud Quette + + * drivers/mge-xml.c: Eaton NMC: fix the non publication of real/power + with 3ph power and realpower for 3ph Lx were not publishing values + when they were 0 + +2022-01-11 Dave Williams + + * drivers/cps-hid.c: New HID fix strategy after consultation with CPS + It appears both input and output LogMin and LogMax values are + incorrect as the rated voltage (for EU models) is 170v to 270v + which is outside the logical limits reported by the HID. The fix + checks for the error (loosely) and then applies reasonable values + (0v and 511v) to allow the actual input and output voltages to be + reported rather than be constrained to the limits. + +2022-01-11 Jim Klimov + + * drivers/arduino-hid.c, drivers/delta_ups-hid.c, + drivers/hidparser.c, drivers/idowell-hid.c, drivers/powervar-hid.c, + drivers/salicru-hid.c: drivers/hidparser.c + *-hid.c: include + "config.h" first + +2022-01-11 Jim Klimov + + * docs/nut.dict: Update nut.dict Updated for PR + https://github.com/networkupstools/nut/pull/1256 + +2022-01-11 Jim Klimov + + * drivers/generic_modbus.c: drivers/generic_modbus.c: handle the two + APIs for libmodbus timeout setting + * m4/nut_check_libmodbus.m4: m4/nut_check_libmodbus.m4: in tests for + API, the AC_DEFINE must be used with exact macro names (not + m4/shell variables) + * m4/nut_check_libmodbus.m4: m4/nut_check_libmodbus.m4: in tests for + API, clarify if old API (timeval) can be used with variables from + new API (uint32) set into the struct + * m4/nut_check_libmodbus.m4: m4/nut_check_libmodbus.m4: in tests for + API, "new/old" comments were confused + * m4/nut_check_libmodbus.m4: m4/nut_check_libmodbus.m4: in tests for + API, initialize modbus_t *ctx differently + * m4/nut_check_libmodbus.m4: m4/nut_check_libmodbus.m4: test actively + for the modbus timeout API (count and type of args used) + * m4/nut_check_libmodbus.m4: m4/nut_check_libmodbus.m4: convert a + code block from plain shell to autoscript + * m4/nut_check_libmodbus.m4: m4/nut_check_libmodbus.m4: test for + presence of modbus_set_byte_timeout() and + modbus_set_response_timeout() + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: detect support for + (ignoring) "-Wsign-conversion" + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: add guards to call + AX_C_PRINTF_STRING_NULL and AX_C_PRAGMAS logic only once + * drivers/generic_modbus.c: drivers/generic_modbus.c: bump + DRIVER_VERSION for feature change (connection timeout handling) + +2022-01-10 Ablerexsoftware + + * data/driver.list.in: update the driver.list.in + +2022-01-11 Dimitris Economou + + * drivers/adele_cbi.c, drivers/adele_cbi.h: ghost alarms bug fix, + other bug fixes + +2022-01-10 Jim Klimov + + * docs/man/powercom.txt: Update powercom.txt Sentence restructure + +2022-01-10 Jim Klimov + + * .github/pull_request_template.md: pull_request_template.md: update + and reshuffle check-list items + * .../{PULL_REQUEST_TEMPLATE/nut-driver-PR.md => + pull_request_template.md}: Move fancy-named PR template to plain + .github/pull_request_template.md + * drivers/salicru-hid.c, scripts/upower/95-upower-hid.rules: + drivers/salicru-hid.c: add known compatibility for Salicru SLC TWIN + (PRO2, PRO3, RT3) per reports in issue #1142 + * data/driver.list.in: data/driver.list.in: add known compatibility + for Salicru TWIN (PRO2, PRO3, RT3) per reports in issues #450 and + #1142 + * .github/PULL_REQUEST_TEMPLATE/nut-driver-PR.md: Add + .github/PULL_REQUEST_TEMPLATE/nut-driver-PR.md template + +2022-01-10 Dimitris Economou + + * drivers/adele_cbi.c, drivers/adele_cbi.h: first testing release + +2022-01-10 Jim Klimov + + * data/driver.list.in: data/driver.list.in: fix English typos in + comment + * docs/developers.txt: docs/developers.txt: remind to update + docs/acknowledgements.txt when adding vendor-backed support + * docs/man/usbhid-ups.txt: docs/man/usbhid-ups.txt: fix reference to + data/driver.list (typo in filename) + +2022-01-09 Rouben Tchakhmakhtchian + + * docs/man/powercom.txt, drivers/powercom.c: Powercom driver + (drivers/powercom.c) version bump from 0.17 to 0.18: * Implement + configuration flag "nobt" to skip battery test during + initialization * Cleanup old code to use testvar() for config + parameter checks in upsdrv_initups() * Add nobt flag to sample + config file in built-in doc Powercom driver man page + (docs/man/powercom.txt) update to explain nobt flag + +2022-01-09 Dimitris Economou + + * drivers/adele_cbi.c, drivers/adele_cbi.h: alrm_t, alrm_ar_t data + structures, construction of upsdrv_updateinfo in progress + +2022-01-08 Dimitris Economou + + * drivers/adele_cbi.c, drivers/adele_cbi.h: structure device data, + code get_dev_state, in progress + +2022-01-07 Jim Klimov + + * tools/nut-usbinfo.pl: tools/nut-usbinfo.pl: be sure to have + PATH_MAX defined (for usb.h that did not bother by itself) + * drivers/usb-common.h: drivers/usb-common.h: be sure to have + PATH_MAX defined (for usb.h that did not bother by itself) + +2022-01-07 Dimitris Economou + + * drivers/adele_cbi.h: register status values and masks added + +2022-01-06 Jim Klimov + + * Jenkinsfile-dynamatrix: Revert "Jenkinsfile-dynamatrix: be sure to + reset slowBuild configs over dynacfgBase" This reverts commit + 18cf19ebc7e01f30c3d84c7b3b8f69e961429ebb as the "design flaw" which + that change worked around should now be (hopefully) fixed in the + jenkins-fynamatrix library itselg. + +2022-01-06 Dimitris Economou + + * drivers/Makefile.am: Makefile.am modifications + * drivers/adele_cbi.c, drivers/adele_cbi.h: under construction + +2022-01-05 Jim Klimov + + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: fix + dynamatrixAxesCommonEnvCartesian cases to group the variables we + apply as one bunch, not as several separate hits + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: define + dynacfgPipeline.excludeCombos_DEFAULT (mismatched ARCHes only) + * tools/nut-scanner/scan_avahi.c: tools/nut-scanner/scan_avahi.c: + avoid implicit case fallthrough + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: be sure to reset + slowBuild configs over dynacfgBase + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: avoid running + "cppcheck" several times per host + +2022-01-04 Jim Klimov + + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: reinstate + excludeCombos for autotools-only builds (fightwarn) to avoid + unsupported ARCH-bits mix builds + +2022-01-02 Jim Klimov + + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: fix "Default + autotools driven build with default warning levels (gnu99/gnu++11)" + dynamatrixAxesVirtualLabelsMap mergeMode from "merge" to "replace" + (want to only build listed scenarios, not everything possible in + the matrix) + +2021-12-30 Jim Klimov + + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: avoid using + undefined (null) excludeCombos_DEFAULT + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: fix references to + excludeCombos: ... axisCombos_COMPILER_(NOT_)GCC + +2022-01-05 Jim Klimov + + * m4/nut_check_cppcheck.m4: m4/nut_check_cppcheck.m4: relax required + tool version for cppcheck*.xml generation + * Makefile.am: Makefile.am: fix dependencies for cppcheck*.xml + generation + +2022-01-04 Dimitris Economou + + * drivers/generic_modbus.c: comment and code alignment fixes + +2022-01-03 Jim Klimov + + * ci_build.sh: ci_build.sh: set DO_CLEAN_CHECK=no for default- + tgt:cppcheck or docs-building scenarios by default, so we can + get/archive those costly media files + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: set + DO_CLEAN_CHECK=no for default-tgt:cppcheck scenarios, so we can get + that analysis data + +2021-12-30 Jim Klimov + + * tools/nut-scanner/nutscan-ip.c: tools/nut-scanner/nutscan-ip.c: + include config.h first + +2021-12-30 Jim Klimov + + * docs/developers.txt, docs/nut.dict: docs/developers.txt: update + about C89/GNU89 support (with GCC toolkit) + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: separate + C89/C90/ANSI builds with GCC (can actually pass strict and GNU + modes) and CLANG (more pedantic) + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: typo fix for + disableSlowBuildCIBuildExperimentalANSI + +2021-12-30 Jim Klimov + + * m4/nut_compiler_family.m4: m4/nut_compiler_family.m4: do not test + for "-fcolor-diagnostics" - redundant for clang, and sometimes + toxic for gcc + * drivers/Makefile.am: drivers/Makefile.am: snmp-ups uses fabsf() so + needs libm + * drivers/nut-libfreeipmi.c: drivers/nut-libfreeipmi.c: include + config.h first + * drivers/microsol-apc.c: drivers/microsol-apc.c: include config.h + first + * drivers/genericups.c: drivers/genericups.c: include config.h first + * include/nut_stdint.h: include/nut_stdint.h: define SSIZE_MAX if + missing + * drivers/serial.h: drivers/serial.h: pull more includes + +2021-12-30 Jim Klimov + + * drivers/Makefile.am: drivers/Makefile.am: metasys uses fabsf() so + needs libm + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: fix comments to C-style + * drivers/powercom.c: drivers/powercom.c: fix comments to C-style + * drivers/microdowell.h: drivers/microdowell.h: fix comments to + C-style + * drivers/solis.h: drivers/solis.h: fix comments to C-style + * drivers/libshut.c: drivers/libshut.c: fix comments to C-style + * drivers/openups-hid.c: drivers/openups-hid.c: include config.h + first + * drivers/snmp-ups.c: drivers/snmp-ups.c: fix comments to C-style + * drivers/riello_usb.c: drivers/riello_usb.c: fix comments to C-style + * drivers/generic_modbus.h: drivers/generic_modbus.h: fix comments to + C-style + * tools/nut-scanner/scan_xml_http.c: tools/nut- + scanner/scan_xml_http.c: fix comments to C-style + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + fix comments to C-style + * tools/nut-scanner/nutscan-init.c: tools/nut-scanner/nutscan-init.c: + fix comments to C-style + * tools/nut-scanner/scan_eaton_serial.c: tools/nut- + scanner/scan_eaton_serial.c: fix comments to C-style + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: fix + comments to C-style + * tools/nut-scanner/scan_nut.c: tools/nut-scanner/scan_nut.c: fix + comments to C-style + * server/upsd.c: server/upsd.c: fix comments to C-style + * server/conf.c: server/conf.c: fix comments to C-style + * drivers/bcmxcp.c: drivers/bcmxcp.c: fix comments to C-style + * drivers/main.c: drivers/main.c: fix comments to C-style + * common/upsconf.c: common/upsconf.c: include config.h first + * common/str.c: common/str.c: fix comments to C-style + * server/user.c: server/user.c: include config.h first + * server/desc.c: server/desc.c: include config.h first + * drivers/upsdrvctl.c: drivers/upsdrvctl.c: include config.h first + * drivers/riello_usb.c: drivers/riello_usb.c: include config.h first + * drivers/riello_ser.c: drivers/riello_ser.c: include config.h first + * drivers/rhino.c: drivers/rhino.c: include config.h first + * drivers/mge-utalk.c: drivers/mge-utalk.c: include config.h first + * drivers/libhid.c: drivers/libhid.c: include config.h first, and try + to get strings.h explicitly + * drivers/huawei-ups2000.c: drivers/huawei-ups2000.c: include + config.h first + * drivers/dummy-ups.c: drivers/dummy-ups.c: include config.h first + * drivers/dstate.c: drivers/dstate.c: include config.h first + * tools/nut-scanner/scan_eaton_serial.c: tools/nut- + scanner/scan_eaton_serial.c: try to include explicitly both of + (sys/)signal.h + * server/upsd.c: server/upsd.c: try to include explicitly both of + (sys/)signal.h + * tools/nut-scanner/nutscan-serial.c: tools/nut-scanner/nutscan- + serial.c: include config.h first + * tools/nut-scanner/nutscan-device.c: tools/nut-scanner/nutscan- + device.c: include config.h first + * drivers/mge-xml.c: drivers/mge-xml.c: include config.h first + * drivers/libshut.c: drivers/libshut.c: include config.h first + * common/state.c: common/state.c: include config.h first + * common/str.c: common/str.c: include config.h first, and try to get + strings.h explicitly + * include/common.h: include/common.h: try to include explicitly + string(s).h and (sys/)signal.h + * configure.ac: configure.ac: test more actively for strcasecmp, + strncasecmp, strdup and usleep methods that are problematic for + strict C99+ builds + * configure.ac: configure.ac: detect explicitly string(s).h and + (sys/)signal.h + +2021-12-29 Jim Klimov + + * configure.ac: configure.ac: zero-init struct in ntohl/htonl + warning-tweaks test code + +2021-12-29 Jim Klimov + + * drivers/nut-libfreeipmi.c: drivers/nut-libfreeipmi.c: be pragmatic + about possibly unreachable error handling in arch-dependent range + check + * drivers/nut-libfreeipmi.c: drivers/nut-libfreeipmi.c: mark local + vars as static + * configure.ac: configure.ac: constrain warning-tweaks against macro + str*() and ntohl/htonl to LIBNETSNMP_CFLAGS (empirically) + * configure.ac: configure.ac: detect if compiler (e.g. older + clang-3.4) has a problem with built-in/macro variants of system + str*() and htonl/ntohl functions at our higher warning levels, and + mitigate that + * m4/nut_compiler_family.m4: m4/nut_compiler_family.m4: rearrange + detection order of compiler flags + * drivers/generic_modbus.c: drivers/generic_modbus.c: quiesce + warnings about unreachable-code (default after full enum-case + handling) with older clang + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: ignore potentially + unreachable code in assert() + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: quiesce warnings about + unreachable-code (default after full enum-case handling) with older + clang + * drivers/upscode2.c: drivers/upscode2.c: quiesce warnings about + unreachable-code (default after full enum-case handling) with older + clang + * drivers/hidparser.c: drivers/hidparser.c: ignore potentially + unreachable code in platforms-dependent range checks + * drivers/libhid.c: drivers/libhid.c: ignore potentially unreachable + code in platforms-dependent range checks + * drivers/libshut.c: drivers/libshut.c: tell compiler that we do want + to treat a char array (managed by comms code) as the aligned + pointer to struct + * drivers/libshut.c: drivers/libshut.c: adjust data_size usage to + usb_ctrl_charbufsize typedef - fix pragmas for range-checks + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: quiesce warnings about + unreachable-code (default after full enum-case handling) with older + clang + * drivers/genericups.c: drivers/genericups.c: ignore potentially + unreachable code in platforms-dependent range checks + * drivers/bestuferrups.c: drivers/bestuferrups.c: ignore potentially + unreachable code in assert(0) + * drivers/bestfcom.c: drivers/bestfcom.c: ignore potentially + unreachable code in assert(0) + * clients/upsmon.c: clients/upsmon.c: ignore potentially unreachable + code in platforms-dependent range checks + * tools/nut-scanner/scan_nut.c: tools/nut-scanner/scan_nut.c: ignore + potentially unreachable code in platforms-dependent range checks + * tools/nut-scanner/nutscan-init.c: tools/nut-scanner/nutscan-init.c: + ignore potentially unreachable code in platforms-dependent range + checks + * server/upsd.c: server/upsd.c: quiesce warnings about unreachable- + code (default after full enum-case handling) with older clang + * configure.ac: configure.ac: update "clang-medium" warnings level + with "-Wno-conversion" for older clang releases + * ci_build.sh: ci_build.sh: introduce CI_FAILFAST for + BUILD_TYPE=default-all-errors + * ci_build.sh: ci_build.sh: use configurable --enable-Wcolor for + compiler warnings in default quick build + * ci_build.sh: ci_build.sh: use configurable --enable-Wcolor for + compiler warnings in all BUILD_TYPEs + * configure.ac, m4/nut_compiler_family.m4: configure.ac + + m4/nut_compiler_family.m4: allow configurable --enable-Wcolor for + compiler warnings + * m4/nut_compiler_family.m4: m4/nut_compiler_family.m4: add + diagnostics-color support for GCC + * configure.ac, m4/ax_check_compile_flag.m4, + m4/nut_compiler_family.m4: m4/nut_compiler_family.m4: use + AX_CHECK_COMPILE_FLAG to detect generic options supported by + compilers + +2021-12-28 Jim Klimov + + * configure.ac: configure.ac: pass "-Wno-disabled-macro-expansion" in + clang-medium and clang-hard modes, to avoid choking on systems- + provided strncmp() etc. + * drivers/bcmxcp_ser.c: drivers/bcmxcp_ser.c: pw_comm_setup(): ignore + potentially unreachable code in platforms-dependent range checks + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + ignore potentially unreachable code in platforms-dependent range + checks + * common/common.c: common/common.c: get_user_pwent(): ignore + "-Wunreachable-code" where we were required to have a return + * common/common.c: common/common.c: get_max_pid_t(): avoid warnings + in C89/C90/ANSI builds *because* we check for LLONG_MAX macro + * common/common.c: common/common.c: get_max_pid_t(): ignore + "-Wunreachable-code" + * common/common.c: common/common.c: vupslog(): ignore "-Wformat- + nonliteral" with older clang too + * configure.ac: configure.ac: with (older) clang, ignore "unused- + arguments" (of clang program) + * server/upsd.c: server/upsd.c: mainloop(): ignore "-Wcovered-switch- + default" with older clang too + * clients/upsclient.c: clients/upsclient.c: upscli_init(): fix "ret" + to "long", to match some versions of SSL_CTX_ctrl() (from + openssl/ssl.h e.g. in FreeBSD) + * drivers/riello_usb.c: drivers/riello_usb.c: riello_command(): + handle possibly undefined ETIME + * drivers/blazer_usb.c: drivers/blazer_usb.c: blazer_command(): + handle possibly undefined ETIME + * drivers/blazer_usb.c: drivers/blazer_usb.c: phoenix_command(): + avoid fall-through in a case + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: qx_command(): handle + possibly undefined ETIME + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: phoenix_command(): avoid + fall-through in a case + * drivers/mge-hid.c: drivers/mge-hid.c: nominal_output_voltage_fun(): + explicitly fall-through in a case + * drivers/libshut.c: drivers/libshut.c: shut_control_msg(): + explicitly fall-through in a case, and finish the default with a + break + * m4/nut_compiler_family.m4: m4/nut_compiler_family.m4: comment away + setting "-isystem ..." common paths early in CFLAGS + * configure.ac: configure.ac: set "-Wno-system-headers" early in + gcc/clang medium and hard warning levels + * m4/nut_compiler_family.m4: m4/nut_compiler_family.m4: set "-isystem + ..." paths early in CFLAGS + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: expel other + C89/C90/ANSI builds to only happen if not + disableSlowBuildCIBuildExperimentalANSI and only in branches (or + PRs to) matching ~/fightwarn.*89.*/ currently + * configure.ac: configure.ac: try to handle warnings in system + headers at our medium and hard levels + +2021-12-28 Jim Klimov + + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: fix_report_desc(): + avoid shadowing global var with method arg name + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: fix_report_desc(): mark + NUT_UNUSED_VARIABLEs + +2021-12-28 Jim Klimov + + * docs/man/nutdrv_qx.txt: docs/man/nutdrv_qx.txt: mention Armac in + SUPPORTED HARDWARE section, and wrap long lines there + * docs/man/nutdrv_qx.txt, docs/nut.dict: docs/man/nutdrv_qx.txt: port + notes for "armac" subdriver from source code + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: armac_command(): move + variable declarations to top of scope + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: armac_command(): fix + varied int types to size_t, and move equation sides around to avoid + signedness + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: armac_command(): zero out + whole tmpbuf[], not one element + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: normalize whitespace for + "armac" code addition + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: add (C) for "armac" code + addition + +2021-12-25 Tomasz Fortuna + + * data/driver.list.in, docs/man/nutdrv_qx.txt, docs/nut.dict, + drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: add support for Armac UPS + (or maybe other richcomm_usb like) Based on Armac R/2000I/PSW, but + should support other UPSes that work with "PowerManagerII" software + from Richcomm Technologies from around 2004-2005. + +2021-12-28 Jim Klimov + + * docs/ci-farm-lxc-setup.txt, docs/nut.dict: docs/ci-farm-lxc- + setup.txt: add a troubleshooting section, with entry for + cgroupsv1-only guests on a cgroupsv2-only host + * docs/config-prereqs.txt, docs/nut.dict: docs/config-prereqs.txt: + add a chapter for CentOS 7 agent preparation + * docs/config-prereqs.txt: docs/config-prereqs.txt: clarify that + OpenBSD multitude of autotools versions is a blessing, not a pain + ;) + * docs/config-prereqs.txt: docs/config-prereqs.txt: clarify that JDK + installation in Debian guests may need /proc submounted + * docs/ci-farm-lxc-setup.txt: docs/ci-farm-lxc-setup.txt: move "sudo" + installation away from useradd example (so "apt-get" does not + pollute non-debian guest examples) + * docs/ci-farm-lxc-setup.txt: docs/ci-farm-lxc-setup.txt: change + CentOS7 example guest name from ...-x86_64 to ...-x86-64 (or + -amd64) to avoid loss of character + * docs/ci-farm-lxc-setup.txt: docs/ci-farm-lxc-setup.txt: avoid + "AltArch" CentOS i686, use just x86_64 as something easier to get + hands on + +2021-12-27 hunter86bg + + * data/driver.list.in: Add Cyber Power PR1500RT2U, fixes + networkupstools/nut#1191 + +2021-12-27 Jim Klimov + + * docs/ci-farm-lxc-setup.txt: docs/ci-farm-lxc-setup.txt: remind to + revise container MAC addresses + * docs/ci-farm-lxc-setup.txt: docs/ci-farm-lxc-setup.txt: clarify + that "third-party distro" LXC helpers may need chiseling + * docs/ci-farm-lxc-setup.txt, docs/nut.dict: docs/ci-farm-lxc- + setup.txt: hint at needed "pacman" for Arch Linux container + installation + * docs/ci-farm-lxc-setup.txt, docs/nut.dict: docs/ci-farm-lxc- + setup.txt: add installation of RPM based distros as guests on non- + RPM (DEB) hosts + * docs/ci-farm-lxc-setup.txt: docs/ci-farm-lxc-setup.txt: clarify how + to find defined LXC templates, and get usage details about them + +2021-12-25 Jim Klimov + + * drivers/riello_ser.c: drivers/riello_ser.c: do not include + hidparser.h (hiccups in usb-common.h due to lack of + WITH_LIBUSB_x_y) + * drivers/riello_ser.c: drivers/riello_ser.c: do not include + hidparser.h (hiccups in usb-common.h due to lack of + WITH_LIBUSB_x_y) + * drivers/libshut.c: drivers/libshut.c: adjust data_size usage to + usb_ctrl_charbufsize typedef + +2021-12-21 Jim Klimov + + * configure.ac: configure.ac: switch default warnings level to + "medium" + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: range-check quiesced by + pragmas (GCC) + * drivers/libusb0.c: drivers/libusb0.c: do not separate if-clause + parenthesis by pragmas (GCC) + * drivers/libusb1.c: drivers/libusb1.c: do not separate if-clause + parenthesis by pragmas (GCC) + * drivers/libshut.c: drivers/libshut.c: do not separate if-clause + parenthesis by pragmas (GCC) + * drivers/hidparser.c: drivers/hidparser.c: do not separate if-clause + parenthesis by pragmas (GCC) + +2021-12-20 Jim Klimov + + * drivers/libusb1.c: drivers/libusb1.c: fix whitespace (break long + lines) + * drivers/libshut.h: drivers/libshut.h: define ERROR_ACCESS etc. used + for USB(-like) result states + +2021-12-19 Jim Klimov + + * drivers/hidparser.c, drivers/hidparser.h, drivers/libhid.c, + drivers/libhid.h, drivers/libshut.c, drivers/libshut.h, + drivers/libusb0.c, drivers/libusb1.c, drivers/nut_libusb.h, + drivers/nutdrv_atcl_usb.c, drivers/richcomm_usb.c, + drivers/riello_usb.c, drivers/tripplite_usb.c, drivers/usb- + common.h, drivers/usbhid-ups.c: drivers (c,h) USB, HID and SHUT: + converge parameter usage from strict int types to backend API + dependent "usb_ctrl_*" and "usb_dev_handle" typedefs, then range- + check and cast the numbers, and avoid build warnings + +2021-12-25 Jim Klimov + + * drivers/libshut.c: drivers/libshut.c: adjust data_size usage to + usb_ctrl_charbufsize typedef + +2021-12-21 Jim Klimov + + * configure.ac: configure.ac: switch default warnings level to + "medium" + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: range-check quiesced by + pragmas (GCC) + * drivers/libusb0.c: drivers/libusb0.c: do not separate if-clause + parenthesis by pragmas (GCC) + * drivers/libusb1.c: drivers/libusb1.c: do not separate if-clause + parenthesis by pragmas (GCC) + * drivers/libshut.c: drivers/libshut.c: do not separate if-clause + parenthesis by pragmas (GCC) + * drivers/hidparser.c: drivers/hidparser.c: do not separate if-clause + parenthesis by pragmas (GCC) + +2021-12-20 Jim Klimov + + * drivers/libusb1.c: drivers/libusb1.c: fix whitespace (break long + lines) + * drivers/libshut.h: drivers/libshut.h: define ERROR_ACCESS etc. used + for USB(-like) result states + +2021-12-19 Jim Klimov + + * drivers/hidparser.c, drivers/hidparser.h, drivers/libhid.c, + drivers/libhid.h, drivers/libshut.c, drivers/libshut.h, + drivers/libusb0.c, drivers/libusb1.c, drivers/nut_libusb.h, + drivers/nutdrv_atcl_usb.c, drivers/richcomm_usb.c, + drivers/riello_usb.c, drivers/tripplite_usb.c, drivers/usb- + common.h, drivers/usbhid-ups.c: drivers (c,h) USB, HID and SHUT: + converge parameter usage from strict int types to backend API + dependent "usb_ctrl_*" and "usb_dev_handle" typedefs, then range- + check and cast the numbers, and avoid build warnings + +2021-12-25 Jim Klimov + + * drivers/nutdrv_atcl_usb.c, drivers/richcomm_usb.c, drivers/usb- + common.h, m4/nut_check_libusb.m4: m4/nut_check_libusb.m4, + drivers/usb-common.h + nutdrv_atcl_usb.c + richcomm_usb.c: only + apply usb_detach_kernel_driver_np to libusb-0.1 builds (no alias + tricks) + * drivers/libusb1.c, drivers/nutdrv_atcl_usb.c, + drivers/richcomm_usb.c, m4/nut_check_libusb.m4: + m4/nut_check_libusb.m4, drivers/libusb1.c + nutdrv_atcl_usb.c + + richcomm_usb.c: honor that libusb-1.0 may + HAVE_LIBUSB_DETACH_KERNEL_DRIVER_NP + * drivers/nutdrv_atcl_usb.c, drivers/richcomm_usb.c, drivers/usb- + common.h, m4/nut_check_libusb.m4: m4/nut_check_libusb.m4, + drivers/usb-common.h + nutdrv_atcl_usb.c + richcomm_usb.c: only + apply usb_detach_kernel_driver_np to libusb-0.1 builds (no alias + tricks) + * drivers/libusb1.c, drivers/nutdrv_atcl_usb.c, + drivers/richcomm_usb.c, m4/nut_check_libusb.m4: + m4/nut_check_libusb.m4, drivers/libusb1.c + nutdrv_atcl_usb.c + + richcomm_usb.c: honor that libusb-1.0 may + HAVE_LIBUSB_DETACH_KERNEL_DRIVER_NP + +2021-12-24 Jim Klimov + + * drivers/nutdrv_atcl_usb.c, drivers/richcomm_usb.c, + drivers/riello_usb.c: drivers/riello_usb.c, richcomm_usb.c, + nutdrv_atcl_usb.c: fix remaining uses of (lib)usb_strerror with + nut_usb_strerror() + +2021-12-25 Jim Klimov + + * drivers/usb-common.h: drivers/usb-common.h: map + libusb_detach_kernel_driver_np (1.0) as usb_detach_kernel_driver_np + (0.1) + * drivers/usb-common.h: drivers/usb-common.h: map + libusb_detach_kernel_driver_np (1.0) as usb_detach_kernel_driver_np + (0.1) + +2021-12-24 Jim Klimov + + * configure.ac: configure.ac: update "clang-medium" warnings pre-set + with -Wno-incompatible-pointer-types-discards-qualifiers + * drivers/libusb1.c: drivers/libusb1.c: some more whitespace and + comment fixes + * drivers/nutdrv_atcl_usb.c, drivers/richcomm_usb.c, + drivers/riello_usb.c: drivers/riello_usb.c, richcomm_usb.c, + nutdrv_atcl_usb.c: fix remaining uses of (lib)usb_strerror with + nut_usb_strerror() + * tools/nut-scanner/scan_usb.c: tools/nut-scanner/scan_usb.c: missed + whitespace fixes + * tools/nut-scanner/scan_usb.c: tools/nut-scanner/scan_usb.c: comment + "#else WITH_LIBUSB_..." in long blocks + +2021-12-20 Jim Klimov + + * tools/nut-scanner/scan_usb.c: tools/nut-scanner/scan_usb.c: fix + whitespace (indentation etc) + * drivers/nutdrv_atcl_usb.c: drivers/nutdrv_atcl_usb.c: drop local + libusb-0.1 vs 1.0 definitions now provided by usb-common.h + * m4/nut_check_libusb.m4: m4/nut_check_libusb.m4: update comments + +2021-12-19 Jim Klimov + + * m4/nut_check_libusb.m4: m4/nut_check_libusb.m4: make sure (missing) + methods from another API are defined in config.h (so "#if HAVE_..." + is valid and not guessed as 0) + +2021-12-20 Jim Klimov + + * drivers/usb-common.h: drivers/usb-common.h: whitespace-separate + definitions of ERROR_ACCESS etc., nut_usb_strerror() and similar + macros + +2021-12-21 Jim Klimov + + * drivers/usb-common.h: drivers/usb-common.h: include "common.h" + +2021-12-16 Jim Klimov + + * drivers/usb-common.h: drivers/usb-common.h: define + PRI_NUT_USB_CTRL_CHARBUFSIZE, usb_ctrl_msgvalue and + usb_ctrl_strindex + * drivers/usb-common.h: drivers/usb-common.h: clarify that libusb + timeouts are in milliseconds (with variouts int types per API + version) + * drivers/usb-common.h: drivers/usb-common.h: update comment about + mapping from libusb-0.1 to libusb-1.0 API + * drivers/nut_libusb.h: drivers/nut_libusb.h: comment the practical + mess around hid_rep_index + * drivers/usb-common.h: drivers/usb-common.h: comment which API + version each endif is for + * drivers/usb-common.h: drivers/usb-common.h: note the arg type for + libusb_strerror() in comments to our macro wrapper + nut_usb_strerror() + * drivers/usb-common.h: drivers/usb-common.h: update heading comment + with references to different API docs + * drivers/usb-common.h: drivers/usb-common.h: update heading comment + and (C) for libusb-1.0 related changes + +2021-12-24 Jim Klimov + + * drivers/libshut.c: drivers/libshut.c: shut_control_msg(): data_size + is a "short int" (not size_t) in this branch + +2021-12-15 Jim Klimov + + * drivers/libshut.c: drivers/libshut.c: shut_control_msg(): range- + check data_size before stuffing the number into a char + * drivers/libshut.c: drivers/libshut.c: range-check and cast ints to + struct members and library args + * drivers/libshut.c: drivers/libshut.c: braces fix + * drivers/nut_libusb.h, drivers/usb-common.h: drivers/usb-common.h + + nut_libusb.h: typedef more usb_ctrl_* tokens to match libusb-0.1 vs + 1.0 API + +2021-12-20 Jim Klimov + + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: comment FIXME for + possible uses of usb_ctrl_* typedefs + +2021-12-13 Jim Klimov + + * drivers/bcmxcp_usb.c, drivers/blazer_usb.c, + drivers/nutdrv_atcl_usb.c, drivers/nutdrv_qx.c, + drivers/richcomm_usb.c, drivers/riello_usb.c, drivers/usb-common.h: + USB: Rename typedef usb_ctrl_char to usb_ctrl_charbuf to avoid + confsion (it is a char* sibling, not plain char) + * drivers/libshut.h, drivers/nut_libusb.h: drivers/nut_libusb.h, + libshut.h: whitespace fixes (align "version") + +2021-12-10 Jim Klimov + + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: current use of + SHUT_MODE relies on defined/not-defined, not on value for plain #if + macro + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: adapt to usb-common.h and + (usb_ctrl_char) casting + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: adapt to usb-common.h + and (usb_ctrl_char) casting + * drivers/nutdrv_atcl_usb.c: drivers/nutdrv_atcl_usb.c: adapt to usb- + common.h and (usb_ctrl_char) casting + +2021-12-20 Jim Klimov + + * drivers/richcomm_usb.c: drivers/richcomm_usb.c: fix whitespace + (break long lines) + * drivers/riello_usb.c: drivers/riello_usb.c: fix whitespace (break + long lines) + +2021-12-10 Jim Klimov + + * drivers/riello_usb.c: drivers/riello_usb.c: adapt to usb-common.h + and (usb_ctrl_char) casting + * drivers/riello.h: drivers/riello.h: do not define duplicate + USB_ENDPOINT_IN/USB_ENDPOINT_OUT + * drivers/usb-common.h: drivers/usb-common.h: convert + usb_get_string{_simple}() from macro aliases to real mappings with + range-checks for libusb-1.0 API + * drivers/usb-common.h: drivers/usb-common.h: mark "static inline" + functions with + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC since not + all C files call them + * drivers/bcmxcp_usb.c, drivers/blazer_usb.c, drivers/libhid.h, + drivers/nutdrv_atcl_usb.c, drivers/nutdrv_qx.c, + drivers/richcomm_usb.c, drivers/riello_usb.c, + drivers/tripplite_usb.c, drivers/usb-common.h: drivers/usb- + common.h: consolidate libusb-0.1 vs 1.0 data/func mappings from + *usb.c files + * drivers/nut_libusb.h, drivers/usb-common.h: drivers/nut_libusb.h + already includes "usb-common.h" so no need to pull LibUSB headers + again + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: range-check and cast + args for usb_control_msg() => libusb_control_transfer() and + usb_interrupt_read() => libusb_interrupt_transfer() for libusb-1.0 + support + +2021-12-09 Jim Klimov + + * tools/nut-usbinfo.pl: tools/nut-usbinfo.pl: sanity check that + exactly one version of WITH_LIBUSB_x_y is set (defined and has + value 1) + * drivers/usb-common.h: drivers/usb-common.h: sanity check that + exactly one version of WITH_LIBUSB_x_y is set (defined and has + value 1) + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: sanity check that + exactly one version of WITH_LIBUSB_x_y is set (defined and has + value 1) + +2021-12-08 Jim Klimov + + * drivers/nut_libusb.h: drivers/nut_libusb.h: sanity check that + exactly one version of WITH_LIBUSB_x_y is set (defined and has + value 1) + +2021-12-24 Jim Klimov + + * drivers/libusb1.c: drivers/libusb1.c: + HAVE_LIBUSB_DETACH_KERNEL_DRIVER needs "#ifdef" not "#if" + * drivers/nutdrv_atcl_usb.c, drivers/richcomm_usb.c, tools/nut- + scanner/scan_usb.c: Convert C code from "#ifdef WITH_LIBUSB_x_y" to + "#if" tests for defined value - merging missed a few in + libusb-1.0+0.1 branch + +2021-12-08 Jim Klimov + + * drivers/bcmxcp_usb.c, drivers/blazer_usb.c, drivers/nut_libusb.h, + drivers/nutdrv_atcl_usb.c, drivers/nutdrv_qx.c, + drivers/richcomm_usb.c, drivers/riello_usb.c, + drivers/tripplite_usb.c, drivers/usb-common.h, tools/nut- + scanner/nutscan-init.c, tools/nut-scanner/scan_usb.c, tools/nut- + usbinfo.pl: Convert C code from "#ifdef WITH_LIBUSB_x_y" to "#if" + tests for defined value + +2021-12-24 Jim Klimov + + * configure.ac: configure.ac: update "clang-medium" warnings pre-set + with -Wno-incompatible-pointer-types-discards-qualifiers + +2021-12-20 Jim Klimov + + * tools/nut-scanner/scan_usb.c: tools/nut-scanner/scan_usb.c: fix + whitespace (indentation etc) + * drivers/nutdrv_atcl_usb.c: drivers/nutdrv_atcl_usb.c: drop local + libusb-0.1 vs 1.0 definitions now provided by usb-common.h + * m4/nut_check_libusb.m4: m4/nut_check_libusb.m4: update comments + +2021-12-19 Jim Klimov + + * m4/nut_check_libusb.m4: m4/nut_check_libusb.m4: make sure (missing) + methods from another API are defined in config.h (so "#if HAVE_..." + is valid and not guessed as 0) + +2021-12-20 Jim Klimov + + * drivers/usb-common.h: drivers/usb-common.h: whitespace-separate + definitions of ERROR_ACCESS etc., nut_usb_strerror() and similar + macros + +2021-12-21 Jim Klimov + + * drivers/usb-common.h: drivers/usb-common.h: include "common.h" + +2021-12-16 Jim Klimov + + * drivers/usb-common.h: drivers/usb-common.h: define + PRI_NUT_USB_CTRL_CHARBUFSIZE, usb_ctrl_msgvalue and + usb_ctrl_strindex + * drivers/usb-common.h: drivers/usb-common.h: clarify that libusb + timeouts are in milliseconds (with variouts int types per API + version) + * drivers/usb-common.h: drivers/usb-common.h: update comment about + mapping from libusb-0.1 to libusb-1.0 API + * drivers/nut_libusb.h: drivers/nut_libusb.h: comment the practical + mess around hid_rep_index + * drivers/usb-common.h: drivers/usb-common.h: comment which API + version each endif is for + * drivers/usb-common.h: drivers/usb-common.h: note the arg type for + libusb_strerror() in comments to our macro wrapper + nut_usb_strerror() + * drivers/usb-common.h: drivers/usb-common.h: update heading comment + with references to different API docs + * drivers/usb-common.h: drivers/usb-common.h: update heading comment + and (C) for libusb-1.0 related changes + +2021-12-24 Jim Klimov + + * drivers/libshut.c: drivers/libshut.c: shut_control_msg(): data_size + is a "short int" (not size_t) in this branch + +2021-12-15 Jim Klimov + + * drivers/libshut.c: drivers/libshut.c: shut_control_msg(): range- + check data_size before stuffing the number into a char + * drivers/libshut.c: drivers/libshut.c: range-check and cast ints to + struct members and library args + * drivers/libshut.c: drivers/libshut.c: braces fix + * drivers/nut_libusb.h, drivers/usb-common.h: drivers/usb-common.h + + nut_libusb.h: typedef more usb_ctrl_* tokens to match libusb-0.1 vs + 1.0 API + +2021-12-20 Jim Klimov + + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: comment FIXME for + possible uses of usb_ctrl_* typedefs + +2021-12-13 Jim Klimov + + * drivers/bcmxcp_usb.c, drivers/blazer_usb.c, + drivers/nutdrv_atcl_usb.c, drivers/nutdrv_qx.c, + drivers/richcomm_usb.c, drivers/riello_usb.c, drivers/usb-common.h: + USB: Rename typedef usb_ctrl_char to usb_ctrl_charbuf to avoid + confsion (it is a char* sibling, not plain char) + * drivers/libshut.h, drivers/nut_libusb.h: drivers/nut_libusb.h, + libshut.h: whitespace fixes (align "version") + +2021-12-10 Jim Klimov + + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: current use of + SHUT_MODE relies on defined/not-defined, not on value for plain #if + macro + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: adapt to usb-common.h and + (usb_ctrl_char) casting + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: adapt to usb-common.h + and (usb_ctrl_char) casting + * drivers/nutdrv_atcl_usb.c: drivers/nutdrv_atcl_usb.c: adapt to usb- + common.h and (usb_ctrl_char) casting + +2021-12-20 Jim Klimov + + * drivers/richcomm_usb.c: drivers/richcomm_usb.c: fix whitespace + (break long lines) + * drivers/riello_usb.c: drivers/riello_usb.c: fix whitespace (break + long lines) + +2021-12-10 Jim Klimov + + * drivers/riello_usb.c: drivers/riello_usb.c: adapt to usb-common.h + and (usb_ctrl_char) casting + * drivers/riello.h: drivers/riello.h: do not define duplicate + USB_ENDPOINT_IN/USB_ENDPOINT_OUT + * drivers/usb-common.h: drivers/usb-common.h: convert + usb_get_string{_simple}() from macro aliases to real mappings with + range-checks for libusb-1.0 API + * drivers/usb-common.h: drivers/usb-common.h: mark "static inline" + functions with + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC since not + all C files call them + * drivers/bcmxcp_usb.c, drivers/blazer_usb.c, drivers/libhid.h, + drivers/nutdrv_atcl_usb.c, drivers/nutdrv_qx.c, + drivers/richcomm_usb.c, drivers/riello_usb.c, + drivers/tripplite_usb.c, drivers/usb-common.h: drivers/usb- + common.h: consolidate libusb-0.1 vs 1.0 data/func mappings from + *usb.c files + * drivers/nut_libusb.h, drivers/usb-common.h: drivers/nut_libusb.h + already includes "usb-common.h" so no need to pull LibUSB headers + again + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: range-check and cast + args for usb_control_msg() => libusb_control_transfer() and + usb_interrupt_read() => libusb_interrupt_transfer() for libusb-1.0 + support + +2021-12-09 Jim Klimov + + * tools/nut-usbinfo.pl: tools/nut-usbinfo.pl: sanity check that + exactly one version of WITH_LIBUSB_x_y is set (defined and has + value 1) + * drivers/usb-common.h: drivers/usb-common.h: sanity check that + exactly one version of WITH_LIBUSB_x_y is set (defined and has + value 1) + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: sanity check that + exactly one version of WITH_LIBUSB_x_y is set (defined and has + value 1) + +2021-12-08 Jim Klimov + + * drivers/nut_libusb.h: drivers/nut_libusb.h: sanity check that + exactly one version of WITH_LIBUSB_x_y is set (defined and has + value 1) + +2021-12-24 Jim Klimov + + * drivers/libusb1.c: drivers/libusb1.c: + HAVE_LIBUSB_DETACH_KERNEL_DRIVER needs "#ifdef" not "#if" + +2021-12-08 Jim Klimov + + * drivers/bcmxcp_usb.c, drivers/blazer_usb.c, drivers/nut_libusb.h, + drivers/nutdrv_atcl_usb.c, drivers/nutdrv_qx.c, + drivers/richcomm_usb.c, drivers/riello_usb.c, + drivers/tripplite_usb.c, drivers/usb-common.h, tools/nut- + scanner/nutscan-init.c, tools/nut-scanner/scan_usb.c, tools/nut- + usbinfo.pl: Convert C code from "#ifdef WITH_LIBUSB_x_y" to "#if" + tests for defined value + +2021-12-18 Dave Williams + + * drivers/apc-hid.c, drivers/arduino-hid.c, drivers/belkin-hid.c, + drivers/cps-hid.c, drivers/delta_ups-hid.c, drivers/explore-hid.c, + drivers/hidtypes.h, drivers/idowell-hid.c, drivers/liebert-hid.c, + drivers/mge-hid.c, drivers/openups-hid.c, drivers/powercom-hid.c, + drivers/powervar-hid.c, drivers/salicru-hid.c, drivers/tripplite- + hid.c, drivers/usbhid-ups.c, drivers/usbhid-ups.h: Fix #439 + Incorrect Output Voltage on CPS*EFPCLCD + +2021-12-08 Jim Klimov + + * drivers/Makefile.am: drivers/Makefile.am: define SHUT_MODE=1 (with + a value) so #if is predictable + +2021-12-09 Jim Klimov + + * configure.ac, m4/nut_check_libusb.m4: configure.ac + + m4/nut_check_libusb.m4: rectify WITH_LIBUSB_x_y definitions + +2021-12-08 Jim Klimov + + * m4/nut_check_libusb.m4: m4/nut_check_libusb.m4: (hidden) debug + before AC_DEFINE + * m4/nut_check_libusb.m4: m4/nut_check_libusb.m4: always AC_DEFINE + the WITH_LIBUSB_1_0 and WITH_LIBUSB_0_1 macros with a 0 or 1 value + +2021-12-07 Jim Klimov + + * docs/configure.txt: configure.ac et al: drop the extra --with- + libusb-version and handle its goals via --with-usb=VERSION + +2021-12-24 Jim Klimov + + * configure.ac, m4/nut_check_libusb.m4: m4/nut_check_libusb.m4 + + configure.ac: port newer solution for libusb version selection from + libusb-1.0 branch + +2021-12-07 Jim Klimov + + * configure.ac: configure.ac: drop duplicate NUT_CHECK_LIBNETSNMP + * configure.ac: configure.ac: regroup some NUT_ARG_WITH() closer to + their NUT_CHECK_*() so help for detailed options is near + +2021-11-15 Jim Klimov + + * m4/nut_check_libusb.m4: Move "additional USB-related checks" from + configure.ac to m4/nut_check_libusb.m4 + +2021-12-08 Jim Klimov + + * drivers/Makefile.am: drivers/Makefile.am: define SHUT_MODE=1 (with + a value) so #if is predictable + +2021-12-09 Jim Klimov + + * configure.ac, m4/nut_check_libusb.m4: configure.ac + + m4/nut_check_libusb.m4: rectify WITH_LIBUSB_x_y definitions + +2021-12-08 Jim Klimov + + * m4/nut_check_libusb.m4: m4/nut_check_libusb.m4: (hidden) debug + before AC_DEFINE + * m4/nut_check_libusb.m4: m4/nut_check_libusb.m4: always AC_DEFINE + the WITH_LIBUSB_1_0 and WITH_LIBUSB_0_1 macros with a 0 or 1 value + +2021-12-24 Dimitris Economou + + * drivers/generic_modbus.c: fix in modbus response value check + +2021-12-23 dtsecon + + * drivers/generic_modbus.c, drivers/generic_modbus.h: handle broken + pine error in modbus TCP connections, configurable modbus response + timeouts between requests and frame bytes + +2021-12-23 Jim Klimov + + * ci_build.sh: ci_build.sh: separate the "RES" vars used for + configure_nut() and default-all-errors processing (extend to + libusb-1.0* branches) + * tests/getvaluetest.c: tests/getvaluetest.c: include "config.h" + first + * tests/Makefile.am: tests/Makefile.am: only TEST getvaluetest "if + WITH_USB" + * m4/nut_check_libusb.m4: m4/nut_check_libusb.m4: do not report + misleading "none (libusb-0.1-config)" as the detected libusb + version Seems this confused not only human readers, but also the + verdict - whether we build WITH_USB + * ci_build.sh: ci_build.sh: separate the "RES" vars used for + configure_nut() and default-all-errors processing (extend to + libusb-1.0* branches + * tests/getvaluetest.c: tests/getvaluetest.c: include "config.h" + first + * tests/Makefile.am: tests/Makefile.am: only TEST getvaluetest "if + WITH_USB" + +2021-12-22 Jim Klimov + + * clients/upsclient.c: clients/upsclient.c: upscli_tryconnect(): in + logged messages, clarity "connect to NUT server %s" Otherwise nut- + scanner output looks awkward when looking at large subnets with + many protocols (including "Old NUT") + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: + convert logging in the main loop from a lot of fprintf() to + manageable upsdebugx() + * tools/nut-scanner/scan_ipmi.c: tools/nut-scanner/scan_ipmi.c: + convert logging in the main loop from a lot of fprintf() to + manageable upsdebugx() + * ci_build.sh: ci_build.sh: fix a typo, copypasted around + * tests/Makefile.am: tests/Makefile.am: only build getvaluetest "if + WITH_USB" + * drivers/blazer_usb.c: drivers/blazer_usb.c: forget + libusb_device_handle + * drivers/libhid.h: drivers/libhid.h: forget libusb_device_handle + +2021-12-19 Jim Klimov + + * ci_build.sh: ci_build.sh: allow to build custom + NUT_USB_VARIANTS=libusb-x.y (not plain "x.y") + * ci_build.sh: ci_build.sh: allow to build custom NUT_USB_VARIANTS + and skip building a separate NUT_SSL_VARIANTS=auto + +2021-12-22 Jim Klimov + + * ci_build.sh: ci_build.sh: fix a typo, copypasted around + * tests/Makefile.am: tests/Makefile.am: only build getvaluetest "if + WITH_USB" + * drivers/blazer_usb.c: drivers/blazer_usb.c: forget + libusb_device_handle + * drivers/libhid.h: drivers/libhid.h: forget libusb_device_handle + +2021-12-21 Jim Klimov + + * docs/nut.dict: docs/nut.dict: update for recent NEWS + * NEWS: NEWS: prepare for nutdrv-qx legrand merge in 2.7.5 timeline + * NEWS: NEWS: prepare for nutdrv-qx ablerex merge in 2.7.5 timeline + * NEWS: NEWS: know about usbhid-ups Delta Minuteman support for NUT + v2.7.5 + * NEWS: NEWS: fix USB LogMin/LogMax mismatch reporting (just once!) + for NUT v2.7.5 + * NEWS: NEWS: add a little delay between multicommands [PR #1228] for + NUT v2.7.5 + * NEWS: NEWS: prepare for libusb-1.0 merge in 2.7.5 timeline + +2021-05-25 Jim Klimov + + * NEWS: NEWS: added nutdrv_qx "phoenixtec" subdriver in NUT-2.7.5 + +2021-04-23 Jim Klimov + + * docs/nut.dict: docs/nut.dict + NEWS: fix both to pass spellcheck + +2019-03-13 Arnaud Quette + + * docs/nut.dict: Update spelling dictionary + +2021-12-19 Jim Klimov + + * ci_build.sh: ci_build.sh: allow to build custom + NUT_USB_VARIANTS=libusb-x.y (not plain "x.y") + * ci_build.sh: ci_build.sh: allow to build custom NUT_USB_VARIANTS + and skip building a separate NUT_SSL_VARIANTS=auto + * ci_build.sh: ci_build.sh: allow to build custom + NUT_USB_VARIANTS=libusb-x.y (not plain "x.y") + * ci_build.sh: ci_build.sh: allow to build custom NUT_USB_VARIANTS + and skip building a separate NUT_SSL_VARIANTS=auto + +2021-12-21 Jim Klimov + + * drivers/legrand-hid.c: drivers/legrand-hid.c: fix type of + usb_device_id_t vendorID/productID to uint16_t * *{usb,hid}.c: + sentinel in a table of uint16_t can not be -1 + +2021-12-21 Jim Klimov + + * ci_build.sh: ci_build.sh: separate the "RES" vars used for + configure_nut() and default-all-errors processing + +2021-12-15 Jim Klimov + + * drivers/libshut.h: drivers/libshut.h: whitespace fixes (make func + ptrs more visible) + +2021-12-13 Jim Klimov + + * drivers/libusb.h: drivers/libusb.h: whitespace fixes (make func + ptrs more visible) + +2021-12-10 Jim Klimov + + * ci_build.sh: ci_build.sh: comment the rationale reminder for + "default-all-errors" mode + * ci_build.sh: ci_build.sh: try more options for non-verbose MAKE + runs + * conf/upsmon.conf.sample.in: conf/upsmon.conf.sample.in: update + suggestions and envvar list for NOTIFYCMD callouts + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: introduce + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNUSED_FUNCTION + +2021-12-19 Jim Klimov + + * drivers/hidparser.c, drivers/hidparser.h: drivers/hidparser.{c,h}: + fix ReportDescSize from int to size_t + +2021-12-15 Jim Klimov + + * drivers/libhid.c, drivers/libhid.h: drivers/libhid.{c,h}: + HIDGetDataValue(), refresh_report_buffer(), get_item_buffered(): + fix "age" from int to time_t, to match time() operations + +2021-12-21 Jim Klimov + + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: date_conversion_fun(): + hush a string overflow warning (overkill the buffer size a bit) + +2021-12-15 Jim Klimov + + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: date_conversion_fun(): + comment and cast numeric type conversions + +2021-12-16 Jim Klimov + + * include/nut_stdint.h: include/nut_stdint.h: make sure we know + PRIsize and PRIssize + +2021-12-21 Jim Klimov + + * docs/developers.txt, docs/nut.dict: docs/developers.txt: note that + we define "gcc-medium|gcc-hard" warnings without "pedantic" for + C89/C90/ANSI builds (flaws in OS headers are out of our control) + * configure.ac: configure.ac: define "gcc-medium|gcc-hard" warnings + with "extra" always, but without "pedantic" for C89/C90/ANSI builds + (flaws in OS headers are out of our control) + * tests/Makefile.am: tests/Makefile.am: consider LIBUSB_CFLAGS when + building parser test + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: separate (and + disable by default) ANSI C build scenarios, they are too noisy in + fightwarn for no real good + * common/common.c: common/common.c: s_upsdebug*(): move fmt2[] + declarations to top from code + * common/common.c: common/common.c: fix comments from // to /* */ + * drivers/hidparser.h: drivers/hidparser.h: include "config.h" + * server/upsd.c: server/upsd.c: #include config.h first + +2021-12-21 Jim Klimov + + * drivers/nutdrv_qx.c: Update nutdrv_qx.c Fix this on some of the CI + platforms: ```` [2021-12-21T09:21:47.623Z] nutdrv_qx.c:1665:2: + error: initialization from incompatible pointer type [-Werror] + [2021-12-21T09:21:47.623Z] { USB_DEVICE(0xffff, 0x0000), NULL, + NULL, &ablerex_subdriver }, /* Ablerex 625L USB */ + [2021-12-21T09:21:47.623Z] ^ [2021-12-21T09:21:47.623Z] + nutdrv_qx.c:1665:2: error: (near initialization for + 'qx_usb_id[1].fun') [-Werror] ```` + +2021-12-21 Jim Klimov + + * scripts/upower/95-upower-hid.rules: Update 95-upower-hid.rules Add + VID/PID for Minuteman UPS + * drivers/blazer_usb.c: drivers/blazer_usb.c: cast tmp as char* + Older compilers complain that we are: passing argument 3 of + 'usb_interrupt_read' from incompatible pointer type expected 'char + *' but argument is of type 'char (*)[512]' + +2021-12-21 Jim Klimov + + * docs/nut.dict: Update nut.dict Update for PR #1135 + +2021-12-20 Jim Klimov + + * drivers/nutdrv_qx.c: Update nutdrv_qx.c Whitespace fix + +2021-12-20 hunter86bg + + * data/driver.list.in: Add Powerwalker VFI 3000 TG Online UPS to + driver.list.in (#1224) + +2021-12-20 Jim Klimov + + * drivers/hidparser.c: Update hidparser.c Fix whitespace in recent + changes for LogMin/LogMax rectification + +2021-12-20 Jim Klimov + + * tools/nut-scanner/scan_usb.c: tools/nut-scanner/scan_usb.c: fix + whitespace (indentation etc) + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: fix whitespace (break + long lines) + * drivers/riello_usb.c: drivers/riello_usb.c: fix whitespace (break + long lines) + * drivers/richcomm_usb.c: drivers/richcomm_usb.c: fix whitespace + (break long lines) + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: fix whitespace (break + long lines) + * drivers/blazer_usb.c: drivers/blazer_usb.c: fix whitespace (break + long lines) + +2021-12-19 Scott Colby + + * drivers/usbhid-ups.c: Add a short sleep between fallback instcmds + in usbhid-ups. For some devices, missing instcmds are emulated by + calling two instcmds that do exist in sequence. For some devices, + when these commands arrive too quickly, they are not properly + processed. (One, both, or neither of the commands are acted upon.) + Adding a 1/8th-second delay (125,000 microseconds) between the two + instcmds that make up the fallback command has worked to make the + TrippLite AVR750U (new version with the 3024 productId/protocol) + behave consistently when using the fallback commands + (shutdown.return and shutdown.stayoff). This delay is also short + enough that it seems unlikely to cause a problem for any devices + which don't exhibit this issue. + +2021-12-16 Ablerexsoftware + + * docs/acknowledgements.txt, docs/man/nutdrv_qx.txt, docs/nutdrv_qx- + subdrivers.txt, drivers/Makefile.am, drivers/nutdrv_qx.c: modify CI + warnings and Replace the new sub driver + +2021-12-15 Nick Briggs + + * drivers/hidparser.c: Move check for LogMax encoding error to + parsing of report description At least one UPS [APC Back-UPS + BX1600MI FW:294201G -302201G] is known to have encoding errors in + its USB HID report description such that a conforming + interpretation of the encoded LogicalMaximum value indicates that + it is -1 and the resulting LogicalMin..LogicalMax range is 0..-1. + The actual report values read are correctly encoded. Rather than + log a range error each time a value is read we can detect the + encoding error when the report description is read (once, at + startup) and adjust for the encoding error at that time. + +2021-12-09 Jim Klimov + + * ci_build.sh: Refactor `./ci_build.sh spellcheck` to be more useful + * ci_build.sh: ci_build.sh: refactor + build_to_only_catch_errors_target() out of + build_to_only_catch_errors() + * ci_build.sh, docs/developers.txt: ci_build.sh: introduce support + for CI_SHELL_IS_FLAKY=true + * docs/developers.txt: docs/developers.txt: when introducing + ci_build.sh, mention that NUT CI farm tells how to reproduce builds + +2021-12-08 Jim Klimov + + * docs/man/nut-scanner.txt: Update nut-scanner.txt Clarify SNMP + auth/priv proto support depends on Net-SNMP lib + * docs/man/snmp-ups.txt: Update snmp-ups.txt Clarify SNMP auth/priv + proto support depends on Net-SNMP lib + +2021-12-08 Mauro Guerrera + + * docs/man/snmp-ups.txt: Update snmp-ups docs + * docs/man/nut-scanner.txt: Update docs to list new auth and privacy + encryption options + +2021-12-07 Jim Klimov + + * m4/nut_check_libusb.m4: m4/nut_check_libusb.m4: refactor shell + if/case to m4 (tracking down missed parentheses) + * m4/nut_check_libusb.m4: m4/nut_check_libusb.m4: port more function + probes from libusb-1.0+0.1 branch + * ci_build.sh, configure.ac, docs/configure.txt, + m4/nut_check_libusb.m4: configure.ac et al: drop the extra --with- + libusb-version and handle its goals via --with-usb=VERSION + * m4/nut_check_libusb.m4: m4/nut_check_libusb.m4: port comments and + m4 markup from libusb-1.0+0.1 branch + * configure.ac, m4/nut_check_libusb.m4: configure.ac: move remaining + libusb sanity checks into the m4/nut_check_libusb.m4 file + * configure.ac: configure.ac: drop duplicate NUT_CHECK_LIBNETSNMP + * configure.ac: configure.ac: regroup some NUT_ARG_WITH() closer to + their NUT_CHECK_*() so help for detailed options is near + * drivers/libusb1.c: drivers/libusb1.c: nut_libusb_open(): range- + check and cast libusb_control_transfer() arg rdlen + * drivers/libusb1.c: drivers/libusb1.c: nut_libusb_open(): range- + check and cast libusb_control_transfer() arg rdlen + * Makefile.am: Makefile.am: do not let (parallel) "make maintainer- + clean" remove the files that cleanup recipe needs + * ci_build.sh: Revert "ci_build.sh: fix bogus expression for + BUILDSTODO" This reverts commit + e57eec425da5c2020656fd48ec3f8bb9bbf55c52 and adds comments and + handling why that weird construct was not bogus ;) + * docs/ci-farm-lxc-setup.txt, docs/nut.dict: docs/ci-farm-lxc- + setup.txt: reword notes for default QEMU container memory settings + * ci_build.sh: Add a shortcut hack to "./ci_build.sh spellcheck" + easily + * common/Makefile.am: common/Makefile.am: some "make" implems dislike + DRY multi-entry definition of same target (common.c) + * ci_build.sh: Add a shortcut hack to "./ci_build.sh spellcheck" + easily + * drivers/snmp-ups.c, tools/nut-scanner/scan_snmp.c: drivers/snmp- + ups.c + tools/nut-scanner/scan_snmp.c: hide sanity checks before + generate_Ku() into pragmas to not warn about type-limits + ("comparison is always false due to limited range of data type" on + some architectures) + * drivers/solis.c: drivers/solis.c: make sure nut_stdint.h is + included early and defines size_t + +2021-12-06 Jim Klimov + + * drivers/snmp-ups.c, tools/nut-scanner/scan_snmp.c: drivers/snmp- + ups.c + tools/nut-scanner/scan_snmp.c: align (cast) arg type of + generate_Ku() with net-snmp headers, and document the inconsistency + of size_t vs u_int in the same API + * drivers/snmp-ups.c: drivers/snmp-ups.c: align (cast) arg type of + malloc()/realloc() + * drivers/snmp-ups.c: drivers/snmp-ups.c: align (cast) arg type of + snmp_errstring() vs response->errstat (int vs long), and document + the inconsistency with net-snmp headers + * drivers/snmp-ups.c: drivers/snmp-ups.c: upsdrv_makevartable(): fix + maths with size_t vs int + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: setvar(): cast + placing of new_unit_id into wire protocol (FIXME? Does that code + assume CPU endianness?) + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: + upsdrv_initinfo(): fix receiver of strtol() + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: whitespace fixes + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: setvar(): fix + determination of outlet index number + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: debug_message(): + fix len from int to size_t + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: soft_shutdown(): + cast placing of offdelay into wire protocol (FIXME? Does that code + assume CPU endianness?) + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: fix reading and + printing of offdelay (unsigned int in this driver) + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: fix hex2d() to + long as a consumer of strtol() + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: fix toprint_str() + length to size_t and toprint(x) to char + * drivers/netxml-ups.c: drivers/netxml-ups.c: fix type of "ret" for + ne_read_response_block() and ne_sock_read() to ssize_t (as in + libneon headers) + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: fix qx_command() to + return ssize_t like ser_send() at least + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: range-check and cast + "u_langid_fix" in upsdrv_initups() + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: range-check and cast + length of "cmdlen" in phoenixtec_command() + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: range-check and cast + bytes in phoenixtec_command() + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: range-check and cast + bytes in fuji_command() + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: range-check and cast + bytes in repetitive "Simple unicode -> ASCII inplace conversion" + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: range-check and cast int + vs size_t in subdriver handlers (buflen, ret, i++) + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: initialize ret=0 before + we potentially use it in loop i+=ret (should not happen in current + code, but...) + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: cast upsdebug_hex() + logging with non-size_t args + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: range-check and cast + receivers of strtol() + * drivers/nutdrv_qx.c, drivers/nutdrv_qx.h: drivers/nutdrv_qx.{c,h}: + qx_process(), item_t.answer_len: fix lengths from int to size_t + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: qx_command(): indent + ifdefs for TESTING/QX_USB/QX_SERIAL for easier navigation + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: qx_command() complains + about unused parameters (not sure why); mark with + NUT_UNUSED_VARIABLE just in case + * drivers/nutdrv_qx.c, drivers/nutdrv_qx.h: drivers/nutdrv_qx.{c,h}: + fix STATUS() macro, qx_status(), status_lkp_t.status_mask field and + ups_status var to all be "unsigned int" + * drivers/nutdrv_qx_voltronic.c: drivers/nutdrv_qx_voltronic.c: + range-check and cast receivers of strtol(); wrap a few long lines + * drivers/nutdrv_qx_mecer.c: drivers/nutdrv_qx_mecer.c: fix receivers + of strtol() + * drivers/nutdrv_qx_masterguard.c: drivers/nutdrv_qx_masterguard.c: + masterguard_test_battery(): fix receivers of strtol() - duration + * drivers/nutdrv_qx_masterguard.c: drivers/nutdrv_qx_masterguard.c: + masterguard_shutdown(): fix receivers of strtol() - + ondelay/offdelay + * drivers/nutdrv_qx_masterguard.c: drivers/nutdrv_qx_masterguard.c: + masterguard_new_slaveaddr(): range-check and cast + "masterguard_next_slaveaddr" + * drivers/nutdrv_qx_masterguard.c: drivers/nutdrv_qx_masterguard.c: + fix receivers of strtol() + * drivers/nutdrv_qx_masterguard.c: drivers/nutdrv_qx_masterguard.c: + masterguard_output_voltages(): fix type for sizeof() maths + * drivers/nutdrv_qx_masterguard.c: drivers/nutdrv_qx_masterguard.c: + masterguard_model(): fix type of min_bp/max_bp + +2021-12-04 Jim Klimov + + * drivers/nutdrv_qx_blazer-common.c: drivers/nutdrv_qx_blazer- + common.c: fix and range-check receivers of strtol() + * drivers/nutdrv_qx_bestups.c: drivers/nutdrv_qx_bestups.c: fix + receivers of strtol() + * drivers/nutdrv_qx_voltronic-qs-hex.c: drivers/nutdrv_qx_voltronic- + qs-hex.c: fix receivers of strtol() + * drivers/solis.c: drivers/solis.c: fix packet_size from int to + size_t + * drivers/apcsmart.c: drivers/apcsmart.c: bit-wise &= ~() insists it + is for unsigned (int) types - vt->flags + * drivers/apcsmart.c: drivers/apcsmart.c: bit-wise &= ~() insists it + is for unsigned (int) types - termios struct + * drivers/apcsmart.c: drivers/apcsmart.c: sdcmd_CS: fix cshd from int + to useconds_t + * drivers/apcsmart.c: drivers/apcsmart.c: whitespace fix + * drivers/apcsmart.c: drivers/apcsmart.c: apc_getcaps(): fix i, + nument, entlen from int to size_t + * drivers/apcsmart.c: drivers/apcsmart.c: cast prtchr() args from + (unsigned char) to (char) + * drivers/apcsmart.c: drivers/apcsmart.c: fix receivers of strtol() + * drivers/apcsmart.c: drivers/apcsmart.c: cast + apc_read*()/apc_write*() from ((const) char) to (const unsigned + char) + * drivers/apcsmart.c: drivers/apcsmart.c: fix receivers of strlen() + from int to ssize_t + * drivers/apcsmart.c, drivers/apcsmart.h: drivers/apcsmart.{c,h}: fix + ups_status and APC_STAT_* from int to long (to match strtol() used) + * drivers/apcsmart.c: drivers/apcsmart.c: fix receivers of strlen() + from int to ssize_t + * drivers/apcsmart.c: drivers/apcsmart.c: fix + apc_read*()/apc_write*() from int to ssize_t to match select_read() + et al + * drivers/apcsmart.c: drivers/apcsmart.c: include main.h => config.h + first + * drivers/apcsmart.c: drivers/apcsmart.c: convert_data(): fix + receivers of strtol() + * drivers/apcsmart-old.c, drivers/apcsmart-old.h: drivers/apcsmart- + old.c: fix const/unsigned/char usages + * drivers/apcsmart-old.c: drivers/apcsmart-old.c: do_capabilities(): + fix i, nument, entlen from int to size_t + * drivers/apcsmart-old.c, drivers/apcsmart-old.h: drivers/apcsmart- + old.c: fix receivers of strtol() + * drivers/solis.h: drivers/solis.h: fix packet_size from into to + size_t + * drivers/apcsmart-old.c: drivers/apcsmart-old.c: fix handling of + ser_*() retval from int to ssize_t + * drivers/clone.c: drivers/clone.c: fix ondelay/offdelay handling + from int to long (to match strtol() used) + * drivers/clone-outlet.c: drivers/clone-outlet.c: fix handling of + read()/write() retval from int to ssize_t + * drivers/clone.c: drivers/clone.c: fix handling of read()/write() + retval from int to ssize_t + * drivers/blazer.h, drivers/blazer_ser.c, drivers/blazer_usb.c: + drivers/blazer.h + blazer_{ser,usb}.c: blazer_command(): fix + handling of ser_get_buf() retval from int to ssize_t + * drivers/blazer.c: drivers/blazer.c: fix ondelay/offdelay handling + from int to long (to match strtol() used) + * drivers/blazer.c: drivers/blazer.c: fix receivers of strtol() - + delay tmp var + * drivers/powerp-txt.c: drivers/powerp-txt.c: fix ondelay/offdelay + handling from int to long (to match strtol() used) + * drivers/victronups.c: drivers/victronups.c: fix receivers of + strtol() + * drivers/victronups.c: drivers/victronups.c: fix handling of + ser_get_line() retval from int to ssize_t + * drivers/tripplite.c: drivers/tripplite.c: fix receivers of strtol() + => hex2d() + * drivers/tripplite.c: drivers/tripplite.c: fix handling of + ser_get_char() retval from int to ssize_t + * drivers/solis.c, drivers/solis.h: drivers/solis.{c,h}: fix + comm_receive() from int to size_t, and match ser_get_buf_len() len- + or-error returns + * drivers/solis.c, drivers/solis.h: drivers/solis.{c,h}: fix byte- + sized maths of str2bin() and day counts to uint8_t + * drivers/solis.c: drivers/solis.c: include main.h => config.h first + * drivers/solis.c, drivers/solis.h: drivers/solis.c: + save_ups_config(): fix casting of ConfigPack[] entries to (unsigned + char) from original types + * drivers/nutdrv_siemens_sitop.c: drivers/nutdrv_siemens_sitop.c: fix + handling of ser_get_line() retval from int to ssize_t + * drivers/safenet.c: drivers/safenet.c: fix ondelay/offdelay handling + from int to long (to match strtol() used) + * drivers/safenet.c: drivers/safenet.c: fix array loop iterator from + int to size_t + * drivers/safenet.c: drivers/safenet.c: fix handling of + ser_get_line() retval from int to ssize_t + * drivers/rhino.c: drivers/rhino.c: fix handling of ser_get_line() + retval from int to ssize_t + * drivers/powercom.h: drivers/powercom.h: fix whitespace + (indentations) + * drivers/powercom.c: drivers/powercom.c: fix array loop iterator + from int to size_t + * drivers/powercom.c: drivers/powercom.c: fix handling of + ser_get_line() retval from int to ssize_t + * drivers/optiups.c: drivers/optiups.c: a few whitespace nits + * drivers/optiups.c: drivers/optiups.c: fix OPTISBIT_* handling from + int to long (to match strtol() used) + * drivers/optiups.c: drivers/optiups.c: fix optifill() len from int + to size_t + * drivers/optiups.c: drivers/optiups.c: fix handling of + ser_get_line() retval from int to ssize_t + * drivers/oneac.c: drivers/oneac.c: fix handling of ser_get_line() + retval from int to ssize_t + * scripts/subdriver/gen-usbhid-subdriver.sh: scripts/subdriver/gen- + usbhid-subdriver.sh: update generated C heading comment with "TODO" + and update generated code whitespace markup + * drivers/arduino-hid.c, drivers/salicru-hid.c: drivers/usb- + common.{c,h} drivers/*{usb,hid}.c: fix type of usb_device_id_t + vendorID/productID to uint16_t Catch up to earlier change for + recently merged USB HID drivers; specifically * *{usb,hid}.c: + sentinel in a table of uint16_t can not be -1 for: * + drivers/salicru-hid.c * drivers/arduino-hid.c * + scripts/subdriver/gen-usbhid-subdriver.sh creating the boilerplates + +2021-12-03 Jim Klimov + + * drivers/microsol-common.c: drivers/microsol-common.c: fix + setup_poweroff_schedule() vars from int to bool_t to match + set_schedule_time() + * drivers/microsol-common.c: drivers/microsol-common.c: fix + get_base_info(), get_updated_info() buf sizes from unsigned int to + ssize_t (to match ser_get_buf_len() len-or-error returns) + * drivers/microsol-common.c: drivers/microsol-common.c: fix + comm_receive() from int to size_t + * drivers/microsol-common.c: drivers/microsol-common.c: + save_ups_config(): fix casting of configuration_packet[] entries to + (unsigned char) from original types + * drivers/microsol-common.c: drivers/microsol-common.c: fix byte- + sized maths of bitstring_to_binary() and day counts to uint8_t + +2021-12-06 Jim Klimov + + * drivers/huawei-ups2000.c: drivers/huawei-ups2000.c: instcmd(): + range-check and cast for ups2000_write_register() and + handler_func() + * drivers/huawei-ups2000.c: drivers/huawei-ups2000.c: + ups2000_update_alarm(): range-check and cast all_alarms_len from + snprintf() retval + * drivers/huawei-ups2000.c: drivers/huawei-ups2000.c: + ups2000_update_info(): pragma disable warnings for non-fixed format + string + * drivers/huawei-ups2000.c: drivers/huawei-ups2000.c: + ups2000_update_info(): cast uint32_t for reg-idx + * drivers/huawei-ups2000.c: drivers/huawei-ups2000.c: + ups2000_read_serial(): range-check and cast ssize_t vs size_t + increments + * drivers/huawei-ups2000.c: drivers/huawei-ups2000.c: + ups2000_update_info(): cast uint8_t calculations of reg_id parts + * drivers/huawei-ups2000.c: drivers/huawei-ups2000.c: + ups2000_device_identification(): cast uint32_t calculations of + ups2000_ident + * drivers/huawei-ups2000.c: drivers/huawei-ups2000.c: + ups2000_device_identification(): range-check and cast crc16 + calculations + * drivers/huawei-ups2000.c: drivers/huawei-ups2000.c: + ups2000_write_registers(), ups2000_read_registers(), + ups2000_device_identification(): initialize variables that clang-9 + is not sure about Seems like a clang analyzer bug frankly: code + starts with a retrying loop that would initialize these variables. + But still, adding determinism into code never hurts ;) + * drivers/huawei-ups2000.c: drivers/huawei-ups2000.c: crc16(): fix + casting to uint16_t when bit-shifting + * drivers/huawei-ups2000.c: drivers/huawei-ups2000.c: ups2000_alarm[] + sentinel: fix uint16_t reg from -1 to 0 + * drivers/huawei-ups2000.c: drivers/huawei-ups2000.c: + ups2000_device_identification(): fix r from int to size_t, to match + ser_send_buf() + * drivers/huawei-ups2000.c: drivers/huawei-ups2000.c: fix + ups2000_read_serial() from int to size_t, to match ser_get_buf() + * drivers/huawei-ups2000.c: drivers/huawei-ups2000.c: mark local + variables static + +2021-12-03 Jim Klimov + + * drivers/microsol-common.c: drivers/microsol-common.c: fix (and + range-check) casting for memcpy + * drivers/microsol-common.c: drivers/microsol-common.c: wrap some + long comments + * drivers/microsol-common.c: drivers/microsol-common.c: include + main.h => config.h first + * common/Makefile.am: common/Makefile.am: limit the use of common.c + symlinking from srcdir to builddir only to cases when not + BUILDING_IN_TREE + * tools/nut-scanner/nutscan-init.c: tools/nut-scanner/nutscan-init.c: + comment that semaphore gets re-initialized by nut-scanner.c program + and why + * tools/nut-scanner/nut-scan.h, tools/nut-scanner/nutscan-init.c: + tools/nut-scanner/nutscan-init.c + nut-scan.h: hide "semaphore" + library variable + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + #include "config.h" first + * tools/nut-scanner/nut-scan.h, tools/nut-scanner/nut-scanner.c, + tools/nut-scanner/nutscan-init.c, tools/nut-scanner/scan_nut.c, + tools/nut-scanner/scan_snmp.c, tools/nut-scanner/scan_xml_http.c: + tools/nut-scanner/*.c: fix use of size_t max_threads(_scantype) vs + (unsigned int) in sem_init() args + * tools/nut-scanner/nut-scan.h: tools/nut-scanner/nut-scan.h: fix + declaration of nutscan_semaphore(void) + * drivers/snmp-ups.c, m4/nut_check_libnetsnmp.m4, tools/nut- + scanner/nut-scanner.c, tools/nut-scanner/scan_snmp.c: + nut_check_libnetsnmp.m4, nut-scanner.c, scan_snmp.c, snmp-ups.c: + transition from NETSNMP_DRAFT_BLUMENTHAL_AES_04 (that may be not- + defined so #if is invalid) to + NUT_HAVE_LIBNETSNMP_DRAFT_BLUMENTHAL_AES_04 + * ci_build.sh: ci_build.sh: in default-all-errors mode, avoid last- + loop cleanup if DO_CLEAN_CHECK==no + * ci_build.sh: ci_build.sh: fix bogus expression for BUILDSTODO + * ci_build.sh: ci_build.sh: only score *_clean_check as SUCCEEDED if + they were not skipped, and report a bit more + +2021-11-30 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: load_mib2nut(): import + tracing messages and points from 42ITy/DMF fork + * drivers/snmp-ups.c: drivers/snmp-ups.c: load_mib2nut(): clarify the + "trying the new match_sysoid() method" message + * drivers/snmp-ups.c: drivers/snmp-ups.c: load_mib2nut(): fix + upsdebugx() levels verbosity to make more sense + * drivers/snmp-ups.c: drivers/snmp-ups.c: load_mib2nut(): reformat + some debugs, use __func__ + * drivers/snmp-ups.c: drivers/snmp-ups.c: load_mib2nut(): report + device name (section) and host/IP in progress and errors + +2021-11-28 Jim Klimov + + * m4/nut_check_libpowerman.m4: m4/nut_check_libpowerman.m4: if + (lib)powerman.pc is missing, but header is present, check + -lpowerman directly + * m4/nut_check_libpowerman.m4: m4/nut_check_libpowerman.m4: they + deliver an empty version string, so we should not error out on that + +2021-11-27 Jim Klimov + + * m4/nut_check_libusb.m4: m4/nut_check_libusb.m4: if libusb-config + and libusb.pc are missing, but header is present, check -lusb + directly + * m4/nut_check_libnetsnmp.m4: m4/nut_check_libnetsnmp.m4: detect + NET_SNMP_CONFIG with AC_PATH_PROGS and/or configure option (and + handle if it is missing) + * docs/configure.txt: docs/configure.txt: document --with-net-snmp- + config configure option better + * docs/configure.txt: docs/configure.txt: rephrase comments about + --with-*-libs and --with-*-include + * docs/configure.txt, m4/nut_check_pkgconfig.m4: + m4/nut_check_pkgconfig.m4 + docs/configure.txt: detect + (dummy_)PKG_CONFIG with AC_PATH_PROGS and/or configure option (and + handle if it is missing) + * m4/nut_check_libgd.m4: m4/nut_check_libgd.m4: initialize empty + CFLAGS LIBS LDFLAGS + * m4/nut_check_libgd.m4: m4/nut_check_libgd.m4: detect GDLIB_CONFIG + with AC_PATH_PROGS and/or configure option (and handle if it is + missing) + * docs/configure.txt, m4/nut_check_libusb.m4: m4/nut_check_libusb.m4 + + docs/configure.txt: detect LIBUSB_CONFIG with AC_PATH_PROGS + and/or configure option (and handle if it is missing) + * m4/nut_check_libpowerman.m4: m4/nut_check_libpowerman.m4: consider + have_PKG_CONFIG + * m4/nut_check_libwrap.m4: *.m4: AC_LANG_PUSH before AC_LINK_IFELSE + and similar tests + +2021-11-27 Jim Klimov + + * m4/ax_c___attribute__.m4, m4/nut_check_headers_windows.m4, + m4/nut_check_libnetsnmp.m4, m4/nut_func_getnameinfo_argtypes.m4, + m4/nut_type_socklen_t.m4: *.m4: AC_LANG_PUSH before + AC_COMPILE_IFELSE and similar tests + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: try to report + toStringStageCountDump() in ircNotify() + * configure.ac: configure.ac: AC_LANG_PUSH before AC_COMPILE_IFELSE + and similar tests + * clients/upsclient.c, clients/upslog.c, clients/upsmon.c, + clients/upsrw.c, clients/upssched.c, clients/upsset.c, + common/state.c, common/upsconf.c, docs/developers.txt, + docs/nut.dict, drivers/apcsmart-old.c, drivers/apcsmart.c, + drivers/apcupsd-ups.c, drivers/belkin.c, drivers/belkinunv.c, + drivers/bestups.c, drivers/clone-outlet.c, drivers/clone.c, + drivers/dstate.c, drivers/gamatronic.c, drivers/huawei-ups2000.c, + drivers/main.c, drivers/masterguard.c, drivers/mge-utalk.c, + drivers/mge-xml.c, drivers/nutdrv_qx.c, + drivers/nutdrv_qx_bestups.c, drivers/nutdrv_qx_blazer-common.c, + drivers/nutdrv_qx_voltronic-qs-hex.c, drivers/nutdrv_qx_voltronic- + qs.c, drivers/nutdrv_qx_voltronic.c, drivers/oneac.c, + drivers/powercom.c, drivers/powerman-pdu.c, drivers/powerp-txt.c, + drivers/snmp-ups.c, drivers/tripplite_usb.c, drivers/upscode2.c, + drivers/victronups.c, server/conf.c, server/netget.c, + server/netlist.c, server/netset.c, server/user.c, + tests/cpputest.cpp, tools/nut-scanner/nut-scanner.c, tools/nut- + scanner/scan_snmp.c: Replace strcmp() and strcasecmp() use-cases + for short fixed string args by strncmp() and strncasecmp() + respectively Some compilers on some OSes complain due to implem + nuances. Updated docs/developers.txt to make note for posterity. + * drivers/microdowell.c: drivers/microdowell.c: some more pragmatic + ignorance for CLAMP() macro uses (older clang-3.4 et al) + +2021-11-22 Yifeng Li + + * drivers/huawei-ups2000.c: huawei-ups2000.c: rework logic for + "load.on". Currently the driver prevents the user from executing + "load.on" when the UPS is already on, and reports a + STAT_INSTCMD_FAILED with error logs. We need to do this if the UPS + is in bypass mode, because the UPS would otherwise enter normal + mode - "load.on" is not supposed to do that. On the other hand, + executing "load.on" when the UPS is already in "normal-mode on" has + no effect, it's still a legal command and should not be rejected + arbitrarily, which can potentially confuse downstream applications + and users. It also contains two misleading typos in the error + logs: (1) it incorrectly suggests "bypass.off" instead of + "bypass.stop", and (2) reports "failed: reason unknown." when the + reason is simply an already-on UPS. This commit allows "load.on" + to execute when it's in normal mode and already on, and changes the + log messages from errors to warnings. Typos in the log messages are + also fixed. The "load.on" command is only rejected in bypass mode, + with error logs. Finally, the logic for the off test is reworked + to improve readability. The original code checks whether the UPS is + on by testing the negative "not OFF" condition, which is not easy + to understand - the reader must have intimate knowledge on the code + to know its correctness. Namely, When the UPS power status is + updated, 1 of the 5 mutually exclusive flags, OL, OB, OL ECO, + BYPASS, or OFF is always set, thus the absence of the OFF flag + always reliably indicates an ON status. This commits converts the + single negative "not OFF" test to three positive tests for "OL", + "OB" and "OFF", with additional comments added on reachable and + unreachable conditions. Thus, previous uncertainty is eliminated. + +2021-11-26 Jim Klimov + + * tools/nut-scanner/scan_xml_http.c: tools/nut- + scanner/scan_xml_http.c: fix dummy nutscan_scan_xml_http_range() + (WITHOUT_NEON) arg type for useconds_t usec_timeout + * drivers/libhid.c: drivers/libhid.c: fix debug-printing of byte- + counts as size_t + * drivers/microdowell.c: drivers/microdowell.c: some more pragmatic + ignorance for CLAMP() macro uses + * tools/nut-scanner/scan_nut.c: tools/nut-scanner/scan_nut.c: + whitespace fix + * tools/nut-scanner/scan_eaton_serial.c, tools/nut- + scanner/scan_nut.c, tools/nut-scanner/scan_snmp.c, tools/nut- + scanner/scan_xml_http.c: tools/nut-scanner/scan_*.c: fix debug- + printing of thread accounting as size_t + +2021-10-26 Jim Klimov + + * drivers/hidparser.c: drivers/hidparser.c: Parse_ReportDesc(): fix + "max" to size_t and "id" to uint8_t, to match struct fields + * drivers/blazer_usb.c: drivers/blazer_usb.c: fix cast of range- + checked u_langid_fix + * drivers/blazer_usb.c: drivers/blazer_usb.c: fix cast of return + types to size_t vs int + * drivers/libhid.c: drivers/libhid.c: string_to_path(): range-check + and cast converted values for path->Node[] + * drivers/libhid.c: drivers/libhid.c: hid_lookup_usage(): fix cast of + usage_code for printing and returning + * drivers/libhid.c: drivers/libhid.c: string_to_path(): check for + type overflow, and cast + * drivers/libhid.c: drivers/libhid.c: fix types for iterating vs + rbuflen from int to size_t + * drivers/libhid.c, drivers/libhid.h: drivers/libhid.{c,h}: fix + interrupt_size from int to size_t + * drivers/libhid.c: drivers/libhid.c: fix types for iterating vs + rbuflen from int to size_t + * drivers/libhid.c, drivers/libhid.h: drivers/libhid.{c,h}: fix + max_report_size from int to size_t + * drivers/libhid.c: drivers/libhid.c: file_report_buffer(): fix + buflen from int to size_t + * drivers/hidtypes.h: drivers/hidtypes.h: change HIDDesc_t.replen[] + from (array of) int to size_t + * drivers/nutdrv_qx_bestups.c: drivers/nutdrv_qx_bestups.c: cast for + bit math for qx_status() result + * drivers/nutdrv_qx_voltronic.c: drivers/nutdrv_qx_voltronic.c: cast + for bit math for qx_status() result, and line-wrap a long message + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: cast arg for + upsdebug_hex() to size_t + * drivers/nutdrv_qx_voltronic-qs-hex.c: drivers/nutdrv_qx_voltronic- + qs-hex.c: cast arg for upsdebug_hex() to size_t + * drivers/libusb.c: drivers/libusb.c: libusb_open(): cast rdlen to + unsigned to match usb_control_msg() where it is safe to do so + * drivers/libhid.h: drivers/libusb.h: change reportbuf_t.len[] from + (array of) int to size_t + * drivers/hidparser.c, drivers/hidtypes.h: drivers/hidtypes.h + + hidparser.c: change HIDDesc_t.nitems from int to size_t + * drivers/hidparser.c: drivers/hidparser.c: cast int types to + explicit conversions where safe + +2021-10-04 Jim Klimov + + * drivers/apcupsd-ups.c: drivers/apcupsd-ups.c: process(): fix int + types + * drivers/apcupsd-ups.c: drivers/apcupsd-ups.c: upsdrv_initups(): fix + type of port + * drivers/nutdrv_qx.h: drivers/nutdrv_qx.h: define QX_FLAG_* macros + as typed numbers (UL) to match item_t->qxflags + * drivers/powercom-hid.c: drivers/powercom-hid.c: range-check and + cast uint16_t values for ups delays + * drivers/nutdrv_atcl_usb.c: drivers/nutdrv_atcl_usb.c: align return + type of usb_interrupt_read() and our upsdebug_hex() args + * drivers/upscode2.c: drivers/upscode2.c: align types of two statuses + * drivers/upscode2.c: drivers/upscode2.c: fix useconds_t + output_pace_usec + * drivers/upscode2.c: drivers/upscode2.c: fix speed_t baud var + * drivers/upscode2.c: drivers/upscode2.c: fix ssize_t ret for ser*() + routines + * drivers/powerp-txt.c: drivers/powerp-txt.c: fix ssize_t ret for + ser*() routines + * drivers/powerp-bin.c: drivers/powerp-bin.c: fix ssize_t ret for + ser*() routines, and cmd len + * drivers/powerpanel.h: drivers/powerpanel.h: adjust powerpanel + subdriver_t funcptr type for initups() + * drivers/ivtscd.c: drivers/ivtscd.c: fix ssize_t for ivt_status() + and ser_*() involved + * drivers/riello_ser.c: drivers/riello_ser.c: riello_instcmd(): fix + int type of delay vs atoi() + * drivers/riello_ser.c: drivers/riello_ser.c: fix ssize_t ret for + read() routines + * drivers/riello_usb.c: drivers/riello_usb.c: ussleep(): fix + useconds_t type + * drivers/riello_usb.c: drivers/riello_usb.c: riello_instcmd(): fix + int type of delay vs atoi() + * drivers/riello_usb.c: drivers/riello_usb.c: Get_USB_Packet(): fix + int type of size + * drivers/riello.c: drivers/riello.c: riello_parse_rc(): cast uint8_t + into char + * drivers/riello.c: drivers/riello.c: riello_prepare*(): cast + delay%256 into uint8_t + * drivers/riello.c: drivers/riello.c: riello_parse_sentr(): cast pom + maths into uint16_t explicitly... range-check missing though + * drivers/riello.c: drivers/riello.c: riello_parse_sentr(): cast + uint8_t => char to construct Version byte by byte + * drivers/riello.c: drivers/riello.c: riello_parse_gn(): range-check + and cast the NomPowerKVA / NomPowerKW + * drivers/riello.c: drivers/riello.c: riello_calc_CRC(): clarify and + cast the bitness magic as needed + * drivers/powercom.c: drivers/powercom.c: fix int type of model vars + to match OPTImodels/BNTmodels/KINmodels/IMPmodels arrays + * drivers/powercom.c: drivers/powercom.c: avoid casting via wrong int + type for termios fields + * drivers/powercom.c, drivers/powercom.h: drivers/powercom.{c,h}: + align int size for delay (min, sec) and ser_send_char() sending a + char + * drivers/tripplite.c: drivers/tripplite.c: fix casting of unsigned + delays from atoi() + * drivers/tripplite.c: drivers/tripplite.c: fix casting of ints in + send_cmd() + * drivers/tripplitesu.c: drivers/tripplitesu.c: fix casting of ints + into unsigned min/max high/low transfer values + * drivers/nutdrv_qx_masterguard.c: drivers/nutdrv_qx_masterguard.c: + hide warnings for intentional variable format string use + * drivers/nutdrv_qx_masterguard.c: drivers/nutdrv_qx_masterguard.c: + avoid a few potential uninitialized uses + * drivers/nutdrv_qx_masterguard.c: drivers/nutdrv_qx_masterguard.c: + fix a case of shadowed vars in a clause + * drivers/nutdrv_qx_masterguard.c: drivers/nutdrv_qx_masterguard.c: + declare local vars and funcs as static + * drivers/netxml-ups.c: drivers/netxml-ups.c: fix casting ssize_t + value up to size_t for ne_buffer_append() args + * drivers/netxml-ups.c: drivers/netxml-ups.c: fix int type of port + for ne_sock_connect() args + +2021-09-28 Jim Klimov + + * drivers/microdowell.c: drivers/microdowell.c: shuffle include-file + order + * drivers/microdowell.c: drivers/microdowell.c: instcmd(): casting + and (pragma-hushed) range checks for "delay" + * drivers/solis.c: drivers/solis.c: convert_days(): limit the range + for safe casting to size_t for memcpy() + * drivers/rhino.c: drivers/rhino.c: align int types in send_command() + * drivers/microsol-common.c, drivers/microsol-common.h: + drivers/microsol-common.{c,h}: mark local variables as static; + expose a few reasonable ones as extern + * drivers/microdowell.c, drivers/microdowell.h: + drivers/microdowell.{c,h}: fix size_t lengths and uint16_t/uint32_t + status bitmasks + * drivers/phoenixcontact_modbus.c: drivers/phoenixcontact_modbus.c: + declare upsdrv_shutdown() as noreturn + * drivers/phoenixcontact_modbus.c: drivers/phoenixcontact_modbus.c: + declare file-local variables static + * drivers/hidparser.c: drivers/hidparser.c: avoid shadowed local + variables in HIDParse() + * drivers/hidparser.c: drivers/hidparser.c: fix Value cast in + FormatValue() + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: fix status_mask to + unsigned int for STATUS() and bitmask maths + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: fix parsing of + interrupt_size from args, and error out on invalid inputs + * drivers/nutdrv_siemens_sitop.c: drivers/nutdrv_siemens_sitop.c: fix + counters to unsigned int + * drivers/mge-hid.c, drivers/usbhid-ups.c, drivers/usbhid-ups.h: + drivers/usbhid-ups.{c,h} + mge-hid.c: fix ups_status from int to + "unsigned" to match the STATUS() macro and bitmask maths + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: fix + type for snmp_sess.timeout assignment + * drivers/microsol-apc.h: drivers/microsol-apc.h: align type of + NOMINAL_POWER[] to int, like nominal_power var in microsol-common.h + * drivers/oneac.c: drivers/oneac.c: fix buf sizes to size_t + * drivers/main.c, drivers/main.h, drivers/mge-utalk.c, + drivers/nutdrv_siemens_sitop.c, drivers/usbhid-ups.c: + drivers/main.{c,h} et al: fix poll_interval to be time_t like the + time() it has maths with + * drivers/main.c: drivers/main.c: allow only positive pollinterval + settings (avoid DoS by crazy loop) + * drivers/main.c: drivers/main.c: report and fail with invalid + pollinterval settings + * drivers/serial.c: drivers/serial.c: after some investigation of + standards, we may cast useconds_t=>suseconds_t + * server/netset.c: server/netset.c: log tracking_disable() result to + find a use for it (warning fix) + * drivers/richcomm_usb.c: drivers/richcomm_usb.c: + execute_and_retrieve_query(): fix int casting and add diags pragmas + for range checks + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: get_answer(): fix int + casting for tail; fix redundant comparison + * drivers/bestfortress.c: drivers/bestfortress.c: simplify + usleep(d_usec) to no casting + * drivers/belkin.c: drivers/belkin.c: comment why casting usleep(cnt) + is okay + +2021-09-27 Jim Klimov + + * clients/upsclient.c, common/common.c, docs/new-drivers.txt, + drivers/serial.c, drivers/serial.h, include/common.h: + include/common.h, drivers/serial.{c,h}, docs/new-drivers.txt, + common/common.c, clients/upsclient.c: fix d_sec long => time_t to + match timeval struct fields + * clients/upsclient.c, common/common.c, include/common.h: + include/common.h, common/common.c, clients/upsclient.c: fix + select_read()/select_write(): long d_usec => suseconds_t + * docs/nut.dict: docs/nut.dict: update for new-drivers.txt revision + * docs/new-drivers.txt: docs/new-drivers.txt: align USB-common + structure and method signature descriptions with current + drivers/*usb*.h + * docs/man/upscli_readline.txt, docs/man/upscli_sendline.txt: + docs/man/upscli_readline.txt + upscli_sendline.txt: update method + arguments to match code (timeout unsigned int => const long) + * docs/man/upscli_list_next.txt, docs/man/upscli_list_start.txt: + docs/man/upscli_list_start.txt + upscli_list_next.txt: update + method arguments to match code (numa/numq unsigned int => size_t) + +2021-09-26 Jim Klimov + + * drivers/upsdrvctl.c: drivers/upsdrvctl.c: fix data types for + alarm() and sleep() + * drivers/mge-utalk.c: drivers/mge-utalk.c: fix int casting to + snprintf() (size_t/ssize_t) + * drivers/mge-utalk.c: drivers/mge-utalk.c: fix int casting to + ser_get*()/ser_send_*() (size_t/ssize_t) + * drivers/metasys.c: drivers/metasys.c: fix int casting to + ser_get*()/ser_send_*() (size_t/ssize_t) + * drivers/liebert-esp2.c: drivers/liebert-esp2.c: fix int casting to + ser_get*() (size_t/ssize_t) + * drivers/gamatronic.c: drivers/gamatronic.c: fix int casting to + ser_get*() (size_t/ssize_t) and unify naming of msg(_)len + * drivers/bestups.c: drivers/bestups.c: fix int casting to ser_get*() + (size_t/ssize_t) + * drivers/bestuferrups.c: drivers/bestuferrups.c: fix int casting to + ser_get*() (size_t/ssize_t) + * drivers/bestfortress.c: drivers/bestfortress.c: fix int casting to + ser_get*() (size_t/ssize_t) + * drivers/bestfcom.c: drivers/bestfcom.c: fix int casting to + ser_get*() (size_t/ssize_t) + * drivers/belkinunv.c: drivers/belkinunv.c: fix int casting to + ser_get*(), read() and write() (size_t/ssize_t) + * drivers/belkin.c: drivers/belkin.c: fix int casting to ser_get*() + (size_t/ssize_t) + * drivers/al175.c: drivers/al175.c: fix raw_data_t::buf_size and + io_head_t::addr,len to size_t + * drivers/al175.c: drivers/al175.c: fix int casting to ser_get*() + (size_t/ssize_t) + * drivers/dstate.c: drivers/dstate.c: augment range check when using + size_t as int + * drivers/dstate.c: drivers/dstate.c: fix int casting to read() and + write(), add range checks for bytes written (size_t/ssize_t) + +2021-09-23 Jim Klimov + + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: fix elapsed_time type + and casting + * drivers/bcmxcp.c, drivers/bcmxcp_io.h, drivers/bcmxcp_ser.c, + drivers/bcmxcp_usb.c: drivers/bcmxcp*.{c,h}: fix types involved + with read() and write() to ssize_t + * tools/nut-scanner/nutscan-serial.c: tools/nut-scanner/nutscan- + serial.c: fix count to size_t + * tools/nut-scanner/scan_avahi.c: tools/nut-scanner/scan_avahi.c: fix + buf_size to size_t + * tools/nut-scanner/scan_eaton_serial.c: tools/nut- + scanner/scan_eaton_serial.c: fix types involved with read() and + write() to ssize_t + * tools/nut-scanner/scan_eaton_serial.c: tools/nut- + scanner/scan_eaton_serial.c: fix size_t thread_count and its + iterator + * drivers/serial.c, drivers/serial.h: drivers/serial.[h,c]: fix + d_usec from long to useconds_t + * tools/nut-scanner/nut-scan.h, tools/nut-scanner/nut-scanner.c, + tools/nut-scanner/scan_avahi.c, tools/nut-scanner/scan_nut.c, + tools/nut-scanner/scan_snmp.c, tools/nut-scanner/scan_xml_http.c: + tools/nut-scanner/*.[h,c]: fix usec_timeout from long to useconds_t + * tools/nut-scanner/scan_xml_http.c: tools/nut- + scanner/scan_xml_http.c: fix size_t thread_count and its iterator + * tools/nut-scanner/scan_xml_http.c: tools/nut- + scanner/scan_xml_http.c: fix recv_size use as size_t parameter + * tools/nut-scanner/nut-scan.h, tools/nut-scanner/scan_xml_http.c: + tools/nut-scanner/nut-scan.h + scan_xml_http.c: fix port type to + uint16_t + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: fix + arg type for generate_Ku() + * drivers/apc-hid.c, drivers/bcmxcp_usb.c, drivers/belkin-hid.c, + drivers/blazer_usb.c, drivers/cps-hid.c, drivers/delta_ups-hid.c, + drivers/idowell-hid.c, drivers/liebert-hid.c, drivers/mge-hid.c, + drivers/nutdrv_atcl_usb.c, drivers/openups-hid.c, drivers/powercom- + hid.c, drivers/powervar-hid.c, drivers/richcomm_usb.c, + drivers/riello_usb.c, drivers/tripplite-hid.c, + drivers/tripplite_usb.c, drivers/usb-common.c, drivers/usb- + common.h: drivers/usb-common.{c,h} drivers/*{usb,hid}.c: fix type + of usb_device_id_t vendorID/productID to uint16_t * usb-common.h: + fix the definition * *{usb,hid}.c: sentinel in a table of uint16_t + can not be -1 * usb-common.c: uint16_t for vendor and product -- + change sentinel matcher for full (0,0,NULL) hits + * tools/nut-scanner/nutscan-ip.c: tools/nut-scanner/scan_xml_http.c: + 32-bit IPv4 addr mask should be uint32_t not int + * tools/nut-scanner/nutscan-ip.c: tools/nut-scanner/scan_xml_http.c: + 32-bit IPv4 addr should be uint32_t not int + +2021-10-12 Jim Klimov + + * tools/nut-scanner/nutscan-ip.c: tools/nut-scanner/nutscan-ip.c: + safety-check and cast use of small mask_byte values + +2021-09-23 Jim Klimov + + * tools/nut-scanner/nutscan-ip.c: tools/nut-scanner/nutscan-ip.c: use + platform-dependent getnameinfo() argument types + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: fix + size_t thread_count and its iterator + * tools/nut-scanner/scan_nut.c: tools/nut-scanner/scan_nut.c: fix + size_t thread_count and its iterator + * tools/nut-scanner/scan_nut.c: tools/nut-scanner/scan_nut.c: fix + size_t buf_size + * tools/nut-scanner/scan_nut.c: tools/nut-scanner/scan_nut.c: align + upscli_*() numa and numq args from "unsigned int" to "size_t", to + match PCONF_CTX_t fields + * server/upsd.c: server/upsd.c: fix comparisons of nfds_t maxconn, + long sysconf() and size_t malloc() + * server/upsd.c: server/upsd.c: check if maxconn<1 to avoid + signedness issues and because zero connections are also useless + * server/upsd.c: server/upsd.c: align use of nfds_t vs. long + (maxconn) for GCC "-Wtype-limits" + +2021-09-22 Jim Klimov + + * server/sstate.c: server/sstate.c: fix missed include + * server/conf.c, server/upsd.c, server/upsd.h: server/upsd.c + + conf.c: align use of nfds_t vs. long (maxconn) + * server/upsd.c: server/upsd.c: align use of uint8_t when + constructing an UUID + * clients/upsclient.c, server/netssl.c: server/netssl.c + + clients/upsclient.c: fix ssl_error() to use ssize_t "ret" + * server/sstate.c: server/sstate.c: fix int casting to read() and + write(), add range checks for bytes written (size_t/ssize_t) + * clients/upsc.c, clients/upsclient.c, clients/upsclient.h, + clients/upscmd.c, clients/upsimage.c, clients/upslog.c, + clients/upsmon.c, clients/upsrw.c, clients/upsset.c, + clients/upsstats.c, docs/man/upscli_get.txt, drivers/dummy-ups.c: + clients/upsclient.h and numerous *.c: align upscli_get(), + upscli_list_start(), upscli_list_next() numa and numq args from + "unsigned int" to "size_t", to match PCONF_CTX_t fields + * clients/upsmon.c: clients/upsmon.c: fix int casting to read() and + write(), add separate retval processing from system() + * clients/upssched.c: clients/upssched.c: fix int casting to read() + and write(), add range checks for bytes written (size_t/ssize_t) + * clients/upsclient.c: clients/upsclient.c: fix receiver of strtol(), + and log a FIXME for sanity checks + * clients/upsmon.c: clients/upsmon.c: fix receiver of strtol() + * clients/upssched.c: clients/upssched.c: fix receiver of strtol() + * clients/upsmon.c: clients/upsmon.c: fix int type for use of + upscli_readline() + * clients/upscmd.c: clients/upscmd.c: fix int type for use of + upscli_readline() + * clients/upsimage.c: clients/upsimage.c: fix int casting + * clients/upsrw.c: clients/upsrw.c: fix receiver of strtol() + * drivers/nutdrv_qx.c, server/netset.c: server/netset.c + + drivers/nutdrv_qx.c: fix consumers of "long" getaux() + * common/str.c: common/str.c: fix buffer int length in str_to_*int*() + methods + * common/state.c, include/state.h, server/sstate.c, server/sstate.h: + common/state.c + server/sstate.c + *.h: aux field is a "long" so + getaux() should return long + * common/common.c, include/common.h: common/common.c: fix use of a + pid_t value + +2021-11-25 Jim Klimov + + * configure.ac: configure.ac: typo fix for ABS_TOP_* determination + +2021-11-25 Jim Klimov + + * docs/FAQ.txt: Update FAQ.txt Update rationale (reasonable use- + cases) for "clone" driver + +2021-11-25 Jim Klimov + + * common/Makefile.am, configure.ac: configure.ac + + common/Makefile.am: detect if building in-tree and differentiate + the recipe involving common.c based on that + * common/Makefile.am: common/Makefile.am: let OpenBSD 6.4 make cope + with common.c recipe + * docs/config-prereqs.txt: docs/config-prereqs.txt: add libusb1 for + OpenBSD + * docs/config-prereqs.txt, docs/nut.dict: docs/config-prereqs.txt: + concerns about OpenBSD 6.4 freeipmi vs. "-largp" + +2021-11-25 Jim Klimov + + * NEWS, docs/nut.dict: NEWS: added new salicru-hid subdriver in + usbhid-ups for NUT v2.7.5 + +2021-11-25 xbgmsharp + + * drivers/salicru-hid.c: Rename unmapped.* to experimental.* data + points Add untested instant commands + +2021-11-24 xbgmsharp + + * drivers/salicru-hid.c: Update mapping + +2021-11-23 Jim Klimov + + * docs/FAQ.txt: docs/FAQ.txt: extend Q&A on "NUT proxying" with + mention of "clone" driver + +2021-11-22 xbgmsharp + + * data/driver.list.in, drivers/Makefile.am, drivers/salicru-hid.c, + drivers/salicru-hid.h, drivers/usbhid-ups.c, + scripts/upower/95-upower-hid.rules: Initial release for Salicru + driver + * data/driver.list.in, drivers/Makefile.am, drivers/salicru-hid.c, + drivers/salicru-hid.h, drivers/usbhid-ups.c, + scripts/upower/95-upower-hid.rules: Initial release for Salicru + driver + +2021-11-22 Yifeng Li + + * docs/nut.dict: docs/nut.dict: add model name "KRTS". + * docs/man/huawei-ups2000.txt: huawei-ups2000.txt: update tested + models and user report suggestions. + * docs/man/huawei-ups2000.txt: huawei-ups2000.txt: minor typo fixes + +2021-11-22 Jim Klimov + + * docs/FAQ.txt: Update docs/FAQ.txt Add example of dummy-ups (relay + mode) configuration section Co-authored-by: Helmut K. C. Tessarek + + +2021-11-18 Jim Klimov + + * drivers/snmp-ups.c, drivers/snmp-ups.h: drivers/snmp-ups.{c,h}: + typedef snmp_info_t::flags and define its PRI_SU_FLAGS format to + ease type changes later Also adds a "default:" to case for + template flag handling (from FTY fork) + +2021-11-22 Jim Klimov + + * docs/FAQ.txt: docs/FAQ.txt: update for interactions via github + (issues, PRs, ...) + * docs/FAQ.txt: docs/FAQ.txt: update for use-cases of dummy-ups in + relay mode + +2021-11-20 Jim Klimov + + * ci_build.sh: ci_build.sh: Make end of log useful for spellcheck + failure handling + +2021-11-20 Jim Klimov + + * docs/config-prereqs.txt, docs/nut.dict: docs/config-prereqs.txt: + add a chapter on OpenBSD build agent setup + * configure.ac: configure.ac: require at least autoconf-2.61 (macros + are used that are missing in 2.60 and before) + * autogen.sh: autogen.sh: comment that libtool is also needed + * autogen.sh: autogen.sh: comment about envs that want + AUTOCONF_VERSION or AUTOMAKE_VERSION + * autogen.sh, configure.ac, scripts/augeas/.gitignore, + scripts/devd/Makefile.am, scripts/udev/.gitignore, + scripts/udev/Makefile.am: autogen.sh + configure.ac: try to support + building on systems without Python or Perl + +2021-11-22 Arnaud Quette + + * drivers/mge-xml.c: Eaton XML/PDC: add External Battery Module count + +2021-11-16 Jim Klimov + + * drivers/snmp-ups-helpers.c: drivers/snmp-ups-helpers.c: reshuffle + includes + * drivers/snmp-ups.c: drivers/snmp-ups.c: include main.h => common.h + => config.h first + * drivers/snmp-ups.c: drivers/snmp-ups.c: fix strncmp() limits for + "v1" and "v3" checks (copy-pasting typo) + * drivers/snmp-ups.c: drivers/snmp-ups.c: mention in help that SNMP + version may be "v3" + * drivers/libusb1.c: drivers/libusb1.c: fix devcount and devnum from + ssize_t to size_t + +2021-11-15 Jim Klimov + + * drivers/nutdrv_qx_masterguard.c: drivers/nutdrv_qx_masterguard.c: + printf() assumes floating-point numbers are doubles, satisfy its + warnings + * drivers/libusb1.c: drivers/libusb1.c: drop extra "int i" definition + * ci_build.sh: ci_build.sh: NUT_USB_VARIANT= => --with- + usb=libusb [libusb-1.0+0.1 branch] + * ci_build.sh: ci_build.sh: NUT_USB_VARIANT=no => --without-usb + explicitly + * ci_build.sh: ci_build.sh: default-all-errors: report + BUILDSTODO_INITIAL at the end of log, and if non-zero BUILDSTODO + remained unaccounted + * ci_build.sh: ci_build.sh: report which SSL/USB variants will be + looped + * drivers/phoenixcontact_modbus.c: drivers/phoenixcontact_modbus.c: + use a longer global var name for modbus_ctx (nee ctx) + * drivers/bcmxcp_ser.c, drivers/bcmxcp_ser.h, tools/nut- + scanner/scan_eaton_serial.c: drivers/bcmxcp_ser.{c,h} + tools/nut- + scanner/scan_eaton_serial.c: use longer global var name (AUT => + BCMXCP_AUTHCMD) + * drivers/bestfortress.c: drivers/bestfortress.c: comment an + analyzer-check complaint + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: avoid useless + comparison (warning) + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: only define + "Compatibility layer between libusb 0.1 and 1.0" if we build with + QX_USB at all (no required headers are in context otherwise) + * ci_build.sh: ci_build.sh: BUILD_TYPE="default-all-errors": ensure + BUILDSTODO counts for SSL+USB are planned same as executed - and + handle explicit NUT_USB_VARIANTS=no + * ci_build.sh: ci_build.sh: BUILD_TYPE="default-all-errors": ensure + BUILDSTODO counts for SSL+USB are planned same as executed + * ci_build.sh: ci_build.sh: BUILD_TYPE="default-all-errors": ensure + BUILDSTODO counts are decremented when configuration failed + * ci_build.sh: ci_build.sh: BUILD_TYPE="default-all-errors": between + configure and build, report the Configured NUT_USB_VARIANT + * ci_build.sh: ci_build.sh: BUILD_TYPE="default-all-errors": between + configure and build, report the Configured NUT_SSL_VARIANT + * ci_build.sh: ci_build.sh: BUILD_TYPE="default-all-errors": support + looping over NUT_USB_VARIANTS as well + * drivers/libhid.c: drivers/libhid.c: HIDDumpTree(): mark that arg + "hd" is not used in SHUT_MODE + * m4/nut_check_libusb.m4: m4/nut_check_libusb.m4: the "additional + USB-related checks" should now manipulate "LIBS" not "LIBUSB_LIBS" + * m4/nut_check_libusb.m4: m4/nut_check_libusb.m4: comment on + "additional USB-related checks" + * m4/nut_check_libusb.m4: Move "additional USB-related checks" from + configure.ac to m4/nut_check_libusb.m4 + * drivers/nutdrv_qx.c: [libusb-1.0] Realign buffer casting to + (usb_ctrl_char) after merge from master + * tools/nut-scanner/scan_usb.c: tools/nut-scanner/scan_usb.c: fix + merge conflict [libusb-1.0+0.1] + * m4/nut_check_libusb.m4: m4/nut_check_libusb.m4: complete the merge + from master to libusb-1.0+0.1 + * ci_build.sh: ci_build.sh: NUT_USB_VARIANT=no => --without-usb + explicitly + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: fix definition of + curDevice (libusb-1.0) + * ci_build.sh: ci_build.sh: default-all-errors: report + BUILDSTODO_INITIAL at the end of log, and if non-zero BUILDSTODO + remained unaccounted + * ci_build.sh: ci_build.sh: default-all-errors: report + BUILDSTODO_INITIAL at the end of log, and if non-zero BUILDSTODO + remained unaccounted + * ci_build.sh: ci_build.sh: report which SSL/USB variants will be + looped + +2018-03-14 Daniele Pezzini + + * data/cmdvartab, docs/nut-names.txt: libusb: update example of + driver.version.usb and add it to cmdvartab + +2021-11-15 François-Régis Degott + + * drivers/eaton-ats16-nm2-mib.c: eaton-ats16-nm2-mib.c: fix mul coef. + for ambient.temperature and humidity (#1173) * eaton- + ats16-nm2-mib.c: fix mul coef. for ambient.temperature and + ambient.humidity * Update eaton-ats16-nm2-mib.c Co-authored-by: + Arnaud Quette + +2021-11-15 Jim Klimov + + * ci_build.sh: ci_build.sh: BUILD_TYPE="default-all-errors": between + configure and build, report the Configured NUT_SSL_VARIANT + * ci_build.sh: ci_build.sh: BUILD_TYPE="default-all-errors": ensure + BUILDSTODO counts are decremented when configuration failed + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: avoid useless + comparison (warning) + * drivers/bestfortress.c: drivers/bestfortress.c: comment an + analyzer-check complaint + * drivers/bcmxcp_ser.c, drivers/bcmxcp_ser.h, tools/nut- + scanner/scan_eaton_serial.c: drivers/bcmxcp_ser.{c,h} + tools/nut- + scanner/scan_eaton_serial.c: use longer global var name (AUT => + BCMXCP_AUTHCMD) + * drivers/phoenixcontact_modbus.c: drivers/phoenixcontact_modbus.c: + use a longer global var name for modbus_ctx (nee ctx) + * drivers/phoenixcontact_modbus.c: drivers/phoenixcontact_modbus.c: + use a longer global var name for modbus_ctx (nee ctx) + * drivers/bcmxcp_ser.c, drivers/bcmxcp_ser.h, tools/nut- + scanner/scan_eaton_serial.c: drivers/bcmxcp_ser.{c,h} + tools/nut- + scanner/scan_eaton_serial.c: use longer global var name (AUT => + BCMXCP_AUTHCMD) + * drivers/bestfortress.c: drivers/bestfortress.c: comment an + analyzer-check complaint + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: avoid useless + comparison (warning) + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: only define + "Compatibility layer between libusb 0.1 and 1.0" if we build with + QX_USB at all (no required headers are in context otherwise) + * configure.ac: configure.ac: neuter "nut_usb_lib" if building + --without-usb + * ci_build.sh: ci_build.sh: BUILD_TYPE="default-all-errors": ensure + BUILDSTODO counts for SSL+USB are planned same as executed - and + handle explicit NUT_USB_VARIANTS=no + * ci_build.sh: ci_build.sh: BUILD_TYPE="default-all-errors": ensure + BUILDSTODO counts for SSL+USB are planned same as executed + * ci_build.sh: ci_build.sh: BUILD_TYPE="default-all-errors": ensure + BUILDSTODO counts are decremented when configuration failed + * ci_build.sh: ci_build.sh: BUILD_TYPE="default-all-errors": between + configure and build, report the Configured NUT_USB_VARIANT + * ci_build.sh: ci_build.sh: BUILD_TYPE="default-all-errors": between + configure and build, report the Configured NUT_SSL_VARIANT + * ci_build.sh: ci_build.sh: BUILD_TYPE="default-all-errors": support + looping over NUT_USB_VARIANTS as well + * m4/nut_check_libusb.m4: m4/nut_check_libusb.m4: report a NOTICE if + libusb-1.0 support was detected, but another was chosen + * drivers/libhid.c: drivers/libhid.c: HIDDumpTree(): mark that arg + "hd" is not used in SHUT_MODE + * m4/nut_check_libusb.m4: m4/nut_check_libusb.m4: the "additional + USB-related checks" should now manipulate "LIBS" not "LIBUSB_LIBS" + * m4/nut_check_libusb.m4: m4/nut_check_libusb.m4: comment on + "additional USB-related checks" + * configure.ac, m4/nut_check_libusb.m4: Move "additional USB-related + checks" from configure.ac to m4/nut_check_libusb.m4 + * configure.ac, docs/configure.txt, m4/nut_check_libusb.m4: + m4/nut_check_libusb.m4 et al: add support for --with-libusb- + version=(auto|0.1|1.0) + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: restore "ret" lost in + merging + * drivers/riello_usb.c: drivers/riello_usb.c: properly export + variables shared between driver subtypes (reapply to libusb-1.0 + branch) + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: add a bit more of + "Compatibility layer between libusb 0.1 and 1.0" + * drivers/nutdrv_atcl_usb.c, drivers/nutdrv_qx.c, + drivers/richcomm_usb.c: [libusb-1.0] Realign use of + nut_usb_strerror() after merge from master + * drivers/libusb1.c, drivers/nutdrv_qx.c: [libusb-1.0] Realign buffer + casting to (usb_ctrl_char) after merge from master + +2021-11-13 Dan Benton + + * data/driver.list.in: Add CyberPower RMCARD205 which is supported + +2021-11-13 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: hide clang-3.4 warnings + about str{n}cmp() args into pragmas + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: detect general "-Warray- + bounds" support + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: detect general + "-Wtautological-compare" + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: detect "pragma clang + diagnostic push/pop" support (needed with older clang versions not + on par with GCC) + * drivers/snmp-ups-helpers.c: drivers/snmp-ups-helpers.c: include + "config.h" before any system headers (such as time.h indirectly) + * configure.ac: configure.ac: be sure to detect "time.h" + * ci_build.sh: ci_build.sh: support a common DO_CLEAN_CHECK=no + +2021-11-13 Jim Klimov + + * drivers/snmp-ups-helpers.c: drivers/snmp-ups-helpers.c: include a + header, avoid a warning + * UPGRADING, docs/nut.dict: NEWS: updated build against various + generations of Net-SNMP for NUT v2.7.5 + * docs/configure.txt, m4/nut_check_libnetsnmp.m4: + m4/nut_check_libnetsnmp.m4: allow --with-netsnmp-config(=yes) to + mean prefer_NET_SNMP_CONFIG=true + * NEWS: NEWS: updated build against various generations of FreeIPMI + for NUT v2.7.5 + * drivers/snmp-ups.c: drivers/snmp-ups.c: replace strcmp("short + string") with strncmp() (clang-3.4 warns about array out of bounds) + * drivers/bcmxcp_ser.c: drivers/bcmxcp_ser.c: resolve a "tautological + compare" when building on older agents + * drivers/nut-ipmi.h, drivers/nut-ipmipsu.c, drivers/nut- + libfreeipmi.c: drivers/nut-libfreeipmi.c nut-ipmipsu.c nut-ipmi.h: + adjust input_voltage_range_t (args of + ipmi_fru_multirecord_power_supply_information() vs. + ipmi_fru_parse_multirecord_power_supply_information() in different + FreeIPMI releases) [issue #1175] + * drivers/Makefile.am: drivers/Makefile.am: disable quick-hack of + nut_ipmipsu_CFLAGS+="-Wno-pointer-sign" [issue #1175] + * m4/nut_check_libusb.m4: m4/nut_check_libusb.m4: consider + have_PKG_CONFIG + * m4/nut_check_libopenssl.m4: m4/nut_check_libopenssl.m4: consider + have_PKG_CONFIG + * m4/nut_check_libnss.m4: m4/nut_check_libnss.m4: consider + have_PKG_CONFIG + * m4/nut_check_libnetsnmp.m4: m4/nut_check_libnetsnmp.m4: consider + have_PKG_CONFIG + * m4/nut_check_libneon.m4: m4/nut_check_libneon.m4: consider + have_PKG_CONFIG + * m4/nut_check_libmodbus.m4: m4/nut_check_libmodbus.m4: consider + have_PKG_CONFIG + * m4/nut_check_libgd.m4: m4/nut_check_libgd.m4: consider + have_PKG_CONFIG + * m4/nut_check_libfreeipmi.m4: m4/nut_check_libfreeipmi.m4: consider + have_PKG_CONFIG + * m4/nut_check_libavahi.m4: m4/nut_check_libavahi.m4: consider + have_PKG_CONFIG + * m4/nut_check_pkgconfig.m4: m4/nut_check_pkgconfig.m4: separate + detection of support for have_PKG_CONFIG vs have_PKG_CONFIG_MACROS + * configure.ac: configure.ac: call PKG_CONFIG for systemd settings + query only if we have_PKG_CONFIG, and die if "yes" was required but + query is not possible + * m4/nut_check_pkgconfig.m4: m4/nut_check_pkgconfig.m4: extend to + consider PKG_CONFIG possibly detected by autoconf + * configure.ac, m4/nut_check_pkgconfig.m4: configure.ac: evict + NUT_CHECK_PKGCONFIG into m4/nut_check_pkgconfig.m4 + * clients/upsmon.c, drivers/mge-utalk.c, drivers/snmp-ups.c, + tools/nut-scanner/scan_snmp.c: clients/upsmon.c tools/nut- + scanner/scan_snmp.c drivers/snmp-ups.c mge-utalk.c: avoid + strcmp("") as the implementation may be invalid (reaches out of + one-element array for "") + * m4/nut_check_libnetsnmp.m4: m4/nut_check_libnetsnmp.m4: whitespace + fix (indent if-clause content) + +2021-11-12 Jim Klimov + + * m4/nut_check_libnetsnmp.m4: m4/nut_check_libnetsnmp.m4: support + (and prefer) pkg-config info to net-snmp-config script(s) + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: separate + "distcheck-valgrind" from "default-nodoc", to filter away + "NUT_BUILD_CAPS=valgrind=no" agents + +2021-11-13 Jim Klimov + + * ci_build.sh: ci_build.sh: update guessing SYS_PKG_CONFIG_PATH for + *openindiana*|*omnios*|*solaris*|*illumos*|*sunos* + * ci_build.sh: ci_build.sh: for optional_maintainer_clean_check(), + ignore ".ci*.log*" files if present + +2021-11-12 Jim Klimov + + * ci_build.sh: ci_build.sh: report which PWD failed a "git status" + query + * ci_build.sh: ci_build.sh: report if ".git" disappeared during + *clean check [issue #1167] + +2021-11-11 Jim Klimov + + * drivers/snmp-ups.h: drivers/snmp-ups.h: fix remaining SU_* flag + bits to (unsigned long), to match snmp_info_t->flags type + * drivers/snmp-ups.h: drivers/snmp-ups.h: comment SU_* bit usage by + bit-shifting macros + * drivers/snmp-ups.h: drivers/snmp-ups.h: wrap long comments, and + detail where flag-field bits come from + * drivers/snmp-ups.h: drivers/snmp-ups.h: comment typical use of + SU_TYPE(t) macro + * drivers/snmp-ups.h: drivers/snmp-ups.h: fix SU_TYPE_DAISY(t) macro + (had no arg) + * drivers/snmp-ups.h: drivers/snmp-ups.h: whitespace fixes + * drivers/snmp-ups.h: drivers/snmp-ups.h: comment SU_STATUS_NUM_ELEM + as possibly obsolete + +2021-10-27 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: fix buffer size to possibly + print max size_t + +2021-10-26 Jim Klimov + + * drivers/snmp-ups.c, drivers/snmp-ups.h: drivers/snmp-ups.{c,h}: fix + SU_FLAG_* to (unsigned long) and their usage, to match + snmp_info_t->flags type + * drivers/snmp-ups.c: drivers/snmp-ups.c: decode_str(): range-check + return of snprintf() + +2021-11-11 Jim Klimov + + * tools/nut-scanner/Makefile.am: tools/nut-scanner/Makefile.am: + rearrange lines to better match with 42ITy fork + * NEWS, docs/nut.dict: NEWS: improved SNMPv3 Auth/Priv algo support, + and nut-scanner threadcount, for NUT v2.7.5 + +2021-11-10 Jim Klimov + + * drivers/Makefile.am: drivers/Makefile.am: hotfix header + (in)compatibility of different IPMI versions + * drivers/Makefile.am: drivers/Makefile.am: hotfix header + (in)compatibility of different IPMI versions + * drivers/Makefile.am: drivers/Makefile.am: hotfix header + (in)compatibility of different IPMI versions + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: hunnox_step is only used + qith QX_USB + * drivers/bcmxcp_usb.c, drivers/libusb.h, drivers/nutdrv_atcl_usb.c, + drivers/nutdrv_qx.c, drivers/richcomm_usb.c, + drivers/tripplite_usb.c: drivers/*usb*: align whitespace changes + with libusb-1.0 branch + * drivers/Makefile.am: drivers/Makefile.am: use LIBUSB_IMPL macro to + align with libusb-1.0 branch + * drivers/libusb.c: drivers/libusb.c: whitespace fixes and message + fixes to align with libusb-1.0 branch + * drivers/libusb.c, drivers/libusb.h, drivers/powervar-hid.c, + drivers/usbhid-ups.c: drivers/libusb.{c,h} + powervar-hid.c + + usbhid-ups.c: whitespace fixes after PR #1044 + * docs/config-prereqs.txt: docs/config-prereqs.txt: mention further + I2C-related packages in Debian/Ubuntu distros + * ci_build.sh: ci_build.sh: in "default-all-errors" mode, report the + start of build variant and how many remain + * Makefile.am, clients/Makefile.am, common/Makefile.am, + conf/Makefile.am, data/Makefile.am, data/html/Makefile.am, + docs/Makefile.am, docs/cables/Makefile.am, docs/man/Makefile.am, + drivers/Makefile.am, include/Makefile.am, lib/Makefile.am, + scripts/Makefile.am, scripts/Solaris/Makefile.am, + scripts/augeas/Makefile.am, scripts/devd/Makefile.am, + scripts/hotplug/Makefile.am, scripts/python/Makefile.am, + scripts/systemd/Makefile.am, scripts/udev/Makefile.am, + scripts/ufw/Makefile.am, scripts/upsdrvsvcctl/Makefile.am, + server/Makefile.am, tests/Makefile.am, tools/Makefile.am, + tools/nut-scanner/Makefile.am: */Makefile.am: ensure that `make + maintainer-clean` also removes .dirstamp files + * .gitignore: .gitignore: remove a redundancy + * ci_build.sh: ci_build.sh: in "default-all-errors" mode, ignore + strange exit-code from `expr` - if the maths result was "0" + * ci_build.sh: ci_build.sh: in "default-all-errors" mode, ignore + strange exit-code from `expr` + * ci_build.sh: ci_build.sh: in "default-all-errors" mode, do not + distclean before build (this just spends time to generate the + Makefile to kill it) + * ci_build.sh: ci_build.sh: in "default-all-errors" mode, report + "SUCCEEDED build(s)" after final optional_maintainer_clean_check() + if that is called + * ci_build.sh: ci_build.sh: dumb down can_clean_check() to pass "set + -e" shells + * ci_build.sh: ci_build.sh: optional_*_clean_check() quickly skip if + there is no Makefile + * ci_build.sh: ci_build.sh: in "default-all-errors" mode, count + expected/remaining BUILDSTODO and call + optional_maintainer_clean_check() for the last iteration and + optional_dist_clean_check() for others + * ci_build.sh: ci_build.sh: introduce can_clean_check() to not fail + when we have nothing to test against + +2021-11-09 Jim Klimov + + * Makefile.am: Makefile.am: first-shot "git-realclean-check" and + targets to print *CLEANFILES lists + * ci_build.sh: ci_build.sh: introduce optional_dist_clean_check() to + use e.g. in "default-all-errors" case + * ci_build.sh: ci_build.sh: in loop for "default-all-errors", report + "build" successes as such + * ci_build.sh: ci_build.sh: skip optional_maintainer_clean_check() if + there is no .git [issue #1167] + +2021-11-09 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: consider SNMPv3 Auth/Priv + algos detected by configure script when reporting the usage (via + addvar() help messages) [issue #1169] + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + consider SNMPv3 Auth/Priv algos detected by configure script when + reporting the usage [issue #1169] + * tools/nut-scanner/scan_ipmi.c: tools/nut-scanner/scan_ipmi.c: + comment the comment + * tools/nut-scanner/scan_nut.c, tools/nut-scanner/scan_snmp.c, + tools/nut-scanner/scan_xml_http.c: tools/nut- + scanner/scan_xml_http.c + scan_snmp.c + scan_nut.c: ifdef the + references to max_threads_scantype + +2021-11-09 Jim Klimov + + * configure.ac: configure.ac: limit the impact of linux_i2c absent + libs when "auto" mode was requested + * ci_build.sh: ci_build.sh: start default build from a clean slate, + and do not REQUIRE to be able to build everything (do auto-detect) + * tests/Makefile.am, tools/nut-scanner/Makefile.am: tools/nut- + scanner/Makefile.am, tests/Makefile.am: do not refer to + LINKED_SOURCE_FILES with extra paths + +2021-11-09 Jim Klimov + + * docs/ci-farm-lxc-setup.txt, docs/nut.dict: docs/ci-farm-lxc- + setup.txt: note about PTY definitions + * docs/config-prereqs.txt: docs/config-prereqs.txt: say a bit more + about OSes with containers + * docs/config-prereqs.txt: docs/config-prereqs.txt: say a bit more + about "General call to Test" and mention "ci_build.sh" + * docs/config-prereqs.txt, docs/nut.dict: docs/config-prereqs.txt: + revise pkgs available in Debian-like operating systems + +2021-11-08 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: use detected + NUT_HAVE_LIBNETSNMP_usm* support to define and use actual Priv or + Auth types + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: use + detected NUT_HAVE_LIBNETSNMP_usm* support to define and use actual + Priv or Auth types + * m4/nut_check_libnetsnmp.m4: m4/nut_check_libnetsnmp.m4: detect + support of usmAES128PrivProtocol in Net-SNMP we build against + * m4/nut_check_libnetsnmp.m4: m4/nut_check_libnetsnmp.m4: detect + support of (NETSNMP_DRAFT_BLUMENTHAL_AES_04) usmAES192PrivProtocol + usmAES256PrivProtocol in Net-SNMP we build against + * m4/nut_check_libnetsnmp.m4: m4/nut_check_libnetsnmp.m4: detect + support of usmDESPrivProtocol usmHMACMD5AuthProtocol + usmHMACSHA1AuthProtocol in Net-SNMP we build against + * m4/nut_check_libnetsnmp.m4: m4/nut_check_libnetsnmp.m4: detect + support of usmHMAC256SHA384AuthProtocol + usmHMAC384SHA512AuthProtocol usmHMAC192SHA256AuthProtocol in Net- + SNMP we build against + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: ifdef + all references to NETSNMP_DRAFT_BLUMENTHAL_AES_04 related code + * tools/nut-scanner/nut-scanner.c, tools/nut-scanner/nutscan-init.c: + tools/nut-scanner/... : move init/destroy of threadcount_mutex from + nut-scanner.c to nutscan-init.c + +2021-11-05 Dim + + * drivers/snmp-ups.c, tools/nut-scanner/nut-scanner.c, tools/nut- + scanner/scan_snmp.c: Added new auth methods to snmp + +2021-11-08 Jim Klimov + + * tools/nut-scanner/scan_eaton_serial.c, tools/nut- + scanner/scan_nut.c, tools/nut-scanner/scan_snmp.c, tools/nut- + scanner/scan_xml_http.c: tools/nut-scanner/scan_eaton_serial.c + + scan_nut.c + scan_snmp.c + scan_xml_http.c: release global + semaphores in final protocol-scanner tread reaping + * tools/nut-scanner/scan_eaton_serial.c, tools/nut- + scanner/scan_nut.c, tools/nut-scanner/scan_snmp.c, tools/nut- + scanner/scan_xml_http.c: tools/nut-scanner/scan_eaton_serial.c + + scan_nut.c + scan_snmp.c + scan_xml_http.c: report if we are + waiting for semaphored threads to complete + +2017-10-31 barraudl + + * tools/nut-scanner/Makefile.am, tools/nut-scanner/README, tools/nut- + scanner/nut-scan.h, tools/nut-scanner/nut-scanner.c, tools/nut- + scanner/nutscan-init.c, tools/nut-scanner/nutscan-init.h: Revise + use of semaphores in nut-scanner vs libnutscanner Original commit + in 42ITy fork in 2017: "Fix the Debian package generation" Adapted + into NUT upstream code, considering 4 years of codebase evolution, + in 2021: + +2017-10-23 barraudl + + * configure.ac, tools/nut-scanner/nut-scan.h, tools/nut-scanner/nut- + scanner.c, tools/nut-scanner/scan_eaton_serial.c, tools/nut- + scanner/scan_nut.c, tools/nut-scanner/scan_snmp.c, tools/nut- + scanner/scan_xml_http.c: Add thread limitation to avoid memory + error Original development in 42ITy fork in 2017: UPDATE: Merged + with NUT upstream, considering evolution of codebases over 4 years + since original commit, revised 2021: + +2021-11-08 Jim Klimov + + * drivers/mge-hid.c: drivers/mge-hid.c: actively check and warn if we + truncated the string + * drivers/gamatronic.c: drivers/gamatronic.c: actively check and warn + if we truncated the string + * docs/nut.dict: docs/nut.dict: update for recent NEWS + * drivers/nutdrv_qx_masterguard.c: drivers/nutdrv_qx_masterguard.c: + safely limit a strncpy() call + * drivers/oneac.c: drivers/oneac.c: shield a potentially truncating + snprintf() into a small buffer + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: introduce + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRINGOP_TRUNCATION + * drivers/mge-hid.c: drivers/mge-hid.c: shield a potentially + truncating snprintf() into a small buffer + +2021-11-08 Jim Klimov + + * configure.ac: configure.ac: for CppUnit, also sanity-check + CPPUNIT_ASSERT_MESSAGE() + +2021-11-07 Jim Klimov + + * clients/Makefile.am: clients/Makefile.am: depend on "dummy" recipe + to re-evaluate out-of-dir libs (so development iterations in them + are reflected in rebuilds) + * drivers/Makefile.am: drivers/Makefile.am: depend on "dummy" recipe + to re-evaluate out-of-dir libs (so development iterations in them + are reflected in rebuilds) + * server/Makefile.am: server/Makefile.am: depend on "dummy" recipe to + re-evaluate out-of-dir libs (so development iterations in them are + reflected in rebuilds) + * tools/nut-scanner/Makefile.am: tools/nut-scanner/Makefile.am: + depend on "dummy" recipe to re-evaluate out-of-dir libs (so + development iterations in them are reflected in rebuilds) + * tests/Makefile.am: tests/Makefile.am: depend on "dummy" recipe to + re-evaluate out-of-dir libs (so development iterations in them are + reflected in rebuilds) + * tests/Makefile.am: tests/Makefile.am: drop obsoleted comment + * tests/nutclienttest.cpp: tests/nutclienttest.cpp: add + test_strarr_alloc() This may seem trivial, but there are + suspicions this allocation does not always work (e.g. NUT issue + #1126) + +2021-11-07 Jim Klimov + + * drivers/gamatronic.c: drivers/gamatronic.c: shield a potentially + truncating snprintf() into a small buffer + * drivers/bcmxcp.c: drivers/bcmxcp.c: shield a potentially dangerous + snprintf() into a small buffer as tested-safe + * clients/upscmd.c: clients/upscmd.c: shield a potentially dangerous + snprintf() into a small buffer as tested-safe + * clients/upsrw.c: clients/upsrw.c: shield a potentially dangerous + snprintf() into a small buffer as tested-safe + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: add + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION + +2021-11-07 Jim Klimov + + * clients/nutclient.cpp: clients/nutclient.cpp: safety check in + strarr_alloc(): returned pointer should be not null + * clients/nutclient.h: tests/nutclienttest.h: whitespace fixes + (indent chars) + * tests/nutclienttest.cpp: tests/nutclienttest.cpp: whitespace fixes + (wrap long lines for maintainability) + +2021-11-07 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: load_mib2nut(): do not + report "Unknown mibs value" just if a device did not match the + mapping [NUT issue #1141] + * drivers/snmp-ups.c: drivers/snmp-ups.c: refactor load_mib2nut() to + not `strcmp(mib, "auto")` many times + +2021-11-07 Jim Klimov + + * drivers/snmp-ups.c: Update snmp-ups.c Fix use of `char + su_scratch_buf[255]` (original static array moved to another file + in master branch), and bump `DRIVER_VERSION` + +2021-11-07 Jim Klimov + + * NEWS: NEWS: added snmp-ups support for ondelay/offdelay for + NUT-2.7.5 + +2021-11-07 Jim Klimov + + * drivers/snmp-ups.c: Update snmp-ups.c Use the common (and + sufficiently large for any runaway numeric madness) + `su_scratch_buf` instead of a local `char[6]` buffer. + * drivers/snmp-ups.c: Update snmp-ups.c A few small whitespace fixes + +2021-11-07 Jim Klimov + + * drivers/arduino-hid.c: drivers/arduino-hid.c: normalize whitespace + for NUT codebase + * drivers/arduino-hid.c, drivers/arduino-hid.h: drivers/arduino- + hid.{c,h}: update (C) to arduino-hid support author + * NEWS: NEWS: added usbhid-ups new subdriver arduino-hid support for + NUT-2.7.5 + * NEWS: NEWS: added USB HID support on interface number greater than + 0 for NUT-2.7.5 + * NEWS: NEWS: added huawei-ups2000 support for NUT-2.7.5 + +2021-11-07 Jim Klimov + + * docs/man/huawei-ups2000.txt: Update huawei-ups2000.txt Made the + `configure` example a bit friendlier for copy-pasting. + +2021-11-06 Jim Klimov + + * tests/.gitignore, tools/nut-scanner/.gitignore: GitIgnore + LINKED_SOURCES (follow-up to PR #1159) + * .gitignore: GitIgnore .dirstamp in build trees + * Makefile.am: Makefile.am: move removal of dist tarballs and build + packages from "distclean" to "maintainer-clean" + * tools/nut-scanner/Makefile.am: tools/nut-scanner/Makefile.am: mark + use of LINKED_SOURCE_FILES as "nodist" + * tests/Makefile.am: tests/Makefile.am: mark use of + LINKED_SOURCE_FILES as "nodist" + * Makefile.am: Makefile.am: add a "make realclean" as alias to + maintainer-clean + * Makefile.am: Makefile.am: typo fix MAINTAINERCLEAN_FILES => + MAINTAINERCLEANFILES + * ci_build.sh: ci_build.sh: there is no default "make realclean" + implem in autotools, fall back to "maintainer-clean" support for + wipingg the workspace + * Makefile.am, clients/Makefile.am, common/Makefile.am, + conf/Makefile.am, data/Makefile.am, data/html/Makefile.am, + docs/Makefile.am, docs/cables/Makefile.am, docs/man/Makefile.am, + drivers/Makefile.am, include/Makefile.am, lib/Makefile.am, + scripts/Makefile.am, scripts/Solaris/Makefile.am, + scripts/augeas/Makefile.am, scripts/devd/Makefile.am, + scripts/hotplug/Makefile.am, scripts/python/Makefile.am, + scripts/systemd/Makefile.am, scripts/udev/Makefile.am, + scripts/ufw/Makefile.am, scripts/upsdrvsvcctl/Makefile.am, + server/Makefile.am, tests/Makefile.am, tools/Makefile.am, + tools/nut-scanner/Makefile.am: */Makefile.am: there is no default + "make realclean" implem in autotools, fall back to "maintainer- + clean" support for wipingg the workspace + * Makefile.am, clients/Makefile.am, common/Makefile.am, + conf/Makefile.am, data/Makefile.am, data/html/Makefile.am, + docs/Makefile.am, docs/cables/Makefile.am, docs/man/Makefile.am, + drivers/Makefile.am, include/Makefile.am, lib/Makefile.am, + scripts/Makefile.am, scripts/Solaris/Makefile.am, + scripts/augeas/Makefile.am, scripts/devd/Makefile.am, + scripts/hotplug/Makefile.am, scripts/python/Makefile.am, + scripts/systemd/Makefile.am, scripts/udev/Makefile.am, + scripts/ufw/Makefile.am, scripts/upsdrvsvcctl/Makefile.am, + server/Makefile.am, tests/Makefile.am, tools/Makefile.am, + tools/nut-scanner/Makefile.am: */Makefile.am: reshuffle what we + remove as part of "make distclean" vs. "make realclean" (can be + remade only by autogen.sh) + * Makefile.am: Makefile.am: do not "distclean" away some more parts + of "configure" script ecosystem (leave that to "realclean") + * tools/nut-scanner/Makefile.am: tools/nut-scanner/Makefile.am: + restore use of $(builddir) for LINKED_SOURCE_FILES + * tests/Makefile.am: tests/Makefile.am: restore use of $(builddir) + for LINKED_SOURCE_FILES + * ci_build.sh: ci_build.sh: call optional_realclean_check() after + more build variants + * tools/Makefile.am: tools/Makefile.am: distclean the helper scripts + that can be re-made + * ci_build.sh: ci_build.sh: change the cleanliness check from + "distcheck" to "realcheck" and factor into a method + * Makefile.am: Makefile.am: regenerate the helper needed for + ChangeLog if cleaned away + * Makefile.am: Makefile.am: delete the configure script and its + components not in a "make distclean" but in "make realclean" + +2021-11-05 Jim Klimov + + * tools/nut-scanner/Makefile.am: tools/nut-scanner/Makefile.am: use + BUILT_SOURCES=LINKED_SOURCE_FILES to avoid dist-ing temporary + symlinks as files + * tests/Makefile.am: tests/Makefile.am: use + BUILT_SOURCES=LINKED_SOURCE_FILES to avoid dist-ing temporary + symlinks as files + * ci_build.sh: ci_build.sh: only call dpkg if present + * ci_build.sh: ci_build.sh: configure_nut(): call ./autogen.sh before + CONFIGURE_SCRIPT if there is no configure script + * tools/nut-scanner/Makefile.am: tools/nut-scanner/Makefile.am: + revise the magic of LINKED_SOURCE_FILES for distcheck + * tests/Makefile.am: tests/Makefile.am: revise the magic of + LINKED_SOURCE_FILES for distcheck + * ci_build.sh: ci_build.sh: add a DO_DISTCHECK_CLEAN to make sure we + clean everything made, and no more (after any distcheck) + * tools/nut-scanner/Makefile.am: tools/nut-scanner/Makefile.am: + revise the magic of LINKED_SOURCE_FILES for distcheck + * tests/Makefile.am: tests/Makefile.am: revise the magic of + LINKED_SOURCE_FILES for distcheck + * tools/nut-scanner/Makefile.am: tools/nut-scanner/Makefile.am: make + sure to symlink sources into $(builddir)/ + * tests/Makefile.am: tests/Makefile.am: make sure to symlink sources + into $(builddir)/ + * tools/nut-scanner/Makefile.am: tools/nut-scanner/Makefile.am: work + around dmake bugs + * tests/Makefile.am: tests/Makefile.am: work around dmake bugs + * tools/nut-scanner/Makefile.am: tools/nut-scanner/Makefile.am: quote + pathnames, and force the symlink (to overwrite older if any) + * tests/Makefile.am: tests/Makefile.am: quote pathnames, and force + the symlink (to overwrite older if any) + * Makefile.am: Makefile.am: distclean-local: first find(), then rm() + the findings (find-recursion fails otherwise) + * tools/nut-scanner/Makefile.am: tools/nut-scanner/Makefile.am: + symlink source used from another directory into current builddir, + do avoid external ".deps/" usage + * tests/Makefile.am: tests/Makefile.am: symlink source used from + another directory into current builddir, do avoid external ".deps/" + usage + * Makefile.am, clients/Makefile.am, common/Makefile.am, + drivers/Makefile.am, server/Makefile.am, tests/Makefile.am, + tools/nut-scanner/Makefile.am: */Makefile.am: Do not clean ".deps" + in SUBDIRS of the main project + * Makefile.am, clients/Makefile.am, common/Makefile.am, + conf/Makefile.am, data/Makefile.am, data/html/Makefile.am, + docs/Makefile.am, docs/cables/Makefile.am, docs/man/Makefile.am, + drivers/Makefile.am, include/Makefile.am, lib/Makefile.am, + scripts/Makefile.am, scripts/Solaris/Makefile.am, + scripts/augeas/Makefile.am, scripts/devd/Makefile.am, + scripts/hotplug/Makefile.am, scripts/python/Makefile.am, + scripts/systemd/Makefile.am, scripts/udev/Makefile.am, + scripts/ufw/Makefile.am, scripts/upsdrvsvcctl/Makefile.am, + server/Makefile.am, tests/Makefile.am, tools/Makefile.am, + tools/nut-scanner/Makefile.am: */Makefile.am: revise CLEANFILES and + DISTCLEANFILES (favored over clean-local target rules) + +2021-11-04 Jim Klimov + + * tools/nut-scanner/Makefile.am: tools/nut-scanner/Makefile.am: use + libcommon.la as part of libnutscan.(la|so) + +2021-11-04 Jim Klimov + + * tools/nut-scanner/Makefile.am: tools/nut-scanner/Makefile.am: do + not build common.c into nut-scanner (avoid double-definition of + nut_debug_level among other things) + * tools/nut-scanner/Makefile.am: tools/nut-scanner/Makefile.am: fix + rule for NUT_SCANNER_DEPS to be sure + * clients/Makefile.am, common/Makefile.am, drivers/Makefile.am, + server/Makefile.am, tests/Makefile.am, tools/nut- + scanner/Makefile.am: */Makefile.am: define dependencies on out-of- + dir *.la helper libs: use AM_MAKEFLAGS (follows-up to PR #1151) + +2021-11-04 Jim Klimov + + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + revise parsing of --thread via strtol() Inspired by 42ITy fork + approach to similar issue + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + rename "--jobs" to "--thread" Inspired by 42ITy fork approach to + similar issue + +2021-11-04 Jim Klimov + + * tools/nut-scanner/Makefile.am: tools/nut-scanner/Makefile.am: fix + rule for NUT_SCANNER_DEPS to be sure + * clients/Makefile.am, common/Makefile.am, drivers/Makefile.am, + server/Makefile.am, tests/Makefile.am, tools/nut- + scanner/Makefile.am: */Makefile.am: define dependencies on out-of- + dir *.la helper libs: use AM_MAKEFLAGS (follows-up to PR #1151) + +2021-11-04 Jim Klimov + + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + refine sanity-checks for nofile_limit.rlim_cur value range + * tools/nut-scanner/nut-scan.h, tools/nut-scanner/nut-scanner.c, + tools/nut-scanner/scan_nut.c, tools/nut-scanner/scan_snmp.c, + tools/nut-scanner/scan_xml_http.c: tools/nut-scanner/nut-scanner.c + + scan_xml_http.c + scan_snmp.c + scan_nut.c + nut-scan.h: Add a + hard limit on netxml scanning thread count + * configure.ac, tools/nut-scanner/nut-scanner.c: tools/nut- + scanner/nut-scanner.c + configure.ac: detect if getrlimit() is + usable + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + constrain default or requested job count with current `ulimit -n` + (minus known overhead) + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + whitespace fix + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + wrap long line + +2021-11-03 Jim Klimov + + * tools/nut-scanner/scan_eaton_serial.c: tools/nut- + scanner/scan_eaton_serial.c: limit thread count like in scan_snmp.c + * tools/nut-scanner/scan_nut.c: tools/nut-scanner/scan_nut.c: limit + thread count like in scan_snmp.c + * tools/nut-scanner/scan_xml_http.c: tools/nut- + scanner/scan_xml_http.c: define TRUE/FALSE + * tools/nut-scanner/scan_xml_http.c: tools/nut- + scanner/scan_xml_http.c: limit thread count like in scan_snmp.c + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: + comment "#endif // HAVE_PTHREAD" to navigate in code better + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: only + loop to free the thread_array if any were allocated + * tools/nut-scanner/nut-scan.h, tools/nut-scanner/scan_snmp.c: + tools/nut-scanner/nut-scan.h + scan_snmp.c: (C) header and some + cosmetic fixes + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + bump default max_threads to not lag with /24 subnets + +2021-11-03 Jim Klimov + + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: only + sleep after attempting pthread_tryjoin_np() if nothing got cleaned + away + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: hide + debug logging for thread herding + * tools/nut-scanner/nut-scan.h, tools/nut-scanner/scan_snmp.c: + tools/nut-scanner/scan_snmp.c: update comments and messages + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: + update log-tracing of pthread herding + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: move + locking of total thread count change when we add one + +2021-11-03 Jim Klimov + + * configure.ac, tools/nut-scanner/nut-scanner.c, tools/nut- + scanner/scan_snmp.c: configure.ac, tools/nut-scanner/scan_snmp.c, + tools/nut-scanner/nut-scanner.c: not all glibc versions + HAVE_PTHREAD_TRYJOIN + +2021-11-03 Jim Klimov + + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: limit + the thread count for parallelized scanning + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + add a threadcount_mutex to use in all children + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: + handle max_threads, curr_threads + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + add support for -j N (--jobs=N) option to limit simultaneous + scanning threads + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: + comment a FIXME for limiting the pthread count + * tools/nut-scanner/nutscan-ip.c: tools/nut-scanner/nutscan-ip.c: + nutscan_cidr_to_ip(): forbid scanning whole Internet + +2021-11-03 Jim Klimov + + * tests/.gitignore: GitIgnore test log and trace for "getvaluetest" + +2021-11-03 Jim Klimov + + * tools/nut-scanner/nutscan-ip.c: tools/nut-scanner/nutscan-ip.c: + tone down the debug-logging of CIDR processing + * tools/nut-scanner/nutscan-ip.c: tools/nut-scanner/nutscan-ip.c: + only free cidr_tok after we are done manipulating its memory buffer + * tools/nut-scanner/nut-scanner.c, tools/nut-scanner/nutscan-ip.c: + nutscan-ip.c, nut-scanner.c: instrument the CIDR processing to + trace an error + +2021-11-02 Jim Klimov + + * docs/documentation.txt, docs/man/dummy-ups.txt: + docs/documentation.txt + docs/man/dummy-ups.txt: refer to + `tools/nut-ddl-dump.sh` in the same manner (issue #1111) + * docs/man/dummy-ups.txt: docs/man/dummy-ups.txt: fix use of "link:" + tag in asciidoc (issue #1111) and slightly reword + * docs/documentation.txt: docs/documentation.txt: fix use of "link:" + tag in asciidoc (issue #1111) and slightly reword + * docs/nut-names.txt: docs/nut-names.txt: fix use of "link:" tag in + asciidoc (issue #1111) + * docs/developers.txt: docs/developers.txt: fix use of "link:" tag in + asciidoc (issue #1111) + +2021-11-01 Jim Klimov + + * ci_build.sh: ci_build.sh: give the caller a way to disable parallel + builds with PARMAKE_FLAGS=" " (space) + * ci_build.sh: ci_build.sh: enable parallel builds for default build + (one without a BUILD_TYPE specified) + * ci_build.sh: ci_build.sh: enable parallel builds for "distcheck" in + default builds, which should now pass well (after usual build and + check passed) + * ci_build.sh: ci_build.sh: report chosen settings for parallel + builds + * configure.ac: configure.ac: test more proactively if valgrind can + test things and not crash by itself + * ci_build.sh: ci_build.sh: enable parallel builds for "default- + tgt:*" which should now pass well + * ci_build.sh: ci_build.sh: guess the available amount of parallelism + for the current system; consider load averages for GNU Make too + * docs/Makefile.am, docs/man/Makefile.am: docs/(man/)Makefile.am: + move back to builddir all files for the built documents, not just + the target name + * docs/Makefile.am, docs/man/Makefile.am: docs/(man/)Makefile.am: + before putting back the built documents, clean up the destination + if needed and make the workdir removable if needed (a2x can copy + system/EXTRA_DIST resources with their attrs) + +2021-10-31 Jim Klimov + + * docs/Makefile.am, docs/man/Makefile.am: docs/(man/)Makefile.am: + only delete target before build if it is a directory (chunked HTML) + * docs/Makefile.am: docs/Makefile.am: update comment about + destination dir for asciidoc/a2x + * docs/man/Makefile.am: Revert "docs/man/Makefile.am: tone down the + use of "touch" for multicomponent docs" This reverts commit + 0b9ac2500ddbc7bd11a639805d43cda9259bfb1f. + * docs/Makefile.am: docs/Makefile.am: avoid potential for races where + same document is built several times (mentioned in different list + variables) + * docs/man/Makefile.am: docs/man/Makefile.am: avoid races where same + document is built several times (mentioned in different list + variables) + * docs/man/Makefile.am: Revert "docs/man/Makefile.am: avoid races + where same document is built several times (mentioned in different + list variables)" This reverts commit + 29ae5a8f6e5524d689ebaf2abdf508528288b010. + * docs/man/Makefile.am: docs/man/Makefile.am: tag DOC-MAN-HTML + visibly different from DOC-HTML of the main docs dir + * docs/man/Makefile.am: docs/man/Makefile.am: avoid races where same + document is built several times (mentioned in different list + variables) + * docs/man/Makefile.am: docs/man/Makefile.am: tone down the use of + "touch" for multicomponent docs + * docs/.gitignore, docs/Makefile.am, docs/man/.gitignore, + docs/man/Makefile.am: docs/(man/)Makefile.am: fan out doc builds + into subdirectories, where we can, so parallel runs do not collide + +2021-11-01 Jim Klimov + + * ci_build.sh: ci_build.sh: update the heading comment + +2021-10-31 Jim Klimov + + * docs/man/Makefile.am: docs/man/Makefile.am: whitespace fixes (drop + some indentation) + +2021-10-30 Jim Klimov + + * docs/Makefile.am: docs/Makefile.am: as developer aid, add + "(all-)docs" target to try building all types regardless of + enablement by configure script; also add "make man" support + +2021-10-31 Jim Klimov + + * ci_build.sh: ci_build.sh: support CI_REQUIRE_GOOD_GITIGNORE=false + to bypass fatal error on git status being not empty after build + +2021-10-30 Jim Klimov + + * tools/nut-scanner/Makefile.am: tools/nut-scanner/Makefile.am: + reference nut_version.h in a way that does not offend "make + dist(check)" + * tools/nut-scanner/Makefile.am: tools/nut-scanner/Makefile.am: + reference some out-of-dir sources via top_srcdir (not ../..) + * clients/Makefile.am, drivers/Makefile.am, server/Makefile.am, + tests/Makefile.am, tools/nut-scanner/Makefile.am: */Makefile.am: + define dependencies on out-of-dir *.la helper libs, and reference + them via top_builddir (not ..) + * common/Makefile.am: common/Makefile.am: reference nut_version.h in + a way that does not offend "make dist(check)" + * ci_build.sh: ci_build.sh: default "minimal" ritual should not spend + half the time building docs + +2021-10-04 Jim Klimov + + * drivers/nut-libfreeipmi.c: drivers/nut-libfreeipmi.c: range-check + and cast returned ipmi_dev->sensors_count + * drivers/nut-libfreeipmi.c: drivers/nut-libfreeipmi.c: + libfreeipmi_get_sensors_info(): we check that sdr_record_len is not + negative, so can cast to (uint) + * drivers/nut-libfreeipmi.c: drivers/nut-libfreeipmi.c: + libfreeipmi_get_board_info(): range-check and cast mfg_date_time + * drivers/nut-libfreeipmi.c: drivers/nut-libfreeipmi.c: + libfreeipmi_get_psu_info(): range-check and cast libfreeipmi method + arguments which are ints + * drivers/nut-libfreeipmi.c: drivers/nut-libfreeipmi.c: + libfreeipmi_get_psu_info(): range-check and cast libfreeipmi method + arguments which are uint8_t + * drivers/nut-libfreeipmi.c: drivers/nut-libfreeipmi.c: + nut_ipmi_open(): range-check and cast libfreeipmi method arguments + which are uint8_t + +2021-09-23 Jim Klimov + + * tools/nut-scanner/scan_ipmi.c: tools/nut-scanner/scan_ipmi.c: + range-check and cast ipmi_sec->authentication_type + ipmi_sec->privilege_level ipmi_id to match method signatures + +2021-10-15 Jim Klimov + + * ci_build.sh: ci_build.sh: report Build host settings + +2021-10-16 Jim Klimov + + * ci_build.sh, docs/developers.txt: ci_build.sh: add + BUILD_TYPE=fightwarn(-clang|-gcc) for presets with developer aid + Also updated docs/developers.txt with example and description + +2021-10-26 Jim Klimov + + * tests/getvaluetest.c: tests/getvaluetest.c: align test structure + with field types in HIDData_t + * tests/getvaluetest.c: tests/getvaluetest.c: fix bufsize size_t type + * tests/getvaluetest.c: tests/getvaluetest.c: mark static local + methods as such + * drivers/hidparser.c: drivers/hidparser.c: for skipping botched + LogMin/LogMax, also log a message + +2021-10-20 Stephan Blecher <_github@blecher.at> + + * drivers/hidparser.c: drivers/hidparser.c + +2021-10-22 Jim Klimov + + * autogen.sh: autogen.sh: surprise, not all systems have "dos2unix" + * configure.ac: configure.ac: fix use of --with-docs + * configure.ac: configure.ac: fix use of --with-valgrind + +2021-10-21 Jim Klimov + + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: currently constrain + cppcheck phase(s) to fightwarn-related branch/PR builds + +2021-10-20 Jim Klimov + + * .gitignore, Jenkinsfile-dynamatrix, Makefile.am, ci_build.sh, + configure.ac, docs/config-prereqs.txt, docs/nut.dict, + m4/nut_check_cppcheck.m4: Add recipe support for cppcheck analysis + * ci_build.sh: ci_build.sh: let initial DO_DISTCHECK value be set by + caller + +2021-10-20 Arnaud Quette + + * tools/nut-scanner/scan_snmp.c: Only try all OIDs if sysOID matching + failed + +2021-10-19 Jim Klimov + + * drivers/nutdrv_qx_ablerex.c, drivers/nutdrv_qx_ablerex.h: + drivers/nutdrv_qx_ablerex.{c,h}: heading fixes -- name, descr, (C) + * drivers/nutdrv_qx.c, drivers/nutdrv_qx_ablerex.c: + drivers/nutdrv_qx.c + nutdrv_qx_ablerex.c: common whitespace fixes + * drivers/Makefile.am: drivers/Makefile.am: restore bits lost with + initial posting of PR #1135 + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: update DRIVER_VERSION for + added "ablerex" support + +2021-10-18 Ablerexsoftware + + * drivers/Makefile.am, drivers/nutdrv_qx.c, + drivers/nutdrv_qx_ablerex.c, drivers/nutdrv_qx_ablerex.h: Add + nutdrv_qx driver for Ablerex model PR#2 + +2021-10-16 Jim Klimov + + * NEWS, UPGRADING, docs/nut.dict: UPGRADING: notice that upsdebugx() + et al became macros in NUT-2.7.5 + * NEWS: NEWS: another expected point for release after 2.7.5 + +2021-10-14 Jim Klimov + + * drivers/Makefile.am, drivers/snmp-ups-helpers.c, drivers/snmp- + ups.c, drivers/snmp-ups.h: Separate source files of snmp-ups.c + (driver core) and snmp-ups-helpers.c (shared mapping tables and + funcs) (#1134) * drivers/Makefile.am: bring some order into + snmp_ups_SOURCES list * drivers/snmp-ups.h: update (C) heading * + drivers/snmp-ups.h: comment that su_find*() are related to certain + info_lkp_t fields * drivers/snmp-ups.c: extract snmp-ups-helpers.c + that can be built independently * drivers/snmp-ups.h: mark the + range of data points related to Subdrivers shared helpers functions + +2021-10-12 Jim Klimov + + * drivers/powerware-mib.c, drivers/snmp-ups.c, drivers/snmp-ups.h: + drivers/snmp-ups.{h,c} + powerware-mib.c: reference date converter + by macro name instead of magic number + * drivers/snmp-ups.c, drivers/snmp-ups.h: drivers/snmp-ups.{h,c}: + rename the fun/nuf mappings to fun_vp2s/nuf_s2l to match the DMF + codebase and ease eventual backports + * drivers/snmp-ups.h: drivers/snmp-ups.h: comment the fun/nuf mapping + and their relation to su_find_*() methods + * drivers/snmp-ups.c: drivers/snmp-ups.c: clarify that we pass a + "long*" arg to su_find_infoval() + * drivers/snmp-ups.c: drivers/snmp-ups.c: typo fix + * drivers/snmp-ups.c: drivers/snmp-ups.c: clarify in decode_str() + that we pass a "long*" arg to su_find_infoval() + * drivers/snmp-ups.c, drivers/snmp-ups.h: drivers/snmp-ups.{c,h}: + rearrange braces, blank lines and some comments to match the + formatting fixes in DMF branch (and to simplify eventual backport) + * drivers/snmp-ups.c: drivers/snmp-ups.c: rearrange mib2nut[] in + alphabetic order (except *ietf tables that go last) and reference + mib.c sources + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: fix + whitespace (indent) + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: fix regex pattern + for dynacfgPipeline.appliesToChangedFilesRegex_FILES_PY + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: parameterize + dynacfgPipeline.axisCombos* and excludeCombos_DEFAULT_* for + repetitive settings + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: parameterize + dynacfgPipeline.branchStableRegex + * docs/ci-farm-lxc-setup.txt: docs/ci-farm-lxc-setup.txt: extend + sample capability labels with PYTHON variants + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: update for Python- + version build scenarios + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: add + dynacfgPipeline.appliesToChangedFilesRegex_FILES_PY for future + handling + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: update + dynacfgPipeline.appliesToChangedFilesRegex_FILES_RECIPE to consider + changes of autogen.sh + * tools/nut-scanner/nutscan-serial.c: tools/nut-scanner/nutscan- + serial.c: fix whitespace style + * tools/nut-scanner/nutscan-ip.c: tools/nut-scanner/nutscan-ip.c: fix + whitespace style + +2021-10-11 Jim Klimov + + * tools/nut-scanner/nutscan-device.c: tools/nut-scanner/nutscan- + device.c: fix whitespace style + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: fix + whitespace style + * tools/nut-scanner/scan_avahi.c: tools/nut-scanner/scan_avahi.c: fix + whitespace style + * tools/nut-scanner/scan_ipmi.c: tools/nut-scanner/scan_ipmi.c: fix + whitespace style + * tools/nut-scanner/nutscan-serial.c: tools/nut-scanner/nutscan- + serial.c: fix whitespace style + * tools/nut-scanner/nutscan-ip.c: tools/nut-scanner/nutscan-ip.c: fix + whitespace style + * tools/nut-scanner/scan_xml_http.c: tools/nut- + scanner/scan_xml_http.c: fix whitespace style + * tools/nut-scanner/scan_eaton_serial.c: tools/nut- + scanner/scan_eaton_serial.c: fix whitespace style + * tools/nut-scanner/nutscan-device.h: tools/nut-scanner/nutscan- + device.h: fix whitespace style + * tools/nut-scanner/scan_usb.c: tools/nut-scanner/scan_usb.c: fix + whitespace style + * tools/nut-scanner/scan_nut.c: tools/nut-scanner/scan_nut.c: fix + whitespace style + * tools/nut-snmpinfo.py.in: tools/nut-snmpinfo.py.in: fix whitespace + style of generated header + * tools/nut-snmpinfo.py.in: tools/nut-snmpinfo.py.in: fix heading of + generated header + +2021-09-28 Jim Klimov + + * drivers/microdowell.h: drivers/microdowell.h: normalize whitespace + within the file + * drivers/microsol-apc.h: drivers/microsol-apc.h: whitespace fix + +2021-09-23 Jim Klimov + + * drivers/bcmxcp.c: drivers/bcmxcp.c: fix whitespace style + * drivers/bcmxcp_ser.c: drivers/bcmxcp_ser.c: fix whitespace style + * tools/nut-scanner/scan_avahi.c: tools/nut-scanner/scan_avahi.c: fix + whitespace style + +2021-09-22 Jim Klimov + + * tests/cpputest.cpp: tests/cpputest.cpp: avoid "no out-of-line + virtual method definitions" (weak-vtables) + * tests/nutclienttest.cpp: tests/nutclienttest.h: avoid "unused + exception parameter ex" + * clients/nutclientmem.h: clients/nutclientmem.h: avoid "extra ; + after method" warnings + +2021-10-11 Jim Klimov + + * docs/Makefile.am, docs/man/Makefile.am: docs{,/man}/Makefile.am: + quiesce docs-generating targets by default to just state what they + make + * docs/nut.dict: Update spellchecker dict + +2021-10-09 Jim Klimov + + * ci_build.sh: ci_build.sh: add support for CI agents setting + NUT_BUILD_CAPS=valgrind=no + * Makefile.am: Makefile.am: `make spellcheck` from top dir should be + quieter (fallout from touchfiles) + * docs/ci-farm-lxc-setup.txt: docs/ci-farm-lxc-setup.txt: stress to + `systemctl restart lxc-net` after edits of /etc/lxc/dnsmasq- + hosts.conf + * docs/ci-farm-lxc-setup.txt, docs/nut.dict: docs/ci-farm-lxc- + setup.txt: stress that for CI_WRAP_SH method, the Prefix Start + Agent Commandshould not pollute stderr/stdout + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: report more details + about the build host when we "Inspect initial envvars" + +2021-10-08 Jim Klimov + + * scripts/subdriver/gen-snmp-subdriver.sh: gen-snmp-subdriver.sh: + deprecate "which" in favor of "command -v" + * ci_build.sh: ci_build.sh: deprecate "which" in favor of "command + -v" + +2021-10-07 Jim Klimov + + * m4/nut_check_python.m4: m4/nut_check_python.m4: export PYTHON(2,3) + envvars for other scripts called in the build + +2021-09-28 Jim Klimov + + * .gitignore: GitIgnore the tmp/ subdirectory used by CI builds + * .gitignore: GitIgnore Python precompiled files + +2021-09-27 Jim Klimov + + * configure.ac: configure.ac: split generation of "data" files vs. + "scripts" from *.in templates + * configure.ac: Update python scripts to be generated by configure + and using the detected PYTHON value + * clients/nutclient.h: clients/nutclient.h: whitespace typo fix + * docs/developers.txt: docs/developers.txt: fix reference to Fosshost + to be an URL + +2021-09-26 Jim Klimov + + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: for a non-PR build + of a fightwarn* branch, reference 'fightwarn' for analysis + +2021-09-23 Jim Klimov + + * tools/nut-usbinfo.pl: tools/nut-usbinfo.pl => generated nutscan- + usb.h: sentinel in a table of uint16_t can not be -1 + +2021-09-22 Jim Klimov + + * clients/upsclient.c, configure.ac: clients/upsclient.c + + configure.ac: fix use of CPU_TYPE + * configure.ac: configure.ac: add "-Wno-cast-qual" to clang-medium + and clang-hard warnings levels + +2021-10-05 Jim Klimov + + * docs/nut.dict: Update spellchecker + * NEWS: NEWS: added FTTx support and other genericups improvenets for + NUT-2.7.5 + +2021-10-05 Jim Klimov + + * configure.ac: configure.ac: more AC_CHECK_HEADERS_ONCE + * ci_build.sh: ci_build.sh: for default mode (no BUILD_TYPE) enable + cgi and dev files (no=>auto) and do not require serial drivers + (yes=>auto) + * m4/nut_type_socklen_t.m4: m4/nut_type_socklen_t.m4: fix detection + on windows Probably practical codebase should also account for + other arg types, e.g. "SOCKET" that is not even exported into a + macro so far. + * ci_build.sh: ci_build.sh: report CI_OS_NAME detection issues more + clearly It is not helpful to read just this: Could not recognize + ... from ''-'' + +2021-10-05 Jim Klimov + + * autogen.sh: autogen.sh: suggest CRLF fixes for the workspace (e.g. + if checked out on Windows) This falls a bit short of enforcing + with .gitattributes which may or may not interfere with platform- + native editors and other tools. + +2021-10-04 Jim Klimov + + * conf/Makefile.am, docs/man/Makefile.am: conf/Makefile.am, + docs/man/Makefile.am: avoid prerequisites on suffix rules + * drivers/apc-mib.c: drivers/apc-mib.c: bump APCC_MIB_VERSION for PR + #1113 + * docs/man/genericups.txt, drivers/genericups.c: genericups: + officially alias "NULL" and "none" setting keywords + +2021-10-04 Jim Klimov + + * docs/ci-farm-lxc-setup.txt, docs/nut.dict: docs/ci-farm-lxc- + setup.txt: recommend a unique Remote root directory per agent + +2021-10-04 Jim Klimov + + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: extend QEMU build + scenarios to "ssh-qemu-nut-builder" agents, and to iterate + "COMPILER" toolkits for cross-check on same platform + +2021-10-04 Jim Klimov + + * docs/config-prereqs.txt: docs/config-prereqs.txt: Debianish systems + tend to deliver g++ in a separate package from gcc + * docs/ci-farm-lxc-setup.txt, docs/nut.dict: docs/ci-farm-lxc- + setup.txt: add a chapter on Jenkins Build Agent setup for the + containers + +2021-10-03 Jim Klimov + + * docs/nut.dict: Update spellchecker + * docs/ci-farm-lxc-setup.txt: docs/ci-farm-lxc-setup.txt: document + making a self-login ssh key for abuild + * docs/ci-farm-lxc-setup.txt: docs/ci-farm-lxc-setup.txt: document + allowing container SSH server to accept envvars from client + +2021-10-03 Jim Klimov + + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: Typo fix: remove + extra unstashCleanSrc() for ci_build.sh preparations + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: allow limited use + of QEMU containers as build agents (slow workers => few combos) + +2021-10-02 Jim Klimov + + * configure.ac: configure.ac: quiesce the check for usable valgrind + binary + * docs/nut.dict: Update spellchecker + * configure.ac: configure.ac: adapt warnings level (auto, minimal) + for GCC with c89/c90/ansi requested builds + * tests/getvaluetest.c: tests/getvaluetest.c: fix declaration of + variables in code body, and type of sizeof-derived iterator + * tests/getvaluetest.c: tests/getvaluetest.c: normalize whitespace to + NUT style + * tests/getvaluetest.c: tests/getvaluetest.c: add (C) and descriptive + heading + +2021-10-02 Jim Klimov + + * configure.ac: configure.ac: test if valgrind is actually usable on + build/check ssytem + * docs/ci-farm-lxc-setup.txt: docs/ci-farm-lxc-setup.txt: fix + extraction of hosts-map data + * docs/ci-farm-lxc-setup.txt: docs/ci-farm-lxc-setup.txt: make note + of lxc-create for other distros + * docs/ci-farm-lxc-setup.txt: docs/ci-farm-lxc-setup.txt: add git to + early starter-kit of packages + +2021-09-30 Jim Klimov + + * Jenkinsfile-dynamatrix, docs/developers.txt: Jenkinsfile-dynamatrix + + developers.txt: for "GNU C89 standard builds with fatal + warnings", only run with a `fightwarn.*89.*` regex branch name; do + not pollute logs and analysis of "usual fightwarn" builds + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: for "GNU C standard + builds with non-fatal warnings, without distcheck and docs (must + pass)" slowBuild scenario, start with a "gnu89/gnu++98" non- + regression variant + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: reword some + slowBuild filter config descriptions and comments + * docs/developers.txt, docs/nut.dict: docs/developers.txt: extend the + description of NUT CI setup Clarification of adaptive jobs, + running different sets of scenarios, and how to reproduce a failed + test case locally. Also updated spellchecker dictionary. + * docs/developers.txt: docs/developers.txt: stress likely + incompatibility with stricter C89/GNU89/ANSI-C standard, so C99 + (GNU99) is the baseline + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: rearrange for + readability (line-split allowedFailure and excludeCombos blocks + that have many combos inside) + +2021-09-30 Jim Klimov + + * .lgtm.yml: .lgtm.yml: drop redundant lines + * autogen.sh: autogen.sh: whitespace fix + * autogen.sh, configure.ac, scripts/systemd/Makefile.am: nut- + common.tmpfiles.in: fix systemd magic vs autoconf magic Follows up + from PR #1037 for issue #1030 to let the trick work for distcheck + and similar out-of-tree builds. + +2021-09-27 Jim Klimov + + * .lgtm.yml: Add .lgtm.yml to specify search for python template + files * Index *.py.in + scripts/python/app/NUT-Monitor.in * Do not + consider them templates to ignore * Also turn off the FIXME alerts, + NUT has a lot of those so far + * NEWS: NEWS: updated the python 2+3 compatibility notice + * Makefile.am: Makefile.am: call the generated gitlog2changelog.py + from correct path + * scripts/augeas/Makefile.am, tools/Makefile.am: Fix "dist" targets + to call templates gen-nutupsconf-aug.py.in and nut-snmpinfo.py.in + that they have + * scripts/python/module/PyNUT.py.in, + scripts/python/module/test_nutclient.py.in: + scripts/python/module/PyNUT.py.in: update syntax for Python 3 (also + ok for 2.7) + * .gitignore: GitIgnore possible leftovers from interrupted configure + script run + * scripts/Solaris/.gitignore, scripts/augeas/.gitignore, + scripts/python/app/.gitignore, scripts/python/module/.gitignore, + tools/.gitignore: GitIgnore generated python scripts + * scripts/augeas/Makefile.am: scripts/augeas/Makefile.am: comment + where gen-nutupsconf-aug.py comes from + * autogen.sh: autogen.sh: simplify call of gen-nutupsconf-aug.py.in + in the subdir + * autogen.sh: autogen.sh: use gen-nutupsconf-aug.py.in with the + $PYTHON interpreter + * ci_build.sh: ci_build.sh: pass $PYTHON envvar -t configure --with- + python=... arg + * configure.ac: configure.ac: split generation of "data" files vs. + "scripts" from *.in templates + * configure.ac, scripts/Solaris/Makefile.am, + scripts/Solaris/{precheck.py => precheck.py.in}, + scripts/augeas/Makefile.am, .../{gen-nutupsconf-aug.py => gen- + nutupsconf-aug.py.in}, scripts/python/Makefile.am, + scripts/python/app/{NUT-Monitor => NUT-Monitor.in}, + scripts/python/module/{PyNUT.py => PyNUT.py.in}, + .../module/{test_nutclient.py => test_nutclient.py.in}, + tools/Makefile.am, tools/{gitlog2changelog.py => + gitlog2changelog.py.in}, tools/{nut-snmpinfo.py => nut- + snmpinfo.py.in}: Update python scripts to be generated by configure + and using the detected PYTHON value + * configure.ac, m4/nut_check_python.m4: configure.ac: detect PYTHON, + PYTHON2, PYTHON3 implementations in the build environment + * autogen.sh: autogen.sh: find various python versions if not + specified by $PYTHON + * clients/nutclient.h: clients/nutclient.h: whitespace typo fix + * docs/developers.txt: docs/developers.txt: fix reference to Fosshost + to be an URL + * NEWS: NEWS: expect a few more milestones for 2.7.6 (or later) + release + * UPGRADING: UPGRADING: mention protocol changes due to new TRACKING + ability + * NEWS, UPGRADING: NEWS + UPGRADING: Warn about API changes due to + fightwarn + +2021-09-26 Mark Dietzer + + * drivers/apc-mib.c: Add active power and apparent power from APC + MIBs for single-phase UPS devices + +2021-09-25 Jim Klimov + + * docs/developers.txt, docs/nut.dict: docs/developers.txt: replace + references to defunct Travis CI with new NUT CI farm [#869] + * docs/nut-qa.txt, docs/nut.dict: docs/nut-qa.txt: replace references + to defunct Travis CI with new NUT CI farm [#869] + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: with customized + shellcheck dynamatrixAxesLabels, be sure to match both OS_FAMILY + and OS_DISTRO as a bundle + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: with + docs+distcheck, also test compliance with available Make + interpreters + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: with shellcheck, + also test available Make interpreters + * Makefile.am, configure.ac, include/Makefile.am: configure.ac + + {./,include/}Makefile.am: revise the recipe for + include/nut_version.h + * docs/nut.dict: docs/nut.dict: update dict + * ci_build.sh: ci_build.sh: call "$MAKE -j NUM" with a space, to + cater for make implems that require a separate argument token + +2021-09-23 Jim Klimov + + * m4/nut_func_getnameinfo_argtypes.m4: + m4/nut_func_getnameinfo_argtypes.m4: reorder the loop to first try + current X/Open definition of getnameinfo() + * configure.ac, m4/nut_check_headers_windows.m4, + m4/nut_func_getnameinfo_argtypes.m4: + m4/nut_func_getnameinfo_argtypes.m4 + m4/nut_check_headers_windows.m4: lift recipes from cURL to detect + NUT_FUNC_GETNAMEINFO_ARGTYPES + +2021-09-22 Jim Klimov + + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: introduce + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_COMPARE and HAVE_PRAGMA_GCC + _DIAGNOSTIC_IGNORED_TAUTOLOGICAL_UNSIGNED_ZERO_COMPARE Sometimes + library/system provided types are beyond our control and vary from + OS to OS... + +2021-09-23 Jim Klimov + + * tools/nut-scanner/scan_xml_http.c: tools/nut- + scanner/scan_xml_http.c: fix whitespace style + * tools/nut-scanner/scan_usb.c: tools/nut-scanner/scan_usb.c: fix + whitespace style + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: fix + whitespace style + * tools/nut-scanner/scan_nut.c: tools/nut-scanner/scan_nut.c: fix + whitespace style + * tools/nut-scanner/scan_ipmi.c: tools/nut-scanner/scan_ipmi.c: fix + whitespace style + * tools/nut-scanner/scan_eaton_serial.c: tools/nut- + scanner/scan_eaton_serial.c: fix whitespace style + * tools/nut-scanner/scan_avahi.c: tools/nut-scanner/scan_avahi.c: fix + whitespace style + * tools/nut-scanner/nutscan-serial.c: tools/nut-scanner/nutscan- + serial.c: fix whitespace style + * tools/nut-scanner/nutscan-ip.c, tools/nut-scanner/nutscan-ip.h: + tools/nut-scanner/nutscan-ip.c: fix whitespace style + * tools/nut-scanner/nutscan-init.c: tools/nut-scanner/nutscan-init.c: + fix whitespace style + * tools/nut-scanner/nutscan-device.c, tools/nut-scanner/nutscan- + device.h: tools/nut-scanner/nutscan-device.[c,h]: fix whitespace + style + * tools/nut-scanner/nutscan-display.c: tools/nut-scanner/nutscan- + display.c: fix whitespace style + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + fix whitespace style + * tools/nut-scanner/nut-scan.h: tools/nut-scanner/nut-scan.h: fix + whitespace style + +2021-09-22 Jim Klimov + + * server/sstate.c: server/sstate.c: whitespace fix + +2021-09-23 Jim Klimov + + * ci_build.sh: ci_build.sh: warn that a build without BUILD_TYPE + ignores BUILD_WARNOPT and BUILD_WARNFATAL settings + +2021-09-22 Jim Klimov + + * tests/Makefile.am: tests/Makefile.am: comment a TODO for + referencing helpers built in other dirs + +2021-09-22 Yifeng Li + + * docs/nut.dict: nut.dict: add my name "Yifeng". + * docs/nut.dict: nut.dict: add technical terms for UPS2000 man page. + * docs/man/Makefile.am, docs/man/huawei-ups2000.txt: huawei-ups2000: + add documentation. + * drivers/Makefile.am, drivers/huawei-ups2000.c: huawei-ups2000: + Modbus driver for Huawei UPS2000 (1kVA-3kVA) This commit + implements a Modbus driver for Huawei UPS2000 (1kVA-3kVA) series + UPS units using the USB or RS-232 interface (USB is only support on + Linux 5.12+ via the "xr_serial" kernel module), with support for + power and battery status monitoring, alarm reporting, RW variables, + and instant commands for battery selftest, buzzer, shutdown, + restart, and bypass control. + +2021-09-23 Jim Klimov + + * drivers/generic_modbus.c: drivers/generic_modbus.c: fix assignments + of sigar[].type to enum + * drivers/generic_modbus.c: drivers/generic_modbus.{c,h}: fix + ser_parity to char, and sanity-check before dereferencing + * drivers/generic_modbus.c: drivers/generic_modbus.c: fix switch{} + warnings + * drivers/generic_modbus.c: drivers/generic_modbus.c: fix suseconds_t + for time ranges + * drivers/generic_modbus.c: drivers/generic_modbus.c: fix warnings + with declarations + * drivers/generic_modbus.c, drivers/generic_modbus.h: + drivers/generic_modbus.{c,h}: fix whitespace style + * NEWS: NEWS: added tripplite ability to manage outlet groups for + NUT-2.7.5 + +2021-09-23 Jim Klimov + + * docs/nut.dict: Update nut.dict + +2021-09-22 Jim Klimov + + * docs/nut.dict: docs/nut.dict: updated for recent NEWS and UPGRADING + * UPGRADING: UPGRADING: clarified upsdebugx() `[D#]` prefix impact + * UPGRADING: UPGRADING: stress that new Qx protocol drivers should be + developed in common nutdrv_qx framework + * UPGRADING: UPGRADING: Cut-off features that did land into master + branch to become the 2.7.5 release, vs. big chunks planned now for + later releases + * NEWS: NEWS: update reference to ChangeLog file vs. Git history + * NEWS: NEWS: refactored upsdebugx() and friends as macros for + NUT-2.7.5 + * NEWS: NEWS: HCL updated with Ippon Back Comfo Pro II 650/850/1050 + (USB) for NUT-2.7.5 + * NEWS: NEWS: added and clarified many battery.* protocol variables + for NUT-2.7.5 + * NEWS: NEWS: netxml-ups battery info fixed for NUT-2.7.5 + * NEWS: NEWS: HCL updated with Opti-UPS PS1500E (USB) for NUT-2.7.5 + * NEWS: NEWS: referenced Date and Time representations preferred for + NUT-2.7.5 + * NEWS: NEWS: added generic_modbus driver for NUT-2.7.5 + * NEWS: NEWS: updated systemd integration for NUT-2.7.5 + * NEWS: NEWS: added autoconf-2.70 update for NUT-2.7.5 + * NEWS: NEWS: added portable Makefile effort for NUT-2.7.5 + * NEWS: NEWS: added incremental "make spellcheck" support for + NUT-2.7.5 + * NEWS: NEWS: Cut-off features that did land into master branch to + become the 2.7.5 release, vs. big chunks planned now for later + releases + * NEWS: NEWS: added DISABLE_WEAK_SSL for NUT-2.7.5 + +2021-06-30 Jim Klimov + + * NEWS: NEWS: mention `experimental.*` namespace + * NEWS: NEWS: mention that master/slave deprecation did not impact + protocol currently + * NEWS: NEWS: mark libusb-1.0 support in main branch as "expected" + currently + +2021-05-24 Jim Klimov + + * NEWS: NEWS: added powerpanel driver support for CyberPower + OR1500LCDRTXL2U in NUT-2.7.5 + * NEWS: NEWS: added TcpClient C++ testing mock for NUT-2.7.5 + * NEWS: NEWS: improved USB HID parsing for NUT-2.7.5 + * NEWS: NEWS: improved USB device matching for NUT-2.7.5 + * NEWS: NEWS: microsol-apc added for NUT-2.7.5 + +2021-04-23 Jim Klimov + + * NEWS, docs/nut.dict: docs/nut.dict + NEWS: fix both to pass + spellcheck + +2021-04-21 Jim Klimov + + * NEWS: NEWS: Add 2.7.5 support for Tripplite AVR750U + +2021-04-20 Jim Klimov + + * NEWS: NEWS: List more achievements of 2.7.5 + +2020-01-20 Jim Klimov + + * NEWS: NEWS: described nut-driver-enumerator introduction + +2019-03-15 Arnaud Quette + + * NEWS: Add entry for openssl-1.1.0 support + +2019-03-13 Arnaud Quette + + * docs/nut.dict: Update spelling dictionary + +2019-02-28 Arnaud Quette + + * NEWS: Update NEWS for next release + +2018-02-28 Arnaud Quette + + * docs/nut.dict: Add Avocent to the spell check list + +2018-02-27 Arnaud Quette + + * NEWS: Update NEWS for Emerson Avocent PM3000 PDU + +2017-11-17 Arnaud Quette + + * NEWS: Update NEWS for next release + * NEWS: Update NEWS for next release + +2017-10-08 Charles Lepple + + * NEWS, UPGRADING, docs/nut.dict: Spell-check release notes + * NEWS, UPGRADING: Update NEWS and UPGRADING for next release + Current as of master @ b8df06b761, assuming libusb-1.0+0.1 gets + merged + +2021-09-22 Jim Klimov + + * docs/config-prereqs.txt: docs/config-prereqs.txt: cosmetically + update OmniOS notes + * docs/ci-farm-lxc-setup.txt: docs/ci-farm-lxc-setup.txt: comment a + TODO for NAT setup desired + * docs/ci-farm-lxc-setup.txt: docs/ci-farm-lxc-setup.txt: comment why + LXC+LIBVIRT + * docs/ci-farm-lxc-setup.txt, docs/config-prereqs.txt, docs/user- + manual.txt: docs/config-prereq.txt + ci-farm-lxc-setup.txt + user- + manual.txt: fix markup so new docs can be chapters in user- + manual.html + +2021-09-21 Jim Klimov + + * scripts/Solaris/postinstall.in, scripts/Solaris/preremove.in: + scripts/Solaris/preremove.in + postinstall.in: configure sanity + checker likes datarootdir more than datadir + * ci_build.sh: ci_build.sh: fix reported BUILD_TYPE for default- + spellcheck builds + +2021-09-21 Jim Klimov + + * docs/Makefile.am: docs/Makefile.am: try to avoid "warning: ignoring + prerequisites on suffix rule definition" + * docs/Makefile.am: docs/Makefile.am: when calling a sub-make for + *-spellchecked rule, make sure to use the + "$(abs_top_builddir)/docs/Makefile" (the original "top_builddir" + might come from outer caller in another subdir) + * docs/Makefile.am: docs/Makefile.am: move reading of the + spellchecked file out of the pipe so errors finding one are exposed + to build result + * conf/Makefile.am, data/Makefile.am, docs/Makefile.am, + docs/man/Makefile.am: docs/Makefile.am: conjure a portable + *-spellchecked rule that works for non-GNU make tools + * docs/Makefile.am: docs/Makefile.am: comment about a non-portable + GNU Make feature use + * docs/Makefile.am: docs/Makefile.am: for no-op *-spellchecked rule, + report SKIP-ASPELL with the target (touchfile) name to avoid + source-text determination + * docs/Makefile.am: docs/Makefile.am: be sure to run the quiet sub- + make using docs/Makefile.am to use its target definitions + * docs/Makefile.am: docs/Makefile.am: if SPELLCHECK_ENV_DEBUG, report + which file we would spellcheck (quiet sub-make might do and report + nothing for an already checked text) + * docs/Makefile.am: docs/Makefile.am: consider "-spellchecked" among + SUFFIXes + * docs/Makefile.am: docs/Makefile.am: comment about a non-portable + GNU Make feature use + +2021-09-21 Jim Klimov + + * .gitignore, Makefile.am, conf/Makefile.am, data/Makefile.am, + docs/Makefile.am, docs/cables/Makefile.am, docs/man/Makefile.am, + lib/Makefile.am, scripts/augeas/Makefile.am, + scripts/ufw/Makefile.am, tools/nut-scanner/Makefile.am: Makefiles: + change from *.spellchecked suffix pattern to *-spellchecked which + is easier to plug into POSIX make rulesets + * Makefile.am, conf/Makefile.am, configure.ac, data/Makefile.am, + docs/Makefile.am, docs/cables/Makefile.am, docs/man/Makefile.am, + lib/Makefile.am, scripts/Makefile.am, scripts/augeas/Makefile.am, + scripts/ufw/Makefile.am, tools/nut-scanner/Makefile.am: Makefiles + + configure.ac: add a way to "make clean" away the *.spellchecked + touch-files + * .gitignore, conf/Makefile.am, data/Makefile.am, docs/Makefile.am, + docs/man/Makefile.am: Makefiles: mark every spellchecked text file + with a touch-file to not re-test it again needlessly (at a cost of + some noise for some implementations of make) + +2021-09-21 Jim Klimov + + * drivers/legrand-hid.c: Update legrand-hid.c Address build warnings + from CI + +2021-09-21 Jim Klimov + + * scripts/Solaris/postinstall.in, scripts/Solaris/preremove.in: + scripts/Solaris/preremove.in + postinstall.in: configure sanity + checker likes datarootdir more than datadir + * ci_build.sh: ci_build.sh: fix reported BUILD_TYPE for default- + spellcheck builds + +2021-09-21 Jim Klimov + + * docs/Makefile.am: docs/Makefile.am: try to avoid "warning: ignoring + prerequisites on suffix rule definition" + * docs/Makefile.am: docs/Makefile.am: when calling a sub-make for + *-spellchecked rule, make sure to use the + "$(abs_top_builddir)/docs/Makefile" (the original "top_builddir" + might come from outer caller in another subdir) + * docs/Makefile.am: docs/Makefile.am: move reading of the + spellchecked file out of the pipe so errors finding one are exposed + to build result + * conf/Makefile.am, data/Makefile.am, docs/Makefile.am, + docs/man/Makefile.am: docs/Makefile.am: conjure a portable + *-spellchecked rule that works for non-GNU make tools + * docs/Makefile.am: docs/Makefile.am: comment about a non-portable + GNU Make feature use + * docs/Makefile.am: docs/Makefile.am: for no-op *-spellchecked rule, + report SKIP-ASPELL with the target (touchfile) name to avoid + source-text determination + * docs/Makefile.am: docs/Makefile.am: be sure to run the quiet sub- + make using docs/Makefile.am to use its target definitions + * docs/Makefile.am: docs/Makefile.am: if SPELLCHECK_ENV_DEBUG, report + which file we would spellcheck (quiet sub-make might do and report + nothing for an already checked text) + * docs/Makefile.am: docs/Makefile.am: consider "-spellchecked" among + SUFFIXes + * docs/Makefile.am: docs/Makefile.am: comment about a non-portable + GNU Make feature use + +2021-09-21 Jim Klimov + + * .gitignore, Makefile.am, conf/Makefile.am, data/Makefile.am, + docs/Makefile.am, docs/cables/Makefile.am, docs/man/Makefile.am, + lib/Makefile.am, scripts/augeas/Makefile.am, + scripts/ufw/Makefile.am, tools/nut-scanner/Makefile.am: Makefiles: + change from *.spellchecked suffix pattern to *-spellchecked which + is easier to plug into POSIX make rulesets + * Makefile.am, conf/Makefile.am, configure.ac, data/Makefile.am, + docs/Makefile.am, docs/cables/Makefile.am, docs/man/Makefile.am, + lib/Makefile.am, scripts/Makefile.am, scripts/augeas/Makefile.am, + scripts/ufw/Makefile.am, tools/nut-scanner/Makefile.am: Makefiles + + configure.ac: add a way to "make clean" away the *.spellchecked + touch-files + * .gitignore, conf/Makefile.am, data/Makefile.am, docs/Makefile.am, + docs/man/Makefile.am: Makefiles: mark every spellchecked text file + with a touch-file to not re-test it again needlessly (at a cost of + some noise for some implementations of make) + * docs/nut.dict: docs/nut.dict: update for recent changes + * docs/man/apcsmart.txt, docs/man/generic_modbus.txt: + docs/man/apcsmart.txt: fix an indented block + * docs/man/apcsmart.txt, docs/man/generic_modbus.txt: + docs/man/generic_modbus.txt + apcsmart.txt: drop "[source, conf]" + decorators for sample configs and ASCII-art, pygmentize needs much + setup to render that + * docs/config-prereqs.txt: docs/config-prereqs.txt: add "pygmentize" + packages to the list, for HTML rendering of "source" blocks + * docs/man/generic_modbus.txt: docs/man/generic_modbus.txt: import a + note from discussion at NUT issue #1056 about the data-path and + generic use for the modbus driver + * docs/man/generic_modbus.txt: docs/man/generic_modbus.txt: line-wrap + long paragraphs + * tests/nutlogtest.c: tests/nutlogtest.c: fix more fallout from #675 + * configure.ac, m4/nut_check_libnss.m4: m4/nut_check_libnss.m4: fix + deterministic 32/64 bit builds (on illumos/solaris family of OSes + at least) + * ci_build.sh: ci_build.sh: tweak PKG_CONFIG_PATH setting for 64-bit + dirs on illumos/solaris and related operating systems (otherwise + pkg-config reports default data, can be for 32-bit libs, on 64-bit + hosts) + * ci_build.sh: ci_build.sh: report detected CI_OS_NAME if we had to + guess + * ci_build.sh: ci_build.sh: for developer workstation use, detect + CI_OS_NAME via uname as a fallback (if CI vars are not provided) + * ci_build.sh: ci_build.sh: recognize CI_OS_NAME from case- + insensitive match of "$OS_FAMILY-$OS_DISTRO", and recognize + solaris+sunos + * include/common.h: Fix some fallout from PR #685 * The + parenthesized "(label)" in debug macros is a safer expansion than + the original "label" * Avoid the dangling "args..." that may be + not-specified by caller (strict-C99 compat) + * docs/Makefile.am: docs/Makefile.am: do not spellcheck ../INSTALL + which is generated + * ci_build.sh: ci_build.sh: run the first spellcheck really quietly + * docs/Makefile.am, docs/nut.dict: docs/Makefile.am + docs/nut.dict: + add more texts from base dir to spellcheck them too + * docs/Makefile.am: docs/Makefile.am: report the directory relative + to which spellchecked text sources failed + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: use ci_build.sh to + spellcheck with a more user-friendly output + * ci_build.sh: ci_build.sh: extend the BUILD_TYPE=default-spellcheck + to do a quiet round first, and only report details about failed + files if needed + * ci_build.sh: ci_build.sh: fallback BUILD_WARNFATAL=true/false + handling; comment values for BUILD_WARNOPT + +2021-09-20 Jim Klimov + + * docs/nut.dict: docs/nut.dict: update for recently added docs and + merged PRs, and update sorting + * docs/config-prereqs.txt: config-prereqs.txt: fix markup to become + asciidoc + +2021-09-20 Jim Klimov + + * docs/Makefile.am, docs/ci-farm-lxc-setup.txt: docs/ci-farm-lxc- + setup.txt + docs/Makefile.am: update some notes and ability to + build the new doc + +2021-09-20 Jim Klimov + + * docs/ci-farm-lxc-setup.txt: ci-farm-lxc-setup.txt: update with + notes for "chroot apt-get" tricks + * docs/ci-farm-lxc-setup.txt: ci-farm-lxc-setup.txt: fix markup to + become asciidoc + +2021-09-21 Jim Klimov + + * docs/man/generic_modbus.txt: docs/man/generic_modbus.txt: some + whitespace issues + * m4/nut_type_socklen_t.m4: [NUT issue #1053] + m4/nut_type_socklen_t.m4: convert one remaining + AC_TRY_COMPILE(H,M,S) into modern + AC_COMPILE_IFELSE(AC_LANG_PROGRAM(H,M), S) + * configure.ac: [NUT issue #1053] configure.ac: apply recommendations + of "autoupdate" and warnings from "autoconf" for autotools-2.70 + +2021-09-20 Jim Klimov + + * docs/config-prereqs.txt: config-prereqs.txt: fix markup to become + asciidoc + * tests/.gitignore: GitIgnore test log and trace for "nutlogtest" + +2021-09-20 Jim Klimov + + * docs/Makefile.am, docs/ci-farm-lxc-setup.txt: docs/ci-farm-lxc- + setup.txt + docs/Makefile.am: update some notes and ability to + build the new doc + +2021-09-20 Jim Klimov + + * docs/nut.dict: docs/nut.dict: ordering and typo fixes in the + dictionary :) + * docs/ci-farm-lxc-setup.txt: ci-farm-lxc-setup.txt: update with + notes for "chroot apt-get" tricks + +2021-09-19 Jim Klimov + + * docs/nut-names.txt: docs/nut-names.txt: refactor the standalone + Time and Date format chapter + +2021-09-20 Jim Klimov + + * docs/ci-farm-lxc-setup.txt: ci-farm-lxc-setup.txt: fix markup to + become asciidoc + +2021-09-19 Jim Klimov + + * docs/ci-farm-lxc-setup.txt: Introduce docs/ci-farm-lxc-setup.txt + with setup notes + * docs/ci-farm-lxc-setup.txt: Introduce docs/ci-farm-lxc-setup.txt + with setup notes + +2021-09-17 Jim Klimov + + * Jenkinsfile-dynamatrix: Update Jenkinsfile-dynamatrix Revise + pattern for Makefiles and similar + * Jenkinsfile-dynamatrix: Update Jenkinsfile-dynamatrix Do not apply + filename regex filtering to main branch builds so they can always + serve as a reference + * Jenkinsfile-dynamatrix: Update Jenkinsfile-dynamatrix Remove + 'default' target as it brings little value: default-tgt:distcheck- + valgrind tests the distcheck part, and default-nodoc tests the main + recipe with default settings and no distcheck (both skip/disable + docs). + +2021-09-17 Jim Klimov + + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: modularize the way + to constrain build scenarios not relevant to the changed files + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: find a way to + constrain build scenarios not relevant to the changed files (e.g. + no big rebuilds for a docs-only change) + +2021-09-16 Jim Klimov + + * docs/nut.dict: Update nut.dict + * docs/nut.dict: Update nut.dict + * docs/nut-names.txt: Update nut-names.txt Clarified an ambiguity + typo about time format, added examples for data with time zones + +2021-09-16 dtsecon + + * drivers/generic_modbus.c: change ulon to uint_32 + * drivers/generic_modbus.h: fix forward declarations of enum + occurances + +2021-09-15 Jim Klimov + + * docs/nut.dict: Update nut.dict Update for PR #1076 + * docs/nut.dict: Update nut.dict Add "FTTx" for PR #1061 + * tests/getvaluetest.c: Update getvaluetest.c Include NUT "common.h" + for NUT_UNUSED_VARIABLE among other things + * tests/getvaluetest.c: getvaluetest.c: Fixing a NUT_UNUSED_VARIABLE + +2021-09-15 Jim Klimov + + * clients/upsclient.c: upsclient.c: log upscli_init() as a no-op in + case of builds without SSL + * clients/upsclient.c: upsclient.c: add NUT_UNUSED_VARIABLE for the + stub implem in case of builds without SSL + * server/netssl.c: netssl.c: add NUT_UNUSED_VARIABLE for the stub + implem in case of builds without SSL + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: limit default- + withdoc(:man) scenarios to not iterate compiler variants, only OSes + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: add a comment with + overview of the dynacfgPipeline.slowBuild goals and trade-offs + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: add a groovy + shebang for highlighters + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: rephrase some + comments and filter bundle names + +2021-09-14 dtsecon + + * docs/nut.dict: update nut.dict + * docs/nut.dict: update nut.dic + +2021-09-13 Jim Klimov + + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: only run and + withdocs:man on setups that did not yet run a witdocs:all (and are + declared capable of man) + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: remove distcheck- + light (sort of pointless WRT other scenarios) and withdocs:man + (redundant) from "various builds" + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: comment that + "default-all-errors" builds do not include docs and distcheck + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: add "default- + alldrv:no-distcheck" variant + * ci_build.sh: ci_build.sh: add "default-alldrv:no-distcheck" variant + * ci_build.sh: ci_build.sh: comment "default-all-errors" builds with + varying SSL implementations and refactor into a loop and case + Should be helftul for https://github.com/networkupstools/jenkins- + dynamatrix/issues/4 eventually + * ci_build.sh: ci_build.sh: comment the case BUILD_TYPE to maintain + easier + +2021-09-12 Jim Klimov + + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: reduce the amount + of build combos by careful use of dynamatrixAxesCommonEnv + +2021-09-11 Jim Klimov + + * tests/cpputest.cpp: tests/cpputest.cpp: add an optional verbose + mode to list executed test case names + * configure.ac: ci_build.sh: actively check that cppunit is not just + installed, but is usable with current compiler toolkit (we saw + linking issues and runtime segfaults with it) + * ci_build.sh: ci_build.sh: update a comment for OpenIndiana gcc-4.x + vs. libgd + * ci_build.sh: ci_build.sh: skip CGI builds for openindiana with + gcc-4.x (or older, preemptively) for now + * ci_build.sh: ci_build.sh: update constraints for libgd/cgi builds + on freebsd + * ci_build.sh: ci_build.sh: fix --disable-cppunit (not --without- + cppunit) + +2021-09-11 Jim Klimov + + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: constrain autotools + builds to "*fightwarn*" branches and PRs + +2021-06-14 Doug Nazar + + * server/netssl.c: server: Add warning if DISABLE_WEAK_SSL is not + enabled. + +2021-06-12 Jim Klimov + + * server/netssl.c: Update netssl.c Comment the default value of + `disable_weak_ssl` (currently not getting in our way, but can + change later) + * server/netssl.c: Update netssl.c Slight pedantic fix for use of + NSS VMAJOR/VMINOR macros + * server/conf.c: Update conf.c Comment parse_boolean() and add + support for "0" and "1" string values there, for good measure + * conf/upsd.conf.sample: Update upsd.conf.sample Mention that + DISABLE_WEAK_SSL is "currently" disabled by default, hinting that + it can become enabled after some releases. + * docs/nut.dict: Update nut.dict Add "TLSv" support in + spellchecker + +2021-06-11 Doug Nazar + + * conf/upsd.conf.sample, server/conf.c, server/netssl.c, + server/netssl.h: server: Add option to disable weak SSL + protocols/ciphers. + +2021-09-01 Arnaud Quette + + * drivers/eaton-pdu-marlin-mib.c, drivers/powerware-mib.c, + drivers/snmp-ups.c, drivers/snmp-ups.h: snmp-ups: Add a generic + function to convert date (#1078) This provides conversion from US + date (mm/dd/yyyy) to ISO Calendar date (yyyy-mm-dd). Also adapt the + function callback mechanism to make it more generic, and only char* + to char* reformating, beside from the int to char* value lookup. + Co-authored-by: Jim Klimov + +2021-08-03 Jim Klimov + + * clients/nutclient.h, clients/nutclientmem.cpp, + clients/nutclientmem.h: clients/nutclient.h + nutclientmem.h/.cpp: + add NUT_UNUSED_VARIABLE() where needed + * drivers/libshut.h: drivers/libshut.h: define the Device field + recently added to USBDevice_t + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: initialize the recently + added USBDevice_t Device field + * drivers/nutdrv_qx_masterguard.c: drivers/nutdrv_qx_masterguard.c: + fix the switch-case fallthrough that should not be (the case of "s" + is handled lower in the routine, so instant return is not logical) + * drivers/nutdrv_qx_masterguard.c: drivers/nutdrv_qx_masterguard.c: + complete the item_t initializers + * drivers/nutdrv_qx_masterguard.c: drivers/nutdrv_qx_masterguard.c: + be explicit about NUT_UNUSED_VARIABLEs + +2021-07-20 Jim Klimov + + * common/common.c: common/common.c: avoid C++ style comments + +2021-05-25 Jim Klimov + + * docs/images/ci/fosshost.org_Host_Light_309px.png, + docs/images/ci/fosshost.org_Host_Light_38px.png: docs/image/ci: add + more Fosshost logos tuned to be readable at smaller height + +2021-04-26 Jim Klimov + + * docs/man/dummy-ups.txt: dummy-ups.txt: mention the DDL and nut-ddl- + dump.sh + +2021-08-27 Jim Klimov + + * docs/config-prereqs.txt: docs/config-prereqs.txt: note caveats + about installing cppunit and gcc-4.4.4 on OpenIndiana + +2021-08-07 Jim Klimov + + * docs/config-prereqs.txt: docs/config-prereqs.txt: suggest + installing valgrind where available + +2021-08-04 Jim Klimov + + * docs/config-prereqs.txt: docs/config-prereqs.txt: suggest + installing source-highlight where available + +2021-08-03 Jim Klimov + + * docs/nut.dict: docs/config-prereqs.txt: list prerequisites for at + least a minimal build in OmniOS CE - update spellchecker + * docs/config-prereqs.txt: docs/config-prereqs.txt: list + prerequisites for at least a minimal build in OmniOS CE + * docs/config-prereqs.txt: docs/config-prereqs.txt: document libtool + as a prerequisite + +2021-08-02 Jim Klimov + + * docs/config-prereqs.txt: docs/config-prereqs.txt: revise + installation of supported shell interpreters + * docs/config-prereqs.txt: docs/config-prereqs.txt: add en-aspell for + freebsd profile + +2021-08-01 Jim Klimov + + * docs/Makefile.am, docs/config-prereqs.txt, docs/nut.dict, + docs/packager-guide.txt, docs/user-manual.txt: Introduce + docs/config-prereqs.txt and spellcheck for it + +2021-08-11 Jim Klimov + + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: revise use of + requiredNodelabels/excludedNodelabels, and reset them to surely + delete any cached values in the reusable dynamatrix object + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: keep docs builds to + the standard set of builders (nut-builder not doc-builder) + +2021-08-10 Jim Klimov + + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: use a custom-named + dynacfgPipeline.stashnameSrc + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: neuter the example + buildCommit + * Jenkinsfile-dynamatrix: Revert "Jenkinsfile-dynamatrix: list the + custom commits built on new NUT CI for initial history" This + reverts commit c9b5c870ac6834f16ebecb5334ac178de2d03d3d. Have that + list in history but do not clutter live version. + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: list the custom + commits built on new NUT CI for initial history + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: revise docs-all + build spec + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: modernize example + for custom replayed builds + +2021-08-04 Jim Klimov + + * ci_build.sh: ci_build.sh: double-quote path var expansions + * ci_build.sh: ci_build.sh: detect build agent capabilities for + Jenkins builds with NUT dynaMatrix config + * ci_build.sh: ci_build.sh: abstract from TRAVIS_OS_NAME to + CI_OS_NAME and set one for Jenkins builds with NUT dynaMatrix + config + +2021-08-03 Jim Klimov + + * configure.ac: configure.ac: hack around libtool when building with + custom bitness + +2021-08-03 Jim Klimov + + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: define autotools- + based distcheck for NUT + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: define autotools- + based distcheck for NUT + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: explicitly exclude + openindiana from build scenario with all docs types + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: typo fix + (require*d*Nodelabels after upstream refactor) + * m4/nut_compiler_family.m4: m4/nut_compiler_family.m4: do not pass + "-Wno-unknown-warning" to GCC + * m4/nut_check_libavahi.m4: m4/nut_check_libavahi.m4: PoC enable + avahi build in FreeBSD - rearrange + +2021-08-02 Jim Klimov + + * Jenkinsfile-dynamatrix: Revert "Jenkinsfile-dynamatrix: try to + synchronize cloning of dsbcClone+stageNameClone" This reverts + commit 2d477fac1c67f7a8477c550f1e5a638e533ab2ad : "synchronized" is + not supported for Jenkins Groovy CPS + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: try to synchronize + cloning of dsbcClone+stageNameClone + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: define + dsbcClone+stageNameClone closer to start of closure to get the + correct copy ASAP + * Jenkinsfile-dynamatrix: Jenkinsfile-dynamatrix: add + SERVICE_FRAMEWORK="selftest" to shellcheck-nde (equivalent) + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in: check for not-supported (t)csh interpreter + * Makefile.am: Makefile.am: add SERVICE_FRAMEWORK="selftest" to + shellcheck-nde + * Makefile.am: Makefile.am: add shellcheck-nde + * Makefile.am: Makefile.am: fix shellcheck (not all OSes serve + /bin/bash at that pathname) + +2021-07-31 Jim Klimov + + * m4/nut_check_libavahi.m4: m4/nut_check_libavahi.m4: PoC enable + avahi build in FreeBSD + * m4/nut_check_libneon.m4: m4/nut_check_libneon.m4: FreeBSD installs + stuff under /usr/local + +2021-07-28 Jim Klimov + + * ci_build.sh: ci_build.sh: report CONFIGURING NUT in a way + friendlier for copy-paste + * configure.ac, m4/nut_compiler_family.m4: configure.ac + + m4/nut_compiler_family.m4: introduce NUT_COMPILER_FAMILY_FLAGS to + propagate -Wno-unknown-warning(-opton) before any pkgconfig + * docs/man/Makefile.am: docs/man/Makefile.am: Fix check-man-txt to + also run from separate build dirs + * ci_build.sh: ci_build.sh: do not make TOO MUCH noise when dumping + config.log + * ci_build.sh: ci_build.sh: set DISTCHECK_FLAGS in "default-tgt:"* + handling too + +2021-07-27 Jim Klimov + + * ci_build.sh: ci_build.sh: introduce BUILD_TYPE=default-withdoc:man + (and allow it) + * .gitignore: GitIgnore CI-generated log files + * ci_build.sh: ci_build.sh: introduce BUILD_TYPE=default-withdoc:man + * ci_build.sh: ci_build.sh: make sure DISTCHECK_FLAGS is single-line + * configure.ac: configure.ac: tell compiler to not choke on unknown + options + +2021-07-26 Jim Klimov + + * ci_build.sh: ci_build.sh: parameterize $MAKE + * ci_build.sh: ci_build.sh: try to avoid problems with multi-token + CFLAGS etc. when passed from "${CONFIG_OPTS[@]}" array into + DISTCHECK_CONFIGURE_FLAGS string (envvar) - refactor + +2021-07-22 Jim Klimov + + * ci_build.sh: ci_build.sh: try to avoid problems with multi-token + CFLAGS etc. when passed from "${CONFIG_OPTS[@]}" array into + DISTCHECK_CONFIGURE_FLAGS string (envvar) + +2021-07-20 Jim Klimov + + * configure.ac: configure.ac: detect if i2c library is usable, and + cancel i2c driver build if it is not + +2021-06-26 Jim Klimov + + * Makefile.am, configure.ac: configure.ac: follow autotools doc + recommendation to automatically update the libtool script if it + becomes out-of-date + * configure.ac: configure.ac: AC_PROG_LIBTOOL is noisily deprecated + since autotools-2.70; LT_INIT is the replacement + * m4/nut_arg_with.m4: m4/nut_arg_with.m4: AC_HELP_STRING is noisily + deprecated since autotools-2.70; AS_HELP_STRING is available since + 2.59 and we use it already a lot elsewhere + +2021-04-26 Jim Klimov + + * drivers/Makefile.am: drivers/Makefile.am: fix truncated comment + Text originates from SVN-Git migration in + e8e716e0598158f705e060c72f8f4b0444fbcd0f + +2021-08-23 Arnaud Quette + + * docs/nut-names.txt: Complete the date standardization proposal for + time + +2021-08-20 Arnaud Quette + + * docs/nut-names.txt: Propose to express dates using ISO 8601 when + possible + +2021-08-19 Stephan Blecher <_github@blecher.at> + + * drivers/legrand-hid.c: issue-616: legrand 600 fix input voltage + +2021-08-18 root + + * scripts/upower/95-upower-hid.rules: legrand hid rules update + +2021-08-12 Arnaud Quette + + * drivers/mge-xml.c: netxml-ups: fix for erroneous battery info + (MGEXML/0.30) (#1069) Some battery related information were + wrongly using output information + * docs/nut-names.txt: RFC: clarify and complete battery dates (#1063) + The existing battery.date means the installation or last + replacement date, as it seems to be implemented by various drivers. + Add an additional battery.date.maintenance for the next replacement + or maintenance date + * docs/nut-names.txt: Extend battery information collection (#1062) + * RFC: Add battery.capacity.nominal * RFC: add Li-ion battery + cell information * RFC: Add battery.status * Clarify Li-ion + battery cell information Mention that min/max cell voltage and + temperature are observed values, not settings + * docs/nut-names.txt: RFC: add new variable battery.packs.external + (#1060) * RFC: add new variable battery.packs.external * Improve + wording, as per Charles Lepple feedback * Improve example values, + which can or not be zero-padded + +2021-08-01 Jim Klimov + + * Jenkinsfile-dynamatrix: Introduce Jenkinsfile-dynamatrix + +2021-07-28 Jim Klimov + + * data/driver.list.in: data/driver.list.in: list Ippon Back Comfo Pro + II 650/850/1050 as supported by blazer_usb [#1035] + +2021-07-21 dtsecon + + * drivers/generic_modbus.c, drivers/generic_modbus.h: shutdown + configurable repetition with increasing time interval added + +2021-07-19 dtsecon + + * configure.ac, docs/Makefile.am, docs/man/Makefile.am: fix man pages + broken build process + +2021-07-16 dtsecon + + * docs/man/generic_modbus.txt: improve man page + * docs/man/Makefile.am, docs/man/generic_modbus.txt: man page text + created, added in build procedure + +2021-07-08 dogtopus + + * docs/man/genericups.txt, drivers/genericups.h: genericups: Change + type 23 to be active low. Seems that typical RS232 transceivers + inverts the signal automatically anyway, so there's no point of + making them active high by default. + +2021-07-06 dogtopus + + * docs/man/genericups.txt: docs: Document the special line NULL in + genericups documentation. + * drivers/genericups.c: genericups: Bump version number. + * docs/contact-closure.txt, docs/man/genericups.txt, + drivers/genericups.c, drivers/genericups.h: genericups: Add support + for FTTx battery backup. A lot of those "UPSes" use a 4-wire open- + drain-like contact closure signaling (dubbed "telemetry interface") + to report their status (see https://dl4jz3rbrsfum.cloudfront.net/do + cuments/CyberPower_UM_CBN50U48A-1.pdf for example). They are sorta + compatible with APC 940-0020B/C cables in terms of pin assignments, + with extra signals for replace battery and battery missing and lack + of shutdown signal. This patch adds a sample device type (23) for + this kind of device. It also adds support for the extra signal + types (RB for replace battery and BYPASS for disconnected battery) + used by these devices, as well as an option to unassign/disable an + unused signal in the config file by setting it to NULL. Note that + there is no standard cable for this kind of device, so type 23 + assumes RS232 control signaling and RTS as the voltage source for + input pin pullups. + +2021-07-06 dtsecon + + * drivers/generic_modbus.c, drivers/generic_modbus.h: fix serial + options in modbus_open + * drivers/generic_modbus.c: fix 'for' loop initial declarations for + compatibility out of C99 mode + * drivers/Makefile.am: generic_modbus.h added to Makefile.am + * drivers/generic_modbus.c: just one space less + +2021-06-30 Nick Briggs + + * tests/.gitignore, tests/Makefile.am, tests/getvaluetest.c: Create + test harness for GetValue() report value extraction (usbhid-ups) + Adds source and updates Makefile.am to build tests/getvaluetest, a + test harness for the report value extraction function GetValue() in + hidparser.c. getvaluetest has some built-in test cases, which are + easily extensible, but also accepts a single test specification on + the command line to allow for easy experimentation. getvaluetest + -h for usage + +2021-06-30 Jim Klimov + + * scripts/systemd/nut-driver-enumerator.service.in, + scripts/systemd/nut-driver@.service.in, scripts/systemd/nut- + monitor.service.in, scripts/systemd/nut-server.service.in: + systemd/*.service(.in): update units with SyslogIdentifier=%N The + log identifier should hopefully help make more sense of syslog or + journal entries where helper shell script traces might end up. + +2021-06-29 Dimitris Economou + + * drivers/generic_modbus.c: minor changes to comply with nut + development guidelines + * drivers/generic_modbus.c: variable ctx changed to mbctx + +2021-06-25 dtsecon + + * drivers/generic_modbus.c: removing unnecessary code + * drivers/generic_modbus.c: time_ellapsed fixed + +2021-06-25 abratchik + + * drivers/Makefile.am, drivers/arduino-hid.c, drivers/arduino-hid.h, + drivers/usbhid-ups.c, scripts/upower/95-upower-hid.rules: Arduino + UPS Support + +2021-06-12 abratchik + + * docs/FAQ.txt, drivers/libusb.c, drivers/libusb.h, drivers/powervar- + hid.c: HID-compliant UPS support with interface gt than 0 + +2021-06-24 dtsecon + + * drivers/generic_modbus.c: minor changes and tidying up + * drivers/generic_modbus.c: remove unnecessary stuff + * drivers/generic_modbus.c, drivers/generic_modbus.h: initial commit + of generic_modbus beta version source files + * drivers/Makefile.am: generic_modbus sources add in buidling + procedure + +2021-06-22 Tom Fifield + + * data/driver.list.in: Opti-UPS PS1500E is supported by blazer_usb + Opti-UPS PS1500E connects via serial over USB, and is supported by + the blazer_usb driver. This patch updates the compatibility list. + Manufacturer link: https://www.opti- + ups.com/index.asp?SCID=SC20060001 Device is automatically detected + by nut-scanner > [nutdev1] > driver = "blazer_usb" > + port = "auto" > vendorid = "0665" > productid = "5161" + > bus = "001" OB status is correctly detected, and other + correct values are displayed when queried: battery.charge: 100 + battery.voltage: 27.60 battery.voltage.high: 26.00 + battery.voltage.low: 20.80 battery.voltage.nominal: 24.0 + device.mfr: device.model: 1500VA device.type: ups driver.name: + blazer_usb driver.parameter.bus: 001 driver.parameter.pollinterval: + 2 driver.parameter.port: auto driver.parameter.productid: 5161 + driver.parameter.synchronous: no driver.parameter.vendorid: 0665 + driver.version: 2.7.4 driver.version.internal: 0.12 + input.current.nominal: 13.0 input.frequency: 60.0 + input.frequency.nominal: 60 input.voltage: 113.9 + input.voltage.fault: 111.4 input.voltage.nominal: 110 + output.voltage: 113.3 ups.beeper.status: enabled + ups.delay.shutdown: 30 ups.delay.start: 180 ups.firmware: ups.load: + 2 ups.mfr: ups.model: 1500VA ups.productid: 5161 ups.status: OL + ups.type: offline / line interactive ups.vendorid: 0665 + +2021-06-18 Scott K Logan + + * drivers/tripplite.c: drivers/tripplite.c: start using the 'X' value + Relatively ancient documentation seems to suggest that this + 'firmware checksum' value can be used to indicate the firmware + generation as well as the capabilities of the UPS, namely the + number of independently controllable plugs. + +2021-06-16 Nick Briggs + + * drivers/hidparser.c: Add note regarding sensitivity to 32- vs 64- + bit compilation and overflow + +2021-06-14 Doug Nazar + + * Makefile.am, conf/Makefile.am, data/Makefile.am, docs/Makefile.am, + docs/man/Makefile.am: Fix spellcheck to also run from separate + build dirs + +2021-06-12 Jim Klimov + + * docs/nut-names.txt: docs/nut-names.txt: add the note about RFC + Recording Document + * docs/nut-names.txt: docs/nut-names.txt: reword the intro paragraphs + and define the "experimental.*" namespace + * docs/FAQ.txt: FAQ.txt: make it easier to find suggestions for + missing "battery.charge.restart" workarounds + +2021-06-02 Nick Briggs + + * drivers/hidparser.c: Fix GetValue() to correctly extract values + from a report when compiled in LP64 mode Changes the strategy for + removing potential garbage bits from values extracted from a + report. Use the LogMin and LogMax fields to drive which bits are + meaningful but avoid confusion when, for example, given a range of + -1..2147483647 + +2021-05-30 Jim Klimov + + * configure.ac: configure.ac: bugfix - populate systemdtmpfilesdir in + its option, not systemdshutdowndir + * configure.ac: configure.ac: do not make noise with yet empty + systemdtmpfilesdir + * configure.ac: configure.ac: process other values for + systemdshutdowndir option + * configure.ac: configure.ac: just in case, double-quote to single- + tokenize detected systemd related options + * configure.ac: configure.ac: update comments for systemd related + options + +2021-05-28 Jim Klimov + + * docs/nut.dict: nut.dict: add new words for nut-website + * configure.ac: configure.ac: improve reporting of systemd options + processing + * autogen.sh, configure.ac, scripts/systemd/.gitignore, + scripts/systemd/nut-common.tmpfiles.in: configure.ac: generate + scripts/systemd/nut-common.in based on current config + * configure.ac: configure.ac: typo fix in comment + * Makefile.am, configure.ac, docs/configure.txt, docs/nut.dict, + scripts/systemd/.gitignore, scripts/systemd/Makefile.am, + scripts/systemd/nut-common.tmpfiles.in: [Issue #1030] Deliver + systemd-tmpfiles config to pre-create runtime locations + +2021-05-24 Jim Klimov + + * docs/nut.dict: Update nut.dict Update dict for PR #975 + * docs/man/nutdrv_qx.txt: Update nutdrv_qx.txt Our accepted + terminology is for multiple "UPSes" not "UPSen", however + questionable the language might be + * drivers/nutdrv_qx.c: Update nutdrv_qx.c Bump version due to + addition of `phoenixtec_command()` + * drivers/nutdrv_qx.c: Update nutdrv_qx.c Pre-initialize "e = NULL" + in phoenixtec_command(), we do not set it from `memchr()` later in + all cases. + * drivers/nutdrv_qx_masterguard.c: Update nutdrv_qx_masterguard.c + Add #include + * drivers/powerpanel.h: Update powerpanel.h Define a subdriver_t for + driver version (modifiable) vs type (bin/txt) + * drivers/powerp-txt.c: Update powerp-txt.c Fix subdriver type vs + subdriver version + * drivers/powerp-bin.c: Update powerp-bin.c Track subdriver version + * drivers/powerp-txt.c: Update powerp-txt.c Introduce versioning + * drivers/cyberpower-mib.c: Update cyberpower-mib.c Update reported + driver version after the bump + * drivers/cyberpower-mib.c: Update cyberpower-mib.c Handle + "battery.voltage" and "battery.current" readings for different MIB + revisions + +2021-05-24 Jim Klimov + + * lib/.gitignore: GitIgnore generated lib/libnutclientstub.pc + +2021-05-24 Jim Klimov + + * drivers/nutdrv_qx.c: Update nutdrv_qx.c Formatting and slight + rewording of a comment + +2021-05-24 Jim Klimov + + * drivers/usb-common.h: drivers/usb-common.h: better comment "the 5 + pieces of information by which a USB device identifies itself" + * drivers/usb-common.h: drivers/usb-common.h: move the recently added + USBDevice_t Device field to the end, for a bit of cross-version + binary compatibility + * docs/man/blazer-common.txt, docs/man/nutdrv_qx.txt, + docs/man/tripplite_usb.txt, docs/man/usbhid-ups.txt: Docs: rephrase + Note for "device" option in USB drivers + +2021-05-18 Clappier, Eric + + * tests/nutclienttest.cpp: Fix typo + +2021-05-17 Clappier, Eric + + * clients/nutclientmem.cpp, clients/nutclientmem.h, + tests/nutclienttest.cpp: Take into account pull request remarks + +2021-05-07 Clappier, Eric + + * drivers/bcmxcp_ser.c: Fix coverity test issue + * tests/nutclienttest.cpp: Try fixing coverity test issue + * clients/Makefile.am, configure.ac, lib/Makefile.am, + lib/libnutclientstub.pc.in, tests/Makefile.am: Separate lib for + stub + +2021-05-05 Clappier, Eric + + * tests/nutclienttest.cpp: Add tests in cppunit + * clients/Makefile.am: Fix missing header + +2021-05-04 Clappier, Eric + + * clients/Makefile.am, clients/{nutclientmock.cpp => + nutclientmem.cpp}, clients/{nutclientmock.h => nutclientmem.h}, + tests/nutclienttest.cpp: Rename class Fix cppunit test Add + typedef for map + * clients/nutclientmock.cpp: Fix indentation + * clients/Makefile.am, clients/nutclient.cpp, clients/nutclient.h, + clients/nutclientmock.cpp, clients/nutclientmock.h: Separate + NutClientMock class + * clients/nutclient.cpp, clients/nutclient.h, + tests/nutclienttest.cpp: Add mock for TcpClient + +2021-05-20 Denis Yurin + + * drivers/powercom-hid.c: add temperature readings for Powercom + MRT-3000 add temperature readings support for Powercom MRT-3000 + +2021-05-18 Alexey Kazancev + + * drivers/nutdrv_qx.c: nutdrv_qx.c: bump version to 0.31 + * drivers/nutdrv_qx.c: nutdrv_qx.c: add batt.volt.act validation + Some UPS return zero batt voltage after communication error. This + validation must fix wrong runtime calculation. + * drivers/nutdrv_qx.c: nutdrv_qx.c: fix snr_command communication + error in protocol matching phase. + +2021-05-06 Alexey Kazancev + + * drivers/nutdrv_qx.c: nutdrv_qx.c: bump version to 0.30 + +2021-04-26 Alexey Kazancev + + * drivers/nutdrv_qx.c: nutdrv_qx.c: add correction of runtime + estimation + +2021-04-23 Jim Klimov + + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: + fabula_hunnox_subdriver(): annotate NUT_UNUSED_VARIABLE(device) arg + * drivers/delta_ups-hid.c: drivers/delta_ups-hid.c: fix + initialization of delta_ups_type_info[] + * drivers/delta_ups-hid.c: drivers/delta_ups-hid.c: fix + initialization of delta_ups_type_info[] + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: + fabula_hunnox_subdriver(): annotate NUT_UNUSED_VARIABLE(device) arg + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: order includes and + subdrivers alphabetically + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: order includes and + subdrivers alphabetically + * clients/nutclient.cpp, clients/nutclient.h: + clients/nutclient.{h,cpp}: explicitly request assignment operator + generation for exception classes + +2021-04-09 Jim Klimov + + * drivers/metasys.c: drivers/metasys.c: fix SIZE_MAX comparison + * drivers/metasys.c: drivers/metasys.c: fix %zd printing of ssize_t + res + +2021-03-31 Jim Klimov + + * drivers/metasys.c: drivers/metasys.c: protect failsafe logic from + compiler warnings with pragmas + * drivers/metasys.c: drivers/metasys.c: upsdrv_initinfo(): pedantic + and stylistic fixes + * drivers/metasys.c: drivers/metasys.c: upsdrv_initinfo(): sanity- + check that reply was big enough to have a serial number, and then + cast for memcpy() + * drivers/metasys.c: drivers/metasys.c: get_answer(): rectify var + types to avoid signedness and range warnings + * drivers/metasys.c: drivers/metasys.c: fix arg type for + send_read_command() to avoid signedness mismatches + * drivers/metasys.c: drivers/metasys.c: refactor a get_word_float() + to simplify code + * drivers/metasys.c: drivers/metasys.c: fix fixed-width integers for + get_word()/get_long() or cast meaningfully where needed + * drivers/bcmxcp.c: drivers/bcmxcp.c: cast the bytes when + constructing "cbuf[]"s element by element + * drivers/bcmxcp.c: drivers/bcmxcp.c: instcmd(): cast use of sddelay + to avoid signedness warnings + * drivers/bcmxcp.c: drivers/bcmxcp.c: upsdrv_initinfo(): buf is + size_t by usage + * drivers/bcmxcp.c: drivers/bcmxcp.c: upsdrv_initinfo(): fix atoi() + of unsigned value for shutdown_delay + * drivers/bcmxcp.c: drivers/bcmxcp.c: fix fixed-width integers for + get_word()/get_long()/init_outlet() or cast meaningfully where + needed + * drivers/al175.c: drivers/al175.c: avoid implicit conversion of byte + to int during bit-shifting + +2021-03-30 Jim Klimov + + * drivers/al175.c: drivers/al175.c: avoid implicit tcflag_t + signedness conversion + * drivers/al175.c: drivers/al175.c: avoid implicit char/byte + conversion + * drivers/al175.c: drivers/al175.c: avoid implicit long/unsigned long + conversion, and fix formatting nearby + * drivers/al175.c: drivers/al175.c: align arguments to wrappers of + al175_do() with the uint16_t type it accepts (avoid variable-width + signed int) + * drivers/libusb.c: drivers/libusb.c: mark hid_rep_index static (not + externalized) + +2021-01-20 Jim Klimov + + * drivers/eaton-ats16-nm2-mib.c, drivers/eaton-ats16-nmc-mib.c: + eaton-ats16-nm?-mib.c: port comments from 42ity fork to clarify + what is going on here for mib2nut_info_t definitions + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: + comment about not-function pointers from libnet-snmp + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: fix + indentations and whitespaces + * tools/nut-scanner/scan_xml_http.c: tools/nut- + scanner/scan_xml_http.c: fix indentations and whitespaces + * tools/nut-scanner/nut-scanner.c: nut-scanner.c: some extra + whitespace, some missing, in longopts[] + +2021-01-06 Jim Klimov + + * server/netssl.c: server/netssl.c: #include "nut_stdint.h" for + limits definitions + * clients/upscmd.c, clients/upsimage.c, clients/upsmon.c, + clients/upsrw.c, clients/upsstats.c, common/common.c, common/str.c, + drivers/al175.c, drivers/bcmxcp.c, drivers/bcmxcp_ser.c, + drivers/bcmxcp_usb.c, drivers/bestfortress.c, drivers/etapro.c, + drivers/genericups.c, drivers/metasys.c, drivers/netxml-ups.c, + drivers/nutdrv_siemens_sitop.c, drivers/powercom.h, + drivers/richcomm_usb.c, drivers/serial.c, drivers/snmp-ups.c, + server/upsd.c: Various sources: use nut_stdint.h where limits.h was + introduced recently + * configure.ac, include/nut_stdint.h: nut_stdint.h: include limits.h + and make sure SIZE_MAX is defined + +2020-12-27 Jim Klimov + + * drivers/richcomm_usb.c: drivers/richcomm_usb.c: fix size_t types + for upsdebugx_hex() and range-check the values + * drivers/blazer_usb.c: drivers/blazer_usb.c: fix static const struct + * drivers/blazer_usb.c: drivers/blazer_usb.c: fix whitespace + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: fix static const struct + +2020-12-26 Jim Klimov + + * server/conf.c, server/upsd.c, server/upsd.h: server/upsd.{c,h} + conf.c: fix maxconn to long, to match sysconf() return value; check + that practical value range allows to malloc() the buffers + * server/upsd.c: server/upsd.c: fix size_t/ssize_t types for + {ssl_,}write() in sendback() + * server/netssl.c, server/netssl.h: server/netssl.{c,h}: fix + ssl_write()/ssl_read() to return ssize_t (like upsclient + net_write()/net_read()) + * server/netssl.c: server/netssl.c: fix int types for OpenSSL + codepaths + * drivers/liebert-esp2.c: drivers/liebert-esp2.c: fix numphases to + unsigned int + * drivers/liebert-esp2.c: drivers/liebert-esp2.c: fix int size_t + types for read(), malloc() etc. + * drivers/liebert-esp2.c: drivers/liebert-esp2.c: fix size_t types + for upsdebugx_hex() and some indentation + * drivers/isbmex.c: drivers/isbmex.c: fix int size_t types for + read(), malloc() etc. + * drivers/genericups.c: drivers/genericups.c: fix int types for + sleep() + * drivers/genericups.c: drivers/genericups.c: cast termios types for + bit magic + * drivers/gamatronic.h: drivers/gamatronic.h: fix speed_t/size_t in + baud_rates[] definition like for bcmxcp_ser + * drivers/gamatronic.c: drivers/gamatronic.c: fix some whitespace + * drivers/gamatronic.c: drivers/gamatronic.c: fix int size_t types + for read(), malloc() etc. + * drivers/etapro.c: drivers/etapro.c: constrain return value for + etapro_get_response() type + * drivers/bestuferrups.c: drivers/bestuferrups.c: fix size_t int type + for execute() (use-cases pass sizeof() anyway) + * drivers/bestfortress.c: drivers/bestfortress.c: constrain value for + usleep() in upssend() + * drivers/bestfortress.c: drivers/bestfortress.c: constrain return + value for upssend() type + * drivers/bestfortress.c: drivers/bestfortress.c: fix size_t types + for upsdebugx_hex() + +2021-04-23 Jim Klimov + + * drivers/bestfortress.c: drivers/bestfortress.c: fix back setparam() + arg type + +2020-12-01 Jim Klimov + + * drivers/bestfortress.c: drivers/bestfortress.c: fix printing of + ssize_t variable + +2020-11-30 Jim Klimov + + * drivers/bestfortress.c: drivers/bestfortress.c: use size_t where it + should be, for data chunk length parsing + +2020-12-26 Jim Klimov + + * drivers/bestfcom.c: drivers/bestfcom.c: fix size_t int type for + execute() (use-cases pass sizeof() anyway) + * drivers/belkinunv.c: drivers/belkinunv.c: fix int types for read(), + malloc() etc. + * drivers/belkinunv.c: drivers/belkinunv.c: fix int types for reg + (byte) + * drivers/belkin.c: drivers/belkin.c: fix size_t/useconds_t int type + for cnt (already limited to byte range) + * drivers/bcmxcp.c: drivers/bcmxcp.c: whitespace fix indentation in + set_alarm_support_in_alarm_map() + * drivers/bcmxcp.c: drivers/bcmxcp.c: fix unsigned int type for index + arguments in set_alarm_support_in_alarm_map() + * drivers/serial.c: drivers/serial.c: fix ssize_t int type for + function returns vs size_t buflen argument + * drivers/dstate.c: drivers/dstate.c: fix size_t int type for + bufrw_max + * drivers/main.c: drivers/main.c: fix int types for poll_interval + * clients/upscmd.c: clients/upscmd.c: fix data range warnings for + asserts about implem-dependent overflow chances + * clients/upsrw.c: clients/upsrw.c: fix data range warnings for + asserts about implem-dependent overflow chances + * clients/upsclient.c: clients/upsclient.c: fix data range warnings + for asserts about implem-dependent overflow chances + * clients/upsmon.c, clients/upsmon.h: clients/upsmon.c: fix int types + for power value and totalpv accounting + * clients/upsmon.c: clients/upsmon.c: fix int types for sleep() + * clients/upsimage.c: clients/upsimage.c: make explicit casts from + floating-points into int types for rendering + * clients/upscmd.c: clients/upscmd.c: fix int types for timeouts from + upsclient.c + * clients/upsrw.c: clients/upsrw.c: fix int types for timeouts from + upsclient.c + * clients/upsclient.c: clients/upsclient.c: fix numq int types for + verify_resp() + +2020-12-25 Jim Klimov + + * clients/upsclient.c: clients/upsclient.c: make explicit a case + size_t/ssize_t casting + * clients/upsclient.c, clients/upsclient.h: clients/upsclient.{c,h}: + fix "timeout" type in + net_read/net_write/upscli_sendline_timeout/upscli_readline_timeout + to match upscli_select_read/upscli_select_write + * clients/upsclient.c: clients/upsclient.c: fix int types for OpenSSL + codepaths + +2020-12-07 Jim Klimov + + * drivers/metasys.c: drivers/metasys.c: various routines: fix + command_length into size_t + * drivers/bcmxcp_io.h, drivers/bcmxcp_ser.c, drivers/bcmxcp_usb.c: + bcmxcp*: various routines: fix command_length into size_t + * drivers/bcmxcp_ser.c: drivers/bcmxcp_ser.c: get_answer(): fix + bytes_read, end_length and length into size_t + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: get_answer(): fix + bytes_read, end_length and length into size_t + +2020-12-02 Jim Klimov + + * drivers/bcmxcp.c: drivers/bcmxcp.c: use size_t for upsdebugx_hex() + and upsdebugx_ascii() args for logged data length + +2020-12-01 Jim Klimov + + * drivers/masterguard.c: drivers/masterguard.c: fix printing of + ssize_t variable + +2020-11-30 Jim Klimov + + * clients/upsstats.c: clients/upsstats.c: fix use of use size_t vs + int-argumented printf("%.*s", int, str) formatting + * drivers/al175.c: drivers/al175.c: check pointer math WRT buffer + lengths passed to logging + * common/common.c, include/common.h: common.{c,h}: use size_t for + upsdebugx_hex() and upsdebugx_ascii() args for logged data length + * drivers/tripplitesu.c: drivers/tripplitesu.c: init_comm(): fix data + types to size_t for strlen() function + * drivers/tripplitesu.c: drivers/tripplitesu.c: do_command(): fix up + "count" int type to be unsigned + * drivers/tripplitesu.c: drivers/tripplitesu.c: do_command(): fix up + "ret" int type to avoid conversions + * drivers/masterguard.c: drivers/masterguard.c: avoid value type + conversion by changing data types to size_t for strlen() function + * drivers/masterguard.c: drivers/masterguard.c: avoid value type + conversion by casting explicitly the return value of strlen() + function + +2020-12-27 Jim Klimov + + * clients/nutclient.cpp, clients/nutclient.h: + clients/nutclient.{h,cpp}: explicitly request copy constructor + generation for exception classes + +2020-11-30 Jim Klimov + + * clients/upsset.c: drivers/upsset.c: fix up int types to avoid + implicit conversions + * clients/upsimage.c: drivers/upsimage.c: avoid value type conversion + by casting explicitly the return value of strlen() function + * clients/upsimage.c: drivers/upsimage.c: fix up int types to avoid + conversions + * clients/cgilib.c: drivers/cgilib.c: fix up int types to avoid + conversions + * clients/upsstats.c: drivers/upsstats.c: fix up floating-point types + to avoid conversions and precision change + * clients/upsstats.c: clients/upsstats.c: use size_t where it should + be, for string length related processing + * clients/upslog.c: clients/upslog.c: use size_t where it should be, + for string length related processing + * clients/upslog.c: clients/upslog.c: avoid implicit floating-integer + conversion + +2021-03-30 Jim Klimov + + * configure.ac: configure.ac: nut_enable_warnings: clang presets + should let "-Wdocumentation" slide: NUT does not use it now, and + third-party headers are what they are + +2020-12-29 Jim Klimov + + * tests/nut-driver-enumerator-test.sh: tests/nut-driver-enumerator- + test.sh: allow to pass SHELL_PROGS="busybox_sh" as a single token + +2020-12-26 Jim Klimov + + * .travis.yml: .travis.yml: move _matrix_linux_gnustd_warn_viable a + bit up in _matrix_required_linux listing, to get more probable + failures earlier + +2021-04-23 Jim Klimov + + * drivers/delta_ups-mib.c: delta-mib.c: rename onbatt_info lookup + table in commented-away code sample (and match naming pattern with + other tables) + * drivers/delta_ups-hid.c: drivers/delta_ups-hid.c: typo in comment + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: comment that Vendor ID + 0x0483 is from ST Microelectronics + +2021-04-23 Jim Klimov + + * drivers/ever-hid.c: Update ever-hid.c Make and comment the macro + for ST Microelectronics vendor id (to generate udev data, etc. + properly) + * drivers/ever-hid.c: Update ever-hid.c Lowercase the hex in vendor + ID macro, for consistency + +2021-04-22 Nick Briggs + + * drivers/hidparser.c: correct 'for' loop initial declarations are + only allowed in C99 or C11 mode + * drivers/hidparser.c: Extract values in HIDParse correctly when + compiled in 64-bit (LP64) mode Reworks the conversion of bytes in + little-endian order to host order to operate independently of the + sizeof(long) and the byte-order of the host system. The extracted + value is stored as uint32_t as the code already performs casts to + signed/unsigned of varying sizes as appropriate to the context of + use. + +2021-04-21 Jim Klimov + + * drivers/delta_ups-hid.c: drivers/delta_ups-hid.c/.h: sync PR #807 + code with master branch: sync polling frequencies + * drivers/delta_ups-hid.c: drivers/delta_ups-hid.c/.h: sync PR #807 + code with master branch: remove (read-only) mappings for ups.delay* + in favor of same points polled for ups.timer* + * drivers/delta_ups-hid.c: drivers/delta_ups-hid.c/.h: sync PR #807 + code with master branch: comment away ups.mfr/model/serial setting + per PR comments + * drivers/delta_ups-hid.c: drivers/delta_ups-hid.c/.h: sync PR #807 + code with master branch: set voltage/current/frequency precision to + %.1f same for all entries + * drivers/delta_ups-hid.c: drivers/delta_ups-hid.c/.h: sync PR #807 + code with master branch: set battery.charge* precision to %.0f same + for all entries + * drivers/delta_ups-hid.c: drivers/delta_ups-hid.c/.h: sync PR #807 + code with master branch: import delta_ups_hid2nut[] entries "as is" + * drivers/delta_ups-hid.c: drivers/delta_ups-hid.c/.h: sync PR #807 + code with master branch: import Helper lookup tables and mapping + functions from master + * drivers/delta_ups-hid.c: drivers/delta_ups-hid.c/.h: sync PR #807 + code with master branch: change delta_ups_hid2nut[] content order + by names to be same as in master + * drivers/delta_ups-hid.c: drivers/delta_ups-hid.c/.h: sync PR #807 + code with master branch: import named delta_ups_usage_lkp[] content + from master + * drivers/delta_ups-hid.c: drivers/delta_ups-hid.c/.h: sync PR #807 + code with master branch: import delta_ups_format_model() content + from master + * drivers/delta_ups-hid.c: drivers/delta_ups-hid.c/.h: sync PR #807 + code with master branch: move delta_ups_format_model() to same + position as in master + * drivers/delta_ups-hid.c: drivers/delta_ups-hid.c/.h: sync PR #807 + code with master branch: indentations in delta_ups_claim() + * drivers/delta_ups-hid.c: drivers/delta_ups-hid.c/.h: sync PR #807 + code with master branch: indentations in delta_ups_hid2nut[] + * drivers/delta_ups-hid.c: drivers/delta_ups-hid.c/.h: sync PR #807 + code with master branch: indentations in delta_ups_usage_lkp[] + * drivers/delta_ups-hid.c, drivers/delta_ups-hid.h: + drivers/delta_ups-hid.c/.h: sync PR #807 code with master branch: + rename delta => delta_ups, sync comments + * drivers/Makefile.am, drivers/{delta-hid.c => delta_ups-hid.c}, + drivers/{delta-hid.h => delta_ups-hid.h}, drivers/usbhid-ups.c, + scripts/upower/95-upower-hid.rules: Rename delta-hid.c/.h to + delta_ups-hid.c/.h and sync vendor label for USB [#807] + +2021-04-21 Edgar Fuß + + * drivers/nutdrv_qx.c: Correct format string size_t is unsigned, so + use %zu (not %zd) in upsdebug() format string. + * drivers/nutdrv_qx.c: Remove vis-dependent debugging code Remove + (level 4) debugging code in the phoenixtex/masterguard USB + subdriver that depends on the BSD strvis() family for visual string + formatting. + +2021-04-20 Jim Klimov + + * drivers/delta-hid.c: Update delta-hid.c Sync the vendor-name + comment (for udev generation among others) with another Delta HID + driver merged to master recently. + +2021-04-20 Jim Klimov + + * drivers/delta_ups-hid.c, scripts/upower/95-upower-hid.rules: + 95-upower-hid.rules: regenerate for idVendor=05dd (Delta UPS) + * docs/documentation.txt: docs/documentation.txt: add a section on + reporting Data dumps for the DDL + +2021-04-20 Jim Klimov + + * docs/nut.dict: Update nut.dict Updated for PR #994 + +2021-04-20 Jim Klimov + + * docs/man/nutdrv_qx.txt: docs/man/nutdrv_qx.txt: fix copy-paste typo + +2021-04-20 Ygor Amadeo Sartori Regados + + * docs/man/microsol-apc.txt: Man page compilation error fixes + * docs/man/Makefile.am, docs/man/microsol-apc.txt: Added man page + * drivers/microsol-apc.c, drivers/microsol-common.h: Fix: wrong + operator and unused function + * drivers/microsol-apc.c, drivers/microsol-apc.h: Fixed driver name + +2021-04-20 Jim Klimov + + * drivers/microsol-apc.c: Update microsol-apc.c In upsdrv_info, + split contributors one per line for better source readability + +2021-04-20 Jim Klimov + + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: fix back the name for + "fabula_hunnox_subdriver" (USB protocol subdriver vs. + "hunnox_subdriver" for device data mapping) + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: bump core DRIVER_VERSION + to reflect changes from PR #638 for "hunnox" support + * docs/man/nutdrv_qx.txt, drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: + simplify new subdriver/command naming from "fabula-hunnox" to + "hunnox" + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: restore indentation with + TABs + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: fabula_command_hunnox(): + comment about truncating the buflen to 102 bytes + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: fabula_command_hunnox(): + comment away scoping for (and use of) "hunnox_patch" leaving the + markers in comments for refactoring + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: comment that + fabula_hunnox_subdriver was reported to support more than Hunnox + branded devices + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: fabula_command_hunnox(): + restore originally PRed choice of usb_get_string{,_simple}() based + on langid_fix alone + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: separate + fabula_command_hunnox() from fabula_command() without using a mixed + routine, to ensure no impact on currently supported devices + * docs/nut.dict: docs/nut.dict: typo fix + +2021-04-20 Jim Klimov + + * docs/nut.dict: Update nut.dict Some more keywords to the + dictionary from PR #638 + +2021-04-19 Jim Klimov + + * docs/nut.dict: Update nut.dict Update dictionary for Hunnox PR + #638 + * docs/man/nutdrv_qx.txt: Update nutdrv_qx.txt Basically mention + updates from Hunnox subdriver and protocol addition (PR #638). + * drivers/nutdrv_qx.c: Update nutdrv_qx.c Err on the safer side of + changing behavior for non-hunnox device support, limit the + applicability of langid_fix (per PR #638 review cautionary + comments). Maybe the proposed original change did apply to other + devices that support the fix-up, but that should be evaluated + separately and this new constraint reversed if needed. + * drivers/nutdrv_qx_hunnox.c: Update nutdrv_qx_hunnox.c Updated file + heading + * drivers/nutdrv_qx_hunnox.h: Update nutdrv_qx_hunnox.h Updated file + heading + +2021-04-10 Jim Klimov + + * docs/images/advanced.png, docs/images/bizarre.png: Vox populi: + replace master by primary and slave by secondary in documentation + images [#840] + +2021-04-09 Jim Klimov + + * docs/images/ci/fosshost.org_Host_Dark_56px.png, + docs/images/ci/jenkins-nut-large-256px.png, docs/images/ci/jenkins- + nut-large-squared.png, docs/images/ci/jenkins-nut-large.pdn, + docs/images/ci/jenkins-nut-large.png, docs/images/ci/jenkins-nut- + small-256px.png, docs/images/ci/jenkins-nut-small.pdn, + docs/images/ci/jenkins-nut-small.png, docs/images/ci/jenkins-nut- + squared.png, docs/images/ci/jenkins-nut-transparent-bg-40px.png, + docs/images/ci/jenkins-nut-transparent-bg.png, + docs/images/ci/jenkins-nut.css, docs/images/ci/jenkins-nut.png, + docs/images/ci/jenkins-nut.txt: Add image and CSS resources used in + new Jenkins CI [#869] + +2021-04-09 Jim Klimov + + * docs/nut.dict: Update nut.dict Missed a couple of new dictionary + words + +2021-04-09 Alexey Kazancev + + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: add overflows protection + for snr subdriver + +2021-04-09 Jim Klimov + + * docs/nut.dict: Update nut.dict Added "snr" and "SNR" to + spellchecker dictionary + +2021-04-09 Alexey Kazancev + + * docs/acknowledgements.txt: docs/acknowledgements.txt: add NAG at + manufacturer list + * data/driver.list.in: data/driver.list.in: add various SNR-UPS-LID- + XXXX UPSes supported by nutdrv_qx Protocol: 'megatec' USB + subdriver: 'snr' + * docs/man/nutdrv_qx.txt: docs/man/nutdrv_qx.txt: update man page for + new 'snr' USB subdriver + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: add new 'snr' USB + subdriver to support SNR-UPS-LID units + +2021-04-08 Jim Klimov + + * docs/man/Makefile.am: Update Makefile.am Beside exactly "troff" + some systems have other "*roff" family tools and formats + +2021-04-07 Jim Klimov + + * configure.ac: configure.ac: satisfy both builders that have pkg- + config installed and those who do not + * configure.ac: configure.ac: avoid syntax errors if pkg-config is + not installed + +2021-04-06 Aaron Thompson + + * drivers/powercom.c: drivers/powercom.c: Fix a small error in output + voltage for KIN models. + +2021-03-31 Jim Klimov + + * drivers/dstate.c: drivers/dstate.c: protect failsafe logic from + compiler warnings with pragmas + +2021-03-30 Jim Klimov + + * drivers/dstate.c: drivers/dstate.c: alarm_set(): stretch slightly + absurd ways to avoid overflow and fix signed/unsigned mismatch + (follow up for #986) + * configure.ac: configure.ac: add --enable-cppunit to allow disabling + it even if deemed supported by compiler Practice shows that + libcppunit.so may be linked against a different compiler version + and/or libc than the one used for current NUT build. While formal + support checked by the script works, practical build fails. + * NEWS: NEWS: Reflect terminology change for upsmon + +2021-03-29 Jim Klimov + + * clients/upsmon.c: clients/upsmon.c: rename static functions + slavesync() => sync_secondaries() and checkmaster() => + apply_for_primary() and document them better + * README, clients/nutclient.cpp, clients/nutclient.h, + clients/upsmon.c, clients/upsmon.h, conf/ups.conf.sample, + conf/upsd.users.sample, conf/upsmon.conf.sample.in, docs/config- + notes.txt, docs/design.txt, docs/features.txt, docs/history.txt, + docs/man/clone.txt, docs/man/genericups.txt, + docs/man/libnutclient_misc.txt, docs/man/nut.conf.txt, + docs/man/nutdrv_atcl_usb.txt, docs/man/richcomm_usb.txt, + docs/man/upsd.txt, docs/man/upsd.users.txt, + docs/man/upsmon.conf.txt, docs/man/upsmon.txt, docs/net- + protocol.txt, docs/new-drivers.txt, docs/scheduling.txt, + docs/security.txt, drivers/optiups.c, scripts/augeas/README, + scripts/augeas/nutupsdusers.aug.in, + scripts/augeas/tests/test_nut.aug, scripts/perl/Nut.pm, + scripts/python/module/PyNUT.py, server/netcmds.h, server/netuser.c, + server/netuser.h, server/user.c: Vox populi: replace manager/master + by primary and subordinate/slave by secondary + * scripts/python/app/README: scripts/python/app/README: typo fix + * docs/man/libnutclient_misc.txt: docs/man/libnutclient_misc.txt: fix + English wording a bit + * docs/nut.dict: docs/nut.dict: update word-count after large docs + update + +2021-03-27 orbea + + * drivers/Makefile.am: drivers: Fix undefined references with + slibtool. + +2021-03-26 Arnaud Quette + + * scripts/upower/95-upower-hid.rules: Revert "95-upower-hid.rules + script updated" This reverts commit + 262c23c6b8f1368165c75a0df317b1ba9ff5c511. + +2021-03-26 Jim Klimov + + * tools/nut-snmpinfo.py: Update nut-snmpinfo.py Also handle the `//` + comments same way as `/*...` + +2021-03-25 Arnaud Quette + + * tools/nut-snmpinfo.py: nut-scanner: improve SNMP extractor script + Also remove EOL comments + +2021-03-24 Jim Klimov + + * drivers/bestups.c, drivers/blazer.c, drivers/blazer.h, + drivers/blazer_ser.c, drivers/blazer_usb.c: bestups, blazer* driver + sources: add obsoletion notices on top, in favor of nutdrv_qx + drivers + * tools/nut-usbinfo.pl: tools/nut-usbinfo.pl: allow to trace USB + driver conflicts (e.g. obsoleted and new handlers of same + vendor/product IDs) + +2021-03-23 Ygor Amadeo Sartori Regados + + * drivers/microsol-apc.c, drivers/microsol-apc.h, drivers/microsol- + common.c, drivers/microsol-common.h: Bug fix: battery charge + calculation + +2021-03-23 Jim Klimov + + * ci_build.sh: ci_build.sh: make GitIgnores failure fatal (and report + what the difference is, for tracked and regenerated files) + * tests/.gitignore: GitIgnore tests/nutlogtest binary + * ci_build.sh: ci_build.sh: make GitIgnores failure fatal + +2021-03-23 Degott, Francois Regis + + * scripts/upower/95-upower-hid.rules: 95-upower-hid.rules script + updated + +2021-03-23 Ygor Amadeo Sartori Regados + + * drivers/microsol-common.c: Bug fix: Handle packet boundary + desynchronization + +2021-03-23 Degott, Francois Regis + + * scripts/upower/95-upower-hid.rules: 95-upower-hid.rules script + updated + * drivers/Makefile.am, drivers/eaton-ats16-nm2-mib.c, .../{eaton- + ats16-mib.h => eaton-ats16-nm2-mib.h}, .../{eaton-ats16-mib.c => + eaton-ats16-nmc-mib.c}, drivers/eaton-ats16-nmc-mib.h, + drivers/snmp-ups.c: improve support of EATON ATS16 NMC/NM2 + +2021-03-21 Ygor Amadeo Sartori Regados + + * drivers/microsol-apc.c: Fixed missing calculation part for BZ1500 + Bug identified with data provided on issue #697 + * drivers/microsol-common.c: CI fix: C89 compilation fixed + * drivers/Makefile.am: Missing header fixed + * drivers/Makefile.am: CI error fix: missing header file + +2021-03-19 Ygor Amadeo Sartori Regados + + * drivers/microsol-common.c, drivers/microsol-common.h: Fixed LGTM + alert about localtime_r Also passed microsol-common.c through + indent + * drivers/Makefile.am, drivers/microsol-apc.c, drivers/microsol- + apc.h, drivers/microsol-common.c, drivers/microsol-common.h: New + driver: microsol-apc Derived from solis driver, for newer APC + Back-UPS BR hardware. Support added for APC Back-UPS BZ1500, + BZ2200BI and BZ2200I. Tested on BZ2200BI. Created common file that + may be used on solis as well. + +2021-03-14 JungEon Kim + + * data/driver.list.in: Add Delta UPS Amplon R Series in drivers.list + +2021-03-14 Jim Klimov + + * drivers/dstate.c: drivers/dstate.c: alarm_set(): at least log the + truncated buf if it does not fit into dstate field + +2021-03-13 Jim Klimov + + * docs/developers.txt: docs/developers.txt: replace "master" where it + is easy, and update some recommendations + * clients/upsmon.c: clients/upsmon.c: comment that also several NUT + drivers can directly set FSD flag propagated from the smarter power + devices + * docs/security.txt: docs/security.txt: extend the Firewall section + for more considerations + * docs/man/upsmon.txt: docs/man/upsmon.txt: suggestions for + experiments about timing the shutdown vs. dummy SHUTDOWNCMD to + check the skeleton logic + * docs/man/upsmon.conf.txt: docs/man/upsmon.conf.txt: extend the + example for "bigserver" with manager vs subordinate upsmon's + * docs/history.txt: docs/history.txt: reflect that slave/master terms + were deprecated + * README: README: Make note of UPSes which allow multiple managerial + accesses + * clients/nutclient.cpp, clients/nutclient.h, clients/upsmon.c, + docs/net-protocol.txt, scripts/perl/Nut.pm, + scripts/python/module/PyNUT.py, server/netcmds.h, server/netuser.c, + server/netuser.h, server/user.c: Identify points in source code + (and few related docs) for deprecating master|slave terminology + * README, clients/upsmon.c, clients/upsmon.h, conf/ups.conf.sample, + conf/upsd.users.sample, conf/upsmon.conf.sample.in, docs/config- + notes.txt, docs/design.txt, docs/features.txt, docs/man/clone.txt, + docs/man/genericups.txt, docs/man/libnutclient_misc.txt, + docs/man/nut.conf.txt, docs/man/nutdrv_atcl_usb.txt, + docs/man/richcomm_usb.txt, docs/man/upsd.txt, + docs/man/upsd.users.txt, docs/man/upsmon.conf.txt, + docs/man/upsmon.txt, docs/net-protocol.txt, docs/new-drivers.txt, + docs/nut.dict, docs/scheduling.txt, docs/security.txt, + drivers/optiups.c, scripts/augeas/README, + scripts/augeas/nutupsdusers.aug.in, + scripts/augeas/tests/test_nut.aug, scripts/perl/Nut.pm, + server/user.c: Update documentation, emitted messages and easy-to- + fix code to rename master=>manager and slave=>subordinate + * docs/man/upsmon.txt: docs/man/upsmon.txt: suggestions for + experiments about timing the shutdown vs. dummy SHUTDOWNCMD to + check the skeleton logic + * docs/security.txt: docs/security.txt: extend the Firewall section + for more considerations + * docs/security.txt: docs/security.txt: reword one shade of "master" + * docs/solaris-usb.txt: docs/solaris-usb.txt: reword one shade of + "master" + * drivers/asem.c: drivers/asem.c: clarify the use of "S" word + * drivers/phoenixcontact_modbus.c: drivers/phoenixcontact_modbus.c: + clarify the use of "S" word + * drivers/nutdrv_qx.c, drivers/usbhid-ups.c: drivers/nutdrv_qx.c & + usbhid-ups.c: reword "Reference list of..." + * clients/upsmon.c, docs/net-protocol.txt: docs/net-protocol.txt + + upsmon.c: comment that also several NUT drivers can directly set + FSD flag propagated from the smarter power devices + * conf/upsmon.conf.sample.in: conf/upsmon.conf.sample.in: note that + systems should only shutdown when less than MINSUPPLIES PSUs are + non-critical + * conf/upsmon.conf.sample.in: conf/upsmon.conf.sample.in: note about + UPSes with manageable thresholds for critical state + * conf/upsmon.conf.sample.in: conf/upsmon.conf.sample.in: note that + rack shutdowns can compete for I/O and take longer + * conf/upsmon.conf.sample.in: conf/upsmon.conf.sample.in: generalize + the example about multi-PSU servers + * docs/config-notes.txt: docs/config-notes.txt: update the example + about multi-PSU servers + +2021-03-13 JungEon Kim + + * drivers/Makefile.am, drivers/delta_ups-hid.c, drivers/delta_ups- + hid.h, drivers/usbhid-ups.c: delta_ups-hid: Add support for Delta + UPS Amplon R Series + +2021-03-13 Jim Klimov + + * docs/config-notes.txt: docs/config-notes.txt: note about upsmon + with 0 PSUs for just-monitoring + * data/html/header.html.in, docs/cables/apc-rs500-serial.txt, + docs/cables/ge-imv-victron.txt, docs/cables/powerware.txt, + docs/cables/repotec.txt, docs/cables/sms.txt, docs/man/apcsmart- + old.txt, docs/man/apcsmart.txt, docs/man/asem.txt, + docs/man/bcmxcp.txt, docs/man/bcmxcp_usb.txt, docs/man/belkin.txt, + docs/man/belkinunv.txt, docs/man/bestfcom.txt, + docs/man/bestuferrups.txt, docs/man/bestups.txt, + docs/man/everups.txt, docs/man/genericups.txt, docs/man/index.txt, + docs/man/libnutclient_misc.txt, docs/man/libnutclient_tcp.txt, + docs/man/libupsclient-config.txt, docs/man/liebert-esp2.txt, + docs/man/metasys.txt, docs/man/mge-shut.txt, docs/man/mge- + utalk.txt, docs/man/nut-driver-enumerator.txt, docs/man/nut- + ipmipsu.txt, docs/man/nut-scanner.txt, + docs/man/nutdrv_atcl_usb.txt, + docs/man/nutscan_add_device_to_device.txt, + docs/man/nutscan_add_option_to_device.txt, + docs/man/nutscan_cidr_to_ip.txt, + docs/man/nutscan_display_parsable.txt, + docs/man/nutscan_display_ups_conf.txt, + docs/man/nutscan_free_device.txt, + docs/man/nutscan_get_serial_ports_list.txt, + docs/man/nutscan_init.txt, docs/man/nutscan_new_device.txt, + docs/man/nutscan_scan_avahi.txt, + docs/man/nutscan_scan_eaton_serial.txt, + docs/man/nutscan_scan_ipmi.txt, docs/man/nutscan_scan_nut.txt, + docs/man/nutscan_scan_snmp.txt, docs/man/nutscan_scan_usb.txt, + docs/man/nutscan_scan_xml_http.txt, docs/man/oneac.txt, + docs/man/optiups.txt, docs/man/phoenixcontact_modbus.txt, + docs/man/powercom.txt, docs/man/powerman-pdu.txt, + docs/man/rhino.txt, docs/man/richcomm_usb.txt, + docs/man/riello_ser.txt, docs/man/riello_usb.txt, + docs/man/skel.txt, docs/man/solis.txt, docs/man/tripplite.txt, + docs/man/ups.conf.txt, docs/man/upscli_add_host_cert.txt, + docs/man/upscli_connect.txt, docs/man/upscli_disconnect.txt, + docs/man/upscli_get.txt, docs/man/upscli_init.txt, + docs/man/upscli_splitaddr.txt, docs/man/upscli_splitname.txt, + docs/man/upscli_upserror.txt, docs/man/upsclient.txt, + docs/man/upscmd.txt, docs/man/upsd.conf.txt, docs/man/upsd.txt, + docs/man/upsd.users.txt, docs/man/upsdrvctl.txt, + docs/man/upsdrvsvcctl.txt, docs/man/upslog.txt, + docs/man/upsmon.conf.txt, docs/man/upsmon.txt, docs/man/upsrw.txt, + docs/man/upssched.txt, docs/man/upsset.cgi.txt, + docs/man/upsset.conf.txt, docs/man/upsstats.html.txt, + docs/man/usbhid-ups.txt, docs/man/victronups.txt: docs: fix some + trailing whitespaces + +2021-03-12 Jim Klimov + + * drivers/dstate.c: drivers/dstate.c: limit alarm_buf string to fit + into a dstate info status, and log errors and overflows from + alarm_set() [issue #960] + +2021-03-02 Edgar Fuß + + * docs/man/blazer-common.txt, docs/man/nutdrv_qx.txt, + docs/man/tripplite_usb.txt, docs/man/usbhid-ups.txt: Add a remark + that USB device numbers may be unstable In the documentation of + the USB device number matching, add a remark that device numbers + need not to be stable across re-boots or when re-plugging the + device. + * drivers/usb-common.c: USB device matching: add debug messages on + non-match When failing to match the Device part, note this via + upsdebugx() just like when not matching any other part (VendorId, + ProductId, Bus, etc.). + +2021-03-02 Jim Klimov + + * docs/man/nutdrv_qx.txt: Update nutdrv_qx.txt Fixed typo in a new + masterguard paragraph + +2021-02-12 Edgar Fuß + + * tools/nut-usbinfo.pl: Fix VendorID/ProductID matching In a line + like { USB_DEVICE(0x06da, 0x0002), "Phoenixtec Power","USB Cable + (V2.00)", &phoenixtec_subdriver },/* Masterguard A Series */ don't + match ProductID up to the closing parenthesis in the product name + string. + +2021-02-11 Edgar Fuß + + * docs/man/masterguard.txt, docs/man/nutdrv_qx.txt, docs/nutdrv_qx- + subdrivers.txt, drivers/Makefile.am, drivers/nutdrv_qx.c, + drivers/nutdrv_qx_masterguard.c, drivers/nutdrv_qx_masterguard.h: + Add Masterguard A/E driver based on Q* framework Add a new driver + for Masterguard A and E series based on the Q* framework + (nutdrv_qx). Based on vendor documentation of both the command set + and USB protocol I was both asked not to disclose. Supports "new" + A700/1000/2000/3000(-19) and E40/60/100(-19) (totally untested due + to lack of hardware). Still sort of work in progress due to some + open questions on NUT integration. + * docs/man/blazer-common.txt, docs/man/nutdrv_qx.txt, + docs/man/tripplite_usb.txt, docs/man/usbhid-ups.txt, + drivers/blazer_usb.c, drivers/libusb.c, drivers/nutdrv_qx.c, + drivers/riello_usb.c, drivers/tripplite_usb.c, drivers/usb- + common.c, drivers/usb-common.h, drivers/usbhid-ups.c: Add USB + device number matching Extend the USB matching by a device number + (in addition to the existing bus number) by adding a Device field + to USBDevice_[st] and ammending the RegExp by a seventh field. + Maybe some #defines for the magical constants would be appropriate. + Add DEBUG_EXACT_MATCH_DEVICE analogous to DEBUG_EXACT_MATCH_BUS, + whatever its intended usage is. Document the device field where + the bus field was documented (which is not the case everywhere it's + actually used). + +2021-01-31 TJ McConnell + + * drivers/tripplite-hid.c: Move 0x3024 alphabetically. Add comment + about new version + +2021-01-26 Arnaud Quette + + * drivers/eaton-pdu-marlin-mib.c: snmp-ups: fix regression on Eaton + ePDU Fix a regression that caused a mis-determination of the SNMP + base OID index (0 or 1, should be 1). This in turn caused a mis- + iteration over the outlets, from 0 to N-1 instead of 1 to N, which + resulted in the missing Nth outlet (last outlet of the PDU). This + also caused some data refresh issues + +2021-01-23 Yifeng Li + + * drivers/main.c: main.c: write upsdrv_initinfo/updateinfo() logs to + syslog When a NUT driver is started (via upsdrvctl start), it runs + the following sequence: 1. Run as a foreground process. 2. Do some + basic initialization, log to stderr. 3. If not debugging: - fork() + - Run as a daemon, stderr off, syslog on. The problem, however, is + that upsdrv_initinfo() and updateinfo() are first called before + forking, as a result, the log messages is only sent to stderr, not + syslog. On a traditional init + syslog server setup, those startup + messages are lost. However, those lost messages can be urgent - for + example, it can be a warning about a failed UPS inverter. If the + server is freshly started, the admin may miss them until much + later, or keep staring at the mysterious alarm word without finding + anything relevant in syslog. Similarly, other types of warnings, + such as a rounded ondelay value, should also be visible in syslog. + This patch checks the debugging flags and turn on syslog earlier + when it's in non-debug, non-fork mode, allowing the logs during + upsdrv_initinfo() and upsdrv_updateinfo() to be recorded in syslog. + Mailing list discussion: https://alioth- + lists.debian.net/pipermail/nut-upsdev/2021-January/007508.html + +2021-01-23 TJ McConnell + + * drivers/tripplite-hid.c, scripts/upower/95-upower-hid.rules: Add + AVR750U (0x3024). Use smart1500lcdt_scale for + voltage/current/frequence + +2021-01-20 Jim Klimov + + * drivers/delta_ups-mib.c: delta-mib.c: rename onbatt_info lookup + table in commented-away code sample + * drivers/huawei-mib.c: huawei-mib.c: rename onbatt_info lookup table + in commented-away code sample + * drivers/xppc-mib.c: xppc-mib.c: rename onbatt_info lookup table in + commented-away code sample + +2016-05-25 Jim Klimov + + * drivers/raritan-px2-mib.c: raritan-px2-mib - renamed lookups to + have "raritanpx2_*" prefix + * drivers/raritan-pdu-mib.c: raritan-pdu-mib - renamed lookups to + have "raritan_pdu_*" prefix + * drivers/powerware-mib.c: powerware-mib - renamed "ietf_*" and + "eaton_*" lookups to have "pw_*" prefix + +2016-05-23 Jim Klimov + + * drivers/mge-mib.c: mge-mib.c : rename rogue ietf_* lookups to mge_* + +2016-05-25 Jim Klimov + + * drivers/baytech-mib.c: baytech-mib - renamed "outlet_status_info" + lookup to "baytech_outlet_status_info" + * drivers/apc-ats-mib.c: apc-ats-mib.c- renamed "ats_*" lookups to + "apc_ats_*" + +2021-01-08 Arnaud Quette + + * drivers/snmp-ups.c: snmp-ups: fix instant commands using numeric + parameters Instant commands using numeric parameters, like + on/off/cycle commands, were failing due to a bad value submitted + type (time instead of integer) Cherry-picked from + https://github.com/42ity/nut/pull/120 + +2020-12-29 Steve Magoun + + * drivers/macosx-ups.c: drivers/macosx-ups.c: Add ups.mfr and + ups.model legacy vars, fixes #949 + +2020-12-29 Jim Klimov + + * ci_build.sh: ci_build.sh: allow CI workers to say if they have + functional libgd (for the current compiler/ABI version) so whether + it should not be required + +2020-12-28 Jim Klimov + + * ci_build.sh: ci_build.sh: treat helper dirs (tmp/ .inst/ + CCACHE_DIR/) correctly even if named FS objects are symlinks to + dirs + * docs/Makefile.am, docs/man/Makefile.am: docs/{man/,}Makefile.am: + parameterize EGREP and call "file" sanity checks case-insensitive + * m4/nut_compiler_family.m4: m4/nut_compiler_family.m4: detect Apple + LLVM as CLANG + +2020-12-27 Jim Klimov + + * configure.ac, docs/developers.txt: configure.ac + docs/developers.txt: add a "medium" warning pre-set difficulty + level + * configure.ac: configure.ac: document the choice rationale of no- + warning macros + * docs/developers.txt, docs/nut.dict: docs/developers.txt: document + the new --enable-warnings options + * configure.ac: configure.ac: define a clang-minimal warning preset + that our codebase already survives + * .travis.yml, configure.ac: Move comment about clang no-warning + selection from .travis.yml to configure.ac + * .travis.yml: .travis.yml: make use of BUILD_WARNFATAL=yes + BUILD_WARNOPT=hard to simplify the test setup specifications + +2020-12-26 Jim Klimov + + * configure.ac: configure.ac: hush clang warnings about nullptr in + C++ code (c++98 not compatible)) + * configure.ac: configure.ac: provide a hidden "gcc-legacy" warnings + option to cover previous behavior + * ci_build.sh: ci_build.sh: allow passing --enable-warnings=... and + --enable-Werror=... args via BUILD_WARNOPT and BUILD_WARNFATAL + envvars + * configure.ac: configure.ac: implement --enable-warnings=... and + --enable-Werror(=yes/no) to specify the presets we require to pass + * m4/nut_arg_with.m4: m4/nut_arg_with.m4: add NUT_ARG_ENABLE and + document the difference vs NUT_ARG_WITH + * ci_build.sh: ci_build.sh: support passing BUILD_SSL_ONCE=true to + only try whichever SSL implem is found, not both even if installed + * autogen.sh: autogen.sh: shell-check that generated configure script + is syntactically valid + * m4/nut_compiler_family.m4: m4/nut_compiler_family.m4: fix tracking + nut_cv_CLANGCC and determining CLANGCC=yes + * drivers/apcsmart.c, drivers/apcsmart.h: drivers/apcsmart.{c,h}: + drop custom debx()/logx()/fatx()/fate() macros in favor of NUT- + standard ones + +2020-12-02 Jim Klimov + + * drivers/bcmxcp.c: drivers/bcmxcp.c: fix a few whitespaces + (indentation) + +2020-12-07 Jim Klimov + + * drivers/libusb.c: drivers/libusb.c: fix whitespace + +2020-12-25 Jim Klimov + + * common/common.c: common/common.c: fix initialization of a struct + timeval (initialize all fields) + * drivers/eaton-pdu-marlin-mib.c: drivers/eaton-pdu-marlin-mib.c: fix + initialization of a info_lkp_t (initialize all fields) + * drivers/al175.c: drivers/al175.c: assert incoming numbers, error- + check the sprintf() result, and comment why + * drivers/blazer_usb.c, drivers/nutdrv_qx.c: nutdrv_qx blazer_usb: + report acceptable subdriver names in help() + +2020-12-25 Jim Klimov + + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: + match_function_subdriver(): upsdebugx() device matching faults to + help troubleshoot driver setups + +2020-12-24 Jim Klimov + + * drivers/usb-common.c: usb-common.c: upsdebugx() device matching + faults to help troubleshoot driver setups + +2020-12-25 Jim Klimov + + * drivers/bcmxcp_ser.c: drivers/bcmxcp_ser.c: add comment for per- + warning pragma naming + * drivers/bcmxcp_ser.c: drivers/bcmxcp_ser.c: fix wrong long macro + name typo, for the pragmas gating + * drivers/bcmxcp_ser.c: drivers/bcmxcp_ser.h: #include + (lost in cherrypick web) + * docs/nut.dict: docs/nut.dict: add Evgeny + * docs/nut.dict: docs/nut.dict: add maintainership + * drivers/bcmxcp_ser.c: drivers/bcmxcp_ser.c: fix nesting of macros + for pragmas + * drivers/bcmxcp_ser.c: drivers/bcmxcp_ser.c: use HAVE_PRAGMAS_FOR_GC + C_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: introduce HAVE_PRAGMAS_FOR_ + GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE + (equivalent of HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS on + some compilers) + * drivers/bcmxcp_ser.c: drivers/bcmxcp_ser.c: comment in/out function + contexts for the pragma + * drivers/bcmxcp_ser.c: drivers/bcmxcp_ser.c: do macro magic for + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC working + with older compilers + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: separate the support for + #pragma GCC diagnostic... inside vs outside function bodies + (gcc-4.4 and older are upset about "inside" case) + * drivers/bcmxcp_ser.c: drivers/bcmxcp_ser.c: cast type for printing + speed_t on different OSes + +2020-12-07 Jim Klimov + + * drivers/bcmxcp_ser.c, drivers/bcmxcp_ser.h: + drivers/bcmxcp_ser.{c,h}: get_answer(): fix baud rate processing + into speed_t and size_t + +2020-12-23 Jim Klimov + + * docs/user-manual.txt: docs/user-manual.txt: small typo fix + * docs/nut.dict: nut.dict: update with project names that nut-website + spellchecking prefers to know + * docs/nut.dict: nut.dict: update with project names that nut-website + spellchecking prefers to know + * docs/nut.dict: nut.dict: update with project names that nut-website + spellchecking prefers to know + +2020-12-21 Jim Klimov + + * docs/acknowledgements.txt: docs/acknowledgements.txt: update + persons currently involved, new maintainer https://alioth- + lists.debian.net/pipermail/nut-upsdev/2020-November/007494.html + +2020-12-15 Bi11 + + * drivers/snmp-ups.c, tools/nut-scanner/scan_snmp.c: Fix incorrect + fatal message for privProtocol + * tools/nut-scanner/scan_snmp.c: Fix incorrect usmAESPrivProtocol + import in nut-scanner In libnetsnmp, usmAES128PrivProtocol is a + pointer, while usmAESPrivProtocol is an array. This change is the + same as in c7cf507454bcf6f40b24b58e61c130c7772c5bf2. + +2020-12-15 Arnaud Quette + + * drivers/eaton-pdu-marlin-mib.c: snmp-ups: Restore legacy Eaton ePDU + switchability info Use a hack to also have switchability for both + the unit and its outlets on legacy Eaton G2 ePDU Partially + cherry-picked from 42ity fork, and bumped to their faster moving + MIB mapping revision number. See + https://github.com/42ity/nut/pull/118 As for the behavior of the + fix: * on G2, the first outlet.switchable doesn't exist, so try + the 2nd, which is the ugly hack: try on the first outlet to see if + switchable * on G3, the first is good, so flag unique does the + rest Tested on MA G2 and G3. + +2020-11-30 Jim Klimov + + * drivers/dummy-ups.c: drivers/dummy-ups.c: use size_t where it + should be, for numargs-related parsing + * clients/upsclient.c: clients/upsclient.c: use size_t where it + should be, for numargs parsing + * server/netcmds.h, server/netget.c, server/netget.h, + server/netinstcmd.c, server/netinstcmd.h, server/netlist.c, + server/netlist.h, server/netmisc.c, server/netmisc.h, + server/netset.c, server/netset.h, server/netssl.c, server/netssl.h, + server/netuser.c, server/netuser.h, server/upsd.c, server/user.c: + server/*: numerous upsd commands: use size_t where it should be, + for numargs parsing + * server/sockdebug.c: server/sockdebug.c: use (and print) size_t + where it should be, for numargs parsing + * drivers/dstate.c: drivers/dstate.c: use size_t where it should be, + for numargs parsing + * clients/upssched.c: clients/upssched.c: use (and print) size_t + where it should be, for numargs parsing + * clients/upsmon.c: clients/upsmon.c: use size_t where it should be, + for numargs parsing + * clients/upsset.c: clients/upsset.c: use size_t where it should be, + for numargs parsing + * server/conf.c: server/conf.c: use size_t where it should be, for + numargs parsing + * drivers/snmp-ups.c: drivers/snmp-ups.c: whitespace fix + * drivers/snmp-ups.c: drivers/snmp-ups.c: use size_t where it should + be, for numargs parsing + * common/state.c, include/state.h, server/sstate.c: common and server + state.c: use size_t where it should be, for numargs and numflags + parsing + * drivers/clone-outlet.c: drivers/clone-outlet.c: use size_t where it + should be, for numargs parsing + * drivers/clone.c: drivers/clone.c: use size_t where it should be, + for numargs parsing + * server/netssl.c: server/netssl.c: avoid implicit size_t (arch- + dependent) vs. PRInt32 (Mozilla NSS) integer conversion + * clients/upsclient.c: clients/upsclient.c: avoid implicit size_t + (arch-dependent) vs. PRInt32 (Mozilla NSS) integer conversion + +2020-12-02 Jim Klimov + + * drivers/solis.c: Update solis.c Shuffle the comparison in the if- + clause to certainly bail out if we did not read from the port. + +2020-11-30 Jim Klimov + + * drivers/bestfortress.c: drivers/bestfortress.c: fix up int types to + avoid implicit conversions, and pre-initialize to avoid + uninitialized use + * drivers/nut-libfreeipmi.c: drivers/nut-libfreeipmi.c: initialize + variable to avoid potential uninitialized use + * drivers/blazer.c: drivers/blazer.c: initialize variable to avoid + potential uninitialized use and convey an error if that happens + * drivers/powerpanel.c: drivers/powerpanel.c: initialize variable to + avoid potential uninitialized use and convey an error if that + happens + * drivers/solis.c: drivers/solis.c: initialize variable to avoid + potential uninitialized use and convey an error if that happens + * drivers/rhino.c: drivers/rhino.c: initialize variable to avoid + potential uninitialized use and convey an error if that happens + * drivers/bestfortress.c: drivers/bestfortress.c: initialize + variables to avoid potential uninitialized use and null-pointer + dereference if data processing fails + +2020-12-02 Jim Klimov + + * include/nut_float.h: Update nut_float.h Consider equality to + epsilon to be also treated as zero + * include/nut_float.h: Update nut_float.h Fix copyright line + +2020-11-30 Jim Klimov + + * drivers/cps-hid.c: drivers/cps-hid.c: employ nut_float.h for safer + floating point comparisons + * drivers/snmp-ups.c: drivers/snmp-ups.c: employ nut_float.h for + safer floating point comparisons + * drivers/nutdrv_qx_voltronic.c: drivers/nutdrv_qx_voltronic.c: + employ nut_float.h for safer floating point comparisons + * drivers/nutdrv_qx_bestups.c: drivers/nutdrv_qx_bestups.c: employ + nut_float.h for safer floating point comparisons + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: employ nut_float.h for + safer floating point comparisons + * drivers/blazer.c: drivers/blazer.c: employ nut_float.h for safer + floating point comparisons + * drivers/upscode2.c: drivers/upscode2.c: employ nut_float.h for + safer floating point comparisons + * drivers/solis.c: drivers/solis.c: employ nut_float.h for safer + floating point comparisons + * drivers/rhino.c: drivers/rhino.c: employ nut_float.h for safer + floating point comparisons + * drivers/metasys.c: drivers/metasys.c: employ nut_float.h for safer + floating point comparisons + * drivers/mge-hid.c: drivers/mge-hid.c: employ nut_float.h for safer + floating point comparisons + * configure.ac, include/Makefile.am, include/nut_float.h: Introduce + nut_float.h and check more carefully for presence of math.h and/or + float.h in the build system + * drivers/tripplitesu.c: drivers/tripplitesu.c: avoid "bad function + cast" by casting explicitly the return value of the function + * drivers/tripplite.c: drivers/tripplite.c: avoid "bad function cast" + by casting explicitly the return value of the function + * drivers/mge-xml.c: drivers/mge-xml.c: avoid "bad function cast" by + casting explicitly the return value of the function + * drivers/bestfortress.c: drivers/bestfortress.c: avoid "bad function + cast" by casting explicitly the return value of the function + * drivers/snmp-ups.c: drivers/snmp-ups.c: fix snprintf() target + buffer size from bogus sizeof() determination (#926) + +2020-11-29 Jim Klimov + + * drivers/nutdrv_atcl_usb.c: drivers/nutdrv_atcl_usb.c: fix const + qualifier usage + * drivers/snmp-ups.c: drivers/snmp-ups.c: fix const qualifier usage + * drivers/snmp-ups.h: drivers/snmp-ups.h: remove const qualifiers + from strings in snmp_info_t, we have code that writes into them + * drivers/dstate.c: drivers/dstate.c: dstate_tree_dump(): fix const + qualifier usage + * drivers/bestfcom.c: drivers/bestfcom.c: avoid "bad function cast" + by casting explicitly the return value of the function + * drivers/libshut.c: drivers/libshut.c: avoid alignment issues with + buffer used actually for different variable types + * tools/nut-scanner/nutscan-ip.c: tools/nut-scanner/nutscan-ip.c: use + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN to quiesce warnings + about a value we anyway receive a pointer to + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: introduce + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN + +2020-11-25 Jim Klimov + + * drivers/solis.c: drivers/solis.c: avoid variable-length arrays, + their support became optional after C99 + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: avoid variable-length + arrays, their support became optional after C99 + * drivers/apcsmart.c: drivers/apcsmart.c: avoid variable-length + arrays, their support became optional after C99 + * drivers/rhino.c: drivers/rhino.c: upsdrv_shutdown(): use sendshut() + * drivers/rhino.c: drivers/rhino.c: sendshut(): handle negative + returns from send_command() + * drivers/rhino.c: drivers/rhino.c: fix mismatched signedness in + comparison + * drivers/rhino.c: drivers/rhino.c: avoid variable-length arrays, + their support became optional after C99 + +2020-11-29 Jim Klimov + + * server/sstate.c: server/sstate.c: sstate_dead(): do not shadow + global varname "maxage" with same-named func argument + * drivers/snmp-ups.c: drivers/snmp-ups.c: su_ups_get(): do not shadow + function-scope varname "value" with temporary-scope namesake + * drivers/snmp-ups.c: drivers/snmp-ups.c: snmp_ups_walk(): do not + shadow global varnames "(input|output|bypass)_phases" with same- + named func local variables + * drivers/upscode2.c: drivers/upscode2.c: check_uppm(): do not shadow + function-scope varname "val" with temporary-scope namesake + * drivers/libhid.c: drivers/libhid.c: new_report_buffer(): do not + shadow global varname "pDesc" with same-named func argument + * drivers/libshut.c: drivers/libshut.c: do not shadow global varnames + "upsfd" and "device_path" with same-named func arguments in + numerous routines + * drivers/dummy-ups.c: drivers/dummy-ups.c: parse_data_file(): do not + shadow global varname "upsfd" with same-named func argument (unused + for good measure) + * clients/upsset.c: clients/upsset.c: print_rw(): do not shadow + global varname "upsname" with same-named func argument + * drivers/riello_usb.c: drivers/riello_usb.c: fix array initializers + for sentinel entries + * drivers/blazer_usb.c: drivers/blazer_usb.c: fix array initializers + for sentinel entries + * drivers/nutdrv_qx_voltronic.c: drivers/nutdrv_qx_voltronic.c: fix + array initializers for sentinel entries + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: fix array initializers + for sentinel entries + * drivers/apcsmart_tabs.c: drivers/apcsmart_tabs.c: fix array + initializers for sentinel entries + * drivers/apcsmart_tabs.c: drivers/apcsmart_tabs.c: fix numeric 0 + into pointer NULL + * drivers/apcsmart.c: drivers/apcsmart.c: fix array initializers for + sentinel entries + * drivers/blazer_ser.c: drivers/blazer_ser.c: fix array initializers + for sentinel entries + * drivers/blazer.c: drivers/blazer.c: fix array initializers for + sentinel entries + * drivers/powerp-txt.c: drivers/powerp-txt.c: fix array initializers + for sentinel entries + * drivers/powerp-bin.c: drivers/powerp-bin.c: fix array initializers + for sentinel entries + * drivers/mge-hid.c: drivers/mge-hid.c: fix array initializers for + sentinel entries + * drivers/liebert-esp2.c: drivers/liebert-esp2.c: upsdrv_initinfo(): + fix array initializer; small whitespace clean-up + * server/upsd.c: server/upsd.c: use + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT to + reinforce the defensive programming patterns + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: use + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT to + reinforce the defensive programming patterns + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: use + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT to + reinforce the defensive programming patterns + * drivers/powerp-bin.c: drivers/powerp-bin.c: use + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT to + reinforce the defensive programming patterns + * drivers/upscode2.c: drivers/upscode2.c: use + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT to + reinforce the defensive programming patterns + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: use + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT to + reinforce the defensive programming patterns + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: introduce + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: introduce + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: introduce + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ASSIGN_ENUM + * tools/nut-scanner/scan_nut.c: tools/nut-scanner/scan_nut.c: use + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES to quiesce a + system definition of signal routines + * drivers/dstate.c: drivers/dstate.c: use + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES to quiesce a + system definition of signal routines + * drivers/main.c: drivers/main.c: use + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES to quiesce a + system definition of signal routines + * clients/upssched.c: clients/upssched.c: use + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES to quiesce a + system definition of signal routines + * clients/upsmon.c: clients/upsmon.c: use + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES to quiesce a + system definition of signal routines + * server/upsd.c: server/upsd.c: use + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES to quiesce a + system definition of signal routines + * tools/nut-scanner/scan_eaton_serial.c: tools/nut- + scanner/scan_eaton_serial.c: use + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES to quiesce a + system definition of signal routines + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: introduce + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: introduce + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: introduce + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ASSIGN_ENUM + * tools/nut-scanner/nutscan-ip.c: tools/nut-scanner/nutscan-ip.c: + whitespace/formatting fixes + * tools/nut-scanner/scan_nut.c: tools/nut-scanner/scan_nut.c: + whitespace/formatting fixes + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: introduce + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: introduce + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES + * tools/nut-scanner/scan_avahi.c: tools/nut-scanner/scan_avahi.c: use + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ASSIGN_ENUM to quiesce a + thirdparty-strange usecase of enum + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: introduce + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ASSIGN_ENUM + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + whitespace/formatting fixes + * tools/nut-scanner/nutscan-ip.h: tools/nut-scanner/nutscan-ip.h: + whitespace/formatting fixes + * tools/nut-scanner/nutscan-device.c: tools/nut-scanner/nutscan- + device.c: whitespace/formatting fixes + * tools/nut-scanner/scan_avahi.c: tools/nut-scanner/scan_avahi.c: + drop semicolons after scope braces + +2020-11-28 Jim Klimov + + * ci_build.sh: ci_build.sh: consider "gdlib" pkg-config presence + equivalent to "libgd" There is a discrepancy between OS distro + packaging names and the delivered .pc file name... + * .travis.yml: .travis.yml: mark "gnu*-nowarn-x86-32bit" test cases + evergreen + +2020-11-27 Jim Klimov + + * drivers/bcmxcp.c, drivers/bcmxcp.h: drivers/bcmxcp.{h,c}: typo fix + CAPASITOR=>CAPACITOR + * tests/cpputest.cpp: cpputest.cpp: be sure to be able to handle + exception objects + +2020-11-26 Jim Klimov + + * drivers/blazer_usb.c: drivers/blazer_usb.c: annotate + #if/#else/#endif relevant to TESTING builds + * scripts/Solaris/precheck.py: scripts/Solaris/precheck.py: quote + shell vars, and report mismatches if any + +2020-11-27 Jim Klimov + + * .travis.yml: .travis.yml: xenial@s390x does not have "time" for us + (missed one beat) + +2020-11-26 Jim Klimov + + * drivers/nutdrv_atcl_usb.c: drivers/nutdrv_atcl_usb.c: copy-paste + typo fix about unreachable code + * drivers/libusb.c: drivers/libusb.c: copy-paste typo fix about + unreachable code + +2020-11-27 Jim Klimov + + * .travis.yml: .travis.yml: from 32-bit build envs, drop amd64 libs + that confuse the linker + * .travis.yml: .travis.yml: tell the linker to go 32-bit too + +2020-11-23 Jim Klimov + + * .travis.yml: .travis.yml: work around poor packaging of multilib + perl in ubuntu + * .travis.yml: .travis.yml: define a &deps_driverlibs_cross_i386 list + for cross-builds (x86 32-bit) + * .travis.yml: .travis.yml: for x86-32 builds with gnu17 standard, + try to change install order for g++-multilib + * .travis.yml: .travis.yml: for x86-32 builds with gnu99 standard, + avoid g++-multilib + +2020-11-20 Jim Klimov + + * .travis.yml: .travis.yml: explicit support on 64-bit Debianish + systems for "gcc -m32" at least appears with gcc-multilib and + g++-multilib packages + +2020-11-03 Jim Klimov + + * .travis.yml: .travis.yml: comment for exploring ways to get 32-bit + travis builds + * .travis.yml: Issue #823 follow-up: add explicitly x86 32-bit builds + in Travis CI + +2020-11-27 Jim Klimov + + * ci_build.sh: ci_build.sh: relax the naming of libgd options seen in + the wild + +2020-11-23 Jim Klimov + + * ci_build.sh: ci_build.sh: warn if libgd is not seen and a "default- + all-errors" build might go without CGI binaries + +2020-11-17 Jim Klimov + + * drivers/phoenixcontact_modbus.c: drivers/phoenixcontact_modbus.c: + mrir(): do not shadow global varname "ctx" with same-named func + argument + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: possibly_supported(): + do not shadow global varname "hd" with func argument "hd" + +2020-11-25 Jim Klimov + + * tools/nut-scanner/scan_xml_http.c: tools/nut- + scanner/scan_xml_http.c: drop semicolons after scope braces + * tools/nut-scanner/nutscan-device.c: tools/nut-scanner/nutscan- + device.c: drop semicolons after scope braces + * tools/nut-scanner/scan_ipmi.c: tools/nut-scanner/scan_ipmi.c: drop + semicolons after scope braces + * drivers/riello.c: drivers/riello.c: drop extra semicolons + * drivers/bcmxcp.c: drivers/bcmxcp.c: drop semicolons after scope + braces + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: drop + semicolons after scope braces + * drivers/powercom.c: drivers/powercom.c: drop semicolons after scope + braces + * drivers/dstate.c: drivers/dstate.c: declare a macro for scoped + block in a way that semicolon may follow + * tools/nut-scanner/scan_avahi.c: tools/nut-scanner/scan_avahi.c: + mark up NUT_UNUSED_VARIABLEs + * tools/nut-scanner/scan_ipmi.c: tools/nut-scanner/scan_ipmi.c: mark + up NUT_UNUSED_VARIABLEs + * tools/nut-scanner/scan_xml_http.c: tools/nut- + scanner/scan_xml_http.c: mark up NUT_UNUSED_VARIABLEs + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: mark + up NUT_UNUSED_VARIABLEs + +2020-11-27 Jim Klimov + + * clients/Makefile.am: clients/Makefile.am: + AM_CXXFLAGS+=-I$(top_srcdir)/include + +2020-11-25 Jim Klimov + + * tests/example.cpp, tests/nutclienttest.cpp: tests/nutclienttest.cpp + example.cpp: wrap into + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS et al to + avoid warnings for CPPUnit macro implementation (boils down to + static vars) + * tests/cpputest.cpp, tests/example.cpp, tests/nutclienttest.cpp, + tests/nutlogtest.c: tests/*.{c,cpp}: update legaleze headings + * tests/example.cpp: tests/example.cpp: fix casting + * tests/nutclienttest.cpp: tests/nutclienttest.cpp: fix CPPUNIT + assert after nullptr + * tests/nutclienttest.cpp: tests/nutclienttest.cpp: fix NULL => + nullptr + * tests/nutclienttest.cpp: tests/nutclienttest.cpp: fix casting + * tests/Makefile.am: tests/Makefile.am: fix delivery and tracking of + CPPUNITTEST(ER)SRC + * tests/nutlogtest.c: tests/nutlogtest.c: add more tests to + investigate NUT_STRARG() behaviors + * configure.ac, include/str.h, m4/ax_c_pragmas.m4: + m4/ax_c_pragmas.m4, str.h => common.h: introduce + HAVE_PRINTF_STRING_NULL and NUT_STRARG(x) macro (for issue #904) + * tests/nutlogtest.c: tests/nutlogtest.c: use + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_OVERFLOW detection to + quiesce warnings about "%s" resolving from NULL pointer First shot + at issue NUT #904 + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: introduce + HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_OVERFLOW detection First + shot at issue NUT #904 + * tests/cpputest.cpp: tests/cpputest.cpp: print final result code + more comprehensibly (especially since process exit code is + inverted) + * clients/Makefile.am: clients/Makefile.am: be sure to use NUT + libcommon for CXX client builds + * clients/nutclient.cpp, clients/nutclient.h: + clients/nutclient.{h,cpp}: move virtual destructors of exception + classes into CPP file to bolt a linker unit (avoid Weak Vtables + warnings and related build overheads) + * clients/nutclient.cpp: clients/nutclient.cpp: (presumed) typo fix - + line ended with comma not semicolon + * clients/nutclient.cpp: clients/nutclient.cpp: quiesce warning and + make visible the unused variable + * clients/Makefile.am: clients/Makefile.am: define HAVE_NUTCOMMON for + NUT C++ builds + * clients/nutclient.cpp: clients/nutclient.cpp: use pragmas for + -Wexit-time-destructors and -Wglobal-constructors handling for an + std:string static variable + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: define pragmas for -Wexit- + time-destructors and -Wglobal-constructors handling + * clients/nutclient.cpp, clients/nutclient.h: + clients/nutclient.{h,cpp}: align strarr_alloc() type with xcalloc() + it uses => size_t + * clients/nutclient.cpp: clients/nutclient.cpp: fix old-style C casts + into static_cast<>s + * clients/nutclient.cpp, clients/nutclient.h: clients/nutclient.cpp: + for (clang) c++ builds with C++11/17/20, avoid warnings about C++98 + compatibility that we do not claim anyway - quiesce in C++ source + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: for (clang) c++ builds with + C++11/17/20, avoid warnings about C++98 compatibility that we do + not claim anyway - check that we have pragmas for that + * clients/nutclient.h: clients/nutclient.h: align method docs with + param names + +2020-11-26 Bastien Nocera + + * tools/nut-usbinfo.pl: tools/nut-usbinfo.pl: Reindent upower rules + header This piece of the code was really confusing because it + looked like, at a glance (and at more than a glance), that the line + which we'd have read in the generated rules file was commented out. + Turns out that beginning of lines in the generated rules could be + in the middle of the line in the code that generated it. Reindent + everything so that each line in the output corresponds to one line + in the input, except for empty lines. There are no differences in + output between the versions before and after this change. + * tools/nut-usbinfo.pl: tools/nut-usbinfo.pl: Simplify exit path Why + "!= usb" when we're already checking for usb and other values + above? Always go to the end label if we didn't already jump to the + section containing the actual rules. + +2020-11-25 Jim Klimov + + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: do + not wrap variable definitions into parentheses like function + pointers + * drivers/al175.c: drivers/al175.c: declare function(void) prototypes + explicitly + * drivers/netxml-ups.c: drivers/netxml-ups.c: + netxml_alarm_subscribe(): explicitly cast range-limited int + conversions + * drivers/powercom.c: drivers/powercom.c: wrap unreachable exit() + added due to earlier compiler warnings with "ifndef + HAVE___ATTRIBUTE__NORETURN" to avoid opposite warnings now + * drivers/powerman-pdu.c: drivers/powerman-pdu.c: annotate + upsdrv_shutdown() with noreturn attr + * drivers/powercom.c: drivers/powercom.c: annotate upsdrv_shutdown() + with noreturn attr + * drivers/riello_usb.c: drivers/riello_usb.c: annotate shutdown*() + with noreturn attr + * drivers/powercom.c: drivers/powercom.c: annotate shutdown*() with + noreturn attr + * drivers/al175.c: drivers/al175.c: annotate upsdrv_shutdown() with + noreturn attr + * clients/upsmon.c: clients/upsmon.c: annotate forceshutdown() with + noreturn attr + * clients/upsimage.c: clients/upsimage.c: wrap unreachable exit() + added due to earlier compiler warnings with "ifndef + HAVE___ATTRIBUTE__NORETURN" to avoid opposite warnings now + * clients/upsimage.c: clients/upsimage.c: annotate lots of routines + with noreturn attr + * tools/nut-scanner/scan_avahi.c: tools/nut-scanner/scan_avahi.c: + mark up NUT_UNUSED_VARIABLEs + * tools/nut-scanner/scan_ipmi.c: tools/nut-scanner/scan_ipmi.c: mark + up NUT_UNUSED_VARIABLEs + * tools/nut-scanner/scan_xml_http.c: tools/nut- + scanner/scan_xml_http.c: mark up NUT_UNUSED_VARIABLEs + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: mark + up NUT_UNUSED_VARIABLEs + * drivers/netxml-ups.c: drivers/netxml-ups.c: align method docs with + param names + * drivers/netxml-ups.c: drivers/netxml-ups.c: align method docs with + supported keywords + * drivers/al175.c: drivers/al175.c: align method docs with param + names + * drivers/hidparser.c: drivers/hidparser.c: satisfy pedantic macro + parser (defined vs. used value) + * drivers/libshut.c: drivers/libshut.c: satisfy pedantic macro parser + (defined vs. used value) + +2020-11-26 Jim Klimov + + * drivers/libusb.c: drivers/libusb.c: copy-paste typo fix about + unreachable code + * drivers/nutdrv_atcl_usb.c: drivers/nutdrv_atcl_usb.c: copy-paste + typo fix about unreachable code + +2020-11-25 Jim Klimov + + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: wrap unreachable exit() + added due to earlier compiler warnings with "ifndef + HAVE___ATTRIBUTE__NORETURN" to avoid opposite warnings now + +2020-11-26 Jim Klimov + + * drivers/nutdrv_qx_blazer-common.c: drivers/nutdrv_qx_blazer- + common.c: remove overly-eager protection from nonliteral format + strings + +2020-11-26 Bastien Nocera + + * tools/nut-usbinfo.pl: tools/nut-usbinfo.pl: Fix handling of "bind" + events See https://lwn.net/Articles/837033/ for an in-depth + explanation of how "bind" events should be handled in udev rules. + In short: " The ACTION line causes the entire file to be skipped + for anything other than ADD or CHANGE events; in particular, that + is what will happen with BIND events. That will cause properties + associated with those events to be lost — and the device in + question to be set up improperly (if at all). " + +2020-11-26 Jim Klimov + + * .travis.yml: .travis.yml: mark "gnu*-nowarn-s390x" test cases + evergreen + +2020-11-25 Jim Klimov + + * .travis.yml: .travis.yml: xenial@s390x does not have "time" for us + +2020-11-24 Jim Klimov + + * .travis.yml: Issue #823 follow-up: add s390x (BigEndian) builds in + Travis CI + +2020-11-25 Jim Klimov + + * drivers/riello_usb.c: drivers/riello_usb.c: do not hijack system + "errno" definition, and no use for local var of that name found + anyway + * drivers/powerman-pdu.c: drivers/powerman-pdu.c: do not assign + invalid value not from enum range, especially when for no reason + other than to have an un-used initial value + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: cover all values + of enum in a switch() Note: everything not covered before this PR + got aliased into default cases. I do not know the hardware and + models to rule this out otherwise, possibly assignments of binary + and/or smart protocol (lack of?) support are now wrong. + * drivers/powerp-bin.c: drivers/powerp-bin.c: cover all values of + enum in a switch() + * drivers/bestfcom.c: drivers/bestfcom.c: do not "break" just after + "fatalx()" + * drivers/bcmxcp.c: drivers/bcmxcp.c: do not "break" just after + "return" + * common/strerror.c: common/strerror.c: do not warn about unreachable + code in the web of ifdef built blocks + * drivers/liebert-esp2.c: drivers/liebert-esp2.c: fix indentation + +2020-11-20 Jim Klimov + + * common/upsconf.c: common/upsconf.c: conf_args(): fix numargs type + * common/str.c: common/str.c: str_to_{u,}short{,_strict}() routines: + explicit cast from temporary variable to return-value type + * common/common.c: common/common.c: common/common.c: snprintfcat(): + replace asserts by negative returns (and errno where applicable) + * common/common.c: common/common.c: common/common.c: snprintfcat(): + sort out the messy return types (avoid implicit cast in + verification assert) + +2020-11-25 Jim Klimov + + * drivers/nutdrv_atcl_usb.c: drivers/nutdrv_atcl_usb.c: do not warn + about nonliteral format string in this case + * drivers/richcomm_usb.c: drivers/richcomm_usb.c: do not warn about + nonliteral format string in this case + * drivers/snmp-ups.c: drivers/snmp-ups.c: various routines: do not + warn about nonliteral format string in these cases + * drivers/nutdrv_qx_voltronic.c: drivers/nutdrv_qx_voltronic.c: + various routines: do not warn about nonliteral format string in + these cases + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: do not warn about + nonliteral format string in this case + * drivers/powerp-bin.c: drivers/powerp-bin.c: do not warn about + nonliteral format string in this case + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: do not warn about + nonliteral format string in this case + * drivers/liebert-esp2.c: drivers/liebert-esp2.c: do not warn about + nonliteral format string in these cases + * drivers/liebert-esp2.c: drivers/liebert-esp2.c: rename scope-local + 'val' variables that shadow another from same routine + * drivers/belkinunv.c: drivers/belkinunv.c: do not warn about + nonliteral format string in this case + * drivers/bcmxcp.c: drivers/bcmxcp.c: do not warn about nonliteral + format string in this case + * drivers/serial.c: drivers/serial.c: various routines: do not warn + about nonliteral format string in these cases + * clients/upsset.c: clients/drivers: error_page(): do not warn about + nonliteral format string in this case + * clients/upsmon.c: clients/drivers: do_notify(): do not warn about + nonliteral format string in this case + * clients/upsimage.c: clients/drivers: drawbar() noimage(): do not + warn about nonliteral format string in this case + * clients/upsclient.c: clients/upsclient.c: build_cmd(): do not warn + about nonliteral format string in this case + * clients/upsclient.c: clients/upsclient.c: upscli_strerror(): do not + warn about nonliteral format string in this case + +2020-11-22 Jim Klimov + + * clients/nutclient.h: clients/nutclient.h: declare strarr routines + to be seen + +2020-11-25 Jim Klimov + + * tools/nut-scanner/nutscan-display.c: tools/nut-scanner/nutscan- + display.c: declare nutscan_device_type_string[] file-local variable + as static, and fix its indentation + +2020-11-23 Jim Klimov + + * drivers/snmp-ups.c, drivers/snmp-ups.h: drivers/snmp-ups*.{c,h}: + export *_info vars to avoid not-used allegations + * drivers/apcupsd-ups.h: drivers/apcupsd-ups.h: comment away + status_info[] as currently un-used + * drivers/riello.c, drivers/riello.h, drivers/riello_ser.c, + drivers/riello_usb.c: drivers/riello*.{c,h}: properly export + variables shared between driver subtypes + * drivers/nut-libfreeipmi.c: drivers/nut-libfreeipmi.c: comment away + ipmi_config as currently un-used + * drivers/mge-xml.c, drivers/netxml-ups.c, drivers/netxml-ups.h: + drivers/netxml/mge-xml*.{c,h}: export shutdown_duration more + usefully + * drivers/riello.h, drivers/riello_ser.c, drivers/riello_usb.c: + drivers/riello*.{c,h}: export get_ups_statuscode() to avoid not- + used allegations + * drivers/libshut.c: drivers/libshut.c: fix pre-declaration of + LIBshut_set_report() + * drivers/al175.c: drivers/al175.c: declare ACT methods to keep + compiler happy even if some are not currently used + * drivers/bcmxcp.c: drivers/bcmxcp.c: comment away FreqTol as + currently un-used + * tools/nut-scanner/nutscan-display.c: tools/nut-scanner/nutscan- + display.c: use nut-scan.h header + * tools/nut-scanner/nutscan-init.c: tools/nut-scanner/nutscan-init.h: + use its own header + +2020-11-22 Jim Klimov + + * tools/nut-scanner/scan_xml_http.c: tools/nut- + scanner/scan_xml_http.c: expose load_library() routine + +2020-11-23 Jim Klimov + + * server/netcmds.h: server/netcmds.h: declare function(non-void!) + prototype explicitly + +2020-11-22 Jim Klimov + + * server/netcmds.h: server/netcmds.h: declare function(void) + prototype explicitly + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: + expose load_library() routine + * clients/upslog.h: clients/upslog.h: declare function(non-void*) + prototype explicitly + * tools/nut-scanner/scan_eaton_serial.c: tools/nut- + scanner/scan_eaton_serial.c: declare multiple file-local routines + as static + * tools/nut-scanner/scan_avahi.c: tools/nut-scanner/scan_avahi.c: + expose load_library() routine + * tools/nut-scanner/scan_usb.c: tools/nut-scanner/scan_usb.c: expose + load_library() routine + * tools/nut-scanner/scan_ipmi.c: tools/nut-scanner/scan_ipmi.c: + declare a file-local routine as static + * tools/nut-scanner/scan_nut.c: tools/nut-scanner/scan_nut.c: expose + load_library() routine + * tools/nut-scanner/scan_ipmi.c: tools/nut-scanner/scan_ipmi.c: + expose load_library() routine + * drivers/nut-ipmi.h: drivers/nut-ipmi.h: declare function(void) + prototype explicitly + * drivers/apcsmart.c: drivers/apcsmart.c: declare multiple file-local + routines as static + * drivers/powercom.c: drivers/powercom.c: declare multiple file-local + variables as static + * drivers/oneac.c: drivers/oneac.c: declare multiple file-local + routines as static + * drivers/libshut.c: drivers/libshut.c: declare multiple file-local + routines as static + * drivers/microdowell.c: drivers/microdowell.c: rectify whitespaces + (indentations and blank lines) + * drivers/microdowell.c: drivers/microdowell.c: declare multiple + file-local routines as static + * drivers/microdowell.c: drivers/microdowell.c: declare a driver- + local variable as static + * drivers/metasys.c: drivers/metasys.c: declare multiple file-local + routines as static + * drivers/isbmex.c: drivers/isbmex.c: declare multiple file-local + routines as static + * drivers/gamatronic.c: drivers/gamatronic.c: do not mark common + routine as static + * drivers/gamatronic.c: drivers/gamatronic.c: declare multiple file- + local routines as static + * drivers/bestfortress.c: drivers/bestfortress.c: declare a file- + local routine as static + * drivers/bestfcom.c: drivers/bestfcom.c: declare multiple file-local + routines as static + * drivers/bestfcom.c: drivers/bestfcom.c: declare a driver-local + variable as static + * drivers/bcmxcp_ser.c: drivers/bcmxcp_ser.c: declare a file-local + routine as static + * drivers/al175.c: drivers/al175.c: declare multiple file-local + routines as static + * server/conf.c: server/conf.c: declare a file-local variable as + static + * server/user.c: server/user.c: declare multiple file-local variables + as static, and fix their indentation + * server/upsd.c: server/upsd.c: declare multiple file-local routines + as static + * server/upsd.c: server/upsd.c: declare multiple file-local variables + as static, and fix their indentation + * server/netcmds.h: server/netcmds.h: declare a file-local variable + as static + * tools/nut-scanner/nutscan-serial.c: tools/nut-scanner/nutscan- + serial.c: declare a file-local variable as static + * tools/nut-scanner/nut-scan.h: tools/nut-scanner/nut-scan.h: declare + function(void) prototype explicitly + * tools/nut-scanner/nutscan-device.h: tools/nut-scanner/nutscan- + device.h: declare function(void) prototype explicitly + * tools/nut-scanner/scan_snmp.c: tools/nut-scanner/scan_snmp.c: + declare multiple file-local variables as static + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + declare a file-local routine as static + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + declare multiple file-local variables as static + * drivers/nut-libfreeipmi.c: drivers/nut-libfreeipmi.c: declare + function(void) prototype explicitly + * drivers/nut-libfreeipmi.c: drivers/nut-libfreeipmi.c: declare + multiple file-local variables as static + * drivers/nut-ipmipsu.c: drivers/nut-ipmipsu.c: declare multiple + file-local variables as static + * drivers/powerman-pdu.c: drivers/powerman-pdu.c: declare multiple + file-local variables as static + * drivers/netxml-ups.c: drivers/netxml-ups.c: declare a driver-local + variable as static + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: declare multiple file- + local variables as static + * drivers/apc-hid.c: drivers/apc-hid.c: declare multiple file-local + variables as static + * drivers/emerson-avocent-pdu-mib.c: drivers/emerson-avocent-pdu- + mib.c: declare multiple file-local variables as static + * drivers/masterguard.c: drivers/masterguard.c: declare multiple + file-local variables as static + * drivers/Makefile.am, drivers/bcmxcp_ser.c, drivers/bcmxcp_ser.h, + tools/nut-scanner/scan_eaton_serial.c: Introduce bcmxcp_ser.h to + provide as extern some variables from the driver also used in nut- + scanner + * drivers/raritan-px2-mib.c: drivers/raritan-px2-mib.c: declare a + driver-local variable as static + * drivers/snmp-ups.h: clients/snmp-ups.h: declare some setter/getter + routines to be seen + * drivers/snmp-ups.h: drivers/snmp-ups.h: declare function(void) + prototype explicitly + * drivers/snmp-ups.c: drivers/snmp-ups.c: declare multiple file-local + routines as static + * drivers/snmp-ups.c: drivers/snmp-ups.c: declare multiple file-local + variables as static + * drivers/nutdrv_qx_bestups.c: drivers/nutdrv_qx_bestups.c: declare + multiple file-local variables as static + * drivers/riello_usb.c: drivers/riello_usb.c: declare multiple file- + local routines as static + * drivers/riello_usb.c: drivers/riello_usb.c: declare multiple file- + local variables as static + * drivers/riello_ser.c: drivers/riello_ser.c: declare multiple file- + local routines as static + * drivers/riello_ser.c: drivers/riello_ser.c: declare multiple file- + local variables as static + * drivers/riello.h: drivers/riello.h: declare function(void) + prototype explicitly + * drivers/riello.c: drivers/riello.c: declare multiple file-local + variables as static + * drivers/apcupsd-ups.h: drivers/apcupsd-ups.h: declare a driver- + local variable as static + * drivers/apcsmart-old.h: drivers/apcsmart-old.h: declare multiple + file-local variables as static + * drivers/victronups.c: drivers/victronups.c: declare multiple file- + local variables as static + * drivers/mge-hid.c: drivers/mge-hid.c: declare multiple file-local + variables as static + * drivers/mge-hid.c: drivers/mge-hid.c: end all info_lkp_t arrays + with sentinel entries + * drivers/apc-hid.h, drivers/libhid.h: Move "extern int + max_report_size;" declaration from drivers/apc-hid.h to more + suitable drivers/libhid.h + * drivers/mge-utalk.c: drivers/mge-utalk.c: declare a driver-local + variable as static + * drivers/mge-utalk.h: drivers/mge-utalk.h: declare a driver-local + variable as static + * drivers/metasys.c: drivers/metasys.c: declare multiple file-local + variables as static + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: declare multiple + file-local routines as static + +2020-11-20 Jim Klimov + + * drivers/genericups.h: drivers/genericups.h: declare a driver-local + variable as static + * drivers/gamatronic.h: drivers/gamatronic.h: declare multiple file- + local variables as static + * drivers/bestuferrups.c: drivers/bestuferrups.c: declare a driver- + local variable as static + * drivers/dummy-ups.c: drivers/dummy-ups.c: declare multiple file- + local variables as static + * drivers/dummy-ups.h: drivers/dummy-ups.h: declare a driver-local + variable as static + * drivers/bestuferrups.c: drivers/bestuferrups.c: declare a file- + local variable as static + * drivers/bestfortress.c: drivers/bestfortress.c: declare a file- + local variable as static + * drivers/belkinunv.c: drivers/belkinunv.c: declare multiple file- + local variables as static + * drivers/bcmxcp_ser.c: drivers/bcmxcp_ser.c: declare multiple file- + local variables as static + * drivers/bcmxcp.c: drivers/bcmxcp.c: declare multiple file-local + variables as static + * drivers/main.c: drivers/main.c: declare multiple file-local + variables as static, and fix their indentation + * clients/upssched.c: clients/upssched.c: declare multiple file-local + variables as static, and fix their indentation + * clients/upsmon.h: clients/upsmon.h: declare file-local variable as + static: struct notifylist[] + * clients/upsset.c: clients/upsset.c: declare multiple file-local + variables as static, and fix their indentation + * clients/upsimagearg.h: clients/upsimagearg.h: declare file-local + variable as static: struct imgarg[] + * clients/status.h: clients/status.h: declare file-local variable as + static: struct stattab[] + * clients/upslog.h: clients/upslog.h: declare file-local variable as + static: struct logcmds[] + * clients/upsclient.c: clients/upsclient.c: declare file-local + variable as static: struct upscli_errlist[] + +2020-11-17 Jim Klimov + + * drivers/riello_ser.c: drivers/riello_ser.c: riello_serialcomm(): do + not shadow global varname "bufIn" with same-named func argument + * tools/nut-scanner/scan_eaton_serial.c: tools/nut- + scanner/scan_eaton_serial.c: shut_synchronise(): do not shadow + global varnames "upsfd" (from scan_eaton_serial.c and main.c) with + func argument "upsfd" + +2020-11-25 Jim Klimov + + * clients/nutclient.h, tests/nutclienttest.cpp: + tests/nutclienttest.cpp: add tests on Device, Variable and Command + copying by assignment and by constructor + +2020-11-24 Jim Klimov + + * clients/nutclient.cpp: clients/nutclient.cpp: whitespace fixes + (indentations, blank lines) + * clients/nutclient.h: clients/nutclient.h: whitespace fixes + (indentations) + +2020-11-17 Jim Klimov + + * clients/nutclient.cpp, clients/nutclient.h: nutclient.cpp: match a + copy constructor with a copy assignment operator (Device, Variable, + Command classes) + +2020-11-18 Jim Klimov + + * drivers/tripplite.c: drivers/tripplite.c: upsdrv_initinfo(): use a + literal format string + +2020-11-22 Jim Klimov + + * tools/nut-scanner/nutscan-serial.c: tools/nut-scanner/nutscan- + serial.c: fix diags pragmas to use our configured-support macros + for cleaner fencing (nonliteral format strings) + +2020-11-18 Jim Klimov + + * tools/nut-scanner/nutscan-serial.c: tools/nut-scanner/nutscan- + serial.c: do not warn about nonliteral format string in this case + +2020-11-22 Jim Klimov + + * drivers/nutdrv_qx_voltronic-qs-hex.c: drivers/nutdrv_qx_voltronic- + qs-hex.c: fix diags pragmas to use our configured-support macros + for cleaner fencing (nonliteral format strings) + +2020-11-18 Jim Klimov + + * drivers/nutdrv_qx_voltronic-qs-hex.c: drivers/nutdrv_qx_voltronic- + qs-hex.c: various routines: do not warn about nonliteral format + string in these cases + +2020-11-22 Jim Klimov + + * drivers/nutdrv_qx_voltronic-qs.c: drivers/nutdrv_qx_voltronic-qs.c: + fix diags pragmas to use our configured-support macros for cleaner + fencing (nonliteral format strings) + +2020-11-18 Jim Klimov + + * drivers/nutdrv_qx_voltronic-qs.c: drivers/nutdrv_qx_voltronic-qs.c: + do not warn about nonliteral format string in this case + +2020-11-22 Jim Klimov + + * drivers/nutdrv_qx_mecer.c: drivers/nutdrv_qx_mecer.c: fix diags + pragmas to use our configured-support macros for cleaner fencing + (nonliteral format strings) + +2020-11-18 Jim Klimov + + * drivers/nutdrv_qx_mecer.c: drivers/nutdrv_qx_mecer.c: various + routines: do not warn about nonliteral format string in these cases + +2020-11-22 Jim Klimov + + * drivers/nutdrv_qx_blazer-common.c: drivers/nutdrv_qx_blazer- + common.c: fix diags pragmas to use our configured-support macros + for cleaner fencing (nonliteral format strings) + +2020-11-18 Jim Klimov + + * drivers/nutdrv_qx_blazer-common.c: drivers/nutdrv_qx_blazer- + common.c: various routines: do not warn about nonliteral format + string in these cases + +2020-11-22 Jim Klimov + + * drivers/nutdrv_qx_bestups.c: drivers/nutdrv_qx_bestups.c: fix diags + pragmas to use our configured-support macros for cleaner fencing + (nonliteral format strings) + +2020-11-18 Jim Klimov + + * drivers/nutdrv_qx_bestups.c: drivers/nutdrv_qx_bestups.c: various + routines: do not warn about nonliteral format string in these cases + +2020-11-22 Jim Klimov + + * drivers/apcupsd-ups.c: drivers/apcupsd-ups.c: fix diags pragmas to + use our configured-support macros for cleaner fencing (nonliteral + format strings) + +2020-11-18 Jim Klimov + + * drivers/apcupsd-ups.c: drivers/apcupsd-ups.c: do not warn about + nonliteral format string in this case + +2020-11-22 Jim Klimov + + * drivers/blazer.c: drivers/blazer.c: fix diags pragmas to use our + configured-support macros for cleaner fencing (nonliteral format + strings) + +2020-11-18 Jim Klimov + + * drivers/blazer.c: drivers/blazer.c: various routines: do not warn + about nonliteral format string in these cases + +2020-11-22 Jim Klimov + + * drivers/powerp-txt.c: drivers/powerp-txt.c: fix diags pragmas to + use our configured-support macros for cleaner fencing (nonliteral + format strings) + +2020-11-18 Jim Klimov + + * drivers/powerp-txt.c: drivers/powerp-txt.c: do not warn about + nonliteral format string in this case + +2020-11-22 Jim Klimov + + * drivers/mge-utalk.c: drivers/mge-utalk.c: fix diags pragmas to use + our configured-support macros for cleaner fencing (nonliteral + format strings) + +2020-11-18 Jim Klimov + + * drivers/mge-utalk.c: drivers/mge-utalk.c: various routines: do not + warn about nonliteral format string in this case + +2020-11-22 Jim Klimov + + * drivers/bestfortress.c: drivers/bestfortress.c: fix diags pragmas + to use our configured-support macros for cleaner fencing + (nonliteral format strings) + +2020-11-18 Jim Klimov + + * drivers/bestfortress.c: drivers/bestfortress.c: setinfo_float(): + comment about a casting problem, and do not warn about nonliteral + format string in this case + * drivers/bestfortress.c: drivers/bestfortress.c: do not warn about + nonliteral format string in this case + +2020-11-22 Jim Klimov + + * drivers/serial.c: drivers/serial.c: fix diags pragmas to use our + configured-support macros for cleaner fencing (nonliteral format + strings) + +2020-11-18 Jim Klimov + + * drivers/serial.c: drivers/serial.c: do not warn about nonliteral + format string in this case + +2020-11-22 Jim Klimov + + * drivers/dstate.c: drivers/dstate.c: fix diags pragmas to use our + configured-support macros for cleaner fencing (nonliteral format + strings) + +2020-11-18 Jim Klimov + + * drivers/dstate.c: drivers/dstate.c: various routines: do not warn + about nonliteral format string in this case + +2020-11-22 Jim Klimov + + * clients/upssched.c: clients/upssched.c: fix diags pragmas to use + our configured-support macros for cleaner fencing (nonliteral + format strings) + +2020-11-18 Jim Klimov + + * clients/upssched.c: clients/upssched.c: send_to_one(): do not warn + about nonliteral format string in this case + +2020-11-22 Jim Klimov + + * common/common.c: common/common.c: fix diags pragmas to use our + configured-support macros for cleaner fencing (nonliteral format + strings) + +2020-11-20 Jim Klimov + + * common/common.c: common/common.c: various routines: do not warn + about nonliteral format string in these cases + +2020-11-17 Jim Klimov + + * common/common.c: common/common.c: snprintfcat(): do not warn about + nonliteral format string in this case + +2020-11-24 Jim Klimov + + * .travis.yml: .travis.yml: run gnu17-clang-8-nowarn-ARM-64bit case + in fightwarn branches + * .travis.yml: .travis.yml: annotate clearer the different + allowed_failure OS build sections + * .travis.yml: .travis.yml: point all GCC -std=*++99 to *-98 I + thought it was an older GCC quirk, but even new ones complain: + g++: error: unrecognized command-line option '-std=gnu++99'; did + you mean '-std=gnu++98'? g++ (FreeBSD Ports Collection) 10.0.0 + 20191222 (experimental) Copyright (C) 2019 Free Software + Foundation, Inc. This is free software; see the source for copying + conditions. There is NO warranty; not even for MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. + +2020-11-23 Jim Klimov + + * .travis.yml: .travis.yml: mark gnuXX-gcc-*-arm64 test cases as + evergreen + * .travis.yml: .travis.yml: separate ARM64 test case matrices into + ..._viable and ..._fatal subsets + * .travis.yml: .travis.yml: introduce + NUT_MATRIX_TAG="gnu17-gcc-9-nowarn-ARM-64bit" test case + * .travis.yml: .travis.yml: drop gcc-multilib in ARM builds, seems + missing in Debian + * .travis.yml: .travis.yml: drop arm-32bit builds, seems a no-go on + Travis quickly + * .travis.yml: Issue #823 follow-up: add ARM 32-bit and 64-bit builds + in Travis CI + +2020-11-22 Jim Klimov + + * drivers/gamatronic.c: drivers/gamatronic.c: rectify whitespaces + (indentations and blank lines) + +2020-11-20 Jim Klimov + + * drivers/gamatronic.c: drivers/gamatronic.c: fix indentation and + scope whitespace + * drivers/gamatronic.c: drivers/gamatronic.c: fix trailing whitespace + * common/common.c: common/common.c: cleaner macro processing for + BUILD_64 + +2020-11-22 Jim Klimov + + * include/timehead.h: include/timehead.h: satisfy pedantic macro + parser (defined vs. used value) + +2020-11-23 Jim Klimov + + * m4/nut_report_feature.m4: m4/nut_report_feature.m4: report the + compiler tools and flags ultimately applied to this build + * .gitignore: GitIgnore configure-test.docbuild* dirs + * .travis.yml: .travis.yml: separate the matrix for + _matrix_freebsd_gnustd_warn_viable and ..._fatal cases + * .travis.yml: .travis.yml: mark "gnuXX-gcc-freebsd-warn" cases as + evergreen to keep that way + * .travis.yml: .travis.yml: on freebsd, `pkg install libgd` + explicitly (needs sudo) + * .travis.yml: .travis.yml: introduce freebsd test cases with + warnings (typo fix) + +2020-11-22 Jim Klimov + + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: alarm if bogus tests did + not fail + * m4/ax_c_pragmas.m4: m4/ax_c_pragmas.m4: adapt to gcc vs clang CLI + capabilities + * configure.ac, m4/nut_compiler_family.m4: Introduce + m4/nut_compiler_family.m4 detection + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: fix diags pragmas + to use our configured-support macros for cleaner fencing + (unreachable code) + * drivers/nutdrv_atcl_usb.c: drivers/nutdrv_atcl_usb.c: fix diags + pragmas to use our configured-support macros for cleaner fencing + (unreachable code) + * drivers/libusb.c: drivers/libusb.c: fix diags pragmas to use our + configured-support macros for cleaner fencing (unreachable code) + * drivers/richcomm_usb.c: drivers/richcomm_usb.c: fix diags pragmas + to use our configured-support macros for cleaner fencing + (unreachable code) + * configure.ac, m4/ax_c_pragmas.m4: Introduce m4/ax_c_pragmas.m4 + * .travis.yml: .travis.yml: curiously, gcc-7 in Travis does not alias + -std=gnu++99 to canonic gnu++98 + * autogen.sh: autogen.sh: do not hide the progress of autoreconf + * ci_build.sh: ci_build.sh: fix whitespace + * ci_build.sh: ci_build.sh: parameterize $CONFIGURE_SCRIPT as it may + be called differently on some platforms + * .travis.yml: .travis.yml: amend cygwin bin files ACLs to let them + execute Thanks https://stackoverflow.com/a/4493653/4715872 for the + hint + * .travis.yml: .travis.yml: use choco bins in PATH also with + /cygdrive/ prefix just in case + * .travis.yml: .travis.yml: use cygwin bins in PATH also with + /cygdrive/ prefix just in case + * .travis.yml: .travis.yml: allow to skip cygwin autotools install if + it was done earlier and cached + +2020-11-21 Jim Klimov + + * .travis.yml: .travis.yml: use cygwin bins as last resort (e.g. for + autoconf) + * .travis.yml: Revert ".travis.yml: run Windows test cases with + cygwin bash" This reverts commit + 4592860aa82a208969eb1ae3ac2ec1f96e77bc07. + +2020-11-19 Jim Klimov + + * .travis.yml: .travis.yml: for windows builds, add + /C/tools/cygwin/bin to PATH + * .travis.yml: .travis.yml: define a NUT_MATRIX_TAG="gnu99-clang-win- + warn" test case for completeness + +2020-11-22 Jim Klimov + + * .travis.yml: .travis.yml: add _matrix_freebsd_gnustd_warn to + _matrix_freebsd + * .travis.yml: .travis.yml: introduce freebsd test cases with nowarn + and gnu17 + * .travis.yml: .travis.yml: introduce freebsd test cases with + warnings + * .travis.yml: .travis.yml: mark "gnu99-gcc-freebsd-nowarn" and + "gnu99-clang-freebsd-nowarn" as required + * ci_build.sh: ci_build.sh: as of now, skip building cgi (needs + libgd) on freebsd too, for "default-all-errors" test cases + * .travis.yml: .travis.yml: define simple freebsd scenarios + +2020-11-20 Jim Klimov + + * drivers/nutdrv_atcl_usb.c: drivers/nutdrv_atcl_usb.c: do not warn + about unreachable code where we handle a legacy off-chance that + fatalx() might not exit the program + * drivers/richcomm_usb.c: drivers/richcomm_usb.c: do not warn about + unreachable code where we handle a legacy off-chance that fatalx() + might not exit the program + * drivers/libusb.c: drivers/libusb.c: do not warn about unreachable + code where we handle a legacy off-chance that fatalx() might not + exit the program + * server/upsd.c: server/upsd.c: a move "help" switch() handling to + default case + * server/upsd.c: server/upsd.c: a switch() default needs no break + * drivers/upsdrvctl.c: drivers/upsdrvctl.c: a switch() default needs + no break + * drivers/riello_usb.c: drivers/riello_usb.c: wrap unreachable exit() + added due to earlier compiler warnings with "ifndef + HAVE___ATTRIBUTE__NORETURN" to avoid opposite warnings now + * drivers/blazer_usb.c: drivers/blazer_usb.c: wrap unreachable exit() + added due to earlier compiler warnings with "ifndef + HAVE___ATTRIBUTE__NORETURN" to avoid opposite warnings now + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: wrap unreachable + exit() added due to earlier compiler warnings with "ifndef + HAVE___ATTRIBUTE__NORETURN" to avoid opposite warnings now + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: control_outlet(): + do not warn about syntactic "break;" after returns in conditionals + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: wrap unreachable exit() + added due to earlier compiler warnings with "ifndef + HAVE___ATTRIBUTE__NORETURN" to avoid opposite warnings now + * drivers/metasys.c: drivers/metasys.c: a switch() default needs no + break, especially not after fatalx() + * drivers/dummy-ups.c: drivers/dummy-ups.c: a switch() default needs + no break, especially not after fatalx() + * .gitignore: GitIgnore temporary dirs made by configure script + (remain around if it is aborted) + * clients/upsmon.c: clients/upsmon.c: wrap unreachable exit() added + due to earlier compiler warnings with "ifndef + HAVE___ATTRIBUTE__NORETURN" to avoid opposite warnings now + * clients/upsmon.c: clients/upsmon.c: wrap unreachable switch()-break + after help() with "ifndef HAVE___ATTRIBUTE__NORETURN" to avoid + warnings + * clients/upslog.c: clients/upslog.c: wrap unreachable switch()-break + after help() with "ifndef HAVE___ATTRIBUTE__NORETURN" to avoid + warnings + * clients/upscmd.c: clients/upscmd.c: wrap unreachable exit() added + due to earlier compiler warnings with "ifndef + HAVE___ATTRIBUTE__NORETURN" to avoid opposite warnings now + * clients/upsc.c: clients/upsc.c: wrap unreachable exit() added due + to earlier compiler warnings with "ifndef + HAVE___ATTRIBUTE__NORETURN" to avoid opposite warnings now + * server/upsd.c: server/upsd.c: wrap unreachable exit() added due to + earlier compiler warnings with "ifndef HAVE___ATTRIBUTE__NORETURN" + to avoid opposite warnings now + * include/attribute.h: include/attribute.h: align with + AX_C___ATTRIBUTE__ autoconf macro + * m4/ax_c___attribute__.m4: m4/ax_c___attribute__.m4: extend to + declare support for certain __attribute__((...)) use-cases of + interest to NUT + * configure.ac, m4/ax_c___attribute__.m4: configure.ac: introduce + AX_C___ATTRIBUTE__ from gnu.org + * server/upsd.c: server/upsd.c: annotate help() with noreturn attr + +2020-11-17 Jim Klimov + + * server/upsd.c: server/upsd.c: help(): do not shadow global varnames + "progname" (from upsd.c and main.c) with func argument "progname" + +2020-11-20 Jim Klimov + + * drivers/nut-ipmipsu.c: drivers/nut-ipmipsu.c: annotate + upsdrv_shutdown() with noreturn attr + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: annotate + nutusb_open_error() with noreturn attr + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: fix indenting + whitespace + * drivers/riello_ser.c: drivers/riello_ser.c: annotate + upsdrv_shutdown() with noreturn attr + * drivers/blazer.c: drivers/blazer.c: annotate upsdrv_shutdown() with + noreturn attr + * drivers/dummy-ups.c: drivers/dummy-ups.c: annotate + upsdrv_shutdown() with noreturn attr + * clients/upsmon.c: clients/upsmon.c: annotate several routines with + noreturn attrs + * clients/upsmon.c: clients/upsmon.c: help(): do not shadow global + varname "progname" with same-named func argument + * clients/upsset.c: clients/upsset.c: annotate several routines with + noreturn attrs + * clients/upsimage.c: clients/upsimage.c: annotate drawimage() with + noreturn attr + * clients/upslog.c: clients/upslog.c: annotate help() with noreturn + attr + +2020-11-17 Jim Klimov + + * drivers/upsdrvctl.c: drivers/upsdrvctl.c: annotate help() with + noreturn attr + * drivers/macosx-ups.c: drivers/macosx-ups.c: annotate + upsdrv_shutdown() with noreturn attr + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: annotate + upsdrv_shutdown() with noreturn attr + * drivers/apcupsd-ups.c: drivers/apcupsd-ups.c: annotate + upsdrv_shutdown() with noreturn attr + * drivers/ivtscd.c: drivers/ivtscd.c: annotate upsdrv_shutdown() with + noreturn attr + * drivers/clone.c: drivers/clone.c: annotate upsdrv_shutdown() with + noreturn attr + * drivers/skel.c: drivers/skel.c: annotate upsdrv_shutdown() with + noreturn attr + * drivers/liebert.c: drivers/liebert.c: annotate upsdrv_shutdown() + with noreturn attr + * drivers/serial.c: drivers/serial.c: annotate ser_open_error() with + noreturn attr + * drivers/dstate.c: drivers/dstate.c: annotate sock_fail() with + noreturn attr + * drivers/main.c: drivers/main.c: annotate forceshutdown() with + noreturn attr + * common/parseconf.c: common/parseconf.c: annotate pconf_fatal() with + noreturn attr + +2020-11-18 Jim Klimov + + * .travis.yml: .travis.yml: fix typo in recent fix for clang warnings + +2020-11-18 Jim Klimov + + * scripts/Solaris/precheck.py: scripts/Solaris/precheck.py: modernize + calling sub-processes for Python 2.6+ and 3+ (keep original way for + older systems compat) + +2020-11-17 Jim Klimov + + * scripts/augeas/gen-nutupsconf-aug.py: scripts/augeas/gen- + nutupsconf-aug.py: drop unused variables Originally PR meant to + drop "global" modifier outside a local function context, but found + that nothing defines or uses these three names. Must be some + leftover from planned but unfinished development. Re-ran + ./autogen.sh and it generates the same file for the build. + +2020-11-18 Jim Klimov + + * drivers/dstate.h: drivers/dstate.h: dstate_setaux(): fix missed + type change for "aux" + * drivers/dstate.c: drivers/dstate.c: dstate_setaux(): fix missed + type change for "aux" + * .gitignore: GitIgnore NetBeans project directory + +2020-11-16 Jim Klimov + + * .gitignore: GitIgnore .gdb_history files + * .gitignore: GitIgnore conf??????/ temporary directories that can + remain if configure script is aborted + * .gitignore: GitIgnore conf_nut_report_feature file (made by + m4/nut_report) + +2020-11-17 Jim Klimov + + * drivers/powerman-pdu.c: drivers/powerman-pdu.c: query_one() + query_all(): do not shadow global varname "pm" with same-named func + argument + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: + subdriver_match_func(): do not shadow global varname "hd" with func + argument "hd" + * drivers/mge-xml.c: drivers/mge-xml.c: numerous routines: do not + shadow global varname "val" (for XML element temp store?) with + same-named func argument + * drivers/netxml-ups.c: drivers/netxml-ups.c: send_http_request(): do + not shadow global varnames "session" and "uri" with func arguments + * drivers/upscode2.c: upscode2.c: upsc_setstatus(): do not shadow + global varname "status" with func argument "status" + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: callback(): do not + shadow global varname "udev" with func argument "udev" + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: callback(): do not + shadow global varname "hd" with func argument "hd" + * drivers/riello.c: drivers/riello.c: riello_calc_CRC(): change data + type to fix comparisons + * drivers/powercom.c: drivers/powercom.c: output_voltage(): avoid a + multiplication overflow by casting + * server/upsd.c: upsd.c: actually include signal.h from system + * common/common.c: common/common.c: upsdebug_hex() / + upsdebug_ascii(): fix const-ness of buf casting + * common/common.c: common/common.c: get_libname(): fix type to + receive strlen() + * common/state.c, drivers/dstate.c, include/state.h, server/netget.c: + state.c dstate.c etc.: fix st_tree_t->aux to "long" as we convert + via strtol() + * common/parseconf.c: common/parseconf.c: addchar(): signedness-aware + trim of ctx->ch range + * common/common.c: common/common.c: mark search_paths[] as a static + array + * common/common.c: common/common.c: snprintfcat(): sort out the messy + return types + * common/common.c: common/common.c: sendsignalfn(): fix pid to "long" + as we convert via strtol() + * common/common.c: common/common.c: writepid(): fix data type for + umask() + * common/parseconf.c: parseconf.c: add_arg_word(): fix argpos to + size_t, we do not expect negative offsets + * clients/upsclient.c, clients/upsclient.h, common/common.c, + drivers/apcsmart.c, drivers/serial.c, drivers/serial.h, + include/common.h: common, serial, upsclient: change read() and + write() operations from "int" to "ssize_t" + * include/attribute.h: include/attribute.h: satisfy pedantic macro + parser (defined vs. used value) + * drivers/powercom.c: drivers/powercom.c: do not check "if model >= + 2000" just after processing "model < 2000" + * drivers/pijuice.c: drivers/pijuice.c: do not check for + "powerInput5vIo <= POWER_PRESENT" twice in a row + * drivers/bcmxcp.c: drivers/bcmxcp.c: do not check for "value>=0" + when we pick it from "unsigned char[]" answer + * common/common.c: common/common.c: search_paths[]: comment the + reasoning (see also issue NUT #805) + * drivers/apcupsd-ups.c: drivers/apcupsd-ups.c: comment about htons() + return value range (why I did not fix an "x<0" check) + * .travis.yml: .travis.yml: run Windows test cases with cygwin bash + * .travis.yml: .travis.yml: add at least a cygwin automake to Windows + test cases + * .travis.yml: .travis.yml: limit builds on xcode7.x to C11 + * include/parseconf.h: include/parseconf.h: fix trailing whitespace + * .travis.yml: .travis.yml: mark clang builds with fatal warnings, + additionally with -Wno-reserved-id-macro -Wno-padded to play around + system header issues + +2020-11-16 Jim Klimov + + * configure.ac: configure.ac: rephrase the notice about looking for + required C library routines which are beyond strict C standards + +2020-11-10 Jim Klimov + + * configure.ac: configure.ac: make checks for "Required C library + routine" not fatal: -Wall -Werror frowns upon the ways autotools + probe the system + * configure.ac: configure.ac: detect routines that may be not + available in constrained standard-C modes + +2020-11-16 Jim Klimov + + * configure.ac, m4/nut_stash_warnings.m4: Introduce + m4/nut_stash_warnings.m4 and NUT_STASH_WARNINGS and + NUT_POP_WARNINGS in configure.ac + +2020-11-17 Jim Klimov + + * drivers/solis.c: drivers/solis.c: convert from localtime() to + localtime_r() which is thread-safe + * drivers/rhino.c: drivers/rhino.c: convert from localtime() to + localtime_r() which is thread-safe + * drivers/microdowell.c: drivers/microdowell.c: convert from + localtime() to localtime_r() which is thread-safe + * drivers/mge-hid.c: drivers/mge-hid.c: convert from localtime() to + localtime_r() which is thread-safe + * clients/upsstats.c: clients/upsstats.c: convert from localtime() to + localtime_r() which is thread-safe + * clients/upslog.c: clients/upslog.c: convert from localtime() to + localtime_r() which is thread-safe + +2020-11-16 Jim Klimov + + * ci_build.sh: ci_build.sh: build_to_only_catch_errors(): also report + on `make check` with the current test case + * .travis.yml: Revert ".travis.yml: DISABLE test case + "gnu99-clang-5.0-nowarn": it has some problem with the recently + changed "tests/" (and runs clang-7 anyway as it does not use the + PPA for 5.0)" This reverts commit + 4749e0b26a33990dbd7bb56ff863cfc30db4245e as we can now have this + test case working again. + * configure.ac: configure.ac: do not pick C++11 support if a standard + is explicitly requested by caller; fixes NUT issue #873 + * .travis.yml: .travis.yml: fix test cases for + NUT_MATRIX_TAG="*-clang-5.0-*" to actually use clang-5.0 explicitly + +2020-11-15 Jim Klimov + + * .travis.yml: .travis.yml: mark test-case "gnu17-gcc-9-warn" as + passing now + * .travis.yml: .travis.yml: add libnss3-dev and libssl-dev to test + against both SSL implems + * .travis.yml: .travis.yml: DISABLE test case + "gnu99-clang-5.0-nowarn": it has some problem with the recently + changed "tests/" (and runs clang-7 anyway as it does not use the + PPA for 5.0) + * drivers/snmp-ups.c, m4/nut_check_libnetsnmp.m4: drivers/snmp-ups.c: + fix the warning about how we get the size of usmAES128PrivProtocol + * ci_build.sh: ci_build.sh: configure_nut(): sleep more before data + dump so interactive devs can react to the broken configure run + * ci_build.sh: ci_build.sh: build_to_only_catch_errors(): report a + SUCCESS when we have one + * ci_build.sh: ci_build.sh: allow caller to customize their + PKG_CONFIG_PATH + * tests/Makefile.am: tests/Makefile.am: fix include dir for + cppunittest + * server/netssl.c: server/netssl.c: comment about non-fatal build + warnings from NSS include names we use + * server/netssl.c: server/netssl.c: mark up NUT_UNUSED_VARIABLEs for + build with Mozilla NSS + * clients/upsclient.c: clients/upsclient.c: mark up + NUT_UNUSED_VARIABLEs for build with Mozilla NSS + * m4/nut_check_libnss.m4: nut_check_libnss.m4 : warn that nss.pc is + more sensitive to matching PKG_CONFIG_PATH and build bitness than + others + * ci_build.sh: ci_build.sh : enable SSL build variants of "default- + all-errors" with both OpenSS and Mozilla NSS + * m4/nut_check_libnetsnmp.m4: m4/nut_check_libnetsnmp.m4: pick + correct bitness net-snmp-config-{32,64} script if available + +2020-11-14 Jim Klimov + + * tests/Makefile.am: tests/Makefile.am: fix include dir for + nutlogtest + +2020-11-10 Jim Klimov + + * .travis.yml: .travis.yml (#823) : green-light several GCC test + cases that now pass even with all warnings enabled as fatal + * clients/upsset.c: clients/upsset.c: refine whitespace + +2020-11-09 Jim Klimov + + * drivers/rhino.c: drivers/rhino.c: drop extraneous parentheses + * drivers/nutdrv_qx.h: drivers/nutdrv_qx.h: avoid a trailing comma in + enum list (C89) + +2020-11-12 Jim Klimov + + * docs/nut.dict: nut.dict: spellcheck new keywords around "fightwarn" + chapter + +2020-11-10 Jim Klimov + + * docs/developers.txt: docs/developers.txt: detail how to use + ci_build.sh intended for Travis CI to work on fixing stuff locally + +2020-11-13 Jim Klimov + + * tests/cpputest.cpp: tests/cpputest.cpp : wrap the test run to catch + exceptions, if any + * tests/cpputest.cpp: tests/cpputest.cpp : comment the progress + through steps + * tests/cpputest.cpp: tests/cpputest.cpp: mark up + NUT_UNUSED_VARIABLEs in the more portable manner + * tests/Makefile.am: tests/Makefile.am : comment the cases where we + do not compile CXX tests + * tests/Makefile.am, tests/nutlogtest.c: Introduce tests/nutlogtest.c + for upslog*() and friends + +2020-11-12 Jean-Baptiste Boric + + * drivers/main.c: Fix faulty dump mode logic + +2020-11-12 Jim Klimov + + * docs/nut.dict: Update nut.dict + +2020-11-10 Jim Klimov + + * configure.ac: configure.ac : detect abs() and fabs() funcs + +2020-11-12 Jim Klimov + + * docs/acknowledgements.txt: Update acknowledgements.txt Do not + constrain contribution from EVER Power Systems to one person + +2020-11-11 Jim Klimov + + * docs/developers.txt: docs/developers.txt: document + NUT_UNUSED_VARIABLE() + +2020-11-10 Jim Klimov + + * include/common.h: include/common.h : drop NUT_UNUSED and + NUT_UNUSED_FUNCTION macros as not portable enough + * drivers/mge-hid.c: drivers/mge-hid.c: mark up NUT_UNUSED_VARIABLEs + in the more portable manner + * drivers/tripplite-hid.c: drivers/tripplite-hid.c: mark up + NUT_UNUSED_VARIABLEs in the more portable manner + * drivers/richcomm_usb.c: drivers/richcomm_usb.c: mark up + NUT_UNUSED_VARIABLEs in the more portable manner + * drivers/serial.c: drivers/serial.c: mark up NUT_UNUSED_VARIABLEs in + the more portable manner + * drivers/bestfcom.c: drivers/bestfcom.c: mark up + NUT_UNUSED_VARIABLEs in the more portable manner + * drivers/dummy-ups.c: drivers/dummy-ups.c: mark up + NUT_UNUSED_VARIABLEs in the more portable manner + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: mark up + NUT_UNUSED_VARIABLEs in the more portable manner + * drivers/apcsmart-old.c: drivers/apcsmart-old.c: mark up + NUT_UNUSED_VARIABLEs in the more portable manner + * drivers/nutdrv_atcl_usb.c: drivers/nutdrv_atcl_usb.c: mark up + NUT_UNUSED_VARIABLEs in the more portable manner + * drivers/cps-hid.c: drivers/cps-hid.c: mark up NUT_UNUSED_VARIABLEs + in the more portable manner + * drivers/apcsmart.c: drivers/apcsmart.c: mark up + NUT_UNUSED_VARIABLEs in the more portable manner + * drivers/bestfortress.c: drivers/bestfortress.c: mark up + NUT_UNUSED_VARIABLEs in the more portable manner + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: mark up + NUT_UNUSED_VARIABLEs in the more portable manner + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: mark up + NUT_UNUSED_VARIABLEs in the more portable manner + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: mark up + NUT_UNUSED_VARIABLEs in the more portable manner + * drivers/blazer_usb.c: drivers/blazer_usb.c: mark up + NUT_UNUSED_VARIABLEs in the more portable manner + * drivers/upsdrvctl.c: drivers/upsdrvctl.c: mark up + NUT_UNUSED_VARIABLEs in the more portable manner + * drivers/apc-hid.c: drivers/apc-hid.c: mark up NUT_UNUSED_VARIABLEs + in the more portable manner + * drivers/nutdrv_qx_voltronic.c: drivers/nutdrv_qx_voltronic.c: mark + up NUT_UNUSED_VARIABLEs in the more portable manner + * drivers/riello_usb.c: drivers/riello_usb.c: mark up + NUT_UNUSED_VARIABLEs in the more portable manner + * drivers/explore-hid.c: drivers/explore-hid.c: mark up + NUT_UNUSED_VARIABLEs in the more portable manner + * drivers/liebert-esp2.c: drivers/liebert-esp2.c: mark up + NUT_UNUSED_VARIABLEs in the more portable manner + * server/upsd.c: server/upsd.c: mark up NUT_UNUSED_VARIABLEs in the + more portable manner + * clients/upssched.c: clients/upssched.c: mark up + NUT_UNUSED_VARIABLEs in the more portable manner + * clients/upsset.c: clients/upsset.c: mark up NUT_UNUSED_VARIABLEs in + the more portable manner + * clients/upsimage.c: clients/upsimage.c: mark up + NUT_UNUSED_VARIABLEs in the more portable manner + * clients/upsstats.c: clients/upsstats.c: mark up + NUT_UNUSED_VARIABLEs in the more portable manner + * clients/upslog.c: clients/upslog.c: mark up NUT_UNUSED_VARIABLEs in + the more portable manner + * clients/upsmon.c: clients/upsmon.c: mark up NUT_UNUSED_VARIABLEs in + the more portable manner + * tools/nut-scanner/scan_eaton_serial.c: tools/nut- + scanner/scan_eaton_serial.c: mark up NUT_UNUSED_VARIABLEs in the + more portable manner + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + mark up NUT_UNUSED_VARIABLEs in the more portable manner + * tools/nut-scanner/scan_avahi.c: tools/nut-scanner/scan_avahi.c: + mark up NUT_UNUSED_VARIABLEs in the more portable manner + * drivers/libshut.c, drivers/riello_ser.c, drivers/snmp-ups.c, + tools/nut-scanner/scan_eaton_serial.c, tools/nut- + scanner/scan_snmp.c: libshut.c riello_ser.c nut-scanner bits: + abolish non-standard u_char and u_short Probably standard C99 + "uint8_t" and 16(?) bit short would be more proper, especially for + serial-line protocols. But the original code used types derived + from hardware implementation sized "char" and "short" - so they + stayed this way here. + * drivers/riello_usb.c: drivers/riello_usb.c: avoid implicit switch + fall-through + * clients/upsc.c: clients/upsc.c: avoid implicit switch fall-through + * clients/upscmd.c: clients/upscmd.c: avoid implicit switch fall- + through + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: avoid implicit switch + fall-through + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: avoid implicit switch + fall-through + * drivers/blazer_usb.c: drivers/blazer_usb.c: avoid implicit switch + fall-through + * server/upsd.c: server/upsd.c: add blank lines for readability of + opts processing switch + * server/upsd.c: server/upsd.c: avoid implicit switch fall-through + * clients/upsstats.h: clients/upsstats.h: wrap with include-guards + * clients/upssched.h: clients/upssched.h: wrap with include-guards + * clients/upsmon.h: clients/upsmon.h: wrap with include-guards + * clients/upslog.h: clients/upslog.h: wrap with include-guards + * clients/upsimagearg.h: clients/upsimagearg.h: wrap with include- + guards + * clients/status.h: clients/status.h: wrap with include-guards + * clients/cgilib.h: clients/cgilib.h: wrap with include-guards + * drivers/tripplite.h: drivers/tripplite.h: wrap with include-guards + * drivers/safenet.h: drivers/safenet.h: wrap with include-guards + * drivers/riello.h: drivers/riello.h: reword the wrap with include- + guards + * drivers/powercom.h: drivers/powercom.h: wrap with include-guards + * drivers/mge-utalk.h: include/mge-utalk.h: wrap with include-guards + * drivers/oneac.h: drivers/oneac.h: wrap with include-guards + * drivers/main.h: drivers/main.h: reword the wrap with include-guards + * drivers/libusb.h: drivers/libusb.h: reword the wrap with include- + guards + * drivers/libshut.h: drivers/libshut.h: reword the wrap with include- + guards + * drivers/libhid.h: drivers/libhid.h: reword the wrap with include- + guards + * drivers/hidparser.h: drivers/hidparser.h: reword the wrap with + include-guards + * drivers/genericups.h: drivers/genericups.h: wrap with include- + guards + * drivers/gamatronic.h: drivers/gamatronic.h: wrap with include- + guards and fix trailing whitespace + * drivers/dummy-ups.h: drivers/dummy-ups.h: wrap with include-guards + * drivers/apcupsd-ups.h: drivers/apcupsd-ups.h: wrap with include- + guards + * drivers/apcsmart_tabs.h: drivers/apcsmart_tabs.h: reword the wrap + with include-guards + * drivers/apcsmart.h: drivers/apcsmart.h: reword the wrap with + include-guards + * drivers/apcsmart-old.h: drivers/apcsmart-old.h: wrap with include- + guards + * include/upsconf.h: include/upsconf.h: wrap with include-guards + * include/upsconf.h: include/upsconf.h: add (C) and license header + * include/upsconf.h: include/upsconf.h: refine whitespace + * include/timehead.h: include/timehead.h: add (C) and license header + * include/timehead.h: include/timehead.h: wrap with include-guards + * include/str.h: include/str.h: reword the wrap with include-guards + * include/state.h: include/state.h: reword the wrap with include- + guards + * include/proto.h: include/proto.h: add (C) and license header + * include/proto.h: include/proto.h: reword the wrap with include- + guards + * include/nut_stdint.h: include/nut_stdint.h: reword the wrap with + include-guards + * include/nut_platform.h: include/nut_platform.h: reword the wrap + with include-guards + * include/extstate.h: include/extstate.h: add (C) and license header + * include/extstate.h: include/extstate.h: reword the wrap with + include-guards + * include/extstate.h: include/extstate.h: refine whitespace + * include/common.h: include/common.h: reword the wrap with include- + guards + * include/attribute.h: include/attribute.h: add (C) and license + header + * include/attribute.h: include/attribute.h: reword the wrap with + include-guards + * server/user.h: server/user.h: update (C) and license header + * server/user.h: server/user.h: wrap with include-guards + * server/user-data.h: server/user-data.h: update (C) and license + header + * server/user-data.h: server/user-data.h: wrap with include-guards + * server/upstype.h: server/upstype.h: reword the wrap with include- + guards + * server/stype.h: server/stype.h: reword the wrap with include-guards + * server/sstate.h: server/sstate.h: reword the wrap with include- + guards + * server/nut_ctype.h: server/nut_ctype.h: protect header files for + C++ inclusion + * server/netuser.h: server/netuser.h: wrap with include-guards + * server/netuser.h: server/netuser.h: add (C) and license header + * server/netssl.h: server/netssl.h: reword the wrap with include- + guards + * server/netset.h: server/netset.h: wrap with include-guards + * server/netset.h: server/netset.h: add (C) and license header + * server/netmisc.h: server/netmisc.h: wrap with include-guards + * server/netmisc.h: server/netmisc.h: add (C) and license header + * server/netcmds.h: server/netcmds.h: add (C) and license header + * server/netlist.h: server/netlist.h: wrap with include-guards + * server/netlist.h: server/netlist.h: add (C) and license header + * server/netinstcmd.h: server/netinstcmd.h: wrap with include-guards + * server/netinstcmd.h: server/netinstcmd.h: add (C) and license + header + * server/netget.h: server/netget.h: wrap with include-guards + * server/netget.h: server/netget.h: add (C) and license header + * server/neterr.h: server/neterr.h: protect header files for C++ + inclusion + * server/neterr.h: server/neterr.h: wrap with include-guards + * server/neterr.h: server/neterr.h: add (C) and license header + * server/netcmds.h: server/netcmds.h: wrap with include-guards + * server/desc.h: server/desc.h: add (C) and license header + * server/desc.h: server/desc.h: wrap with include-guards + * server/conf.h: server/conf.h: update (C) and license header + * server/conf.h: server/conf.h: wrap with include-guards + +2020-11-09 Jim Klimov + + * docs/nut.dict: Update nut.dict Add EVER Sinline model name + +2020-11-09 Jim Klimov + + * drivers/asem.c: drivers/al175.c: update Linux i2c include mesh + (thanks to pijuice.c) + * drivers/pijuice.c: drivers/pijuice.c: set_power_off(): drop unused + "data" + * drivers/pijuice.c: drivers/pijuice.c: avoid setting "data" during a + write Compiler warnings resolved this puzzle: [2020-11-09 + 15:10:38] [build-err] pijuice.c:737:2: note: in expansion of macro + ‘I2C_WRITE_BYTE’ [2020-11-09 15:10:38] [build-err] 737 | + I2C_WRITE_BYTE( upsfd, cmd, shutdown_delay, __func__ ) [2020-11-09 + 15:10:38] [build-err] | ^~~~~~~~~~~~~~ [2020-11-09 15:10:38] + [build-err] pijuice.c:710:10: warning: variable ‘data’ set but not + used [-Wunused-but-set-variable] [2020-11-09 15:10:38] [build-err] + 710 | uint8_t data; [2020-11-09 15:10:38] [build-err] | + ^~~~ So we did not need to set it at all, can go to simple + anonymous negative-return check. + * drivers/pijuice.c: drivers/pijuice.c: use "__s32" de-facto in + headers instead of "s32" from manpages + * drivers/pijuice.c: drivers/pijuice.c: rearrange I2C_*() macros to + catch -1 error codes while fetching unsigned ints + * drivers/apcsmart.c: drivers/apcsmart.c: fix variadic macro logx() + call to accomodate modern standards + * drivers/apcsmart.c: drivers/apcsmart.c: fix variadic macro logx() + call to accomodate modern standards + * drivers/apcsmart.c: drivers/apcsmart.c: fix variadic macro debx() + call to accomodate modern standards + * drivers/pijuice.c: drivers/pijuice.c: set_poweroff(): fix limited + value range exceeded + * drivers/pijuice.c: drivers/pijuice.c: replace __FUNCTION__ by + __func__ to avoid warnings error: ISO C does not support + '__FUNCTION__' predefined identifier [-Werror=pedantic] + * drivers/bcmxcp.c: drivers/bcmxcp.c: bump string buffer size to + avoid potential overflows If we have some bug getting outlet + numbers into billions (int at 64-bit) the string might overflow + indeed... + * drivers/al175.c: drivers/al175.c: document a warning to address + later + * drivers/snmp-ups.c: drivers/snmp-ups.c: avoid warning: control may + reach end of non-void function + +2020-11-08 Jim Klimov + + * drivers/nutdrv_atcl_usb.c: drivers/nutdrv_atcl_usb.c: avoid + implicit switch fall-through + * .travis.yml: .travis.yml: our code (and checks) should not rely on + specific compiler features; implicit switch FALLTHRU was solved by + explicit goto jumps + * docs/nut.dict: docs/nut.dict: update for conf/upsstats- + single.html.sample + * docs/developers.txt: docs/developers.txt: avoid spellcheck warning + * drivers/eaton-pdu-marlin-mib.c: drivers/eaton-pdu-marlin-mib.c: + rearrange phases_nb and sanity-check the value to debug-log + unexpectancies + * drivers/eaton-pdu-marlin-mib.c: drivers/eaton-pdu-marlin-mib.c: + sanity-check the outlet_group_nb (not negative) + +2020-11-05 Jim Klimov + + * drivers/hidparser.c: drivers/hidparser.c: hide logging check that + never fires hidparser.c:347:28: error: comparison is always false + due to limited range of data type [-Werror=type-limits] 347 | + if(pParser->Data.ReportID >= MAX_REPORT) uint8_t vs "500" CC + @aquette + +2020-11-06 Jim Klimov + + * tools/nut-scanner/scan_xml_http.c: tools/nut- + scanner/scan_xml_http.c: drop g_usec_timeout which is not actually + used + * drivers/libusb.c: drivers/libusb.c: fix debug string formatting + +2020-11-05 Jim Klimov + + * drivers/solis.h: drivers/solis.h: swap "const static" => "static + const" Avoids error: 'static' is not at beginning of declaration + [-Werror=old-style-declaration] + * drivers/solis.c: drivers/solis.c: rectify C-style comments + * drivers/isbmex.c: drivers/isbmex.c: comment about magic D() macro + got debug logging vs. upsdebugx() + * drivers/rhino.c: drivers/rhino.c: ScanReceivePack(): rephrase if- + clause to avoid warnings Seems this is a correct change logically: + - if( !( SourceFail ) == RedeAnterior ) + if( RedeAnterior == !( + SourceFail ) ) given this assignment just below the if-clause: + RedeAnterior = !( SourceFail ); to avoid a compiler warning that + "!" might apply not in a way intended by author + * drivers/masterguard.c: drivers/masterguard.c: StringSplit(): use + the maxlen + * drivers/liebert-esp2.c: drivers/liebert-esp2.c: setvar(): find a + use for "val" + +2020-11-04 Jim Klimov + + * clients/upssched.c: clients/upssched.c: main(): find use for argc + * clients/upsmon.c: clients/upsmon.c: sigpipe(): find use for sig + * clients/upsset.c: clients/upsset.c: print_rw(): find use for + upsname + +2020-11-08 Jim Klimov + + * drivers/blazer_usb.c: drivers/blazer_usb.c: upsdrv_initups(): + constrain langid_fix scanned values to fit into signed int + +2020-11-06 Jim Klimov + + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: upsdrv_initups(): + constrain langid_fix scanned values to fit into signed int + +2020-11-08 Jim Klimov + + * drivers/netxml-ups.c: drivers/netxml-ups.c: rearrange sscanf() of + inputs to avoid wrong int values + +2020-11-06 Jim Klimov + + * drivers/nutdrv_qx_voltronic.c: drivers/nutdrv_qx_voltronic.c: avoid + buffer overflows iterating item->info_rw, possible NPE, and fix the + check for hitting the sentinel entry Fix warnings like: + nutdrv_qx_voltronic.c:4037:39: error: division 'sizeof (info_rw_t + *) / sizeof (info_rw_t)' does not compute the number of array + elements [-Werror=sizeof-pointer-div] 4037 | if (i >= + (int)(sizeof(item->info_rw) / sizeof(item->info_rw[0]))) { | + ^ nutdrv_qx_voltronic.c: In function 'voltronic_p31g_set': + * drivers/nutdrv_qx_voltronic.c: drivers/nutdrv_qx_voltronic.c: + voltronic_fault(): avoid buffer overflows with sprintf() + +2020-11-04 Jim Klimov + + * clients/upscmd.c: clients/upscmd.c: increase buffers to avoid + overflow (warnings) + * clients/upsrw.c: clients/upsrw.c: increase buffers to avoid + overflow (warnings) + +2020-11-05 Jim Klimov + + * drivers/bestfcom.c: drivers/bestfcom.c: increase buffers to avoid + overflow (warnings) + * drivers/bcmxcp.c: drivers/bcmxcp.c: setvar(): increase buffers to + avoid overflow (warnings) + +2020-11-04 Jim Klimov + + * clients/upssched.c: clients/upssched.c: increase buffers to avoid + overflow (warnings) + +2020-11-06 Jim Klimov + + * tools/nut-scanner/scan_xml_http.c: tools/nut- + scanner/scan_xml_http.c: avoid possible buffer overflow + * drivers/snmp-ups.c: drivers/snmp-ups.c: su_alarm_set(): bump + alarm_info_value size to avoid print overflows + +2020-11-08 Jim Klimov + + * drivers/belkin-hid.c: drivers/belkin-hid.c: use fabs() for + floating-point math + * drivers/belkin-hid.c: drivers/belkin-hid.c: use fabs() for + floating-point math + +2020-11-06 Jim Klimov + + * drivers/upscode2.c: drivers/upscode2.c: use fabs() for floating- + point math + +2020-11-08 Jim Klimov + + * drivers/netxml-ups.c: drivers/netxml-ups.c: instcmd(): find a use + for "extra" + * drivers/riello_usb.c: drivers/riello_usb.c: instcmd(): find a use + for "extra" + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: instcmd(): find a + use for "extra" + +2020-11-06 Jim Klimov + + * drivers/riello_ser.c: drivers/riello_ser.c: instcmd(): find a use + for "extra" + * drivers/apcsmart-old.c: drivers/apcsmart-old.c: instcmd(): find a + use for "extra" + * drivers/ivtscd.c: drivers/ivtscd.c: instcmd(): find a use for + "extra" + * drivers/clone.c: drivers/clone.c: instcmd(): find a use for "extra" + * drivers/powerman-pdu.c: drivers/powerman-pdu.c: instcmd(): find a + use for "extra" + * drivers/powerp-txt.c: drivers/powerp-txt.c: powpan_instcmd(): find + a use for "extra" + * drivers/powerp-bin.c: drivers/powerp-bin.c: powpan_instcmd(): find + a use for "extra" + * drivers/victronups.c: drivers/victronups.c: instcmd(): find a use + for "extra" + +2020-11-05 Jim Klimov + + * drivers/tripplitesu.c: drivers/tripplitesu.c: instcmd(): find a use + for "extra" + * drivers/tripplite.c: drivers/tripplite.c: instcmd(): find a use for + "extra" + * drivers/solis.c: drivers/solis.c: instcmd(): find a use for "extra" + * drivers/nutdrv_siemens_sitop.c: drivers/nutdrv_siemens_sitop.c: + instcmd(): find a use for "extra" + * drivers/safenet.c: drivers/safenet.c: instcmd(): find a use for + "extra" + * drivers/rhino.c: drivers/rhino.c: instcmd(): find a use for "extra" + * drivers/powercom.c: drivers/powercom.c: instcmd(): find a use for + "extra" + * drivers/optiups.c: drivers/optiups.c: instcmd(): find a use for + "extra" + * drivers/mge-utalk.c: drivers/mge-utalk.c: instcmd(): find a use for + "extra" + * drivers/metasys.c: drivers/metasys.c: instcmd(): find a use for + "extra" + * drivers/liebert-esp2.c: drivers/liebert-esp2.c: instcmd(): find a + use for "extra" + * drivers/etapro.c: drivers/etapro.c: instcmd(): find a use for + "extra" + * drivers/dummy-ups.c: drivers/dummy-ups.c: instcmd(): find a use for + "extra" + * drivers/bestups.c: drivers/bestups.c: instcmd(): find a use for + "extra" + * drivers/bestfortress.c: drivers/bestfortress.c: instcmd(): find a + use for "extra" + * drivers/belkinunv.c: drivers/belkinunv.c: instcmd(): find a use for + "extra" + * drivers/belkin.c: drivers/belkin.c: instcmd(): find a use for + "extra" + * drivers/bcmxcp.c: drivers/bcmxcp.c: instcmd(): find a use for + "extra" + +2020-11-04 Jim Klimov + + * drivers/al175.c: drivers/al175.c: instcmd(): find use for "extra" + +2020-11-08 Jim Klimov + + * drivers/mge-xml.c: drivers/mge-xml.c: mark up NUT_UNUSED_VARIABLEs + * drivers/netxml-ups.c: drivers/netxml-ups.c: mark up + NUT_UNUSED_VARIABLEs + * drivers/nutdrv_atcl_usb.c: drivers/nutdrv_atcl_usb.c: mark up + NUT_UNUSED_VARIABLEs + * drivers/riello_usb.c: drivers/riello_usb.c: mark up + NUT_UNUSED_VARIABLEs + * drivers/richcomm_usb.c: drivers/richcomm_usb.c: mark up + NUT_UNUSED_VARIABLEs + * drivers/blazer_usb.c: drivers/blazer_usb.c: mark up + NUT_UNUSED_VARIABLEs + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: mark up + NUT_UNUSED_VARIABLEs + * drivers/bcmxcp_usb.c: drivers/bcmxcp_usb.c: mark up + NUT_UNUSED_VARIABLEs + * drivers/tripplite-hid.c: drivers/tripplite-hid.c: mark up + NUT_UNUSED_VARIABLEs + * drivers/explore-hid.c: drivers/explore-hid.c: mark up + NUT_UNUSED_VARIABLEs + * drivers/explore-hid.c: drivers/explore-hid.c: a few whitespace + fixes + * drivers/cps-hid.c: drivers/cps-hid.c: mark up NUT_UNUSED_VARIABLEs + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: mark up + NUT_UNUSED_VARIABLEs + +2020-11-06 Jim Klimov + + * drivers/nutdrv_qx_voltronic.c: drivers/nutdrv_qx_voltronic.c: mark + up NUT_UNUSED_VARIABLEs + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: mark up + NUT_UNUSED_VARIABLEs + * drivers/apcsmart-old.c: drivers/apcsmart-old.c: mark up + NUT_UNUSED_VARIABLEs + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + mark up NUT_UNUSED_VARIABLEs + * server/netuser.c: server/netuser.c: mark up NUT_UNUSED_VARIABLEs + * server/netmisc.c: server/netmisc.c: mark up NUT_UNUSED_VARIABLEs + * server/netssl.c: server/netssl.c: mark up NUT_UNUSED_VARIABLEs + * server/upsd.c: server/upsd.c: mark up NUT_UNUSED_VARIABLEs + * drivers/upsdrvctl.c: drivers/upsdrvctl.c: mark up + NUT_UNUSED_VARIABLEs + * drivers/apcsmart.c: drivers/apcsmart.c: mark up + NUT_UNUSED_VARIABLEs + +2020-11-05 Jim Klimov + + * drivers/mge-hid.c: drivers/mge-hid.c: mark up NUT_UNUSED_VARIABLEs + * drivers/libshut.c: drivers/libshut.c: mark up NUT_UNUSED_VARIABLEs + * drivers/liebert-esp2.c: drivers/liebert-esp2.c: mark up + NUT_UNUSED_VARIABLEs + * drivers/dummy-ups.c: drivers/dummy-ups.c: mark up + NUT_UNUSED_VARIABLEs + * drivers/bestfortress.c: drivers/bestfortress.c: mark up + NUT_UNUSED_VARIABLEs + * drivers/bestfcom.c: drivers/bestfcom.c: mark up + NUT_UNUSED_VARIABLEs + +2020-11-06 Jim Klimov + + * tools/nut-scanner/scan_eaton_serial.c: tools/nut- + scanner/scan_eaton_serial.c: mark up NUT_UNUSED_VARIABLEs + * tools/nut-scanner/scan_avahi.c: tools/nut-scanner/scan_avahi.c: + mark up NUT_UNUSED_VARIABLEs + +2020-11-04 Jim Klimov + + * drivers/serial.c: drivers/serial.c: mark up NUT_UNUSED_VARIABLEs + * clients/upssched.c: clients/upssched.c: mark up + NUT_UNUSED_VARIABLEs + * clients/upsmon.c: clients/upsmon.c: mark up NUT_UNUSED_VARIABLEs + * clients/upsset.c: clients/upsset.c: mark up NUT_UNUSED_VARIABLEs + * clients/upsimage.c, clients/upsstats.c: clients/upsimage.c: mark up + NUT_UNUSED_VARIABLEs + * clients/upsstats.c: clients/upsstats.c: mark up + NUT_UNUSED_VARIABLEs + * clients/upslog.c: clients/upslog.c: mark up NUT_UNUSED_VARIABLEs + * clients/upsclient.c: clients/upsclient.c: mark up + NUT_UNUSED_VARIABLEs for ifdef-ed codepaths + +2020-11-08 Jim Klimov + + * drivers/apc-hid.c: drivers/apc-hid.c: mark up NUT_UNUSED_VARIABLEs + (and comment a FIXME about possible use for that) + +2020-11-04 Jim Klimov + + * include/common.h: include/common.h: introduce NUT_UNUSED* macros to + mark up codebase + +2020-11-08 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c: comment about issue found + by pedantic compiler snmp-ups.c: In function 'nut_snmp_init': + snmp-ups.c:599:66: error: division 'sizeof (oid * {aka long + unsigned int *}) / sizeof (oid {aka long unsigned int})' does not + compute the number of array elements [-Werror=sizeof-pointer-div] + 599 | g_snmp_sess.securityPrivProtoLen = + sizeof(usmAESPrivProtocol)/sizeof(oid); | + ^ In file included from /usr/include/net-snmp/snmpv3_api.h:27, from + /usr/include/net-snmp/net-snmp-includes.h:78, from snmp-ups.h:79, + from snmp-ups.c:39: /usr/include/net- + snmp/library/transform_oids.h:50:26: note: first 'sizeof' operand + was declared here 50 | NETSNMP_IMPORT oid + *usmAES128PrivProtocol; /* backwards compat */ | + ^~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors + make[1]: *** [Makefile:1953: snmp_ups-snmp-ups.o] Error 1 + +2020-11-08 Jim Klimov + + * docs/developers.txt: Update developers.txt Another spellcheck fix + * docs/developers.txt: Update developers.txt Avoid "quiesce" to + satisfy the spellchecker + +2020-11-08 Jim Klimov + + * drivers/apc-hid.c: drivers/apc-hid.c: a few whitespace fixes + * drivers/openups-hid.c: drivers/openups-hid.c: initialize all fields + of info_lkp_t arrays + * drivers/tripplite-hid.c: drivers/tripplite-hid.c: initialize all + fields of info_lkp_t arrays + * drivers/powercom-hid.c: drivers/powercom-hid.c: initialize all + fields of info_lkp_t arrays + * drivers/cps-hid.c: drivers/cps-hid.c: initialize all fields of + info_lkp_t arrays + * drivers/belkin-hid.c: drivers/belkin-hid.c: initialize all fields + of info_lkp_t arrays + * drivers/apc-hid.c: drivers/apc-hid.c: initialize all fields of + info_lkp_t arrays + * drivers/apc-pdu-mib.c: drivers/apc-pdu-mib.c: define + APC_PDU_DEVICE_MODEL macro on top of file + * drivers/apc-pdu-mib.c: drivers/apc-pdu-mib.c: initialize all fields + of mib2nut_info_t arrays + * drivers/apc-pdu-mib.c: drivers/apc-pdu-mib.c: initialize all fields + of info_lkp_t arrays + * drivers/apc-ats-mib.c: drivers/apc-ats-mib.c: initialize all fields + of mib2nut_info_t array + * drivers/apc-ats-mib.c: drivers/apc-ats-mib.c: initialize all fields + of info_lkp_t arrays + * drivers/eaton-ats16-mib.c: drivers/eaton-ats16-mib.c: initialize + all fields of mib2nut_info_t arrays + * drivers/eaton-ats16-mib.c: drivers/eaton-ats16-mib.c: initialize + all fields of info_lkp_t arrays + * drivers/huawei-mib.c: drivers/huawei-mib.c: initialize all fields + of mib2nut_info_t array + * drivers/huawei-mib.c: drivers/huawei-mib.c: initialize all fields + of info_lkp_t arrays + * drivers/hpe-pdu-mib.c: drivers/hpe-pdu-mib.c: initialize all fields + of mib2nut_info_t array + * drivers/hpe-pdu-mib.c: drivers/hpe-pdu-mib.c: initialize all fields + of info_lkp_t arrays + * drivers/eaton-ats30-mib.c: drivers/eaton-ats30-mib.c: initialize + all fields of mib2nut_info_t array + * drivers/eaton-ats30-mib.c: drivers/eaton-ats30-mib.c: initialize + all fields of info_lkp_t arrays + * drivers/delta_ups-mib.c: drivers/delta_ups-mib.c: initialize all + fields of mib2nut_info_t array + * drivers/delta_ups-mib.c: drivers/delta_ups-mib.c: initialize all + fields of info_lkp_t arrays + * drivers/cyberpower-mib.c: drivers/cyberpower-mib.c: initialize all + fields of mib2nut_info_t array + * drivers/cyberpower-mib.c: drivers/cyberpower-mib.c: initialize all + fields of info_lkp_t arrays + * drivers/bestpower-mib.c: drivers/bestpower-mib.c: initialize all + fields of mib2nut_info_t array + * drivers/bestpower-mib.c: drivers/bestpower-mib.c: initialize all + fields of info_lkp_t arrays + * drivers/xppc-mib.c: drivers/xppc-mib.c: initialize all fields of + info_lkp_t arrays, and end sentinel entries to close them off + * docs/developers.txt, docs/nut.dict: Satisfy the spellchecker + * drivers/xppc-mib.c: drivers/xppc-mib.c: initialize all fields of + mib2nut_info_t array + * drivers/raritan-pdu-mib.c: drivers/raritan-pdu-mib.c: initialize + all fields of mib2nut_info_t array + * drivers/raritan-px2-mib.c: drivers/raritan-px2-mib.c: initialize + all fields of mib2nut_info_t array + * drivers/raritan-px2-mib.c: drivers/raritan-px2-mib.c: fix + indentations + * drivers/raritan-px2-mib.c: drivers/raritan-px2-mib.c: initialize + all fields of info_lkp_t arrays, and fix indentations in the table + * drivers/raritan-pdu-mib.c: drivers/raritan-pdu-mib.c: initialize + all fields of info_lkp_t arrays + * drivers/powerware-mib.c: drivers/powerware-mib.c: initialize all + fields of info_lkp_t arrays + * drivers/netvision-mib.c: drivers/netvision-mib.c: initialize all + fields of mib2nut_info_t array + * drivers/netvision-mib.c: drivers/netvision-mib.c: initialize all + fields of info_lkp_t arrays + * drivers/mge-mib.c: drivers/mge-mib.c: initialize all fields of + mib2nut_info_t array + * drivers/mge-mib.c: drivers/mge-mib.c: initialize all fields of + info_lkp_t arrays + * drivers/ietf-mib.c: drivers/ietf-mib.c: initialize all fields of + mib2nut_info_t arrays + * drivers/ietf-mib.c: drivers/ietf-mib.c: initialize all fields of + info_lkp_t arrays + * drivers/emerson-avocent-pdu-mib.c: drivers/emerson-avocent-pdu- + mib.c: initialize all fields of info_lkp_t arrays + * drivers/emerson-avocent-pdu-mib.c: drivers/emerson-avocent-pdu- + mib.c: initialize all fields of mib2nut_info_t array + * drivers/eaton-pdu-revelation-mib.c: drivers/eaton-pdu-revelation- + mib.c: initialize all fields of mib2nut_info_t array + * drivers/eaton-pdu-revelation-mib.c: drivers/eaton-pdu-revelation- + mib.c: initialize all fields of info_lkp_t arrays + * drivers/eaton-pdu-pulizzi-mib.c: drivers/eaton-pdu-pulizzi-mib.c: + initialize all fields of mib2nut_info_t array + * drivers/eaton-pdu-pulizzi-mib.c: drivers/eaton-pdu-pulizzi-mib.c: + initialize all fields of info_lkp_t arrays + * drivers/eaton-pdu-marlin-mib.c: drivers/eaton-pdu-marlin-mib.c: + initialize all fields of mib2nut_info_t array + * drivers/eaton-pdu-marlin-mib.c: drivers/eaton-pdu-marlin-mib.c: + initialize all fields of info_lkp_t arrays + * drivers/eaton-pdu-genesis2-mib.c: drivers/eaton-pdu-genesis2-mib.c: + initialize all fields of mib2nut_info_t array + * drivers/compaq-mib.c: drivers/compaq-mib.c: initialize all fields + of mib2nut_info_t array + * drivers/compaq-mib.c: drivers/compaq-mib.c: initialize all fields + of info_lkp_t arrays + * drivers/baytech-mib.c: drivers/baytech-mib.c: initialize all fields + of mib2nut_info_t array + * drivers/baytech-mib.c: drivers/baytech-mib.c: initialize all fields + of info_lkp_t arrays + * drivers/apc-mib.c: drivers/apc-mib.c: initialize all fields of + mib2nut_info_t array (and comment concern whether the addition was + right?) + * drivers/apc-mib.c: drivers/apc-mib.c: replace verbatim OID string + we seek with a macro APC_UPS_DEVICE_MODEL like elsewhere + * drivers/apc-mib.c: drivers/apc-mib.c: initialize all fields of + info_lkp_t arrays + +2020-11-06 Jim Klimov + + * drivers/apcsmart_tabs.c: drivers/apcsmart_tabs.c: initialize all + fields of upsdrv_info_t array + * drivers/apcsmart_tabs.c: drivers/apcsmart_tabs.c: initialize all + fields of apc_vartab_t arrays + * tools/nut-scanner/nutscan-serial.c: tools/nut-scanner/nutscan- + serial.c: initialize all fields of device_portname_t arrays + * drivers/upscode2.c: drivers/upscode2.c: initialize all fields of + cmd_t and simple_t arrays + +2020-11-05 Jim Klimov + + * drivers/optiups.c: drivers/optiups.c: initialize all fields of + ezfill_t tables + * drivers/mge-hid.c: drivers/mge-hid.c: update arrays of info_lkp_t + with fourth (nuf) field and comment where a real nuf() might be + useful + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: update arrays of + info_lkp_t with fourth (nuf) field and comment where a real nuf() + might be useful + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: update arrays of + info_lkp_t with fourth (nuf) field + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: update HIDDevice_t + object with missing initializer for bcdDevice + * drivers/mge-hid.c: drivers/mge-utalk.c: update arrays of info_lkp_t + with fourth (nuf) field + * drivers/gamatronic.h: drivers/gamatronic.h: initialize the "value" + field in the struct array + * drivers/gamatronic.h: drivers/gamatronic.h: avoid anonymous struct + +2020-11-04 Jim Klimov + + * drivers/bcmxcp.c: drivers/bcmxcp.c: fix info_lkp_t arrays to + consider fourth "nuf" field + +2020-11-08 Jim Klimov + + * drivers/mge-xml.c: drivers/mge-xml.c: avoid implicit switch fall- + through (comment whether that wondering is the right thing to do + though) + +2020-11-06 Jim Klimov + + * drivers/upscode2.c: drivers/upscode2.c: comment the fallthrough in + upsc_simple() switch, so far consider it explicitly desired as it + was before + * drivers/isbmex.c: drivers/isbmex.c: replace FALLTHRU comments with + more portable and reliable goto jumps + +2020-11-05 Jim Klimov + + * drivers/isbmex.c: drivers/isbmex.c: upsdrv_updateinfo(): fix + switch/break + +2020-11-08 Jim Klimov + + * drivers/blazer_usb.c: drivers/blazer_usb.c: avoid implicit switch + fall-through + * drivers/riello_usb.c: drivers/riello_usb.c: avoid implicit switch + fall-through + * drivers/tripplite_usb.c: drivers/tripplite_usb.c: avoid implicit + switch fall-through + +2020-11-06 Jim Klimov + + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + explicit fall through to displaying help + * drivers/nutdrv_qx.c: drivers/nutdrv_qx.c: qx_command(): explicit + fall through the switch + * drivers/mge-hid.c: drivers/mge-hid.c: replace FALLTHRU comments + with same returns as the next default case + +2020-11-05 Jim Klimov + + * drivers/mge-hid.c: drivers/mge-hid.c: quiesce -Wimplicit- + fallthrough=3 warnings about fall-through in switch + +2020-11-06 Jim Klimov + + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: replace FALLTHRU + comments with more portable and reliable goto jumps + +2020-11-05 Jim Klimov + + * drivers/usbhid-ups.c: drivers/usbhid-ups.c: quiesce -Wimplicit- + fallthrough=3 warnings about fall-through in switch + +2020-11-06 Jim Klimov + + * clients/upsc.c: clients/upsc.c: replace FALLTHRU comments with more + portable and reliable goto jumps + +2020-11-04 Jim Klimov + + * clients/upsc.c: clients/upsc.c: quiesce -Wimplicit-fallthrough=3 + warnings about fall-through in switch + +2020-11-06 Jim Klimov + + * common/snprintf.c: common/snprintf.c: replace FALLTHRU comments + with more portable and reliable goto jumps + +2020-11-04 Jim Klimov + + * common/snprintf.c: common/snprintf.c: quiesce -Wimplicit- + fallthrough=3 warnings about fall-through in switch + +2020-11-08 Jim Klimov + + * ci_build.sh: ci_build.sh: refactor to track failing "default-all- + errors" so we can extend it to "configure_nut()" and + "build_to_only_catch_errors()" more variants + * ci_build.sh: ci_build.sh: refactor to have a + build_to_only_catch_errors() routine + * ci_build.sh: ci_build.sh: refactor to have a configure_nut() + routine + * docs/developers.txt: docs/developers.txt: document a valid use-case + of goto for clean switch-case fall-through + +2020-11-04 Jim Klimov + + * include/common.h: include/common.h: introduce NUT_UNUSED* macros to + mark up codebase + +2020-11-05 Jim Klimov + + * .travis.yml: .travis.yml: in NUT_MATRIX test cases, specify + -Werror=implicit-fallthrough=3 to let special comments quiesce the + warning where a FALLTHRU is intentional + * .travis.yml: .travis.yml: in clang test cases, do not insist that + all macros are used, or we can not pass even autoconf + +2020-11-04 Jim Klimov + + * .travis.yml: .travis.yml : enable "-Wextra -Weverything" for clang + (follow-up to issue #823) + * .travis.yml: .travis.yml : enable "-Wextra" for newer gcc versions + on Linux (follow-up to issue #823) + * .travis.yml: .travis.yml : enable "-Wextra" for default gcc + versions on Linux (follow-up to issue #823) + * configure.ac: configure.ac: revise the fix for AC_PROG_LIBTOOL to + only revert settings already passed to the compiler (that older + releases may not understand if we just force them) + * configure.ac: configure.ac : work around libtool weakness seen by + pedantic compilers (did not test for "${CLANG}" so drop it for now) + * configure.ac: configure.ac : work around libtool weakness seen by + pedantic compilers + * ci_build.sh: ci_build.sh: do not hide autogen.sh stderr + * ci_build.sh: ci_build.sh: if configure failed, sleep a bit before + dumping config.log + +2020-11-03 Jim Klimov + + * ci_build.sh: ci_build.sh : if configure script fails, dump its log + before exiting + * .travis.yml: .travis.yml : rephrase some comments + * .travis.yml: .travis.yml : separate the "_matrix_gnustd_nowarn" + * .travis.yml: Issue #823 follow-up: support branches named like + "fightwarn" to build more test cases in Travis CI (actually enable + those build matrices) + * .travis.yml: Issue #823 follow-up: support branches named like + "fightwarn" to build more test cases in Travis CI + +2020-11-07 Jim Klimov + + * drivers/eaton-ats16-mib.c: Update eaton-ats16-mib.c Reworded the + comments + * drivers/nutdrv_qx.c: Update nutdrv_qx.c drivers/nutdrv_qx.c: + rectify indentations + * drivers/tripplite_usb.c: Update tripplite_usb.c + drivers/tripplite_usb.c: drop trailing whitespace + * docs/acknowledgements.txt: Update acknowledgements.txt Acknowledge + a vendor contribution from EVER Power Systems + * drivers/ever-hid.c: Update ever-hid.c Small whitespace fixes + * docs/acknowledgements.txt: Update acknowledgements.txt Add vendor + contribution from AMETEK Powervar for UPM series + * drivers/liebert-hid.c: Update liebert-hid.c Minor whitespace fixes + +2020-11-06 Jim Klimov + + * configure.ac: configure.ac: drop trailing whitespace + * tools/nut-usbinfo.pl: tools/nut-usbinfo.pl: drop trailing + whitespace + * tools/nut-recorder.sh: tools/nut-recorder.sh: drop trailing + whitespace + * tools/nut-ddl-dump.sh: tools/nut-ddl-dump.sh: drop trailing + whitespace + * tests/nutclienttest.cpp: tests/nutclienttest.cpp: drop trailing + whitespace + * server/user.c: server/user.c: drop trailing whitespace + * server/upstype.h: server/upstype.h: drop trailing whitespace + * server/sstate.c: server/sstate.c: drop trailing whitespace + * server/sockdebug.c: server/sockdebug.c: drop trailing whitespace + * server/netlist.c: server/netlist.c: drop trailing whitespace + * server/netinstcmd.c: server/netinstcmd.c: drop trailing whitespace + * server/netget.c: server/netget.c: drop trailing whitespace + * server/conf.c: server/conf.c: drop trailing whitespace + * common/upsconf.c: common/upsconf.c: drop trailing whitespace + * common/state.c: common/state.c: drop trailing whitespace + * common/setenv.c: common/setenv.c: drop trailing whitespace + * common/parseconf.c: common/parseconf.c: drop trailing whitespace + * clients/upsmon.h: clients/upsmon.h: drop trailing whitespace + * clients/upsimagearg.h: clients/upsimagearg.h: rectify whitespace + * clients/upsclient.h: clients/upsclient.h: drop trailing whitespace + * clients/nutclient.cpp, clients/nutclient.h: + clients/nutclient.{cpp,h}: drop trailing whitespace + * clients/cgilib.c: clients/cgilib.c: drop trailing whitespace + * drivers/nut-ipmipsu.c, drivers/nut-libfreeipmi.c: + drivers/nut-*ipmi**.{c,h}: drop trailing whitespace + * drivers/netxml-ups.c, drivers/netxml-ups.h: drivers/netxml- + ups.{c,h}: drop trailing whitespace + * drivers/mge-utalk.h, drivers/mge-xml.c, drivers/mge-xml.h: + drivers/mge*.{c,h}: drop trailing whitespace + * drivers/main.h: drivers/main.h: drop trailing whitespace + * drivers/main.c: Drop exec bit from source file + * drivers/liebert-hid.h, drivers/liebert.c: drivers/liebert*: drop + trailing whitespace + * drivers/libhid.c: drivers/libhid.h: drop trailing whitespace + * drivers/idowell-hid.c: drivers/idowell-hid.h: drop trailing + whitespace + * drivers/hidtypes.h: drivers/hidtypes.h: drop trailing whitespace + * drivers/genericups.h: drivers/genericups.h: drop trailing + whitespace + * drivers/everups.c: drivers/everups.c: drop trailing whitespace + * drivers/eaton-pdu-pulizzi-mib.c: drivers/eaton-pdu-pulizzi-mib.c: + drop trailing whitespace + * drivers/dummy-ups.h: drivers/dummy-ups.h: drop trailing whitespace + * drivers/dstate.c: drivers/dstate.c: drop trailing whitespace + * drivers/delta_ups-mib.c: drivers/delta_ups-mib.c: drop trailing + whitespace + * drivers/cyberpower-mib.c: drivers/cyberpower-mib.c: drop trailing + whitespace + * drivers/blazer.c, drivers/blazer_usb.c: drivers/blazer*.{c,h}: drop + trailing whitespace + * drivers/bestuferrups.c: drivers/bestuferrups.c: rectify + indentations + * drivers/bestuferrups.c: drivers/bestuferrups.c: drop trailing + whitespace + * drivers/belkin-hid.c, drivers/belkin-hid.h: drivers/belkin*.{c,h}: + drop trailing whitespace + * drivers/bcmxcp_io.h, drivers/bcmxcp_ser.c, drivers/bcmxcp_usb.c: + drivers/bcmxcp*.{c,h}: drop trailing whitespace + * drivers/baytech-mib.c: drivers/baytech-mib.c: drop trailing + whitespace + * drivers/apc-mib.c: drivers/apc-mib.c: drop trailing whitespace + * drivers/apc-hid.c, drivers/apc-hid.h: drivers/apc-hid.{c,h}: drop + trailing whitespace + * drivers/xppc-mib.c: drivers/xppc-mib.h: drop trailing whitespace + * drivers/tripplite-hid.h: drivers/tripplite-hid.h: drop trailing + whitespace + * drivers/snmp-ups.h: drivers/snmp-ups.h: drop trailing whitespace + * drivers/skel.c: drivers/skel.c: drop trailing whitespace + * drivers/richcomm_usb.c: drivers/richcomm_usb.c: drop trailing + whitespace + * drivers/powerware-mib.c: drivers/powerware-mib.c: drop trailing + whitespace + * drivers/openups-hid.c: drivers/openups-hid.c: drop trailing + whitespace + * drivers/oneac.c, drivers/oneac.h: drivers/oneac.{c,h}: drop + trailing whitespace + * drivers/nutdrv_atcl_usb.c: drivers/nutdrv_atcl_usb.c: drop trailing + whitespace + * drivers/riello.c, drivers/riello_ser.c, drivers/riello_usb.c: + drivers/riello*.{c,h}: drop trailing whitespaces + * drivers/apcsmart-old.c, drivers/apcsmart-old.h: drivers/apcsmart- + old.{c,h}: drop trailing whitespaces + * tools/nut-scanner/nut-scanner.c: tools/nut-scanner/nut-scanner.c: + fix whitespaces + * tools/nut-scanner/nut-scanner.c, tools/nut-scanner/nutscan-ip.c, + tools/nut-scanner/nutscan-ip.h, tools/nut-scanner/scan_avahi.c, + tools/nut-scanner/scan_eaton_serial.c, tools/nut- + scanner/scan_ipmi.c, tools/nut-scanner/scan_usb.c: tools/nut- + scanner/*.{c,h}: drop trailing whitespaces + * server/netmisc.c: server/netmisc.c: drop trailing whitespaces + * server/netssl.c: server/netssl.c: drop trailing whitespaces + * server/upsd.c: server/upsd.c: drop trailing whitespaces + * drivers/ivtscd.c: drivers/ivtscd.c: drop trailing whitespaces + * drivers/powerp-bin.h, drivers/powerp-txt.h, drivers/powerpanel.c, + drivers/powerpanel.h: drivers/powerp*.{c,h}: drop trailing + whitespaces + * drivers/powerp-txt.c: drivers/powerp-txt.c: drop trailing + whitespaces + * drivers/powerp-bin.c: drivers/powerp-bin.c: drop trailing + whitespaces + * drivers/victronups.c: drivers/victronups.c: rectify whitespace + * drivers/upscode2.c: drivers/upscode2.c: rectify whitespace + +2020-11-05 Jim Klimov + + * drivers/tripplitesu.c: drivers/tripplitesu.c: drop trailing + whitespaces + * drivers/solis.c, drivers/solis.h: drivers/solis.{c,h}: rectify + whitespaces + * drivers/safenet.c: drivers/safenet.c: drop trailing whitespaces + * drivers/rhino.c: drivers/rhino.c: normalize whitespace heavily + * drivers/powercom.c: drivers/powercom.c: rectify leading whitespaces + * drivers/powercom.c: drivers/powercom.c: drop trailing whitespaces + * drivers/powercom.h: drivers/powercom.h: drop trailing whitespaces + * drivers/optiups.c: drivers/optiups.c: rectify whitespaces + * drivers/hidparser.c: drivers/hidparser.c: drop trailing whitespaces + * drivers/usb-common.c: drivers/usb-common.c: drop trailing + whitespaces + * drivers/libshut.h, drivers/libusb.h, drivers/usb-common.h: + drivers/libshut.h libusb.h usb-common.h: drop trailing whitespaces + * drivers/libshut.c: drivers/libshut.c: rectify whitespaces per style + guide + * drivers/mge-utalk.c: drivers/mge-utalk.c: drop trailing whitespaces + * drivers/metasys.c: drivers/metasys.c: drop trailing whitespaces + * drivers/masterguard.c: drivers/masterguard.c: rectify whitespaces + and drop comments opposing the project style guide + * drivers/masterguard.c: drivers/masterguard.c: drop trailing + whitespaces + * drivers/liebert-esp2.c: drivers/liebert-esp2.c: rectify whitespaces + * drivers/liebert-esp2.c: drivers/liebert-esp2.c: drop trailing + whitespaces + * drivers/isbmex.c: drivers/isbmex.c: rectify whitespaces + * drivers/isbmex.c: drivers/isbmex.c: drop trailing whitespaces + * drivers/gamatronic.h: drivers/gamatronic.h: rectify whitespaces + * drivers/dummy-ups.c: drivers/dummy-ups.c: drop trailing whitespaces + * drivers/bestups.c: drivers/bestups.c: drop trailing whitespaces + * drivers/bestfortress.c: drivers/bestfortress.c: rectify whitespaces + * drivers/bestfcom.c: drivers/bestfcom.c: rectify whitespaces + * drivers/belkinunv.c: drivers/belkin.c: rectify whitespaces + * drivers/belkin.c: drivers/belkin.c: drop trailing whitespaces + * drivers/bcmxcp.c: drivers/bcmxcp.c: fix leading whitespaces + +2020-11-04 Jim Klimov + + * drivers/bcmxcp.c: drivers/bcmxcp.c: drop trailing whitespaces + * drivers/bcmxcp.h: drivers/bcmxcp.h: drop trailing whitespaces + * drivers/serial.c: drivers/serial.c: drop trailing whitespaces + * clients/upssched.c: clients/upssched.c: drop trailing whitespaces + * clients/upsmon.c: clients/upsmon.c: drop trailing whitespaces + * clients/upsset.c: clients/upsset.c: drop trailing whitespaces + * clients/upsimage.c: clients/upsimage.c: drop indented whitespaces + * clients/upsstats.c: clients/upsstats.c: drop trailing whitespaces + * clients/upslog.c: clients/upslog.c: drop trailing whitespaces + * clients/upsc.c: clients/upsc.c: drop trailing whitespaces + * clients/upsclient.c: clients/upsclient.c: drop trailing whitespaces + * common/snprintf.c: common/snprintf.c: rectify whitespace + +2020-11-06 amccartney + + * drivers/powervar-hid.c: Final clean up and edits for Powervar UPM + support + +2020-11-04 Jim Klimov + + * configure.ac: Fix issue #833 for (sys/)termios.h on BSD ...And + generally check if we CAN build serial drivers before trying to + (and/or guessing if we should try). + +2020-11-04 Jim Klimov + + * drivers/solis.c: Update solis.c Drop temporary unicode comment for + PR + * drivers/nutdrv_qx_voltronic.c: Update nutdrv_qx_voltronic.c Drop + temporary comment with unicode for PR + +2020-11-03 Eric Clappier + + * drivers/eaton-ats16-mib.c: Apply patch "Nut-scanner fix for + discovery ats16 with legacy NMC and newer Network-M2" + +2020-10-26 Arnaud Quette + + * drivers/eaton-pdu-marlin-mib.c: snmp-ups: fix outlet ID on Eaton + ePDU Tie outlet ID to a real OID, to avoid erroneous indexes (-1, + 0) + * docs/nut-names.txt, drivers/eaton-pdu-marlin-mib.c: snmp-ups: fix + Eaton ePDU switch ability Expose a general switchability of the + unit, using outlet.switchability, along with a more suitable per- + outlet mechanism + +2020-10-25 Jim Klimov + + * docs/man/Makefile.am: docs/man/Makefile.am : @echo diagnostic + messages without a trace by default + +2020-10-22 Arnaud Quette + + * drivers/main.c: Fix dstate init call WRT data dump Closes: + https://github.com/networkupstools/nut/issues/835 + +2020-10-15 Jim Klimov + + * docs/man/Makefile.am: docs/man/Makefile.am : in check-man-* + targets, count the checked files (to see better the cases where + none were available) + * docs/man/Makefile.am: docs/man/Makefile.am : typo fix ">&@" => + ">&2" for stderr + +2020-10-13 Jim Klimov + + * .travis.yml: .travis.yml (#823) : in default builds, disable + whatever is not in "_matrix_required" + * .travis.yml: .travis.yml (#823) : define a _matrix_linux and + _matrix_all groupings + * .travis.yml: .travis.yml (#823) : clarify the distro-dependent + relations of matrix jobs as required and allowfail per distro + +2020-10-12 Jim Klimov + + * docs/man/usbhid-ups.txt: Update usbhid-ups.txt Rearranged lines to + keep "all" block together, and finish the list item with a comma + without much context change ;) + * docs/nut.dict: Update nut.dict for PR #733 Add new product name + and vendor keywords + +2020-10-12 Jim Klimov + + * docs/acknowledgements.txt: docs/acknowledgements.txt: revise the + last paragraph for listing corporate contributors + +2020-10-12 amccartney + + * docs/man/usbhid-ups.txt, drivers/powervar-hid.c: Changes per NUT + review comments. Removed info fields from polling. Added + company/contributor info. Updated docs/man/usbhid-ups.txt + +2020-10-12 Jim Klimov + + * docs/nutdrv_qx-subdrivers.txt: docs/nutdrv_qx-subdrivers.txt: + revise a few typos + * docs/configure.txt: docs/configure.txt: update for gdlib pkg-config + support (follow-up to #809) + * docs/configure.txt: docs/configure.txt: update for gdlib pkg-config + support (follow-up to #809) + +2020-10-12 Jim Klimov + + * configure.ac: Update configure.ac Whitespace mess + +2020-10-12 Jim Klimov + + * docs/man/upsd.conf.txt: docs/man/upsd.conf.txt: mention that + ALLOW_NO_DEVICE envvar (e.g. from nut.conf) can override the + setting in upsd.conf + * conf/nut.conf.sample: conf/nut.conf.sample: fix ALLOW_NO_DEVICE + example to "export" it on a separate line + +2020-10-12 Jim Klimov + + * .travis.yml: .travis.yml (#823) : win bash has no time + +2020-10-12 Konstantin Gizdov + + * drivers/usbhid-ups.c: address some comments + +2020-10-12 Jim Klimov + + * .travis.yml: ci_build.sh (#823) : add gnu99-clang-win-nowarn + * ci_build.sh: ci_build.sh (#823) : only call dpkg on linux + * ci_build.sh: ci_build.sh (#823) : investigate win autogen + * .travis.yml: .travis.yml (#823) : fix delivery of ccache to win + builds + +2020-10-11 Jim Klimov + + * .travis.yml: .travis.yml (#823) : do not cache /usr/local/Cellar on + osx, it is too big and rejected anyway + * .travis.yml: .travis.yml (#823, #828) : extend matrix for osx + builds with -std=gnu* variants that seem to pass + * .travis.yml: .travis.yml (#823) : for osx builds, avoid "brew + update" by default, that since 2.0.0 release involves cleanup + automagically and takes a needless 15-30 minutes hit on a Travis + worker When desired we can set HOMEBREW_NO_AUTO_UPDATE + customizable per run + * .travis.yml: .travis.yml (#823) : for osx builds, add ccache; and + only bother for asciidoc + docbook-xsl if building docs + * .travis.yml: .travis.yml (#823) : cache locations related to Brew + between runs + * .travis.yml: .travis.yml (#823) : for now, enable CI_TRACE on Win + always (to find where ci_build.sh script dies) + * .travis.yml: .travis.yml : set jobs.fast_finish:true + +2020-10-10 Jim Klimov + + * .travis.yml: .travis.yml (#823) : group tests into YAML _matrix-* + lists to pick some easier for particular runs on dev branches + * .travis.yml: .travis.yml (#823) : xcode6.4 is deprecated on Travis, + try a newer oldest alternative (7.3) + * .travis.yml: .travis.yml (#823) : add c99-clang-xcode10.2-warn + * .travis.yml: .travis.yml (#823) : reorder some allowed_failure + tests to group logically + * .travis.yml: .travis.yml (#823) : drop gnu14-gcc-8-nowarn (no C14), + add gnu17-clang-8-nowarn + * .travis.yml: .travis.yml (#823) : drop gnu14 and gnu17 attempts + with gcc-7; try gnu14 with gcc-8 + * .travis.yml: .travis.yml (#823) : mark gnu17-gcc-9-nowarn as OK + * ci_build.sh: .travis.yml (#823) : give up on gdlib (--with-cgi) on + win for now + * .travis.yml: .travis.yml (#823) : add a few MacOS X and + Windows+clang9 build combos for diversity + * .travis.yml: .travis.yml (#823) : add more compilers and standards + to try, to collect max diags: c17-clang-8-warn gnu17-gcc-9-warn + * .travis.yml: .travis.yml (#823) : add more compilers and standards + to try : gnu14-gcc-7-nowarn gnu17-gcc-7-nowarn gnu17-gcc-9-nowarn + c99-clang-3.5-nowarn c17-clang-8-nowarn + * .travis.yml: .travis.yml (#823) : specify "compiler" in our + handmade matrix to hint to Travis which env we want + * .travis.yml: .travis.yml (#823) : comment the reference of C/C++ + standard support by gcc and clang versions used + * .travis.yml: .travis.yml : reshuffle default required builds order + to have the quicker ones more likely to fail in development + iterations to run first + * .travis.yml: .travis.yml : move BUILD_TYPE=default and + BUILD_TYPE=default-tgt:distcheck-light into common stack for + manageability + * .travis.yml: .travis.yml: declare linux "dist" that we want by + default + * ci_build.sh: ci_build.sh: handle runs with unspecified BUILD_TYPE + * ci_build.sh: ci_build.sh: report if PATH includes ccache, and if CC + and CXX understand passed C(XX)FLAGS + * ci_build.sh: ci_build.sh: report values of PATH, CC and CXX (and + versions of the latter) before adding CCACHE into the mix + +2020-10-09 Konstantin Gizdov + + * drivers/usbhid-ups.c: more compact logic + * drivers/usbhid-ups.c: remove leftover lines + * drivers/usbhid-ups.c: lay the groundwork for CyberPower UT + cputquirk + * drivers/usbhid-ups.c: fix indentation style + +2017-10-03 Arnaud Quette + + * docs/configure.txt: Remove an extraneous point + * docs/configure.txt: Update configure documentation for libusb + Document the possibility to override the auto-detection choice, + even though the implementation of this override is not yet + currently working + +2020-10-09 Jim Klimov + + * docs/developers.txt: docs/developers.txt : document coding style + examples for tabs vs spaces + * docs/developers.txt: docs/developers.txt : document a "for loop + initial declarations are only allowed in C99 or C11 mode" + portability offense + * docs/developers.txt: docs/developers.txt : document the official + C99+ standard support and that we have CI to help make sure what is + upheld + * .travis.yml: .travis.yml : update comment for the NUT_MATRIX_TAG + block of tests + * .travis.yml: .travis.yml : fix comment-naming for cDefault-gcc- + default-nowarn/gnu99-gcc-default-nowarn primary not-failing case to + keep up + * .travis.yml: .travis.yml : mark gnu89-gcc-default-nowarn as a not- + failing case to keep up + * drivers/solis.c: drivers/solis.c : fix C89 for-loop var + declarations + * .travis.yml: .travis.yml : mark gnu11-gcc-7-nowarn + gnu99-clang-5.0-nowarn as not-failing cases to keep up + * .travis.yml: .travis.yml : add gnu89-gcc-default-nowarn to the test + matrix to check if at least the basic syntax is okay (note that + current warnings for C89 seem to indicate faults that may be fatal + in binary code) + * .travis.yml: .travis.yml : mark gnu99-gcc-7-nowarn as a not-failing + case to keep up + * .travis.yml: .travis.yml : add gnu99-clang-5.0-nowarn to the test + matrix (hope clang can do GNU C dialect) + * .travis.yml: .travis.yml : add gnu11-gcc-7-nowarn to the test + matrix + +2020-10-08 Alexey Rodionov + + * .../python/app/locale/ru/LC_MESSAGES/NUT-Monitor.mo, + scripts/python/app/locale/ru/ru.po: Fixed two typos and translation + of the term load + +2020-10-08 Jim Klimov + + * .travis.yml: .travis.yml : add c11-clang-5.0-nowarn and + c11-clang-5.0-warn to the matrix + * .travis.yml: .travis.yml : add gnu99-gcc-7-nowarn + c99-clang-5.0-nowarn to test matrix (expected to be green) + * .travis.yml: .travis.yml : warning comment about multitoken CFLAGS + and distcheck + * ci_build.sh: ci_build.sh : spell case statements in consistent + style + * ci_build.sh: ci_build.sh : define default-all-errors separately + from default-alldrv + +2020-08-08 Sean McBride + + * clients/cgilib.c, clients/nutclient.cpp, clients/upsmon.c, + clients/upsset.c, drivers/al175.c, drivers/apcsmart-old.c, + drivers/asem.c, drivers/bcmxcp.c, drivers/belkinunv.c, + drivers/dstate.c, drivers/gamatronic.c, drivers/isbmex.c, + drivers/mge-utalk.c, drivers/nut-libfreeipmi.c, + drivers/nutdrv_qx_voltronic-qs-hex.c, + drivers/nutdrv_qx_voltronic.c, drivers/oneac.c, drivers/powercom.c, + drivers/rhino.c, drivers/riello_ser.c, drivers/snmp-ups.c, + drivers/solis.c, drivers/tripplite_usb.c, drivers/tripplitesu.c, + server/netssl.c, tools/nut-scanner/scan_nut.c: WIP: Fixed various + warnings and errors identified by cppcheck Specifically: + arrayIndexThenCheck,drivers/nutdrv_qx_voltronic-qs- + hex.c:222,style,Array index 'i' is used before limits check. + arrayIndexThenCheck,drivers/oneac.c:176,style,Array index 'i' is + used before limits check. + clarifyCalculation,drivers/belkinunv.c:1063,style,Clarify + calculation precedence for '&' and '?'. + clarifyCalculation,drivers/belkinunv.c:922,style,Clarify + calculation precedence for '&' and '?'. + clarifyCalculation,drivers/powercom.c:677,style,Clarify calculation + precedence for '&' and '?'. + clarifyCalculation,drivers/powercom.c:732,style,Clarify calculation + precedence for '&' and '?'. + clarifyCondition,drivers/asem.c:248,style,Boolean result is used in + bitwise operation. Clarify expression with parentheses. + duplicateConditionalAssign,drivers/solis.c:725,style,The statement + 'if (DaysOnWeek!=DaysOffWeek) DaysOnWeek=DaysOffWeek' is logically + equivalent to 'DaysOnWeek=DaysOffWeek'. + duplicateExpression,clients/cgilib.c:49,style,Same expression on + both sides of '||'. + duplicateExpression,drivers/nutdrv_qx_voltronic.c:270,style,Same + expression on both sides of '||'. + duplicateExpression,drivers/nutdrv_qx_voltronic.c:303,style,Same + expression on both sides of '||'. + duplicateExpression,drivers/nutdrv_qx_voltronic.c:397,style,Same + expression on both sides of '||'. identicalInnerCondition,drivers/t + ripplite_usb.c:579,warning,Identical inner 'if' condition is always + true. incorrectLogicOperator,drivers/dstate.c:1170,warning,Logical + conjunction always evaluates to false: c2 && !c2. + incorrectLogicOperator,drivers/rhino.c:190,warning,Logical + disjunction always evaluates to true: BattVoltage > 129 || + BattVoltage < 144. incorrectStringBooleanError,drivers/mge- + utalk.c:899,warning,Conversion of string literal "\r\n" to bool + always evaluates to true. + invalidPrintfArgType_sint,clients/upsset.c:393,warning,%d in format + string (no. 1) requires 'int' but the argument type is 'unsigned + int'. invalidPrintfArgType_sint,clients/upsset.c:676,warning,%d in + format string (no. 1) requires 'int' but the argument type is + 'unsigned int'. + invalidPrintfArgType_sint,drivers/isbmex.c:178,portability,%d in + format string (no. 1) requires 'int' but the argument type is + 'ssize_t {aka signed long}'. + invalidPrintfArgType_sint,drivers/tripplitesu.c:435,warning,%d in + format string (no. 1) requires 'int' but the argument type is + 'unsigned int'. + knownConditionTrueFalse,clients/upsmon.c:919,style,Condition 'un' + is always true + knownConditionTrueFalse,drivers/gamatronic.c:111,style,Condition + 'ret>=0' is always true + knownConditionTrueFalse,drivers/powercom.c:696,style,Condition + 'battval>bat0' is always true + knownConditionTrueFalse,drivers/solis.c:485,style,Condition + 'AppPower==0' is always false knownConditionTrueFalse,tools/nut- + scanner/scan_nut.c:180,style,Condition 'numa>=3' is always true + memleak,clients/upsset.c:664,error,Memory leak: val + nullPointerRedundantCheck,drivers/snmp-ups.c:1554,warning,Either + the condition 'info_template==NULL' is redundant or there is + possible null pointer dereference: info_template. + pointerLessThanZero,drivers/nut-libfreeipmi.c:864,style,A pointer + can not be negative so it is either pointless or an error to check + if it is. pointerLessThanZero,drivers/nut-libfreeipmi.c:884,style,A + pointer can not be negative so it is either pointless or an error + to check if it is. + postfixOperator,clients/nutclient.cpp:896,performance,Prefer prefix + ++/-- operators for non-primitive types. + redundantInitialization,drivers/al175.c:548,style,Redundant + initialization for 'reply'. The initialized value is overwritten + before it is read. + uninitMemberVar,clients/nutclient.cpp:504,warning,Member variable + 'TcpClient::_timeout' is not initialized in the constructor. + uninitMemberVar,clients/nutclient.cpp:513,warning,Member variable + 'TcpClient::_timeout' is not initialized in the constructor. + uninitvar,server/netssl.c:546,error,Uninitialized variable: ret + unsignedLessThanZero,drivers/apcsmart-old.c:928,style,Checking if + unsigned expression 'sdtype' is less than zero. + unsignedPositive,drivers/bcmxcp.c:785,style,Unsigned expression + 'commandByte' can't be negative so it is unnecessary to test it. + uselessAssignmentPtrArg,drivers/riello_ser.c:105,warning,Assignment + of function parameter has no effect outside the function. Did you + forget dereferencing it? + +2020-10-08 Jim Klimov + + * ci_build.sh: ci_build.sh : revise multi-token CONFIG_OPTS entries + * .travis.yml, ci_build.sh: .travis.yml / ci_build.sh : define a + BUILD_TYPE=default-all-errors specifically to list all files with + errors fatal for current build config (but not list whatever + succeds) + * ci_build.sh: ci_build.sh : allow to stack multi-token CC="ccache + clang" and such + * ci_build.sh: ci_build.sh : recognize is_clang() for ccache wrapping + * ci_build.sh: ci_build.sh : recognize is_clang() + * .travis.yml, ci_build.sh: Issue #823 : Set up Travis CI testing for + more compiler implementations and C/C++ standards + * ci_build.sh: ci_build.sh : fix a few historic typos + * ci_build.sh: ci_build.sh: make sure we build all possible binaries + in default-alldrv mode + +2020-10-08 Alexey Rodionov + + * .../app/locale/ru/LC_MESSAGES/NUT-Monitor.mo, + scripts/python/app/locale/ru/ru.po: Additional corrections of the + Russian translation + * .../app/locale/ru/LC_MESSAGES/NUT-Monitor.mo, + scripts/python/app/locale/ru/ru.po: Fixed typos, made changes + according to comments + +2020-10-08 Jim Klimov + + * drivers/Makefile.am: drivers/Makefile.am : drop redundant + pijuice_SOURCES listed in wrong section + +2020-10-07 Jim Klimov + + * docs/man/snmp-ups.txt, docs/nut.dict: Update snmp-ups manpage for + symmetrathreephase quirk to complete PR #788 + +2020-10-07 Jim Klimov + + * drivers/snmp-ups.c: Update snmp-ups.c Fixed indentation for + multiline if-clause + +2020-10-07 Jim Klimov + + * docs/man/Makefile.am, docs/man/index.txt, docs/man/pijuice.txt, + docs/nut.dict: Add initial manpage for pijuice driver, hastily + ripped off one for asem driver + * drivers/pijuice.c: pijuice.c cleanup : rectify leading indentations + * drivers/pijuice.c: pijuice.c cleanup : rectify tabulation of + definitions + * drivers/pijuice.c: pijuice.c cleanup : comment end of big block of + nested #if macros + * drivers/pijuice.c: pijuice.c cleanup : rectify indentation and + blank-line the default return + * drivers/pijuice.c: pijuice.c cleanup : indent stacked #if* macros + * drivers/pijuice.c: pijuice.c cleanup : trailing whitespaces + +2020-10-07 Jim Klimov + + * clients/upsmon.c: Update upsmon.c Log a warning if an UPS is both + OB+LB+Calibrating so due to this combo we do not tell the host to + shut down gracefully. Comment some ideas to work around such + situation in a smarter way if we have additional info to know if we + are in a safe environment just calibrating, or a known-unsafe one + with a real outage in progress. + * common/state.c: state.c: state_delinfo(): comment on immutables + For `state_delinfo()` not deleting immutable variables, comment + this near the function and log for runtime hits to help + troubleshooting. + +2020-10-06 Arnaud Quette + + * drivers/main.c: Driver datadump improvements Do not switch to + statepath, nor write pidfile, when using the datadump (-s -d) mode + +2020-09-22 Ross Williams + + * clients/upsmon.c, clients/upsmon.h: Do not shutdown if UPS is + performing calibration Some UPS calibration procedures (e.g. + CyberPower) involve discharging the battery below the LB level, but + we don't want systems to shut down if the UPS is only on battery + because it is calibrating. + +2019-04-01 Ross Williams + + * drivers/cyberpower-mib.c: cyberpower-mib: fix instant command + declarations Had desired OID values in default value field. Also, + default value for SU_TYPE_CMD should be NULL. + +2019-03-29 Ross Williams + + * drivers/cyberpower-mib.c: cyberpower-mib: Add instant commands + +2019-04-01 Ross Williams + + * drivers/cyberpower-mib.c: cyberpower-mib: got delay OID wrong Left + off .0 + * drivers/cyberpower-mib.c: cyberpower-mib: Add delay variables Add + some read/write variables affecting the sleep delay and return + delay. + * drivers/cyberpower-mib.c: cyberpower-mib: fix instant command + declarations Had desired OID values in default value field. Also, + default value for SU_TYPE_CMD should be NULL. + * drivers/cyberpower-mib.c: cyberpower-mib: NUT runtime is seconds + not minutes + * drivers/cyberpower-mib.c: cyberpower-mib: clarify status values + * drivers/cyberpower-mib.c: cyberpower-mib: correct sysOID At least + newer CyberPower management cards report a sysOID of CPS-MIB::ups, + not the base CyberPower enterprise MIB that was previously defined. + +2019-03-29 Ross Williams + + * drivers/cyberpower-mib.c: cyberpower-mib: Add instant commands + * drivers/cyberpower-mib.c: cyberpower-mib: add support for battery + status Reports LB, CAL, and RB flags + +2020-08-12 Konstantin Gizdov + + * drivers/usbhid-ups.c: initial patch that works + +2020-07-29 Fabrice Fontaine + + * m4/nut_check_libgd.m4: nut_check_libgd.m4: try to find gd through + pkg-config gdlib-config has been dropped from version 2.3.0 with h + ttps://github.com/libgd/libgd/commit/d62f608c7c4a814c70d4ba777725e3 + e62d9e2cde + +2020-07-21 Luka Kovačič + + * drivers/delta-hid.c: drivers: delta-hid: Update entry flags + appropriately Update entry flags to use HU_FLAG_QUICK_POLL for + status and alarm variables, HU_FLAG_SEMI_STATIC for variables that + can change on user changes and HU_FLAG_STATIC for variables that + don't need to be updated after init. + +2020-07-02 Luka Kovačič + + * drivers/Makefile.am, drivers/delta-hid.c, drivers/delta-hid.h, + drivers/usbhid-ups.c, scripts/upower/95-upower-hid.rules: drivers: + delta-hid: Add Delta HID subdriver Delta HID subdriver is added to + support Delta RT Series, Single Phase, 1/2/3 kVA UPS devices. The + driver was tested and tweaked on Delta RT 3 kVA UPS. + +2020-07-17 Alexey Rodionov + + * .../app/locale/ru/LC_MESSAGES/NUT-Monitor.mo, + scripts/python/app/locale/ru/ru.po: Add Russian translation for + NUT-Monitor + +2020-07-11 Matt Merhar + + * docs/security.txt: Fix typo in TCP Wrappers documentation + +2020-06-15 Florian Bernd + + * drivers/apcupsd-ups.c: Do not overwrite `poll_interval` in + `apcupsd-ups` This commit removes the hardcoded poll-interval of + 60 seconds and instead only makes sure that the user-defined + interval is greater than a minimum-interval. + * drivers/apcupsd-ups.c, drivers/apcupsd-ups.h: Do not call + `dstate_delinfo()` for LB-condition variables This commit fixes + the `ignorelb` flag for the `apcupsd-ups` driver. Previusly + "battery.charge" and "battery.runtime" was cleared before invoking + `status_commit()` which caused the LB-condition to always be + `false`. + * common/state.c: Respect `ST_FLAG_IMMUTABLE` in `dstate_delinfo()` + +2020-06-11 Eric Zinnikas + + * drivers/cyberpower-mib.c: Support CyberPower RMCARD205 + +2020-06-11 Peter Klein + + * clients/nutclient.cpp, clients/nutclient.h: Remove dynamic + exception specifications from clients/nutclient.cpp These are + invalid in c++17 and must be removed for compatibility with modern + compilers. + +2020-06-02 Jim Klimov + + * drivers/apc-ats-mib.c: apc-ats-mib.c : use a ..._MODEL_NAME macro + and bump version to complete earlier fix + +2020-05-31 Timothy Pearson + + * drivers/snmp-ups.c: Fix long-standing transfer threshold read bug + with APCC 3 phase Symmetra units + +2020-05-14 Arnaud Quette + + * tools/nut-scanner/scan_snmp.c: SNMP scan: check the match dup on + 'mib' instead of 'sysoid' This actually avoids duplication when + multiple sysOIDs are declared for the same MIB + +2020-05-01 gprints + + * drivers/liebert-hid.c: Update liebert-hid.c + +2020-04-28 Arnaud Quette + + * drivers/eaton-ats16-mib.c: snmp-ups: cleanup Eaton ATS16 with new + Network-M2 Duplicate the definition, as a workaround to the bugger + scanner data extraction, and point at the same eaton_ats16 name, + since there is no interest in separating mib2nut entries pointing + at the same MIB mapping + +2020-01-15 Clappier, Eric + + * drivers/ietf-mib.c: Issue corection filter ietf mib (cherry picked + from commit 93a64efbdae28355be60329b651d3c42c7ddedf8) + +2020-04-28 Arnaud Quette + + * tools/nut-snmpinfo.py: Fix Python issue in the SNMP scan extractor + +2020-01-15 Clappier, Eric + + * tools/nut-scanner/scan_snmp.c, tools/nut-snmpinfo.py: Fix nutscan + snmp (cherry picked from commit + bc5a6c218e21c0af454007e2929c084129b6f3ed) + * drivers/apc-ats-mib.c: Issue correction no pointer null at + beginning of the SNMP IDs device table (cherry picked from commit + 9d167892a36bf75d30839e7d4d6b53f037751666) + +2020-04-28 Arnaud Quette + + * drivers/huawei-mib.c: Huawei MIB: add a counter check OID This + avoids getting a false result when trying all OIDs, due to the use + of Net SNMP sysOID (.1.3.6.1.4.1.8072.3.2.10), found in various + implementations + +2016-05-25 Jim Klimov + + * drivers/huawei-mib.c: huawei-mib - renamed lookups to have + "huawei_*" prefix (cherry picked from commit + fd29f32b2837588518ec7bea07f414c2631d5c8f) + +2020-04-21 Jim Klimov + + * scripts/augeas/nutupsdconf.aug.in: nutupsdconf.aug.in: complete the + ALLOW_NO_DEVICE definition + * conf/nut.conf.sample, conf/upsd.conf.sample, + docs/man/upsd.conf.txt, scripts/augeas/nutupsdconf.aug.in, + scripts/augeas/tests/test_nut.aug, server/conf.c, server/upsd.c, + server/upsd.h: Rename NUT_NOCONF_ALLOWED to ALLOW_NO_DEVICE as + suggested in PR comments + * conf/nut.conf.sample: nut.conf.sample: update the comment about + NUT_NOCONF_ALLOWED + * server/upsd.c: upsd.c : CONST char* temp "envvar" as we do not + change the string later + +2020-04-17 Jim Klimov + + * conf/upsd.conf.sample, docs/man/upsd.conf.txt: Re-spell "Boolean" + to satisfy spell-checker + * conf/upsd.conf.sample, docs/man/upsd.conf.txt, + scripts/augeas/nutupsdconf.aug.in, + scripts/augeas/tests/test_nut.aug, server/conf.c, server/upsd.c, + server/upsd.h: Allow to configure NUT_NOCONF_ALLOWED option via + upsd.conf + +2020-04-17 Arnaud Quette + + * drivers/eaton-ats16-mib.c, drivers/eaton-ats16-mib.h, drivers/snmp- + ups.c: snmp-ups: add Eaton ATS16 with new Network-M2 Add support + for Eaton ATS16 using the new Network-M2 communication cards, and + including a fixed sysOID fingerprint + +2020-04-03 Jim Klimov + + * clients/nutclient.cpp: clients/nutclient.cpp: sanity-check + getDevicesVariableValues() called with empty device list + +2020-03-14 Jim Klimov + + * docs/nut.dict: nut.dict : fixes for NUT_NOCONF_ALLOWED addition + * scripts/systemd/nut-driver-enumerator.service.in, + scripts/systemd/nut-driver@.service.in, scripts/systemd/nut- + monitor.service.in, scripts/systemd/nut-server.service.in: SystemD + service units: source EnvironmentFile=...nut.conf if available + * conf/nut.conf.sample: nut.conf.sample : prepare an uncommentable + line for NUT_NOCONF_ALLOWED=true + * server/upsd.c: server/upsd.c: introduce support for envvar + NUT_NOCONF_ALLOWED=true to allow starting with 0 ups.conf sections + +2018-09-19 Arnaud Quette + + * server/upsd.c: upsd should return EXIT_FAILURE when -c failed + +2020-02-19 Jim Klimov + + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in: when autostarting/reloading upsd (nut-server), do + it for previously "failed" unit too + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in: do systemctl daemon-reload between editing a unit + definition and auto-starting it + +2018-12-18 Jim Klimov + + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : centralize management of TIMEOUT_CMD and + TIMEOUT_ARGS, and use it for driver stop/start - it hangs too + sometimes + +2020-02-09 Laurent Bigonville + + * scripts/python/app/nut-monitor.appdata.xml, scripts/python/app/nut- + monitor.desktop: Update the appdata file to the latest version of + the specification (#727) * nut-monitor: Update the appdata file to + the latest version of the specification Fixes: #724 * nut- + monitor: Update the desktop file to follow the last version of the + sepcification + +2020-02-09 Jim Klimov + + * docs/Makefile.am, docs/documentation.txt, docs/nut.dict, + docs/solaris-usb.txt, scripts/Solaris/README: Add docs/solaris- + usb.txt for posterity (#755) + +2020-01-08 Fernando Chaves <38504809+fernandolcx@users.noreply.github.com> + + * drivers/apcupsd-ups.h: apcupsd-ups: add real power and current + variables LOAD_W => ups.realpower LOADAPNT => power.percent + OUTCURNT => `output.current` LOAD_VA => `ups.power` NOMAPNT => + `ups.power.nominal` Closes: + https://github.com/networkupstools/nut/pull/753 + +2019-11-06 Charles Lepple + + * data/driver.list.in: HCL: Add PowerWalker VFI 1000 CG PF1 Closes: + https://github.com/networkupstools/nut/issues/648 + +2019-09-18 andrewmccartney + + * drivers/Makefile.am, drivers/libusb.c, drivers/powervar-hid.c, + drivers/powervar-hid.h, drivers/usbhid-ups.c: Changes to add + support for Powervar UPM as usb-hid UPS. Includes adding a report + index to libusb.c in order to handle the composite device in the + UPM. + +2019-09-12 Andrew Anderson + + * drivers/pijuice.c: Conditionally include linux/i2c.h Check for + I2C_FUNC_I2C to avoid errors caused by conflicts between + linux/i2c-dev.h and linux/i2c.h + * configure.ac, drivers/pijuice.c: Add more granular I2C support + checks Accommodate one more variation of SMBUS/I2C support where + both the headers and the libraries exist and are usable. + * drivers/pijuice.c: Pull over the latest development version Clean + up the upsdebugX() labels Pull the conditional I2C support code + closer to the includes block Don't report battery temp as UPS temp + Warn if we adjust shutdown_delay + * drivers/pijuice.c: Fix the length passed into memset() + * drivers/asem.c: Add pijuice I2C driver for PiJuice HAT 4/4 Update + asem.c to complie cleanly by adding an include for + * configure.ac: Add pijuice I2C driver for PiJuice HAT 3/4 Check for + both the i2c-tools 3.x and 4.x include files (i2c-dev.h/smbus.h) + and set flags accordingly. Link with the i2c library file from + i2c-tools 4.x if it is available. + * drivers/Makefile.am: Add pijuice I2C driver for PiJuice HAT 2/4 + Update the driver Makefile.am to add pijuice driver to the + LINUX_I2C_DRIVERLIST + * drivers/pijuice.c: Add pijuice I2C driver for PiJuice HAT 1/4 Add + pijuice driver + +2019-09-02 Laurent Bigonville + + * scripts/python/app/nut-monitor.desktop: nut-monitor: Drop the .png + extension for the Icon in the .desktop file + +2019-08-18 Laurent Bigonville + + * scripts/python/Makefile.am, scripts/python/app/icons/256x256/nut- + monitor.png, .../python/app/{ => icons/48x48}/nut-monitor.png, + scripts/python/app/icons/64x64/nut-monitor.png, + scripts/python/app/icons/scalable/nut-monitor.svg: nut-monitor: Add + scalable, 64x64 and 256x256 icon for nut-monitor FTR, this icon + comes from gnome-icon-theme 2.28 + +2019-07-22 rpvelloso + + * drivers/solis.c: solis: avoid index out of bounds Since the + parameter taken by autonomy_calc() is used to index a couple of + arrays of 5 positions and the variable `im`, which is passed to + autonomy_calc(), can be equal to 4, blindly incrementing it by one, + when it's 4, leads to an index out of bounds. + +2019-07-30 Daniele Pezzini + + * drivers/nutdrv_siemens_sitop.c: nutdrv_siemens_sitop: move to the + new "battery.charge.approx" var + * data/cmdvartab, docs/nut-names.txt: Add and document a new + "battery.charge.approx" var + +2019-07-12 Spencer Shimko + + * drivers/tripplite_usb.c: Report load for Tripp Lite USB 3005 + protocol The debug output for a device using the Tripp Lite 09ae + 3005 protocol seems to show that the ups.debug.L is the load as + noted on mailing list posts. Decode it and report it as ups.load. + Tested on TRIPP LITE SMART500RT1U. + +2019-07-11 Jim Klimov + + * scripts/Solaris/nut-driver.xml.in: Solaris/nut-driver.xml.in : + constrain the impact of managing SMF instances for missing devices + * scripts/systemd/nut-driver@.service.in: nut-driver@.service.in : + fix back templated @SBINDIR@ + * scripts/systemd/nut-driver@.service.in: Problem: Attempts to start + a nut-driver@bogusname actually run upsdrvctl on everything + Solution: First check if service instance name is valid, then use + it Should fix https://github.com/42ity/nut/issues/87 + +2019-07-10 Laurent Bigonville + + * clients/Makefile.am, tools/nut-scanner/Makefile.am: libupsclient, + libnutscan: Only export symbols part of the public API Fixes: #713 + +2019-07-09 Laurent Bigonville + + * clients/upsclient.c, clients/upsmon.c, drivers/apcsmart.c, + drivers/bcmxcp.h, drivers/bestuferrups.c, drivers/main.c, + drivers/masterguard.c, drivers/metasys.c, drivers/mge-hid.c, + drivers/mge-mib.c, drivers/nutdrv_qx_q1.c, drivers/nutdrv_qx_q1.h, + drivers/optiups.c, drivers/solis.c, scripts/python/app/NUT-Monitor, + tools/nut-scanner/nut-scanner.c: Fix several typos + * configure.ac, lib/libupsclient.pc.in, m4/nut_check_libnss.m4, + m4/nut_check_libopenssl.m4: Use pkg-config module names instead of + listing the libraries Fixes: #709 + +2019-07-02 Jim Klimov + + * common/common.c: common.c : BUILD_64 not detected in some distros, + needs stdint.h + +2018-05-04 Matthijs ten Berge + + * docs/man/nutdrv_siemens_sitop.txt: Spelling fix + * drivers/nutdrv_siemens_sitop.c: Remove %-sign from variable values + * drivers/nutdrv_siemens_sitop.c: Fix line endings + * docs/man/nutdrv_siemens_sitop.txt: Better explanation of serial + port polling + +2018-04-11 Matthijs ten Berge + + * data/driver.list.in, docs/man/Makefile.am, docs/man/{siemens- + sitop.txt => nutdrv_siemens_sitop.txt}, drivers/Makefile.am, + drivers/{siemens-sitop.c => nutdrv_siemens_sitop.c}: Rename driver + siemens-sitop to nutdrv_siemens_sitop As requested in https://gith + ub.com/networkupstools/nut/pull/545#pullrequestreview-106712942 + +2018-03-26 Matthijs ten Berge + + * drivers/siemens-sitop.c: Various code improvements after review - + The number of delimiter characters is no longer hard-coded, but + will be detected and thrown away at runtime - Discard any remains + in the RX buffer after communication errors - collapse repeating + code - upsdrv_shutdown now uses instcmd (removes duplicate code) - + obsolete ups.* variables removed - poll_interval not hard-coded, + but give a warning when a large value is encountered - option + parsing improved + * docs/man/siemens-sitop.txt: Improve manpage layout + +2018-03-23 Matthijs ten Berge + + * docs/man/siemens-sitop.txt, docs/nut.dict: Spellcheck fixes + * data/driver.list.in, docs/man/Makefile.am, docs/man/siemens- + sitop.txt, drivers/Makefile.am, drivers/siemens-sitop.c: Initial + commit of siemens-sitop: driver for Siemens SITOP UPS500-series + UPSes + +2019-04-26 William Chase + + * drivers/bestfcom.c: Fix for Ferrups FE7000 "off" command (#692) + "off" command for FE7000 required at least 5 seconds for the + command to be accepted. Also should match the off with autostart + or "o" with "a" to be consistent with the manual: + https://www.eaton.com/content/dam/eaton/products/backup-power-ups- + surge-it-power-distribution/backup-power-ups/eaton-ferrups-tower- + ups/eaton-ferrups-FE-QFE-userguide-.pdf (o [time] a is how the + manual references the "short" command) + +2019-04-16 Ross Williams + + * drivers/snmp-ups.c: snmp-ups: add ability to set TimeTicks + correctly (#687) * snmp-ups: add ability to set TimeTicks + correctly Driver had been setting read/write parameters as either + Integer or String, but OIDs that expect TimeTicks cannot be set + using an Integer. snmp-ups already supported getting TimeTicks + correctly and had helper functions for setting TimeTicks, but logic + had not been implemented in su_setOID(). * Missing semicolon ;-( + * snmp-ups: use NUT's str_to_long() in su_setOID() Safer + conversion from provided strings to instant command or read/write + value. Omitted default value if !SU_MODE_INSTCMD because it is not + possible for read/write variable functions to be called without a + value (unlike instant commands). + +2019-04-11 Jim Klimov + + * drivers/eaton-pdu-marlin-mib.c, drivers/snmp-ups.c: [DNMY] Fix snmp + templates (#681) * eaton-pdu-marlin-mib.c : move "outlet.count" + query higher * snmp-ups.c : anticipate lack of OIDs in templates + +2019-04-05 Jim Klimov + + * .travis.yml, Makefile.am, ci_build.sh: Introduce shell script + syntax checks (#675) * Introduce shell script syntax checks * + Makefile.am : do not shellcheck/spellcheck by default as it can + fail for external circumstances (e.g. missing tools) * Makefile.am + : visibly separate the "check-scripts-syntax" implementation (with + current system shells) vs "shellcheck" which may get impemented + differently (with external tools) in later iterations * + Makefile.am : update the check-scripts-syntax comment (clarify + text, fix typo) * Makefile.am : clarify the check-scripts-syntax + vs shellcheck comment * .travis.yml and ci_build.sh : leave TBDs + for future shellcheck tool integration * ci_build.sh : call both + shellcheck and check-scripts-syntax targets; it does not duplicate + the work and reports while one calls another for now - and will do + two tests when they become independent + * configure.ac: configure.ac : fix mismatched usage of have_cxx11 + envvar (#689) + * server/conf.c: Problem: isdigit() receives a char* instead of char + (#690) Solution: as a quick fix, pick the first char of the string + we pass. The proper fix would be to use the str_*() API for safe + conversions, in a later iteration. See-also: + https://github.com/networkupstools/nut/issues/676 + +2019-04-01 Jim Klimov + + * include/common.h: common.h : use the common do/while idiom for + macro with if clause + +2019-04-01 Jim Klimov + + * common/common.c, include/common.h: Problem: upsdebug*() pass data + and allocate vars always Solution: wrap old well-known API + routines into macros that check debugging level first, and only + invest into calling routines and passing data later - if that would + not be in vain. + +2019-03-25 Jean-Baptiste Boric + + * tools/nut-scanner/scan_snmp.c: Fix nut-scanner SNMPv3 (#680) + +2019-03-19 Arnaud Quette + + * drivers/compaq-mib.c, drivers/eaton-ats16-mib.c, drivers/eaton-pdu- + marlin-mib.c, drivers/hpe-pdu-mib.c, drivers/netxml-ups.c, + drivers/powerware-mib.c: Refresh firmware information for Eaton/HPE + devices Despite the static nature of these data, firmware can be + updated by various means, and should thus be refreshed by the + driver, without needing a driver restart. A "semi static" approach + should be done in the end, as in usbhid-ups, but is not part of the + present development, though commented in the code. For the time + being, simply remove the STATIC flags to refresh the data (snmp- + ups) and allow to refresh product information (netxml-ups) + +2019-03-19 Jean-Baptiste Boric + + * tools/nut-scanner/scan_snmp.c: Fix SNMPv3 in nut-scanner (#679) + +2019-03-15 Arjen de Korte + + * clients/upsclient.c, clients/upssched.c, + m4/nut_check_libopenssl.m4, server/netssl.c: Add support for + openssl-1.1.0 (#504) * Add support for openssl-1.1.0 * Allow + TLSv1 and higher (not just TLSv1) * Fix check for empty string * + Report TLS handshake in debug mode * Update + nut_check_libopenssl.m4 * Update upsclient.c * Update netssl.c + +2019-03-14 Charles Lepple + + * docs/man/nutupsdrv.txt, docs/man/ups.conf.txt: nutupsdrv: reword + "user" directive section Closes: + https://github.com/networkupstools/nut/issues/336 Closes: + https://github.com/networkupstools/nut/issues/671 + +2019-03-11 Arnaud Quette + + * docs/new-clients.txt: libnutclient: add comments to the code sample + +2019-03-11 Jean-Baptiste Boric + + * clients/nutclient.cpp, clients/nutclient.h, docs/new-clients.txt, + docs/nut.dict: Implement tracking commands in libnutclient (#673) + * Implement tracking commands in libnutclient * Add + TrackingResult::INVALID_ARGUMENT + +2019-02-26 Arnaud Quette + + * drivers/solis.c: Fix regression in solis authors list + +2019-02-26 Roberto Panerai Velloso + + * drivers/solis.c, drivers/solis.h: Added author info for previous + merge https://github.com/networkupstools/nut/pull/511 (#672) * + added author information + +2019-02-26 Arnaud Quette + + * clients/Makefile.am, clients/upsclient.c, clients/upsclient.h, + clients/upscmd.c, clients/upsrw.c, common/snprintf.c, + conf/upsd.conf.sample, docs/man/Makefile.am, + docs/man/upscli_cleanup.txt, docs/man/upscli_readline.txt, + docs/man/upscli_sendline.txt, docs/man/upscmd.txt, + docs/man/upsd.conf.txt, docs/man/upsrw.txt, docs/net-protocol.txt, + docs/nut-names.txt, docs/nut.dict, docs/sock-protocol.txt, + drivers/dstate.c, drivers/upshandler.h, include/common.h, + scripts/augeas/nutupsdconf.aug.in, + scripts/augeas/tests/test_nut.aug, server/conf.c, server/netget.c, + server/netinstcmd.c, server/netset.c, server/nut_ctype.h, + server/sstate.c, server/upsd.c, server/upsd.h, tools/nut- + scanner/nut-scanner.c: INSTCMD and SET VAR status tracking + implementation (#659) * INSTCMD and SET VAR status tracking + implementation This commit implements the instant commands + (instcmd) and variables settings (setvar) status tracking, to get + the actual execution status from the driver * Missing Revision + history * Fix nut-names.txt modification that should not be here + * Augeas support: add CMDSETSTATUSDELAY for upsd.conf * INSTCMD + and SET VAR status tracking completion Following Daniele Pezzini + thorough review, sanitize and improve the code, and also complete + documentation * INSTCMD and SET VAR status tracking completion + implement support for status tracking in upscmd and upsrw * + upscmd/upsrw: delay retries for status tracking * Remove comment + There is no need to condition CMDSET_STATUS commands received by + upsd from the driver, on cmdset_status_enabled, since what matters + is the presence of a list and id * Complete comment * UUID v4 + implementation replaced the initial rxi/uuid4 library used by a + cross platform version. Though more basic, it is enough for our + needs, at least for now * status_info should be static * No + need for else, since fatalx is called before * Suppress \n from + debug output * Group sanity checks * Get rid of dynamic memory + allocation * Improve and enforce the use of UUID4_LEN * Comment + on the size of dest for nut_uuid_v4() * Move structures and + defines to more appropriate places * Add functions with timeout + Add upscli_sendline_timeout and upscli_readline_timeout, beside + from the classic blocking versions. Also make a common define for + timeout, and use it in upsclient and nut-scanner * upscmd/upsrw: + add a timeout option * Basic homebrew UUID v4 implementation * + Prefer to use static buffer for UUID * log actual result of + instcmd / setvar * Fix tracking ID reporting due to static memory + changes * upsclient: use unsigned int for timeouts Also, + explicit that upscli_cleanup() takes no argument. * upscmd/upsrw: + use unsigned int for timeout + our str_to_uint() for it Also, + slightly reword the help message for `-t` (timeout) option, in + order to clarify which is the unit (seconds) used for the provided + value. * upscmd/upsrw: don't sleep after receiving a non-PENDING + CMDSET_STATUS Also, remove some nesting in do_cmd() and do_set(). + * net-protocol: clarify the format of GET CMDSET_STATUS + + is not optional to get the status of a + command/setvar with CMDSET_STATUS, so drop the [square brackets] + from it. Also drop "quotes" in SET CMDSET_STATUS's , since + it's expected to be a single word. Plus, fix markup of INSTMCD's + parameter. * sock-protocol: align case and markup of + command parameters * dstate: fix handling of INSTCMD's optional + parameters We should still support the old `INSTCMD + []` format, and not only consider when also + `STATUS_ID ` is provided. Also, fix the format of our sock- + protocol commands mentioned in comments, and add function names to + debug info. * common: document the recently added things * upsd: + in INSTCMD/SET handlers, also accept NULL for status_id Plus: - + use a simpler approach to test if status_id is not empty, - align + the way the SET command is built to the one used for the INSTCMD + command. * upsd: drop unnecessary/unused global * upsd: move + sanity checks of cmdset_status_get() after declaration of vars + Also, drop some nesting in that function. * Move from + CMDSET_STATUS / STATUS_ID to TRACKING This is just a big, big + rename, no code changes. * upsd: refine the tracking API Add a + couple of functions to change in a predictable way the value of the + general enablement of tracking and make it visible only inside + upsd.c. Also, move the tracking type (tracking_t) and the list of + items inside upsd.c. * net-protocol: also return TRACKING between + OK and , for INSTCMD/SET VAR * dstate: *really* fix handling + of INSTCMD's optional parameters Erroring out on `INSTCMD + ` doesn't seem like a good idea... * common: massage + default timeouts Rename the default timeout used in network + operations by upsclient and nut-scanner to be more specific: from + DEFAULT_TIMEOUT to DEFAULT_NETWORK_TIMEOUT. Plus, make the default + timeout used when retrieving the result of an INSTCMD/SET VAR with + TRACKING enabled a common #define'd value + (DEFAULT_TRACKING_TIMEOUT), and use it also to publish the default + value of the -t option in the help messages of upscmd and upsrw. + As suggested by Charles Lepple. * upsd: ignore case of UUID4 in + tracking API Also, remove some nesting in tracking_del(). * + libupsclient: generate manpages for + upscli_{read,send}line_timeout() To keep things simple, at least + for now, only generate manpages and not html pages (and, as such, + don't even think of using our linkman AsciiDoc macro with those + functions, to avoid dead links). * libupsclient: bump version as + per recent changes - addition of upscli_{read,send}line_timeout(), + - upscli_cleanup() -> upcli_cleanup(void) Note: only increase + 'current' and not 'age', because the upscli_cleanup() change could + (potentially) make it not compatible with previous versions. * + upscmd/upsrw: warn that also the drivers need to support TRACKING, + for -w * Fix typo and spelling * Add check around atoi() + conversion + +2019-02-25 Roberto Panerai Velloso + + * drivers/solis.c, drivers/solis.h: solis: various improvements and + fixes - fixed two memory leaks (unnecessary strdup's), - removed + ser_flush calls that were causing the driver to desync, - + refactored code, mostly bit mainpulation functions, - other minor + improvements in source code. + +2019-02-23 Jim Klimov + + * clients/Makefile.am: clients/Makefile.am : also consider HAVE_CXX11 + for .la target + * tests/Makefile.am: tests/Makefile.am : explicitly consider + HAVE_CXX11 + * clients/Makefile.am, tests/Makefile.am: tests, clients Makefiles : + consider HAVE_CXX11 + * configure.ac: configure.ac : expose HAVE_CXX11 into automake + * configure.ac: configure.ac : add C++0X as draft C++11 support + detection (older GCC on some systems) + * configure.ac: configure.ac : refactor C++11 detection for + readability + * configure.ac: Problem: OpenBSD mktemp complains on short pattern + Solution: bump from XXXXX to XXXXXXX which did not complain in + another part of the configure script + +2019-02-20 Jim Klimov + + * clients/Makefile.am, tools/nut-scanner/Makefile.am: nut-scanner and + clients Makefile.am : comments about version-information + +2019-02-16 Jim Klimov + + * docs/nut.dict: nut.dict : add words for upsdrvsvcctl doc + +2019-02-08 Jim Klimov + + * common/common.c: Problem: 32-bit builds fail to load 64-bit libs + Solution: Do our best to guess the bitness of a build, and use it + in search paths for get_libname() + +2019-02-03 Daniele Pezzini + + * server/upsd.c: upsd: fix the calling of netcmds items' func() + Since, as per our network protocol, it's perfectly legal to have + single-word commands (and we already have a few, e.g. VER, NETVER, + HELP, ...), we do not do an early check to ensure that at least one + argument was provided to the command. As such, the list of words + generated by parseconf could actually end with the command itself. + That said, trying to access something that should not be there + doesn't seem like a good idea, so, only pass to netcmds items' + func() the list of arguments (which starts at the second item of + the list of words), if there are arguments, otherwise just pass + NULL. + * server/sstate.c: sstate: make sure ADDRANGE/DELRANGE have all the + needed parameters Since ADDRANGE and DELRANGE take 3 arguments + (, , ), we have to ensure all of them + were provided, before attempting to use them. + * drivers/dstate.c: dstate: fix dstate_delrange() socket protocol + command The documented (and used in server-side) command for + deleting a range is `DELRANGE `, not + `DELRANGE " "`, as used in + dstate_delrange(). So, fix that unused (well, at least in NUT) + function to use the correct format. Also, remove an extraneous + additional space in the command used in dstate_addrange(). + +2019-02-01 Arnaud Quette + + * configure.ac, scripts/augeas/Makefile.am: Augeas support: execute + lenses tests if possible This is however disabled for now, while + waiting to fix the reported issue Ref: + https://github.com/networkupstools/nut/issues/657 + * configure.ac: Fix wording that breaks some syntax highlighting + systems + * docs/nut-names.txt: Add the missing delayed versions of some + commands + +2019-01-30 Jean-Baptiste Boric + + * clients/nutclient.cpp, clients/nutclient.h: libnutclient: introduce + getDevicesVariableValues() (#654) A performance bottleneck was + identified within the 42ity project, where querying all variable + values from 300 ePDUs through upsd and libnutclient took 15 seconds + to complete. The new method TcpClient::getDevicesVariableValues() + allows querying device variable values in bulk, by sending all LIST + VAR commands ahead of time and then parsing all the results at + once. Throughput is vastly improved, with the mega-query completing + about 15 times faster. + +2019-01-28 Arnaud Quette + + * clients/Makefile.am, clients/nutclient.h: libnutclient: fix version + and interface * Library version should be updated to reflect + changes, and is now 1:0:0 * Interface should be adapted so that the + additional argument to instant commands can be optional + * drivers/eaton-pdu-marlin-mib.c, drivers/hpe-pdu-mib.c: snmp-ups: + support extra param for instcmd (Eaton/HPE) Add support for extra + parameter for instant commands on Eaton and HPE ePDU + * drivers/snmp-ups.c: snmp-ups: fix potential segfault when using + delayed instant commands, with a NULL default value, and not + providing a value, the driver can segfault + * docs/nut.dict: Fix spellcheck + * clients/nutclient.cpp, clients/nutclient.h, docs/net-protocol.txt: + Add support for extra parameter for instant commands Instant + commands were almost ready for supporting additional parameter. + However, it was not documented, and libnutclient was not supporting + it yet + +2019-01-24 Arnaud Quette + + * drivers/apc-ats-mib.c, drivers/apc-mib.c, drivers/apc-pdu-mib.c, + drivers/baytech-mib.c, drivers/bestpower-mib.c, drivers/compaq- + mib.c, drivers/cyberpower-mib.c, drivers/eaton-ats16-mib.c, + drivers/eaton-ats30-mib.c, drivers/eaton-pdu-genesis2-mib.c, + drivers/eaton-pdu-marlin-mib.c, drivers/eaton-pdu-pulizzi-mib.c, + drivers/eaton-pdu-revelation-mib.c, drivers/emerson-avocent-pdu- + mib.c, drivers/hpe-pdu-mib.c, drivers/ietf-mib.c, drivers/mge- + mib.c, drivers/netvision-mib.c, drivers/powerware-mib.c, + drivers/raritan-pdu-mib.c, drivers/raritan-px2-mib.c, drivers/snmp- + ups.c, drivers/snmp-ups.h, scripts/subdriver/gen-snmp-subdriver.sh: + snmp-ups: Rework instant commands handling Use snmp_info_t->dfl, + which is a char*, instead of snmp_info_t->info_len for instant + commands default value. This allows to distinguish between commands + that do not require a mandatory value. For instcmd requiring a + parameter (such as *.delay), a NULL snmp_info_t->dfl and no + extradata will result in STAT_INSTCMD_INVALID value returned Also + adapt subdrivers and gen-snmp-subdriver.sh to match this + * drivers/delta_ups-mib.c, drivers/eaton-pdu-marlin-mib.c, + drivers/huawei-mib.c, drivers/snmp-ups.c, drivers/snmp-ups.h, + drivers/xppc-mib.c, scripts/subdriver/gen-snmp-subdriver.sh: snmp- + ups: Simplify the mapping structure * snmp_info_t->setvar is not + used anymore, so drop it, * hence, also delete flag SU_FLAG_SETINT + and references to it, * adapt subdrivers and gen-snmp-subdriver.sh + to match this + +2019-01-23 Arnaud Quette + + * drivers/snmp-ups.c: snmp-ups: Fix warnings (memset-elt- + size/pointer-sign) + * drivers/snmp-ups.c: snmp-ups: Actually fix commands offset (off by + 1) The last fix was wrongly setting the offset to negative, and + substracting it again from the current device number, which + resulted in an addition, not a substraction + * drivers/mge-hid.c, drivers/usbhid-ups.c: usbhid-ups / MGE: bump + versions to reflect changes + +2019-01-22 Arnaud Quette + + * drivers/mge-hid.c, drivers/usbhid-ups.c, drivers/usbhid-ups.h: + usbhid-ups: Fix erroneous OB report on Eaton UPS Also created a + read accessor on status bits and move the related definitions to + the driver header + +2019-01-22 Jean-Baptiste Boric + + * drivers/mge-xml.c, drivers/netxml-ups.c, drivers/netxml-ups.h: + netxml-ups: Report calibration status (#650) + +2019-01-22 Arnaud Quette + + * data/driver.list.in, drivers/Makefile.am, drivers/hpe-pdu-mib.c, + drivers/hpe-pdu-mib.h, drivers/snmp-ups.c: snmp-ups: Add support + for HPE ePDU + +2019-01-21 Arnaud Quette + + * drivers/snmp-ups.c: snmp-ups: Improve ALARM flag handling + +2019-01-17 Arnaud Quette + + * drivers/snmp-ups.c: snmp-ups: Fix ALARM flag on non-daisychained + devices + * drivers/snmp-ups.c: snmp-ups: Fix erroneous integration of hpe_pdu + * drivers/snmp-ups.c: snmp-ups: Fix commands offset (off by 1) + * drivers/snmp-ups.c: snmp-ups: Fix detection and display of hex + strings + +2019-01-11 Arnaud Quette + + * drivers/compaq-mib.c: snmp-ups: Add firmware version for new + Network card Also bump HPE/Compaq subdriver version to 1.62 + +2018-12-04 Jim Klimov + + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh : note to not skip full "main" evaluation in daemon + mode + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh : support SIGHUP causing a quick reconfig when + received both during the sleep and processing in-progress + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh : avoid continuous reconfiguration (esp. in daemon + mode) + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : for many discovered changes, avoid the lag of + running systemctl daemon-reload for every item in the loop + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : in single-run, daemon and full-reconfig modes, + take note if the config file had changed while we were running - + re-sync services vs sections ASAP then + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : introduce calc_md5_file() and comment calc_md5() + a bit better + +2018-12-07 Scott Shambarger + + * clients/upsmon.c, clients/upssched.c, common/parseconf.c: Add + FD_CLOEXEC flag to config files, pipes and sockets File + descriptors are leaking to processes spawned by upsmod and + upssched, leading to SELinux errors when (for example) sendmail + attempts to read from fd #4. + +2018-12-01 mjan + + * drivers/Makefile.am, drivers/nutdrv_qx.c, + drivers/nutdrv_qx_hunnox.c, drivers/nutdrv_qx_hunnox.h: Add support + for Hunnox HNX-850 + +2018-11-19 Jim Klimov + + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : critical typo fix (Environment is valid in + section Service, not Unit) + +2018-11-16 Jim Klimov + + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : refactor upsconf_getSection_content() to have + one place of logic to add the parsed section line + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in, tests/nut-driver- + enumerator-test--ups.conf, tests/nut-driver-enumerator-test.sh: + nut-driver-enumerator.sh.in : section-name brackets should contain + a single token and not be inside another string + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : refactor upslist_normalizeFile_filter() into a + more readable standalone routine + +2018-11-13 Jim Klimov + + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : update the list of config factors that mean an + USB nutdrv_qx device + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in, tests/nut-driver- + enumerator-test.sh: nut-driver-enumerator-test.sh / nut-driver- + enumerator-test--ups.conf / nut-driver-enumerator.sh.in : extend + upsconf_getValue() to query for several values in the same call to + more efficiently check if any key/flag is set + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in, tests/nut-driver- + enumerator-test--ups.conf, tests/nut-driver-enumerator-test.sh: + nut-driver-enumerator-test.sh / nut-driver-enumerator-test-- + ups.conf / nut-driver-enumerator.sh.in : do not ignore driver flags + followed by a comment + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : fix \t into TABCHAR + * tests/nut-driver-enumerator-test.sh: nut-driver-enumerator-test.sh + : show the expected vs actual diff in any shell interpreter + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : add a disclaimer about config parser (probable + non-)conformity to NUT binary definitions + * tests/nut-driver-enumerator-test--ups.conf: nut-driver-enumerator- + test--ups.conf : test a section with indented name + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in, tests/nut-driver- + enumerator-test--ups.conf, tests/nut-driver-enumerator-test.sh: + nut-driver-enumerator-test.sh / nut-driver-enumerator-test-- + ups.conf / nut-driver-enumerator.sh.in : in section-name lines, + ignore anything outside the first set of brackets + * tests/nut-driver-enumerator-test.sh: nut-driver-enumerator-test.sh + : show a diff of expected vs actual, if the shell allows in-place + docs + * tests/nut-driver-enumerator-test.sh: nut-driver-enumerator-test.sh + : suggest to a dev how to re-run the failed test verbosely + +2018-11-05 Jim Klimov + + * tools/Makefile.am, tools/nut-scanner/Makefile.am: tools/ Makefiles + : refactor with clarifications from DMF branch (#636) + +2018-11-04 Jim Klimov + + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : fix svcprop queries to base service level + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : consider "unknown" systemd unit state as one to + be restarted + * scripts/upsdrvsvcctl/upsdrvsvcctl.in: upsdrvsvcctl.in : fix -D for + debugging level + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in, tests/nut-driver- + enumerator-test--ups.conf, tests/nut-driver-enumerator-test.sh: + nut-driver-enumerator-test.sh / nut-driver-enumerator.sh.in : + support USB and Serial modes for nutdrv_qx + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : track changes of global config and restart + drivers and nut-server if that happened + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in, tests/nut-driver- + enumerator-test.sh: nut-driver-enumerator-test.sh / nut-driver- + enumerator.sh.in : in upslist_debug() show also the global config + section + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in, tests/nut-driver- + enumerator-test--ups.conf, tests/nut-driver-enumerator-test.sh: + nut-driver-enumerator-test.sh / nut-driver-enumerator.sh.in : + support flag values (line is a single token) + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : do not use an "other" section as a magic value + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : "break" the loop, not return from it (artefact + of moving code from a sub-shell) + +2018-11-01 Jim Klimov + + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh : Use a timeout to restart/reload nut-server + (systemd) + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh : Do not restart/reload nut-server if not already + running (systemd) + +2018-10-22 Robert W. Cashman + + * drivers/cyberpower-mib.c: Added UPS load, battery charge, input + voltage/frequency, and output voltage, MIB mappings to cyberpower- + mib.c + +2018-10-12 Jim Klimov + + * .travis.yml: .travis.yml : move nut-driver-enumerator-test jobs + lower in stack - we want slow jobs to start first + * .travis.yml: .travis.yml : matrix job seems to require having at + least two items + +2018-10-11 Jim Klimov + + * tests/nut-driver-enumerator-test.sh: Update nut-driver-enumerator- + test.sh Standardize the testing setup + +2018-10-11 Jim Klimov + + * builds/nut-driver-enumerator-test/ci_build.sh: builds/nut-driver- + enumerator-test/ci_build.sh : use the "selftest" dummy service + framework if systemd is not available in the testing OS environment + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : support a "selftest" dummy service framework + * builds/nut-driver-enumerator-test/ci_build.sh: builds/nut-driver- + enumerator-test/ci_build.sh : let the tests have some + SERVICE_FRAMEWORK + * tests/nut-driver-enumerator-test.sh: tests/nut-driver-enumerator- + test.sh : update envvar processing + * builds/nut-driver-enumerator-test/ci_build.sh: builds/nut-driver- + enumerator-test/ci_build.sh : export BUILDDIR SRCDIR for the test + script + * builds/nut-driver-enumerator-test/ci_build.sh: builds/nut-driver- + enumerator-test/ci_build.sh : debug the testing script itself + * .travis.yml, builds/nut-driver-enumerator-test/ci_build.sh, + tests/nut-driver-enumerator-test.sh: Problem: nut-driver-enumerator + not Travised Solution: Add call to its selftest + +2018-10-10 Jim Klimov + + * docs/nut.dict: nut.dict : add components of --show-all-configs + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : echo if there is nothing to reconfigure (add + timestamp, do not spam in daemonized loop by default) + * scripts/Solaris/postinstall.in, scripts/Solaris/preremove.in: + Solaris preremove.in postinstall.in : pass the last-active nut- + driver-enumerator instance across package upgrades done over a + short timeframe + * scripts/Solaris/postinstall.in, scripts/Solaris/preremove.in: + Solaris preremove.in postinstall.in : less spam from "svcadm clear" + of not-failed services + * scripts/Solaris/postinstall.in, scripts/Solaris/preremove.in: + Solaris preremove.in postinstall.in : support the multi-instance + nut-driver-enumerator service now + * tests/Makefile.am: tests/Makefile.am : EXTRA_DIST the new nut- + driver-enumerator-test script and config + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : echo if there is nothing to reconfigure (early + on or after the loop has done some changes) + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : update comments regarding SMF service instance + wrapping + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : test for changed sections before testing for + changed set of section vs service names + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : small sanity check in + upslist_checksums_unchanged() + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : update comments regarding new support for + detection of changed device section contents + * scripts/upsdrvsvcctl/upsdrvsvcctl.in: upsdrvsvcctl.in : SMF service + management should wait for completion, to be same as systemd + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : optimize loop work + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : basic support for detecting changes in ups.conf + * tests/nut-driver-enumerator-test.sh: nut-driver-enumerator-test.sh + : commented a couple of FIXMEs illustrated by the test expected + data + * tests/nut-driver-enumerator-test.sh: nut-driver-enumerator-test.sh + : call testcase_upslist_debug() last in the suite + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : store SECTION_CONTENT in a variable and spit it + out once + * tests/nut-driver-enumerator-test.sh: nut-driver-enumerator-test.sh + : update tests for only trimming whitespace around first "=" + character + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : refer to systemd unit via SVCINST not $1 when + registering + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : update comments + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : drop unneeded assignment in calc_md5() + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : in upslist_normalizeFile() only trim whitespace + around first "=" character (do not touch subsequent ones in value + part) + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : optimize upsconf_getValue() since we use pre- + normalized data + * tests/nut-driver-enumerator-test.sh: nut-driver-enumerator-test.sh + : add DEBUG=trace + * tests/nut-driver-enumerator-test--ups.conf, tests/nut-driver- + enumerator-test.sh: nut-driver-enumerator-test.sh : add a test case + for dummy-ups proxying to a localhost "remote" device; add examples + of quoted key values with spaces + +2018-10-09 Jim Klimov + + * tests/nut-driver-enumerator-test--ups.conf, tests/nut-driver- + enumerator-test.sh: nut-driver-enumerator-test.sh : add a test case + for querying global config pseudo-section + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : support getting global config values (when + device section value is empty) + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : zsh not supported + * tests/nut-driver-enumerator-test.sh: nut-driver-enumerator-test.sh + : add a test case for config value that was quoted + * tests/nut-driver-enumerator-test.sh: nut-driver-enumerator-test.sh + : control values of section and device name checksums in + upsconf_debug() + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : expose section and device name checksums in + upsconf_debug() + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : introduce upsconf_getSection_MD5() to checksum + the normalized payload of a config section + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : in --reconfigure should exit() not return() + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : in systemd_validFullUnitName() add the .service + suffix if needed + * tests/.gitignore, tests/nut-driver-enumerator-test--ups.conf, + tests/nut-driver-enumerator-test.sh: Introduce simple unit tests + for nut-driver-enumerator.sh + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : expose upsconf_debug() and upslist_debug() to + CLI + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : avoid direct exit during loop processing + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : use a variable SYSTEMD_CONFPATH + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : use UPSCONF_DATA_SDP and rearrange getSection() + routines for certain use-cases + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : use upslist_readFile_once() in command-line + tools to avoid re-parsing the config many times + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : use cached UPSCONF_DATA in upsconf_getSection() + rather than FS access every time + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : rearrange and document the initial slurping and + normalization of ups.conf, reducing the work done + * docs/man/nut-driver-enumerator.txt, scripts/upsdrvsvcctl/nut- + driver-enumerator.sh.in, scripts/upsdrvsvcctl/upsdrvsvcctl.in: nut- + driver-enumerator.sh.in : add --show-configs to expose UPSCONF_DATA + with normalized content of ups.conf + +2018-10-05 Jim Klimov + + * scripts/upsdrvsvcctl/upsdrvsvcctl.in: upsdrvsvcctl.in : add + "reconf(igure)" call to pass into nut-driver-enumerator.sh + * scripts/upsdrvsvcctl/upsdrvsvcctl.in: upsdrvsvcctl.in : update + usage() + * docs/man/nut-driver-enumerator.txt, scripts/upsdrvsvcctl/nut- + driver-enumerator.sh.in: nut-driver-enumerator.txt : make + spellchecker happy + * scripts/Solaris/postinstall.in: solaris postinstall : + REPORT_RESTART_42=no when reconfiguring + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : update message for reconfig dropping of old + service + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : fix fall-through daemonization for DASH + * scripts/Solaris/README: Solaris README : update about two nut- + driver-enumerator instances + * docs/man/nut-driver-enumerator.txt: nut-driver-enumerator.txt : add + recently introduced options into manpage + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : typo fix + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : typo fix + * scripts/Solaris/nut-driver-enumerator.xml.in: nut-driver- + enumerator.xml.in : support daemonization into background (contract + service) + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : support daemonization into background + * scripts/Solaris/nut-driver-enumerator.xml.in: nut-driver- + enumerator.xml.in : typo fix + * scripts/Solaris/nut-driver-enumerator.xml.in: nut-driver- + enumerator.xml.in : avoid creating default service twice + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : support SIGHUP for the daemon + * scripts/Solaris/README, scripts/Solaris/nut-driver- + enumerator.xml.in: nut-driver-enumerator : use --daemon(=freq) in + Solaris SMF service, implement it as an option (two prepackaged + services, with and without loop) + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator : add --daemon(=freq) to monitor ups.conf vs. services + changes ourselves in a loop + * scripts/Solaris/postinstall.in: nut-driver-enumerator : use + --reconfigure to remake units from scratch in Solaris postinstall + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator : add --reconfigure to remake units from scratch + +2018-10-04 Jim Klimov + + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : for network-depending connections, wait for + ifplugd to set up physical network, if enabled + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : for network-depending connections, wait for DNS + resolver to appear + * scripts/systemd/nut-driver-enumerator.service.in: nut-driver- + enumerator.service.in : do NOT remain active when done, allow nut- + driver-enumerator.path to start this again + * scripts/Solaris/README: Solaris README : note that there is no + dynamic refresh when ups.conf is changed + * scripts/Solaris/README: Solaris README : update reference to + upsdrvsvcctl directory + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : when removing a systemd instance, also remove + systemd complaints about it (if any) + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : less ambiguity - manage ".service" instances as + such + +2018-10-03 Jim Klimov + + * common/common.c: get_libname() : support more 64-bit pathname + patterns (#609) + +2018-09-08 Jim Klimov + + * drivers/usbhid-ups.c: usbhid-ups.c : libusb/libshut tracing debug + text + +2018-10-02 Jim Klimov + + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : in systemd use-case, fall back to rude restart + if reload-or-restart of nut-server stalled and failed + +2018-09-28 Jim Klimov + + * scripts/systemd/nutshutdown.in: Update nutshutdown.in No strict + restrictions for fallback timeout + +2018-09-27 Jim Klimov + + * scripts/Solaris/nut-server.xml.in, scripts/Solaris/svc-nut- + server.in, scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut- + driver-enumerator.sh.in / nut-server.xml.in / svc-nut-server.in : + reload the running upsd instead of restarting it fully when + possible (Solaris SMF) + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : reload the running upsd instead of restarting it + fully when possible (Linux SystemD) + +2018-09-26 Jim Klimov + + * scripts/systemd/nut-driver-enumerator.path.in: nut-driver- + enumerator.path.in : typo fix for CONFDIR => CONFPATH + * docs/man/Makefile.am: docs/man/Makefile.am : handle other + nutclient*.3 manpages that are mass-implemented by some + libnutclient*.txt + * scripts/systemd/nutshutdown.in: nutshutdown.in : fallback short + timeout if config is absent or not parsable + * scripts/systemd/nutshutdown.in: nutshutdown.in : check that needed + programs exist first + +2018-09-19 Jim Klimov + + * configure.ac: configure.ac : syntactic sugar + * drivers/usbhid-ups.c: usbhid-ups.c : report the libusb version + involved in the driver at this time - reformatted + * drivers/usbhid-ups.c: usbhid-ups.c : report the libusb version + involved in the driver at this time - also the values registered + with comm_driver structure + * drivers/usbhid-ups.c: usbhid-ups.c : report the libusb version + involved in the driver at this time + * drivers/usbhid-ups.c: usbhid-ups.c : report the libusb version + involved in the driver at this time - reformatted + * drivers/usbhid-ups.c: usbhid-ups.c : report the libusb version + involved in the driver at this time - also the values registered + with comm_driver structure + * drivers/usbhid-ups.c: usbhid-ups.c : report the libusb version + involved in the driver at this time + * tools/Makefile.am, tools/nut-scanner/Makefile.am: Update comments + in tools(/nut-scanner)/Makefile.am regarding new more proper + dependency definitions + +2018-09-17 Daniele Pezzini + + * data/driver.list.in: HCL: update support level of some Meta System + devices As per the provided protocol: see nut-website's + 66d30c90401ff7929b25e5a87f9299b728f861ea + +2018-09-08 Jim Klimov + + * tools/Makefile.am: tools/Makefile.am : GENERATED_USB_FILES also + depend on nutdrv_qx.c + * tools/Makefile.am: tools/Makefile.am : generalize + GENERATED_SNMP_FILES too for consistency + * tools/Makefile.am: Makefile.am : fix back calling scripts from + distdir while being in builddir + +2018-09-07 Jim Klimov + + * tools/Makefile.am, tools/nut-snmpinfo.py, tools/nut-usbinfo.pl: + tools/nut-snmpinfo.py tools/nut-usbinfo.pl tools/Makefile : use + TOP_SRCDIR/TOP_BUILDDIR to pass with distcheck too + +2018-09-08 Jim Klimov + + * scripts/Solaris/postinstall.in: Solaris/postinstall.in : clarify + tests for present vs non-empty config files + * scripts/Solaris/postinstall.in, scripts/Solaris/postremove.in, + scripts/Solaris/preinstall.in, scripts/Solaris/preremove.in: Insert + or update header comments in Solaris pre/post-install/remove + scripts + +2018-09-07 Jim Klimov + + * tools/Makefile.am: tools/Makefile.am : update dependency on C + sources + * Makefile.am: Makefile.am : "dist" drivers/*.c before tools (which + generates further files from that) + * drivers/libusb0.c, drivers/libusb1.c: libusb0/1.c : ease debugging + by trace messages + * drivers/libusb1.c: libusb1.c : inverted order of + usb_communication_subdriver_t name/ver fields + * drivers/libusb0.c: libusb.c : inverted order of + usb_communication_subdriver_t name/ver fields + * configure.ac: configure.ac : syntactic sugar + * drivers/libusb.c: libusb.c : inverted order of + usb_communication_subdriver_t name/ver fields + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : fix initial setup with 0 service instances + present + * scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in: nut-driver- + enumerator.sh.in : try to enable "nut-server" when restarting it + * tools/Makefile.am: tools/Makefile.am : avoid rebuilding generated + files after "make dist" over and over + * tools/nut-scanner/Makefile.am: tools/nut-scanner/Makefile.am : + structurally arrange built dependencies, reduce hardcoded + references to their names + +2018-09-06 Jim Klimov + + * drivers/libshut.c, drivers/libusb.c, drivers/usbhid-ups.c: libusb + tracing debug text + +2018-09-06 Daniele Pezzini + + * data/driver.list.in: HCL: add some Legrand devices supported by + nutdrv_qx Also, specify that Legrand Multiplug is USB-only. + * data/driver.list.in: HCL: update support level of some Meta System + devices As per the provided protocol: see nut-website's + 570c1e5e9f1fb4f82abef9359897b5159e88fc50 Also, fix name of "HF Line + /2". + +2018-09-06 Gabriele Taormina + + * drivers/metasys.c: metasys: retrieve also battery charge and + runtime The added command is only supported by devices with an 'id + code' >= 14, while for other, older, models the command is not + enabled by default, and the user has to perform a specific + procedure via serial to enable it (where supported). + +2018-09-05 Daniele Pezzini + + * drivers/metasys.c: metasys: remove useless initialisation of vars + +2018-08-27 Gabriele Taormina + + * data/driver.list.in, drivers/metasys.c: metasys: support some newer + Meta System and Legrand devices Add to the metasys driver a few + new models (Meta System DHEA, and others now branded Legrand) + speaking the Meta System UPS protocol. + * drivers/metasys.c: metasys: treat any '\0' in the serial number as + a '0' + * drivers/metasys.c: metasys: for bypass mode, call status_set() with + "BYPASS", not "BY" + * drivers/metasys.c: metasys: fix handling of errors/special values + As per protocol documentation, data is sent by the device with + unsigned integers of 8, 16 or 32 bits, with errors/special values + being: - for uint16: 0xFFFF and 0xFFFE, - for uint32: 0xFFFFFFFF. + Alas, those values are (and, probably, have always been) actually + reported in the documentation (mostly) as if their types were not + unsigned (so, in decimal: -1, and -2) and the metasys driver used + them like that, converting the values to non-fixed width signed + types (int and long) and then expecting a value of -1 or -2 to + signal a particular event, but this only happens on platforms where + int is exactly 16 bits, and long 32 bits. So, leave values as + unsigned types (adjusting all the printf formats accordingly), and + use the right hex values, instead. + * data/driver.list.in, drivers/Makefile.am, drivers/legrand-hid.c, + drivers/legrand-hid.h, drivers/usbhid-ups.c: usbhid-ups: add + Legrand subdriver + * data/driver.list.in, drivers/nutdrv_qx.c: nutdrv_qx: add support + for some Legrand USB devices + +2018-08-29 Jim Klimov + + * scripts/systemd/Makefile.am: EXTRA_DIST scripts/systemd/nut.target + also + +2018-08-21 Jim Klimov + + * m4/nut_check_libneon.m4: nut_check_libneon.m4 : shell typo fix + * m4/nut_check_libneon.m4: nut_check_libneon.m4 : do not AC_MSG_WARN + inside a standard message chain + * m4/nut_check_libneon.m4: nut_check_libneon.m4 : provide fallback + defaults when pkg-config fails + +2018-08-14 Jim Klimov + + * m4/nut_check_libneon.m4: nut_check_libneon.m4 : comment about + detecting without pkgconfig as a fallback + * m4/nut_check_libavahi.m4: nut_check_libavahi.m4 : typo fix + +2018-08-19 Daniele Pezzini + + * configure.ac: configure: fix messages of pkg-config checks The + PKG_*() macros we use there already print messages, therefore we + can't use AC_MSG_CHECKING() before calling them, and + AC_MSG_RESULT() after, or we will get something like: checking for + autoconf macro support of pkg-config... checking for pkg-config... + /usr/bin/pkg-config ^^^ AC_MSG_CHECKING() + ^^^ PKG_*() macro output checking pkg-config is at least version + 0.9.0... yes ^^^ PKG_*() macro output -- continuation ok ^^^ + AC_MSG_RESULT() checking for autoconf macro support of pkg-config + module checker... checking for dummy_PKG_CONFIG... yes ^^^ + AC_MSG_CHECKING() ^^^ + PKG_*() macro output ok ^^^ AC_MSG_RESULT() ...which is not + exactly desirable. So, move the messages to AC_MSG_NOTICE(), with + the result being explicitly printed only on failure (AC_MSG_WARN() + call). + * docs/man/Makefile.am: docs/man: fix man8 target for linux/i2c + * docs/man/Makefile.am, drivers/Makefile.am: nutdrv_qx: don't + duplicate make targets Since nutdrv_qx is both a serial and a USB + driver, up until now, its executable and manpages appeared in two + lists: serial and USB drivers, in order to be built in both cases, + when ./configure'd for only one of them... but, by doing this, when + ./configure'd for both, we ended up with dupes, which could + potentially cause problems, e.g. when installing them (and this + just happened). For the executable, luckily, libtool calls install + one file at a time, so this was not, and it still should not be, a + problem. For the manpages, we were previously saved by automake, + which splits the list of files to be installed in different calls + if they are too many (see automake's am__install_max var, currently + set to 40), so the two nutdrv_qx entries ended up in different + calls to install, but the 8b75b03 commit, by adding more manpages + before nutdrv_qx's ones, pushed also the first occurrence to the + second call to install, which already contained the other one, + causing an error. While other alternative, more flexible, but also + less portable, ways for solving this exist (e.g. using GNU make's + $(sort) on the generated lists), at least for now, prefer a more + portable solution, adding new intermediate lists for serial/USB + drivers and using simple automake conditionals. Close + https://github.com/networkupstools/nut/issues/594 + +2018-08-14 Jim Klimov + + * .gitignore, Makefile.am, README, common/Makefile.am, configure.ac, + docs/FAQ.txt, docs/config-notes.txt, docs/developers.txt, + docs/features.txt, docs/man/Makefile.am, docs/man/index.txt, + docs/man/nut-driver-enumerator.txt, docs/man/upsdrvctl.txt, + docs/man/upsdrvsvcctl.txt, docs/net-protocol.txt, docs/nut.dict, + include/Makefile.am, scripts/Aix/.gitignore, scripts/Aix/nut.init, + scripts/Aix/nut.init.in, scripts/Makefile.am, + scripts/Solaris/.gitignore, scripts/Solaris/Makefile.am, + scripts/Solaris/README, scripts/Solaris/makelocal.sh, + scripts/Solaris/nut-driver-enumerator.xml.in, scripts/Solaris/nut- + driver.xml.in, scripts/Solaris/nut-monitor.xml.in, + scripts/Solaris/nut-server.xml.in, scripts/Solaris/nut.in, + scripts/Solaris/nut.xml.in, scripts/Solaris/pkginfo.in, + scripts/Solaris/postinstall.in, scripts/Solaris/postremove, + scripts/Solaris/postremove.in, scripts/Solaris/preinstall, + scripts/Solaris/preinstall.in, scripts/Solaris/prepackage.py, + scripts/Solaris/{preproto.pl => preproto.pl.in}, + scripts/Solaris/preremove.in, scripts/Solaris/svc-nut-monitor.in, + scripts/Solaris/svc-nut-server.in, scripts/systemd/.gitignore, + scripts/systemd/Makefile.am, scripts/systemd/README, + scripts/systemd/nut-driver-enumerator.path.in, scripts/systemd/nut- + driver-enumerator.service.in, scripts/systemd/nut- + driver.service.in, scripts/systemd/nut-driver.target, + scripts/systemd/nut-driver@.service.in, scripts/systemd/nut- + monitor.service.in, scripts/systemd/nut-server.service.in, + scripts/systemd/nut.target, scripts/systemd/nutshutdown.in, + scripts/upsdrvsvcctl/.gitignore, scripts/upsdrvsvcctl/Makefile.am, + scripts/upsdrvsvcctl/README, scripts/upsdrvsvcctl/nut-driver- + enumerator.sh.in, scripts/upsdrvsvcctl/upsdrvsvcctl.in: Use target + for drivers in Linux systemd (updated) and SMF instances for + drivers in new Solaris-like systems (and bring AIX initscript into + better shape) (#330) * Use target for drivers in systemd This + allows much better granularity and better monitoring in case of + multiple UPSes. * nut-driver.target improvements suggested by + @peterhoeg in PR#229 * systemd units dependencies revised and + commented * nut-driver-enumerator.sh initial commit * nut- + driver@.service.in : integrate comments from @peterhoeg about + extending unit requirements * WIP : initial integration of nut- + driver-enumerator.sh/service into makefiles etc. * nut-driver- + enumerator.sh renamed into nut-driver-enumerator.sh.in as it has + processable templates in code * nut-driver-enumerator.sh.in : add + its own config-file support to set the variables used inside (if + not via command-line env) * nut-driver-enumerator.sh.in : fix up + the copyright header * Subject: Fix systemd service file for + Debian From: Laurent Bigonville Forwarded: not- + needed * nut-driver-enumerator.sh.in : complete the Solaris SMF + support in the helper script * EXTRA_DIST the scripts/systemd/nut- + driver.target (non-templated) file * nut-driver-enumerator.sh.in : + updated comments (esp. about usage and exit-codes) and runtime + messages * nut-driver-enumerator.service.in : define an actual + service payload * nut-driver-enumerator.sh.in : refactor the logic + of MAIN PROGRAM into smaller routines for readability * nut- + driver-enumerator.sh.in : introduce routines to help define custom + dependencies of particular drivers on other services * nut-driver- + enumerator.sh.in : allow custom NUT_CONF_DIR from envvar, to + facilitate testing * nut-server.service.in : typo fix in comments + * nut-driver-enumerator.sh.in : support the concept of localhost + networking dependencies, and define vars with lists of services to + depend on * nut-driver-enumerator.sh.in : use proper FMRI:instance + separator for SMF * nut-driver-enumerator.sh.in : added variables + for dependency type on third-party service units * nut-driver- + enumerator.sh.in : change upsconf_getDriverMedia() output from tab- + separated to multiline; add upsconf_getMedia() and upsconf_debug() + and upslist_debug() * nut-driver-enumerator.sh.in : refactor with + upsconf_getValue() and cached pre-cooked ups.conf data; + infrastructure to configure service dependencies when adding the + service instance * Remove hardcoded dependencies on udev and + network from provided systemd units; add comments about extending + via drop-in files and that nut-driver-enumerator will do this for + nut-drivers * nutshutdown.in : mark executable * nut-driver- + enumerator.sh.in : complete the systemd drop-in support for custom + dependencies for a driver * nut-driver-enumerator.sh.in : complete + the SMF drop-in support for custom dependencies for a driver * + nut-driver-enumerator.sh.in : comment-away upslist_debug() in + default runs * WIP Adding Solaris SMF manifests for NUT * + Sanitize Solaris SVR4 packaging rules * Sanitize Solaris packaging + scripts some more * Add configure options for Solaris packaging + variants * Sanitize Solaris packaging scripts some more - consider + DESTDIR for installation root * Turn solaris preproto.pl into a + template so it uses proper (configured) user/group strings * + Makefile.am : ensure there is a DESTDIR set before packaging * + Makefile.am : use $(MAKE) $(AM_MAKEFLAGS) instead of explicit + "make" (mostly in packaging recipe) * makelocal.sh : commented and + revised * Solaris/Makefile.am : put generated SVR4 package into + builddir (not srcdir that may be readonly) to match other OS + recipes * Makefile.am : ensure the DESTDIR is used for packaging + purposes (when calling sub-makes) * Solaris/pkginfo.in : ARCH is + CPU_TYPE, not OS_NAME * GitIgnore built Solaris/NUT*.local.gz + product * GitIgnore built systemd files * GitIgnore + _install_pkgprotodir * Makefile.am : ensure only the custom + DESTDIR is used for packaging purposes * Makefile.am : convert the + big packaging "if" into "case"; link steps with "&&"; retain + DESTDIR if Solaris packaging fails; ensure the correct custom + DESTDIR is absent before packaging (and after Solaris packaging) * + Solaris/Makefile.am : Revise recipe-names and comments for Solaris + packaging variants * Solaris/Makefile.am and *.xml.in : relocate + SMF methods and manifests under NUT DATADIR to package compactly * + Solaris-SMF : svc-nut.in svc-nut-client.in : use @RUN_AS_*@ and + @PIDPATH@ vars instead of hardcoding * Solaris/Makefile.am : list + helper scripts and installation scripts and data in variables and + depend on them in packaging; chmod +x the scripts after copying + over to proto area * GitIgnore config.cache * Remove + Solaris/prepackage.py (unreferenced duplicate of precheck.py) * + Solaris/nut.in : sanitize the default init-script * + Solaris/Makefile.am : put init-scripts under NUT share (DATADIR) to + package it compactly; copy to OS dirs in postinstall * Makefile.am + .gitignore etc. relocate successfully built package files to + abs_top_builddir * Change Aix/nut.init to a .in template * svc- + nut.in svc-nut-client.in : consider nut.conf if available * + Solaris/Makefile.am and SVR4 scripts : install augeas lenses as + part of NUT package (in DATADIR at least) * configure.ac : comment + about sysconfdir for NUT * Sanitize Aix/nut.init.in * More + standardization of Solaris initscripts and SMF methods; use + LD_LIBRARY_PATH to prefer NUT provided libs in case of conflicts + (facilitate bundling with third-party packages) * + Solaris/Makefile.am : add ability to "make check" something here, + e.g. validate manifest XMLs * Solaris SMF XML manifests : fix + "dependent" definitions, and add dependencies on required config + files * configure.ac : fix a manually crafted "Checking for" into + using AC_MSG routines * Solaris SVR4 packaging should now take + care of SMF service registration/teardown * Solaris preremove.in + postinstall.in : Usage of @datadir@ caused "${prefix}" strings to + pop up - define the vars * Solaris scripts : use lower-cased + @datadir@ in templates processed by configure * + Solaris/preremove.in : fix FMRI pattern when removing package * + Solaris/postinstall.in : fix SMF manifest dir * + Solaris/postremove.in : fix verbose RM; wipe the /var/run/nut dir + too * Solaris/preremove.in : fix commands when removing package * + Solaris/postinstall.in : enable SMF services if configs are already + available (esp. create nut-driver instances) * + Solaris/preremove.in : fix commands when removing package * + Solaris/postinstall.in : enable SMF services if configs are already + available (esp. create nut-driver instances) - verbosity * + Solaris/nut-driver-enumerator.xml.in : use a unique dependency name + (avoid conflict in nut-driver instances chain of deps) * systemd + and Solaris : fix up embedded ${prefix} in service files and SMF + manifests after generation * systemd/README : add recent authors + * Define a NUT_DATADIR and NUT_LIBEXECDIR with expanded path values + to use in service manifests * Solaris : packaged service + addition/removal more verbose * nut-driver-enumerator.xml.in nut- + driver.xml.in : do not block startup of nut server * nut.xml.in : + do not block startup of nut server due to failed nut-driver- + enumerator * nut-driver-enumerator.sh.in : improve portability by + using TAB char as is (not regex \t which gets misinterpreted by + some tools) * nut-driver-enumerator.sh.in : comment the caveats * + nut-driver-enumerator.sh.in : apcsmart is serial only * nut- + driver-enumerator.sh.in : By default, update wrapping of devices + into services... but keep the door open to other uses of the script + * nut-driver-enumerator.sh.in : refactor a bit and add externally + callable actions * Introduce upsdrvsvcctl with semantics similar + to upsdrvctl, but managing stop/start of SMF or systemd unit + instances * nut-driver-enumerator.sh.in : consider possible + difference of device and service instance names * nut-driver- + enumerator.sh.in : refactor md5 * nut-driver-enumerator.xml.in : + add REFRESH action and do not die on RESTART * Mention nut-driver- + enumerator and upsdrvsvcctl in (systemd/|Solaris/)README * + upsdrvsvcctl.in : updated comments * upsdrvsvcctl.in : added a + resync option * Rename Solaris SMF services to match systemd + patterns and ease life for sysadmins * Add systemd nut.target to + manage the bundle of NUT services * config-notes.txt : document + the systemd and SMF support in NUT * nut.dict : update + spellchecker * Solaris/Makefile.am : support copying where attrs + can not be preserved * Solaris postinstall : report if services + were not instantly enabled due to missing config files * + upsdrvsvcctl.in : reformat prettily * nut-driver-enumerator.sh.in + : wrap usage() * nut-driver-enumerator.sh.in : added --list- + services-for-devices * nut-driver@.service.in : comment about + aligning timeouts with ups.conf maxstartdelay * nut.xml.in : + Revise comments * nut-driver-enumerator.sh.in : when amending + service unit instance config for systemd, update the Description to + state the NUT device section name * nut-driver-enumerator.sh.in : + support common NUT_CONFPATH envvar * Add upsdrvsvcctl.txt manpage + and references to upsdrvsvcctl in other docs * upsdrvsvcctl.txt + manpage : refer to service management system logs * upsdrvsvcctl : + support "list upsname" CLI action to help troubleshooting * + upsdrvsvcctl : add handling for "shutdown" command * Docs about + upsdrvsvcctl - clarify that it may not be preinstalled with non- + SMF/non-systemd OS packages * Pass spellcheck for upsdrvsvcctl doc + updates * Solaris packaging of nut-driver-enumerator.sh : deliver + into libexecdir same as in Linux * Move nut-driver- + enumerator.sh.in and upsdrvsvcctl.in into scripts/upsdrvsvcctl to + share on par between Linux and Solaris (for starters) * Use + @NUT_LIBEXECDIR@ for nut-driver-enumerator.sh * Introduce nut- + driver-enumerator.path.in for systemd * nut-driver- + enumerator.service.in : be part of nut.target, not common multi- + user * Systemd services : be PartOf=nut.target to propagate + service stops * postinstall.in : use NUT_DATADIR * nut- + monitor.xml.in : depend on nut-server (if locally running) * + nut.xml.in : fix path (use pre-eval-ed version) * nut-driver- + enumerator.sh.in : add a way to print out just an instance suffix + name * nut-driver-enumerator.sh.in : when printing full instance + name, do not add stuff if the argument is already a full name * + nut-driver-enumerator.sh.in : implement --get-device-for-service * + nut-driver (systemd/SMF) : use "nut-driver-enumerator.sh --get- + device-for-service" for current service instance name * nut.xml.in + : this service is transient * upsdrvsvcctl.in : fix parameter + passing * upsdrvsvcctl.in : "clear" the SMF service state when + stopping/starting, just in case it was failed * nut-driver- + enumerator.sh.in : restart upsd IFF the set of known-device + mappings was changed * Revise and relax some dependencies for + Solaris SMF services * nut-driver-enumerator.sh.in : info messages + go to stderr; reply for request only goes to stdout * nut-driver- + enumerator.sh.in : complete the upslist_equals() method * + nut.xml.in : never fail on stop (if component services did not + stop, it is their problem) * Solaris preremove.in SMF : clear + sevices before stopping them, just in case * upsdrvsvcctl.in : + post-process clearing of SMF service instances if any have failed + * nut.xml.in : never fail on stop (if component services did not + stop, it is their problem) * Solaris preremove.in SMF : remove nut + before services it depends on * main.c upsdrvctl.c : make debug + messages a bit more useful * Solaris preremove.in SMF : do not + block stopping NUT driver services, but follow up with + upsdrv(svc)ctl stop of everything * Solaris preremove.in SMF : + sleep after stopping drivers before removing their services * + Solaris preremove.in SMF : force-remove services of drivers * nut- + driver.xml.in : rename a dependency to avoid conflicts * Solaris + nut.xml.in : add a refresh action handler * Solaris postinstall.in + SMF : first use nut-driver-enumerator.sh.in to just register the + mappings, no autostarts * Solaris preremove.in SMF : stop drivers + with common method (and use NUT_SBINDIR) before going one by one * + Solaris postinstall.in SMF : start the drivers via upsdrvsvcctl + after registering (so the mapping is stable) * Solaris + postinstall.in preremove.in : NUT_SBINDIR => SBINDIR * Add manpage + for nut-driver-enumerator[8] * Handle EXTRA_DIST of + scripts/upsdrvsvcctl/ with their own Makefile * nut-driver- + enumerator.txt : change to be more like other page sources * + Spellcheck nut-driver-enumerator.txt * Add + scripts/upsdrvsvcctl/README * Update gitignores * List new + manpages upsdrvsvcctl nut-driver-enumerator in index * Add + upsdrvsvcctl do scripts/Makefile.am SUBDIRS * upsdrvsvcctl.in nut- + driver-enumerator.sh.in : Add a way to show configs per device * + nut-driver-enumerator.sh.in : fix upsconf_getValue() to return + success if key was found, or report an error if not * nut-driver- + enumerator.sh.in : expose upsconf_getValue() as --show-device- + config-value * nut-driver-enumerator.sh.in : NOTE on top about the + choice of simplified shell * nut-driver-enumerator.sh.in : in + upsconf_getSection() stop after printing out the section contents + * nut-driver-enumerator.sh.in : refactor upsconf_getValue() to use + upsconf_getSection() * nut-driver-enumerator.sh.in : update + comment in header * nut-driver-enumerator.service.in : do not fail + the systemd unit, it cannot restart * Fix references for + configure.in to point to configure.ac nowadays * nut-driver- + enumerator.sh.in : use fully-pathed SMF svccfg in all parts of code + consistently * nut-driver-enumerator.sh.in : comment about not- + detecting reconfigurations of existing sections currently + * docs/man/Makefile.am, scripts/subdriver/gen-snmp-subdriver.sh: + Upstream smaller fixes from 42ity NUT (#587) * gen-snmp- + subdriver.sh : replace multiline "echo" with questional tabbing by + a single-string "printf" * docs/man/Makefile.am : fix merge error + that broke manpage packaging + +2018-07-31 Daniele Pezzini + + * tools/nut-scanner/nut-scanner.c: nutscanner: get debug level early + (for nutscan_init()) and restore options (#541) * Revert "Problem: + nutscan_init() called before debug is enabled" This reverts commit + f613d45f78c96c290a1d63d4a2c3f28385d90d42. When parsing the command + line (or showing help), many options rely on a nutscan_avail_* var + already initialized by nutscan_init() -- moving that call after the + parsing of opts renders those options unavailable. * nutscanner: + parse debug level opts separately before anything else In order to + have early the value of the desired debug level (needed to + correctly debug nutscan_init()), split the parsing of command line + options into two loops: - the first one, before the call to + nutscan_init(), will only care about debug level, - the second one, + after the call to nutscan_init(), will consider the remaining (and + possibly depending on a nutscan_avail_* var already initialized by + nutscan_init()) arguments (and moan in case of errors). Closes + https://github.com/networkupstools/nut/issues/500 + +2018-07-28 Daniele Pezzini + + * drivers/nutdrv_qx.c: nutdrv_qx: support USB devices that don't + close their replies with a CR Since some devices, when + communicating via USB, don't close their replies to our + commands/queries with the expected (and mandated by the specs) CR, + rendering the driver almost useless as protocols get one less + character than they expect, update the various USB subdrivers + (leaving out the ones that rely on a CR to stop reading from the + device) to add the missing terminating CR in such cases (as long as + we get anything usable). This is a bit of a cheat, but, at least + for now, it will do -- not to mention the fact that it is way less + invasive than touching all the places of the driver that expect a + closing CR and all the qx2nut tables of the various protocols. + Close https://github.com/networkupstools/nut/issues/441 + +2018-07-25 mbastiaan <35669404+mbastiaan@users.noreply.github.com> + + * drivers/tripplite_usb.c: input_voltage_nominal, added case 6 + SMX500RT1U 230V requires case 6. + * drivers/tripplite_usb.c: Update tripplite_usb.c Incremented driver + version for pull request #584 + * data/driver.list.in: Update driver.list.in Added new line for + SMX500RT1U with product ID 0001. Updated line for other product IDs + +2018-07-24 mbastiaan <35669404+mbastiaan@users.noreply.github.com> + + * drivers/tripplite_usb.c: Update tripplite_usb.c Added + battery.charge status for 3005 protocol. Tested on SMX500RT1U, + charge level seems ok-ish considering how it's calculated and the + voltage jumping up and down. + +2018-06-17 Links + + * drivers/mge-hid.c: get PowerWalker VFI 2000 TGS working, read + values correctly + +2018-03-17 Steve Gilbert + + * drivers/libhid.c: In HIDGetEvents.c call to get_interrupt, increase + timeout from 250 to 750 ms to allow more time for UPS response + (cherry picked from commit 5cea18c04a79cd873347efeffb6bb869edd8643e + --@clepple) Closes: + https://github.com/networkupstools/nut/pull/543 Closes: + https://github.com/networkupstools/nut/issues/542 + +2018-05-24 Charles Lepple + + * drivers/tripplite-hid.c: usbhid-ups: Add support for + Delta/Minuteman UPS + https://github.com/networkupstools/nut/issues/555 + +2018-05-22 Jim Klimov + + * .travis.yml, ci_build.sh: Change the Travis test-case for + NO_PKG_CONFIG==true + +2018-05-18 Arnaud Quette + + * scripts/subdriver/gen-snmp-subdriver.sh: Improve the SNMP subdriver + generation script Provide a 3rd mode to allow an offline creation + for a complete MIB walk. In this mode, we get data from 1 file + (numeric snmpwalk dump of the whole SNMP tree). The sysOID is + extracted from the dump, and only the pointed subtree is used. A + MIB file MUST be provided, and is used to produce the string SNMP + walk. Also reformatted the whole script using tab only, and + reconciled with the DMF version. + +2018-05-15 Bernhard M. Wiedemann + + * tools/nut-snmpinfo.py, tools/nut-usbinfo.pl: Sort input file list + (#528) so that nut builds in a reproducible way in spite of + indeterministic filesystem readdir order and + http://bugs.python.org/issue30461 See https://reproducible- + builds.org/ for why this is good. + +2018-05-02 Daniele Pezzini + + * drivers/nutdrv_qx.c: nutdrv_qx: in 'sgs' USB subdriver, use + #define'd value for USB timeouts + +2018-03-15 Daniele Pezzini + + * tools/nut-scanner/scan_usb.c: nutscanner: in scan_usb.c, nullify + free()'d pointers that are later reused We assign 'device_name', + 'serialnumber' and 'vendor_name' only if the analyzed device + provides that data and, since we use these pointers also to check + if those items are available so that we can store and free() them, + after free()'ing them we must make them NULL, or the next device, + if it does not provide that data, will inherit the old (now + free()'d) pointer and will attempt to access it and re-free() it. + * drivers/libusb1.c: libusb1: don't use the same var to iterate both + devices and interface descriptor From our old libusb.c, libusb1.c + inherited a for loop that iterates over the interface descriptor in + order to try and find the HID descriptor among its 'extra' bytes. + Unluckily, it uses the same var (i) that's now used, at the same + time, for the iteration through the device list, in which it + happens to be nested. Since this obviously spells disaster, make + these vars unique (and add a bit of debugging info). + +2018-03-14 Daniele Pezzini + + * data/cmdvartab, docs/nut-names.txt: libusb: update example of + driver.version.usb and add it to cmdvartab + * drivers/libusb1.c: libusb1: publish actual libusb version + * tools/nut-scanner/scan_usb.c: libusb: in nutscanner, free busname + also on nutscan_new_device() errors or when done with it + * drivers/bcmxcp_usb.c, drivers/libusb0.c, drivers/libusb1.c, + drivers/nutdrv_atcl_usb.c, drivers/richcomm_usb.c, tools/nut- + scanner/scan_usb.c: libusb: improve handling of errors when + allocating new memory - libusb 0.1 (when not shared with libusb + 1.0): prefer our xstrdup() function -- on errors, it'll + automatically call fatal*(), - libusb 1.0 (and nutscanner): don't + use our x{malloc,strdup,...}() functions, so that we can free the + list of devices (and close the device and call libusb_exit() in + nutscanner) before exiting. + * drivers/libusb1.c: libusb1: publish the interface we are actually + using + * drivers/richcomm_usb.c: richcomm_usb: use the local USB device + handle in usb_device_open() Although at that point of + usb_device_open(), both the local (handle) and the global (udev) + device handles point to the same thing, prefer the local one to + make things clearer. + * drivers/bcmxcp_usb.c, drivers/libusb0.c, drivers/libusb1.c, + drivers/nutdrv_atcl_usb.c, drivers/richcomm_usb.c, tools/nut- + scanner/scan_usb.c: libusb: clean up after ourselves libusb 1.0: - + a device list allocated with libusb_get_device_list() must be + deallocated with a call to libusb_free_device_list(), - ditto for + the config descriptor. libusb 0.1 and 1.0: - release (commented- + out) interfaces when done with them, - remove unnecessary goto's + after calls to fatal*() functions, - nutscanner: also close the USB + device handle (and libusb_exit() for libusb 1.0) on errors. + +2018-03-13 Daniele Pezzini + + * drivers/bcmxcp_usb.c, drivers/tripplite_usb.c: usb drivers: free + USBDevice_t's dynamically allocated items when cleaning + +2018-03-13 Georg Altmann + + * docs/nut.dict: doc: update nut.dict + * INSTALL.nut: doc: Update installation instructions for FreeBSD + Details usb device permissions. Also pkg and new port config style. + +2018-03-10 Patrik Dufresne + + * drivers/powerp-txt.c: Fix tabs + * drivers/powerp-txt.c: Change status line parsing for CyberPower + OR1500LCDRTXL2U Add a new way to parse the status line in + powerpanel text driver to support CyberPower model OR1500LCDRTXL2U + with serial cable. This model doesn't provide temperature, but does + provide runtime. + +2018-03-09 Jim Klimov + + * drivers/main.c, drivers/upsdrvctl.c: main.c upsdrvctl.c : make + debug messages a bit more useful + +2018-03-05 Daniele Pezzini + + * drivers/richcomm_usb.c: richcomm_usb: don't libusb_exit() when + closing a previously opened device + * drivers/nutdrv_atcl_usb.c: nutdrv_atcl_usb: don't libusb_exit() + when closing a previously opened device + * drivers/libusb1.c: libusb1: don't libusb_exit() when closing a + previously opened device + * drivers/riello_usb.c: riello_usb: use libusb_bulk_transfer() for + bulk operations + * drivers/nutdrv_atcl_usb.c: nutdrv_atcl_usb: add missing 'inline' + keyword + +2018-03-04 Charles Lepple + + * drivers/usbhid-ups.c: usbhid-ups: fix instcmd logging before + fallback check The hidups_item pointer needs to be checked for + NULL before dereferencing. + +2018-02-28 Jim Klimov + + * drivers/snmp-ups.c: Fix the recently added update for Avocent + support (#532) * Problem: snmp-ups segfaults Solution: + base_snmp_template_index() prevented from processing empty argument + * Problem: index has to be counted for any device not just for + daisychain Solution: counted for both * Problem: debug info + needs improvement Solution: added * drivers/snmp-ups.c : bump + the version for public-release driver fix * snmp-ups.c : Fix + indentation for recent fixes + +2018-02-20 Bernhard M. Wiedemann + + * tools/nut-usbinfo.pl: Cleanup usbinfo code to reduce code + duplication and solve an associated FIXME + +2018-02-16 Arnaud Quette + + * data/driver.list.in, drivers/Makefile.am, drivers/emerson-avocent- + pdu-mib.c, drivers/emerson-avocent-pdu-mib.h, drivers/snmp-ups.c: + snmp-ups: Add support for Emerson Avocent PM3000 PDU + * drivers/snmp-ups.c, drivers/snmp-ups.h: snmp-ups: various + improvements This prepares the addition of newer devices + +2018-01-11 Daniele Pezzini + + * m4/nut_check_libusb.m4: autoconf: support libusb 0.1 + implementations identified as 'libusb-0.1' Make NUT_CHECK_LIBUSB + macro aware of those libusb 0.1 implementations named in their pkg- + config files as 'libusb-0.1', instead of just 'libusb' (e.g. on + FreeBSD). + +2018-01-10 Daniele Pezzini + + * drivers/nutdrv_qx.c: nutdrv_qx: update USB errors handling to + support both libusb 0.1 and 1.0 + +2018-01-02 Charles Lepple + + * configure.ac: Fix AC_MSG_*() quoting The autoconf quote characters + are `[` and `]` - no need for `"`. + +2018-01-01 Charles Lepple + + * m4/nut_check_libusb.m4: Add autoconf check for libusb_strerror() + Closes: https://github.com/networkupstools/nut/issues/509 + * docs/man/nutdrv_qx.txt, docs/man/snmp-ups.txt, + docs/man/ups.conf.txt, docs/man/usbhid-ups.txt: doc: Clean up + description of `pollfreq` and USB interrupts Closes: + https://github.com/networkupstools/nut/issues/476 + +2017-12-05 Jim Klimov + + * .travis.yml: .travis.yml : add a test-case for builds in absence of + pkg-config in the OS + +2017-11-29 Arnaud Quette + + * docs/configure.txt, docs/man/nutupsdrv.txt, docs/man/upsd.txt: doc: + missing documentation for NUT_* env vars Complete documentation + for upsd and drivers related to the environment variables + NUT_CONFPATH, NUT_STATEPATH and NUT_ALTPIDPATH + +2017-04-08 Sam Varshavchik + + * docs/man/Makefile.am: Fix creation of documentation from + libnutclient_misc.txt A simple .txt.3 rule doesn't understand that + libnutclient_misc.txt creates a bunch of .3. A parallel build, say + 'make -j 10' results in make trying to figure out how to build + nutclient_authenticate.3 before building libnutclient_misc.3, and + without a corresponding .txt in sight it gives up. Rebased onto + master by Charles Lepple clepple+nut@gmail.com Closes: + https://github.com/networkupstools/nut/pull/418 + +2017-11-28 Arnaud Quette + + * docs/man/usbhid-ups.txt: doc: minor formatting in usbhid-ups man + page + +2017-11-27 Arnaud Quette + + * docs/man/nutupsdrv.txt: doc: reword nutupsdrv man page Reference: + https://github.com/networkupstools/nut/issues/476 + +2017-11-27 Jim Klimov + + * tools/nut-scanner/nut-scanner.c: Problem: nutscan_init() called + before debug is enabled Solution: Move the call to this stateless + function to the point after we parse arguments and just before we'd + start the actual scans. Later this can be extended to also consider + which scans were requested and so which libs to load. Thanks to + @clepple for research in + https://github.com/networkupstools/nut/issues/500 + +2017-11-26 Charles Lepple + + * docs/man/usbhid-ups.txt: doc: reword other parts of usbhid-ups man + page + * docs/man/usbhid-ups.txt: doc: mention CPS delay quirks in usbhid- + ups man page Closes: + https://github.com/networkupstools/nut/issues/432 + * tools/nut-scanner/scan_usb.c: nut-scanner: update + usb_get_string_simple() for libusb-1.0 API Closes: + https://github.com/networkupstools/nut/issues/499 + * drivers/libusb1.c: libusb1: const-ify the USB interface number + Remove a few "magic numbers" from USB/HID-related calls. + * drivers/libusb1.c: libusb1: LBYL approach to + libusb_set_auto_detach_kernel_driver() Switch to look-before-you- + leap (LBYL) approach to calling + libusb_set_auto_detach_kernel_driver(), since FreeBSD (11.0 and + 11.1; probably others) requires root privileges to attempt the + kernel driver detach (even if no detach operation is needed). + * m4/nut_check_libusb.m4: libusb1: check for + libusb_kernel_driver_active() + +2017-11-21 Charles Lepple + + * data/driver.list.in: HCL: Change Riello IDG/IPG support level to 4 + The IDG and IPG models were not included in the protocol + documentation provided to the NUT project. Some values are also + returned as 0xFF/0xFFF/0xFFFF - see the HCL for details. Source: + http://lists.alioth.debian.org/pipermail/nut- + upsdev/2017-November/007357.html + +2017-11-17 Arnaud Quette + + * docs/man/nutupsdrv.txt, docs/man/usbhid-ups.txt: man pages: + clarification on polling parameters Explain difference between + pollfreq and pollinterval in usbhid-ups, and highlight the + pollinterval parameter use from ups.conf in nutupsdrv Closes: + https://github.com/networkupstools/nut/issues/476 + * data/driver.list.in: HCL: Eaton 9PX supported by mge-shut, usbhid- + ups and netxml-ups + * data/driver.list.in: HCL: Eaton ATS 30 supported by snmp-ups + * drivers/Makefile.am, drivers/mge-hid.c: mge-shut/usbhid-ups: + compute Output load for Eaton UPS When HID data + UPS.PowerConverter.Output.ActivePower is not present, compute a + realpower approximation using available data. This is needed for + Eaton 5E and some other units Closes: + https://github.com/networkupstools/nut/issues/484 + +2017-10-30 Michal Marek + + * Makefile.am, configure.ac, scripts/systemd/Makefile.am: + configure.ac: Fix systemd shutdown directory detection The + configure script assumes that systemd is installed below ${libdir}, + which is not true on many biarch Linux distros with /lib64. Instead + of guessing, use pkg-config to find the path and provide a --with- + systemdshutdowndir option so that make distcheck can override it. + Also, rename the internal varable to systemdshutdowndir to rhyme + with the respective systemd.pc variable. + +2017-10-20 Jim Klimov + + * configure.ac: Problem: configure fails on system without pkg-config + Solution: detect presence and usability of pkg-config program and + autotools macros (they end up as unexpanded tokens if pkg-config is + not installed), and use this knowledge to proceed with search for + libcppunit - or not. When the test is optional, we should not kill + the build if we can not make it due to missing tools. + +2017-10-11 Jim Klimov + + * drivers/eaton-pdu-marlin-mib.c: eaton-pdu-marlin-mib.c : line- + breaks for readability and 80-col standard - pass 2 + * drivers/eaton-pdu-marlin-mib.c: eaton-pdu-marlin-mib.c : line- + breaks for readability and 80-col standard + +2017-10-08 Charles Lepple + + * docs/hid-subdrivers.txt: hid-subdrivers.txt: fix explore command + line Also reformat some surrounding text. Closes: + https://github.com/networkupstools/nut/issues/436 + * docs/hid-subdrivers.txt: hid-subdrivers.txt: clarify Tripp-Lite USB + reference Closes: + https://github.com/networkupstools/nut/issues/452 + * docs/man/powerpanel.txt: powerpanel: emphasize that this driver is + serial-only Apparently, the PowerPanel Plus vendor tool also has + USB support. + * docs/man/belkin.txt, docs/man/belkinunv.txt: belkin/belkinunv: add + links to man pages for other Belkin drivers + * docs/man/tripplite_usb.txt: tripplite_usb: update man page * Fix + link to tripplitesu(8) * Add 3005 protocol * Update protocol + variable name + * docs/man/dummy-ups.txt: dummy-ups: last state should be "OB LB" to + match text Also corrected a typo. + +2017-10-03 Arnaud Quette + + * docs/configure.txt: Update configure documentation for libusb + Document the possibility to override the auto-detection choice + +2017-10-04 Daniele Pezzini + + * configure.ac, m4/nut_check_libusb.m4: libusb 1.0 port: directly use + `--with-usb` to choose the library + +2017-10-03 Arnaud Quette + + * docs/configure.txt: Remove an extraneous point + * docs/configure.txt: Update configure documentation for libusb + Document the possibility to override the auto-detection choice, + even though the implementation of this override is not yet + currently working + +2017-10-02 Daniele Pezzini + + * docs/configure.txt, m4/nut_check_libusb.m4: libusb 1.0 port: + support libusb 0.1/-compat even when 1.0 is available Since libusb + 1.0 can happily coexist with libusb 0.1/libusb-compat, rework our + NUT_CHECK_LIBUSB macro so that, if both are available, libusb 1.0 + precedence can be overridden passing to `configure` appropriate + values for `--with-usb-includes` and `--with-usb-libs` (i.e. libusb + 0.1/libusb-compat-only settings). + * m4/nut_check_libusb.m4: libusb 1.0 port: expand a bit the + introductory comment of libusb ac macro + * m4/nut_check_libusb.m4: libusb 1.0 port: use only one AC_DEFINE'd + variable for libusb 0.1/-compat Libusb 0.1/libusb-compat can be + found with both pkg-config and with its own libusb-config, but, + regardless of how we found it, we need to use the same AC_DEFINE'd + variable to signal its presence. + * m4/nut_check_libusb.m4: libusb 1.0 port: don't check if libusb is + usable, if it's not available Since LIBUSB_VERSION is always non- + empty ('none', if libusb is not found), testing for non-emptiness + will always fail and libusb 0.1/libusb-compat checks will always be + performed. So, test instead that it is not 'none'. + +2017-03-22 Arnaud Quette + + * drivers/libusb1.c, drivers/nut_libusb.h, tools/nut- + scanner/scan_usb.c: Fix spacers + +2016-11-09 Charles Lepple + + * docs/nut-names.txt, drivers/libusb0.c, drivers/libusb1.c: Add + `driver.version.usb` variable Reference: + https://github.com/networkupstools/nut/issues/300 + +2016-09-25 Charles Lepple + + * drivers/libusb1.c: libusb1: use return code from libusb_open() Per + , the handle is only populated when the return code + is 0. This fixes a crash during device detection where more than + one HID UPS is available, and the driver needs to skip the first + one. + +2016-09-02 Arnaud Quette + + * drivers/bcmxcp_usb.c, drivers/blazer_usb.c, drivers/libusb1.c, + drivers/nutdrv_atcl_usb.c, drivers/nutdrv_qx.c, + drivers/richcomm_usb.c, drivers/riello_usb.c: libusb 1.0 port: fix + return code for interrupt ops libusb 1.0 returns on success, the + number of bytes actually transferred or otherwise an error code, + except for interrupt transfers, where the actual transfer size is + stored in a separate variable. The libusb 1.0 implementation in NUT + thus needed to be fixed to behave the same way than the libusb 0.1 + implementation Reference: + https://github.com/networkupstools/nut/issues/300 + +2016-08-31 Arnaud Quette + + * drivers/libusb1.c: libusb 1.0 port: remove the check on USB device + count With the port to libusb 1.0, a sanity check was done on the + available number of USB devices to try. This however caused a + behavior regression, since the only device that NUT may have access + to can be the only UPS connected. In this case, the driver may exit + upon trying to reconnect if the device is transiently not available + Reference: https://github.com/networkupstools/nut/issues/300 + * drivers/libusb1.c, drivers/richcomm_usb.c: libusb 1.0 port: + complete usb_set_altinterface code usb_set_altinterface allows to + force the USB code to call `libusb_set_interface_alt_setting (0, + 0)` (equivalent to `libusb_set_altinterface(0)` in libusb 0.1), as + was done in NUT 2.7.2 and earlier. However, the libusb 1.0 + implementation was still missing the related code Reference: + https://github.com/networkupstools/nut/issues/300 + * drivers/nutdrv_atcl_usb.c, drivers/richcomm_usb.c: libusb 1.0 port: + fix kernel driver detachment Following the recent modification for + the kernel driver detachment, and the related functions + availability depending on the platforms, nutdrv_atcl_usb and + richcomm_usb were using the wrong macro for + libusb_set_auto_detach_kernel_driver and were missing the libusb + 1.0 code for explicit kernel driver detachment Reference: + https://github.com/networkupstools/nut/issues/300 + +2016-08-17 Arnaud Quette + + * drivers/libusb1.c, m4/nut_check_libusb.m4: libusb 1.0 port: rework + the kernel driver detachment libusb 1.0 has introduced a new + function (libusb_set_auto_detach_kernel_driver), beside from the + explicit kernel driver detachment request + (libusb_detach_kernel_driver). However, the former is not available + on all systems. As an example, FreeBSD 10.1-10.3 does not have + this. The detachment and interface claiming has been reworked to + handle this case (reported by Charles Lepple) Reference: + https://github.com/networkupstools/nut/issues/300 + +2016-08-12 Arnaud Quette + + * drivers/libusb1.c: libusb 1.0: remove unused typesafe_control_msg() + workaround For libusb 0.1 implementation, we had to workaround a + libusb API goofs, by wrapping the base function usb_control_msg(), + and casting the variables to the right type. This is not needed for + libusb 1.0 implementation, but was wrongly left in the code + (reported by Charles Lepple) + +2016-08-11 Arnaud Quette + + * drivers/bcmxcp_usb.c: bcmxcp_usb: fix a warning on unused variable + * drivers/bcmxcp_usb.c, drivers/libusb1.c, drivers/nutdrv_atcl_usb.c, + drivers/richcomm_usb.c: libusb 1.0 port: simplify bus publication + bus publication was wrongly listing both the bus and the portname, + instead of the bus only. This may have caused some issue when + trying to match the port + * drivers/usbhid-ups.c: usbhid-ups/mge-shut: forgotten version bump + * drivers/usbhid-ups.c: usbhid-ups/mge-shut: rework errno/errors + handling libusb 1.0 has its own set of return codes, and error + interface. Rework the common HID core (shared between usbhid-ups + and mge-shut) so that error handling can work with both, and using + either libusb 0.1 or 1.0 for usbhid-ups + * tools/nut-scanner/scan_usb.c: nut-scanner: missing symbols lookup + for libusb 1.0 A few symbols from libusb 1.0 were wrongly used + directly, instead of being looked up and loaded at init time + * drivers/bcmxcp_usb.c, drivers/libusb1.c, drivers/nutdrv_atcl_usb.c, + drivers/richcomm_usb.c: libusb 1.0 port: add missing libusb_exit() + calls + * tools/nut-scanner/nutscan-init.c, tools/nut-scanner/scan_usb.c, + tools/nut-usbinfo.pl: nut-scanner: initial port to libusb 1.0 The + port to libusb 1.0 is complete, at least from a build perspective. + This now needs to be tested with devices + * drivers/nutdrv_atcl_usb.c, drivers/richcomm_usb.c: Remove redundant + variable + * drivers/tripplite_usb.c: tripplite_usb: remove extraneous comment + char + * drivers/nut_libusb.h: permute typedef order of usb_dev_handle + * drivers/nutdrv_qx.c: nutdrv_qx: initial port to libusb 1.0 The + port to libusb 1.0 is complete, at least from a build perspective. + This now needs to be tested with devices + * drivers/richcomm_usb.c: richcomm_usb: missing function remap for + libusb 0.1 usb_strerror was not remapped for libusb 0.1 + implementation + * drivers/tripplite_usb.c: tripplite_usb: initial port to libusb 1.0 + The port to libusb 1.0 is complete, at least from a build + perspective. This now needs to be tested with devices + * drivers/riello_usb.c: riello_usb: initial port to libusb 1.0 The + port to libusb 1.0 is complete, at least from a build perspective. + This now needs to be tested with devices + +2016-08-10 Arnaud Quette + + * drivers/richcomm_usb.c: richcomm_usb: initial port to libusb 1.0 + The port to libusb 1.0 is complete, at least from a build + perspective. This now needs to be tested with devices + * drivers/nutdrv_atcl_usb.c: nutdrv_atcl_usb: add the missing detach + call libusb 1.0 provide its own routine for detaching kernel + driver + * drivers/Makefile.am, drivers/libhid.c, drivers/nut_libusb.h: + Forgotten occurences of libusb.h renaming NUT internal header + "libusb.h" was renamed, since it collides with the libusb 1.0 + header, which has the same name. A few occurences of reference and + documentation were however missing + * drivers/nutdrv_atcl_usb.c: nutdrv_atcl_usb: initial port to libusb + 1.0 The port to libusb 1.0 is complete, at least from a build + perspective. This now needs to be tested with devices + * drivers/blazer_usb.c: blazer_usb: initial port to libusb 1.0 The + port to libusb 1.0 is complete, at least from a build perspective. + This now needs to be tested with devices + * drivers/bcmxcp_usb.c: bcmxcp_usb: code cleanup + +2016-08-09 Arnaud Quette + + * drivers/bcmxcp_usb.c: bcmxcp_usb: initial port to libusb 1.0 The + port to libusb 1.0 is complete, at least from a build perspective. + This now needs to be tested with devices + * docs/configure.txt, drivers/Makefile.am, drivers/libhid.c, + drivers/libhid.h, drivers/{libusb.c => libusb0.c}, + drivers/libusb1.c, drivers/{libusb.h => nut_libusb.h}, drivers/usb- + common.h, drivers/usbhid-ups.c: ushid-ups: complete the port to + libusb 1.0 The port to libusb 1.0 is now complete for usbhid-ups. + Other USB drivers (bcmxcp_usb, blazer_usb, nutdrv_atcl_usb, + richcomm_usb, riello_usb, tripplite_usb, nutdrv_qx) have still to + be addressed + +2016-08-01 Arnaud Quette + + * configure.ac, m4/nut_check_libusb.m4: Initial port to libusb 1.0 + Starting with the configure checks, to detect if libusb 1.0 if + available, and otherwise fall back to the libusb 0.1 backend + +2017-09-17 Jim Klimov + + * configure.ac, tests/Makefile.am: Improve configure script and + recipe for CPPUNIT and C++11 detection * Detect C++11 support and + its use for CPPUNIT tests through configure.ac - should address + issue #472 * Report after detecting C++11 support, presence of + libcppunit, and request for valgrind, whether we'd build the + cppunit tests * Update relevant comments in configure.ac + * drivers/libusb0.c, drivers/libusb1.c: libusb0.c / libusb1.c : + report more visibly if we encountered errors accessing the device + (issue #477) + * drivers/libusb0.c, drivers/libusb1.c: libusb0.c / libusb1.c : + sanitize indentation and break up long-lines + +2017-09-21 Spiros Ioannou + + * drivers/phoenixcontact_modbus.c: phoenixcontact_modbus: fix stale + data detection Also mark driver as DRV_BETA Source: + http://lists.alioth.debian.org/pipermail/nut- + upsdev/2017-September/007331.html + +2017-09-17 Jim Klimov + + * configure.ac: configure.ac : look for CPPUNIT after detecting pkg- + config presence, can help vs. issue #478 + +2017-09-06 Jim Klimov + + * common/common.c: common.c : dflt_statepath() / altpidpath() : + support defined-but-empty envvars to have same effect as not- + defined + * common/common.c: common.c : altpidpath() : support priority of an + envvar, like statepath does + +2017-09-05 Jim Klimov + + * drivers/main.c: main.c : update usage message with hints about + running as unprivileged user + +2017-08-28 Jim Klimov + + * .travis.yml, clients/upsclient.c, drivers/dstate.h, drivers/eaton- + pdu-marlin-mib.c, tests/Makefile.am: A few small fixes for cleaner + codebase and compilations (#466) * dstate.h : use our timehead.h + to have "struct timeval" defined * eaton-marlin : cosmetic + whitespace fixes * tests/Makefile.am : cppunit should build with + C++11 * .travis.yml : make sure to use "docker" env with its + gcc-4.8+ for support of C++11 in cppunit tests + +2017-08-24 Jim Klimov + + * docs/Makefile.am: docs/Makefile.am : fix up access rights for other + files in docs too (some PNGs end up inaccessible otherwise) + +2017-08-23 Arnaud Quette + + * docs/nut-names.txt, docs/nut.dict, drivers/eaton-ats16-mib.c: snmp- + ups: add support for input.phase.shift (#433) * snmp-ups: add + support for input.phase.shift ATS can now publish the electrical + dephasing between input sources * Make spellchecker happy about + "dephasing" + +2017-08-23 Christian Ehrhardt + + * drivers/Makefile.am: automake: only pass net-snmp cflags to snmp- + ups (#464) Other than formerly assumed in the makefile cflags can + be more than includes. And some of them need to be in sync in + regard to CFLAGS and LDFLAGS - for example usage of -fPIE. This + conflicts with a current assumption in the makefile "In any case, + CFLAGS are only -I options, so there is no harm". On a + Distribution where PIE is enabled by default, but disabled for + special cases (like net-snmp) the configure detection gets them as: + LIBNETSNMP_CFLAGS = -DNETSNMP_ENABLE_IPV6 -fno-strict-aliasing -g + -O2 -fdebug-prefix-map=/build/net-snmp-nlMQSZ/net-snmp-5.7.3+dfsg=. + -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector- + strong -Wformat -Werror=format-security -DNETSNMP_USE_INLINE + -Ulinux -Dlinux=linux -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv + -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE + -D_FILE_OFFSET_BITS=64 -I/usr/lib/x86_64-linux-gnu/perl/5.26/CORE + -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include LIBNETSNMP_LIBS = + -Wl,-Bsymbolic-functions -specs=/usr/share/dpkg/no-pie-link.specs + -Wl,-z,relro -Wl,-z,now -L/usr/lib/x86_64-linux-gnu -lnetsnmp + -lcrypto -lm Of importance are: -specs=/usr/share/dpkg/no-pie- + compile.specs -specs=/usr/share/dpkg/no-pie-link.specs Now when + compiling the non-snmp objects incorrectly get the + "-specs=/usr/share/dpkg/no-pie-compile.specs" due to the assumption + that it is safe to add up all CFLAGS to the global one. LDFLAGS + imported that way are only added to snmp. snmp_ups_LDADD = + $(LDADD_DRIVERS) $(LIBNETSNMP_LIBS) [...] snmp-ups$(EXEEXT): + $(snmp_ups_OBJECTS) $(snmp_ups_DEPENDENCIES) + $(EXTRA_snmp_ups_DEPENDENCIES) @rm -f snmp-ups$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(snmp_ups_OBJECTS) $(snmp_ups_LDADD) $(LIBS) + That leads to other (all non snmp_ups) objects in drivers failing + to build. They get the no-pie-compile.specs (incorrect) spec but + not the no-pie-link.specs on the link step. Some other parts like + mge_shut and nutdrv_qx already have custom CFLAGS/LDFLAGS that are + not added to the global CFLAGS. So despite the commend in the + makefile this doesn't seem to be new in general to nut. I don't + want to mess too much with your build system for now as I don't + know many of its implications. So I chose not the full drop of that + global CFLAGS merge, but a minimal patch for now which fixes the + issue described. Thereby closes #463 + +2017-08-23 Jim Klimov + + * docs/snmp-subdrivers.txt, drivers/Makefile.am, drivers/eaton-mib.h, + drivers/eaton-pdu-genesis2-mib.c, drivers/eaton-pdu-genesis2-mib.h, + drivers/{eaton-mib.c => eaton-pdu-marlin-mib.c}, drivers/eaton-pdu- + marlin-mib.h, drivers/eaton-pdu-pulizzi-mib.c, drivers/eaton-pdu- + pulizzi-mib.h, drivers/eaton-pdu-revelation-mib.c, drivers/eaton- + pdu-revelation-mib.h, drivers/snmp-ups.c: Eaton ePDU SNMP MIB file + split in four (#465) * snmp-subdrivers.txt : reference the + multitude of eaton subdrivers * eaton-mib.h renamed into separate + constituent headers * eaton-mib.c renamed into separate + constituent sources, earlier history retained in eaton-pdu- + genesis2-mib.c * eaton-pdu-revelation-mib.c eaton-pdu-pulizzi- + mib.c eaton-pdu-genesis2-mib.c : no use to include dstate.h here * + eaton-pdu-marlin-mib.c eaton-pdu-revelation-mib.c : port the + renamed structure names from original eaton-mib.c evolution + +2017-08-16 Arnaud Quette + + * drivers/snmp-ups.c: snmp-ups: fix the rounding / truncation of some + values The multiplier system of the snmp-ups driver resulted in + some values being rounded to the nearby integer value, thus causing + a loss of the decimals and the value precision in general. This was + mainly visible on the value of currents, but also on some voltages + +2017-08-07 Tobby + + * drivers/apcupsd-ups.c: apcupsd-ups: interpret "SHUTTING DOWN" as + "LB" Fix issue https://github.com/networkupstools/nut/issues/460 + so NUT with apcupsd-ups driver will correctly initiate a shut down + on low battery. Bump version to 0.5 Closes: + https://github.com/networkupstools/nut/issues/460 Closes: + https://github.com/networkupstools/nut/issues/461 + +2017-08-10 Arnaud Quette + + * drivers/apc-ats-mib.c, drivers/apc-ats-mib.h: Remove exec bits on + SNMP subdrivers + +2017-08-02 Charles Lepple + + * drivers/cps-hid.c: CPS HID: add input.frequency and + output.frequency (0.5) Suggested by Andy Jan: + http://lists.alioth.debian.org/pipermail/nut- + upsuser/2017-August/010856.html + +2017-08-04 Arnaud Quette + + * docs/nut-names.txt: NUT namespace: fix an extraneous character + insertion A character was wrongly inserted during the previous + commit, triggering a spellcheck error + * drivers/eaton-mib.c: snmp-ups: Publish outlet.n.name for Eaton ePDU + * docs/nut-names.txt: Extend namespace for iPDU and outlets Extend + NUT namespace to also publish the name of an outlet, using + "outlet.n.name", beside from the existing "outlet.n.desc" + +2017-08-03 Arnaud Quette + + * drivers/eaton-mib.c: snmp-ups: Fix the phase of outlet groups for + Eaton PDU Compute the phase to which an outlet group is connected + WRT the total number of phase(s) and the considered outlet group + number. + * drivers/snmp-ups.c, drivers/snmp-ups.h: snmp-ups: Introduce values + lookup functions As already used in other drivers, such as usbhid- + ups, introduce optional values lookup functions, beside from values + lookup mapping. This allows to have a more powerful and generic + values processing before publication + +2017-07-22 Charles Lepple + + * drivers/openups-hid.c: usbhid-ups: only check iOEMInformation once + for openups2 This prevents the 'libusb_get_string: invalid + argument' message from being logged continously. Patch provided by + Alphonse + http://lists.alioth.debian.org/pipermail/nut- + upsdev/2017-July/007314.html + +2017-02-02 Daniel Schaal + + * drivers/main.c: Add foreground option to drivers + * docs/man/upsd.txt, scripts/systemd/nut-server.service.in, + server/upsd.c: Add foreground option to upsd + +2016-12-17 Daniel Schaal + + * clients/upsmon.c, docs/man/upsmon.txt, scripts/systemd/nut- + monitor.service.in: Add option to run upsmon in foreground + +2017-06-26 Jim Klimov + + * docs/man/Makefile.am: docs/man/Makefile.am : Suffice to have + prebuilt docs in dist-ed sources only if DOC_INSTALL_DISTED_MANS is + enabled + * docs/man/Makefile.am: docs/man/Makefile.am : Fix up dist-ed manpage + source timestamps regardless of DOC_INSTALL_DISTED_MANS value + * docs/man/Makefile.am: docs/man/Makefile.am : Fix up manpage source + timestamps when dist-ing + * docs/Makefile.am: docs/Makefile.am : make sure the builddir copy of + docbook-xsl.css is writeable (file is copied from OS, some distros + have it 444 and not 644) + * docs/man/Makefile.am: docs/man/Makefile.am : do not rebuild docs + and do not error out if a prebuilt copy is among sources (not only + in builddir as before) + * configure.ac, docs/man/Makefile.am: configure.ac + docs/man/Makefile.am : track DOC_INSTALL_DISTED_MANS fallback + behavior + * configure.ac, m4/nut_check_asciidoc.m4: m4/nut_check_asciidoc.m4 + configure.ac : parametrize the required minimum versions + (asciidoc/a2x, dblatex) + * configure.ac: configure.ac : refer to detailed doc from --with-doc + help text; preset explicit nut_with_doc=man=auto value + * docs/man/Makefile.am: docs/man/Makefile.am : small typo in comment + * configure.ac: configure.ac : move comment to a more relevant line + +2017-06-25 Charles Lepple + + * tools/gitlog2changelog.py: gitlog2changelog: log parse errors for + Author and Date Suggested by Jim Klimov. + * tools/gitlog2changelog.py: gitlog2changelog: Date header only + occurs at start of line Alternative to + https://github.com/networkupstools/nut/pull/427 + +2017-06-13 Arnaud Quette + + * drivers/main.c: all drivers: update inline help for '-d ' + +2017-06-12 Arnaud Quette + + * drivers/powerware-mib.c: snmp-ups: add input.bypass.frequency for + Eaton 3ph + +2017-06-12 EVER-PowerSystems + + * drivers/ever-hid.c: fixed status names, added comments, fixed + duplicates + * drivers/ever-hid.c: fixed NUT names + +2017-06-12 Arnaud Quette + + * docs/man/nutupsdrv.txt, drivers/main.c: all drivers: change + dump_data from flag to variable The new option '-d dump_data' can + now accept the number of update loops requested as its value + +2017-06-09 Arnaud Quette + + * drivers/main.c: all drivers: add '-d' data dump option Add '-d' + option to the driver-core, which causes the driver to dump the data + tree in upsc-like format to stdout, and exit + +2017-06-09 Arnaud Quette + + * docs/man/nutupsdrv.txt, drivers/dstate.c, drivers/dstate.h, + drivers/main.c: all drivers: add '-d' data dump option Add '-d' + option to the driver-core, which causes the driver to dump the data + tree in upsc-like format to stdout, and exit + +2017-06-12 Emilien Kia (Eaton) + + * docs/man/nutupsdrv.txt, drivers/main.c: Add option to run driver on + standalone mode. (#423) When a driver is launched with '-s ' + instead of '-a ', the driver does not read ups.conf and only + looks for parameters on command line arguments (-x =). At + least, 'port' parameter shall be specified. + +2017-06-03 Charles Lepple + + * drivers/belkin-hid.c: usbhid-ups: add Liebert GXT4 USB VID:PID + [10AF:0000] Source: http://lists.alioth.debian.org/pipermail/nut- + upsuser/2017-June/010682.html Voltage and ConfigVoltage appear to + be scaled improperly per the debug output. + +2017-05-24 Arnaud Quette + + * docs/nut-names.txt, drivers/eaton-mib.c, drivers/snmp-ups.c: snmp- + ups: add support for outlet.group phase (#422) * snmp-ups: fix + oid2info value lookup When oid2info returns NULL, don't publish + the variable. Previously, this was returning "UNKNOWN" which was + not suitable * snmp-ups: add support for outlet.group phase + Outlets groups can now publish the electrical phase to which the + physical outlets group (Gang) is connected to. This is useful for + 3ph ePDU + +2017-05-21 Charles Lepple + + * data/driver.list.in: HCL: CPS EC750G Source: + http://lists.alioth.debian.org/pipermail/nut- + upsuser/2016-December/010461.html + * data/driver.list.in: HCL: CPS PR2200LCDRT2U (SNMP) + +2017-05-20 Charles Lepple + + * data/driver.list.in: HCL: Add APC Back-UPS CS; edit other APC USB + entries Closes: https://github.com/networkupstools/nut/issues/365 + * data/driver.list.in: HCL: CyberPower EC350G supported by usbhid-ups + (v2.7.3) Per @aurimasv on GitHub: > Test results: Tested on + FreeNAS 9.10.1. Unplugged the UPS and the system > shutdown after + 30 seconds. Closes: + https://github.com/networkupstools/nut/issues/347 Also sorted CPS + entries. + * data/driver.list.in: HCL: Powercool 350VA to 1600VA USB (v2.7.2+) + Closes: https://github.com/networkupstools/nut/issues/203 + * data/driver.list.in: HCL: Numeric Digital 800 plus works with + nutdrv_qx Closes: + https://github.com/networkupstools/nut/issues/115 (~ 2.7.4) + +2017-05-08 EVER-PowerSystems + + * drivers/Makefile.am: fixed errors in makefile + * drivers/Makefile.am, drivers/ever-hid.c, drivers/ever-hid.h, + drivers/usbhid-ups.c, scripts/upower/95-upower-hid.rules: add EVER + hid ups + +2017-04-21 Jim Klimov + + * docs/Makefile.am: docs: build cables html documentation Don't skip + cables from html documentation. + +2017-04-09 Jim Klimov + + * docs/Makefile.am: docs/Makefile.am : typo fix not-building + FAQ.chunked + +2017-04-21 Jim Klimov + + * docs/Makefile.am: docs/Makefile.am : make the working directory + contents writable before running a2x, so it can manage files copied + as read-only in earlier steps + +2017-04-10 Jim Klimov + + * docs/Makefile.am, docs/man/Makefile.am: Some systems detect html- + pages as "XML" - please them too + * docs/man/Makefile.am: Some systems detect man-pages as "ASCII text" + - please them + +2017-04-10 Jim Klimov + + * docs/man/Makefile.am: Update Makefile.am Some systems detect text + sources as "ISO-8859 English" text - please them. + +2017-04-09 Jim Klimov + + * docs/man/Makefile.am: docs/man/Makefile.am : fix check-man-html for + distcheck + * docs/man/Makefile.am: docs/man/Makefile.am : fix check-man-pages + for distcheck + * docs/man/Makefile.am: docs/man/Makefile.am : fix check-man-txt for + distcheck + * configure.ac, docs/Makefile.am, docs/man/Makefile.am: Add "make + check" for generated (or "released" pre-built) docs + * docs/Makefile.am: docs/Makefile.am : typo fix not-building + FAQ.chunked + * configure.ac: configure.ac : add --with- + doc(s)=all={yes,no,skip,auto} to manch e.g. man=skip etc. syntax + +2017-04-05 Arnaud Quette + + * data/driver.list.in: Add support for Eaton 9PX Split Phase 6/8/10 + kVA Using netxml-ups, usbhid-ups and mge-shut + * drivers/netxml-ups.c: netxml-ups: bump driver version In order to + reflect update for 2phases, bump driver version + * drivers/dstate.c: dstate_detect_phasecount: update for 2phases + Update the code to be able to handle 2phases devices, also known as + "split phases" + +2017-04-04 Arnaud Quette + + * MAINTAINERS, data/driver.list.in, docs/man/nutupsdrv.txt, + drivers/Makefile.am, drivers/mge-shut.c, drivers/mge-shut.h: + oldmge-shut: final deprecation and removal oldmge-shut is not + anymore part of the distribution, and is replaced by mge-shut + +2017-04-04 Arnaud Quette + + * clients/upsclient.c, drivers/gamatronic.c, drivers/openups-hid.c, + drivers/snmp-ups.c, server/netssl.c, tools/nut-scanner/nutscan- + ip.c, tools/nut-scanner/nutscan-serial.c, tools/nut- + scanner/scan_eaton_serial.c, tools/nut-scanner/scan_nut.c, + tools/nut-scanner/scan_snmp.c, tools/nut-scanner/scan_xml_http.c: + Cppcheck improvements (#405) Fix all Cppcheck errors, using + standard c89: * Uninitialized variables, * Memory leak, * Brackets + balancing, * Common realloc mistake, * Possible null pointer + dereference, * Array index out of bounds, * Not null-terminated + string + +2017-03-31 Nash Kaminski + + * docs/man/liebert-esp2.txt, docs/nut.dict, drivers/liebert-esp2.c: + liebert-esp2 changes: Correct battery V scaling, update docs, + implement split-phase unit support (#412) * Update liebert-esp2 + documentation, include note that port on GXT2 series does not fully + follow RS-232 specs. * Refactor output format of liebert-esp2 + driver to follow that of other drivers to fix the nut-cgi interface + as well as for overall consistency. Implement support for 2 phase + i.e. split phase input Liebert GXT2 series units. Correct battery + voltage scaling for GXT2 series units as well. * Update nut.dict + * Update nut.dict + +2017-03-30 Jim Klimov + + * .travis.yml: Problem: NUT tests in Travis CI often wait for + default-withdoc Solution in .travis.yml : since Travis cloud + starts the jobs as soon as it has resources, move the bulk of + quicker matrix jobs to start after the longest withdocs build. + Experimental note: we still need one job defined in the simple + matrix for default environment, but can keep others in a single + explicitly ordered list. Now the "Running for" time got cut from + 8-9 to 5.5-6 minutes. + +2017-03-29 Jim Klimov + + * docs/Makefile.am: docs/Makefile.am : update comment about + spellcheck-sortdict post-processing, to make it more relevant + * docs/man/upsd.conf.txt, docs/nut.dict: Fix some more typos and add + nut.dict exceptions + +2017-03-29 Arnaud Quette + + * docs/man/upsd.conf.txt: upsd.conf.txt: fix a typo from the previous + commit + * conf/upsd.conf.sample, docs/man/upsd.conf.txt: upsd.conf: + clarification on the LISTEN directive + +2017-03-22 Arnaud Quette + + * drivers/libusb1.c, drivers/nut_libusb.h, tools/nut- + scanner/scan_usb.c: Fix spacers + +2016-11-09 Charles Lepple + + * docs/nut-names.txt, drivers/libusb0.c, drivers/libusb1.c: Add + `driver.version.usb` variable Reference: + https://github.com/networkupstools/nut/issues/300 + +2016-09-25 Charles Lepple + + * drivers/libusb1.c: libusb1: use return code from libusb_open() Per + , the handle is only populated when the return code + is 0. This fixes a crash during device detection where more than + one HID UPS is available, and the driver needs to skip the first + one. + +2016-09-02 Arnaud Quette + + * drivers/bcmxcp_usb.c, drivers/blazer_usb.c, drivers/libusb1.c, + drivers/nutdrv_atcl_usb.c, drivers/nutdrv_qx.c, + drivers/richcomm_usb.c, drivers/riello_usb.c: libusb 1.0 port: fix + return code for interrupt ops libusb 1.0 returns on success, the + number of bytes actually transferred or otherwise an error code, + except for interrupt transfers, where the actual transfer size is + stored in a separate variable. The libusb 1.0 implementation in NUT + thus needed to be fixed to behave the same way than the libusb 0.1 + implementation Reference: + https://github.com/networkupstools/nut/issues/300 + +2016-08-31 Arnaud Quette + + * drivers/libusb1.c: libusb 1.0 port: remove the check on USB device + count With the port to libusb 1.0, a sanity check was done on the + available number of USB devices to try. This however caused a + behavior regression, since the only device that NUT may have access + to can be the only UPS connected. In this case, the driver may exit + upon trying to reconnect if the device is transiently not available + Reference: https://github.com/networkupstools/nut/issues/300 + * drivers/libusb1.c, drivers/richcomm_usb.c: libusb 1.0 port: + complete usb_set_altinterface code usb_set_altinterface allows to + force the USB code to call `libusb_set_interface_alt_setting (0, + 0)` (equivalent to `libusb_set_altinterface(0)` in libusb 0.1), as + was done in NUT 2.7.2 and earlier. However, the libusb 1.0 + implementation was still missing the related code Reference: + https://github.com/networkupstools/nut/issues/300 + * drivers/nutdrv_atcl_usb.c, drivers/richcomm_usb.c: libusb 1.0 port: + fix kernel driver detachment Following the recent modification for + the kernel driver detachment, and the related functions + availability depending on the platforms, nutdrv_atcl_usb and + richcomm_usb were using the wrong macro for + libusb_set_auto_detach_kernel_driver and were missing the libusb + 1.0 code for explicit kernel driver detachment Reference: + https://github.com/networkupstools/nut/issues/300 + +2016-08-17 Arnaud Quette + + * drivers/libusb1.c, m4/nut_check_libusb.m4: libusb 1.0 port: rework + the kernel driver detachment libusb 1.0 has introduced a new + function (libusb_set_auto_detach_kernel_driver), beside from the + explicit kernel driver detachment request + (libusb_detach_kernel_driver). However, the former is not available + on all systems. As an example, FreeBSD 10.1-10.3 does not have + this. The detachment and interface claiming has been reworked to + handle this case (reported by Charles Lepple) Reference: + https://github.com/networkupstools/nut/issues/300 + +2016-08-12 Arnaud Quette + + * drivers/libusb1.c: libusb 1.0: remove unused typesafe_control_msg() + workaround For libusb 0.1 implementation, we had to workaround a + libusb API goofs, by wrapping the base function usb_control_msg(), + and casting the variables to the right type. This is not needed for + libusb 1.0 implementation, but was wrongly left in the code + (reported by Charles Lepple) + +2016-08-11 Arnaud Quette + + * drivers/bcmxcp_usb.c: bcmxcp_usb: fix a warning on unused variable + * drivers/bcmxcp_usb.c, drivers/libusb1.c, drivers/nutdrv_atcl_usb.c, + drivers/richcomm_usb.c: libusb 1.0 port: simplify bus publication + bus publication was wrongly listing both the bus and the portname, + instead of the bus only. This may have caused some issue when + trying to match the port + * drivers/usbhid-ups.c: usbhid-ups/mge-shut: rework errno/errors + handling libusb 1.0 has its own set of return codes, and error + interface. Rework the common HID core (shared between usbhid-ups + and mge-shut) so that error handling can work with both, and using + either libusb 0.1 or 1.0 for usbhid-ups + * tools/nut-scanner/scan_usb.c: nut-scanner: missing symbols lookup + for libusb 1.0 A few symbols from libusb 1.0 were wrongly used + directly, instead of being looked up and loaded at init time + * drivers/bcmxcp_usb.c, drivers/libusb1.c, drivers/nutdrv_atcl_usb.c, + drivers/richcomm_usb.c: libusb 1.0 port: add missing libusb_exit() + calls + * tools/nut-scanner/nutscan-init.c, tools/nut-scanner/scan_usb.c, + tools/nut-usbinfo.pl: nut-scanner: initial port to libusb 1.0 The + port to libusb 1.0 is complete, at least from a build perspective. + This now needs to be tested with devices + * drivers/nutdrv_atcl_usb.c, drivers/richcomm_usb.c: Remove redundant + variable + * drivers/tripplite_usb.c: tripplite_usb: remove extraneous comment + char + * drivers/nut_libusb.h: permute typedef order of usb_dev_handle + * drivers/nutdrv_qx.c: nutdrv_qx: initial port to libusb 1.0 The + port to libusb 1.0 is complete, at least from a build perspective. + This now needs to be tested with devices + * drivers/richcomm_usb.c: richcomm_usb: missing function remap for + libusb 0.1 usb_strerror was not remapped for libusb 0.1 + implementation + * drivers/tripplite_usb.c: tripplite_usb: initial port to libusb 1.0 + The port to libusb 1.0 is complete, at least from a build + perspective. This now needs to be tested with devices + * drivers/riello_usb.c: riello_usb: initial port to libusb 1.0 The + port to libusb 1.0 is complete, at least from a build perspective. + This now needs to be tested with devices + +2016-08-10 Arnaud Quette + + * drivers/richcomm_usb.c: richcomm_usb: initial port to libusb 1.0 + The port to libusb 1.0 is complete, at least from a build + perspective. This now needs to be tested with devices + * drivers/nutdrv_atcl_usb.c: nutdrv_atcl_usb: add the missing detach + call libusb 1.0 provide its own routine for detaching kernel + driver + * drivers/Makefile.am, drivers/libhid.c, drivers/nut_libusb.h: + Forgotten occurences of libusb.h renaming NUT internal header + "libusb.h" was renamed, since it collides with the libusb 1.0 + header, which has the same name. A few occurences of reference and + documentation were however missing + * drivers/nutdrv_atcl_usb.c: nutdrv_atcl_usb: initial port to libusb + 1.0 The port to libusb 1.0 is complete, at least from a build + perspective. This now needs to be tested with devices + * drivers/blazer_usb.c: blazer_usb: initial port to libusb 1.0 The + port to libusb 1.0 is complete, at least from a build perspective. + This now needs to be tested with devices + * drivers/bcmxcp_usb.c: bcmxcp_usb: code cleanup + +2016-08-09 Arnaud Quette + + * drivers/bcmxcp_usb.c: bcmxcp_usb: initial port to libusb 1.0 The + port to libusb 1.0 is complete, at least from a build perspective. + This now needs to be tested with devices + * docs/configure.txt, drivers/Makefile.am, drivers/libhid.c, + drivers/libhid.h, drivers/{libusb.c => libusb0.c}, + drivers/libusb1.c, drivers/{libusb.h => nut_libusb.h}, drivers/usb- + common.h, drivers/usbhid-ups.c: ushid-ups: complete the port to + libusb 1.0 The port to libusb 1.0 is now complete for usbhid-ups. + Other USB drivers (bcmxcp_usb, blazer_usb, nutdrv_atcl_usb, + richcomm_usb, riello_usb, tripplite_usb, nutdrv_qx) have still to + be addressed + +2016-08-01 Arnaud Quette + + * configure.ac, m4/nut_check_libusb.m4: Initial port to libusb 1.0 + Starting with the configure checks, to detect if libusb 1.0 if + available, and otherwise fall back to the libusb 0.1 backend + +2017-03-22 Arnaud Quette + + * clients/upssched-cmd, conf/upssched.conf.sample.in: upssched: align + documentation and sample files Align documentation and sample + configuration and script, so that the whole is more coherent + +2017-03-21 Arnaud Quette + + * docs/scheduling.txt: upssched: some clarification on TIMER + +2017-03-20 Charles Lepple + + * docs/nut.dict: Re-sort nut.dict (#406) * Re-sort nut.dict * + nut.dict header line + +2017-03-13 Spiros Ioannou + + * configure.ac, data/driver.list.in, docs/man/Makefile.am, + docs/man/index.txt, docs/man/phoenixcontact_modbus.txt, + docs/nut.dict, drivers/Makefile.am, + drivers/phoenixcontact_modbus.c, m4/nut_check_libmodbus.m4: + phoenixcontact_modbus driver Closes: + https://github.com/networkupstools/nut/pull/404 + +2017-03-14 Spiros Ioannou + + * .travis.yml: added libmodbus-dev to travis configuration + +2017-03-15 Jim Klimov + + * docs/config-notes.txt: config-notes.txt : small clarifications in + the text + * docs/developers.txt: developers.txt : small clarifications in the + text and line-wrapping and backticks + * docs/config-notes.txt: config-notes.txt : small clarifications in + the text and line-wrapping + * docs/cables.txt: cables.txt : line-wrapping + * docs/asciidoc.txt: asciidoc.txt : line-wrapping + * docs/acknowledgements.txt: acknowledgements.txt : line-wrapping + * docs/support.txt: support.txt : small clarifications in the text + and line-wrapping + * docs/security.txt: security.txt : small clarifications in the text + and line-wrapping + * docs/outlets.txt: outlets.txt : line-wrapping + * docs/new-drivers.txt: new-drivers.txt : line-wrapping + * docs/net-protocol.txt: net-protocol.txt : line-wrapping + * docs/maintainer-guide.txt: maintainer-guide.txt : small + clarifications in the text and line-wrapping and backticks + * docs/macros.txt: macros.txt : line-wrapping + * docs/history.txt: history.txt : line-wrapping + * docs/features.txt: features.txt : small clarifications in the text + and line-wrapping and backticks + * docs/download.txt: download.txt : line-wrapping + * docs/developers.txt: developers.txt : small clarifications in the + text and line-wrapping and backticks + * docs/daisychain.txt: daisychain.txt : small clarifications in the + text and line-wrapping + * docs/configure.txt: configure.txt : small clarifications in the + text + * docs/config-notes.txt: config-notes.txt : small clarifications in + the text + * docs/acknowledgements.txt: acknowledgements.txt : small + clarifications in the text + * docs/FAQ.txt, docs/nutdrv_qx-subdrivers.txt: nutdrv_qx- + subdrivers.txt : small clarifications in the text + +2017-03-13 Jim Klimov + + * docs/nut.dict: nut.dict : add "distros" slangey + * docs/configure.txt, docs/contact-closure.txt, docs/daisychain.txt, + docs/developers.txt, docs/features.txt, docs/history.txt, docs/net- + protocol.txt, docs/new-drivers.txt, docs/nut-names.txt, docs/nut- + qa.txt, docs/nutdrv_qx-subdrivers.txt, docs/outlets.txt, docs/sock- + protocol.txt: docs/*.txt : cleanup long-dash (use double-minus) + * docs/acknowledgements.txt, docs/cables.txt, docs/configure.txt, + docs/contact-closure.txt, docs/design.txt, docs/developer- + guide.txt, docs/developers.txt, docs/documentation.txt, + docs/download.txt, docs/features.txt, docs/hid-subdrivers.txt, + docs/history.txt, docs/macros.txt, docs/maintainer-guide.txt, + docs/net-protocol.txt, docs/new-clients.txt, docs/new-drivers.txt, + docs/nut-names.txt, docs/nut-qa.txt, docs/outlets.txt, + docs/packager-guide.txt, docs/snmp-subdrivers.txt, docs/snmp.txt, + docs/sock-protocol.txt, docs/support.txt, docs/user-manual.txt: + docs/*.txt : cleanup trailing whitespace + +2017-03-13 Arnaud Quette + + * scripts/systemd/nutshutdown.in: Prefer @CONFPATH@ over @sysconfdir@ + Otherwise, the generated nutshutdown script can end up with a non + fully expanded path like "${prefix}/etc/nut.conf" when not + specifying --sysconfdir and using default flags + +2017-01-28 Laurent Bigonville + + * scripts/systemd/nutshutdown.in: Add support for POWEROFF_WAIT + parameter Use "systemctl reboot --force --force" to reboot the + machine has not been shutdown after the POWEROFF_WAIT delay. + Closes: #382 + +2017-03-04 Jim Klimov + + * drivers/snmp-ups.c: snmp-ups.c : presumed typo fix : NUT var for + bypass mapping is "input.bypass" (fix the caller too) + +2017-03-15 Jim Klimov + + * docs/nut.dict: nut.dict : know of "nowait" + +2017-01-28 Jim Klimov + + * docs/man/ups.conf.txt, docs/man/upsdrvctl.txt, drivers/upsdrvctl.c: + From: Arnaud Quette Date: Sat, 7 Jun 2014 + 02:27:15 +0200 Subject: [PATCH] Add 'nowait' option for upsdrvctl + in ups.conf The nowait flag allow to tell upsdrvctl to not wait at + all for the driver(s) to execute the request command. The default + behavior, when this variable is omitted, is to wait 'maxstartdelay' + seconds + +2017-03-13 Arnaud Quette + + * scripts/systemd/nutshutdown.in: Prefer @CONFPATH@ over @sysconfdir@ + Otherwise, the generated nutshutdown script can end up with a non + fully expanded path like "${prefix}/etc/nut.conf" when not + specifying --sysconfdir and using default flags + * docs/scheduling.txt: Disambiguate FHS - Filesystem Hierarchy + Standard + * docs/security.txt: Missing space + +2017-03-13 Jim Klimov + + * docs/FAQ.txt, docs/config-notes.txt, docs/scheduling.txt, + docs/security.txt: Some docs/ files revised to backtick pathnames, + clean up trailing whitespace, and use double-minuses for long-dash + in sentences + * docs/nut.dict: docs/nut.dict : add "FHS" + +2017-03-04 Arnaud Quette + + * docs/FAQ.txt, docs/config-notes.txt, docs/scheduling.txt, + docs/security.txt: Try to adapt paths in documentation + Documentation still widely uses the default paths source when + compiled from source. While it is feasible to adapt some at + compilation time, it is not desirable since, for example, the + online documentation on networkupstools.org has to be generic. So + try to make these paths more generic when possible, and otherwise + make a note + +2017-03-04 Jim Klimov + + * docs/hid-subdrivers.txt, docs/nut.dict: spellcheck: "futher" is a + mistaken exception in custom dictionary + * docs/nut.dict: nut.dict bumped to support nut-website documents + with words that Travis does not know + * drivers/snmp-ups.c: snmp-ups.c : presumed typo fix : NUT var for + bypass mapping is "input.bypass" (fix the caller too) + * docs/nut.dict: nut.dict bumped to support nut-website documents + with words that Travis does not know + * docs/nut.dict: nut.dict bumped to support nut-website documents + +2017-03-02 Arnaud Quette + + * tools/nut-ddl-dump.sh: nut-ddl-dump.sh: various improvements + Improve the script to generate NUT device dumps by adding: * a + header line that mentions the generation source (automatic) and + date * add upsrw dump as comments * add upscmd dump as comments + * drivers/eaton-ats16-mib.c: snmp-ups: ATS16 fixes for ambient sensor + values Values for the attached ambient sensor to an ATS16 were + erroneously multiplied by 10 + +2017-03-01 Jim Klimov + + * drivers/mge-xml.c: Update mge-xml.c Include drivers/main.h to get + testvar() declared properly + +2017-03-01 Jim Klimov + + * docs/man/upscli_init.txt: docs/man/upscli_init.txt : rephrase the + text to pass spellcheck (and human readability) and wrap some long + lines + * drivers/snmp-ups.c: snmp-ups.c : presumed typo fix : NUT var for + bypass mapping is "input.bypass" + * drivers/snmp-ups.c: snmp-ups.c : added comments about some + daisychain global vars + +2017-02-28 Jim Klimov + + * drivers/snmp-ups.c: drivers/snmp-ups.c : in snmp_ups_walk(), report + in log if aborting because of exit_flag + * drivers/snmp-ups.c: drivers/snmp-ups.c : in snmp_ups_walk(), update + some comments + * drivers/snmp-ups.c: drivers/snmp-ups.c : presumed typo fix in + comment about daisy (should be "1..N" not "2..N" in final code) + * drivers/snmp-ups.c: drivers/snmp-ups.c : comment in snmp_ups_walk() + about daisychains vs unitary devices + * drivers/snmp-ups.c: drivers/snmp-ups.c : comment in snmp_ups_walk() + about daisychains vs unitary devices + * drivers/snmp-ups.c: drivers/snmp-ups.c : fix trailing whitespace + * drivers/dstate.c, drivers/dstate.h, drivers/usbhid-ups.h: + drivers/dstate.c : in dstate_detect_phasecount() do not hardcode a + buf[] size but use a macro + * drivers/dstate.c: drivers/dstate.c : extend a comment about 2-phase + devices into dstate_detect_phasecount() + +2017-02-12 Jim Klimov + + * drivers/dstate.c: dstate.c : catch a few more zero value + representation and comment about others + +2017-02-10 Jim Klimov + + * drivers/dstate.c: dstate.c : refactor dstate_detect_phasecount() : + change the report about calculated values to use common format with + __func__ + * drivers/dstate.c: dstate.c : refactor dstate_detect_phasecount() : + change the no-longer-sexy overgrown one-liners with a readable + macro + * drivers/dstate.c: dstate.c : important typo fixed for + dstate_detect_phasecount() + * drivers/dstate.c: dstate.c : revise comment for + dstate_detect_phasecount() + * drivers/dstate.c: dstate.c : address code style (move var + declarations to top of scope) + * drivers/dstate.c: dstate.c : address some nit-picks + +2017-02-09 Jim Klimov + + * drivers/dstate.c, drivers/dstate.h, drivers/mge-xml.c: Refactor + dstate_detect_phasecount(), adding a read-only mode (so the caller + can query the guesswork logic without changing active dstates) + * drivers/dstate.c, drivers/dstate.h, drivers/mge-xml.c: Refactor the + dstate guesswork and setting for 1/3 phases, move it to common + dstate.c/.h and rename to dstate_detect_phasecount() + * drivers/mge-xml.c: Refactor recent logic into a common + set_phasecount() + * drivers/mge-xml.c: Drop an empty line + * drivers/mge-xml.c: mge-xml.c : calculate + (input|bypass|output).phases number (1 or 3) based on available + non-zero measurements - typo fix for "INPUT.bypass." + * drivers/mge-xml.c: mge-xml.c : calculate + (input|bypass|output).phases number (1 or 3) based on available + non-zero measurements - consider absence of Lx values for 1-phase + case + * drivers/mge-xml.c: mge-xml.c : calculate + (input|bypass|output).phases number (1 or 3) based on available + non-zero measurements - also consider current (amps) + * drivers/mge-xml.c: mge-xml.c : calculate + (input|bypass|output).phases number (1 or 3) based on available + non-zero measurements + +2017-02-28 Jim Klimov + + * docs/man/netxml-ups.txt, drivers/mge-xml.c, drivers/netxml-ups.c: + mge-xml / netxml-ups : reimplement do_convert_deci as a simple + VAR_FLAG setting + +2017-02-27 Jim Klimov + + * drivers/mge-xml.c: mge-xml.c : add debug logging of values which + were converted + * docs/man/netxml-ups.txt, docs/nut.dict, drivers/mge-xml.c, + drivers/netxml-ups.c: netxml-ups and mge-xml : allow users to + reenable legacy convert_deci() behavior at run-time, with a + configuration toggle (documented) + * drivers/mge-xml.c: mge-xml.c : updated comment about convert_deci() + pre-history + +2017-02-21 Jim Klimov + + * drivers/mge-xml.c: drivers/mge-xml.c : when reporting deprecation + of convert_deci(), do it once visibly with details like issue + tracker URL, and in regular debug messages refer to that line + +2017-02-20 Jim Klimov + + * drivers/mge-xml.c: drivers/mge-xml.c : in convert_deci() now report + it is deprecated (with debug level 5) so we get reports if + deprecation bites anyone in reality + * drivers/mge-xml.c: drivers/mge-xml.c : bump subdriver version + * drivers/mge-xml.c: drivers/mge-xml.c : bump copyrights + +2017-02-18 Jim Klimov + + * drivers/mge-xml.c: Disable convert_deci() that was needed a decade + ago Left the old code in place, commented away. If devices with + old NetXML pop up (those which served in XML 10x the measured + value), fixes can be applied based on voltage and amps and power + (order of magnitude comparison), or perhaps model names and/or + firmware versions or release dates, if we get those. + +2017-02-27 Jim Klimov + + * drivers/netxml-ups.c: netxml-ups.c : typo fix (shutdwon => + shutdown) + * docs/man/netxml-ups.txt: docs/man/netxml-ups.txt : trailing + whitespace fixes + +2017-02-28 Jim Klimov + + * data/Makefile.am: data/Makefile.am : did not link back to + "spellcheck-sortdict" + +2017-02-04 Steven Bell + + * docs/nut.dict: Removed line left over from merge conflict. Ooops! + +2017-01-28 Laurent Bigonville + + * scripts/systemd/nutshutdown.in: Add support for POWEROFF_WAIT + parameter Use "systemctl reboot --force --force" to reboot the + machine has not been shutdown after the POWEROFF_WAIT delay. + Closes: #382 + +2017-01-28 Jim Klimov + + * drivers/eaton-ats30-mib.c: drivers/eaton-ats30-mib.c : fix + whitespace + * drivers/snmp-ups.c: drivers/snmp-ups.c : fix trailing whitespaces + * docs/nut.dict: nut.dict : know of "nowait" + * docs/Makefile.am: docs/Makefile.am : after spellcheck-interactive, + advise how to review the dictionary changes and avoid regressions + * conf/upsd.conf.sample, conf/upsmon.conf.sample.in, + conf/upssched.conf.sample.in, docs/nut.dict: Spellchecked the conf/ + sample files + * Makefile.am, conf/Makefile.am: Spellcheck the conf/ directory + * conf/upsd.users.sample, conf/upsmon.conf.sample.in: + upsmon.conf.sample.in : clarify nuances of master/slave systems, + and special use-cases of SHUTDOWNCMD and powervalue==0 + * conf/hosts.conf.sample, conf/nut.conf.sample, conf/ups.conf.sample, + conf/upsd.conf.sample, conf/upsd.users.sample, + conf/upsmon.conf.sample.in, conf/upssched.conf.sample.in, + conf/upsset.conf.sample, conf/upsstats.html.sample: Sample + configuration files : fix leading and trailing whitespace (mix of + tab/space) + * conf/ups.conf.sample: ups.conf.sample : move maxretry example + higher in the file so it is before driver-block examples + * drivers/apc-pdu-mib.c: Date: Fri Aug 19 02:43:44 2016 +0200 apc- + pdu-mib.c fixes : * added trailing NULLs for proper structure size; + * fixed some items' flags; * fixed whitespace; * bumped MIBmap + version + * data/driver.list.in, drivers/Makefile.am, drivers/apc-pdu-mib.c, + drivers/apc-pdu-mib.h, drivers/snmp-ups.c: From: Arnaud Quette + Date: Fri, 8 Apr 2016 14:40:00 +0200 + Subject: [PATCH] snmp-ups: support APC PDU Based on initial work + and data from Opengear, using SNMP subdriver creation script, add + support for the more recent APC PDU. This was tested with a + AP8958, but should cover other models + * docs/man/ups.conf.txt, docs/man/upsdrvctl.txt, drivers/upsdrvctl.c: + From: Arnaud Quette Date: Sat, 7 Jun 2014 + 02:27:15 +0200 Subject: [PATCH] Add 'nowait' option for upsdrvctl + in ups.conf The nowait flag allow to tell upsdrvctl to not wait at + all for the driver(s) to execute the request command. The default + behavior, when this variable is omitted, is to wait 'maxstartdelay' + seconds + * conf/ups.conf.sample: Document and pre-set the "maxretry" option in + ups.conf.sample + +2017-01-27 Jim Klimov + + * drivers/eaton-ats16-mib.c, drivers/eaton-ats30-mib.c: Prefix + structures in eaton-atsXY-mib.c files with an eaton_atsXY rather + than just atsXY + * README: README: not asciidoc, and redistributed - do not link to + volatile build status + +2017-01-27 Arnaud Quette + + * drivers/snmp-ups.c: snmp-ups: Fix counter OID matching In case of + multiple similar sysOID (i.e. same sysOID in different subdrivers), + there is a counter matching OID (generally using the model OID). + However, the matching was causing a crash of snmp-ups in case where + it was not the right MIB mapping and the OID for model entry was + not available + +2017-01-27 Steven Bell + + * docs/man/upscli_connect.txt, docs/nut.dict: Fixed issues with + documentation for automated spellcheck during CI check. + +2017-01-27 Jim Klimov + + * docs/nut.dict: docs/nut.dict : sorted to facilitate further + maintenance + +2017-01-27 Arnaud Quette + + * Makefile.am, data/Makefile.am, data/cmdvartab: Integrate cmdvartab + to the spellcheck target This also includes 2 spelling fixes + +2017-01-27 Jim Klimov + + * NEWS, docs/nut.dict: Spellcheck : Fixed typo in Tore O*r*petveit's + name + * README: README : embed a Travis status image link for NUT Master + branch + * Makefile.am, docs/.gitignore, docs/Makefile.am, + docs/man/Makefile.am: Spellcheck : add a recipe to keep nut.dict + sorted so git diffs are clearer + * Makefile.am: Makefile.am : when calling spellcheck or spellcheck- + interactive for several subdirs, do not stop after the first failed + sub-make + +2017-01-27 Steven Bell + + * docs/man/upscli_add_host_cert.txt, docs/man/upscli_connect.txt, + docs/man/upscli_init.txt: Updated and corrected documentation. + +2017-01-27 Arnaud Quette + + * drivers/Makefile.am, drivers/eaton-ats16-mib.c, drivers/eaton- + ats16-mib.h, drivers/snmp-ups.c: snmp-ups: rename Eaton ATS16 + resources Rename the subdriver files along with the structure and + entries, to make a clear difference with the newly added + eaton_ats30. This completes the previous commit, where some files + was erroneously committed + * drivers/{eaton-ats-mib.c => eaton-ats16-mib.c}, drivers/{eaton-ats- + mib.h => eaton-ats16-mib.h}, drivers/eaton-ats30-mib.c: Fix + unterminated comment, from previous commit + * tools/nut-scanner/scan_snmp.c: nut-scanner: force numeric + resolution of OIDs As done in snmp-ups, force the numeric + resolution of OIDs, to ensure correct OID matching in all cases + * drivers/snmp-ups.c: Only free variable when needed in + su_setvar/su_setOID Previously, we tried to free temporary + pointers in all cases. However, this pointer may ever point at the + static structure, in case we do not need to instantiate variable + (outlet.* collection), and which causes a crash of the driver + * drivers/eaton-ats30-mib.c: Add a comment on the unused OIDs + * drivers/snmp-ups.c: Fix spacing + * drivers/eaton-ats30-mib.c, drivers/eaton-ats30-mib.h: Fix legal + information + +2017-01-26 Tomas Halman + + * drivers/Makefile.am, drivers/eaton-ats30-mib.c, drivers/eaton- + ats30-mib.h, drivers/snmp-ups.c: snmp-ups: support Eaton Automatic + Transfer Switch ATS30 ATS30 MIB differs from previously integrated + EATON ATS driver. + +2016-09-14 Jim Klimov + + * common/common.c: common.c : revised upsdebugx() and upslogx() calls + to not trail an extra newline + * common/common.c, configure.ac: Add support for system library + directories with names based on short target/build/host OS spec too + +2017-01-24 Jim Klimov + + * common/common.c, configure.ac: Add support for system library + directories with names based on target/build/host OS spec (for GCC + at least) + +2016-09-14 Jim Klimov + + * common/common.c: common.c : added logging and small optimizations + during get_libname() + * common/common.c: common.c : add /usr/local/lib64 to search path + +2017-01-19 Jim Klimov + + * tools/nut-scanner/nutscan-init.c: nutscan-init.c : We can also use + libusb-compat from newer libusb-1.0 releases (issue #361) + +2016-09-14 Jim Klimov + + * tools/nut-scanner/nutscan-init.c: nut-scanner : support libneon- + gnutls.so as an alternative name + +2016-07-12 Carlos Dominguez + + * common/common.c, include/common.h, tools/nut-scanner/nutscan- + init.c: Arnaud's patch applied, dynamic library bug fixed, tested! + +2016-07-04 Arnaud Quette + + * common/common.c, include/common.h, tools/nut-scanner/nutscan- + init.c: Move get_libname() to common This function, originally + created for nut-scanner, to be able to lookup for libraries loaded + using libtool loader, is now also useful for the DMF support. This + last loads libneon at runtime, to load DMF structure (including the + one for nut-scanner) and unload it once the file were read + +2017-01-23 Jim Klimov + + * drivers/mge-hid.c, drivers/nutdrv_qx.h, + drivers/nutdrv_qx_bestups.c: Fix the non-ASCII quote character away + from C sources + * docs/daisychain.txt, docs/man/al175.txt, docs/man/apcsmart.txt, + docs/man/apcupsd-ups.txt, docs/man/bcmxcp_usb.txt, + docs/man/bestups.txt, docs/man/blazer-common.txt, + docs/man/clone.txt, docs/man/libnutclient_commands.txt, + docs/man/libnutclient_misc.txt, docs/man/libnutclient_tcp.txt, + docs/man/libnutclient_variables.txt, docs/man/macosx-ups.txt, + docs/man/mge-shut.txt, docs/man/nut-scanner.txt, + docs/man/nutdrv_qx.txt, docs/man/nutscan_add_device_to_device.txt, + docs/man/nutscan_add_option_to_device.txt, + docs/man/nutscan_cidr_to_ip.txt, + docs/man/nutscan_get_serial_ports_list.txt, docs/man/nutupsdrv.txt, + docs/man/skel.txt, docs/man/snmp-ups.txt, docs/man/solis.txt, + docs/man/ups.conf.txt, docs/man/upscode2.txt, + docs/man/upsd.conf.txt, docs/man/upsd.txt, + docs/man/upsmon.conf.txt, docs/man/upsmon.txt, docs/man/upsrw.txt, + docs/man/upssched.conf.txt, docs/man/upsstats.html.txt, + docs/man/usbhid-ups.txt, docs/nut.dict: Update nut.dict and manpage + sources after initial spellchecking integration + * Makefile.am, ci_build.sh, docs/man/Makefile.am: + docs/man/Makefile.am : track all manpage sources in a separate + variable and use that for spellchecker + * docs/Makefile.am: docs/Makefile.am : add daisychain to ALL_TXT_SRC + * docs/Makefile.am: docs/Makefile.am : revised TODOs for spellchecker + +2017-01-20 Jim Klimov + + * .travis.yml: Enable valgrind in travis matrix + +2017-01-21 Jim Klimov + + * indent.sh: Initial commit of indent.sh helper + +2017-01-20 Jim Klimov + + * Makefile.am, tests/Makefile.am: VALGRIND: abuse distcheck to run + tested programs in debug mode under valgrind + * configure.ac: valgrind config fix + * ci_build.sh: Travis : make spellcheck failures fatal now + * docs/nut.dict: docs/nut.dict : add another word missed by earlier + private dict + * docs/nut.dict: docs/nut.dict : try to enable UTF8 contributor names + * docs/Makefile.am: docs/Makefile.am : try to enable UTF8 in args and + env + * .travis.yml, ci_build.sh: Travis : enable i2c tests + * .travis.yml: .travis.yml : rearrange apt deps and special case for + doc/spell tests in the matrix + * .travis.yml, ci_build.sh: Travis: port the test-script structure + from DMF brach (better case than if) + +2017-01-19 Jim Klimov + + * docs/nut.dict: docs/nut.dict : add some words not in dictionaries + available to Travis CI; add some developer names to the dictionary + * NEWS, TODO, UPGRADING, common/parseconf.c, docs/FAQ.txt, + docs/acknowledgements.txt, docs/cables/sms.txt, docs/config- + notes.txt, docs/download.txt, docs/hid-subdrivers.txt, docs/new- + drivers.txt, docs/nut-qa.txt, docs/nut.dict, docs/nutdrv_qx- + subdrivers.txt, docs/packager-guide.txt, docs/snmp-subdrivers.txt, + lib/README, scripts/augeas/README: Spellchecker : Fix or rephrase + issues found by spellchecker, and update the NUT custom dictionary + * docs/developers.txt: docs/developers.txt : fix non-ASCII tick + character + * docs/acknowledgements.txt, docs/packager-guide.txt: Added myself to + docs/acknowledgements.txt docs/packager-guide.txt + * docs/nut-qa.txt: docs/nut-qa.txt : rearranged the paragraph with CI + (to fit in 80 cols) and added link to Travis CI dashboard for NUT + branches + * docs/packager-guide.txt: docs/packager-guide.txt : rearranged the + paragraph with recommended package description (to fit in 80 cols) + * docs/developers.txt: docs/developers.txt : mention the recently + added Travis CI integration + * docs/developers.txt: docs/developers.txt : reformat the paragraph + on distcheck-light, and mention the recently added option to skip + building docs + * Makefile.am: Makefile.am : allow to call from workspace root the + docs/Makefile for targets: spellcheck spellcheck-interactive doc + +2017-01-19 Jim Klimov + + * docs/Makefile.am: docs/Makefile.am : parametrize aspell common + args; add togglable debugging of aspell setup + +2017-01-19 Jim Klimov + + * ci_build.sh, docs/Makefile.am: docs/Makefile.am + Travis : support + a SPELLCHECK_ERROR_FATAL toggle, and use it from Travis for now * + docs/Makefile.am : also report if the build succeeds despite + spellcheck errors (due to this setting) + * docs/Makefile.am: docs/Makefile.am : name the en lang explicitly + * docs/Makefile.am: docs/Makefile.am : big reorganization of + spellcheck * spellcheck targets should fail the build not only if + the last document failed the test * make sure to use custom + spellcheck dictionary from NUT source tree; revise erroring out if + automatic aspell finds issues * also set LC_ALL=C for aspell * + revised spellcheck failure message to suggest next steps for the + human * comment the spellcheck test; use more portable shell test + (instead of bracket); do not fail on empty aspell outputs + +2016-09-07 Jim Klimov + + * configure.ac: configure.ac : add potential usage of valgrind, + optional and configurable/detectable + +2017-01-19 Jim Klimov + + * .travis.yml, ci_build.sh: Travis CI should call spellcheck as a + separate spellchecking job (parallelize, optimize for speed, + separate error causes/reports) + * .travis.yml: .travis.yml : add libcppunit to travis env, so tests + in NUT will be enabled + +2017-01-11 Jim Klimov + + * .travis.yml: .travis.yml : drop comment for PR #354 + +2016-11-21 Jim Klimov + + * common/snprintf.c: common/snprintf.c : avoid a few compilation + warnings and a possible crash due to padded ints in variadic + functions + * common/snprintf.c, configure.ac: common/snprintf.c and configure.ac + : avoid a few compilation warnings + +2017-01-06 Daniele Pezzini + + * common/state.c: state: consider also ST_FLAG_NUMBER flags + * drivers/dstate.c: dstate: report ST_FLAG_NUMBERs also in response + to a DUMPALL request + * drivers/dstate.c: dstate: when dealing with ranges, don't lose + already-set flags Ranges are now explicitly flagged as numbers, + but the use of dstate_setflags() means that we substitute any + previously-set flag with the ones we pass to that function, losing, + for example, an already-set r/w status, with the result of making + an affected var unchangeable. Use instead the newly added + dstate_addflags() function, which preserves already-set flags. + * drivers/dstate.c, drivers/dstate.h: dstate: add a couple of + functions to ease the manipulation of flags + +2017-01-10 Arnaud Quette + + * drivers/snmp-ups.c: snmp-ups: fix device.type setting in daisychain + mode device.type was not set due to a coding error, but pushed to + device.model (reported by Evgeny "Jim" Klimov from Eaton) + * drivers/main.c: drivers: set the default device.type even earlier + device.type default setting to "ups" has to be done prior to the + initups() call, otherwise some devices (such as daisychained PDUs) + will not be able to override it + +2017-01-04 Jim Klimov + + * ci_build.sh: ci_build.sh : list contents of installation directory + * ci_build.sh: ci_build.sh : fix installation directories for /etc + and udev, devd and hotplug (not hardcoded root paths) + * ci_build.sh: ci_build.sh : list contents of installation directory + * ci_build.sh: ci_build.sh : fix installation directories for /etc + and udev, devd and hotplug (not hardcoded root paths) + * .travis.yml, ci_build.sh: Travis : take advantage of "--with- + doc=skip" support recently added in configure and Makefiles + +2016-09-13 Jim Klimov + + * configure.ac, docs/man/Makefile.am: configure.ac, + docs/man/Makefile.am - support SKIP_MANS as an explicit non-fatal + situation + +2017-01-04 Jim Klimov + + * ci_build.sh: ci_build.sh : comment about missing i2c + * ci_build.sh: ci_build.sh : generalize the skipping of distcheck and + make it more comprehensible in script code + * .travis.yml: .travis.yml : include the headers needed for i2c + * .travis.yml: .travis.yml : use specific libgd + * .travis.yml: .travis.yml : add graphics pkgs for CGI builds + * ci_build.sh: .travis.yml / ci_build.sh : speed up with parallel + build (fall back to sequential if this fails) + * .travis.yml, ci_build.sh: .travis.yml / ci_build.sh : current NUT + does not skip docs safely, so enable just manpages in default build + * .travis.yml: .travis.yml : add libipmimonitoring packages too + * .travis.yml: .travis.yml : older freeipmi in Travis Ubuntu 12.04.5 + * ci_build.sh: ci_build.sh : fix the doc-skipping option + * .travis.yml: .travis.yml : apparently, libfreeipmi16 pkg requires + extra invitation + * .travis.yml, ci_build.sh: Travis : require docs tools only for + "default-withdoc" builds; change "default" to skip the docs (and + try to pass distcheck) + * .travis.yml: .travis.yml : only define default-alldrv once + * .travis.yml, ci_build.sh: Initial integration of a travis matrix + build (different scenarios) + * .gitignore, .travis.yml, ci_build.sh, docs/Makefile.am: Initial + commits of config and script files for Travis CI automatic + validation (simply do a compile and distcheck) + +2017-01-04 Arnaud Quette + + * m4/nut_check_asciidoc.m4: Minor typo fixes + +2017-01-04 Jim Klimov + + * configure.ac: configure.ac : switch default option to "--with- + doc=man=auto" so ordinary builds succeed by default on any system + * configure.ac: configure.ac alias + * configure.ac: configure.ac : add the "--with-docs" as alias to "-- + with-doc" + * configure.ac, m4/ax_compare_version.m4, m4/nut_check_asciidoc.m4: + Refactor nut_check_asciidoc.m4 and configure.ac to check all doc- + tools in one place (and also only once), and fix comments and some + coding issues + +2016-12-29 Charles Lepple + + * docs/new-drivers.txt: docs: reword/reformat new-drivers.txt + Distinguish HID PDC from Q*, etc. + +2016-11-29 Florian Bruhin + + * tools/gitlog2changelog.py: Fix gitlog2changelog.py on python 3 + * scripts/augeas/gen-nutupsconf-aug.py: Make gen-nutupsconf-aug.py + work with Python 3 This makes the script work with Python 2.6+. + Fixes #345. + +2016-11-28 Daniele Pezzini + + * configure.ac: configure: fix checks for a2x-built docs Since, + starting from commit d4a55ed, we now check that documents are + buildable in an 'external' directory, we need to call a2x with '-- + destination-dir' pointing to that directory, otherwise a2x will put + the generated documents in the same directory where source files + are and then testing the non-existent files under our 'external' + directory will always fail, meaning that we will never pass these + checks. + +2016-11-21 Jim Klimov + + * docs/Makefile.am: EXTRA_DIST the docs/asciidoc.txt as used in + configure script checks + * configure.ac: configure.ac : avoid nonportable "mktemp --tmpdir" + option + +2016-11-17 Michal Soltys + + * autogen.sh: autogen.sh: minor script fixup In case any of the perl + / python parts fails (for example if system default is python3, the + script will complain about print), cd ../.. won't be executed. + Furthermore - if any of those scripts fail, there's no point in + continuing as both files are mandatory. + * docs/man/apcsmart.txt, drivers/apcsmart.c, drivers/apcsmart.h: + apcsmart: CS "hack" updates This patch adds cshdelay option (with + default set to 3.5s) between "simulate power failure" and "soft + hibernate" commands. + +2016-11-16 Arnaud Quette + + * drivers/mge-hid.c: sbhid-ups: fix Eaton/MGE mapping for beeper + handling Two HID Paths exists for handling beeper status and + commands. However, only one historic was implement, which was not + actually suitable for issuing the commands on newer units (such as + 3S, 5P*, ...) (reported by Sergey Talchuk) Closes: + https://github.com/networkupstools/nut/issues/9 + * drivers/usbhid-ups.c: usbhid-ups: adjust debuging info + +2016-11-09 Charles Lepple + + * docs/nut-names.txt, drivers/libusb0.c, drivers/libusb1.c: Add + `driver.version.usb` variable Reference: + https://github.com/networkupstools/nut/issues/300 + +2016-11-03 Charles Lepple + + * data/driver.list.in: HCL: CP1500EPFCLCD Source: + https://github.com/networkupstools/nut/issues/337 + +2016-11-02 Charles Lepple + + * data/driver.list.in: HCL: Eaton 5E2200VA Reference: + https://github.com/networkupstools/nut/issues/335 + * data/driver.list.in: HCL: Eaton Ellipse PRO 650 VA (USB) supported + by usbhid-ups Closes: + https://github.com/networkupstools/nut/issues/255 + +2016-10-21 Charles Lepple + + * docs/download.txt: download.txt: Add Slackware link + +2016-10-12 Kirill Ovchinnikov + + * drivers/apc-mib.c, drivers/snmp-ups.c: apc-mib.c modified for + ups.delay.{start,shutdown} to include SU_TYPE_TIME + +2016-10-11 Yann E. MORIN + + * clients/upsclient.c: client/ups: add missing include struct + timeval is declared in sys/time.h, so we need to #include it. + +2016-10-11 Arnaud Quette + + * tools/nut-scanner/nut-scan.h, tools/nut-scanner/nut-scanner.c: + Remove unimplement nut-scanner option The -F --fingerprints-file + option, used to provide an additional list of SNMP fingerprints, + was never implemented, but made its way into the code. Remove it, + at least while waiting for an actual implementation + * docs/man/nut-scanner.txt: Update nut-scanner manual page + * tools/nut-scanner/nutscan-device.c, tools/nut- + scanner/scan_xml_http.c: Fix c++ style comments + +2016-04-03 Alica + + * conf/upsstats.html.sample: upsstats.html: Conform to HTML 4.01 + Strict Closes: https://github.com/networkupstools/nut/pull/278 + * conf/upsstats-single.html.sample: upsstats-single.html: Conform to + HTML 4.01 Strict + +2016-10-05 Arnaud Quette + + * common/common.c: Fix c++ style comments + * drivers/snmp-ups.c: Fix exit code for --list + +2016-09-28 Jim Klimov + + * tools/nut-scanner/nut-scan.h, tools/nut-scanner/nut-scanner.c, + tools/nut-scanner/scan_xml_http.c: nut-scanner : implement single- + IP and IP-range UDP NetXML device discovery + * tools/nut-scanner/scan_snmp.c: scan_xml_http.c : fix leading + whitespaces (SPACE vs TABs mixed in code) + * tools/nut-scanner/scan_snmp.c: scan_xml_http.c : replace some + fprintf with upsdebugx + * tools/nut-scanner/nut-scanner.c: nut-scanner.c : increased debug- + tracing messages of nut-scanner progress + * tools/nut-scanner/nut-scanner.c: nut-scanner.c : replaced printq() + with standard upsdebugx(), added "-D" option to increase debug + verbosity as common in NUT, moved the help text printout to its own + function + +2016-09-27 Jim Klimov + + * common/common.c, include/common.h: common.c/.h : simplify the + upsdebugx() enhancement (no need to fight with warnings/pragmas) + +2016-09-26 Arnaud Quette + + * scripts/systemd/nut-server.service.in: systemd: add reload support + for nut-server / upsd Add ExecReload entry to execute a + configuration reload of upsd, using the available 'upsd -c reload' + +2016-09-25 Charles Lepple + + * drivers/libusb1.c: libusb1: use return code from libusb_open() Per + , the handle is only populated when the return code + is 0. This fixes a crash during device detection where more than + one HID UPS is available, and the driver needs to skip the first + one. + +2016-09-21 Jim Klimov + + * include/common.h: common.h : rearranged the + ENABLE_WARNING/DISABLE_WARNING macro definitions so they are only + called for supported compilers and generate empty macros (no-op) + for others + +2016-09-20 Jim Klimov + + * common/common.c: common.c : move anti-warning macros out of the + function body, some compilers do not like that + +2016-09-19 Jim Klimov + + * tools/nut-scanner/scan_xml_http.c: scan_xml_http.c : do not suggest + NetXML support for ePDUs (almost exclusively they are XMLv4 and do + not work with current NUT) + +2016-09-18 Jim Klimov + + * common/common.c: common.c : in upsdebugx() added "[Dx]" prefix : do + not add it for level 0 + +2016-09-17 Jim Klimov + + * common/common.c, include/common.h: common.c : augment upsdebugx() + and upsdebug_with_errno() by prepending the debug-level to logged + messages + * common/common.c: common.c : fix whitespaces + +2016-09-17 Jim Klimov + + * configure.ac: configure.ac : do not fail configuration if a doctype + picked with "auto" can not be built on this system - just skip it + +2016-09-15 Jim Klimov + + * drivers/snmp-ups.c: Added and documented an snmp-ups argument to + list currently loaded MIB-to-NUT mappings (typo fix) + * docs/man/snmp-ups.txt, drivers/snmp-ups.c: Added and documented an + snmp-ups argument to list currently loaded MIB-to-NUT mappings + * drivers/snmp-ups.c: snmp-ups.c : small typo fix + * docs/man/snmp-ups.txt, drivers/ietf-mib.c: Mention tripplite + mapping in snmp-ups manpage; updated some comments about it in + ietf-mib.c + * configure.ac: configure.ac : when verifying ability to build docs, + consider out-of-tree builds too + +2016-09-14 Jim Klimov + + * configure.ac: configure.ac : verify that we can actually build a + simple or chunked HTML document, beside having nominal versions of + software + * configure.ac: configure.ac : verify that we can actually build a + manpage document, beside having nominal versions of software + * configure.ac: configure.ac : verify that we can actually build a + simple PDF document, beside having nominal versions of software + +2016-09-13 Jim Klimov + + * drivers/ietf-mib.c: Give the Tripplite SNMP MIB a name, do not + duplicate "ietf" entries + +2016-09-02 Arnaud Quette + + * drivers/bcmxcp_usb.c, drivers/blazer_usb.c, drivers/libusb1.c, + drivers/nutdrv_atcl_usb.c, drivers/nutdrv_qx.c, + drivers/richcomm_usb.c, drivers/riello_usb.c: libusb 1.0 port: fix + return code for interrupt ops libusb 1.0 returns on success, the + number of bytes actually transferred or otherwise an error code, + except for interrupt transfers, where the actual transfer size is + stored in a separate variable. The libusb 1.0 implementation in NUT + thus needed to be fixed to behave the same way than the libusb 0.1 + implementation Reference: + https://github.com/networkupstools/nut/issues/300 + +2016-08-31 Arnaud Quette + + * drivers/libusb1.c: libusb 1.0 port: remove the check on USB device + count With the port to libusb 1.0, a sanity check was done on the + available number of USB devices to try. This however caused a + behavior regression, since the only device that NUT may have access + to can be the only UPS connected. In this case, the driver may exit + upon trying to reconnect if the device is transiently not available + Reference: https://github.com/networkupstools/nut/issues/300 + * drivers/libusb1.c, drivers/richcomm_usb.c: libusb 1.0 port: + complete usb_set_altinterface code usb_set_altinterface allows to + force the USB code to call `libusb_set_interface_alt_setting (0, + 0)` (equivalent to `libusb_set_altinterface(0)` in libusb 0.1), as + was done in NUT 2.7.2 and earlier. However, the libusb 1.0 + implementation was still missing the related code Reference: + https://github.com/networkupstools/nut/issues/300 + * drivers/nutdrv_atcl_usb.c, drivers/richcomm_usb.c: libusb 1.0 port: + fix kernel driver detachment Following the recent modification for + the kernel driver detachment, and the related functions + availability depending on the platforms, nutdrv_atcl_usb and + richcomm_usb were using the wrong macro for + libusb_set_auto_detach_kernel_driver and were missing the libusb + 1.0 code for explicit kernel driver detachment Reference: + https://github.com/networkupstools/nut/issues/300 + +2016-08-17 Arnaud Quette + + * drivers/libusb1.c, m4/nut_check_libusb.m4: libusb 1.0 port: rework + the kernel driver detachment libusb 1.0 has introduced a new + function (libusb_set_auto_detach_kernel_driver), beside from the + explicit kernel driver detachment request + (libusb_detach_kernel_driver). However, the former is not available + on all systems. As an example, FreeBSD 10.1-10.3 does not have + this. The detachment and interface claiming has been reworked to + handle this case (reported by Charles Lepple) Reference: + https://github.com/networkupstools/nut/issues/300 + +2016-08-16 Arnaud Quette + + * clients/upsrw.c: upsrw: display the variable type beside ENUM / + RANGE upsrw now displays more information, beside the ENUM and + RANGE, such as the variable type (NUMBER or STRING), and the + maximum length for STRING Closes: + https://github.com/networkupstools/nut/issues/267 + * include/extstate.h: Add an explicit type NONE (ST_FLAG_NONE) + Reference: https://github.com/networkupstools/nut/issues/267 + * server/netget.c: Modify server side publication for variable type + ENUM can be either NUMBER or STRING, which was previously not + published. Reference: + https://github.com/networkupstools/nut/issues/267 + * drivers/dstate.c: Automatically set the "NUMBER" flag for ranges + Ranges, added through dstate_addrange(), only support numeric + ranges. So automatically add the ST_FLAG_NUMBER flag to range + Reference: https://github.com/networkupstools/nut/issues/267 + * drivers/dstate.c: Support ST_FLAG_NUMBER in dstate_setflags() + Allow the drivers to explicitly use ST_FLAG_NUMBER through + dstate_setflags() Reference: + https://github.com/networkupstools/nut/issues/267 + * include/extstate.h: Add an explicit type NUMBER (ST_FLAG_NUMBER) + Beside from the existing ST_FLAG_STRING, a need has arise to have + an explicit type NUMBER, and thus a flag for this type, can be used + generally, and more specifically with the driver primitive + dstate_setflags() Reference: + https://github.com/networkupstools/nut/issues/267 + +2016-08-12 Arnaud Quette + + * drivers/libusb1.c: libusb 1.0: remove unused typesafe_control_msg() + workaround For libusb 0.1 implementation, we had to workaround a + libusb API goofs, by wrapping the base function usb_control_msg(), + and casting the variables to the right type. This is not needed for + libusb 1.0 implementation, but was wrongly left in the code + (reported by Charles Lepple) + * clients/upsrw.c: upsrw: display current values of NUMBER variables + References: https://github.com/networkupstools/nut/issues/267 + * drivers/snmp-ups.c: snmp-ups: discard decimals when set to "0" + Publish values as integer when decimals are set to "0". This at + least makes sense for some values that are real integers (phases + and outlets counts for example), but also with many other values + that have not sufficient precision to provide decimals + +2016-08-11 Arnaud Quette + + * drivers/bcmxcp_usb.c: bcmxcp_usb: fix a warning on unused variable + * drivers/bcmxcp_usb.c, drivers/libusb1.c, drivers/nutdrv_atcl_usb.c, + drivers/richcomm_usb.c: libusb 1.0 port: simplify bus publication + bus publication was wrongly listing both the bus and the portname, + instead of the bus only. This may have caused some issue when + trying to match the port + * drivers/usbhid-ups.c: usbhid-ups/mge-shut: forgotten version bump + * drivers/usbhid-ups.c: usbhid-ups/mge-shut: rework errno/errors + handling libusb 1.0 has its own set of return codes, and error + interface. Rework the common HID core (shared between usbhid-ups + and mge-shut) so that error handling can work with both, and using + either libusb 0.1 or 1.0 for usbhid-ups + * tools/nut-scanner/scan_usb.c: nut-scanner: missing symbols lookup + for libusb 1.0 A few symbols from libusb 1.0 were wrongly used + directly, instead of being looked up and loaded at init time + * drivers/bcmxcp_usb.c, drivers/libusb1.c, drivers/nutdrv_atcl_usb.c, + drivers/richcomm_usb.c: libusb 1.0 port: add missing libusb_exit() + calls + * tools/nut-scanner/nutscan-init.c, tools/nut-scanner/scan_usb.c, + tools/nut-usbinfo.pl: nut-scanner: initial port to libusb 1.0 The + port to libusb 1.0 is complete, at least from a build perspective. + This now needs to be tested with devices + * drivers/nutdrv_atcl_usb.c, drivers/richcomm_usb.c: Remove redundant + variable + * drivers/tripplite_usb.c: tripplite_usb: remove extraneous comment + char + * drivers/nut_libusb.h: permute typedef order of usb_dev_handle + * drivers/nutdrv_qx.c: nutdrv_qx: initial port to libusb 1.0 The + port to libusb 1.0 is complete, at least from a build perspective. + This now needs to be tested with devices + * drivers/richcomm_usb.c: richcomm_usb: missing function remap for + libusb 0.1 usb_strerror was not remapped for libusb 0.1 + implementation + * drivers/tripplite_usb.c: tripplite_usb: initial port to libusb 1.0 + The port to libusb 1.0 is complete, at least from a build + perspective. This now needs to be tested with devices + * drivers/riello_usb.c: riello_usb: initial port to libusb 1.0 The + port to libusb 1.0 is complete, at least from a build perspective. + This now needs to be tested with devices + +2016-08-10 Arnaud Quette + + * drivers/richcomm_usb.c: richcomm_usb: initial port to libusb 1.0 + The port to libusb 1.0 is complete, at least from a build + perspective. This now needs to be tested with devices + * drivers/nutdrv_atcl_usb.c: nutdrv_atcl_usb: add the missing detach + call libusb 1.0 provide its own routine for detaching kernel + driver + * drivers/Makefile.am, drivers/libhid.c, drivers/nut_libusb.h: + Forgotten occurences of libusb.h renaming NUT internal header + "libusb.h" was renamed, since it collides with the libusb 1.0 + header, which has the same name. A few occurences of reference and + documentation were however missing + * drivers/nutdrv_atcl_usb.c: nutdrv_atcl_usb: initial port to libusb + 1.0 The port to libusb 1.0 is complete, at least from a build + perspective. This now needs to be tested with devices + * drivers/blazer_usb.c: blazer_usb: initial port to libusb 1.0 The + port to libusb 1.0 is complete, at least from a build perspective. + This now needs to be tested with devices + * drivers/bcmxcp_usb.c: bcmxcp_usb: code cleanup + +2016-08-09 Arnaud Quette + + * drivers/bcmxcp_usb.c: bcmxcp_usb: initial port to libusb 1.0 The + port to libusb 1.0 is complete, at least from a build perspective. + This now needs to be tested with devices + * docs/configure.txt, drivers/Makefile.am, drivers/libhid.c, + drivers/libhid.h, drivers/{libusb.c => libusb0.c}, + drivers/libusb1.c, drivers/{libusb.h => nut_libusb.h}, drivers/usb- + common.h, drivers/usbhid-ups.c: ushid-ups: complete the port to + libusb 1.0 The port to libusb 1.0 is now complete for usbhid-ups. + Other USB drivers (bcmxcp_usb, blazer_usb, nutdrv_atcl_usb, + richcomm_usb, riello_usb, tripplite_usb, nutdrv_qx) have still to + be addressed + +2016-08-06 Jim Klimov + + * docs/man/dummy-ups.txt: dummy-ups.txt : noted the sleep between + loops + * docs/man/dummy-ups.txt: dummy-ups.txt : text and formatting revised + to be clearer to the uninitiated + +2016-08-04 Arnaud Quette + + * docs/man/snmp-ups.txt: snmp-ups: document the use of non-standard + port SNMP agent may publish data over a non-standard port, i.e. + not 161. This feature is supported since the origin, but was not + explicitly documented nor usable + +2016-08-01 Arnaud Quette + + * configure.ac, m4/nut_check_libusb.m4: Initial port to libusb 1.0 + Starting with the configure checks, to detect if libusb 1.0 if + available, and otherwise fall back to the libusb 0.1 backend + +2016-07-11 Arnaud Quette + + * drivers/snmp-ups.c: snmp-ups: fix device.type publication In + daisychain mode at least, device.type was not set to its actual + value, using the current mapping structure, but defaulting to "ups" + (reported by Tomas Halman, from Eaton) + * drivers/snmp-ups.c: snmp-ups: fix and improve match_sysoid The + function was returning FALSE instead of NULL in one case. Also + retry at most 3 times to get the sysOID + +2016-07-07 Arnaud Quette + + * drivers/snmp-ups.c: snmp-ups: fix instant commands publication + With non-daisychain setup, there was a bug that created an infinite + test loop when trying to add instant commands + +2016-06-30 Tomas Halman + + * clients/nutclient.cpp: nutclient: fix library segmentation fault if + device name doesn't exists. If device doesn't exist, getClient() + returns NULL. Then calling the method like + getClient()->getDeviceDescription(getName()) causes segfault. We + rather check the status and throw an exception in this case. + +2016-06-25 Charles Lepple + + * docs/acknowledgements.txt: doc: fix acknowledgements link to GitHub + +2016-06-23 Timothy Pearson + + * drivers/libhid.c, drivers/tripplite-hid.c, drivers/usbhid-ups.c, + scripts/upower/95-upower-hid.rules: Add support for SU3000LCD2UHV + Note that protocol 1330 does not respond to requests for + UPS.OutletSystem.Outlet.DelayBeforeReboot, therefore those requests + needed to be bypassed in the driver. + +2016-06-23 Arnaud Quette + + * drivers/mge-xml.c: netxml-ups: detect the unsupported XML v4 + protocol The XML/PDC protocol had an update with version 4, for + ePDU. However, this version is not supported by netxml-ups. We now + detect this version, and explicitly exit with an "XML v4 protocol + is not supported!" message + * drivers/netxml-ups.c: netxml-ups: fix a segmentation fault + netxml_get_page() was not checking if page is NULL, hence resulting + in a segmentation fault with Eaton ePDU, which use the unsupported + version 4 of the XML/PDC protocol. Bump the driver version to 0.41 + +2016-06-13 Tomas Halman + + * clients/nutclient.cpp: NUT client library: internal::Socket class + must close socket in destructor. + +2016-04-16 Charles Lepple + + * data/driver.list.in, drivers/mge-hid.c, scripts/upower/95-upower- + hid.rules: usbhid-ups: add IBM USB VID Reference: + http://article.gmane.org/gmane.comp.monitoring.nut.user/7721 and + http://news.gmane.org/find- + root.php?message_id=5712AB29.6040001%40delphinidae.org.uk + +2016-06-09 Arnaud Quette + + * drivers/snmp-ups.c: snmp-ups: 2nd pass on fixing memory leaks Fix + some remaining memory leaks reported by Coverity scan + * drivers/snmp-ups.c: snmp-ups: fix memory leaks and incorrect + expression Following the registration of NUT in Coverity scan, a + number of issues were identified. This is the very first set of QA + fixes related to this static code analysis + +2016-06-08 Arnaud Quette + + * Makefile.am: AIX package: reference the exact tarball version + +2016-06-07 Charles Lepple + + * docs/download.txt: Update VMware ESXi package link (from René + Garcia) + +2016-06-07 Arnaud Quette + + * drivers/snmp-ups.c: snmp-ups: fix some regression due to daisychain + A few issues were remaining, following the daisychain support + addition. Issues were related to, at least, 3ph initialization and + data not being published, and identified with Eaton 3ph units, + using the "pw" MIB (reported by Yves Clauzel, from Eaton) + +2016-06-05 Timothy Pearson + + * drivers/powerp-txt.c: Add deep battery test for CyberPower + OL3000RMXL2U + +2016-05-31 Arnaud Quette + + * drivers/snmp-ups.c, drivers/snmp-ups.h: snmp-ups: support + daisychain commands and settings Daisychain commands and settings + on subdevices are now supported. Since 95% of the code of these two + functions was similar, a new function called su_setOID() was + created, and is now called by su_setvar and su_instcmd. This new + function is also daisychain-aware + * drivers/dstate.c: dstate: adapt daisychain devices functions For + daisychain devices, we increase the counter when alarms are present + on a subdevice, but don't decrease the count when the buffer is + empty. Otherwise, we may not get the ALARM flag in ups.status, + while there are some alarms present on device.X + * drivers/eaton-mib.c: snmp-ups: fix input.L2.voltage on Eaton G2/G3 + PDU This data entry was missing the daisychain formatting + directive, which resulted in this data not being published + (reported by Vyskocil Michal from Eaton) + +2016-05-27 Arnaud Quette + + * drivers/snmp-ups.c: snmp-ups: fix regression related to daisychain + Fix a few regression with unitary devices, related to the + daisychain changes of the SNMP core engine + * drivers/dstate.c: dstate: enforce underflow to not generate false + alarm The newly introduced daisychain mechanism, with alarm + counters (not just boolean) introduced a potential underflow on + alarm_commit, which resulted in false positive "ALARM" flag + publication in ups.status + * drivers/snmp-ups.c: snmp-ups: update for daisychain Update the + daisychain implementation, as per the latest specification, + including considerations on "device.0". Alarms are also handled for + the daisychain devices. Initial code for settings and commands is + also present, but will be completed in subsequent commits, along + with a final cleanup and potential composite settings and commands + on "device.0" (that are then applied to all daisychain devices) + * drivers/eaton-mib.c: snmp-ups: fix some daisychain data for Eaton + PDU Some data (outlet.%i.current, outlet.%i.power, + outlet.%i.load.{off,on,cycle} and + outlet.group.%i.load.{off,on,cycle}) were missing the daisychain + formatting string, and were hence not published + * docs/daisychain.txt, drivers/dstate.c, drivers/dstate.h: dstate: + add functions to address daisychain alarms Add 2 new functions, + device_alarm_init() and device_alarm_commit(), to address + daisychain devices: these acts as the standard alarm_{init,commit}, + but only clearing / committing the alarm buffer, and not + reinitializing the main alarm counter. Hence, the "device.0" (whole + daisychain) knows if it has to publish the "ALARM" flag in + ups.status + +2016-05-25 Arnaud Quette + + * docs/new-drivers.txt: daisychain: add a reference for drivers and + alarms + * docs/daisychain.txt: daisychain: update specification for alarms + handling + * drivers/eaton-mib.c, drivers/snmp-ups.c, drivers/snmp-ups.h: snmp- + ups: daisychain update, fix and completion Following the + specification update on "device.0" consideration, adapt the current + implementation. For now, the whole daisychain will only publish + device.{mfr,model,count}. Initial support for settings and commands + was also added, and will be expanded to "device.0" + * docs/daisychain.txt: daisychain: update and fix specification + * docs/daisychain.txt: daisychain: update specification as per + discussion + +2016-05-23 Arnaud Quette + + * docs/Makefile.am, docs/daisychain.txt, docs/developer-guide.txt, + docs/user-manual.txt: daisychain documentation: fix documentation + building The daisychain documentation was missing from the build + rules, and from the documentation integration, which resulted in + documentation build being broken (reported by Charles Lepple). As a + side note, the documentation (both user and developer) will need + some update and cleanup, now that there is more content Closes: + https://github.com/networkupstools/nut/issues/291 + * drivers/eaton-mib.c: snmp-ups: Eaton Aphel Revelation updates + Update Eaton Aphel Revelation MIB mapping, by fixing outlets + switchability publication and adding "device.revision". This last + data still has to be submitted as an RFC for extending NUT + variables namespace + +2016-05-19 Arnaud Quette + + * drivers/snmp-ups.c: snmp-ups: fix daisychain regression A bug was + discovered with the new daisychain code and non-daisychained + device, resulting in data not being published + +2016-05-18 Arnaud Quette + + * drivers/compaq-mib.c, drivers/ietf-mib.c, drivers/mge-mib.c, + drivers/netvision-mib.c, drivers/powerware-mib.c, drivers/snmp- + ups.c, drivers/snmp-ups.h: snmp-ups: daisychain handling of 1ph / + 3ph phases Per device phases management is now available in + daisychain mode, for input, output and bypass. The overall + mechanism for phase determination has also changed to something + more generic, and not requiring the SU_FLAG_SETINT flag + * drivers/eaton-mib.c: snmp-ups: fix input.phases for Eaton G2 / G3 + ePDU The current implementation was using the number of input, not + the number of phase(s) + +2016-05-17 Arnaud Quette + + * drivers/eaton-mib.c: snmp-ups: initial daisychain support for Eaton + PDU Following the base implementation for daisychain support in + the SNMP driver core (snmp-ups), add support for daisychain for + Eaton PDU. Commands definitions are disabled for now, and will be + addressed in a subsequent commit + * drivers/snmp-ups.c, drivers/snmp-ups.h: snmp-ups: base daisychain + support This commit includes the initial support for daisychain. + There are however a number of limitations that still need to be + addressed, such as: * {input,output,bypass}.phase handling: for + now, mixed / hybrid daisychains are not supported * All devices + alarms are pushed to "ups.alarm" without discriminant (i.e. not + "device.X" appended to the alarm) * commands and settings are not + yet handled * non-regression testing on unitary devices have to be + done + * README, docs/outlets.txt, docs/user-manual.txt: Documentation + adjustments + * docs/daisychain.txt, docs/nut-names.txt: daisychain: initial + specification and documentation + * drivers/mge-hid.c: mge-shut/usbhid-ups: list AEG PROTECT NAS vendor + 06da AEG PROTECT NAS were previously using VendorID / ProductID + 0x2b2d / 0xffff, and are now using 0x06da / 0xffff. Also bump the + mge-hid subdriver version to 1.40 + +2016-05-13 Arnaud Quette + + * docs/man/nutupsdrv.txt: Mention explicitly the default pollinterval + As in ups.conf manual page, mention the default poll interval, to + make it clear + +2016-05-10 Arnaud Quette + + * docs/nut-qa.txt: NUT QA: add Coverity static code analysis + information NUT is now a registered Coverity project, and can thus + get static code analysis from it. This is just a first step, and + actions are needed to address the actual defects and complete the + project configuration. Due thanks to Synopsys, Inc., mother firm of + Coverity, for providing this service to Opensource project + +2016-05-09 Arnaud Quette + + * drivers/apc-mib.c, drivers/snmp-ups.h: snmp-ups: remove the + redundant SU_TYPE_STRING define SU_TYPE_STRING was originally + created to expose a required cast to string. However, it is + redundant with ST_FLAG_STRING, and not useful in the end. The only + subdriver that was using it is apc-mib (UPS support) and this was a + no-op + * README: Fix wrong link reference The "NUT outlets management and + PDU notes" were wrongly referred to as "Configuring automatic UPS + shutdowns + +2016-05-04 Jim Klimov + + * .gitignore, docs/.gitignore: GitIgnore some built documents + +2016-05-03 Jim Klimov + + * configure.ac: configure.ac : prefer "/usr/share/augeas/lenses/dist" + over "/usr/share/augeas/lenses" if present + +2016-05-03 Arnaud Quette + + * docs/configure.txt: Document Augeas lenses configure option Add + documentation on the new configure option --with-augeas-lenses- + dir=PATH + +2016-05-03 Jim Klimov + + * docs/Makefile.am, docs/man/Makefile.am: Follow-up to NUT PR#281 - + notice for the future + * docs/Makefile.am, docs/man/Makefile.am: Revert toxic commit: "a2x + says "--destination-dir" is only valid for HTML... so let us reduce + complaints reported in build" This reverts commit + fe17861c4ea12679b3ebfefa8a6d692d79d99f2d because in fact asciidoc + (8.6.9) lies about not supporting the flag, and it is reqired for + `ASCIIDOC_VERBOSE=-v make distcheck-light` to pass. So let's keep + it complaining but working. + * Makefile.am, configure.ac, scripts/augeas/Makefile.am: Allow "make + install" to deliver Augeas lenses into the path defined by + configure (defaults to /usr/share/augeas/lenses) + +2016-05-02 Jim Klimov + + * docs/Makefile.am, docs/man/Makefile.am: a2x says "--destination- + dir" is only valid for HTML... so let us reduce complaints reported + in build + * configure.ac: configure.ac : by default, "--with-doc=man=yes" to + match legacy expectations, and permit "make dist" out of the box + +2016-04-26 Arnaud Quette + + * tools/nut-scanner/nut-scan.h, tools/nut-scanner/nut-scanner.c: nut- + scanner: Force numeric OIDs resolution Force numeric OIDs + resolution (ie, do not resolve to textual names) and disable MIB + loading. This is mostly for the convenience of debug and results + output + * scripts/subdriver/gen-snmp-subdriver.sh: SNMP subdriver generator: + add a FIXME + +2016-04-11 Michal Vyskocil + + * drivers/netvision-mib.c: netvision-mib: uses 0 as dfl Change to + NULL as other subdrivers does + +2016-04-11 Arnaud Quette + + * tools/nut-scanner/nutscan-init.c: nut-scanner: additional search + path Prepend "/usr/" to the provided --libdir, in case this one + points at "/lib/..." or similar, and not to "/usr/lib/..." + +2016-04-09 Émilien Kia + + * clients/nutclient.cpp: Correctly increment pointer in + stringset_to_strarr and stringvector_to_strarr. Fix bug #232 + * tests/Makefile.am, tests/nutclienttest.cpp: Create unit test + (failing for now) to test bug #232 (nutclient: + stringset_to_strarr() and stringvector_to_strarr() only work for + one element). + * clients/nutclient.cpp: Make string[set|vector]_to_strarr public to + be accessible to unit tests. + * clients/nutclient.h: Make nut::Client::~Client virtual. Prevent + compilation warning [-Wdelete-non-virtual-dtor]. + +2016-03-23 Jim Klimov + + * configure.ac, docs/configure.txt, docs/man/Makefile.am: Added + WITH_MANS support (to toggle generation of manpages) and revised + other documentation formats + +2016-04-08 Jim Klimov + + * configure.ac, docs/configure.txt: configure.ac : do not inspect + systemdunitdir with pkg-info if we asked not to use it at all + +2016-04-07 Arnaud Quette + + * drivers/raritan-px2-mib.c: snmp-ups: fix a missing field in + raritan_px2 mapping The default value (dfl field) was missing, and + thus producing a compilation warning + +2016-04-07 Jim Klimov + + * docs/configure.txt, m4/nut_check_libgd.m4, + m4/nut_check_libnetsnmp.m4: Allow to customize path to gdlib-config + and net-snmp-config programs + +2016-04-06 Arnaud Quette + + * data/driver.list.in, docs/man/snmp-ups.txt, drivers/Makefile.am, + drivers/raritan-px2-mib.c, drivers/raritan-px2-mib.h, drivers/snmp- + ups.c: snmp-ups: support Raritan Dominion PX2 PDU Based on initial + work and data from Opengear, using SNMP subdriver creation script, + add support for the more recent Raritan PDU, model PX2. This was + tested with a PX2-1486 (Metered Input), but should cover all PX2 + models + * scripts/subdriver/gen-snmp-subdriver.sh: SNMP subdriver creation + script: minor updates + +2016-03-23 Jim Klimov + + * configure.ac: Fix "--with-doc=auto" to use present doc-gens * + configure.ac : when using "--with-doc" do actually proceed if some + supported methods are found and some are not... build what we can + on this platform * configure.ac : revised upon peer review : + yes==all, default(empty)==no as documented in --help, auto guesser + must be explicit + +2016-03-24 Kirill Ovchinnikov + + * drivers/snmp-ups.c, drivers/snmp-ups.h: Added a feature of power on + and power off delay time writing to UPS configuration; Added + support of writing "timeticks" values to su_setvar() routine + +2016-03-23 Michal Vyskocil + + * drivers/eaton-mib.c: Bumb version of eaton-mib + +2016-03-23 Arnaud Quette + + * docs/man/snmp-ups.txt, docs/snmp.txt: Fix references to the SNMP + section of protocols + +2016-03-22 Michal Vyskocil + + * drivers/snmp-ups.h: snmp-ups: mark SU_FLAG_OK as internal to the + driver + * drivers/eaton-mib.c: snmp-ups: add outlet type to Eaton Marlin MIB + +2016-03-22 Arnaud Quette + + * configure.ac: Remove the extraneous GNU in front of FreeIPMI + Messages are now more homogeneous + * docs/configure.txt: Clarify multiple specifier for --with-doc + * docs/configure.txt: Update FreeIPMI requirements The documented + requirements were out of date, compared to the tests done at + configure time + +2016-03-22 Michal Vyskocil + + * drivers/snmp-ups.h: snmp-ups: enhance documentation of some flags + Mark SU_FLAG_OK as deprecated and SU_FLAG_STALE as internal to + driver. This helps new developers to write or extend snmp + subdrivers. + * docs/nut-names.txt: Document outlet.n.type Add and document + outlet.n.type variable, which provides information about physical + outlet type. + +2016-03-19 Charles Lepple + + * configure.ac: Version to 2.7.4.1 for snapshots + +2016-03-18 Marty R + + * docs/download.txt: Update OpenWRT package information The previous + link is over 5 years old, nut is now maintained in the packages + repository on GitHub. + +2016-03-10 Arnaud Quette + + * tools/nut-scanner/Makefile.am: Fix nut-scanner compilation in some + environments Following the commits 5187dab (common: add some + string-related functions) and e767df5 (common: consolidate some + string-related functions), the build rules of nut-scanner were not + updated to also use str.c. Since the libcommon.la dependency was + still there, some environments managed to build cleanly, while + other are failing. Update build dependencies to fix this situation + * drivers/powerware-mib.c: snmp-ups: Eaton 3ph UPS improvements Fix + the battery test status reporting, and start to simplify the + mapping layout by getting rid of some #define. Also add the + following: - battery test result "Unknown" - last battery + replacement date (battery.date) - output.voltage thresholds (high + and low) and nominal value + * drivers/snmp-ups.c: snmp-ups: add a debug trace on + nut_snmp_get_int() + 2016-03-09 Arnaud Quette * configure.ac: Fix autoreconf on Debian For some reason, Automake @@ -56,10 +15906,10 @@ * drivers/baytech-mib.c, drivers/bestpower-mib.c, drivers/compaq- mib.c, drivers/cyberpower-mib.c, drivers/eaton-mib.c, drivers/mge- - mib.c, drivers/netvision-mib.c, drivers/powerware-mib.c, drivers - /raritan-pdu-mib.c: snmp-ups: fix mib2nut structures Non existent - OIDs, for testing MIB selection, must be expressed as NULL and not - as empty string ("") for the algorithm to work + mib.c, drivers/netvision-mib.c, drivers/powerware-mib.c, + drivers/raritan-pdu-mib.c: snmp-ups: fix mib2nut structures Non + existent OIDs, for testing MIB selection, must be expressed as NULL + and not as empty string ("") for the algorithm to work 2016-03-03 Daniele Pezzini @@ -928,10 +16778,10 @@ * drivers/hidtypes.h: Increase the maximum number of HID objects The previous value (300) was causing a trim of the remaining objects. Increase the value to 500, which should give a bit of time - * drivers/libshut.c, drivers/libshut.h, drivers/libusb.c, drivers - /usb-common.h, drivers/usbhid-ups.c: Add support for Eaton dual HID - report descriptor All devices use HID descriptor at index 0. - However, some newer Eaton units have a light HID descriptor at + * drivers/libshut.c, drivers/libshut.h, drivers/libusb.c, + drivers/usb-common.h, drivers/usbhid-ups.c: Add support for Eaton + dual HID report descriptor All devices use HID descriptor at index + 0. However, some newer Eaton units have a light HID descriptor at index 0, and the full version is at index 1 (in which case, bcdDevice == 0x0202). This dual report descriptor approach is due to the fact that the main report descriptor is now too heavy, and @@ -1032,25 +16882,26 @@ * tools/nut-scanner/nut-scan.h, tools/nut-scanner/nut-scanner.c, tools/nut-scanner/nutscan-device.c, tools/nut-scanner/nutscan- - device.h, tools/nut-scanner/nutscan-display.c, tools/nut-scanner - /nutscan-init.c, tools/nut-scanner/nutscan-init.h, tools/nut- - scanner/nutscan-ip.c, tools/nut-scanner/nutscan-ip.h, tools/nut- - scanner/nutscan-serial.c, tools/nut-scanner/nutscan-serial.h, tools - /nut-scanner/scan_avahi.c, tools/nut-scanner/scan_eaton_serial.c, - tools/nut-scanner/scan_ipmi.c, tools/nut-scanner/scan_nut.c, tools - /nut-scanner/scan_snmp.c, tools/nut-scanner/scan_usb.c, tools/nut- - scanner/scan_xml_http.c: Fix legal information on source-code - headers Copyright and author were not mentioned as it should be. - Most of the nut-scanner copyright belongs to EATON, apart from few - parts. Files descriptions are now also in Doxygen format + device.h, tools/nut-scanner/nutscan-display.c, tools/nut- + scanner/nutscan-init.c, tools/nut-scanner/nutscan-init.h, + tools/nut-scanner/nutscan-ip.c, tools/nut-scanner/nutscan-ip.h, + tools/nut-scanner/nutscan-serial.c, tools/nut-scanner/nutscan- + serial.h, tools/nut-scanner/scan_avahi.c, tools/nut- + scanner/scan_eaton_serial.c, tools/nut-scanner/scan_ipmi.c, + tools/nut-scanner/scan_nut.c, tools/nut-scanner/scan_snmp.c, + tools/nut-scanner/scan_usb.c, tools/nut-scanner/scan_xml_http.c: + Fix legal information on source-code headers Copyright and author + were not mentioned as it should be. Most of the nut-scanner + copyright belongs to EATON, apart from few parts. Files + descriptions are now also in Doxygen format 2015-05-18 Daniele Pezzini * docs/nutdrv_qx-subdrivers.txt, drivers/nutdrv_qx.c, - drivers/nutdrv_qx.h, drivers/nutdrv_qx_bestups.c, drivers - /nutdrv_qx_blazer-common.c, drivers/nutdrv_qx_blazer-common.h, - drivers/nutdrv_qx_mecer.c, drivers/nutdrv_qx_megatec-old.c, - drivers/nutdrv_qx_megatec.c, drivers/nutdrv_qx_mustek.c, + drivers/nutdrv_qx.h, drivers/nutdrv_qx_bestups.c, + drivers/nutdrv_qx_blazer-common.c, drivers/nutdrv_qx_blazer- + common.h, drivers/nutdrv_qx_mecer.c, drivers/nutdrv_qx_megatec- + old.c, drivers/nutdrv_qx_megatec.c, drivers/nutdrv_qx_mustek.c, drivers/nutdrv_qx_q1.c, drivers/nutdrv_qx_voltronic-qs-hex.c, drivers/nutdrv_qx_voltronic-qs.c, drivers/nutdrv_qx_voltronic.c, drivers/nutdrv_qx_zinto.c: nutdrv_qx: make preprocessed value's @@ -1234,11 +17085,11 @@ 2015-03-26 Stuart Henderson * data/driver.list.in, docs/man/snmp-ups.txt, docs/snmp- - subdrivers.txt, drivers/Makefile.am, drivers/huawei-mib.c, drivers - /huawei-mib.h, drivers/snmp-ups.c: snmp-ups: new subdriver for - Huawei "Hi, the [commit] below adds a new subdriver for snmp-ups - to support Huawei UPS, based on an observed walk from a UPS5000-E - with a few bits filled in from the MIBs (copy at + subdrivers.txt, drivers/Makefile.am, drivers/huawei-mib.c, + drivers/huawei-mib.h, drivers/snmp-ups.c: snmp-ups: new subdriver + for Huawei "Hi, the [commit] below adds a new subdriver for snmp- + ups to support Huawei UPS, based on an observed walk from a + UPS5000-E with a few bits filled in from the MIBs (copy at http://junkpile.org/HUAWEI_UPS_MIB/)." http://news.gmane.org/find- root.php?message_id=slrnmh6npf.tg7.stu%40naiad.spacehopper.org @@ -1264,10 +17115,10 @@ user @nickma82 * docs/man/nutdrv_qx.txt, docs/nutdrv_qx-subdrivers.txt: nutdrv_qx: document 'voltronic-qs-hex' subdriver in man pages - * docs/man/nutdrv_qx.txt, drivers/nutdrv_qx_bestups.c, drivers - /nutdrv_qx_blazer-common.c, drivers/nutdrv_qx_blazer-common.h, - drivers/nutdrv_qx_mecer.c, drivers/nutdrv_qx_megatec-old.c, - drivers/nutdrv_qx_megatec.c, drivers/nutdrv_qx_mustek.c, + * docs/man/nutdrv_qx.txt, drivers/nutdrv_qx_bestups.c, + drivers/nutdrv_qx_blazer-common.c, drivers/nutdrv_qx_blazer- + common.h, drivers/nutdrv_qx_mecer.c, drivers/nutdrv_qx_megatec- + old.c, drivers/nutdrv_qx_megatec.c, drivers/nutdrv_qx_mustek.c, drivers/nutdrv_qx_q1.c, drivers/nutdrv_qx_voltronic-qs-hex.c, drivers/nutdrv_qx_voltronic-qs.c, drivers/nutdrv_qx_zinto.c: nutdrv_qx: add 'ignoresab' flag to support bogus devices Some @@ -1277,8 +17128,9 @@ always contains FSD). To workaround this issue, add a new 'ignoresab' flag that makes the driver do just what its name tells (IGNORE Status Active Bit) skipping the relative item in qx2nut - tables. References: - http://lists.alioth.debian.org/pipermail - /nut-upsdev/2015-March/006896.html - + tables. References: - + http://lists.alioth.debian.org/pipermail/nut- + upsdev/2015-March/006896.html - https://github.com/networkupstools/nut/issues/195 2015-03-11 Arnaud Quette @@ -1518,9 +17370,9 @@ 2015-01-02 Charles Lepple * docs/cables.txt, docs/config-notes.txt, docs/configure.txt, - docs/features.txt, docs/history.txt, docs/man/nutdrv_qx.txt, docs - /nut-names.txt, docs/scheduling.txt, docs/security.txt: docs: typo - fixes + docs/features.txt, docs/history.txt, docs/man/nutdrv_qx.txt, + docs/nut-names.txt, docs/scheduling.txt, docs/security.txt: docs: + typo fixes 2015-01-01 Charles Lepple @@ -1541,8 +17393,9 @@ 2014-12-12 Andy Juniper * clients/upslog.c, docs/man/upslog.txt: upslog: break out of sleep - on SIGUSR1 and log immediately Reference: http://news.gmane.org - /find-root.php?message_id=54863D44.3000902%40freeuk.com + on SIGUSR1 and log immediately Reference: + http://news.gmane.org/find- + root.php?message_id=54863D44.3000902%40freeuk.com 2014-11-25 Charles Lepple @@ -1784,12 +17637,12 @@ 2014-09-03 Daniele Pezzini - * drivers/Makefile.am, drivers/nutdrv_qx.c, drivers - /nutdrv_qx_voltronic-qs-hex.c, drivers/nutdrv_qx_voltronic-qs- - hex.h: nutdrv_qx: add Voltronic-QS-Hex subdriver (protocol - =voltronic-qs-hex) A subdriver using a protocol, specific to UPSes - manufactured by Voltronic Power, partially Hex-encoded (e.g. 'QS' - reply) and supporting some megatec commands. + * drivers/Makefile.am, drivers/nutdrv_qx.c, + drivers/nutdrv_qx_voltronic-qs-hex.c, drivers/nutdrv_qx_voltronic- + qs-hex.h: nutdrv_qx: add Voltronic-QS-Hex subdriver + (protocol=voltronic-qs-hex) A subdriver using a protocol, specific + to UPSes manufactured by Voltronic Power, partially Hex-encoded + (e.g. 'QS' reply) and supporting some megatec commands. * docs/nutdrv_qx-subdrivers.txt: nutdrv_qx: update docs about added support for more complex UPS answers * drivers/nutdrv_qx.c, drivers/nutdrv_qx.h, @@ -2028,9 +17881,9 @@ (0.62) Patch suggested by Bruno Salvador for BZ1200-BR, and also tested by Douglas A. Augusto on BZ2200BI-BR. Reference: * http://forums.freenas.org/index.php?threads/nobreak-bz1200-br-back- - ups-rs-1200va-600w-bivolt-115-nt.20247/ * http://news.gmane.org - /find-root.php?message_id=CACu22%2d3Nn2R%3dQQe9uy%5fPXHRduaPaFgCp2S - w4ra57Ow2qDQcOJQ%40mail.gmail.com + ups-rs-1200va-600w-bivolt-115-nt.20247/ * + http://news.gmane.org/find-root.php?message_id=CACu22%2d3Nn2R%3dQQe + 9uy%5fPXHRduaPaFgCp2Sw4ra57Ow2qDQcOJQ%40mail.gmail.com 2014-06-08 Arnaud Quette @@ -2072,8 +17925,8 @@ Pedantic, to be sure, but someone might try the driver with a protocol not listed, and sure enough, bv_12V won't be initialized. * docs/man/tripplite_usb.txt, drivers/tripplite_usb.c: tripplite_usb: - expose battery_min/_max as variables (0.22) http://news.gmane.org - /find- + expose battery_min/_max as variables (0.22) + http://news.gmane.org/find- root.php?message_id=21370.36829.817425.464627%40godel.bruda.ca 2014-05-27 Charles Lepple @@ -2131,16 +17984,17 @@ * drivers/powercom-hid.c, drivers/usbhid-ups.c: Bump versions. * data/driver.list.in, docs/man/usbhid-ups.txt: Update documentation. * drivers/usbhid-ups.c: Reconnect on interrupt read error. - * drivers/libhid.c, drivers/libhid.h, drivers/powercom-hid.c, drivers - /usbhid-ups.c: Reading from the interrupt pipe implies that you use - INPUT flagged objects. + * drivers/libhid.c, drivers/libhid.h, drivers/powercom-hid.c, + drivers/usbhid-ups.c: Reading from the interrupt pipe implies that + you use INPUT flagged objects. * drivers/powercom-hid.c: Remove erroneous status. * drivers/powercom-hid.c: Comment non-compliant variables. 2014-04-17 Andrew Burdo - * drivers/libhid.c, drivers/libhid.h, drivers/powercom-hid.c, drivers - /usbhid-ups.c: Add support for 0d9f:0001 (USB HID, Powercom). + * drivers/libhid.c, drivers/libhid.h, drivers/powercom-hid.c, + drivers/usbhid-ups.c: Add support for 0d9f:0001 (USB HID, + Powercom). 2014-04-17 Arnaud Quette @@ -2206,10 +18060,11 @@ 2014-03-18 Charles Lepple * data/driver.list.in: [HCL] Digitus DN-170014 supported by - richcomm_usb Reference: http://lists.alioth.debian.org/pipermail - /nut-upsdev/2014-March/006695.html -or- http://news.gmane.org/find- - root.php?message_id=CADq9dvWMx0xBz9XXkVKXCre4ox%2d2kSeHtD7LW39eEDH1 - RCY8sQ%40mail.gmail.com + richcomm_usb Reference: + http://lists.alioth.debian.org/pipermail/nut- + upsdev/2014-March/006695.html -or- http://news.gmane.org/find-root. + php?message_id=CADq9dvWMx0xBz9XXkVKXCre4ox%2d2kSeHtD7LW39eEDH1RCY8s + Q%40mail.gmail.com 2014-03-05 Charles Lepple @@ -2295,8 +18150,8 @@ * http://lists.alioth.debian.org/pipermail/nut- upsdev/2013-November/006564.html * http://news.gmane.org/find- root.php?message_id=50D9D460.1080408%40gmail.com - * http://news.gmane.org/find-root.php?message_id=CA%2b4duQ%3dppW%2 - bPz%2bRVPVXJyFLj0HErh1ZOtm5tk8b6n5Nd5kSk0g%40mail.gmail.com * + * http://news.gmane.org/find-root.php?message_id=CA%2b4duQ%3dppW%2b + Pz%2bRVPVXJyFLj0HErh1ZOtm5tk8b6n5Nd5kSk0g%40mail.gmail.com * http://news.gmane.org/find- root.php?message_id=528EC53C.9000801%40me.com * docs/nut-qa.txt: NUT QA document: updated and reworded @@ -2318,8 +18173,8 @@ * UPGRADING: Add a note on Hardware Abstraction Layer removal * INSTALL.nut, autogen.sh, configure.ac, docs/Makefile.am, docs/configure.txt, docs/developers.txt, docs/features.txt, - docs/macros.txt, docs/new-drivers.txt, docs/nut-hal.txt, docs - /packager-guide.txt, drivers/Makefile.am, drivers/dstate-hal.c, + docs/macros.txt, docs/new-drivers.txt, docs/nut-hal.txt, + docs/packager-guide.txt, drivers/Makefile.am, drivers/dstate-hal.c, drivers/dstate-hal.h, drivers/main-hal.c, drivers/main-hal.h, m4/nut_check_libhal.m4, m4/nut_config_libhal.m4: Remove the remaining HAL files and references Remove the remaining build @@ -2369,11 +18224,13 @@ (docbook) Add HTML tag to not auto-create telephone number links on mobile browsers also in docbook processed documents. Reference: https://github.com/networkupstools/nut/issues/78 XSL - files source: - https://github.com/asciidoc/asciidoc/blob/master - /docbook-xsl/common.xsl - + files source: - https://github.com/asciidoc/asciidoc/blob/master/docbook- - xsl/xhtml.xsl - https://github.com/asciidoc/asciidoc/blob/master - /docbook-xsl/chunked.xsl + xsl/common.xsl - + https://github.com/asciidoc/asciidoc/blob/master/docbook- + xsl/xhtml.xsl - + https://github.com/asciidoc/asciidoc/blob/master/docbook- + xsl/chunked.xsl * docs/man/asciidoc.conf: docs: prevent smartphones from being too smart Add HTML tag to not auto-create telephone number links on mobile browsers. Reference: @@ -2416,12 +18273,11 @@ 2014-02-14 Arnaud Quette - * docs/acknowledgements.txt: Update NUT team membership for - Frédéric Bohe Frederic Bohe, NUT senior developer and Eaton - contractor from 2009 to 2013, is now a retired member. Thanks for - all the hard work on the Windows port, nut-scanner, Unix packaging, - support, ... Also update the developers membership page, from - Alioth to GitHub + * docs/acknowledgements.txt: Update NUT team membership for Frédéric + Bohe Frederic Bohe, NUT senior developer and Eaton contractor from + 2009 to 2013, is now a retired member. Thanks for all the hard work + on the Windows port, nut-scanner, Unix packaging, support, ... Also + update the developers membership page, from Alioth to GitHub 2013-02-24 Charles Lepple @@ -2563,12 +18419,12 @@ 2013-12-05 Daniele Pezzini - * drivers/Makefile.am, drivers/nutdrv_qx.c, drivers - /nutdrv_qx_voltronic-qs.c, drivers/nutdrv_qx_voltronic-qs.h: - nutdrv_qx: add Voltronic-QS subdriver (nutdrv_qx protocol - =voltronic-qs) A subdriver using a protocol, specific to UPSes - manufactured by Voltronic Power, based on the 'mustek' one (i.e. - 'QS'). + * drivers/Makefile.am, drivers/nutdrv_qx.c, + drivers/nutdrv_qx_voltronic-qs.c, drivers/nutdrv_qx_voltronic-qs.h: + nutdrv_qx: add Voltronic-QS subdriver (nutdrv_qx + protocol=voltronic-qs) A subdriver using a protocol, specific to + UPSes manufactured by Voltronic Power, based on the 'mustek' one + (i.e. 'QS'). 2014-01-01 Charles Lepple @@ -2589,9 +18445,9 @@ 2013-12-31 Laurent Bigonville - * .gitignore, INSTALL, INSTALL.nut, Makefile.am, docs/FAQ.txt, - docs/Makefile.am, docs/configure.txt, docs/packager-guide.txt, docs - /user-manual.txt: Rename INSTALL to INSTALL.nut Rename it to + * .gitignore, INSTALL => INSTALL.nut, Makefile.am, docs/FAQ.txt, + docs/Makefile.am, docs/configure.txt, docs/packager-guide.txt, + docs/user-manual.txt: Rename INSTALL to INSTALL.nut Rename it to INSTALL.nut so autoreconf will not try to overwrite it. In Debian tools like dh_autoreconf calls autoreconf with -f which overwrite the INSTALL file. @@ -2616,19 +18472,19 @@ 2013-11-30 Daniele Pezzini - * docs/man/nutdrv_qx.txt, drivers/nutdrv_qx.c, drivers - /nutdrv_qx_blazer-common.c, drivers/nutdrv_qx_blazer-common.h, - drivers/nutdrv_qx_megatec-old.c, drivers/nutdrv_qx_mustek.c, - drivers/nutdrv_qx_q1.c: nutdrv_qx: fix 'megatec/old' and 'mustek' - subdrivers' claim functions Address, for 'megatec/old' and - 'mustek' subdrivers, the same problem fixed in commit - 720975f4de910b270ba705a7f2981c2ee33ca2eb for Q1-based ones: - Make - the claim function of 'megatec/old' and 'mustek' subdrivers not - poll the UPS for 'vendor' informations as they are not really - needed to set these protocols apart from the other ones (i.e. the - 'status' poll is specific enough, at the time of writing). - Move - common 'light' claim function to nutdrv_qx_blazer-common.{c,h}. - - Update manual. - Versioning. + * docs/man/nutdrv_qx.txt, drivers/nutdrv_qx.c, + drivers/nutdrv_qx_blazer-common.c, drivers/nutdrv_qx_blazer- + common.h, drivers/nutdrv_qx_megatec-old.c, + drivers/nutdrv_qx_mustek.c, drivers/nutdrv_qx_q1.c: nutdrv_qx: fix + 'megatec/old' and 'mustek' subdrivers' claim functions Address, + for 'megatec/old' and 'mustek' subdrivers, the same problem fixed + in commit 720975f4de910b270ba705a7f2981c2ee33ca2eb for Q1-based + ones: - Make the claim function of 'megatec/old' and 'mustek' + subdrivers not poll the UPS for 'vendor' informations as they are + not really needed to set these protocols apart from the other ones + (i.e. the 'status' poll is specific enough, at the time of + writing). - Move common 'light' claim function to nutdrv_qx_blazer- + common.{c,h}. - Update manual. - Versioning. 2013-11-24 Daniele Pezzini @@ -2665,7 +18521,7 @@ 2013-11-23 Charles Lepple - * configure.ac, configure.in: Rename configure.in to configure.ac + * configure.in => configure.ac: Rename configure.in to configure.ac autoconf has been warning about this for a while - let's fix it before too many branches get created with the old name. * configure.in: configure.in: bump version to 2.7.1.5 Some packaging @@ -2745,8 +18601,8 @@ environment on ships (and we don't need shutdown there -- in critical situations the system has to operate as long as possible, untill the battery is empty) Also, all of the previous issues - listed below are now fixed in this al175 version: - ‘return’ - with a value, in function returning void (2x) - anonymous variadic + listed below are now fixed in this al175 version: - ‘return’ with + a value, in function returning void (2x) - anonymous variadic macros were introduced in C99 - C++ style comments are not allowed in ISO C90 - ISO C forbids braced-groups within expressions (5x) - ISO C90 forbids specifying subobject to initialize (16x) - ISO C99 @@ -2843,27 +18699,26 @@ revert of the voltronic merge * data/driver.list.in: nutdrv_qx: remove superfluous indications from the HCL - * data/driver.list.in, docs/Makefile.am, docs/blzr-subdrivers.txt, - docs/man/Makefile.am, docs/man/blzr.txt, docs/man/index.txt, - docs/man/nutdrv_qx.txt, docs/man/nutupsdrv.txt, docs/new- - drivers.txt, docs/nutdrv_qx-subdrivers.txt, drivers/Makefile.am, - drivers/blzr.c, drivers/blzr.h, drivers/blzr_blazer-common.c, - drivers/blzr_blazer-common.h, drivers/blzr_mecer.c, - drivers/blzr_mecer.h, drivers/blzr_megatec-old.c, drivers - /blzr_megatec-old.h, drivers/blzr_megatec.c, - drivers/blzr_megatec.h, drivers/blzr_mustek.c, - drivers/blzr_mustek.h, drivers/blzr_voltronic.c, - drivers/blzr_voltronic.h, drivers/blzr_zinto.c, - drivers/blzr_zinto.h, drivers/nutdrv_qx.c, drivers/nutdrv_qx.h, - drivers/nutdrv_qx_blazer-common.c, drivers/nutdrv_qx_blazer- - common.h, drivers/nutdrv_qx_mecer.c, drivers/nutdrv_qx_mecer.h, - drivers/nutdrv_qx_megatec-old.c, drivers/nutdrv_qx_megatec-old.h, - drivers/nutdrv_qx_megatec.c, drivers/nutdrv_qx_megatec.h, - drivers/nutdrv_qx_mustek.c, drivers/nutdrv_qx_mustek.h, - drivers/nutdrv_qx_voltronic.c, drivers/nutdrv_qx_voltronic.h, - drivers/nutdrv_qx_zinto.c, drivers/nutdrv_qx_zinto.h, tools/nut- - usbinfo.pl: nutdrv_qx: rename 'blzr' driver to 'nutdrv_qx' - Reference: http://lists.alioth.debian.org/pipermail/nut- + * data/driver.list.in, docs/Makefile.am, docs/man/Makefile.am, + docs/man/index.txt, docs/man/{blzr.txt => nutdrv_qx.txt}, + docs/man/nutupsdrv.txt, docs/new-drivers.txt, ...lzr-subdrivers.txt + => nutdrv_qx-subdrivers.txt}, drivers/Makefile.am, drivers/{blzr.c + => nutdrv_qx.c}, drivers/{blzr.h => nutdrv_qx.h}, ...r_blazer- + common.c => nutdrv_qx_blazer-common.c}, ...r_blazer-common.h => + nutdrv_qx_blazer-common.h}, drivers/{blzr_mecer.c => + nutdrv_qx_mecer.c}, drivers/{blzr_mecer.h => nutdrv_qx_mecer.h}, + ...{blzr_megatec-old.c => nutdrv_qx_megatec-old.c}, + ...{blzr_megatec-old.h => nutdrv_qx_megatec-old.h}, + drivers/{blzr_megatec.c => nutdrv_qx_megatec.c}, + drivers/{blzr_megatec.h => nutdrv_qx_megatec.h}, + drivers/{blzr_mustek.c => nutdrv_qx_mustek.c}, + drivers/{blzr_mustek.h => nutdrv_qx_mustek.h}, + .../{blzr_voltronic.c => nutdrv_qx_voltronic.c}, + .../{blzr_voltronic.h => nutdrv_qx_voltronic.h}, + drivers/{blzr_zinto.c => nutdrv_qx_zinto.c}, drivers/{blzr_zinto.h + => nutdrv_qx_zinto.h}, tools/nut-usbinfo.pl: nutdrv_qx: rename + 'blzr' driver to 'nutdrv_qx' Reference: + http://lists.alioth.debian.org/pipermail/nut- upsdev/2013-November/006555.html * docs/stable-hcl.txt, docs/website/css/web-layout.css: Address Issue #48 (text-based browsers) Reference: https://github.com/networkups @@ -2894,12 +18749,11 @@ 2013-10-16 Daniele Pezzini - * docs/man/Makefile.am, docs/man/blazer-common.txt, - docs/man/blazer.txt, docs/man/blazer_ser.txt, - docs/man/blazer_usb.txt, docs/man/index.txt, - docs/man/nutupsdrv.txt: blazer: Fix {usb,ser} manual Split the old - blazer manual in two manuals named after their executables with a - common source. + * docs/man/Makefile.am, docs/man/{blazer.txt => blazer-common.txt}, + docs/man/blazer_ser.txt, docs/man/blazer_usb.txt, + docs/man/index.txt, docs/man/nutupsdrv.txt: blazer: Fix {usb,ser} + manual Split the old blazer manual in two manuals named after + their executables with a common source. * docs/man/blazer.txt: blazer: Fix user manual Fix minor errors Add ranges Fix test.battery.start (i.e. minutes instead of seconds) * drivers/blazer.c: blazer: Fix shutdown sequence Split stop pending @@ -2974,8 +18828,8 @@ docs/man/Makefile.am, docs/man/blzr.txt, docs/man/index.txt, docs/man/nutupsdrv.txt, docs/new-drivers.txt, drivers/Makefile.am, drivers/blzr.c, drivers/blzr.h, drivers/blzr_blazer-common.c, - drivers/blzr_blazer-common.h, drivers/blzr_megatec-old.c, drivers - /blzr_megatec-old.h, drivers/blzr_megatec.c, + drivers/blzr_blazer-common.h, drivers/blzr_megatec-old.c, + drivers/blzr_megatec-old.h, drivers/blzr_megatec.c, drivers/blzr_megatec.h, drivers/blzr_mustek.c, drivers/blzr_mustek.h, drivers/blzr_voltronic.c, drivers/blzr_voltronic.h, drivers/blzr_zinto.c, @@ -3270,10 +19124,10 @@ Solaris * tools/nut-scanner/nutscan-device.c, tools/nut-scanner/nutscan- device.h, tools/nut-scanner/scan_avahi.c, tools/nut- - scanner/scan_eaton_serial.c, tools/nut-scanner/scan_ipmi.c, tools - /nut-scanner/scan_nut.c, tools/nut-scanner/scan_snmp.c, tools/nut- - scanner/scan_usb.c, tools/nut-scanner/scan_xml_http.c: [nut- - scanner] Make sure to return the first device of the list. + scanner/scan_eaton_serial.c, tools/nut-scanner/scan_ipmi.c, + tools/nut-scanner/scan_nut.c, tools/nut-scanner/scan_snmp.c, + tools/nut-scanner/scan_usb.c, tools/nut-scanner/scan_xml_http.c: + [nut-scanner] Make sure to return the first device of the list. 2013-07-22 Charles Lepple @@ -3635,10 +19489,10 @@ scripts/java/jNutWebAPI/README, scripts/java/jNutWebAPI/pom.xml, .../jnutwebapi/NutRestProvider.java, .../jnutwebapi/RestWSApplication.java, - .../jnutwebapi/ScannerProvider.java, .../jNutWebAPI/src/main/webapp - /WEB-INF/web.xml: Remove java related files (jNut) which will be - moved to a separated repository. See issues: - - https://github.com/networkupstools/nut/issues/2 - + .../jnutwebapi/ScannerProvider.java, + .../jNutWebAPI/src/main/webapp/WEB-INF/web.xml: Remove java related + files (jNut) which will be moved to a separated repository. See + issues: - https://github.com/networkupstools/nut/issues/2 - https://github.com/networkupstools/nut/issues/22 2013-03-26 Alex Lov @@ -3850,17 +19704,17 @@ docs/man/nutscan_scan_eaton_serial.txt, docs/man/nutscan_scan_ipmi.txt, docs/man/nutscan_scan_nut.txt, docs/man/nutscan_scan_snmp.txt, docs/man/nutscan_scan_usb.txt, - docs/man/nutscan_scan_xml_http.txt, include/nut_platform.h, tools - /nut-scanner/Makefile.am, tools/nut-scanner/nut-scan.h, tools/nut- - scanner/nut-scanner.c, tools/nut-scanner/nutscan-device.h, tools - /nut-scanner/nutscan-display.c, tools/nut-scanner/nutscan-serial.c, - tools/nut-scanner/nutscan-serial.h, tools/nut- - scanner/scan_eaton_serial.c, tools/nut-scanner/scan_nut.c: Add nut- - scanner support for Eaton serial units nut-scanner and libnutscan - now provides respectively an option and functions to detect Eaton - serial devices. The following protocols are supported: SHUT, XCP - and Q1 (patch from Frederic Bohe, with parts from Arnaud Quette, - both for Eaton) + docs/man/nutscan_scan_xml_http.txt, include/nut_platform.h, + tools/nut-scanner/Makefile.am, tools/nut-scanner/nut-scan.h, + tools/nut-scanner/nut-scanner.c, tools/nut-scanner/nutscan- + device.h, tools/nut-scanner/nutscan-display.c, tools/nut- + scanner/nutscan-serial.c, tools/nut-scanner/nutscan-serial.h, + tools/nut-scanner/scan_eaton_serial.c, tools/nut- + scanner/scan_nut.c: Add nut-scanner support for Eaton serial units + nut-scanner and libnutscan now provides respectively an option and + functions to detect Eaton serial devices. The following protocols + are supported: SHUT, XCP and Q1 (patch from Frederic Bohe, with + parts from Arnaud Quette, both for Eaton) * configure.in: Fix for pthread on HP-UX pthread is compiled on a stub when -lpthread is not explicitly added. This commit is a duplicate of [[SVN:3801]], from Frederic Bohe (for Eaton) @@ -4031,11 +19885,11 @@ * conf/.gitignore: Subversion ignored files completion Mark upsmon.conf.sample as Subversion ignored, since it is now generated from a .in template file (no functional changes) - * conf/Makefile.am, conf/upsmon.conf.sample, - conf/upsmon.conf.sample.in, configure.in: Adapt upsmon.conf sample - to use configured values The sample upsmon.conf provided now - adapts RUN_AS_USER value, and NOTIFYCMD / POWERDOWNFLAG base path - to the user configured values + * conf/Makefile.am, conf/{upsmon.conf.sample => + upsmon.conf.sample.in}, configure.in: Adapt upsmon.conf sample to + use configured values The sample upsmon.conf provided now adapts + RUN_AS_USER value, and NOTIFYCMD / POWERDOWNFLAG base path to the + user configured values 2012-11-28 Arnaud Quette @@ -4045,11 +19899,11 @@ device.mfr was also changed in both drivers, and revisions were bumped to 0.02 (patch from Elio Parisi, Riello) * data/driver.list.in, drivers/Makefile.am, drivers/openups-hid.c, - drivers/openups-hid.h, drivers/usbhid-ups.c, scripts/upower/95 - -upower-hid.rules: Official support for Minibox openUPS Intelligent - UPS Add a new usbhid-ups subdriver to handle Minibox openUPS - Intelligent UPS (USB ID 0x04d8:0xd004) (patch from Nicu Pavel, - Mini-Box.Com) + drivers/openups-hid.h, drivers/usbhid-ups.c, + scripts/upower/95-upower-hid.rules: Official support for Minibox + openUPS Intelligent UPS Add a new usbhid-ups subdriver to handle + Minibox openUPS Intelligent UPS (USB ID 0x04d8:0xd004) (patch from + Nicu Pavel, Mini-Box.Com) 2012-11-28 Charles Lepple @@ -4081,12 +19935,12 @@ * data/driver.list.in, docs/man/.gitignore, docs/man/Makefile.am, docs/man/riello_ser.txt, docs/man/riello_usb.txt, drivers/.gitignore, drivers/Makefile.am, drivers/riello.c, - drivers/riello.h, drivers/riello_ser.c, drivers/riello_usb.c, tools - /nut-usbinfo.pl: Official support for Riello serial and USB devices - Add two new drivers, riello_ser and riello_usb, to support the - whole ranges of Riello devices: IDG, IPG, WPG, NPW, NDG, DVT, DVR, - DVD, VST, VSD, SEP, SDH, SDL, SPW, SPT, MCT, MST, MCM, MCT, MHT, - MPT and MPM. This completes the official Riello protocols + drivers/riello.h, drivers/riello_ser.c, drivers/riello_usb.c, + tools/nut-usbinfo.pl: Official support for Riello serial and USB + devices Add two new drivers, riello_ser and riello_usb, to support + the whole ranges of Riello devices: IDG, IPG, WPG, NPW, NDG, DVT, + DVR, DVD, VST, VSD, SEP, SDH, SDL, SPW, SPT, MCT, MST, MCM, MCT, + MHT, MPT and MPM. This completes the official Riello protocols publication, that happened in May 2012 (developed by Elio Parisi, from Riello) @@ -4190,8 +20044,8 @@ * drivers/cps-hid.c, drivers/idowell-hid.c, scripts/subdriver/gen- usbhid-subdriver.sh: Replace missing occurrences in previous commit * docs/hid-subdrivers.txt, drivers/libhid.c, scripts/Makefile.am, - scripts/subdriver/gen-usbhid-subdriver.sh, scripts/subdriver/path- - to-subdriver.sh: Rename usbhid subdriver generation script This + scripts/subdriver/{path-to-subdriver.sh => gen-usbhid- + subdriver.sh}: Rename usbhid subdriver generation script This script was previously named path-to-subdriver.sh, which was not enough meaningful. The renaming to gen-usbhid-subdriver.sh also makes sense with a potential gen-snmp-subdriver.sh @@ -4232,14 +20086,14 @@ 2012-10-10 Arnaud Quette * README: Spell check fix (test) - * .gitignore, configure.in, docs/.gitignore, docs/Makefile.am, docs - /nut-qa.txt, docs/nut.dict: Spell checking framework implementation - Implement a framework to spell check documentation source files, - using Aspell. This includes an interactive build target (make - spellcheck-interactive), and an automated one (make spellcheck), - mainly for QA / Buildbot purpose. Note that a base NUT dictionnary - is also available (docs/nut.dict), providing a glossary of terms - related to power devices and management + * .gitignore, configure.in, docs/.gitignore, docs/Makefile.am, + docs/nut-qa.txt, docs/nut.dict: Spell checking framework + implementation Implement a framework to spell check documentation + source files, using Aspell. This includes an interactive build + target (make spellcheck-interactive), and an automated one (make + spellcheck), mainly for QA / Buildbot purpose. Note that a base NUT + dictionnary is also available (docs/nut.dict), providing a glossary + of terms related to power devices and management * drivers/tripplite_usb.c: Remove POD ("Plain Old Documentation") With the approval of the author (Charles Lepple), remove POD ("Plain Old Documentation"). This embedded documentation was @@ -4255,8 +20109,8 @@ 2012-10-04 Arnaud Quette - * docs/man/nut-scanner.txt, drivers/nut-ipmipsu.c, tools/nut-scanner - /nut-scan.h, tools/nut-scanner/nut-scanner.c, tools/nut- + * docs/man/nut-scanner.txt, drivers/nut-ipmipsu.c, tools/nut- + scanner/nut-scan.h, tools/nut-scanner/nut-scanner.c, tools/nut- scanner/scan_ipmi.c: Support power supplies scan over the network nut-scanner can now scan for power supplies with IPMI over LAN. This is currently limited to IPMI 1.5 only @@ -4340,13 +20194,14 @@ docs/man/macosx-ups.txt, docs/man/mge-shut.txt, docs/man/nutscan.txt, docs/man/nutscan_scan_avahi.txt, docs/man/powercom.txt, docs/man/skel.txt, docs/nut-names.txt, - docs/website/.gitignore, docs/website/Makefile.am, docs/website/css - /web-layout.css, docs/website/news.txt, docs/website/old-news.txt, - docs/website/projects.txt, docs/website/web-layout.conf, - drivers/.gitignore, drivers/Makefile.am, drivers/macosx-ups.c, - drivers/mge-hid.c, drivers/powercom-hid.c, drivers/skel.c, drivers - /usbhid-ups.c, drivers/usbhid-ups.h, m4/nut_check_libltdl.m4: Merge - from trunk [[SVN:3679]] to [[SVN:3718]] to ssl-nss-port + docs/website/.gitignore, docs/website/Makefile.am, + docs/website/css/web-layout.css, docs/website/news.txt, + docs/website/old-news.txt, docs/website/projects.txt, + docs/website/web-layout.conf, drivers/.gitignore, + drivers/Makefile.am, drivers/macosx-ups.c, drivers/mge-hid.c, + drivers/powercom-hid.c, drivers/skel.c, drivers/usbhid-ups.c, + drivers/usbhid-ups.h, m4/nut_check_libltdl.m4: Merge from trunk + [[SVN:3679]] to [[SVN:3718]] to ssl-nss-port 2012-08-09 Arnaud Quette @@ -4484,10 +20339,10 @@ 2012-07-19 Emilien Kia - * server/Makefile.am, server/conf.c, server/netcmds.h, - server/netssl.c, server/netssl.h, server/ssl.c, server/ssl.h, - server/upsd.c: Replace server/ssl.[h|c] by server/netssl.[h|c] in - order to prepare nss branch merging. + * server/Makefile.am, server/conf.c, server/netcmds.h, server/{ssl.c + => netssl.c}, server/{ssl.h => netssl.h}, server/upsd.c: Replace + server/ssl.[h|c] by server/netssl.[h|c] in order to prepare nss + branch merging. 2012-07-18 Emilien Kia @@ -4505,14 +20360,14 @@ docs/documentation.txt, docs/download.txt, docs/features.txt, docs/images/advanced.png, docs/images/bigbox.png, docs/images/bizarre.png, docs/images/nut-logo.png, - docs/images/nut.svg, docs/images/simple.png, docs/macros.txt, docs - /maintainer-guide.txt, docs/man/.gitignore, docs/man/Makefile.am, - docs/man/apcsmart-old.txt, docs/man/apcsmart.txt, - docs/man/bcmxcp.txt, docs/man/belkinunv.txt, docs/man/blazer.txt, - docs/man/dummy-ups.txt, docs/man/index.txt, docs/man/metasys.txt, - docs/man/nut-ipmipsu.txt, docs/man/nut-recorder.txt, docs/man/nut- - scanner.txt, docs/man/nut.conf.txt, docs/man/nutscan.txt, - docs/man/nutscan_add_device_to_device.txt, + docs/images/nut.svg, docs/images/simple.png, docs/macros.txt, + docs/maintainer-guide.txt, docs/man/.gitignore, + docs/man/Makefile.am, docs/man/apcsmart-old.txt, + docs/man/apcsmart.txt, docs/man/bcmxcp.txt, docs/man/belkinunv.txt, + docs/man/blazer.txt, docs/man/dummy-ups.txt, docs/man/index.txt, + docs/man/metasys.txt, docs/man/nut-ipmipsu.txt, docs/man/nut- + recorder.txt, docs/man/nut-scanner.txt, docs/man/nut.conf.txt, + docs/man/nutscan.txt, docs/man/nutscan_add_device_to_device.txt, docs/man/nutscan_add_option_to_device.txt, docs/man/nutscan_cidr_to_ip.txt, docs/man/nutscan_display_parsable.txt, @@ -4532,8 +20387,8 @@ layout.css, docs/website/faviconut.ico, docs/website/faviconut.png, docs/website/news.txt, docs/website/projects.txt, docs/website/ups- protocols.txt, docs/website/web-layout.conf, drivers/.gitignore, - drivers/Makefile.am, drivers/apc-hid.c, drivers/apc-mib.c, drivers - /apcsmart-old.c, drivers/apcsmart-old.h, drivers/apcsmart.c, + drivers/Makefile.am, drivers/apc-hid.c, drivers/apc-mib.c, + drivers/apcsmart-old.c, drivers/apcsmart-old.h, drivers/apcsmart.c, drivers/apcsmart.h, drivers/apcsmart_tabs.c, drivers/apcsmart_tabs.h, drivers/bcmxcp.c, drivers/bcmxcp.h, drivers/bcmxcp_ser.c, drivers/bcmxcp_usb.c, drivers/belkin-hid.c, @@ -4546,27 +20401,28 @@ drivers/etapro.c, drivers/gamatronic.c, drivers/genericups.c, drivers/ietf-mib.c, drivers/isbmex.c, drivers/libhid.c, drivers/libshut.c, drivers/liebert-esp2.c, drivers/liebert-hid.c, - drivers/main.c, drivers/masterguard.c, drivers/metasys.c, drivers - /mge-hid.c, drivers/mge-mib.c, drivers/mge-shut.c, drivers/mge- - utalk.c, drivers/microdowell.c, drivers/netvision-mib.c, drivers - /netxml-ups.c, drivers/nut-ipmi.h, drivers/nut-ipmipsu.c, drivers - /nut-libfreeipmi.c, drivers/oneac.c, drivers/oneac.h, drivers - /powercom-hid.c, drivers/powercom.c, drivers/powercom.h, drivers - /powerware-mib.c, drivers/raritan-pdu-mib.c, drivers/rhino.c, - drivers/safenet.c, drivers/snmp-ups.c, drivers/snmp-ups.h, - drivers/solis.c, drivers/tripplite-hid.c, drivers/tripplite_usb.c, - drivers/tripplitesu.c, drivers/upscode2.c, drivers/upshandler.h, - drivers/usb-common.c, drivers/usbhid-ups.c, include/.gitignore, - include/Makefile.am, include/common.h, include/extstate.h, - include/nut_stdint.h, include/parseconf.h, include/state.h, - lib/.gitignore, lib/Makefile.am, lib/README, lib/libnutscan.pc.in, - lib/libupsclient-config.in, lib/libupsclient.pc.in, - m4/ax_create_stdint_h.m4, m4/nut_check_libavahi.m4, - m4/nut_check_libfreeipmi.m4, m4/nut_check_libltdl.m4, - m4/nut_check_libwrap.m4, m4/nut_check_os.m4, - m4/nut_report_feature.m4, scripts/HP-UX/.gitignore, scripts/HP- - UX/makedepot.sh, scripts/HP-UX/nut.psf.in, scripts/Makefile.am, - scripts/README, scripts/augeas/Makefile.am, scripts/augeas/README, + drivers/main.c, drivers/masterguard.c, drivers/metasys.c, + drivers/mge-hid.c, drivers/mge-mib.c, drivers/mge-shut.c, + drivers/mge-utalk.c, drivers/microdowell.c, drivers/netvision- + mib.c, drivers/netxml-ups.c, drivers/nut-ipmi.h, drivers/nut- + ipmipsu.c, drivers/nut-libfreeipmi.c, drivers/oneac.c, + drivers/oneac.h, drivers/powercom-hid.c, drivers/powercom.c, + drivers/powercom.h, drivers/powerware-mib.c, drivers/raritan-pdu- + mib.c, drivers/rhino.c, drivers/safenet.c, drivers/snmp-ups.c, + drivers/snmp-ups.h, drivers/solis.c, drivers/tripplite-hid.c, + drivers/tripplite_usb.c, drivers/tripplitesu.c, drivers/upscode2.c, + drivers/upshandler.h, drivers/usb-common.c, drivers/usbhid-ups.c, + include/.gitignore, include/Makefile.am, include/common.h, + include/extstate.h, include/nut_stdint.h, include/parseconf.h, + include/state.h, lib/.gitignore, lib/Makefile.am, lib/README, + lib/libnutscan.pc.in, lib/libupsclient-config.in, + lib/libupsclient.pc.in, m4/ax_create_stdint_h.m4, + m4/nut_check_libavahi.m4, m4/nut_check_libfreeipmi.m4, + m4/nut_check_libltdl.m4, m4/nut_check_libwrap.m4, + m4/nut_check_os.m4, m4/nut_report_feature.m4, scripts/HP- + UX/.gitignore, scripts/HP-UX/makedepot.sh, scripts/HP- + UX/nut.psf.in, scripts/Makefile.am, scripts/README, + scripts/augeas/Makefile.am, scripts/augeas/README, scripts/avahi/nut.service.in, scripts/java/Makefile.am, scripts/java/README, scripts/java/jNut/README, scripts/java/jNut/pom.xml, @@ -4584,40 +20440,41 @@ scripts/java/jNutWebAPI/README, scripts/java/jNutWebAPI/pom.xml, .../jnutwebapi/NutRestProvider.java, .../jnutwebapi/RestWSApplication.java, - .../jnutwebapi/ScannerProvider.java, .../jNutWebAPI/src/main/webapp - /WEB-INF/web.xml, scripts/logrotate/nutlogd, - scripts/python/module/PyNUT.py, scripts/systemd/Makefile.am, - scripts/systemd/README, scripts/systemd/nut-driver.service.in, - scripts/systemd/nut-monitor.service.in, scripts/systemd/nut- - server.service.in, scripts/systemd/nutshutdown.in, - scripts/udev/.gitignore, scripts/udev/Makefile.am, - scripts/udev/README, scripts/udev/nut-ipmipsu.rules.in, - scripts/ufw/README, scripts/ufw/nut.ufw.profile.in, - scripts/upower/95-upower-hid.rules, server/Makefile.am, - server/ctype.h, server/netcmds.h, server/netget.c, server/netget.h, - server/netinstcmd.c, server/netinstcmd.h, server/netlist.c, - server/netlist.h, server/netmisc.c, server/netmisc.h, - server/netset.c, server/netset.h, server/netssl.c, server/netssl.h, - server/netuser.c, server/netuser.h, server/nut_ctype.h, - server/sstate.c, server/sstate.h, server/upsd.c, server/upsd.h, - server/user.c, tests/Makefile.am, tests/cpputest.cpp, - tests/example.cpp, tools/Makefile.am, tools/device-recorder.sh, - tools/git-svn.authors, tools/nut-hclinfo.py, tools/nut-recorder.sh, - tools/nut-scanner/Makefile.am, tools/nut-scanner/README, tools/nut- + .../jnutwebapi/ScannerProvider.java, + .../jNutWebAPI/src/main/webapp/WEB-INF/web.xml, + scripts/logrotate/nutlogd, scripts/python/module/PyNUT.py, + scripts/systemd/Makefile.am, scripts/systemd/README, + scripts/systemd/nut-driver.service.in, scripts/systemd/nut- + monitor.service.in, scripts/systemd/nut-server.service.in, + scripts/systemd/nutshutdown.in, scripts/udev/.gitignore, + scripts/udev/Makefile.am, scripts/udev/README, scripts/udev/nut- + ipmipsu.rules.in, scripts/ufw/README, + scripts/ufw/nut.ufw.profile.in, scripts/upower/95-upower-hid.rules, + server/Makefile.am, server/netcmds.h, server/netget.c, + server/netget.h, server/netinstcmd.c, server/netinstcmd.h, + server/netlist.c, server/netlist.h, server/netmisc.c, + server/netmisc.h, server/netset.c, server/netset.h, + server/netssl.c, server/netssl.h, server/netuser.c, + server/netuser.h, server/{ctype.h => nut_ctype.h}, server/sstate.c, + server/sstate.h, server/upsd.c, server/upsd.h, server/user.c, + tests/Makefile.am, tests/cpputest.cpp, tests/example.cpp, + tools/Makefile.am, tools/git-svn.authors, tools/nut-hclinfo.py, + tools/{device-recorder.sh => nut-recorder.sh}, tools/nut- + scanner/Makefile.am, tools/nut-scanner/README, tools/nut- scanner/nut-scan.h, tools/nut-scanner/nut-scanner.c, tools/nut- - scanner/nutscan-device.c, tools/nut-scanner/nutscan-device.h, tools - /nut-scanner/nutscan-display.c, tools/nut-scanner/nutscan-init.c, - tools/nut-scanner/nutscan-init.h, tools/nut-scanner/nutscan-ip.c, - tools/nut-scanner/nutscan-ip.h, tools/nut-scanner/scan_avahi.c, - tools/nut-scanner/scan_ipmi.c, tools/nut-scanner/scan_nut.c, tools - /nut-scanner/scan_snmp.c, tools/nut-scanner/scan_usb.c, tools/nut- - scanner/scan_xml_http.c, tools/nut-snmpinfo.py, tools/nut- - usbinfo.pl, tools/svn2cl.authors: Merge from trunk [[SVN:2848]] to - [[SVN:3679]] to ssl-nss-port. Note: a problem is occurring for - server/ssl.[h|c]: they have been moved to server/netssl.[h|c] but - consider them as removed. For the branch merging to trunk, - consider paying attention to the case of these files (removing them - by hand). + scanner/nutscan-device.c, tools/nut-scanner/nutscan-device.h, + tools/nut-scanner/nutscan-display.c, tools/nut-scanner/nutscan- + init.c, tools/nut-scanner/nutscan-init.h, tools/nut- + scanner/nutscan-ip.c, tools/nut-scanner/nutscan-ip.h, tools/nut- + scanner/scan_avahi.c, tools/nut-scanner/scan_ipmi.c, tools/nut- + scanner/scan_nut.c, tools/nut-scanner/scan_snmp.c, tools/nut- + scanner/scan_usb.c, tools/nut-scanner/scan_xml_http.c, tools/nut- + snmpinfo.py, tools/nut-usbinfo.pl, tools/svn2cl.authors: Merge from + trunk [[SVN:2848]] to [[SVN:3679]] to ssl-nss-port. Note: a + problem is occurring for server/ssl.[h|c]: they have been moved to + server/netssl.[h|c] but consider them as removed. For the branch + merging to trunk, consider paying attention to the case of these + files (removing them by hand). 2012-07-17 Arnaud Quette @@ -4641,8 +20498,8 @@ 2012-07-16 Arnaud Quette * drivers/nut-ipmipsu.c, drivers/nut-libfreeipmi.c, - m4/nut_check_libfreeipmi.m4, tools/nut-scanner/nut-scanner.c, tools - /nut-scanner/scan_ipmi.c: Support for FreeIPMI 1.1.x and 1.2.x + m4/nut_check_libfreeipmi.m4, tools/nut-scanner/nut-scanner.c, + tools/nut-scanner/scan_ipmi.c: Support for FreeIPMI 1.1.x and 1.2.x Prepare for supporting API changes in FreeIPMI 1.1.x and 1.2.x. This is mostly related to SDR API simplifications. A 2nd iteration will probably address code redundancy, whenever possible @@ -4821,11 +20678,11 @@ 2012-05-29 Prachi Gandhi - * Makefile.am, configure.in, tools/nut-scanner/Makefile.am, tools - /nut-scanner/nut-scan.h, tools/nut-scanner/nutscan-init.c, tools - /nut-scanner/nutscan-init.h, tools/nut-scanner/scan_snmp.c: Changes - in nut-scanner to remove Sparc 'usmAESPrivProtocol' error while - creating package + * Makefile.am, configure.in, tools/nut-scanner/Makefile.am, + tools/nut-scanner/nut-scan.h, tools/nut-scanner/nutscan-init.c, + tools/nut-scanner/nutscan-init.h, tools/nut-scanner/scan_snmp.c: + Changes in nut-scanner to remove Sparc 'usmAESPrivProtocol' error + while creating package 2012-05-29 Arnaud Quette @@ -5136,16 +20993,16 @@ * tools/nut-scanner/nut-scanner.c, tools/nut-scanner/nutscan-init.c, tools/nut-scanner/nutscan-init.h, tools/nut-scanner/scan_avahi.c, - tools/nut-scanner/scan_ipmi.c, tools/nut-scanner/scan_nut.c, tools - /nut-scanner/scan_snmp.c, tools/nut-scanner/scan_usb.c, tools/nut- - scanner/scan_xml_http.c: Cleaner exit for nut-scanner + tools/nut-scanner/scan_ipmi.c, tools/nut-scanner/scan_nut.c, + tools/nut-scanner/scan_snmp.c, tools/nut-scanner/scan_usb.c, + tools/nut-scanner/scan_xml_http.c: Cleaner exit for nut-scanner 2012-04-23 Frederic Bohe * tools/nut-scanner/scan_avahi.c, tools/nut-scanner/scan_ipmi.c, - tools/nut-scanner/scan_nut.c, tools/nut-scanner/scan_snmp.c, tools - /nut-scanner/scan_usb.c, tools/nut-scanner/scan_xml_http.c: Be more - verbose when failing to dynamically load a library + tools/nut-scanner/scan_nut.c, tools/nut-scanner/scan_snmp.c, + tools/nut-scanner/scan_usb.c, tools/nut-scanner/scan_xml_http.c: Be + more verbose when failing to dynamically load a library 2012-04-14 Arnaud Quette @@ -5159,8 +21016,8 @@ in Kelvin Check if raw value is in the Kelvin range, to detect buggy values that are already expressed in Celsius degrees, as found on some HP devices - * docs/developer-guide.txt, tools/Makefile.am, tools/device- - recorder.sh, tools/nut-recorder.sh: Rename device-recorder to nut- + * docs/developer-guide.txt, tools/Makefile.am, tools/{device- + recorder.sh => nut-recorder.sh}: Rename device-recorder to nut- recorder * data/driver.list.in: HCL: Reorder Dell devices by connection type @@ -5666,18 +21523,18 @@ docs/man/nutscan_scan_usb.txt, docs/man/nutscan_scan_xml_http.txt: Update documentation * tools/nut-scanner/scan_avahi.c, tools/nut-scanner/scan_ipmi.c, - tools/nut-scanner/scan_nut.c, tools/nut-scanner/scan_snmp.c, tools - /nut-scanner/scan_usb.c, tools/nut-scanner/scan_xml_http.c: Make - sure not to call any non-initialized function pointers. - * tools/nut-scanner/Makefile.am, tools/nut-scanner/nut-scan.h, tools - /nut-scanner/nut-scanner.c, tools/nut-scanner/nutscan-init.c, tools - /nut-scanner/nutscan-init.h, tools/nut-scanner/scan_avahi.c, tools - /nut-scanner/scan_ipmi.c, tools/nut-scanner/scan_snmp.c, tools/nut- - scanner/scan_usb.c, tools/nut-scanner/scan_xml_http.c: Keep the - same API whatever the library are at compile time... ...(so some - scan functions may be stub only) Add an init function + variable to - know the available scan method at run time. Update nut-scanner - accordingly. + tools/nut-scanner/scan_nut.c, tools/nut-scanner/scan_snmp.c, + tools/nut-scanner/scan_usb.c, tools/nut-scanner/scan_xml_http.c: + Make sure not to call any non-initialized function pointers. + * tools/nut-scanner/Makefile.am, tools/nut-scanner/nut-scan.h, + tools/nut-scanner/nut-scanner.c, tools/nut-scanner/nutscan-init.c, + tools/nut-scanner/nutscan-init.h, tools/nut-scanner/scan_avahi.c, + tools/nut-scanner/scan_ipmi.c, tools/nut-scanner/scan_snmp.c, + tools/nut-scanner/scan_usb.c, tools/nut-scanner/scan_xml_http.c: + Keep the same API whatever the library are at compile time... + ...(so some scan functions may be stub only) Add an init function + + variable to know the available scan method at run time. Update + nut-scanner accordingly. 2011-12-09 Arnaud Quette @@ -5745,11 +21602,11 @@ libltdl/m4/argz.m4, libltdl/m4/autobuild.m4, libltdl/m4/libtool.m4, libltdl/m4/ltdl.m4, libltdl/m4/ltoptions.m4, libltdl/m4/ltsugar.m4, libltdl/m4/ltversion.in, libltdl/m4/ltversion.m4, - libltdl/m4/lt~obsolete.m4, libltdl/slist.c, libltdl/stamp-mk, tools - /nut-scanner/Makefile.am, tools/nut-scanner/scan_avahi.c, tools - /nut-scanner/scan_snmp.c, tools/nut-scanner/scan_usb.c, tools/nut- - scanner/scan_xml_http.c: First set of modification to include - libltdl + libltdl/m4/lt~obsolete.m4, libltdl/slist.c, libltdl/stamp-mk, + tools/nut-scanner/Makefile.am, tools/nut-scanner/scan_avahi.c, + tools/nut-scanner/scan_snmp.c, tools/nut-scanner/scan_usb.c, + tools/nut-scanner/scan_xml_http.c: First set of modification to + include libltdl 2011-12-05 Arnaud Quette @@ -5862,8 +21719,9 @@ scripts/java/jNutWebAPI/pom.xml, .../jnutwebapi/NutRestProvider.java, .../jnutwebapi/RestWSApplication.java, - .../jnutwebapi/ScannerProvider.java, .../jNutWebAPI/src/main/webapp - /WEB-INF/web.xml: Initial commit of jNutWebAPI. + .../jnutwebapi/ScannerProvider.java, + .../jNutWebAPI/src/main/webapp/WEB-INF/web.xml: Initial commit of + jNutWebAPI. * scripts/java/jNut/.gitignore, scripts/java/jNut/src/main/java/org/n etworkupstools/jnut/Scanner.java: Fix a little bug with function namming (get instead of set). @@ -5959,15 +21817,15 @@ * docs/configure.txt: Add missing --with-avahi documentation * docs/Makefile.am, docs/developer-guide.txt, tools/nut- - scanner/.gitignore, tools/nut-scanner/README, tools/nut-scanner - /nut-scan.h: Add a 'NUT device discovery' chapter to the developer - guide, ... ...to document libnutscan + scanner/.gitignore, tools/nut-scanner/README, tools/nut- + scanner/nut-scan.h: Add a 'NUT device discovery' chapter to the + developer guide, ... ...to document libnutscan * configure.in: Enable Avahi automatic support, upon detection * docs/man/.gitignore, docs/man/Makefile.am, docs/man/index.txt, docs/man/nutscan.txt: Add an overview manpage for libnutscan - * configure.in, docs/Makefile.am, docs/download.txt, - docs/download.txt.in: Revert [[SVN:3272]], which breaks - distribution check, ... ...while waiting for a suitable solution + * configure.in, docs/Makefile.am, docs/{download.txt.in => + download.txt}: Revert [[SVN:3272]], which breaks distribution + check, ... ...while waiting for a suitable solution 2011-10-13 Charles Lepple @@ -5984,8 +21842,8 @@ 2011-10-11 Arnaud Quette - * configure.in, docs/Makefile.am, docs/download.txt, - docs/download.txt.in: Automate generation of the stable release + * configure.in, docs/Makefile.am, docs/{download.txt => + download.txt.in}: Automate generation of the stable release information, in the Download section 2011-10-10 Arnaud Quette @@ -6080,12 +21938,12 @@ 2011-09-20 Arnaud Quette - * server/Makefile.am, server/ctype.h, server/netcmds.h, - server/netget.c, server/netget.h, server/netinstcmd.c, - server/netinstcmd.h, server/netlist.c, server/netlist.h, - server/netmisc.c, server/netmisc.h, server/netset.c, - server/netset.h, server/netuser.c, server/netuser.h, - server/nut_ctype.h, server/ssl.c, server/ssl.h, server/upsd.c, + * server/Makefile.am, server/netcmds.h, server/netget.c, + server/netget.h, server/netinstcmd.c, server/netinstcmd.h, + server/netlist.c, server/netlist.h, server/netmisc.c, + server/netmisc.h, server/netset.c, server/netset.h, + server/netuser.c, server/netuser.h, server/{ctype.h => + nut_ctype.h}, server/ssl.c, server/ssl.h, server/upsd.c, server/upsd.h: Rename upsd internal client structure and header from ctype_t to nut_ctype_t. This avoids namespace conflict on AIX, and is more suitable in general @@ -6207,8 +22065,8 @@ * docs/FAQ.txt, docs/config-notes.txt, docs/download.txt, docs/man/Makefile.am, docs/man/apcsmart-old.txt, docs/man/apcsmart.txt, docs/stable-hcl.txt, docs/website/web- - layout.conf, drivers/Makefile.am, drivers/apcsmart-old.c, drivers - /apcsmart-old.h, drivers/apcsmart.c, drivers/apcsmart.h, + layout.conf, drivers/Makefile.am, drivers/apcsmart-old.c, + drivers/apcsmart-old.h, drivers/apcsmart.c, drivers/apcsmart.h, drivers/apcsmart_tabs.c, drivers/apcsmart_tabs.h, drivers/eaton- mib.c, drivers/eaton-mib.h, drivers/snmp-ups.c: Merge with trunk from [[SVN:3196]] @@ -6289,8 +22147,8 @@ docs/website/news.txt, docs/website/projects.txt, drivers/apc- mib.c, drivers/bestpower-mib.c, drivers/eaton-mib.c, drivers/ietf- mib.c, drivers/mge-hid.c, drivers/mge-mib.c, drivers/netvision- - mib.c, drivers/powerware-mib.c, drivers/raritan-pdu-mib.c, drivers - /snmp-ups.c, drivers/snmp-ups.h, scripts/Makefile.am, + mib.c, drivers/powerware-mib.c, drivers/raritan-pdu-mib.c, + drivers/snmp-ups.c, drivers/snmp-ups.h, scripts/Makefile.am, scripts/README, scripts/java/Makefile.am, scripts/java/README, scripts/java/jNut/README, scripts/java/jNut/pom.xml, .../main/java/org/networkupstools/jnut/Client.java, @@ -6400,8 +22258,8 @@ drivers/microdowell.c, drivers/nut-ipmi.h, drivers/nut-ipmipsu.c, drivers/nut-libfreeipmi.c, drivers/powercom.c, drivers/powercom.h, drivers/rhino.c, drivers/snmp-ups.c, drivers/solis.c, drivers/usb- - common.c, drivers/usb-common.h, include/Makefile.am, lib - /libupsclient-config.in, lib/libupsclient.pc.in, + common.c, drivers/usb-common.h, include/Makefile.am, + lib/libupsclient-config.in, lib/libupsclient.pc.in, m4/ax_create_stdint_h.m4, m4/nut_check_libfreeipmi.m4, m4/nut_report_feature.m4, scripts/Makefile.am, scripts/augeas/README, scripts/avahi/nut.service.in, @@ -6428,9 +22286,9 @@ * tools/nut-scanner/nut-scan.h, tools/nut-scanner/nut-scanner.c, tools/nut-scanner/scan_snmp.c: More API cleaning - * tools/nut-scanner/nut-scan.h, tools/nut-scanner/nutscan-ip.c, tools - /nut-scanner/nutscan-ip.h, tools/nut-scanner/scan_nut.c, tools/nut- - scanner/scan_snmp.c: Consolidating API + * tools/nut-scanner/nut-scan.h, tools/nut-scanner/nutscan-ip.c, + tools/nut-scanner/nutscan-ip.h, tools/nut-scanner/scan_nut.c, + tools/nut-scanner/scan_snmp.c: Consolidating API * configure.in, m4/nut_check_libavahi.m4, tools/nut- scanner/Makefile.am, tools/nut-scanner/nut-scan.h, tools/nut- scanner/nut-scanner.c, tools/nut-scanner/scan_avahi.c: Add avahi @@ -6485,17 +22343,16 @@ 2011-08-16 Frederic Bohe - * tools/nut-scanner/.gitignore, tools/nut-scanner/Makefile.am, tools - /nut-scanner/device.c, tools/nut-scanner/device.h, tools/nut- - scanner/display.c, tools/nut-scanner/ip.c, tools/nut-scanner/ip.h, + * tools/nut-scanner/.gitignore, tools/nut-scanner/Makefile.am, tools/nut-scanner/nut-scan.h, tools/nut-scanner/nut-scanner.c, - tools/nut-scanner/nutscan-device.c, tools/nut-scanner/nutscan- - device.h, tools/nut-scanner/nutscan-display.c, tools/nut-scanner - /nutscan-ip.c, tools/nut-scanner/nutscan-ip.h, tools/nut- - scanner/scan_avahi.c, tools/nut-scanner/scan_ipmi.c, tools/nut- - scanner/scan_nut.c, tools/nut-scanner/scan_snmp.c, tools/nut- - scanner/scan_usb.c, tools/nut-scanner/scan_xml_http.c: More - consistent API naming + tools/nut-scanner/{device.c => nutscan-device.c}, tools/nut- + scanner/{device.h => nutscan-device.h}, tools/nut- + scanner/{display.c => nutscan-display.c}, tools/nut-scanner/{ip.c + => nutscan-ip.c}, tools/nut-scanner/{ip.h => nutscan-ip.h}, + tools/nut-scanner/scan_avahi.c, tools/nut-scanner/scan_ipmi.c, + tools/nut-scanner/scan_nut.c, tools/nut-scanner/scan_snmp.c, + tools/nut-scanner/scan_usb.c, tools/nut-scanner/scan_xml_http.c: + More consistent API naming 2011-08-05 Charles Lepple @@ -6586,8 +22443,9 @@ 2011-07-08 Frederic Bohe - * tools/nut-scanner/ip.c, tools/nut-scanner/ip.h, tools/nut-scanner - /nut-scanner.c: Add an helper function to decode CIDR notation. + * tools/nut-scanner/ip.c, tools/nut-scanner/ip.h, tools/nut- + scanner/nut-scanner.c: Add an helper function to decode CIDR + notation. 2011-07-08 Charles Lepple @@ -6734,9 +22592,9 @@ 2011-06-27 Frederic Bohe - * tools/nut-scanner/device.h, tools/nut-scanner/nut-scan.h, tools - /nut-scanner/nut-scanner.c, tools/nut-scanner/scan_nut.c, tools - /nut-scanner/scan_snmp.c: Add NUT server scan. + * tools/nut-scanner/device.h, tools/nut-scanner/nut-scan.h, + tools/nut-scanner/nut-scanner.c, tools/nut-scanner/scan_nut.c, + tools/nut-scanner/scan_snmp.c: Add NUT server scan. 2011-06-22 Frederic Bohe @@ -6749,8 +22607,8 @@ * tools/nut-scanner/scan_xml_http.c: Use NUT const * tools/nut-scanner/ip.c, tools/nut-scanner/ip.h: Forgot to commit the new files for iterator - * tools/nut-scanner/Makefile.am, tools/nut-scanner/nut-scan.h, tools - /nut-scanner/scan_snmp.c: Factorize IP iterator + * tools/nut-scanner/Makefile.am, tools/nut-scanner/nut-scan.h, + tools/nut-scanner/scan_snmp.c: Factorize IP iterator * tools/nut-scanner/Makefile.am: Remove unneeded reference to *.h files * tools/Makefile.am, tools/nut-scanner/nutscan-snmp.h, tools/nut- @@ -6822,10 +22680,10 @@ scanner/display.c, tools/nut-scanner/scan_usb.c, tools/nut- scanner/scan_xml_http.c: More flexible way to manage optional parameter of each devices... ...via a simple linked list - * tools/nut-scanner/display.h, tools/nut-scanner/nut-scan.h, tools - /nut-scanner/nut-scanner.c, tools/nut-scanner/scan_avahi.h, tools - /nut-scanner/scan_ipmi.h, tools/nut-scanner/scan_nut.h, tools/nut- - scanner/scan_snmp.h, tools/nut-scanner/scan_usb.h, tools/nut- + * tools/nut-scanner/display.h, tools/nut-scanner/{scan_usb.h => nut- + scan.h}, tools/nut-scanner/nut-scanner.c, tools/nut- + scanner/scan_avahi.h, tools/nut-scanner/scan_ipmi.h, tools/nut- + scanner/scan_nut.h, tools/nut-scanner/scan_snmp.h, tools/nut- scanner/scan_xml_http.h: Keep only one file for nut-scan library interface * tools/nut-scanner/display.h: typo @@ -6837,8 +22695,8 @@ 2011-06-03 Arnaud Quette - * tools/nut-scanner/Makefile.am, tools/nut-scanner/device.c, tools - /nut-scanner/device.h, tools/nut-scanner/display.c, tools/nut- + * tools/nut-scanner/Makefile.am, tools/nut-scanner/device.c, + tools/nut-scanner/device.h, tools/nut-scanner/display.c, tools/nut- scanner/display.h, tools/nut-scanner/nut-scanner.c, tools/nut- scanner/scan_avahi.c, tools/nut-scanner/scan_avahi.h, tools/nut- scanner/scan_ipmi.c, tools/nut-scanner/scan_ipmi.h, tools/nut- @@ -7243,13 +23101,13 @@ * COPYING, INSTALL, Makefile.am, NEWS, README, UPGRADING, autogen.sh, clients/Makefile.am, configure.in, data/.gitignore, data/Makefile.am, data/driver.list.in, data/epdu-managed.dev, - data/evolution500.dev, data/evolution500.seq, docs/.gitignore, - docs/Makefile.am, docs/config-notes.txt, docs/configure.txt, docs - /developer-guide.txt, docs/docinfo.xml, docs/documentation.txt, + data/{evolution500.dev => evolution500.seq}, docs/.gitignore, + docs/Makefile.am, docs/config-notes.txt, docs/configure.txt, + docs/developer-guide.txt, docs/docinfo.xml, docs/documentation.txt, docs/download.txt, docs/history.txt, docs/images/old-cgi.png, - docs/man/.gitignore, docs/nut-names.txt, docs/stable-hcl.txt, - docs/support.txt, docs/user-manual.txt, docs/website/Makefile.am, - docs/website/news.txt, docs/website/stable-hcl.txt, + docs/man/.gitignore, docs/nut-names.txt, docs/{website => }/stable- + hcl.txt, docs/support.txt, docs/user-manual.txt, + docs/website/Makefile.am, docs/website/news.txt, docs/website/website.txt, drivers/.gitignore, drivers/Makefile.am, drivers/idowell-hid.c, drivers/idowell-hid.h, drivers/usbhid-ups.c, m4/nut_check_libhal.m4, m4/nut_check_libneon.m4, @@ -7369,49 +23227,55 @@ 2010-12-21 Emilien Kia - * INSTALL, Makefile.am, README, TODO, UPGRADING, clients/upsclient.c, - clients/upsclient.h, clients/upscmd.c, clients/upsrw.c, - conf/upsd.conf.sample, conf/upsd.users.sample, configure.in, - data/Makefile.am, data/driver.list, data/driver.list.in, - docs/.gitignore, docs/FAQ, docs/FAQ.txt, docs/Makefile.am, - docs/README, docs/acknowledgements.txt, docs/acpi.txt, - docs/asciidoc.txt, docs/big-servers.txt, docs/cables.txt, - docs/chroot.txt, docs/commands.txt, docs/config-files.txt, docs - /config-notes.txt, docs/configure.txt, docs/contact-closure.txt, - docs/data-room.txt, docs/design.txt, docs/developer-guide.txt, - docs/developers.txt, docs/documentation.txt, docs/download.txt, - docs/features.txt, docs/hid-subdrivers.txt, docs/history.txt, - docs/ideas.txt, docs/images/advanced.png, docs/images/asciidoc.png, - docs/images/bigbox.png, docs/images/bizarre.png, docs/images/blue- - arrow.png, docs/images/cables/73-0724.png, - docs/images/cables/940-0024C.jpg, + * INSTALL, Makefile.am, README, docs/ideas.txt => TODO, UPGRADING, + clients/upsclient.c, clients/upsclient.h, clients/upscmd.c, + clients/upsrw.c, conf/upsd.conf.sample, conf/upsd.users.sample, + configure.in, data/Makefile.am, data/driver.list, + data/driver.list.in, docs/.gitignore, docs/FAQ, docs/FAQ.txt, + docs/Makefile.am, docs/README, docs/acknowledgements.txt, + docs/acpi.txt, docs/asciidoc.txt, docs/big-servers.txt, + docs/cables.txt, docs/chroot.txt, docs/commands.txt, docs/config- + files.txt, docs/config-notes.txt, docs/configure.txt, docs/contact- + closure.txt, docs/data-room.txt, docs/design.txt, docs/developer- + guide.txt, docs/developers.txt, docs/documentation.txt, + docs/download.txt, docs/features.txt, docs/hid-subdrivers.txt, + docs/history.txt, docs/images/advanced.png, + docs/images/asciidoc.png, docs/images/bigbox.png, + docs/images/bizarre.png, docs/images/blue-arrow.png, + docs/images/cables/73-0724.png, docs/images/cables/940-0024C.jpg, docs/images/cables/Lansafecable.jpg, docs/images/cables/SOLA-330.png, docs/images/cables/belkin-f6cx- rkm-xu-cable.jpg, docs/images/cables/mac-940-0024C.png, docs/images/cables/mge-66049.png, docs/images/cables/mge- - db9-rj12.jpg, docs/images/cables/mge-db9-rj45.jpg, docs/images - /eaton-logo.png, docs/images/note.png, docs/images/nut-banner.png, - docs/images/nut_layering.png, docs/images/nut_layering.svg, - docs/images/simple.png, docs/images/warning.png, docs/macros.txt, - docs/man/Makefile.am, docs/man/apcsmart.txt, - docs/man/asciidoc.conf, docs/man/bcmxcp.txt, - docs/man/bcmxcp_usb.txt, docs/man/belkin.txt, - docs/man/belkinunv.txt, docs/man/bestfcom.txt, - docs/man/bestfortress.txt, docs/man/bestuferrups.txt, - docs/man/bestups.txt, docs/man/blazer.txt, docs/man/clone.txt, - docs/man/dummy-ups.txt, docs/man/etapro.txt, docs/man/everups.txt, - docs/man/gamatronic.txt, docs/man/genericups.txt, + db9-rj12.jpg, docs/images/cables/mge-db9-rj45.jpg, + docs/images/eaton-logo.png, docs/images/note.png, docs/images/nut- + banner.png, docs/images/nut_layering.png, + docs/images/nut_layering.svg, docs/images/simple.png, + docs/images/warning.png, docs/macros.txt, docs/man/Makefile.am, + man/apcsmart.8 => docs/man/apcsmart.txt, docs/man/asciidoc.conf, + docs/man/bcmxcp.txt, man/bcmxcp_usb.8 => docs/man/bcmxcp_usb.txt, + man/belkin.8 => docs/man/belkin.txt, docs/man/belkinunv.txt, + man/bestfcom.8 => docs/man/bestfcom.txt, docs/man/bestfortress.txt, + docs/man/bestuferrups.txt, man/bestups.8 => docs/man/bestups.txt, + man/blazer.8 => docs/man/blazer.txt, man/clone.8 => + docs/man/clone.txt, man/dummy-ups.8 => docs/man/dummy-ups.txt, + docs/man/etapro.txt, docs/man/everups.txt, man/gamatronic.8 => + docs/man/gamatronic.txt, man/genericups.8 => + docs/man/genericups.txt, man/hosts.conf.5 => docs/man/hosts.conf.txt, docs/man/index.txt, docs/man/isbmex.txt, - docs/man/ivtscd.txt, docs/man/libupsclient-config.txt, docs/man - /liebert-esp2.txt, docs/man/liebert.txt, docs/man/masterguard.txt, - docs/man/megatec.txt, docs/man/megatec_usb.txt, - docs/man/metasys.txt, docs/man/mge-shut.txt, docs/man/mge- - utalk.txt, docs/man/microdowell.txt, docs/man/netxml-ups.txt, - docs/man/nut.conf.txt, docs/man/nutupsdrv.txt, docs/man/oneac.txt, - docs/man/optiups.txt, docs/man/powercom.txt, docs/man/powerman- - pdu.txt, docs/man/powerpanel.txt, docs/man/rhino.txt, + docs/man/ivtscd.txt, docs/man/libupsclient-config.txt, + docs/man/liebert-esp2.txt, docs/man/liebert.txt, + docs/man/masterguard.txt, man/megatec.8 => docs/man/megatec.txt, + docs/man/megatec_usb.txt, man/metasys.8 => docs/man/metasys.txt, + docs/man/mge-shut.txt, docs/man/mge-utalk.txt, + docs/man/microdowell.txt, docs/man/netxml-ups.txt, man/nut.conf.5 + => docs/man/nut.conf.txt, docs/man/nutupsdrv.txt, man/oneac.8 => + docs/man/oneac.txt, docs/man/optiups.txt, docs/man/powercom.txt, + docs/man/powerman-pdu.txt, man/powerpanel.8 => + docs/man/powerpanel.txt, docs/man/rhino.txt, docs/man/richcomm_usb.txt, docs/man/safenet.txt, docs/man/skel.txt, - docs/man/snmp-ups.txt, docs/man/solis.txt, docs/man/tripplite.txt, + man/snmp-ups.8 => docs/man/snmp-ups.txt, docs/man/solis.txt, + man/tripplite.8 => docs/man/tripplite.txt, docs/man/tripplite_usb.txt, docs/man/tripplitesu.txt, docs/man/ups.conf.txt, docs/man/upsc.txt, docs/man/upscli_connect.txt, docs/man/upscli_disconnect.txt, @@ -7420,67 +23284,61 @@ docs/man/upscli_readline.txt, docs/man/upscli_sendline.txt, docs/man/upscli_splitaddr.txt, docs/man/upscli_splitname.txt, docs/man/upscli_ssl.txt, docs/man/upscli_strerror.txt, - docs/man/upscli_upserror.txt, docs/man/upsclient.txt, - docs/man/upscmd.txt, docs/man/upscode2.txt, docs/man/upsd.conf.txt, - docs/man/upsd.txt, docs/man/upsd.users.txt, docs/man/upsdrvctl.txt, - docs/man/upsimage.cgi.txt, docs/man/upslog.txt, - docs/man/upsmon.conf.txt, docs/man/upsmon.txt, docs/man/upsrw.txt, - docs/man/upssched.conf.txt, docs/man/upssched.txt, - docs/man/upsset.cgi.txt, docs/man/upsset.conf.txt, - docs/man/upsstats.cgi.txt, docs/man/upsstats.html.txt, docs/man - /usbhid-ups.txt, docs/man/victronups.txt, docs/megatec.txt, docs - /net-protocol.txt, docs/new-clients.txt, docs/new-drivers.txt, docs - /new-names.txt, docs/nut-names.txt, docs/nut-qa.txt, docs/osd- - notify.txt, docs/outlets.txt, docs/packager-guide.txt, - docs/pager.txt, docs/powersaving.txt, docs/protocol.txt, - docs/scheduling.txt, docs/security.txt, docs/shutdown.txt, docs - /sock-protocol.txt, docs/ssl.txt, docs/support.txt, docs/suspend- - to-disk.txt, docs/upssched.txt, docs/user-manual.txt, - docs/website/Makefile.am, docs/website/css/ie-overrides.css, - docs/website/css/web-layout.css, + docs/man/upscli_upserror.txt, docs/man/upsclient.txt, man/upscmd.8 + => docs/man/upscmd.txt, docs/man/upscode2.txt, man/upsd.conf.5 => + docs/man/upsd.conf.txt, docs/man/upsd.txt, man/upsd.users.5 => + docs/man/upsd.users.txt, man/upsdrvctl.8 => docs/man/upsdrvctl.txt, + docs/man/upsimage.cgi.txt, docs/man/upslog.txt, man/upsmon.conf.5 + => docs/man/upsmon.conf.txt, man/upsmon.8 => docs/man/upsmon.txt, + man/upsrw.8 => docs/man/upsrw.txt, docs/man/upssched.conf.txt, + man/upssched.8 => docs/man/upssched.txt, man/upsset.cgi.8 => + docs/man/upsset.cgi.txt, man/upsset.conf.5 => + docs/man/upsset.conf.txt, man/upsstats.cgi.8 => + docs/man/upsstats.cgi.txt, docs/man/upsstats.html.txt, man/usbhid- + ups.8 => docs/man/usbhid-ups.txt, docs/man/victronups.txt, + docs/megatec.txt, docs/net-protocol.txt, docs/new-clients.txt, + docs/new-drivers.txt, docs/new-names.txt, docs/nut-names.txt, + docs/nut-qa.txt, docs/osd-notify.txt, docs/outlets.txt, + docs/packager-guide.txt, docs/pager.txt, docs/powersaving.txt, + docs/protocol.txt, docs/{upssched.txt => scheduling.txt}, + docs/security.txt, docs/shutdown.txt, docs/sock-protocol.txt, + docs/ssl.txt, docs/support.txt, docs/suspend-to-disk.txt, + docs/user-manual.txt, docs/website/Makefile.am, + docs/website/css/ie-overrides.css, docs/website/css/web-layout.css, docs/website/css/xhtml11-quirks.css, docs/website/css/xhtml11.css, docs/website/faviconut.ico, docs/website/faviconut.png, docs/website/news.txt, docs/website/projects.txt, docs/website/scripts/filter_png.js, docs/website/scripts/jquery.js, docs/website/scripts/nut_jquery.js, docs/website/scripts/toc.js, docs/website/stable-hcl.txt, docs/website/ups-protocols.txt, - docs/website/web-layout.conf, docs/website/website.txt, drivers - /apc-hid.c, drivers/belkin.c, drivers/belkin.h, drivers/ietf-mib.c, - drivers/libhid.c, drivers/mge-utalk.c, drivers/powerp-bin.c, - drivers/powerware-mib.c, drivers/skel.c, drivers/snmp-ups.c, - drivers/snmp-ups.h, m4/ax_compare_version.m4, + docs/website/web-layout.conf, docs/website/website.txt, + drivers/apc-hid.c, drivers/belkin.c, drivers/belkin.h, + drivers/ietf-mib.c, drivers/libhid.c, drivers/mge-utalk.c, + drivers/powerp-bin.c, drivers/powerware-mib.c, drivers/skel.c, + drivers/snmp-ups.c, drivers/snmp-ups.h, m4/ax_compare_version.m4, m4/nut_check_asciidoc.m4, m4/nut_check_libnss.m4, m4/nut_check_libopenssl.m4, m4/nut_check_libssl.m4, - m4/nut_report_feature.m4, man/Makefile.am, man/apcsmart.8, - man/bcmxcp.8, man/bcmxcp_usb.8, man/belkin.8, man/belkinunv.8, - man/bestfcom.8, man/bestfortress.8, man/bestuferrups.8, - man/bestups.8, man/blazer.8, man/clone.8, man/dummy-ups.8, - man/etapro.8, man/everups.8, man/gamatronic.8, man/genericups.8, - man/hosts.conf.5, man/isbmex.8, man/ivtscd.8, man/libupsclient- - config.1, man/liebert-esp2.8, man/liebert.8, man/masterguard.8, - man/megatec.8, man/megatec_usb.8, man/metasys.8, man/mge-shut.8, - man/mge-utalk.8, man/microdowell.8, man/netxml-ups.8, - man/nut.conf.5, man/nutupsdrv.8, man/oneac.8, man/optiups.8, - man/powercom.8, man/powerman-pdu.8, man/powerpanel.8, man/rhino.8, - man/richcomm_usb.8, man/safenet.8, man/skel.8, man/snmp-ups.8, - man/solis.8, man/tripplite.8, man/tripplite_usb.8, - man/tripplitesu.8, man/ups.conf.5, man/upsc.8, + m4/nut_report_feature.m4, man/Makefile.am, man/bcmxcp.8, + man/belkinunv.8, man/bestfortress.8, man/bestuferrups.8, + man/etapro.8, man/everups.8, man/isbmex.8, man/ivtscd.8, + man/libupsclient-config.1, man/liebert-esp2.8, man/liebert.8, + man/masterguard.8, man/megatec_usb.8, man/mge-shut.8, man/mge- + utalk.8, man/microdowell.8, man/netxml-ups.8, man/nutupsdrv.8, + man/optiups.8, man/powercom.8, man/powerman-pdu.8, man/rhino.8, + man/richcomm_usb.8, man/safenet.8, man/skel.8, man/solis.8, + man/tripplite_usb.8, man/tripplitesu.8, man/ups.conf.5, man/upsc.8, man/upscli_connect.3, man/upscli_disconnect.3, man/upscli_fd.3, man/upscli_get.3, man/upscli_list_next.3, man/upscli_list_start.3, man/upscli_readline.3, man/upscli_sendline.3, man/upscli_splitaddr.3, man/upscli_splitname.3, man/upscli_ssl.3, man/upscli_strerror.3, man/upscli_upserror.3, man/upsclient.3, - man/upscmd.8, man/upscode2.8, man/upsd.8, man/upsd.conf.5, - man/upsd.users.5, man/upsdrvctl.8, man/upsimage.cgi.8, - man/upslog.8, man/upsmon.8, man/upsmon.conf.5, man/upsrw.8, - man/upssched.8, man/upssched.conf.5, man/upsset.cgi.8, - man/upsset.conf.5, man/upsstats.cgi.8, man/upsstats.html.5, man - /usbhid-ups.8, man/victronups.8, scripts/upower/95-upower- - hid.rules, server/Makefile.am, server/conf.c, server/ctype.h, - server/netcmds.h, server/netssl.c, server/netssl.h, server/ssl.c, - server/ssl.h, server/upsd.c, tools/Makefile.am, tools/nut- - hclinfo.py, tools/nut-usbinfo.pl, tools/svn2cl.authors: Merge from - trunk ([[SVN:2761]]) + man/upscode2.8, man/upsd.8, man/upsimage.cgi.8, man/upslog.8, + man/upssched.conf.5, man/upsstats.html.5, man/victronups.8, + scripts/upower/95-upower-hid.rules, server/Makefile.am, + server/conf.c, server/ctype.h, server/netcmds.h, server/{netssl.c + => ssl.c}, server/{netssl.h => ssl.h}, server/upsd.c, + tools/Makefile.am, tools/nut-hclinfo.py, tools/nut-usbinfo.pl, + tools/svn2cl.authors: Merge from trunk ([[SVN:2761]]) 2010-11-30 Arnaud Quette @@ -7490,9 +23348,9 @@ 2010-11-29 Arjen de Korte - * server/Makefile.am, server/conf.c, server/netcmds.h, - server/netssl.c, server/netssl.h, server/ssl.c, server/ssl.h, - server/upsd.c: Resolve namespace conflict with nss_compat_ossl + * server/Makefile.am, server/conf.c, server/netcmds.h, server/{ssl.c + => netssl.c}, server/{ssl.h => netssl.h}, server/upsd.c: Resolve + namespace conflict with nss_compat_ossl 2010-11-28 Arjen de Korte diff --git a/INSTALL b/INSTALL index 2099840..8865734 100644 --- a/INSTALL +++ b/INSTALL @@ -1,8 +1,8 @@ Installation Instructions ************************* -Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, -Inc. + Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software +Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright @@ -12,97 +12,96 @@ without warranty of any kind. Basic Installation ================== - Briefly, the shell command `./configure && make && make install' + Briefly, the shell command './configure && make && make install' should configure, build, and install this package. The following -more-detailed instructions are generic; see the `README' file for +more-detailed instructions are generic; see the 'README' file for instructions specific to this package. Some packages provide this -`INSTALL' file but do not implement all of the features documented +'INSTALL' file but do not implement all of the features documented below. The lack of an optional feature in a given package is not necessarily a bug. More recommendations for GNU packages can be found in *note Makefile Conventions: (standards)Makefile Conventions. - The `configure' shell script attempts to guess correct values for + The 'configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that +those values to create a 'Makefile' in each directory of the package. +It may also create one or more '.h' files containing system-dependent +definitions. Finally, it creates a shell script 'config.status' that you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). +file 'config.log' containing compiler output (useful mainly for +debugging 'configure'). - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. Caching is -disabled by default to prevent problems with accidental use of stale -cache files. + It can also use an optional file (typically called 'config.cache' and +enabled with '--cache-file=config.cache' or simply '-C') that saves the +results of its tests to speed up reconfiguring. Caching is disabled by +default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can +to figure out how 'configure' could check whether to do them, and mail +diffs or instructions to the address given in the 'README' so they can be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you +some point 'config.cache' contains results you don't want to keep, you may remove or edit it. - The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You need `configure.ac' if -you want to change it or regenerate `configure' using a newer version -of `autoconf'. + The file 'configure.ac' (or 'configure.in') is used to create +'configure' by a program called 'autoconf'. You need 'configure.ac' if +you want to change it or regenerate 'configure' using a newer version of +'autoconf'. The simplest way to compile this package is: - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. + 1. 'cd' to the directory containing the package's source code and type + './configure' to configure the package for your system. - Running `configure' might take a while. While running, it prints + Running 'configure' might take a while. While running, it prints some messages telling which features it is checking for. - 2. Type `make' to compile the package. + 2. Type 'make' to compile the package. - 3. Optionally, type `make check' to run any self-tests that come with + 3. Optionally, type 'make check' to run any self-tests that come with the package, generally using the just-built uninstalled binaries. - 4. Type `make install' to install the programs and any data files and + 4. Type 'make install' to install the programs and any data files and documentation. When installing into a prefix owned by root, it is recommended that the package be configured and built as a regular - user, and only the `make install' phase executed with root + user, and only the 'make install' phase executed with root privileges. - 5. Optionally, type `make installcheck' to repeat any self-tests, but + 5. Optionally, type 'make installcheck' to repeat any self-tests, but this time using the binaries in their final installed location. This target does not install anything. Running this target as a - regular user, particularly if the prior `make install' required + regular user, particularly if the prior 'make install' required root privileges, verifies that the installation completed correctly. 6. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly + source code directory by typing 'make clean'. To also remove the + files that 'configure' created (so you can compile the package for + a different kind of computer), type 'make distclean'. There is + also a 'make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. - 7. Often, you can also type `make uninstall' to remove the installed + 7. Often, you can also type 'make uninstall' to remove the installed files again. In practice, not all packages have tested that uninstallation works correctly, even though it is required by the GNU Coding Standards. - 8. Some packages, particularly those that use Automake, provide `make + 8. Some packages, particularly those that use Automake, provide 'make distcheck', which can by used by developers to test that all other - targets like `make install' and `make uninstall' work correctly. + targets like 'make install' and 'make uninstall' work correctly. This target is generally not run by end users. Compilers and Options ===================== Some systems require unusual options for compilation or linking that -the `configure' script does not know about. Run `./configure --help' +the 'configure' script does not know about. Run './configure --help' for details on some of the pertinent environment variables. - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: + You can give 'configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here is +an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix @@ -113,21 +112,21 @@ Compiling For Multiple Architectures You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their -own directory. To do this, you can use GNU `make'. `cd' to the +own directory. To do this, you can use GNU 'make'. 'cd' to the directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. This -is known as a "VPATH" build. +the 'configure' script. 'configure' automatically checks for the source +code in the directory that 'configure' is in and in '..'. This is known +as a "VPATH" build. - With a non-GNU `make', it is safer to compile the package for one + With a non-GNU 'make', it is safer to compile the package for one architecture at a time in the source code directory. After you have -installed the package for one architecture, use `make distclean' before +installed the package for one architecture, use 'make distclean' before reconfiguring for another architecture. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or -"universal" binaries--by specifying multiple `-arch' options to the -compiler but only a single `-arch' option to the preprocessor. Like +"universal" binaries--by specifying multiple '-arch' options to the +compiler but only a single '-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ @@ -136,105 +135,104 @@ this: This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results -using the `lipo' tool if you have problems. +using the 'lipo' tool if you have problems. Installation Names ================== - By default, `make install' installs the package's commands under -`/usr/local/bin', include files under `/usr/local/include', etc. You -can specify an installation prefix other than `/usr/local' by giving -`configure' the option `--prefix=PREFIX', where PREFIX must be an + By default, 'make install' installs the package's commands under +'/usr/local/bin', include files under '/usr/local/include', etc. You +can specify an installation prefix other than '/usr/local' by giving +'configure' the option '--prefix=PREFIX', where PREFIX must be an absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you -pass the option `--exec-prefix=PREFIX' to `configure', the package uses +pass the option '--exec-prefix=PREFIX' to 'configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give -options like `--bindir=DIR' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. In general, the -default for these options is expressed in terms of `${prefix}', so that -specifying just `--prefix' will affect all of the other directory +options like '--bindir=DIR' to specify different values for particular +kinds of files. Run 'configure --help' for a list of the directories +you can set and what kinds of files go in them. In general, the default +for these options is expressed in terms of '${prefix}', so that +specifying just '--prefix' will affect all of the other directory specifications that were not explicitly provided. The most portable way to affect installation locations is to pass the -correct locations to `configure'; however, many packages provide one or +correct locations to 'configure'; however, many packages provide one or both of the following shortcuts of passing variable assignments to the -`make install' command line to change installation locations without +'make install' command line to change installation locations without having to reconfigure or recompile. The first method involves providing an override variable for each -affected directory. For example, `make install +affected directory. For example, 'make install prefix=/alternate/directory' will choose an alternate location for all directory configuration variables that were expressed in terms of -`${prefix}'. Any directories that were specified during `configure', -but not in terms of `${prefix}', must each be overridden at install -time for the entire installation to be relocated. The approach of -makefile variable overrides for each directory variable is required by -the GNU Coding Standards, and ideally causes no recompilation. -However, some platforms have known limitations with the semantics of -shared libraries that end up requiring recompilation when using this -method, particularly noticeable in packages that use GNU Libtool. +'${prefix}'. Any directories that were specified during 'configure', +but not in terms of '${prefix}', must each be overridden at install time +for the entire installation to be relocated. The approach of makefile +variable overrides for each directory variable is required by the GNU +Coding Standards, and ideally causes no recompilation. However, some +platforms have known limitations with the semantics of shared libraries +that end up requiring recompilation when using this method, particularly +noticeable in packages that use GNU Libtool. - The second method involves providing the `DESTDIR' variable. For -example, `make install DESTDIR=/alternate/directory' will prepend -`/alternate/directory' before all installation names. The approach of -`DESTDIR' overrides is not required by the GNU Coding Standards, and + The second method involves providing the 'DESTDIR' variable. For +example, 'make install DESTDIR=/alternate/directory' will prepend +'/alternate/directory' before all installation names. The approach of +'DESTDIR' overrides is not required by the GNU Coding Standards, and does not work on platforms that have drive letters. On the other hand, it does better at avoiding recompilation issues, and works well even -when some directory options were not specified in terms of `${prefix}' -at `configure' time. +when some directory options were not specified in terms of '${prefix}' +at 'configure' time. Optional Features ================= If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. +with an extra prefix or suffix on their names by giving 'configure' the +option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'. - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the + Some packages pay attention to '--enable-FEATURE' options to +'configure', where FEATURE indicates an optional part of the package. +They may also pay attention to '--with-PACKAGE' options, where PACKAGE +is something like 'gnu-as' or 'x' (for the X Window System). The +'README' should mention any '--enable-' and '--with-' options that the package recognizes. - For packages that use the X Window System, `configure' can usually + For packages that use the X Window System, 'configure' can usually find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. +you can use the 'configure' options '--x-includes=DIR' and +'--x-libraries=DIR' to specify their locations. Some packages offer the ability to configure how verbose the -execution of `make' will be. For these packages, running `./configure +execution of 'make' will be. For these packages, running './configure --enable-silent-rules' sets the default to minimal output, which can be -overridden with `make V=1'; while running `./configure +overridden with 'make V=1'; while running './configure --disable-silent-rules' sets the default to verbose, which can be -overridden with `make V=0'. +overridden with 'make V=0'. Particular systems ================== - On HP-UX, the default C compiler is not ANSI C compatible. If GNU -CC is not installed, it is recommended to use the following options in + On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC +is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. - HP-UX `make' updates targets which have the same time stamps as -their prerequisites, which makes it generally unusable when shipped -generated files such as `configure' are involved. Use GNU `make' -instead. + HP-UX 'make' updates targets which have the same time stamps as their +prerequisites, which makes it generally unusable when shipped generated +files such as 'configure' are involved. Use GNU 'make' instead. On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot -parse its `' header file. The option `-nodtk' can be used as -a workaround. If GNU CC is not installed, it is therefore recommended -to try +parse its '' header file. The option '-nodtk' can be used as a +workaround. If GNU CC is not installed, it is therefore recommended to +try ./configure CC="cc" @@ -242,26 +240,26 @@ and if that doesn't work, try ./configure CC="cc -nodtk" - On Solaris, don't put `/usr/ucb' early in your `PATH'. This + On Solaris, don't put '/usr/ucb' early in your 'PATH'. This directory contains several dysfunctional programs; working variants of -these programs are available in `/usr/bin'. So, if you need `/usr/ucb' -in your `PATH', put it _after_ `/usr/bin'. +these programs are available in '/usr/bin'. So, if you need '/usr/ucb' +in your 'PATH', put it _after_ '/usr/bin'. - On Haiku, software installed for all users goes in `/boot/common', -not `/usr/local'. It is recommended to use the following options: + On Haiku, software installed for all users goes in '/boot/common', +not '/usr/local'. It is recommended to use the following options: ./configure --prefix=/boot/common Specifying the System Type ========================== - There may be some features `configure' cannot figure out + There may be some features 'configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the -_same_ architectures, `configure' can figure that out, but if it prints +_same_ architectures, 'configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: +'--build=TYPE' option. TYPE can either be a short name for the system +type, such as 'sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM @@ -270,101 +268,101 @@ where SYSTEM can have one of these forms: OS KERNEL-OS - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't + See the file 'config.sub' for the possible values of each field. If +'config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should -use the option `--target=TYPE' to select the type of system they will +use the option '--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. +eventually be run) with '--host=TYPE'. Sharing Defaults ================ - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. + If you want to set default values for 'configure' scripts to share, +you can create a site shell script called 'config.site' that gives +default values for variables like 'CC', 'cache_file', and 'prefix'. +'configure' looks for 'PREFIX/share/config.site' if it exists, then +'PREFIX/etc/config.site' if it exists. Or, you can set the +'CONFIG_SITE' environment variable to the location of the site script. +A warning: not all 'configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run +environment passed to 'configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: +them in the 'configure' command line, using 'VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc -causes the specified `gcc' to be used as the C compiler (unless it is +causes the specified 'gcc' to be used as the C compiler (unless it is overridden in the site shell script). -Unfortunately, this technique does not work for `CONFIG_SHELL' due to -an Autoconf limitation. Until the limitation is lifted, you can use -this workaround: +Unfortunately, this technique does not work for 'CONFIG_SHELL' due to an +Autoconf limitation. Until the limitation is lifted, you can use this +workaround: CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash -`configure' Invocation +'configure' Invocation ====================== - `configure' recognizes the following options to control how it + 'configure' recognizes the following options to control how it operates. -`--help' -`-h' - Print a summary of all of the options to `configure', and exit. +'--help' +'-h' + Print a summary of all of the options to 'configure', and exit. -`--help=short' -`--help=recursive' +'--help=short' +'--help=recursive' Print a summary of the options unique to this package's - `configure', and exit. The `short' variant lists options used - only in the top level, while the `recursive' variant lists options - also present in any nested packages. + 'configure', and exit. The 'short' variant lists options used only + in the top level, while the 'recursive' variant lists options also + present in any nested packages. -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' +'--version' +'-V' + Print the version of Autoconf used to generate the 'configure' script, and exit. -`--cache-file=FILE' +'--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to + traditionally 'config.cache'. FILE defaults to '/dev/null' to disable caching. -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. +'--config-cache' +'-C' + Alias for '--cache-file=config.cache'. -`--quiet' -`--silent' -`-q' +'--quiet' +'--silent' +'-q' Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error + suppress all normal output, redirect it to '/dev/null' (any error messages will still be shown). -`--srcdir=DIR' +'--srcdir=DIR' Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. + 'configure' can determine that directory automatically. -`--prefix=DIR' - Use DIR as the installation prefix. *note Installation Names:: - for more details, including other options available for fine-tuning - the installation locations. +'--prefix=DIR' + Use DIR as the installation prefix. *note Installation Names:: for + more details, including other options available for fine-tuning the + installation locations. -`--no-create' -`-n' +'--no-create' +'-n' Run the configure checks, but stop before creating any output files. -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. +'configure' also accepts some other, not widely useful, options. Run +'configure --help' for more details. diff --git a/INSTALL.nut b/INSTALL.nut index 202d1af..cd8ce6b 100644 --- a/INSTALL.nut +++ b/INSTALL.nut @@ -1,11 +1,13 @@ Installation instructions ========================= -This chapter describe the various methods for installing Network UPS Tools. +This chapter describes the various methods for installing Network UPS Tools. Whenever it is possible, prefer <>. Packagers have done an excellent and hard work at improving NUT integration into -their system. +their system. On the other hand, distributions and appliances tend to package +"official releases" of projects such as NUT, and so do not deliver latest and +greatest fixes, new drivers, bugs and other features. [[Installing_source]] Installing from source @@ -16,6 +18,13 @@ These are the essential steps for compiling and installing this software. The NUT linkdoc:packager-guide[Packager Guide], which presents the best practices for installing and integrating NUT, is also a good reading. +The link:config-prereqs.txt[Prerequisites for building NUT on different OSes] +document suggests prerequisite packages with tools and dependencies +available and needed to build and test as much as possible of NUT on +numerous platforms, written from perspective of CI testing (if you +are interested in getting updated drivers for a particular device, +you might select a sub-set of those suggestions). + [NOTE] .Keep in mind that... ================================================================================ @@ -52,7 +61,7 @@ long as you are consistent. The process for doing this varies from one system to the next, and explaining how to add users is beyond the scope of this document. -For the purposes of this document, the user name and group name +For the purposes of this document, the user name and group name will be 'ups' and 'nut' respectively. Be sure the new user is a member of the new group! If you forget to @@ -87,7 +96,7 @@ docs/configure.txt or './configure --help' for all the available options. If you alter paths with additional switches, be sure to use those -new paths while reading the rest of the steps. +new paths while reading the rest of the steps. Reference: <> from the User Manual. @@ -100,7 +109,7 @@ Build the programs This will build the NUT client and server programs and the selected drivers. It will also build any other features that were -selected during <> step above. +selected during <> step above. Installation @@ -175,7 +184,7 @@ permissions for the USB device, you may need to set up (operating system dependent) hotplugging scripts. Sample scripts and information are provided in the scripts/hotplug and scripts/udev directories. For most users, the hotplugging scripts -will be installed automatically by "make install". +will be installed automatically by "make install". (If you want to try if a driver works without setting up hotplugging, you can add the "-u root" option to upsd, upsmon, and @@ -292,25 +301,47 @@ You can either install NUT as a binary package or as a port. Binary package ^^^^^^^^^^^^^^ -To install the main component, use the following command: +To install NUT as a package execute: - # pkg_add -r nut + # pkg install nut Port ^^^^ -The port is located under /usr/ports/sysutils/nut. -To install it, use the following command: +The port is located under +sysutils/nut+. +Use +make config+ to select configuration options, e.g. to build the optional CGI scripts. +To install it, use: - # cd /usr/ports/sysutils/nut/ && make install clean + # make install clean -You have to define WITH_NUT_CGI to build the optional CGI scripts. +USB UPS on FreeBSD +^^^^^^^^^^^^^^^^^^ -Optionally, you can also install the following ports: +For USB UPS devices the NUT package/port installs devd rules in +/usr/local/etc/devd/nut-usb.conf+ to set USB device permissions. 'devd' needs to be restarted for these rules to apply: -- sysutils/nut-snmp, for the SNMP driver, -- sysutils/nut-usb, for the USB drivers, -- sysutils/nut-libupsclient, for the upsclient library. + # service devd restart + +(Re-)connect the device after restarting 'devd' and check that the USB device has the proper +permissions. Check the last entries of the system message buffer. You should +find an entry like + + # dmesg | tail + [...] + ugen0.2: at usbus0 + +The device file must be owned by group +uucp+ and must be group +read-/writable. In the example from above this would be + + # ls -Ll /dev/ugen0.2 + crw-rw---- 1 root uucp 0xa5 Mar 12 10:33 /dev/ugen0.2 + +If the permissions are not correct, verify that your device is registered in ++/usr/local/etc/devd/nut-usb.conf+. The vendor and product id can be found +using: + + # usbconfig -u 0 -a 2 dump_device_desc + +where +-u+ specifies the USB bus number and +-a+ specifies the USB device index. You are now ready to configure NUT, and start testing and using it. diff --git a/MAINTAINERS b/MAINTAINERS index b86fd4b..b2fcaf8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -38,7 +38,7 @@ S: Maintained: apcsmart, belkin, bestups, cyberpower, dummycons, P: Arnaud Quette M: aquette.dev@gmail.com M: ArnaudQuette@eaton.com -S: Maintained or Supported: dummy-ups, usbhid-ups, mge-shut, newmge-shut +S: Maintained or Supported: dummy-ups, usbhid-ups, mge-shut mge-utalk, snmp-ups, ... P: Fabio Di Niro diff --git a/Makefile.am b/Makefile.am index dd9ec33..2ea7d7f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,23 +5,33 @@ ACLOCAL_AMFLAGS = -I m4 # subdirectories to build and distribute. The order matters, as # several subdirectories depend on stuff in "common" or tools being built first -SUBDIRS = include common clients conf data tools docs drivers \ +SUBDIRS = include common clients conf data docs drivers tools \ lib scripts server tests +# Automatically update the libtool script if it becomes out-of-date +# See https://www.gnu.org/software/libtool/manual/html_node/LT_005fINIT.html +LIBTOOL_DEPS = @LIBTOOL_DEPS@ +libtool: $(LIBTOOL_DEPS) + $(SHELL) ./config.status libtool + # COPYING is included automatically. EXTRA_DIST = INSTALL.nut LICENSE-GPL2 LICENSE-GPL3 MAINTAINERS UPGRADING # ---------------------------------------------------------------------- # flags to pass to ./configure when calling "make distcheck" and "make # distcheck-light". Try to check as many features as possible! Also -# need to give hotplug-dir and udev-dir, so that staged install does -# not fail. +# need to give augeas-lenses-dir, hotplug-dir and udev-dir, so that +# staged install does not fail. DISTCHECK_FLAGS = --with-all --with-ssl --with-doc=auto DISTCHECK_LIGHT_FLAGS = --with-all=auto --with-ssl=auto --with-doc=auto +DISTCHECK_VALGRIND_FLAGS = --with-all=auto --with-ssl=auto --with-doc=skip --with-valgrind CXXFLAGS='$(CXXFLAGS) -g' CFLAGS='$(CFLAGS) -g' DISTCHECK_CONFIGURE_FLAGS = ${DISTCHECK_FLAGS} \ --with-systemdsystemunitdir='$${prefix}/lib/systemd/system' \ + --with-systemdshutdowndir='$${prefix}/lib/systemd/system-shutdown' \ + --with-systemdtmpfilesdir='$${prefix}/usr/lib/tmpfiles.d' \ + --with-augeas-lenses-dir='$${prefix}/usr/share/augeas/lenses' \ --with-hotplug-dir='$${prefix}/etc/hotplug' \ --with-udev-dir='$${prefix}/etc/udev' \ --with-devd-dir='$${prefix}/etc/devd' @@ -29,6 +39,10 @@ DISTCHECK_CONFIGURE_FLAGS = ${DISTCHECK_FLAGS} \ distcheck-light: $(MAKE) $(AM_MAKEFLAGS) DISTCHECK_FLAGS="$(DISTCHECK_LIGHT_FLAGS)" distcheck +# Make a distcheck (and check in particular) with enabled valgrind and debug info +memcheck distcheck-valgrind: + $(MAKE) $(AM_MAKEFLAGS) DISTCHECK_FLAGS="$(DISTCHECK_VALGRIND_FLAGS)" distcheck + # workaround the dist generated files that are also part of the distribution # Note that distcleancheck is disabled for now, while waiting for a proper # solution, that do not break older unix systems @@ -37,9 +51,150 @@ distcheck-light: distcleancheck: @: +# Quick alias for root dir recipe: +realclean: maintainer-clean + +# Files made by our targets: +CLEANFILES = *-spellchecked cppcheck*.xml +DISTCLEANFILES = ChangeLog + +# Most of the files generated by custom rules in the configure script +# or by autogen.sh are cleaned by the Makefile.am in their directories. +# Files below are re-created by running `configure` script and may be +# wiped by a `make distclean`: +DISTCLEANFILES += config.log configure~ +#???# configure.ac~ +DISTCLEANFILES += include/config.h.in~ + +# Files made by autotools and common rituals of the configure script, +# these are needed to run the configure script itself so are not wiped +# by a mere `make distclean`; most of these are copied by autotools +# from their installation, or made by `automake` etc. on the system +# which generates `configure`; rebuilding NUT after deleting these +# requires `autogen.sh` script to be re-run (and tools available): +MAINTAINERCLEANFILES = INSTALL +MAINTAINERCLEANFILES += aclocal.m4 config.guess config.sub +MAINTAINERCLEANFILES += configure +MAINTAINERCLEANFILES += depcomp install-sh ltmain.sh test-driver +MAINTAINERCLEANFILES += m4/libtool.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 m4/lt~obsolete.m4 +MAINTAINERCLEANFILES += Makefile.in .dirstamp include/config.h.in + +# Executed after default rules +maintainer-clean-local: + rm -f missing || true + +# Do not let $SUBDIRS/Makefile rules delete their local .deps because +# this breaks our ability to clean up (e.g. some common/.../*.Plo files +# are included by generated Makefiles from other subdirectories, so they +# should be available during their clean-up). Just in case, we make sure +# here that their sub-distcleans complete first. +distclean-local: + @for DIR in $(SUBDIRS) ; do \ + if test -f "$${DIR}/Makefile" ; then \ + echo " DISTCLEAN in $${DIR}" >&2 ; \ + ( cd "$${DIR}" && $(MAKE) -s distclean ) || exit ; \ + fi ; \ + done + rm -rf .inst tmp autom4te.cache + find "$(builddir)" -type d -name '.deps' | while read DIR ; do rm -rf "$${DIR}" ; done + +# Hook the documentation building and validating recipes +# Note: these are optionally available (as determined during configure runs) +spellcheck spellcheck-interactive: + @RES=0; \ + (cd $(builddir)/docs && $(MAKE) -s $@) || RES=$$? ; \ + (cd $(builddir)/docs/man && $(MAKE) -s $@) || RES=$$? ; \ + (cd $(builddir)/conf && $(MAKE) -s $@) || RES=$$? ; \ + (cd $(builddir)/data && $(MAKE) -s $@) || RES=$$? ; \ + exit $$RES + +# Note: the "all-docs" and "check-docs" targets may require tools not +# found by `configure` script (and so avoided by conventional recipes) +# such as PDF generators, so it should only be called at developer's +# discretion, choice and risk. The "check-man" targets covers source +# texts, man pages and HTML rendering of man pages, as enabled by tools. +doc spellcheck-sortdict \ +all-docs check-docs \ +man all-man man-man check-man man-html all-html: + cd $(builddir)/docs && $(MAKE) $@ + +check-NIT check-NIT-devel: + cd $(builddir)/tests/NIT && $(MAKE) $@ + +# This target adds syntax-checking for committed shell script files, +# to avoid surprises and delays in finding fatal typos after packaging +### +### Note: currently, shellcheck target calls check-scripts-syntax +### so when both are invoked at once, in the end the check is only +### executed once. Later it is anticipated that shellcheck would +### be implemented by requiring, configuring and calling the tool +### named "shellcheck" for even more code inspection and details. +### Still, there remains value in also checking the script syntax +### by the very version of the shell interpreter that would run +### these scripts in production usage of the resulting packages. +### +check-scripts-syntax: + @echo 'NOTE: modern bash complains about scripts using backticks (warning not error), which we ignore in NUT codebase for portability reasons: `...` obsolete, use $$(...)' + @RUNBASH=bash; if [ -x /bin/bash ]; then RUNBASH=/bin/bash ; else if [ -x /usr/bin/env ] ; then RUNBASH="/usr/bin/env bash"; fi; fi ; \ + for F in `git ls-files || find . -type f` ; do \ + case "`file "$$F"`" in \ + *"Bourne-Again shell script"*) ( set -x ; $$RUNBASH -n "$$F" ; ) ;; \ + *"POSIX shell script"*|*"shell script"*) ( set -x ; /bin/sh -n "$$F" ; ) ;; \ + esac || { RES=$$? ; echo "ERROR: Syntax check failed for script file: $$F" >&2 ; exit $$RES ; } ; \ + done + @echo 'SUCCESS: Shell scripts syntax is acceptable, no fatal issues were found' + +shellcheck-disclaimer: + @echo "===============================================================================" + @echo "NOTICE: 'make shellcheck' is currently an alias for 'make check-scripts-syntax'" + @echo "Later it may become a call to the real shellcheck tool (if available on the" + @echo "build system during the configure phase)" + @echo "===============================================================================" + +# Note: currently not part of shellcheck target, because the script below +# can test the logic with numerous SHELL_PROGS in a CI setting, and because +# check-scripts-syntax probably has checked the basic syntax above already. +shellcheck-nde: + cd $(srcdir)/tests && SERVICE_FRAMEWORK="selftest" ./nut-driver-enumerator-test.sh + +shellcheck: shellcheck-disclaimer check-scripts-syntax + +CPPCHECK = @CPPCHECK@ +if HAVE_CPPCHECK +cppcheck: cppcheck-cxx11.xml cppcheck-c99.xml + +# Let the analysis get regenerated due to any change in source; +# but note that with our different make implementations to support, +# we can not either $(shell find ...) nor blindly say e.g. *.cpp +# for each FS structure layer because e.g. there are no ./*.cpp +# in the root dir of the codebase (and so make complains there is +# `No rule to make target `*.cpp', needed by `cppcheck-cxx11.xml'`) +# +# Note that the actual `cppcheck` scan finds all files it likes +# (so if CPPCHECK_SRC_* misses something, it just won't trigger +# automagically a rebuild of the XML in developer working cycles). +CPPCHECK_SRC_H = $(top_srcdir)/*/*.h $(top_srcdir)/*/*/*.h +# CPPCHECK_SRC_H += $(top_srcdir)/*.h + +CPPCHECK_SRC_C = $(top_srcdir)/*/*.c $(top_srcdir)/*/*/*.c +# CPPCHECK_SRC_C += $(top_srcdir)/*.cpp + +CPPCHECK_SRC_CXX = $(top_srcdir)/*/*.cpp +# CPPCHECK_SRC_CXX += $(top_srcdir)/*.cpp $(top_srcdir)/*/*/*.cpp + +cppcheck-cxx11.xml: $(CPPCHECK_SRC_CXX) $(CPPCHECK_SRC_H) + $(CPPCHECK) --std=c++11 --enable=all --inconclusive --xml --xml-version=2 . 2>$@ + +cppcheck-c99.xml: $(CPPCHECK_SRC_C) $(CPPCHECK_SRC_H) + $(CPPCHECK) --std=c99 --enable=all --inconclusive --xml --xml-version=2 . 2>$@ +else !HAVE_CPPCHECK +cppcheck: + @echo "CPPCHECK analysis not available since 'cppcheck' was not found." +endif !HAVE_CPPCHECK + # ---------------------------------------------------------------------- # Automatically generate the ChangeLog from Git logs: -MAINTAINERCLEAN_FILES = ChangeLog +MAINTAINERCLEANFILES += ChangeLog # Older boundary of the ChangeLog commits range # It can be a tag ('v2.2.0'), a commit hash, a date, ... @@ -48,18 +203,30 @@ GITLOG_START_POINT=v2.6.0 # Force ChangeLog regeneration upon make dist (due to nonexistant 'dummy-stamp'), # in case it has already been generated previously +# Note that the script is hard-coded to generate "ChangeLog" in the current dir dummy-stamp: ChangeLog: tools/gitlog2changelog.py dummy-stamp - $(top_srcdir)/tools/gitlog2changelog.py $(GITLOG_START_POINT) || \ - echo "gitlog2changelog.py failed to generate the ChangeLog. See https://github.com/networkupstools/nut/commits/master" > $@ + cd $(top_builddir) && \ + ./tools/gitlog2changelog.py $(GITLOG_START_POINT) || \ + { echo "gitlog2changelog.py failed to generate the ChangeLog. See https://github.com/networkupstools/nut/commits/master" > $@ ; } + +nut_version.h include/nut_version.h: + cd $(abs_top_builddir)/include && $(MAKE) nut_version.h + +tools/gitlog2changelog.py: tools/gitlog2changelog.py.in + cd $(@D) && $(MAKE) -s $(@F) # ---------------------------------------------------------------------- # Maintainers targets: distribution signature and hashes -dist-sig: +nut-@PACKAGE_VERSION@.tar.gz: dist +nut-@PACKAGE_VERSION@.tar.gz.sig: dist-sig +nut-@PACKAGE_VERSION@.tar.gz.md5 nut-@PACKAGE_VERSION@.tar.gz.sha256: dist-hash + +dist-sig: nut-@PACKAGE_VERSION@.tar.gz rm -f nut-@PACKAGE_VERSION@.tar.gz.sig gpg --detach-sign nut-@PACKAGE_VERSION@.tar.gz -dist-hash: +dist-hash: nut-@PACKAGE_VERSION@.tar.gz md5sum nut-@PACKAGE_VERSION@.tar.gz > nut-@PACKAGE_VERSION@.tar.gz.md5 sha256sum nut-@PACKAGE_VERSION@.tar.gz > nut-@PACKAGE_VERSION@.tar.gz.sha256 @@ -101,7 +268,7 @@ install-dirs: @echo "Warning: 'make install-dirs' is deprecated." @echo "Use 'make installdirs' instead." @echo $(WARN) - make installdirs + $(MAKE) installdirs cgi build-cgi install-cgi install-cgi-dir install-cgi-bin \ install-cgi-man install-cgi-conf install-cgi-html: @echo "Error: 'make $@' no longer exists." @@ -117,23 +284,65 @@ snmp build-snmp install-snmp install-snmp-mgr install-snmp-man: @echo "Use './configure --with-snmp' instead." setver: @echo "Error: 'make setver' no longer exists." - @echo "Edit configure.in to set version number." -package: - if test `uname -s` = "HP-UX"; then \ - cd scripts/HP-UX; \ - make package; \ - mv NUT_HPUX_package.depot NUT_HPUX_package@PACKAGE_VERSION@.depot; \ - elif test `uname -s` = "SunOS"; then \ - make; \ - rm -rf @prefix@; \ - make install; \ - cd scripts/Solaris; \ - make package; \ - make uninstall; \ - rm -rf @prefix@; \ - elif test `uname -s` = "AIX"; then \ - make dist; \ - cp scripts/Aix/nut-aix.spec /usr/src/packages/SPECS; \ - cp scripts/Aix/nut.init nut-*.tar.gz /usr/src/packages/SOURCES; \ - rpm -ba /usr/src/packages/SPECS/nut-aix.spec; \ - fi; + @echo "Edit configure.ac to set version number." + +# Clean the dist tarball and packages +MAINTAINERCLEANFILES_DISTBALL = nut-*.tar.gz +# HP-UX: +MAINTAINERCLEANFILES_PACKAGES = NUT_HPUX_package@PACKAGE_VERSION@.depot +# AIX as below, and RedHat-compatible (cover binary and source packages): +MAINTAINERCLEANFILES_PACKAGES += nut*rpm +# Debian-compatible (cover binary and source packages): +MAINTAINERCLEANFILES_PACKAGES += nut*deb +# Solaris SVR4 package archives: +MAINTAINERCLEANFILES_PACKAGES += NUT_solaris_*_package@PACKAGE_VERSION@.local.gz +# Newer Solaris IPS (aka "pkg(5)" format archives) +MAINTAINERCLEANFILES_PACKAGES += *.p5p + +MAINTAINERCLEANFILES += $(MAINTAINERCLEANFILES_DISTBALL) +MAINTAINERCLEANFILES += $(MAINTAINERCLEANFILES_PACKAGES) + +package: dist + DESTDIR="$(abs_builddir)/_install_pkgprotodir" ; export DESTDIR; \ + rm -rf "$$DESTDIR"; \ + case "`uname -s`" in \ + "HP-UX") \ + ( cd scripts/HP-UX && \ + $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$DESTDIR" package && \ + mv NUT_HPUX_package.depot $(abs_top_builddir)/NUT_HPUX_package@PACKAGE_VERSION@.depot ) ;; \ + "SunOS") \ + $(MAKE) $(AM_MAKEFLAGS) && \ + $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$DESTDIR" install && \ + ( cd scripts/Solaris && \ + $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$DESTDIR" package ) && \ + $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$DESTDIR" uninstall && \ + rm -rf "$$DESTDIR" || \ + { echo "FAILED to produce SunOS packages, inspect '$$DESTDIR' for clues" >&2 ; exit 1; } ;; \ + "AIX") \ + if test -d /usr/src/packages/SPECS -a -w /usr/src/packages/SPECS ; then : ; else echo "Can not write to /usr/src/packages/SPECS" >&2 ; exit 1; fi ; \ + if test -d /usr/src/packages/SOURCES -a -w /usr/src/packages/SOURCES ; then : ; else echo "Can not write to /usr/src/packages/SOURCES" >&2 ; exit 1; fi ; \ + $(MAKE) $(AM_MAKEFLAGS) dist && \ + cp scripts/Aix/nut-aix.spec /usr/src/packages/SPECS && \ + cp scripts/Aix/nut.init nut-@PACKAGE_VERSION@.tar.gz /usr/src/packages/SOURCES && \ + rpm -ba /usr/src/packages/SPECS/nut-aix.spec && \ + mv /usr/src/packages/RPMS/nut*rpm $(abs_top_builddir)/ ;; \ + *) echo "Unsupported OS for 'make $@' (no recipe bound)" >&2; exit 1;; \ + esac + +print-MAINTAINERCLEANFILES print-REALCLEANFILES: + @echo $(MAINTAINERCLEANFILES) + +print-DISTCLEANFILES: + @echo $(DISTCLEANFILES) + +# TODO: Recursive mode to consider patterns defined in sub-dir makefiles +git-realclean-check: + @if test -e .git && (command -v git); then \ + git status --ignored || while read F ; do \ + for P in $(MAINTAINERCLEANFILES) ; do \ + case "$$F" in \ + */$$P) exit 1 ;; \ + esac ; \ + done; \ + done ; \ + fi diff --git a/Makefile.in b/Makefile.in index 6b39990..2919b26 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.16.3 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -16,7 +16,17 @@ # top-level Makefile for NUT VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -81,27 +91,24 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = . -DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \ - $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(top_srcdir)/configure $(am__configure_deps) \ - $(top_srcdir)/scripts/Aix/nut-aix.spec.in \ - $(top_srcdir)/scripts/avahi/nut.service.in \ - $(top_srcdir)/scripts/HP-UX/nut.psf.in \ - $(top_srcdir)/scripts/HP-UX/postinstall.in \ - $(top_srcdir)/scripts/ufw/nut.ufw.profile.in COPYING TODO \ - compile config.guess config.sub depcomp install-sh missing \ - ltmain.sh ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nut_arg_with.m4 \ $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ $(top_srcdir)/m4/nut_check_libavahi.m4 \ $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ $(top_srcdir)/m4/nut_check_libgd.m4 \ $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ $(top_srcdir)/m4/nut_check_libneon.m4 \ $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ $(top_srcdir)/m4/nut_check_libnss.m4 \ @@ -110,18 +117,29 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ $(top_srcdir)/m4/nut_check_libusb.m4 \ $(top_srcdir)/m4/nut_check_libwrap.m4 \ $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ $(top_srcdir)/m4/nut_type_socklen_t.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ + $(am__configure_deps) $(am__DIST_COMMON) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = scripts/Aix/nut-aix.spec \ scripts/avahi/nut.service scripts/HP-UX/nut.psf \ - scripts/HP-UX/postinstall scripts/ufw/nut.ufw.profile + scripts/python/module/PyNUT.py scripts/Aix/nut.init \ + scripts/HP-UX/postinstall \ + scripts/python/app/NUT-Monitor-py2gtk2 \ + scripts/python/app/NUT-Monitor-py3qt5 \ + scripts/python/module/test_nutclient.py CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) @@ -157,7 +175,7 @@ am__recursive_targets = \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - cscope distdir dist dist-all distcheck + cscope distdir distdir-am dist dist-all distcheck am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is @@ -179,6 +197,18 @@ ETAGS = etags CTAGS = ctags CSCOPE = cscope DIST_SUBDIRS = $(SUBDIRS) +am__DIST_COMMON = $(srcdir)/Makefile.in \ + $(top_srcdir)/scripts/Aix/nut-aix.spec.in \ + $(top_srcdir)/scripts/Aix/nut.init.in \ + $(top_srcdir)/scripts/HP-UX/nut.psf.in \ + $(top_srcdir)/scripts/HP-UX/postinstall.in \ + $(top_srcdir)/scripts/avahi/nut.service.in \ + $(top_srcdir)/scripts/python/app/NUT-Monitor-py2gtk2.in \ + $(top_srcdir)/scripts/python/app/NUT-Monitor-py3qt5.in \ + $(top_srcdir)/scripts/python/module/PyNUT.py.in \ + $(top_srcdir)/scripts/python/module/test_nutclient.py.in \ + AUTHORS COPYING ChangeLog INSTALL NEWS README TODO compile \ + config.guess config.sub depcomp install-sh ltmain.sh missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) @@ -217,6 +247,8 @@ am__relativize = \ DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best DIST_TARGETS = dist-gzip +# Exists only to be overridden by the user if desired. +AM_DISTCHECK_DVI_TARGET = dvi distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' @@ -228,6 +260,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -238,6 +271,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -251,6 +285,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -263,6 +298,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -280,6 +316,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -290,21 +328,32 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ + +# Automatically update the libtool script if it becomes out-of-date +# See https://www.gnu.org/software/libtool/manual/html_node/LT_005fINIT.html +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -324,6 +373,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -337,6 +389,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -354,6 +407,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -367,6 +421,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -392,12 +449,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -413,7 +472,7 @@ ACLOCAL_AMFLAGS = -I m4 # subdirectories to build and distribute. The order matters, as # several subdirectories depend on stuff in "common" or tools being built first -SUBDIRS = include common clients conf data tools docs drivers \ +SUBDIRS = include common clients conf data docs drivers tools \ lib scripts server tests @@ -423,20 +482,62 @@ EXTRA_DIST = INSTALL.nut LICENSE-GPL2 LICENSE-GPL3 MAINTAINERS UPGRADING # ---------------------------------------------------------------------- # flags to pass to ./configure when calling "make distcheck" and "make # distcheck-light". Try to check as many features as possible! Also -# need to give hotplug-dir and udev-dir, so that staged install does -# not fail. +# need to give augeas-lenses-dir, hotplug-dir and udev-dir, so that +# staged install does not fail. DISTCHECK_FLAGS = --with-all --with-ssl --with-doc=auto DISTCHECK_LIGHT_FLAGS = --with-all=auto --with-ssl=auto --with-doc=auto +DISTCHECK_VALGRIND_FLAGS = --with-all=auto --with-ssl=auto --with-doc=skip --with-valgrind CXXFLAGS='$(CXXFLAGS) -g' CFLAGS='$(CFLAGS) -g' DISTCHECK_CONFIGURE_FLAGS = ${DISTCHECK_FLAGS} \ --with-systemdsystemunitdir='$${prefix}/lib/systemd/system' \ + --with-systemdshutdowndir='$${prefix}/lib/systemd/system-shutdown' \ + --with-systemdtmpfilesdir='$${prefix}/usr/lib/tmpfiles.d' \ + --with-augeas-lenses-dir='$${prefix}/usr/share/augeas/lenses' \ --with-hotplug-dir='$${prefix}/etc/hotplug' \ --with-udev-dir='$${prefix}/etc/udev' \ --with-devd-dir='$${prefix}/etc/devd' +# Files made by our targets: +CLEANFILES = *-spellchecked cppcheck*.xml + +# Most of the files generated by custom rules in the configure script +# or by autogen.sh are cleaned by the Makefile.am in their directories. +# Files below are re-created by running `configure` script and may be +# wiped by a `make distclean`: +#???# configure.ac~ +DISTCLEANFILES = ChangeLog config.log configure~ include/config.h.in~ + +# Files made by autotools and common rituals of the configure script, +# these are needed to run the configure script itself so are not wiped +# by a mere `make distclean`; most of these are copied by autotools +# from their installation, or made by `automake` etc. on the system +# which generates `configure`; rebuilding NUT after deleting these +# requires `autogen.sh` script to be re-run (and tools available): + # ---------------------------------------------------------------------- # Automatically generate the ChangeLog from Git logs: -MAINTAINERCLEAN_FILES = ChangeLog +MAINTAINERCLEANFILES = INSTALL aclocal.m4 config.guess config.sub \ + configure depcomp install-sh ltmain.sh test-driver \ + m4/libtool.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 \ + m4/lt~obsolete.m4 Makefile.in .dirstamp include/config.h.in \ + ChangeLog $(MAINTAINERCLEANFILES_DISTBALL) \ + $(MAINTAINERCLEANFILES_PACKAGES) + +# Let the analysis get regenerated due to any change in source; +# but note that with our different make implementations to support, +# we can not either $(shell find ...) nor blindly say e.g. *.cpp +# for each FS structure layer because e.g. there are no ./*.cpp +# in the root dir of the codebase (and so make complains there is +# `No rule to make target `*.cpp', needed by `cppcheck-cxx11.xml'`) +# +# Note that the actual `cppcheck` scan finds all files it likes +# (so if CPPCHECK_SRC_* misses something, it just won't trigger +# automagically a rebuild of the XML in developer working cycles). +@HAVE_CPPCHECK_TRUE@CPPCHECK_SRC_H = $(top_srcdir)/*/*.h $(top_srcdir)/*/*/*.h +# CPPCHECK_SRC_H += $(top_srcdir)/*.h +@HAVE_CPPCHECK_TRUE@CPPCHECK_SRC_C = $(top_srcdir)/*/*.c $(top_srcdir)/*/*/*.c +# CPPCHECK_SRC_C += $(top_srcdir)/*.cpp +@HAVE_CPPCHECK_TRUE@CPPCHECK_SRC_CXX = $(top_srcdir)/*/*.cpp # Older boundary of the ChangeLog commits range # It can be a tag ('v2.2.0'), a commit hash, a date, ... @@ -447,6 +548,17 @@ GITLOG_START_POINT = v2.6.0 # targets from old build system (pre-automake). # supported for a period of time for backward "compatibility". WARN = "----------------------------------------------------------------------" + +# Clean the dist tarball and packages +MAINTAINERCLEANFILES_DISTBALL = nut-*.tar.gz +# HP-UX: +# AIX as below, and RedHat-compatible (cover binary and source packages): +# Debian-compatible (cover binary and source packages): +# Solaris SVR4 package archives: +# Newer Solaris IPS (aka "pkg(5)" format archives) +MAINTAINERCLEANFILES_PACKAGES = \ + NUT_HPUX_package@PACKAGE_VERSION@.depot nut*rpm nut*deb \ + NUT_solaris_*_package@PACKAGE_VERSION@.local.gz *.p5p all: all-recursive .SUFFIXES: @@ -465,15 +577,14 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -490,9 +601,17 @@ scripts/avahi/nut.service: $(top_builddir)/config.status $(top_srcdir)/scripts/a cd $(top_builddir) && $(SHELL) ./config.status $@ scripts/HP-UX/nut.psf: $(top_builddir)/config.status $(top_srcdir)/scripts/HP-UX/nut.psf.in cd $(top_builddir) && $(SHELL) ./config.status $@ +scripts/python/module/PyNUT.py: $(top_builddir)/config.status $(top_srcdir)/scripts/python/module/PyNUT.py.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +scripts/Aix/nut.init: $(top_builddir)/config.status $(top_srcdir)/scripts/Aix/nut.init.in + cd $(top_builddir) && $(SHELL) ./config.status $@ scripts/HP-UX/postinstall: $(top_builddir)/config.status $(top_srcdir)/scripts/HP-UX/postinstall.in cd $(top_builddir) && $(SHELL) ./config.status $@ -scripts/ufw/nut.ufw.profile: $(top_builddir)/config.status $(top_srcdir)/scripts/ufw/nut.ufw.profile.in +scripts/python/app/NUT-Monitor-py2gtk2: $(top_builddir)/config.status $(top_srcdir)/scripts/python/app/NUT-Monitor-py2gtk2.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +scripts/python/app/NUT-Monitor-py3qt5: $(top_builddir)/config.status $(top_srcdir)/scripts/python/app/NUT-Monitor-py3qt5.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +scripts/python/module/test_nutclient.py: $(top_builddir)/config.status $(top_srcdir)/scripts/python/module/test_nutclient.py.in cd $(top_builddir) && $(SHELL) ./config.status $@ mostlyclean-libtool: @@ -610,7 +729,10 @@ distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -rm -f cscope.out cscope.in.out cscope.po.out cscope.files -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @@ -675,7 +797,7 @@ distdir: $(DISTFILES) ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir @@ -690,18 +812,22 @@ dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) +dist-zstd: distdir + tardir=$(distdir) && $(am__tar) | zstd -c $${ZSTD_CLEVEL-$${ZSTD_OPT--19}} >$(distdir).tar.zst + $(am__post_remove_distdir) + dist-tarZ: distdir - @echo WARNING: "Support for shar distribution archives is" \ - "deprecated." >&2 + @echo WARNING: "Support for distribution archives compressed with" \ + "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir - @echo WARNING: "Support for distribution archives compressed with" \ - "legacy program 'compress' is deprecated." >&2 + @echo WARNING: "Support for shar distribution archives is" \ + "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 - shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir @@ -719,7 +845,7 @@ dist dist-all: distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ + eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ @@ -729,25 +855,27 @@ distcheck: dist *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ + eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ + *.tar.zst*) \ + zstd -dc $(distdir).tar.zst | $(am__untar) ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) - mkdir $(distdir)/_build $(distdir)/_inst + mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ - && $(am__cd) $(distdir)/_build \ - && ../configure \ + && $(am__cd) $(distdir)/_build/sub \ + && ../../configure \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ - --srcdir=.. --prefix="$$dc_install_base" \ + --srcdir=../.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) $(AM_DISTCHECK_DVI_TARGET) \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ @@ -816,14 +944,17 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am @@ -832,7 +963,7 @@ distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-libtool \ - distclean-tags + distclean-local distclean-tags dvi: dvi-recursive @@ -876,7 +1007,8 @@ maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic +maintainer-clean-am: distclean-am maintainer-clean-generic \ + maintainer-clean-local mostlyclean: mostlyclean-recursive @@ -898,22 +1030,32 @@ uninstall-am: am--refresh check check-am clean clean-cscope clean-generic \ clean-libtool cscope cscopelist-am ctags ctags-am dist \ dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \ - dist-xz dist-zip distcheck distclean distclean-generic \ - distclean-libtool distclean-tags distcleancheck distdir \ - distuninstallcheck dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ - ps ps-am tags tags-am uninstall uninstall-am + dist-xz dist-zip dist-zstd distcheck distclean \ + distclean-generic distclean-libtool distclean-local \ + distclean-tags distcleancheck distdir distuninstallcheck dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic \ + maintainer-clean-local mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am +.PRECIOUS: Makefile + +libtool: $(LIBTOOL_DEPS) + $(SHELL) ./config.status libtool distcheck-light: $(MAKE) $(AM_MAKEFLAGS) DISTCHECK_FLAGS="$(DISTCHECK_LIGHT_FLAGS)" distcheck +# Make a distcheck (and check in particular) with enabled valgrind and debug info +memcheck distcheck-valgrind: + $(MAKE) $(AM_MAKEFLAGS) DISTCHECK_FLAGS="$(DISTCHECK_VALGRIND_FLAGS)" distcheck + # workaround the dist generated files that are also part of the distribution # Note that distcleancheck is disabled for now, while waiting for a proper # solution, that do not break older unix systems @@ -922,20 +1064,125 @@ distcheck-light: distcleancheck: @: +# Quick alias for root dir recipe: +realclean: maintainer-clean + +# Executed after default rules +maintainer-clean-local: + rm -f missing || true + +# Do not let $SUBDIRS/Makefile rules delete their local .deps because +# this breaks our ability to clean up (e.g. some common/.../*.Plo files +# are included by generated Makefiles from other subdirectories, so they +# should be available during their clean-up). Just in case, we make sure +# here that their sub-distcleans complete first. +distclean-local: + @for DIR in $(SUBDIRS) ; do \ + if test -f "$${DIR}/Makefile" ; then \ + echo " DISTCLEAN in $${DIR}" >&2 ; \ + ( cd "$${DIR}" && $(MAKE) -s distclean ) || exit ; \ + fi ; \ + done + rm -rf .inst tmp autom4te.cache + find "$(builddir)" -type d -name '.deps' | while read DIR ; do rm -rf "$${DIR}" ; done + +# Hook the documentation building and validating recipes +# Note: these are optionally available (as determined during configure runs) +spellcheck spellcheck-interactive: + @RES=0; \ + (cd $(builddir)/docs && $(MAKE) -s $@) || RES=$$? ; \ + (cd $(builddir)/docs/man && $(MAKE) -s $@) || RES=$$? ; \ + (cd $(builddir)/conf && $(MAKE) -s $@) || RES=$$? ; \ + (cd $(builddir)/data && $(MAKE) -s $@) || RES=$$? ; \ + exit $$RES + +# Note: the "all-docs" and "check-docs" targets may require tools not +# found by `configure` script (and so avoided by conventional recipes) +# such as PDF generators, so it should only be called at developer's +# discretion, choice and risk. The "check-man" targets covers source +# texts, man pages and HTML rendering of man pages, as enabled by tools. +doc spellcheck-sortdict \ +all-docs check-docs \ +man all-man man-man check-man man-html all-html: + cd $(builddir)/docs && $(MAKE) $@ + +check-NIT check-NIT-devel: + cd $(builddir)/tests/NIT && $(MAKE) $@ + +# This target adds syntax-checking for committed shell script files, +# to avoid surprises and delays in finding fatal typos after packaging +### +### Note: currently, shellcheck target calls check-scripts-syntax +### so when both are invoked at once, in the end the check is only +### executed once. Later it is anticipated that shellcheck would +### be implemented by requiring, configuring and calling the tool +### named "shellcheck" for even more code inspection and details. +### Still, there remains value in also checking the script syntax +### by the very version of the shell interpreter that would run +### these scripts in production usage of the resulting packages. +### +check-scripts-syntax: + @echo 'NOTE: modern bash complains about scripts using backticks (warning not error), which we ignore in NUT codebase for portability reasons: `...` obsolete, use $$(...)' + @RUNBASH=bash; if [ -x /bin/bash ]; then RUNBASH=/bin/bash ; else if [ -x /usr/bin/env ] ; then RUNBASH="/usr/bin/env bash"; fi; fi ; \ + for F in `git ls-files || find . -type f` ; do \ + case "`file "$$F"`" in \ + *"Bourne-Again shell script"*) ( set -x ; $$RUNBASH -n "$$F" ; ) ;; \ + *"POSIX shell script"*|*"shell script"*) ( set -x ; /bin/sh -n "$$F" ; ) ;; \ + esac || { RES=$$? ; echo "ERROR: Syntax check failed for script file: $$F" >&2 ; exit $$RES ; } ; \ + done + @echo 'SUCCESS: Shell scripts syntax is acceptable, no fatal issues were found' + +shellcheck-disclaimer: + @echo "===============================================================================" + @echo "NOTICE: 'make shellcheck' is currently an alias for 'make check-scripts-syntax'" + @echo "Later it may become a call to the real shellcheck tool (if available on the" + @echo "build system during the configure phase)" + @echo "===============================================================================" + +# Note: currently not part of shellcheck target, because the script below +# can test the logic with numerous SHELL_PROGS in a CI setting, and because +# check-scripts-syntax probably has checked the basic syntax above already. +shellcheck-nde: + cd $(srcdir)/tests && SERVICE_FRAMEWORK="selftest" ./nut-driver-enumerator-test.sh + +shellcheck: shellcheck-disclaimer check-scripts-syntax +@HAVE_CPPCHECK_TRUE@cppcheck: cppcheck-cxx11.xml cppcheck-c99.xml +# CPPCHECK_SRC_CXX += $(top_srcdir)/*.cpp $(top_srcdir)/*/*/*.cpp + +@HAVE_CPPCHECK_TRUE@cppcheck-cxx11.xml: $(CPPCHECK_SRC_CXX) $(CPPCHECK_SRC_H) +@HAVE_CPPCHECK_TRUE@ $(CPPCHECK) --std=c++11 --enable=all --inconclusive --xml --xml-version=2 . 2>$@ + +@HAVE_CPPCHECK_TRUE@cppcheck-c99.xml: $(CPPCHECK_SRC_C) $(CPPCHECK_SRC_H) +@HAVE_CPPCHECK_TRUE@ $(CPPCHECK) --std=c99 --enable=all --inconclusive --xml --xml-version=2 . 2>$@ +@HAVE_CPPCHECK_FALSE@cppcheck: +@HAVE_CPPCHECK_FALSE@ @echo "CPPCHECK analysis not available since 'cppcheck' was not found." + # Force ChangeLog regeneration upon make dist (due to nonexistant 'dummy-stamp'), # in case it has already been generated previously +# Note that the script is hard-coded to generate "ChangeLog" in the current dir dummy-stamp: ChangeLog: tools/gitlog2changelog.py dummy-stamp - $(top_srcdir)/tools/gitlog2changelog.py $(GITLOG_START_POINT) || \ - echo "gitlog2changelog.py failed to generate the ChangeLog. See https://github.com/networkupstools/nut/commits/master" > $@ + cd $(top_builddir) && \ + ./tools/gitlog2changelog.py $(GITLOG_START_POINT) || \ + { echo "gitlog2changelog.py failed to generate the ChangeLog. See https://github.com/networkupstools/nut/commits/master" > $@ ; } + +nut_version.h include/nut_version.h: + cd $(abs_top_builddir)/include && $(MAKE) nut_version.h + +tools/gitlog2changelog.py: tools/gitlog2changelog.py.in + cd $(@D) && $(MAKE) -s $(@F) # ---------------------------------------------------------------------- # Maintainers targets: distribution signature and hashes -dist-sig: +nut-@PACKAGE_VERSION@.tar.gz: dist +nut-@PACKAGE_VERSION@.tar.gz.sig: dist-sig +nut-@PACKAGE_VERSION@.tar.gz.md5 nut-@PACKAGE_VERSION@.tar.gz.sha256: dist-hash + +dist-sig: nut-@PACKAGE_VERSION@.tar.gz rm -f nut-@PACKAGE_VERSION@.tar.gz.sig gpg --detach-sign nut-@PACKAGE_VERSION@.tar.gz -dist-hash: +dist-hash: nut-@PACKAGE_VERSION@.tar.gz md5sum nut-@PACKAGE_VERSION@.tar.gz > nut-@PACKAGE_VERSION@.tar.gz.md5 sha256sum nut-@PACKAGE_VERSION@.tar.gz > nut-@PACKAGE_VERSION@.tar.gz.sha256 @@ -971,7 +1218,7 @@ install-dirs: @echo "Warning: 'make install-dirs' is deprecated." @echo "Use 'make installdirs' instead." @echo $(WARN) - make installdirs + $(MAKE) installdirs cgi build-cgi install-cgi install-cgi-dir install-cgi-bin \ install-cgi-man install-cgi-conf install-cgi-html: @echo "Error: 'make $@' no longer exists." @@ -987,26 +1234,52 @@ snmp build-snmp install-snmp install-snmp-mgr install-snmp-man: @echo "Use './configure --with-snmp' instead." setver: @echo "Error: 'make setver' no longer exists." - @echo "Edit configure.in to set version number." -package: - if test `uname -s` = "HP-UX"; then \ - cd scripts/HP-UX; \ - make package; \ - mv NUT_HPUX_package.depot NUT_HPUX_package@PACKAGE_VERSION@.depot; \ - elif test `uname -s` = "SunOS"; then \ - make; \ - rm -rf @prefix@; \ - make install; \ - cd scripts/Solaris; \ - make package; \ - make uninstall; \ - rm -rf @prefix@; \ - elif test `uname -s` = "AIX"; then \ - make dist; \ - cp scripts/Aix/nut-aix.spec /usr/src/packages/SPECS; \ - cp scripts/Aix/nut.init nut-*.tar.gz /usr/src/packages/SOURCES; \ - rpm -ba /usr/src/packages/SPECS/nut-aix.spec; \ - fi; + @echo "Edit configure.ac to set version number." + +package: dist + DESTDIR="$(abs_builddir)/_install_pkgprotodir" ; export DESTDIR; \ + rm -rf "$$DESTDIR"; \ + case "`uname -s`" in \ + "HP-UX") \ + ( cd scripts/HP-UX && \ + $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$DESTDIR" package && \ + mv NUT_HPUX_package.depot $(abs_top_builddir)/NUT_HPUX_package@PACKAGE_VERSION@.depot ) ;; \ + "SunOS") \ + $(MAKE) $(AM_MAKEFLAGS) && \ + $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$DESTDIR" install && \ + ( cd scripts/Solaris && \ + $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$DESTDIR" package ) && \ + $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$DESTDIR" uninstall && \ + rm -rf "$$DESTDIR" || \ + { echo "FAILED to produce SunOS packages, inspect '$$DESTDIR' for clues" >&2 ; exit 1; } ;; \ + "AIX") \ + if test -d /usr/src/packages/SPECS -a -w /usr/src/packages/SPECS ; then : ; else echo "Can not write to /usr/src/packages/SPECS" >&2 ; exit 1; fi ; \ + if test -d /usr/src/packages/SOURCES -a -w /usr/src/packages/SOURCES ; then : ; else echo "Can not write to /usr/src/packages/SOURCES" >&2 ; exit 1; fi ; \ + $(MAKE) $(AM_MAKEFLAGS) dist && \ + cp scripts/Aix/nut-aix.spec /usr/src/packages/SPECS && \ + cp scripts/Aix/nut.init nut-@PACKAGE_VERSION@.tar.gz /usr/src/packages/SOURCES && \ + rpm -ba /usr/src/packages/SPECS/nut-aix.spec && \ + mv /usr/src/packages/RPMS/nut*rpm $(abs_top_builddir)/ ;; \ + *) echo "Unsupported OS for 'make $@' (no recipe bound)" >&2; exit 1;; \ + esac + +print-MAINTAINERCLEANFILES print-REALCLEANFILES: + @echo $(MAINTAINERCLEANFILES) + +print-DISTCLEANFILES: + @echo $(DISTCLEANFILES) + +# TODO: Recursive mode to consider patterns defined in sub-dir makefiles +git-realclean-check: + @if test -e .git && (command -v git); then \ + git status --ignored || while read F ; do \ + for P in $(MAINTAINERCLEANFILES) ; do \ + case "$$F" in \ + */$$P) exit 1 ;; \ + esac ; \ + done; \ + done ; \ + fi # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/NEWS b/NEWS index 216c835..895b2ed 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,413 @@ If you're upgrading from an earlier version, see the UPGRADING file. For a complete and more detailed list of changes, please refer to the -ChangeLog file. +ChangeLog file (generated for release archives), or to the Git version +control history for "live" codebase. + +--------------------------------------------------------------------------- +Release notes for NUT 2.8.0 - what's new since 2.7.4: + +NOTE: Earlier discussions (mailing list threads, GitHub issues, etc.) could +refer to this change set (too long in the making) as NUT 2.7.5. + + - New (optional) keywords for configuration files were added, + so existing NUT 2.7.x builds would not accept them if some + deployments switch versions back and forth -- due to this, + semantically the version was bumped to NUT 2.8.x. + + - Add support for openssl-1.1.0 (Arjen de Korte) + + - libusb-1.0 API support in addition to libusb-0.1 API [#300] + + - Add support for `DISABLE_WEAK_SSL=true` in upsd.conf to disable older/weaker + SSL/TLS protocols and ciphers: when NUT is built against relatively recent + versions of OpenSSL or NSS it will be restricted to TLSv1.2 or better. + For least-surprise, currently defaults to `false` and complains in log + [PR #1043] + + - Add support for `ALLOW_NO_DEVICE=true` (as an upsd.conf flag or environment + variable passed from caller of the program), to allow starting the data + server initially without any device configurations and reloading it later + to apply config changes on the fly [PR #766] + + - Add support for `debug_min=NUM` setting (ups.conf, upsd.conf, upsmon.conf) + to specify the minimum debug verbosity for daemons. This allows "in-vivo" + troubleshooting of service daemons without editing init scripts or service + unit definitions. + + - Improve support for upsdrvctl for managing of numerous device configs, + including default "maxretry=3" and a "nowait" option to complete the + "start of everything" mode after triggering the drivers and not waiting + for them to complete initializing. This matters on systems that monitor + from dozens to hundreds of devices. + + - Drivers support a new value for `synchronous` setting, which is the + new default now: `auto`. Initially after driver start-up this mode + acts as the older default `off`, but would fall back to `on` in case + the driver fails to send reports to `upsd` by overflowing the socket + buffer in async mode -- so the next connections of this driver uptime + would be synchronized (potentially slower, but safer -- blocking on + writes to the data server). This adaptation would primarily impact + and benefit devices with many (hundreds of) data points, such as + ePDUs and daisy chains. [issue #1309, PR #1315] + + - Daemons such as upsd, upsmon, upslog, and device drivers previously + implied that enabled debugging (or upslog to stdout) means foreground + running, otherwise the daemon was always sent to the background. + Now there are explicit options for this (`-F`/`-B`), although default + behavior is retained. This change is used for simplified service unit + definitions. + + - Improvements for device discovery or driver "lock-picking", including + general support for: + * "Standalone" mode (`-s` option), to monitor a device which is not + detailed or mentioned in ups.conf + * `NUT_ALTPIDPATH` and `NUT_STATEPATH` environment variables to override + the paths built into the driver binary [PR #473 and #507] + * "Driver data dump" mode (`-d` option), to poll a device for one or + few ('update_count' ) loops, report discovered values (dump the data + tree in upsc-like format), and exit. This complements the `nut-scanner` + for finding and identifying devices. + + - support for new devices: + * IBM 6000 VA LCD 4U Rack UPS; 5396-1Kx (USB) + * Phoenix Contact QUINT-UPS model 2320461 (Modbus) + * Tripp-Lite SU3000LCD2UHV (USB; protocol 1330) + * Emerson Avocent PM3000 PDU (SNMP) + * HPE ePDU (SNMP) + + - nutdrv_qx: enhanced estimation of remaining battery runtime based + on speed of voltage drop, which varies as they age [PR #1027] + + - nutdrv_qx: several subdrivers added or improved, including: + * "snr" subdriver with USB connection, for SNR-UPS-LID-XXXX [PR #1008]. + Note that end-users should reference explicitly the `snr` subdriver + in their `ups.conf` settings because of USB chip using the same + values of VendorID/ProductID as fabula_subdriver, fuji_subdriver, + and krauler_subdriver. + * "hunnox" subdriver, as a dialect of earlier "fabula" [PR #638] + adds support for Hunnox HNX-850 with USB connection and reported to work + for Powercool, Iron Guardian, ARES devices and possibly many others from + discussions linking to the pull request which introduced the driver. + * "phoenixtec" subdriver for Masterguard A and E series, device series + A700/1000/2000/3000(-19) and E40/60/100(-19). [PR #975] + * "ablerex" subdriver provided by the OEM vendor, note that it replaces + "krauler_subdriver" as default handler for VID:PID 0xffff:0x0000 + [PR #1135] + * Legrand HID defined and handled by "krauler_subdriver" by default + [PR #1075, issue #616] + * add new "armac" subdriver, tested with Armac R/2000I/PSW, but should + support other UPSes that work with "PowerManagerII" software from + Richcomm Technologies from around 2004-2005 [PR #1239, issue #1238] + + - microsol-apc (starting at version 0.68 as derived from solis 0.67): + adding support for newer APC Back-UPS BR hardware, such as + APC Back-UPS BZ1500, BZ2200BI and BZ2200I [PR #994] + + - pijuice: added new i2c bus driver for PiJuice HAT, a battery UPS module + for the Raspberry Pi systems [PR #730] + + - huawei-ups2000: added new driver for USB (Linux 5.12+ so far) and Serial + RS-232 Modbus device support of Huawei UPS2000/2000A (1kVA-3kVA) series, + and possibly some related FSP UPS models. [PR #954] + + - socomec_jbus: added new driver for modbus-based JBUS protocol over serial + RS-232 for Socomec UPS (tested with a DIGYS 3/3 15kVA model, working + on Linux x86-64 and Raspberry Pi 3 ARM). [PR #1313] + + - adelsystem_cbi: added new driver for ADELSYSTEM CBI2801224A, an all-in-one + 12/24Vdc DC-UPS, which supports the modbus RTU communication protocol + [PR #1282] + + - generic_modbus: added new driver for TCP and Serial Modbus device support. + The driver has been tested against PULS UPS (model UB40.241) via + MOXA ioLogikR1212 (RS485) and ioLogikE1212 (TCP/IP), and configuration + allows to map custom registers and addresses to NUT events [PR #1052] + + - genericups: added support for FTTx battery backup devices, and new signal + type mappings for the contact closure pins interpretation (RB for replace + battery, BYPASS for disconnected battery, and "none" or NULL for signals + to ignore) [PR #1061] + + - add devices to HCL/DDL: + * APC Back-UPS CS (USB) + * CPS CP1500EPFCLCD (USB) + * CPS EC350G, EC750G (USB) + * CPS PR2200LCDRT2U (SNMP) + * Eaton ATS 16 and 30 (SNMP) + * Eaton 5E2200VA (USB) + * Eaton 9PX Split Phase 6/8/10 kVA (XML/USB/SHUT) + * Eaton 9PX (XML/USB/SHUT) + * Eaton Ellipse PRO 650 VA (USB) + * Ippon Back Comfo Pro II 650/850/1050 (USB) + * Numeric Digital 800 (USB) + * Opti-UPS PS1500E (USB) + * Powercool 350VA to 1600VA (USB) + + - C++11 support in nutclient library and cppunit tests + + - Added C++ testing mock for TcpClient class (nutclientmem/MemClientStub: + data stored in local memory) [PR #1034] + + - Dual Python 2 and 3 compatibility in development scripts; ability to + run build activities and resulting built NUT programs on systems that + do not have a binary named "python" [PR #1115 and some before it] + + - Added Russian translation for NUT-Monitor GUI client [PR #806] + + - Separated NUT-Monitor UI into two applications, NUT-Monitor-py2gtk2 and + NUT-Monitor-py3qt5, suitable for two generations of Python ecosystem + with their great differences; `NUT-Monitor` name is retained for wrapper + script which calls one of these, such that the current system can execute + [PRs #1310, #1354] + + - Various USB driver families: expanded device-matching with "device" in + addition to "bus" and generic USB fields. This is needed to support + multiple attached devices that seem identical by other fields (e.g. + same vendor, same model, same USB bus, and no serial number) [PR #974] + + - Various USB driver families: Improved HID parsing for byte-stream to + number conversions on different CPU architectures [PR #1024] + + - Various USB HID driver families: added support for composite devices + utilizing interface greater than 0 for the UPS interface [PR #1044] + + - usbhid-ups: + * added generic framework for fixing Report Descriptors which can be + used for different manufacturers by adding code to the appropriate + subdriver rather than polluting the main code with UPS specific + exceptions, and applied fixes for known mistakes in (some releases + of firmware for) CyberPower CPS*EPFCLCD [issue #439, PR #1245] + * added `onlinedischarge` option for UPSes that report `OL+DISCHRG` + when wall power is lost [PR #811] + * changed detection of VendorID 0x06da handling of which is claimed + by Liebert/Phoenixtec HID historically, and MGE HID (for AEG PROTECT + NAS UPSes) since NUT 2.7.4, so that the higher-priority MGE subdriver + would not grab each and all of the devices exposing that ID [PR #1357] + * CPS HID: add input.frequency and output.frequency + * OpenUPS2: only check OEM Information string once (fewer log messages) + * Liebert GXT4 USB VID:PID [10AF:0000] + * add battery voltage and input/output transfer voltage and frequency + in Liebert/Phoenixtec HID mapping, to support PowerWalker VFI 2000 TGS + better [PR #564, issue #560] + * add a little delay between multicommands [PR #1228] + * fix Eaton/MGE mapping for beeper handling + * add IBM USB VID + * add deep battery test for CyberPower OL3000RMXL2U + * report the libusb version used + * fixed CPU architecture dependent bitmask math issues, causing wrong + numbers interpreted from wire protocol data in Big-Endian LP64 builds + (SPARC64, s390x, etc.) [issue #1023, PRs #1024, #1040, #1055, #1226] + * add Delta UPS Amplon R Series, tested on R1K and R3K model [PR #987] + * add Delta Minuteman UPS VID/PID [PR #1230, issues #555 and #1227] + * add AMETEK Powervar UPM [PR #733] + * add Tripplite AVR750U (ProductID 0x3024) [PR #963] + * add Arduino HID device support with new arduino-hid subdriver [PR #1044] + * add new salicru-hid subdriver, tested with Salicru SPS Home 850 VA + [PR #1199, issue #732] + * add new ever-hid subdriver to support EVER UPS devices (Sinline RT Series, + Sinline RT XL Series, ECO PRO AVR CDS Series) [PR #431] + * add ability to set `battery.mfr.date` for APC HID UPS [PR #1318] + + - usbhid-ups / mge-shut: compute a realpower output load approximation for + Eaton UPS when the needed data is not present + + - snmp-ups: + * APC ePDU MIB support + * add `input.phase.shift` variable + * add configurable write-able `ondelay` (`ups.delay.start`) and `offdelay` + (`ups.delay.shutdown`) as timeticks support [PR #276] + * outlet groups + * fix the rounding / truncation of some values + * add outlet.N.name for Eaton ePDU + * add input.bypass.frequency for Eaton 3ph + * fix support for Eaton 2-phase ("split phase") UPS + * add flag to list currently loaded MIB-to-NUT mappings + * fix input.L2.voltage on Eaton G2/G3 PDU + * update Eaton Aphel Revelation MIB + * support Raritan Dominion PX2 PDU + * support Emerson Avocent PM3000 PDU + * improve ALARM flag handling + * add firmware version for new HPE Network card + * add ups.load, battery.charge, input.{voltage,frequency} and output.voltage + for CyberPower, as well as shutdown and other instant commands + * several rounds of updates for Eaton devices, including new ATS and ePDU + hardware families + * fixed bit mask values for flags to surely use different numbers behind + logical items (inevitably changing some of those macro symbols) [PR #1180] + + - snmp-ups and nut-scanner should now support more SNMPv3 Auth and Priv + protocols, as available at NUT build time [PRs #1165, #1172] + + - nut-scanner: various improvements, including: + * detection of libraries at runtime + * tracing information + * limiting parallelism (thread count) [PRs #1158, #1164] + + - nut-ipmipsu: improve FreeIPMI support to build cleanly against older and + newer FreeIPMI versions [PR #1179] + + - the powerpanel driver now also supports CyberPower OR1500LCDRTXL2U with + serial cable [PR #538] + + - powercom driver: implement `nobt` config parameter to skip battery check + on initialization/startup [PR #1256] + + - netxml-ups: + * Report calibration status + * Fix for erroneous battery info (MGEXML/0.30) [PR #1069] + + - solis: various improvements and fixes + + - liebert-esp2: Correct battery V scaling, update docs, implement split-phase + unit support [PR #412] + + - tripplite: the "Tripp-Lite SmartUPS driver" as tested with SMART2200NET + learned to discover the firmware generation and some device features, + and in particular to manage power separately on one or two outlet groups + [PR #1048] + + - tripplite_usb: updated to recognize the "3005" protocol [PR #584] + + - libnutclient: introduce getDevicesVariableValues() to improve performances + when querying many devices (up to 15 times faster) + + - nut-driver-enumerator: introduced a script for Linux systemd and + Solaris/illumos SMF to inspect current NUT configuration in ups.conf + file and generate service management instances for each currently + tracked power device. Also introduced services to monitor the NUT + configuration and react to editions of this file, mostly intended + for deployments that do massive monitoring of dynamically changing + farms of power devices. + + - Fix File descriptors leaks by upsmon and upssched (SELinux errors) + + - systemd support improvements: + * POWEROFF_WAIT + * reload support for upsd + * Deliver systemd-tmpfiles config to pre-create runtime locations + [PR #1037 for Issue #1030] + * Update units with SyslogIdentifier=%N for better logging [PR #1054] + + - upsrw: display the variable type beside ENUM / RANGE + + - Added `PROTVER` as alias to `NETVER` to report the protocol version in use. + Note that NUT codebase itself does not use this value and handles commands + and reported errors individually [issue #1347] + + - Implement status tracking for instant commands (instcmd) and variables + settings (setvar): this allows to get the actual execution status from the + driver, and is available in libraries and upscmd / upsrw [PR #659] + + - Add support for extra parameter for instant commands, both in library and + in upscmd + + - dummy-ups can now specify `mode` as a driver argument, and separates the + notion of `dummy-once` (new default for `*.dev` files that do not change) + vs. `dummy-loop` (legacy default for `*.seq` and others) [issue #1385] + + - new protocol variables: + * `input.phase.shift` + * `outlet.N.name` + * `outlet.N.type` + * `battery.voltage.cell.max`, `battery.voltage.cell.min` + * `battery.temperature.cell.max`, `battery.temperature.cell.min` + * `battery.status` + * `battery.capacity.nominal` + * `battery.date.maintenance` (and clarified purpose of `battery.date`) + * `battery.packs.external` (and clarified purpose of `battery.packs`) + * `experimental.*` namespace introduced [PR #1046] to facilitate + introduction of NUT drivers and their data points for which we do + not yet have concepts, or which the original driver contributors + did not map well per suitable NUT standards: this allows to balance + having those drivers available in the project vs. least surprise + for when the explicitly experimental names are changed to something + stable and standardized. + * Proposed to track Date and Time values (still as "opaque strings") + preferably in representations compatible to ISO-8601/RFC-3339 [PR #1076] + (standards update; changes to actual codebase to be applied in the future) + ** New routine to convert a US formatted date string "MM/DD/YYYY" to an + ISO 8601 Calendar date "YYYY-MM-DD" was added to snmp-ups.c [PR #1078] + + - Master/Slave terminology was deprecated in favor of Primary/Secondary + modes of `upsmon` client: + * Respective keywords in the configuration files (`upsd.users` and + `upsmon.conf`) are supported as backwards-compatible settings, + but the obsoleted values are no longer documented. + * Protocol keyword support was similarly updated, with `upsmon` now + first trying to elevate privileges with `PRIMARY ` request, + and falling back to `MASTER ` just in case it talks to an + older build of an `upsd` server. + * For the principle of least surprise, NUT codebase still exposes the + `net_master()` (as handler for `MASTER` net command) in header and + C code for the sake of existing linked binaries, and returns the + `OK MASTER-GRANTED` line to the older client that invoked it. + * Newly introduced `net_primary()` (as handler for `PRIMARY` net command) + calls the exact same application logic, but returns `OK PRIMARY-GRANTED` + line to the client. + * Python binding updated to handle both cases, as the only found in-tree + protocol consumer of the full-line text. + * For more details see issue #840 and several pull requests referenced + from it, and discussions on NUT mailing lists. + + - Build fixes: + * In general, numerous fixes were applied to ensure portability and avoid + warnings (fixing a number of real bugs that caused them); CI was extended + to keep the codebase free of those types of warnings which we have got + rid of, requiring builds to succeed cleanly in several dozen combinations + of compiler versions, C standard revisions (C99 upwards, though on many + OSes with GNU99+ extensions), operating systems and CPU architectures. + * Public CI introduced to automatically test every contribution (PR) and + resulting increment of main NUT codebase, including Travis CI and LGTM.com + services, and a Jenkins farm on virtual hardware donated by Fosshost.org; + this augments testing earlier provided for some branches by Buildbot. + * Added cppunit testing with valgrind for the C++ client library + * Make targets added for shell script syntax checks for helper and service + scripts + * Make targets added for spellcheck and for maintenance of the dictionary, + including incremental spellcheck to only parse recently edited text files + * The AsciiDoc detection has been reworked to allow NUT to be built from + source without requiring asciidoc/a2x (using pre-built man pages from + the distribution tarball, for instance) + * Makefile contents rearranged for more resilient out-of-tree and in-tree + builds beside those made from the root workspace directory + * Makefiles are tested with GNU Make and BSD Make to ensure portable recipes + * More use of `pkg-config` to detect dependencies at configure time, as + well as fail-safe detection of presence of pkg-config (and its macros) + to survive and build without it too + * "slibtool" pedantic nuances now supported, allowing an alternative to + GNU libtool + * Build scripts updated to remove obsoleted calls to cleanly work with + autoconf-2.70 releases in 2020 (also works with 2.69 which was the + earlier release since 2012) + * Dynamic library loading used in certain programs and use-cases improved, + especially for 64-bit vs 32-bit builds on multiple-bitness OSes + * Logging routines like `upsdebugx()` were refactored as macros so there + is slightly less overhead when logging is disabled [PRs #685 and #1100] + * Numerous classes of compilation warnings eradicated, many of those being + potential issues with implicit data type conversions and varied numeric + type width, signedness, string buffer size, uninitialized variables or + structure fields; some more in progress + * Several logical errors found and fixed during this walk over codebase. + * Cases where compilers were overly zealous and particular code was written + the way wit was intentionally, including some comparisons that help with + different-bitness builds but indeed seem superfluous in a certain single + bitness, were commented and encased in pragmas to disable the warnings + * Basic coding style (indentations, lack of trailing white space) applied + per developer guide, but not automatically enforced/checked yet. + + - Due to changes needed to resolve build warnings, mostly about mismatching + data types for some variables, some structure definitions and API signatures + of several routines had to be changed for argument types, return types, + or both. Primarily this change concerns internal implementation details + (may impact update of NUT forks with custom drivers using those), but a + few changes also happened in header files installed for builds configured + `--with-dev` and so may impact `upsclient` and `nutclient` (C++) consumers. + At the very least, binaries for those consumers should be rebuilt to remain + stable with NUT 2.8.0 and not mismatch int-type sizes and other arguments. + + - As usual, more bugfixes, cleanup and improvements, on both source code + and documentation. --------------------------------------------------------------------------- Release notes for NUT 2.7.4 - what's new since 2.7.3: @@ -164,7 +570,7 @@ Release notes for NUT 2.7.3 - what's new since 2.7.2: - all drivers: a new 'synchronous' driver flag is available for very verbose units, such as some ePDUs - - Eaton: + - Eaton: * Add support for EnergySaving features for Eaton UPSs (HID USB/SHUT and XCP USB/serial) * Fix and complete Eaton ePDUs G2/G3 support @@ -188,7 +594,7 @@ Release notes for NUT 2.7.3 - what's new since 2.7.2: NHS Sistemas de Energia Expert S Online 6000/8000/10000 Powercom BNT-xxxAP (USB product id: 0001) Rucelf UPOII-3000-96-EL - Tripp Lite OMNIVSINT800 + Tripp Lite OMNIVSINT800 Voltronic Power Apex 1KVA and Imperial 1KVA --------------------------------------------------------------------------- @@ -218,7 +624,7 @@ Release notes for NUT 2.7.2 - what's new since 2.7.1: - snmp-ups: add support for XPPC-MIB and Tripp Lite SU10KRT3/1X. Also fix erroneous status in HP/Compaq SNMP MIB (with the most recent HP - firmware (1.76) ; improved various MIBs (APC, HP/Compaq, ...) + firmware (1.76) ; improved various MIBs (APC, HP/Compaq, ...) - nutdrv_qx: add new 'fallback' Q1 subdriver, with minimal 'Q1' support. General improvements on all subdrivers. @@ -285,7 +691,7 @@ Release notes for NUT 2.7.1 - what's new since 2.6.5: - libnutclient has been added as a C++ alternative to libupsclient. - Packaging files for Solaris and HP-UX (sponsored by Eaton) - + - Fix shutdown of Eaton HID, using usbhid-ups and mge-shut - usbhid-ups: final fix for APC Back UPS ES. APC Back UPS ES devices have @@ -308,11 +714,11 @@ Release notes for NUT 2.7.1 - what's new since 2.6.5: related to power devices and management - Improve systemd integration - + - snmp-ups: Fixed a crash on outlet management, and added delta_ups MIB support. Also fixed mappings for upsBypassVoltage, upsBypassCurrent, and upsBypassPower in three-phase IETF MIB. - + --------------------------------------------------------------------------- Release notes for NUT 2.6.5 - what's new since 2.6.4: @@ -349,7 +755,7 @@ Release notes for NUT 2.6.5 - what's new since 2.6.4: VMware ESXI 5.0, through a native VIB package. This is, for the time being, an external effort from René Garcia (refer to the Download section on NUT website). But work is underway to improve this integration, and - include it in the NUT source tree + include it in the NUT source tree - IPMI support (nut-ipmipsu driver and nut-scanner): prepare for supporting API changes in upcoming FreeIPMI versions 1.1.x and 1.2.x. @@ -374,7 +780,7 @@ Release notes for NUT 2.6.4 - what's new since 2.6.3: especially from the network. Non printable characters were missed from strings operation (such as strlen), but still copied to the buffer, causing an overflow. - Thus, fix NUT parser, to only allow the subset Ascii charset from + Thus, fix NUT parser, to only allow the subset of ASCII charset from Space to ~ (Reported by Sebastian Pohle, Alioth bug #313636, CVE-2012-2944) @@ -424,7 +830,7 @@ Release notes for NUT 2.6.4 - what's new since 2.6.3: PowerShield Defender 1200VA PowerWalker Online VFI LCD, Line-Interactive VI LCD and Line-Interactive VI Riello Netman Plus 102 SNMP Card - Tripp-Lite OMNISMART500 + Tripp-Lite OMNISMART500 - apcsmart has received some fixes to work better on Mac OS X, and in general @@ -436,7 +842,7 @@ Release notes for NUT 2.6.4 - what's new since 2.6.3: - blazer_ser and blazer_usb now try to automatically estimate high and low voltages, to be able to calculate battery charge ; support for online Innova UPS (T, RT and 3/1 T) has been added ; Best UPS support has been - improved, to prepare for superseeding bestups driver + improved, to prepare for superseding bestups driver - bestups has also received some care, though users are encouraged to switch to blazer_ser, since bestups will soon be deprecated. @@ -468,19 +874,19 @@ Release notes for NUT 2.6.4 - what's new since 2.6.3: - Riello protocols have been officially published in NUT protocols library: http://www.networkupstools.org/ups-protocols.html#_riello - + - Duplicate instances of upsd / upsmon are now detected upon startup - NUT variables namespace has been completed with missing variables and commands that are already known and standard - - upslog now comes with a companion file, for logrotate configuration + - upslog now comes with a companion file, for logrotate configuration - more devices embed NUT for power protection, now including Thecus NAS range - more bugfixes, cleanup and improvements, on both source code and documentation, with a good bunch from Greg A. Woods. - + --------------------------------------------------------------------------- Release notes for NUT 2.6.3 - what's new since 2.6.2: @@ -527,7 +933,7 @@ Release notes for NUT 2.6.3 - what's new since 2.6.2: - Base files for HPUX packaging have been added. This is still a work in progress. - - Compilation on IBM Aix has been fixed (namespace conflict with ctypes). + - Compilation on IBM AIX has been fixed (namespace conflict with ctypes). - more bugfixes, cleanup and improvements, on both source code and documentation. @@ -550,7 +956,7 @@ Release notes for NUT 2.6.2 - what's new since 2.6.1: * SNMP, * XML/HTTP (from Eaton), * NUT servers, using the classic connect or Avahi / mDNS methods. - + IPMI support will be added in the next release. A separate library, called 'libnutscan', is also available to provide these feature. Future NUT releases will provides binding for the supported @@ -562,10 +968,10 @@ Release notes for NUT 2.6.2 - what's new since 2.6.1: the future. For more info, refer to nut/scripts/java/README, or the developer guide (chapter 'Creating new client'). Javadoc documentation is also provided, - along with Java archives (.jar) in the Download section. + along with Java archives (.jar) in the Download section. - - support for new devices: Eaton 3S ; Cyber Power Systems CP1000AVRLCD ; - various APC models equiped with APC AP9618 management card, including APC + - support for new devices: Eaton 3S ; Cyber Power Systems CP1000AVRLCD ; + various APC models equipped with APC AP9618 management card, including APC Smart-UPS RT XL ; Orvaldi 750 / 900SP ; POWEREX VI 1000 LED ; PowerWalker VI 850 LCD ; SVEN Power Pro+ series (USB ID ffff:0000). @@ -590,9 +996,9 @@ Release notes for NUT 2.6.2 - what's new since 2.6.1: the default 3 seconds. - snmp-ups.c has a new initialization method, that uses sysObjectID, which is - a pointer to the prefered MIB of the device, to detect supported devices. + a pointer to the preferred MIB of the device, to detect supported devices. This speeds up even more init stage and should render void the use of 'mib' - option. SNMP v3 session initialisation has also been fixed, and Eaton PDU + option. SNMP v3 session initialization has also been fixed, and Eaton PDU support has been completed. - Initial support has been added for systemd, the System and Service Manager @@ -604,7 +1010,7 @@ Release notes for NUT 2.6.2 - what's new since 2.6.1: - Finally, after years of dedication to NUT, Arjen de Korte is now retired. Sincere thanks to you Arjen from us all. - + --------------------------------------------------------------------------- Release notes for NUT 2.6.1 - what's new since 2.6.0: @@ -635,9 +1041,9 @@ Release notes for NUT 2.6.1 - what's new since 2.6.0: - usbhid-ups has completed a bit supported variables for APC and Eaton / MGE. - - on the quality assurance side, Eaton has worked on fixing a few non - conformances, like C++ style comments and warnings, using a newly developed - verification tool (Prachi Gandhi). + - on the quality assurance side, Eaton has worked on fixing a few + non-conformance issues, like C++ style comments and warnings, using + a newly developed verification tool (Prachi Gandhi). - fix remaining references to LIBSSL_LDFLAGS, instead of LIBSSL_LIBS, which cause unresolved symbol on libupsclient users (Fabrice Coutadeur). @@ -696,7 +1102,7 @@ Release notes for NUT 2.6.0 - what's new since 2.4.3: - improve configure time dependencies checking and processing. - - improve older Unix systems support (HP-UX, Aix, ...) for missing functions. + - improve older Unix systems support (HP-UX, AIX, ...) for missing functions. - refresh and improve USB helper files (udev and UPower). @@ -767,8 +1173,8 @@ Release notes for NUT 2.4.1 - what's new since 2.4.0: version 1.1. - the situation of the build toolchain has been fixed, with regard to the - "make clean" target and the wrongly removed generated USB files. This brokes - further configure call. + "make clean" target and the wrongly removed generated USB files. This broke + further configure call. --------------------------------------------------------------------------- Release notes for NUT 2.4.0 - what's new since 2.2.2: @@ -779,7 +1185,7 @@ Release notes for NUT 2.4.0 - what's new since 2.2.2: including: Eaton ePDUs (Managed and Monitored), some Aphel models, some Raritan PDUs, and the whole list of Powerman supported devices: http://powerman.sourceforge.net/supported.html - + - support for new devices: the various PDUs cited above, Chloride Desk Power 650, Cyber Power Systems Value 400E/600E/800E (USB models), Delta GES602N, Digitus DN-170020, the whole Eaton ranges (mostly composed of MGE Office @@ -809,8 +1215,8 @@ Release notes for NUT 2.4.0 - what's new since 2.2.2: - NUT now ships a bash completion function for 'upsc' command (scripts/misc/nut.bash_completion). Simply copy it to /etc/bash_completion.d - - - many internal changes to improve maintenability, while lowering the + + - many internal changes to improve maintainability, while lowering the maintenance cost (thus allowing developers to focus on what matters: the code!). Examples of this are: - the USB information automatic extraction to generate the various USB helper @@ -827,7 +1233,7 @@ Release notes for NUT 2.2.2 - what's new since 2.2.1: - support for new devices: APC BACK-UPS XS LCD, Atlantis Land, Mustek Powermust Office 650, Oneac XAU models, Powerware PW5115 and PW9120 (USB), Nitram Elite 2005 - + - Integrated Power Management (NUT HAL integration) has reached a major milestone: it is now the most advanced UPS integration into Power Management layer known in existing OSs. It has received many @@ -846,15 +1252,15 @@ Release notes for NUT 2.2.2 - what's new since 2.2.1: - the netxml-ups driver has appeared to support MGE* network HTTP/XML cards. - + - NUT now distributes by default the shared version of libupsclient (version 1.0.0), and use this for the provided clients (upsmon, upsc, upsrw, upscmd). This is part of an effort to reduce NUT's footprint, both on disk and in memory. - + - powerpanel has reach a new step toward the replacement of nitram and cpsups drivers. The final step is scheduled for NUT 2.4. - + - many changes, cleanup and fixes to the NUT core and various drivers. --------------------------------------------------------------------------- @@ -874,7 +1280,7 @@ Release notes for NUT 2.2.1 - what's new since 2.2.0: - the megatec and megatec_usb drivers have also been backported from the development (trunk) version. - + - the client development files have also received some care: the upsclient pkg-config file has been fixed, and the upsclient.h file allows older NUT clients to continue using the UPSCONN structure. @@ -926,7 +1332,7 @@ Release notes for NUT 2.0.5 - what's new since 2.0.4: This release is a backport of the development version. Many changes have already been backported previously. Thus it is more a - synchronisation release, though it includes many bugfixes and support + synchronization release, though it includes many bugfixes and support for new models. - support for new devices: APC Smart-UPS with 6TI firmware; Belkin @@ -949,7 +1355,7 @@ Release notes for NUT 2.0.5 - what's new since 2.0.4: - solis: shutdown programming, support new cables, Solaris support - - tripplite_usb: updated SMARTPRO support, fixed OL/OB reporting, + - tripplite_usb: updated SMARTPRO support, fixed OL/OB reporting, better error handling, some memory bugs - new dummy-ups driver simulator @@ -960,12 +1366,12 @@ Release notes for NUT 2.0.5 - what's new since 2.0.4: Release notes for NUT 2.0.4 - what's new since 2.0.3: - The newhidups critical bug (segmentation fault) has been fixed. It has - also received some more care, like buxfixes and new models support and + also received some more care, like bugfixes and new models support and enhancement for Solaris. [Peter Selinger and Arnaud Quette] - A bug has been fixed in NUT core to support resuming from suspend-to-disk. - This should also fix other similar issues, like time synchronisation + This should also fix other similar issues, like time synchronization through the NTP - Network Time Protocol. [Arjen de Korte] @@ -988,7 +1394,7 @@ Release notes for NUT 2.0.4 - what's new since 2.0.3: [Carlos Rodrigues] - The new rhino driver was added to support Microsol Rhino UPS hardware - The solis has also been improved for solaris compatibility, and + The solis has also been improved for Solaris compatibility, and internal / external shutdown programming. solis can now save external shutdown programming to ups, and support new cables for solis 3 [Silvino B. Magalhães] @@ -1028,7 +1434,7 @@ Release notes for NUT 2.0.3 - what's new since 2.0.2: ups.model retrieval for some specific case (release 0.65) - The drivers don't change to the "statepath" directory anymore at - initialisation time if called using -k. This avoid unneeded + initialization time if called using -k. This avoid unneeded failure to poweroff the UPS if /var is already unmounted. [Gaspar Bakos] @@ -1048,7 +1454,7 @@ Release notes for NUT 2.0.3 - what's new since 2.0.2: - The packaging files for Red Hat have received various fixes [Thomas Jarosch] - - The solis driver has been fixed to avoid a naming colision and + - The solis driver has been fixed to avoid a naming collision and compile on Solaris [Paweł Kierdelewicz] @@ -1090,7 +1496,7 @@ Release notes for NUT 2.0.2 - what's new since 2.0.1: [Thanos Chatziathanassiou, Olli Salvia] - The bcmxcp driver is back with support for Powerware UPSs. - [Tore Øpetveit, Kjell Claesson] + [Tore Ørpetveit, Kjell Claesson] - The cyberpower driver now supports CyberPower 1000AVR. [Dave Huang] @@ -1101,7 +1507,7 @@ Release notes for NUT 2.0.2 - what's new since 2.0.1: - The apcsmart driver has fixed APC600 support. - - The etapro driver fixes brokeness due to ser_get_line use + - The etapro driver fixes brokenness due to ser_get_line use [Marek Michalkiewicz] - The new upscode2 driver supports Fiskars, Compaq and Powerware @@ -1140,7 +1546,7 @@ Release notes for NUT 2.0.1 - what's new since 2.0.0: - The everups driver now supports types 73-76 (NET 700/1000/1400/500-DPC) [hunter] - - The new metasys driver supports Meta System models: Line, + - The new metasys driver supports Meta System models: Line, HF Millennium, HF Top Line, ECO Network, ECO, Ally HF, Megaline [BlaXwan] @@ -1153,7 +1559,7 @@ Release notes for NUT 2.0.1 - what's new since 2.0.0: and bypass control. [Gert Lynge] - - The tripplite driver has recieved a major overhaul to bring it up to + - The tripplite driver has received a major overhaul to bring it up to working condition for the 2.0 tree, including code cleanups, several new variables, commands, and user-definable parameters. See ChangeLog for more. @@ -1192,7 +1598,7 @@ Release notes for NUT 2.0.1 - what's new since 2.0.0: [Arnaud Quette] - The fentonups driver now recognizes several more Megatec protocol - units: + units: SuperPower HP360, Hope-550 [Denis Zaika] Unitek Alpha 1000is [Antoine Cuvellard] @@ -1206,7 +1612,7 @@ Release notes for NUT 2.0.1 - what's new since 2.0.0: - upssched's CANCEL events were broken following the change to text-based socket messages in 1.5 and have been fixed. - [Steven Schoch] + [Steven Schoch] - Calls to varargs functions with raw strings from the config files without an intervening "%s" have been fixed in upsmon, upssched, @@ -1225,8 +1631,8 @@ Release notes for NUT 2.0.0 - what's new since 1.4.x: interim compatibility hacks have been removed. - New serial handling code has been added, with greatly simplified - operations. The old mess involving repeated calls to sigaction, - alarm, and read has been condensed to a select-read loop. + operations. The old mess involving repeated calls to sigaction, + alarm, and read has been condensed to a select-read loop. This change allows drivers which don't do any serial communications at all (hidups, snmp-ups) to drop that baggage, so they are a bit @@ -1277,13 +1683,13 @@ Release notes for NUT 2.0.0 - what's new since 1.4.x: [Viktor T. Toth] - The newhidups driver has been merged as the first step towards - portable USB UPS support. This will eventually replace the old + portable USB UPS support. This will eventually replace the old Linux-only hidups driver. The newhidups driver is tagged experimental since it is under active development. [Arnaud Quette, Charles Lepple] - The newapc driver has been renamed to apcsmart, replacing the old - driver with that name. If you used the newapc driver, be sure to + driver with that name. If you used the newapc driver, be sure to delete the old binary and fix your ups.conf. - The apcsmart driver now supports asynchronous notification data @@ -1312,7 +1718,7 @@ Release notes for NUT 2.0.0 - what's new since 1.4.x: instcmds. - Effekta MT 2000 RM hardware is now supported by the fentonups driver. - [christoph moar] + [Christoph Moar] - The new safenet driver supports UPS hardware that uses the protocol of the same name. This includes models from many manufacturers, @@ -1376,20 +1782,20 @@ Release notes for NUT 1.4.0 - what's new since 1.2.x: - upssched now explicitly confirms reception of timer commands before exiting. This was done to avoid a race where one process would - exit right when another one was starting. The second one would - believe its command had been handled when it had been lost. + exit right when another one was starting. The second one would + believe its command had been handled when it had been lost. - upslog has been reworked to use standard getopt parsing to provide the monitoring settings. The old way of specifying arguments is still supported for backwards compatibility. upslog has also been changed to only parse the format string once, - rather than doing it every time through the loop. This should - provide a minuscule drop in CPU utilization. + rather than doing it every time through the loop. This should + provide a minuscule drop in CPU utilization. - Usernames are now required in upsmon and upsd. This means that you must add a username to your MONITOR lines in upsmon.conf and then - create a matching user in upsd.users. + create a matching user in upsd.users. Installations from the 1.2 era probably already use usernames, so this mostly affects those from 1.0 and before. @@ -1426,14 +1832,14 @@ Release notes for NUT 1.4.0 - what's new since 1.2.x: - Signal handlers no longer do any significant amount of work. Some of the programs used to do numerous things in there, raising concerns - about reentrancy. They now set flags and allow the main loop to do + about reentrancy. They now set flags and allow the main loop to do the actual work from there. - A bug in upsmon where NOTIFYFLAG settings could be ignored was fixed. - Group handling has been changed. configure no longer accepts --with-group, and the programs no longer setgid() to a hardcoded - value. They now setgid() to the primary group of whatever the + value. They now setgid() to the primary group of whatever the user value may be. This may be compiled in with --with-user as before, and many programs @@ -1460,7 +1866,7 @@ Release notes for NUT 1.4.0 - what's new since 1.2.x: battery tests were also added. - The dummyups testing driver has been removed. The dummycons testing - driver can do everything that dummyups once did and much more. + driver can do everything that dummyups once did and much more. dummycons is also now built by default for easier testing. - The newapc driver has been reworked to take advantage of the new @@ -1475,7 +1881,7 @@ Release notes for NUT 1.4.0 - what's new since 1.2.x: a shutdown sequence, and more. [Arnaud Quette] - - The mge-utalk driver had trouble establishing communications in + - The mge-utalk driver had trouble establishing communications in some cases due to the RTS line being set. This has been fixed. The mge-shut driver has been added to the tree, and has replaced @@ -1491,7 +1897,7 @@ Release notes for NUT 1.4.0 - what's new since 1.2.x: others before long. [Arnaud Quette] - - KIN-2200AP hardware is now recognized by the powercom driver. + - KIN-2200AP hardware is now recognized by the powercom driver. This change may also support other KIN-xxxxAP equipment. [Preston A. Elder] @@ -1569,7 +1975,7 @@ Release notes for NUT 1.4.0 - what's new since 1.2.x: - The inline keyword is now handled properly on systems which do not support it or have it specified as another name. This was breaking compiles on some systems. - [Petter Reinholdtsen] + [Petter Reinholdtsen] --------------------------------------------------------------------------- Release notes for NUT 1.2.2 - what's new since 1.2.1: @@ -1607,7 +2013,7 @@ Release notes for NUT 1.2.2 - what's new since 1.2.1: [Alex Cichowski] - The liebert driver also now uses debouncing logic on the status - lines. It was possible to get false readings that would start a + lines. It was possible to get false readings that would start a shutdown or just annoy users with excessive onbatt/online notify messages. The new code forces the status to settle down for 3 polls before accepting the new value. @@ -1654,7 +2060,7 @@ Release notes for NUT 1.2.2 - what's new since 1.2.1: - upsd no longer tries to reference a deleted client structure if the client disconnects at the wrong time. Previously, it tried to use - that pointer after the sendback() function had already failed on + that pointer after the sendback() function had already failed on write and deleted the client. This could cause upsd to segfault depending on what areas were accessed. [Patrik Schindler] @@ -1676,7 +2082,7 @@ Release notes for NUT 1.2.1 - what's new since 1.2.0: - The old multilink driver is back with a new name: liebert. It supports Liebert UPStation GXE hardware with the contact-closure cable. This is currently an experimental driver as there is no - way to power down the load. + way to power down the load. - configure now picks up the right flags for gd automatically if gd 2.0.8 or higher is installed. This greatly simplifies the CGI build diff --git a/README b/README index 1b44663..c57dd89 100644 --- a/README +++ b/README @@ -102,7 +102,7 @@ This package is broken down into several categories: - *clients* - They talk to upsd and do things with the status data. - *cgi-bin* - Special class of clients that you can use with your web server. - *scripts* - Contains various scripts, like the Perl and Python binding, -integration bits and applications. +integration bits and applications. Drivers ------- @@ -120,8 +120,9 @@ The entry in `ups.conf` looks like this: driver = apcsmart port = /dev/ttyS1 -To start and stop drivers, use upsdrvctl. By default, it will start or -stop every UPS in the config file: +To start and stop drivers, use upsdrvctl of upsdrvsvcctl (installed on +operating systems with a service management framework supported by NUT). +By default, it will start or stop every UPS in the config file: /usr/local/ups/sbin/upsdrvctl start /usr/local/ups/sbin/upsdrvctl stop @@ -131,6 +132,17 @@ However, you can also just start or stop one by adding its name: /usr/local/ups/sbin/upsdrvctl start sparky /usr/local/ups/sbin/upsdrvctl stop sparky +On operating systems with a supported service management framework, +you might wrap your NUT drivers into individual services instances +with: + + /usr/local/ups/sbin/upsdrvsvcctl resync + +and then manage those service instances with commands like: + + /usr/local/ups/sbin/upsdrvsvcctl start sparky + /usr/local/ups/sbin/upsdrvsvcctl stop sparky + To find the driver name for your device, refer to the section below called "HARDWARE SUPPORT TABLE". @@ -236,8 +248,8 @@ Power distribution unit management NUT also provides an advanced support for power distribution units. -You should read the <> -chapter to learn more about when to use this feature. +You should read the <> +chapter to learn more about when to use this feature. Network Server -------------- @@ -261,32 +273,52 @@ separate section in the documentation since it is so important. You configure it by telling it about UPSes that you want to monitor in upsmon.conf. Each UPS can be defined as one of two possible types: +a "primary" or "secondary". -Master -~~~~~~ +Primary +~~~~~~~ -This UPS supplies power to the system running `upsmon`, and this system is also -responsible for shutting it down when the battery is depleted. This occurs -after any slave systems have disconnected safely. +The monitored UPS possibly supplies power to this system running `upsmon`, +but more importantly -- this system can manage the UPS (typically, this +instance of `upsmon` runs on the same system as the `upsd` and driver(s)): +it is capable and responsible for shutting it down when the battery is +depleted (or in another approach, lingering to deplete it or to tell the +UPS to reboot its load after too much time has elapsed and this system +is still alive -- meaning wall power returned at a "wrong" moment). -If your UPS is plugged directly into a system's serial port, the `upsmon` -process on that system should define that UPS as a master. +The shutdown of this (primary) system itself, as well as eventually an +UPS shutdown, occurs after any secondary systems ordered to shut down +first have disconnected, or a critical urgency threshold was passed. + +If your UPS is plugged directly into a system's serial or USB port, the +`upsmon` process on that system should define its relation to that UPS +as a primary. It may be more complicated for higher-end UPSes with a +shared network management capability (typically via SNMP) or several +serial/USB ports that can be used simultaneously, and depends on what +vendors and drivers implement. Setups with several competing primaries +(for redundancy) are technically possible, if each one runs its own +full stack of NUT, but results can be random (currently NUT does not +provide a way to coordinate several entities managing the same device). For a typical home user, there's one computer connected to one UPS. -That means you run a driver, `upsd`, and `upsmon` in master mode. +That means you would run on the same computer the whole NUT stack -- +a suitable driver, `upsd`, and `upsmon` in primary mode. -Slave -~~~~~ +Secondary +~~~~~~~~~ -This UPS may supply power to the system running `upsmon`, but this system can't -shut it down directly. +The monitored UPS may supply power to the system running `upsmon` (or +alternatively, it may be a monitoring station with zero PSUs fed by +that UPS), but more importantly, this system can't manage the UPS -- +e.g. shut it down directly (through a locally running NUT driver). -Use this mode when you run multiple computers on the same UPS. Obviously, only -one can be connected to the serial port on the UPS, and that system is the -master. Everything else is a slave. +Use this mode when you run multiple computers on the same UPS. +Obviously, only one can be connected to the serial or USB port +on a typical UPS, and that system is the primary. Everything +else is a secondary. For a typical home user, there's one computer connected to one UPS. -That means you run a driver, upsd, and upsmon in master mode. +That means you run a driver, `upsd`, and `upsmon` in primary mode. Additional Information ~~~~~~~~~~~~~~~~~~~~~~ @@ -476,7 +508,11 @@ The past stable trees were 1.0, 1.2, 1.4, 2.0, 2.2 and 2.4, with the latest stable tree designated 2.6. The development trees were 1.1, 1.3, 1.5, 2.1 and 2.3. As of the 2.4 release, there is no real development branch anymore since the code is available through a revision control -system (namely Subversion) and snapshots. +system (namely Subversion) and snapshots. Since 2.7 line of releases, +sources are tracked in Git revision control system, with the project +ecosystem being hosted on GitHub, and improvements or other contributions +merged through common pull request approach and custom NUT CI testing +on multiple platforms. Major release jumps are mostly due to large changes to the features list. There have also been a number of architectural changes which @@ -486,11 +522,11 @@ may not be noticeable to most users, but which can impact developers. Backwards and Forwards Compatibility ------------------------------------ -The old network code spans a range from about 0.41.1 when TCP support +The old network code spans a range from about 0.41.1 when TCP support was introduced up to the recent 1.4 series. It used variable names like STATUS, UTILITY, and LOADPCT. Many of these names go back to the earliest prototypes of this software from 1997. At that point there -was no way to know that so many drivers would come along and introduce +was no way to know that so many drivers would come along and introduce so many new variables and commands. The resulting mess grew out of control over the years. @@ -522,9 +558,9 @@ Here's a table to make it easier to visualize: |============================================= Version 2.0, and more recent, do not contain backwards compatibility for -the old protocol and variable/command names. As a result, 2.0 clients can't -talk to anything older than a 1.4 server. If you ask a 2.0 client to -fetch "STATUS", it will fail. You'll have to ask for "ups.status" +the old protocol and variable/command names. As a result, 2.0 clients can't +talk to anything older than a 1.4 server. If you ask a 2.0 client to +fetch "STATUS", it will fail. You'll have to ask for "ups.status" instead. Authors of separate monitoring programs should have used the 1.4 series diff --git a/TODO b/TODO index 1c45636..81a601f 100644 --- a/TODO +++ b/TODO @@ -13,7 +13,7 @@ Roadmap ^^^ This release is focused on the website and documentation rewrite, using -the excellent link:http://www.methods.co.nz/asciidoc[AsciiDoc]. +the excellent link:https://asciidoc.org/[AsciiDoc]. 2.8 ^^^ @@ -113,6 +113,6 @@ and https://alioth.debian.org/tracker/?atid=411545&group_id=30602&func=browse[fe solar panel driver, and the powerman internal approach of a generic engine with a scripting interface is a cool idea. Ref http://powerman.svn.sourceforge.net/viewvc/powerman/trunk/etc/apcpdu.dev?revision=969&view=markup -- integrate the (future) new powerman LUA engine (maybe/mustbe used for the driver above?) +- integrate the (future) new powerman LUA engine (maybe/must-be used for the driver above?) for native PDU support - see how we can help and collaborate with DeviceKit-power diff --git a/UPGRADING b/UPGRADING index 03cf410..1584e92 100644 --- a/UPGRADING +++ b/UPGRADING @@ -7,6 +7,132 @@ This file lists changes that affect users who installed older versions of this software. When upgrading from an older version, be sure to check this file to see if you need to make changes to your system. +Changes from 2.7.4 to 2.8.0 +--------------------------- + +- Note to distribution packagers: this version hopefully learns from many + past mistakes, so many custom patches may be no longer needed. If some + remain, please consider making pull requests for upstream NUT codebase + to share the fixes consistently across the ecosystem. Also note that + some new types of drivers (so package groups with unique dependencies) + could have appeared since your packaging was written (e.g. with modbus), + as well as new features in systemd integration (`nut-driver@instances` + and the `nut-driver-enumerator` to manage their population), as well as + updated Python 2 and Python 3 support (again, maybe dictating different + package groups) as detailed below. + +- Due to changes needed to resolve build warnings, mostly about mismatching + data types for some variables, some structure definitions and API signatures + of several routines had to be changed for argument types, return types, + or both. Primarily this change concerns internal implementation details + (may impact update of NUT forks with custom drivers using those), but a + few changes also happened in header files installed for builds configured + `--with-dev` and so may impact `upsclient` and `nutclient` (C++) consumers. + At the very least, binaries for those consumers should be rebuilt to remain + stable with NUT 2.8.0 and not mismatch int-type sizes and other arguments. + +- libusb-1.0: NUT now defaults to building against libusb-1.0 API version + if the configure script finds the development headers, falling back to + libusb-0.1 if not. Please report any regressions. + +- apcupsd-ups: When monitoring a remote apcupsd server, interpret "SHUTTING + DOWN" as a NUT "LB" status. If you were relying on the previous behavior + (for instance, in a monitor-only situation), please adjust your upsmon + settings. Reference: https://github.com/networkupstools/nut/issues/460 + +- Packagers: the AsciiDoc detection has been reworked to allow NUT to be built + from source without requiring asciidoc/a2x (using pre-built man pages from + the distribution tarball, for instance). Please double-check that we did not + break anything (see docs/configure.txt for options). + +- Driver core: options added for standalone mode (scanning for devices without + requiring ups.conf) - see docs/man/nutupsdrv.txt for details. + +- oldmge-shut has been removed, and replaced by mge-shut. + +- New drivers for devices with "Qx" (also known as "Megatec Q*") family of + protocols should be developed as sub-drivers in the `nutdrv_qx` framework + for USB and Serial connected devices, not as updates/clones of older e.g. + `blazer` family and `bestups`. Sources, man pages and start-up messages + of such older drivers were marked with "OBSOLETION WARNING". + +- liebert-esp2: some multi-phase variable names have been updated to match the + rest of NUT. + +- netxml-ups: if you have old firmware, or were relying on values being off by + a factor of 10, consider the `do_convert_deci` flag. See + docs/man/netxml-ups.txt for details. + +- snmp-ups: detection of Net-SNMP has been updated to use `pkg-config` by + default (if present), rather than `net-snmp-config(-32|-64)` script(s) as + the only option available previously. The scripts tend to specify a lot + of options (sometimes platform-specific) in suggested `CFLAGS` and `LIBS` + compared to the packaged `pkg-config` information which also works and is + more portable. If this change bites your distribution, please bring it up + in https://github.com/networkupstools/nut/issues or better yet, post a PR. + Also note that `./configure --with-netsnmp-config(=yes)` should set up the + preference of the detected script over `pkg-config` information, if both + are available, and `--with-netsnmp-config=/path/name` would as well. + +- snmp-ups: bit mask values for flags in earlier codebase were defined in a + way that caused logically different items to have same numeric values. + This was fixed to surely use different definitions (so changing numbers + behind some of those macro symbols), and testing with UPS, ePDU and ATS + hardware which was available did not expose any practical differences. + +- usbhid-ups: numeric data conversion from wire protocol to CPU representation + in GetValue() was completely reworked, aiming to be correct on all CPU types. + That said, regressions are possible and feedback is welcome. + +- nut-scanner: Packagers, take note of the changes to the library + search code in common/common.c. Please file an issue if this does not work + with your platform. + +- dummy-ups can now specify `mode` as a driver argument, and separates the + notion of `dummy-once` (new default for `*.dev` files that do not change) + vs. `dummy-loop` (legacy default for `*.seq` and others) [issue #1385] + + * Note this can break third-party test scripts which expected `*.dev` + files to work as a looping sequence with a `TIMER` keywords to change + values slowly; now such files should get processed to the end once. + Specify `mode=dummy-loop` driver option or rename the data file used + in the `port` option for legacy behavior. + Use/Test-cases which modified such files content externally should + not be impacted. + +- Python: scripts have been updated to work with Python 3 as well as 2. + + * PyNUT module (protocol binding) supports both Python generations. + + * NUT-Monitor (desktop UI client) got separated into two projects: + one with support for Python2 and GTK2, and another for Python3 and Qt5. + On operating systems that serve both environments, either of these + implementation should be usable. For distributions that deprecated + and removed Python2 support, it is a point to consider in NUT packages + and their build-time and installation dependencies. + The historic filenames for desktop integration (`NUT-Monitor` script + and `nut-monitor.desktop`) are still delivered, but now cover a wrapper + script which detects the environment capabilities and launches the best + suitable UI implementation (if both are available). + +- apcsmart: updates to CS "hack" (see docs/man/apcsmart.txt for details) + +- upsdebugx(): added `[D#]` prefix to log entries with level > 0 + so if any scripts or other tools relied on parsing those messages + making some assumptions, they should be updated + +- upsdebugx() and related methods are now macros, optionally calling similarly + named implementations like s_upsdebugx() as a slight optimization; this may + show up in linking of binaries for some customized build scenarios + +- libraries, tools and protocol now support a `TRACKING` ID to be used with + an `INSTCMD` or `SET VAR` requests; for details see docs/net-protocol.txt + and docs/sock-protocol.txt + +- upsrw: display the variable type beside ENUM / RANGE + +- Augeas: new `--with-augeas-lenses-dir` configure option. + Changes from 2.7.3 to 2.7.4 --------------------------- @@ -171,7 +297,7 @@ Changes from 2.2.1 to 2.2.2 This enable the additional build and distribution of the static version of libupsclient, along with the pkg-config helper and manual pages. The default configure option is to distribute only the shared -version of libupsclient. This can be overriden by using the +version of libupsclient. This can be overridden by using the "--disable-shared" configure option (distribute static only binaries). - The UPS poweroff handling of the usbhid-ups driver has been reworked. Though regression is not expected, users of this driver are @@ -182,7 +308,7 @@ Changes from 2.2.0 to 2.2.1 --------------------------- - nothing that affects upgraded systems. -(The below message is repetead due to previous omission) +(The below message is repeated due to previous omission) - Developers of external client application using libupsclient are encouraged to rename their "UPSCONN" client structure to "UPSCONN_t" since the former will disappear by the release of NUT 2.4. diff --git a/aclocal.m4 b/aclocal.m4 index 709a8d0..ee7ee0a 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,6 +1,6 @@ -# generated automatically by aclocal 1.14.1 -*- Autoconf -*- +# generated automatically by aclocal 1.16.3 -*- Autoconf -*- -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2020 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -20,146 +20,63 @@ You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) -# longlong.m4 serial 17 -dnl Copyright (C) 1999-2007, 2009-2014 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 12 (pkg-config-0.29.2) -dnl From Paul Eggert. +dnl Copyright © 2004 Scott James Remnant . +dnl Copyright © 2012-2015 Dan Nicholson +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +dnl 02111-1307, USA. +dnl +dnl As a special exception to the GNU General Public License, if you +dnl distribute this file as part of a program that contains a +dnl configuration script generated by Autoconf, you may include it under +dnl the same distribution terms that you use for the rest of that +dnl program. -# Define HAVE_LONG_LONG_INT if 'long long int' works. -# This fixes a bug in Autoconf 2.61, and can be faster -# than what's in Autoconf 2.62 through 2.68. +dnl PKG_PREREQ(MIN-VERSION) +dnl ----------------------- +dnl Since: 0.29 +dnl +dnl Verify that the version of the pkg-config macros are at least +dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's +dnl installed version of pkg-config, this checks the developer's version +dnl of pkg.m4 when generating configure. +dnl +dnl To ensure that this macro is defined, also add: +dnl m4_ifndef([PKG_PREREQ], +dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])]) +dnl +dnl See the "Since" comment for each macro you use to see what version +dnl of the macros you require. +m4_defun([PKG_PREREQ], +[m4_define([PKG_MACROS_VERSION], [0.29.2]) +m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, + [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) +])dnl PKG_PREREQ -# Note: If the type 'long long int' exists but is only 32 bits large -# (as on some very old compilers), HAVE_LONG_LONG_INT will not be -# defined. In this case you can treat 'long long int' like 'long int'. - -AC_DEFUN([AC_TYPE_LONG_LONG_INT], -[ - AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) - AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int], - [ac_cv_type_long_long_int=yes - if test "x${ac_cv_prog_cc_c99-no}" = xno; then - ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int - if test $ac_cv_type_long_long_int = yes; then - dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004. - dnl If cross compiling, assume the bug is not important, since - dnl nobody cross compiles for this platform as far as we know. - AC_RUN_IFELSE( - [AC_LANG_PROGRAM( - [[@%:@include - @%:@ifndef LLONG_MAX - @%:@ define HALF \ - (1LL << (sizeof (long long int) * CHAR_BIT - 2)) - @%:@ define LLONG_MAX (HALF - 1 + HALF) - @%:@endif]], - [[long long int n = 1; - int i; - for (i = 0; ; i++) - { - long long int m = n << i; - if (m >> i != n) - return 1; - if (LLONG_MAX / 2 < m) - break; - } - return 0;]])], - [], - [ac_cv_type_long_long_int=no], - [:]) - fi - fi]) - if test $ac_cv_type_long_long_int = yes; then - AC_DEFINE([HAVE_LONG_LONG_INT], [1], - [Define to 1 if the system has the type 'long long int'.]) - fi -]) - -# Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works. -# This fixes a bug in Autoconf 2.61, and can be faster -# than what's in Autoconf 2.62 through 2.68. - -# Note: If the type 'unsigned long long int' exists but is only 32 bits -# large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT -# will not be defined. In this case you can treat 'unsigned long long int' -# like 'unsigned long int'. - -AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT], -[ - AC_CACHE_CHECK([for unsigned long long int], - [ac_cv_type_unsigned_long_long_int], - [ac_cv_type_unsigned_long_long_int=yes - if test "x${ac_cv_prog_cc_c99-no}" = xno; then - AC_LINK_IFELSE( - [_AC_TYPE_LONG_LONG_SNIPPET], - [], - [ac_cv_type_unsigned_long_long_int=no]) - fi]) - if test $ac_cv_type_unsigned_long_long_int = yes; then - AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1], - [Define to 1 if the system has the type 'unsigned long long int'.]) - fi -]) - -# Expands to a C program that can be used to test for simultaneous support -# of 'long long' and 'unsigned long long'. We don't want to say that -# 'long long' is available if 'unsigned long long' is not, or vice versa, -# because too many programs rely on the symmetry between signed and unsigned -# integer types (excluding 'bool'). -AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET], -[ - AC_LANG_PROGRAM( - [[/* For now, do not test the preprocessor; as of 2007 there are too many - implementations with broken preprocessors. Perhaps this can - be revisited in 2012. In the meantime, code should not expect - #if to work with literals wider than 32 bits. */ - /* Test literals. */ - long long int ll = 9223372036854775807ll; - long long int nll = -9223372036854775807LL; - unsigned long long int ull = 18446744073709551615ULL; - /* Test constant expressions. */ - typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) - ? 1 : -1)]; - typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1 - ? 1 : -1)]; - int i = 63;]], - [[/* Test availability of runtime routines for shift and division. */ - long long int llmax = 9223372036854775807ll; - unsigned long long int ullmax = 18446744073709551615ull; - return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) - | (llmax / ll) | (llmax % ll) - | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) - | (ullmax / ull) | (ullmax % ull));]]) -]) - -# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- -# serial 1 (pkg-config-0.24) -# -# Copyright © 2004 Scott James Remnant . -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# PKG_PROG_PKG_CONFIG([MIN-VERSION]) -# ---------------------------------- +dnl PKG_PROG_PKG_CONFIG([MIN-VERSION]) +dnl ---------------------------------- +dnl Since: 0.16 +dnl +dnl Search for the pkg-config tool and set the PKG_CONFIG variable to +dnl first found in the path. Checks that the version of pkg-config found +dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is +dnl used since that's the first version where most current features of +dnl pkg-config existed. AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) @@ -181,18 +98,19 @@ if test -n "$PKG_CONFIG"; then PKG_CONFIG="" fi fi[]dnl -])# PKG_PROG_PKG_CONFIG +])dnl PKG_PROG_PKG_CONFIG -# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# -# Check to see whether a particular set of modules exists. Similar -# to PKG_CHECK_MODULES(), but does not set variables or print errors. -# -# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) -# only at the first occurence in configure.ac, so if the first place -# it's called might be skipped (such as if it is within an "if", you -# have to call PKG_CHECK_EXISTS manually -# -------------------------------------------------------------- +dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ------------------------------------------------------------------- +dnl Since: 0.18 +dnl +dnl Check to see whether a particular set of modules exists. Similar to +dnl PKG_CHECK_MODULES(), but does not set variables or print errors. +dnl +dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +dnl only at the first occurence in configure.ac, so if the first place +dnl it's called might be skipped (such as if it is within an "if", you +dnl have to call PKG_CHECK_EXISTS manually AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ @@ -202,8 +120,10 @@ m4_ifvaln([$3], [else $3])dnl fi]) -# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) -# --------------------------------------------- +dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +dnl --------------------------------------------- +dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting +dnl pkg_failed based on the result. m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" @@ -215,10 +135,11 @@ m4_define([_PKG_CONFIG], else pkg_failed=untried fi[]dnl -])# _PKG_CONFIG +])dnl _PKG_CONFIG -# _PKG_SHORT_ERRORS_SUPPORTED -# ----------------------------- +dnl _PKG_SHORT_ERRORS_SUPPORTED +dnl --------------------------- +dnl Internal check to see if pkg-config supports short errors. AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then @@ -226,26 +147,24 @@ if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then else _pkg_short_errors_supported=no fi[]dnl -])# _PKG_SHORT_ERRORS_SUPPORTED +])dnl _PKG_SHORT_ERRORS_SUPPORTED -# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], -# [ACTION-IF-NOT-FOUND]) -# -# -# Note that if there is a possibility the first call to -# PKG_CHECK_MODULES might not happen, you should be sure to include an -# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac -# -# -# -------------------------------------------------------------- +dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +dnl [ACTION-IF-NOT-FOUND]) +dnl -------------------------------------------------------------- +dnl Since: 0.4.0 +dnl +dnl Note that if there is a possibility the first call to +dnl PKG_CHECK_MODULES might not happen, you should be sure to include an +dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no -AC_MSG_CHECKING([for $1]) +AC_MSG_CHECKING([for $2]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) @@ -255,11 +174,11 @@ and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then - AC_MSG_RESULT([no]) + AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` - else + else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs @@ -276,7 +195,7 @@ installed software in a non-standard prefix. _PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then - AC_MSG_RESULT([no]) + AC_MSG_RESULT([no]) m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full @@ -292,16 +211,40 @@ else AC_MSG_RESULT([yes]) $3 fi[]dnl -])# PKG_CHECK_MODULES +])dnl PKG_CHECK_MODULES -# PKG_INSTALLDIR(DIRECTORY) -# ------------------------- -# Substitutes the variable pkgconfigdir as the location where a module -# should install pkg-config .pc files. By default the directory is -# $libdir/pkgconfig, but the default can be changed by passing -# DIRECTORY. The user can override through the --with-pkgconfigdir -# parameter. +dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +dnl [ACTION-IF-NOT-FOUND]) +dnl --------------------------------------------------------------------- +dnl Since: 0.29 +dnl +dnl Checks for existence of MODULES and gathers its build flags with +dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags +dnl and VARIABLE-PREFIX_LIBS from --libs. +dnl +dnl Note that if there is a possibility the first call to +dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to +dnl include an explicit call to PKG_PROG_PKG_CONFIG in your +dnl configure.ac. +AC_DEFUN([PKG_CHECK_MODULES_STATIC], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +_save_PKG_CONFIG=$PKG_CONFIG +PKG_CONFIG="$PKG_CONFIG --static" +PKG_CHECK_MODULES($@) +PKG_CONFIG=$_save_PKG_CONFIG[]dnl +])dnl PKG_CHECK_MODULES_STATIC + + +dnl PKG_INSTALLDIR([DIRECTORY]) +dnl ------------------------- +dnl Since: 0.27 +dnl +dnl Substitutes the variable pkgconfigdir as the location where a module +dnl should install pkg-config .pc files. By default the directory is +dnl $libdir/pkgconfig, but the default can be changed by passing +dnl DIRECTORY. The user can override through the --with-pkgconfigdir +dnl parameter. AC_DEFUN([PKG_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) m4_pushdef([pkg_description], @@ -312,16 +255,18 @@ AC_ARG_WITH([pkgconfigdir], AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) -]) dnl PKG_INSTALLDIR +])dnl PKG_INSTALLDIR -# PKG_NOARCH_INSTALLDIR(DIRECTORY) -# ------------------------- -# Substitutes the variable noarch_pkgconfigdir as the location where a -# module should install arch-independent pkg-config .pc files. By -# default the directory is $datadir/pkgconfig, but the default can be -# changed by passing DIRECTORY. The user can override through the -# --with-noarch-pkgconfigdir parameter. +dnl PKG_NOARCH_INSTALLDIR([DIRECTORY]) +dnl -------------------------------- +dnl Since: 0.27 +dnl +dnl Substitutes the variable noarch_pkgconfigdir as the location where a +dnl module should install arch-independent pkg-config .pc files. By +dnl default the directory is $datadir/pkgconfig, but the default can be +dnl changed by passing DIRECTORY. The user can override through the +dnl --with-noarch-pkgconfigdir parameter. AC_DEFUN([PKG_NOARCH_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) m4_pushdef([pkg_description], @@ -332,13 +277,15 @@ AC_ARG_WITH([noarch-pkgconfigdir], AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) -]) dnl PKG_NOARCH_INSTALLDIR +])dnl PKG_NOARCH_INSTALLDIR -# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, -# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# ------------------------------------------- -# Retrieves the value of the pkg-config variable for the given module. +dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ------------------------------------------- +dnl Since: 0.28 +dnl +dnl Retrieves the value of the pkg-config variable for the given module. AC_DEFUN([PKG_CHECK_VAR], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl @@ -347,9 +294,9 @@ _PKG_CONFIG([$1], [variable="][$3]["], [$2]) AS_VAR_COPY([$1], [pkg_cv_][$1]) AS_VAR_IF([$1], [""], [$5], [$4])dnl -])# PKG_CHECK_VAR +])dnl PKG_CHECK_VAR -# Copyright (C) 2002-2013 Free Software Foundation, Inc. +# Copyright (C) 2002-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -361,10 +308,10 @@ AS_VAR_IF([$1], [""], [$5], [$4])dnl # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.14' +[am__api_version='1.16' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.14.1], [], +m4_if([$1], [1.16.3], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -380,14 +327,14 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.14.1])dnl +[AM_AUTOMAKE_VERSION([1.16.3])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -439,7 +386,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd` # AM_CONDITIONAL -*- Autoconf -*- -# Copyright (C) 1997-2013 Free Software Foundation, Inc. +# Copyright (C) 1997-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -470,7 +417,7 @@ AC_CONFIG_COMMANDS_PRE( Usually this means the macro was only invoked conditionally.]]) fi])]) -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -661,13 +608,12 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl # Generate code to set up dependency tracking. -*- Autoconf -*- -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. - # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], @@ -675,49 +621,43 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. - case $CONFIG_FILES in - *\'*) eval set x "$CONFIG_FILES" ;; - *) set x $CONFIG_FILES ;; - esac + # TODO: see whether this extra hack can be removed once we start + # requiring Autoconf 2.70 or later. + AS_CASE([$CONFIG_FILES], + [*\'*], [eval set x "$CONFIG_FILES"], + [*], [set x $CONFIG_FILES]) shift - for mf + # Used to flag and report bootstrapping failures. + am_rc=0 + for am_mf do # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named 'Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # Grep'ing the whole file is not good either: AIX grep has a line + am_mf=`AS_ECHO(["$am_mf"]) | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile which includes + # dependency-tracking related rules and includes. + # Grep'ing the whole file directly is not great: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. - if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then - dirpart=`AS_DIRNAME("$mf")` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running 'make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "$am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`AS_DIRNAME(["$file"])` - AS_MKDIR_P([$dirpart/$fdir]) - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done + sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ + || continue + am_dirpart=`AS_DIRNAME(["$am_mf"])` + am_filepart=`AS_BASENAME(["$am_mf"])` + AM_RUN_LOG([cd "$am_dirpart" \ + && sed -e '/# am--include-marker/d' "$am_filepart" \ + | $MAKE -f - am--depfiles]) || am_rc=$? done + if test $am_rc -ne 0; then + AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments + for automatic dependency tracking. If GNU make was not used, consider + re-running the configure script with MAKE="gmake" (or whatever is + necessary). You can also try re-running configure with the + '--disable-dependency-tracking' option to at least be able to build + the package (albeit without support for automatic dependency tracking).]) + fi + AS_UNSET([am_dirpart]) + AS_UNSET([am_filepart]) + AS_UNSET([am_mf]) + AS_UNSET([am_rc]) + rm -f conftest-deps.mk } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS @@ -726,18 +666,17 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # -# This code is only required when automatic dependency tracking -# is enabled. FIXME. This creates each '.P' file that we will -# need in order to bootstrap the dependency handling code. +# This code is only required when automatic dependency tracking is enabled. +# This creates each '.Po' and '.Plo' makefile fragment that we'll need in +# order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], - [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) -]) + [AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])]) # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -824,11 +763,11 @@ AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: -# -# +# +# AC_SUBST([mkdir_p], ['$(MKDIR_P)']) -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. +# We need awk for the "check" target (and possibly the TAP driver). The +# system "awk" is bad on some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl @@ -892,7 +831,7 @@ END Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation -that behaves properly: . +that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM @@ -902,6 +841,9 @@ END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi +dnl The trailing newline in this macro's definition is deliberate, for +dnl backward compatibility and to allow trailing 'dnl'-style comments +dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. ]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not @@ -931,7 +873,7 @@ for _am_header in $config_headers :; do done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -942,7 +884,7 @@ echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_co # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -if test x"${install_sh}" != xset; then +if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; @@ -952,7 +894,7 @@ if test x"${install_sh}" != xset; then fi AC_SUBST([install_sh])]) -# Copyright (C) 2003-2013 Free Software Foundation, Inc. +# Copyright (C) 2003-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -974,7 +916,7 @@ AC_SUBST([am__leading_dot])]) # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1009,7 +951,7 @@ AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) # Check to see how 'make' treats includes. -*- Autoconf -*- -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1017,49 +959,42 @@ AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) # AM_MAKE_INCLUDE() # ----------------- -# Check to see how make treats includes. +# Check whether make has an 'include' directive that can support all +# the idioms we need for our automatic dependency tracking code. AC_DEFUN([AM_MAKE_INCLUDE], -[am_make=${MAKE-make} -cat > confinc << 'END' +[AC_MSG_CHECKING([whether ${MAKE-make} supports the include directive]) +cat > confinc.mk << 'END' am__doit: - @echo this is the am__doit target + @echo this is the am__doit target >confinc.out .PHONY: am__doit END -# If we don't find an include directive, just comment out the code. -AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# Ignore all kinds of additional output from 'make'. -case `$am_make -s -f confmf 2> /dev/null` in #( -*the\ am__doit\ target*) - am__include=include - am__quote= - _am_result=GNU - ;; -esac -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - case `$am_make -s -f confmf 2> /dev/null` in #( - *the\ am__doit\ target*) - am__include=.include - am__quote="\"" - _am_result=BSD - ;; - esac -fi -AC_SUBST([am__include]) -AC_SUBST([am__quote]) -AC_MSG_RESULT([$_am_result]) -rm -f confinc confmf -]) +# BSD make does it like this. +echo '.include "confinc.mk" # ignored' > confmf.BSD +# Other make implementations (GNU, Solaris 10, AIX) do it like this. +echo 'include confinc.mk # ignored' > confmf.GNU +_am_result=no +for s in GNU BSD; do + AM_RUN_LOG([${MAKE-make} -f confmf.$s && cat confinc.out]) + AS_CASE([$?:`cat confinc.out 2>/dev/null`], + ['0:this is the am__doit target'], + [AS_CASE([$s], + [BSD], [am__include='.include' am__quote='"'], + [am__include='include' am__quote=''])]) + if test "$am__include" != "#"; then + _am_result="yes ($s style)" + break + fi +done +rm -f confinc.* confmf.* +AC_MSG_RESULT([${_am_result}]) +AC_SUBST([am__include])]) +AC_SUBST([am__quote])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997-2013 Free Software Foundation, Inc. +# Copyright (C) 1997-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1080,12 +1015,7 @@ AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; - *) - MISSING="\${SHELL} $am_aux_dir/missing" ;; - esac + MISSING="\${SHELL} '$am_aux_dir/missing'" fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then @@ -1098,7 +1028,7 @@ fi # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1127,7 +1057,7 @@ AC_DEFUN([_AM_SET_OPTIONS], AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1174,7 +1104,7 @@ AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1193,7 +1123,7 @@ AC_DEFUN([AM_RUN_LOG], # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1274,7 +1204,7 @@ AC_CONFIG_COMMANDS_PRE( rm -f conftest.file ]) -# Copyright (C) 2009-2013 Free Software Foundation, Inc. +# Copyright (C) 2009-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1334,7 +1264,7 @@ AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1362,7 +1292,7 @@ fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006-2013 Free Software Foundation, Inc. +# Copyright (C) 2006-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1381,7 +1311,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004-2013 Free Software Foundation, Inc. +# Copyright (C) 2004-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1512,7 +1442,11 @@ AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR +m4_include([m4/ax_c___attribute__.m4]) +m4_include([m4/ax_c_pragmas.m4]) +m4_include([m4/ax_check_compile_flag.m4]) m4_include([m4/ax_compare_version.m4]) +m4_include([m4/ax_run_or_link_ifelse.m4]) m4_include([m4/libtool.m4]) m4_include([m4/ltoptions.m4]) m4_include([m4/ltsugar.m4]) @@ -1520,10 +1454,13 @@ m4_include([m4/ltversion.m4]) m4_include([m4/lt~obsolete.m4]) m4_include([m4/nut_arg_with.m4]) m4_include([m4/nut_check_asciidoc.m4]) +m4_include([m4/nut_check_cppcheck.m4]) +m4_include([m4/nut_check_headers_windows.m4]) m4_include([m4/nut_check_libavahi.m4]) m4_include([m4/nut_check_libfreeipmi.m4]) m4_include([m4/nut_check_libgd.m4]) m4_include([m4/nut_check_libltdl.m4]) +m4_include([m4/nut_check_libmodbus.m4]) m4_include([m4/nut_check_libneon.m4]) m4_include([m4/nut_check_libnetsnmp.m4]) m4_include([m4/nut_check_libnss.m4]) @@ -1532,5 +1469,10 @@ m4_include([m4/nut_check_libpowerman.m4]) m4_include([m4/nut_check_libusb.m4]) m4_include([m4/nut_check_libwrap.m4]) m4_include([m4/nut_check_os.m4]) +m4_include([m4/nut_check_pkgconfig.m4]) +m4_include([m4/nut_check_python.m4]) +m4_include([m4/nut_compiler_family.m4]) +m4_include([m4/nut_func_getnameinfo_argtypes.m4]) m4_include([m4/nut_report_feature.m4]) +m4_include([m4/nut_stash_warnings.m4]) m4_include([m4/nut_type_socklen_t.m4]) diff --git a/clients/Makefile.am b/clients/Makefile.am index 5c7abf9..e9d7e3c 100644 --- a/clients/Makefile.am +++ b/clients/Makefile.am @@ -1,7 +1,19 @@ # Network UPS Tools: clients +EXTRA_DIST = + +# nutclient.cpp for some legacy reason (maybe initial detached development?) +# optionally includes "common.h" with the NUT build setup - and this option +# was never triggered in fact, not until pushed through command line like this: +AM_CXXFLAGS = -DHAVE_NUTCOMMON=1 -I$(top_srcdir)/include + +# Make sure out-of-dir dependencies exist (especially when dev-building parts): +$(top_builddir)/common/libcommon.la \ +$(top_builddir)/common/libcommonclient.la \ +$(top_builddir)/common/libparseconf.la: dummy + @cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F) # by default, link programs in this directory with libcommon.a -LDADD = ../common/libcommon.la libupsclient.la $(NETLIBS) +LDADD = $(top_builddir)/common/libcommon.la libupsclient.la $(NETLIBS) if WITH_SSL LDADD += $(LIBSSL_LIBS) endif @@ -20,9 +32,13 @@ endif bin_PROGRAMS = upsc upslog upsrw upscmd dist_bin_SCRIPTS = upssched-cmd sbin_PROGRAMS = upsmon upssched -lib_LTLIBRARIES = libupsclient.la libnutclient.la +lib_LTLIBRARIES = libupsclient.la +if HAVE_CXX11 + lib_LTLIBRARIES += libnutclient.la + lib_LTLIBRARIES += libnutclientstub.la +endif if WITH_DEV - include_HEADERS = upsclient.h ../include/parseconf.h nutclient.h + include_HEADERS = upsclient.h ../include/parseconf.h nutclient.h nutclientmem.h endif if WITH_CGI cgiexec_PROGRAMS = upsstats.cgi upsimage.cgi upsset.cgi @@ -35,7 +51,7 @@ upslog_SOURCES = upslog.c upsclient.h upslog.h upsmon_SOURCES = upsmon.c upsmon.h upsclient.h upssched_SOURCES = upssched.c upssched.h -upssched_LDADD = ../common/libcommon.la ../common/libparseconf.la $(NETLIBS) +upssched_LDADD = $(top_builddir)/common/libcommon.la $(top_builddir)/common/libparseconf.la $(NETLIBS) upsimage_cgi_SOURCES = upsimage.c upsclient.h upsimagearg.h cgilib.c cgilib.h upsimage_cgi_LDADD = $(LDADD) $(LIBGD_LDFLAGS) @@ -46,15 +62,44 @@ upsstats_cgi_SOURCES = upsstats.c upsclient.h status.h upsstats.h \ # not LDADD. libupsclient_la_SOURCES = upsclient.c upsclient.h -libupsclient_la_LIBADD = ../common/libcommonclient.la +libupsclient_la_LIBADD = $(top_builddir)/common/libcommonclient.la if WITH_SSL libupsclient_la_LIBADD += $(LIBSSL_LIBS) endif -# libupsclient version information +# Below we set API versions of public libraries # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html -libupsclient_la_LDFLAGS = -version-info 4:0:0 +# Note that changes here may have to be reflected in packaging (the shared +# object .so names would differ) +# libupsclient version information +libupsclient_la_LDFLAGS = -version-info 6:0:0 -export-symbols-regex ^upscli_ + +if HAVE_CXX11 +# libnutclient version information and build libnutclient_la_SOURCES = nutclient.h nutclient.cpp -libnutclient_la_LDFLAGS = -version-info 0:0:0 +libnutclient_la_LDFLAGS = -version-info 2:0:0 +# Needed in not-standalone builds with -DHAVE_NUTCOMMON=1 +# which is defined for in-tree CXX builds above: +libnutclient_la_LIBADD = $(top_builddir)/common/libcommonclient.la +else +EXTRA_DIST += nutclient.h nutclient.cpp +endif +if HAVE_CXX11 +# libnutclientstub version information and build +libnutclientstub_la_SOURCES = nutclientmem.h nutclientmem.cpp +libnutclientstub_la_LDFLAGS = -version-info 1:0:0 +libnutclientstub_la_LIBADD = libnutclient.la +else +EXTRA_DIST += nutclientmem.h nutclientmem.cpp +endif + +dummy: + +MAINTAINERCLEANFILES = Makefile.in .dirstamp + +# NOTE: Do not clean ".deps" in SUBDIRS of the main project, +# the root Makefile.am takes care of that! +#clean-local: +# rm -rf $(builddir)/.deps diff --git a/clients/Makefile.in b/clients/Makefile.in index 0a7949e..e7cb07e 100644 --- a/clients/Makefile.in +++ b/clients/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.16.3 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,13 +14,21 @@ @SET_MAKE@ -# Network UPS Tools: clients - VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -90,24 +98,31 @@ target_triplet = @target@ bin_PROGRAMS = upsc$(EXEEXT) upslog$(EXEEXT) upsrw$(EXEEXT) \ upscmd$(EXEEXT) sbin_PROGRAMS = upsmon$(EXEEXT) upssched$(EXEEXT) +@HAVE_CXX11_TRUE@am__append_4 = libnutclient.la libnutclientstub.la @WITH_CGI_TRUE@cgiexec_PROGRAMS = upsstats.cgi$(EXEEXT) \ @WITH_CGI_TRUE@ upsimage.cgi$(EXEEXT) upsset.cgi$(EXEEXT) -@WITH_SSL_TRUE@am__append_4 = $(LIBSSL_LIBS) +@WITH_SSL_TRUE@am__append_5 = $(LIBSSL_LIBS) +@HAVE_CXX11_FALSE@am__append_6 = nutclient.h nutclient.cpp \ +@HAVE_CXX11_FALSE@ nutclientmem.h nutclientmem.cpp subdir = clients -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(dist_bin_SCRIPTS) $(top_srcdir)/depcomp \ - $(am__include_HEADERS_DIST) ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nut_arg_with.m4 \ $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ $(top_srcdir)/m4/nut_check_libavahi.m4 \ $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ $(top_srcdir)/m4/nut_check_libgd.m4 \ $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ $(top_srcdir)/m4/nut_check_libneon.m4 \ $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ $(top_srcdir)/m4/nut_check_libnss.m4 \ @@ -116,15 +131,26 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ $(top_srcdir)/m4/nut_check_libusb.m4 \ $(top_srcdir)/m4/nut_check_libwrap.m4 \ $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ $(top_srcdir)/m4/nut_type_socklen_t.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(dist_bin_SCRIPTS) \ + $(am__include_HEADERS_DIST) $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(cgiexecdir)" \ + "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(libdir)" \ + "$(DESTDIR)$(bindir)" "$(DESTDIR)$(includedir)" +PROGRAMS = $(bin_PROGRAMS) $(cgiexec_PROGRAMS) $(sbin_PROGRAMS) am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -152,12 +178,11 @@ am__uninstall_files_from_dir = { \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } -am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \ - "$(DESTDIR)$(cgiexecdir)" "$(DESTDIR)$(sbindir)" \ - "$(DESTDIR)$(bindir)" "$(DESTDIR)$(includedir)" LTLIBRARIES = $(lib_LTLIBRARIES) -libnutclient_la_LIBADD = -am_libnutclient_la_OBJECTS = nutclient.lo +@HAVE_CXX11_TRUE@libnutclient_la_DEPENDENCIES = \ +@HAVE_CXX11_TRUE@ $(top_builddir)/common/libcommonclient.la +am__libnutclient_la_SOURCES_DIST = nutclient.h nutclient.cpp +@HAVE_CXX11_TRUE@am_libnutclient_la_OBJECTS = nutclient.lo libnutclient_la_OBJECTS = $(am_libnutclient_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -167,9 +192,20 @@ libnutclient_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ $(AM_CXXFLAGS) $(CXXFLAGS) $(libnutclient_la_LDFLAGS) \ $(LDFLAGS) -o $@ +@HAVE_CXX11_TRUE@am_libnutclient_la_rpath = -rpath $(libdir) +@HAVE_CXX11_TRUE@libnutclientstub_la_DEPENDENCIES = libnutclient.la +am__libnutclientstub_la_SOURCES_DIST = nutclientmem.h nutclientmem.cpp +@HAVE_CXX11_TRUE@am_libnutclientstub_la_OBJECTS = nutclientmem.lo +libnutclientstub_la_OBJECTS = $(am_libnutclientstub_la_OBJECTS) +libnutclientstub_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ + $(AM_CXXFLAGS) $(CXXFLAGS) $(libnutclientstub_la_LDFLAGS) \ + $(LDFLAGS) -o $@ +@HAVE_CXX11_TRUE@am_libnutclientstub_la_rpath = -rpath $(libdir) am__DEPENDENCIES_1 = @WITH_SSL_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) -libupsclient_la_DEPENDENCIES = ../common/libcommonclient.la \ +libupsclient_la_DEPENDENCIES = \ + $(top_builddir)/common/libcommonclient.la \ $(am__DEPENDENCIES_2) am_libupsclient_la_OBJECTS = upsclient.lo libupsclient_la_OBJECTS = $(am_libupsclient_la_OBJECTS) @@ -177,52 +213,51 @@ libupsclient_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(libupsclient_la_LDFLAGS) $(LDFLAGS) \ -o $@ -PROGRAMS = $(bin_PROGRAMS) $(cgiexec_PROGRAMS) $(sbin_PROGRAMS) am_upsc_OBJECTS = upsc.$(OBJEXT) upsc_OBJECTS = $(am_upsc_OBJECTS) upsc_LDADD = $(LDADD) -upsc_DEPENDENCIES = ../common/libcommon.la libupsclient.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) +upsc_DEPENDENCIES = $(top_builddir)/common/libcommon.la \ + libupsclient.la $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) am_upscmd_OBJECTS = upscmd.$(OBJEXT) upscmd_OBJECTS = $(am_upscmd_OBJECTS) upscmd_LDADD = $(LDADD) -upscmd_DEPENDENCIES = ../common/libcommon.la libupsclient.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) +upscmd_DEPENDENCIES = $(top_builddir)/common/libcommon.la \ + libupsclient.la $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) am_upsimage_cgi_OBJECTS = upsimage.$(OBJEXT) cgilib.$(OBJEXT) upsimage_cgi_OBJECTS = $(am_upsimage_cgi_OBJECTS) -am__DEPENDENCIES_3 = ../common/libcommon.la libupsclient.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) +am__DEPENDENCIES_3 = $(top_builddir)/common/libcommon.la \ + libupsclient.la $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) upsimage_cgi_DEPENDENCIES = $(am__DEPENDENCIES_3) \ $(am__DEPENDENCIES_1) am_upslog_OBJECTS = upslog.$(OBJEXT) upslog_OBJECTS = $(am_upslog_OBJECTS) upslog_LDADD = $(LDADD) -upslog_DEPENDENCIES = ../common/libcommon.la libupsclient.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) +upslog_DEPENDENCIES = $(top_builddir)/common/libcommon.la \ + libupsclient.la $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) am_upsmon_OBJECTS = upsmon.$(OBJEXT) upsmon_OBJECTS = $(am_upsmon_OBJECTS) upsmon_LDADD = $(LDADD) -upsmon_DEPENDENCIES = ../common/libcommon.la libupsclient.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) +upsmon_DEPENDENCIES = $(top_builddir)/common/libcommon.la \ + libupsclient.la $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) am_upsrw_OBJECTS = upsrw.$(OBJEXT) upsrw_OBJECTS = $(am_upsrw_OBJECTS) upsrw_LDADD = $(LDADD) -upsrw_DEPENDENCIES = ../common/libcommon.la libupsclient.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) +upsrw_DEPENDENCIES = $(top_builddir)/common/libcommon.la \ + libupsclient.la $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) am_upssched_OBJECTS = upssched.$(OBJEXT) upssched_OBJECTS = $(am_upssched_OBJECTS) -upssched_DEPENDENCIES = ../common/libcommon.la \ - ../common/libparseconf.la $(am__DEPENDENCIES_1) +upssched_DEPENDENCIES = $(top_builddir)/common/libcommon.la \ + $(top_builddir)/common/libparseconf.la $(am__DEPENDENCIES_1) am_upsset_cgi_OBJECTS = upsset.$(OBJEXT) cgilib.$(OBJEXT) upsset_cgi_OBJECTS = $(am_upsset_cgi_OBJECTS) upsset_cgi_LDADD = $(LDADD) -upsset_cgi_DEPENDENCIES = ../common/libcommon.la libupsclient.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) +upsset_cgi_DEPENDENCIES = $(top_builddir)/common/libcommon.la \ + libupsclient.la $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) am_upsstats_cgi_OBJECTS = upsstats.$(OBJEXT) cgilib.$(OBJEXT) upsstats_cgi_OBJECTS = $(am_upsstats_cgi_OBJECTS) upsstats_cgi_LDADD = $(LDADD) -upsstats_cgi_DEPENDENCIES = ../common/libcommon.la libupsclient.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) +upsstats_cgi_DEPENDENCIES = $(top_builddir)/common/libcommon.la \ + libupsclient.la $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) SCRIPTS = $(dist_bin_SCRIPTS) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) @@ -238,7 +273,14 @@ am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/cgilib.Po ./$(DEPDIR)/nutclient.Plo \ + ./$(DEPDIR)/nutclientmem.Plo ./$(DEPDIR)/upsc.Po \ + ./$(DEPDIR)/upsclient.Plo ./$(DEPDIR)/upscmd.Po \ + ./$(DEPDIR)/upsimage.Po ./$(DEPDIR)/upslog.Po \ + ./$(DEPDIR)/upsmon.Po ./$(DEPDIR)/upsrw.Po \ + ./$(DEPDIR)/upssched.Po ./$(DEPDIR)/upsset.Po \ + ./$(DEPDIR)/upsstats.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -276,15 +318,16 @@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = -SOURCES = $(libnutclient_la_SOURCES) $(libupsclient_la_SOURCES) \ - $(upsc_SOURCES) $(upscmd_SOURCES) $(upsimage_cgi_SOURCES) \ - $(upslog_SOURCES) $(upsmon_SOURCES) $(upsrw_SOURCES) \ - $(upssched_SOURCES) $(upsset_cgi_SOURCES) \ +SOURCES = $(libnutclient_la_SOURCES) $(libnutclientstub_la_SOURCES) \ + $(libupsclient_la_SOURCES) $(upsc_SOURCES) $(upscmd_SOURCES) \ + $(upsimage_cgi_SOURCES) $(upslog_SOURCES) $(upsmon_SOURCES) \ + $(upsrw_SOURCES) $(upssched_SOURCES) $(upsset_cgi_SOURCES) \ $(upsstats_cgi_SOURCES) -DIST_SOURCES = $(libnutclient_la_SOURCES) $(libupsclient_la_SOURCES) \ - $(upsc_SOURCES) $(upscmd_SOURCES) $(upsimage_cgi_SOURCES) \ - $(upslog_SOURCES) $(upsmon_SOURCES) $(upsrw_SOURCES) \ - $(upssched_SOURCES) $(upsset_cgi_SOURCES) \ +DIST_SOURCES = $(am__libnutclient_la_SOURCES_DIST) \ + $(am__libnutclientstub_la_SOURCES_DIST) \ + $(libupsclient_la_SOURCES) $(upsc_SOURCES) $(upscmd_SOURCES) \ + $(upsimage_cgi_SOURCES) $(upslog_SOURCES) $(upsmon_SOURCES) \ + $(upsrw_SOURCES) $(upssched_SOURCES) $(upsset_cgi_SOURCES) \ $(upsstats_cgi_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ @@ -292,7 +335,7 @@ am__can_run_installinfo = \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__include_HEADERS_DIST = upsclient.h ../include/parseconf.h \ - nutclient.h + nutclient.h nutclientmem.h HEADERS = $(include_HEADERS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, @@ -313,6 +356,7 @@ am__define_uniq_tagged_files = \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) A2X = @A2X@ ACLOCAL = @ACLOCAL@ @@ -321,6 +365,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -331,6 +376,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -344,6 +390,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -356,6 +403,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -373,6 +421,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -383,21 +433,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -417,6 +475,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -430,6 +491,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -447,6 +509,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -460,6 +523,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -485,12 +551,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -501,8 +569,16 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ udevdir = @udevdir@ +# Network UPS Tools: clients +EXTRA_DIST = $(am__append_6) + +# nutclient.cpp for some legacy reason (maybe initial detached development?) +# optionally includes "common.h" with the NUT build setup - and this option +# was never triggered in fact, not until pushed through command line like this: +AM_CXXFLAGS = -DHAVE_NUTCOMMON=1 -I$(top_srcdir)/include + # by default, link programs in this directory with libcommon.a -LDADD = ../common/libcommon.la libupsclient.la $(NETLIBS) \ +LDADD = $(top_builddir)/common/libcommon.la libupsclient.la $(NETLIBS) \ $(am__append_1) # Avoid per-target CFLAGS, because this will prevent re-use of object @@ -510,15 +586,15 @@ LDADD = ../common/libcommon.la libupsclient.la $(NETLIBS) \ # but only add them if we really use the target. AM_CFLAGS = -I$(top_srcdir)/include $(am__append_2) $(am__append_3) dist_bin_SCRIPTS = upssched-cmd -lib_LTLIBRARIES = libupsclient.la libnutclient.la -@WITH_DEV_TRUE@include_HEADERS = upsclient.h ../include/parseconf.h nutclient.h +lib_LTLIBRARIES = libupsclient.la $(am__append_4) +@WITH_DEV_TRUE@include_HEADERS = upsclient.h ../include/parseconf.h nutclient.h nutclientmem.h upsc_SOURCES = upsc.c upsclient.h upscmd_SOURCES = upscmd.c upsclient.h upsrw_SOURCES = upsrw.c upsclient.h upslog_SOURCES = upslog.c upsclient.h upslog.h upsmon_SOURCES = upsmon.c upsmon.h upsclient.h upssched_SOURCES = upssched.c upssched.h -upssched_LDADD = ../common/libcommon.la ../common/libparseconf.la $(NETLIBS) +upssched_LDADD = $(top_builddir)/common/libcommon.la $(top_builddir)/common/libparseconf.la $(NETLIBS) upsimage_cgi_SOURCES = upsimage.c upsclient.h upsimagearg.h cgilib.c cgilib.h upsimage_cgi_LDADD = $(LDADD) $(LIBGD_LDFLAGS) upsset_cgi_SOURCES = upsset.c upsclient.h cgilib.c cgilib.h @@ -528,13 +604,29 @@ upsstats_cgi_SOURCES = upsstats.c upsclient.h status.h upsstats.h \ # not LDADD. libupsclient_la_SOURCES = upsclient.c upsclient.h -libupsclient_la_LIBADD = ../common/libcommonclient.la $(am__append_4) +libupsclient_la_LIBADD = $(top_builddir)/common/libcommonclient.la \ + $(am__append_5) + +# Below we set API versions of public libraries +# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html +# Note that changes here may have to be reflected in packaging (the shared +# object .so names would differ) # libupsclient version information -# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html -libupsclient_la_LDFLAGS = -version-info 4:0:0 -libnutclient_la_SOURCES = nutclient.h nutclient.cpp -libnutclient_la_LDFLAGS = -version-info 0:0:0 +libupsclient_la_LDFLAGS = -version-info 6:0:0 -export-symbols-regex ^upscli_ + +# libnutclient version information and build +@HAVE_CXX11_TRUE@libnutclient_la_SOURCES = nutclient.h nutclient.cpp +@HAVE_CXX11_TRUE@libnutclient_la_LDFLAGS = -version-info 2:0:0 +# Needed in not-standalone builds with -DHAVE_NUTCOMMON=1 +# which is defined for in-tree CXX builds above: +@HAVE_CXX11_TRUE@libnutclient_la_LIBADD = $(top_builddir)/common/libcommonclient.la + +# libnutclientstub version information and build +@HAVE_CXX11_TRUE@libnutclientstub_la_SOURCES = nutclientmem.h nutclientmem.cpp +@HAVE_CXX11_TRUE@libnutclientstub_la_LDFLAGS = -version-info 1:0:0 +@HAVE_CXX11_TRUE@libnutclientstub_la_LIBADD = libnutclient.la +MAINTAINERCLEANFILES = Makefile.in .dirstamp all: all-am .SUFFIXES: @@ -551,14 +643,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu clients/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu clients/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -569,47 +660,6 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): - -install-libLTLIBRARIES: $(lib_LTLIBRARIES) - @$(NORMAL_INSTALL) - @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ - list2=; for p in $$list; do \ - if test -f $$p; then \ - list2="$$list2 $$p"; \ - else :; fi; \ - done; \ - test -z "$$list2" || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ - } - -uninstall-libLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ - for p in $$list; do \ - $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ - done - -clean-libLTLIBRARIES: - -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) - @list='$(lib_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } - -libnutclient.la: $(libnutclient_la_OBJECTS) $(libnutclient_la_DEPENDENCIES) $(EXTRA_libnutclient_la_DEPENDENCIES) - $(AM_V_CXXLD)$(libnutclient_la_LINK) -rpath $(libdir) $(libnutclient_la_OBJECTS) $(libnutclient_la_LIBADD) $(LIBS) - -libupsclient.la: $(libupsclient_la_OBJECTS) $(libupsclient_la_DEPENDENCIES) $(EXTRA_libupsclient_la_DEPENDENCIES) - $(AM_V_CCLD)$(libupsclient_la_LINK) -rpath $(libdir) $(libupsclient_la_OBJECTS) $(libupsclient_la_LIBADD) $(LIBS) install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ @@ -758,6 +808,50 @@ clean-sbinPROGRAMS: echo " rm -f" $$list; \ rm -f $$list +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +libnutclient.la: $(libnutclient_la_OBJECTS) $(libnutclient_la_DEPENDENCIES) $(EXTRA_libnutclient_la_DEPENDENCIES) + $(AM_V_CXXLD)$(libnutclient_la_LINK) $(am_libnutclient_la_rpath) $(libnutclient_la_OBJECTS) $(libnutclient_la_LIBADD) $(LIBS) + +libnutclientstub.la: $(libnutclientstub_la_OBJECTS) $(libnutclientstub_la_DEPENDENCIES) $(EXTRA_libnutclientstub_la_DEPENDENCIES) + $(AM_V_CXXLD)$(libnutclientstub_la_LINK) $(am_libnutclientstub_la_rpath) $(libnutclientstub_la_OBJECTS) $(libnutclientstub_la_LIBADD) $(LIBS) + +libupsclient.la: $(libupsclient_la_OBJECTS) $(libupsclient_la_DEPENDENCIES) $(EXTRA_libupsclient_la_DEPENDENCIES) + $(AM_V_CCLD)$(libupsclient_la_LINK) -rpath $(libdir) $(libupsclient_la_OBJECTS) $(libupsclient_la_LIBADD) $(LIBS) + upsc$(EXEEXT): $(upsc_OBJECTS) $(upsc_DEPENDENCIES) $(EXTRA_upsc_DEPENDENCIES) @rm -f upsc$(EXEEXT) $(AM_V_CCLD)$(LINK) $(upsc_OBJECTS) $(upsc_LDADD) $(LIBS) @@ -835,18 +929,25 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cgilib.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nutclient.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upsc.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upsclient.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upscmd.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upsimage.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upslog.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upsmon.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upsrw.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upssched.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upsset.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upsstats.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cgilib.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nutclient.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nutclientmem.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upsc.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upsclient.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upscmd.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upsimage.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upslog.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upsmon.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upsrw.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upssched.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upsset.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upsstats.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @@ -975,7 +1076,10 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -1007,11 +1111,11 @@ distdir: $(DISTFILES) done check-am: all-am check: check-am -all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(SCRIPTS) $(HEADERS) +all-am: Makefile $(PROGRAMS) $(LTLIBRARIES) $(SCRIPTS) $(HEADERS) install-binPROGRAMS: install-libLTLIBRARIES installdirs: - for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(cgiexecdir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(includedir)"; do \ + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(cgiexecdir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(includedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am @@ -1044,6 +1148,7 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am clean-am: clean-binPROGRAMS clean-cgiexecPROGRAMS clean-generic \ @@ -1051,7 +1156,19 @@ clean-am: clean-binPROGRAMS clean-cgiexecPROGRAMS clean-generic \ mostlyclean-am distclean: distclean-am - -rm -rf ./$(DEPDIR) + -rm -f ./$(DEPDIR)/cgilib.Po + -rm -f ./$(DEPDIR)/nutclient.Plo + -rm -f ./$(DEPDIR)/nutclientmem.Plo + -rm -f ./$(DEPDIR)/upsc.Po + -rm -f ./$(DEPDIR)/upsclient.Plo + -rm -f ./$(DEPDIR)/upscmd.Po + -rm -f ./$(DEPDIR)/upsimage.Po + -rm -f ./$(DEPDIR)/upslog.Po + -rm -f ./$(DEPDIR)/upsmon.Po + -rm -f ./$(DEPDIR)/upsrw.Po + -rm -f ./$(DEPDIR)/upssched.Po + -rm -f ./$(DEPDIR)/upsset.Po + -rm -f ./$(DEPDIR)/upsstats.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -1099,7 +1216,19 @@ install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) + -rm -f ./$(DEPDIR)/cgilib.Po + -rm -f ./$(DEPDIR)/nutclient.Plo + -rm -f ./$(DEPDIR)/nutclientmem.Plo + -rm -f ./$(DEPDIR)/upsc.Po + -rm -f ./$(DEPDIR)/upsclient.Plo + -rm -f ./$(DEPDIR)/upscmd.Po + -rm -f ./$(DEPDIR)/upsimage.Po + -rm -f ./$(DEPDIR)/upslog.Po + -rm -f ./$(DEPDIR)/upsmon.Po + -rm -f ./$(DEPDIR)/upsrw.Po + -rm -f ./$(DEPDIR)/upssched.Po + -rm -f ./$(DEPDIR)/upsset.Po + -rm -f ./$(DEPDIR)/upsstats.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -1122,7 +1251,7 @@ uninstall-am: uninstall-binPROGRAMS uninstall-cgiexecPROGRAMS \ .MAKE: install-am install-strip -.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ clean-binPROGRAMS clean-cgiexecPROGRAMS clean-generic \ clean-libLTLIBRARIES clean-libtool clean-sbinPROGRAMS \ cscopelist-am ctags ctags-am distclean distclean-compile \ @@ -1142,6 +1271,21 @@ uninstall-am: uninstall-binPROGRAMS uninstall-cgiexecPROGRAMS \ uninstall-dist_binSCRIPTS uninstall-includeHEADERS \ uninstall-libLTLIBRARIES uninstall-sbinPROGRAMS +.PRECIOUS: Makefile + + +# Make sure out-of-dir dependencies exist (especially when dev-building parts): +$(top_builddir)/common/libcommon.la \ +$(top_builddir)/common/libcommonclient.la \ +$(top_builddir)/common/libparseconf.la: dummy + @cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F) + +dummy: + +# NOTE: Do not clean ".deps" in SUBDIRS of the main project, +# the root Makefile.am takes care of that! +#clean-local: +# rm -rf $(builddir)/.deps # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/clients/cgilib.c b/clients/cgilib.c index 2eb9ce8..88cebfa 100644 --- a/clients/cgilib.c +++ b/clients/cgilib.c @@ -46,9 +46,12 @@ static char *unescape(char *buf) hex[1] = buf[++i]; hex[2] = '\0'; if (!isxdigit((unsigned char) hex[0]) - || !isxdigit((unsigned char) hex[0])) + || !isxdigit((unsigned char) hex[1])) fatalx(EXIT_FAILURE, "bad escape char"); - ch = strtol(hex, NULL, 16); + long l = strtol(hex, NULL, 16); + assert(l>=0); + assert(l<=255); + ch = (char)l; /* FIXME: Loophole about non-ASCII symbols in top 128 values, or negatives for signed char... */ if ((ch == 10) || (ch == 13)) ch = ' '; @@ -89,7 +92,7 @@ void extractcgiargs(void) continue; } - + *eq = '\0'; value = eq + 1; amp = strchr(value, '&'); @@ -101,7 +104,7 @@ void extractcgiargs(void) ptr = NULL; cleanvar = unescape(varname); - cleanval = unescape(value); + cleanval = unescape(value); parsearg(cleanvar, cleanval); free(cleanvar); free(cleanval); @@ -199,4 +202,4 @@ int checkhost(const char *host, char **desc) pconf_finish(&ctx); return 0; /* not found: access denied */ -} +} diff --git a/clients/cgilib.h b/clients/cgilib.h index 1b620c3..32b6001 100644 --- a/clients/cgilib.h +++ b/clients/cgilib.h @@ -17,6 +17,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef NUT_CGILIB_H_SEEN +#define NUT_CGILIB_H_SEEN 1 + #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { @@ -41,3 +44,4 @@ int checkhost(const char *host, char **desc); /* *INDENT-ON* */ #endif +#endif /* NUT_CGILIB_H_SEEN */ diff --git a/clients/nutclient.cpp b/clients/nutclient.cpp index 8304473..6dfbe3a 100644 --- a/clients/nutclient.cpp +++ b/clients/nutclient.cpp @@ -28,7 +28,7 @@ /* Windows/Linux Socket compatibility layer: */ /* Thanks to Benjamin Roux (http://broux.developpez.com/articles/c/sockets/) */ #ifdef WIN32 -# include +# include #else # include # include @@ -39,7 +39,7 @@ # include # define INVALID_SOCKET -1 # define SOCKET_ERROR -1 -# define closesocket(s) close(s) +# define closesocket(s) close(s) typedef int SOCKET; typedef struct sockaddr_in SOCKADDR_IN; typedef struct sockaddr SOCKADDR; @@ -60,6 +60,23 @@ static inline void *xrealloc(void *ptr, size_t size){return realloc(ptr, size);} static inline char *xstrdup(const char *string){return strdup(string);} #endif /* HAVE_NUTCOMMON */ +/* To stay in line with modern C++, we use nullptr (not numeric NULL + * or shim __null on some systems) which was defined after C++98. + * The NUT C++ interface is intended for C++11 and newer, so we + * quiesce these warnigns if possible. + * An idea might be to detect if we do build with old C++ standard versions + * and define a nullptr like https://stackoverflow.com/a/44517878/4715872 + * but again - currently we do not intend to support that officially. + */ +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT_PEDANTIC +#pragma GCC diagnostic ignored "-Wc++98-compat-pedantic" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT +#pragma GCC diagnostic ignored "-Wc++98-compat" +#endif namespace nut { @@ -81,6 +98,23 @@ std::string SystemException::err() } } +/* Implemented out-of-line to avoid "Weak vtables" warnings and related overheads + * But now with clang-9 C++11 linter (though not C++17) they complain with + * error: definition of implicit copy constructor for 'NutException' + * is deprecated because it has a user-declared destructor + * This is fixed in header with declarations like: + * NutException(const NutException&) = default; + * and assignment operator to accompany the copy constructor, per + * https://lgtm.com/rules/2165180572/ like: + * NutException& operator=(NutException& rhs) = default; + */ +NutException::~NutException() {} +SystemException::~SystemException() {} +IOException::~IOException() {} +UnknownHostException::~UnknownHostException() {} +NotConnectedException::~NotConnectedException() {} +TimeoutException::~TimeoutException() {} + namespace internal { @@ -88,26 +122,27 @@ namespace internal /** * Internal socket wrapper. * Provides only client socket functions. - * + * * Implemented as separate internal class to easily hide plateform specificities. */ class Socket { public: Socket(); + ~Socket(); - void connect(const std::string& host, int port)throw(nut::IOException); + void connect(const std::string& host, uint16_t port); void disconnect(); bool isConnected()const; - void setTimeout(long timeout); + void setTimeout(time_t timeout); bool hasTimeout()const{return _tv.tv_sec>=0;} - size_t read(void* buf, size_t sz)throw(nut::IOException); - size_t write(const void* buf, size_t sz)throw(nut::IOException); + size_t read(void* buf, size_t sz); + size_t write(const void* buf, size_t sz); - std::string read()throw(nut::IOException); - void write(const std::string& str)throw(nut::IOException); + std::string read(); + void write(const std::string& str); private: @@ -124,12 +159,17 @@ _tv() _tv.tv_usec = 0; } -void Socket::setTimeout(long timeout) +Socket::~Socket() +{ + disconnect(); +} + +void Socket::setTimeout(time_t timeout) { _tv.tv_sec = timeout; } -void Socket::connect(const std::string& host, int port)throw(nut::IOException) +void Socket::connect(const std::string& host, uint16_t port) { int sock_fd; struct addrinfo hints, *res, *ai; @@ -146,7 +186,7 @@ void Socket::connect(const std::string& host, int port)throw(nut::IOException) throw nut::UnknownHostException(); } - snprintf(sport, sizeof(sport), "%hu", (unsigned short int)port); + snprintf(sport, sizeof(sport), "%ju", static_cast(port)); memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; @@ -169,7 +209,7 @@ void Socket::connect(const std::string& host, int port)throw(nut::IOException) } } - for (ai = res; ai != NULL; ai = ai->ai_next) { + for (ai = res; ai != nullptr; ai = ai->ai_next) { sock_fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); @@ -178,7 +218,7 @@ void Socket::connect(const std::string& host, int port)throw(nut::IOException) { case EAFNOSUPPORT: case EINVAL: - break; + break; default: throw nut::SystemException(); } @@ -196,11 +236,11 @@ void Socket::connect(const std::string& host, int port)throw(nut::IOException) if(errno == EINPROGRESS) { FD_ZERO(&wfds); FD_SET(sock_fd, &wfds); - select(sock_fd+1,NULL,&wfds,NULL, hasTimeout()?&_tv:NULL); + select(sock_fd+1, nullptr, &wfds, nullptr, hasTimeout() ? &_tv : nullptr); if (FD_ISSET(sock_fd, &wfds)) { error_size = sizeof(error); - getsockopt(sock_fd,SOL_SOCKET,SO_ERROR, - &error,&error_size); + getsockopt(sock_fd, SOL_SOCKET, SO_ERROR, + &error, &error_size); if( error == 0) { /* connect successful */ v = 0; @@ -256,10 +296,10 @@ void Socket::connect(const std::string& host, int port)throw(nut::IOException) #ifdef OLD - struct hostent *hostinfo = NULL; + struct hostent *hostinfo = nullptr; SOCKADDR_IN sin = { 0 }; hostinfo = ::gethostbyname(host.c_str()); - if(hostinfo == NULL) /* Host doesnt exist */ + if(hostinfo == nullptr) /* Host doesnt exist */ { throw nut::UnknownHostException(); } @@ -298,7 +338,7 @@ bool Socket::isConnected()const return _sock!=INVALID_SOCKET; } -size_t Socket::read(void* buf, size_t sz)throw(nut::IOException) +size_t Socket::read(void* buf, size_t sz) { if(!isConnected()) { @@ -310,7 +350,7 @@ size_t Socket::read(void* buf, size_t sz)throw(nut::IOException) fd_set fds; FD_ZERO(&fds); FD_SET(_sock, &fds); - int ret = select(_sock+1, &fds, NULL, NULL, &_tv); + int ret = select(_sock+1, &fds, nullptr, nullptr, &_tv); if (ret < 1) { throw nut::TimeoutException(); } @@ -322,10 +362,10 @@ size_t Socket::read(void* buf, size_t sz)throw(nut::IOException) disconnect(); throw nut::IOException("Error while reading on socket"); } - return (size_t) res; + return static_cast(res); } -size_t Socket::write(const void* buf, size_t sz)throw(nut::IOException) +size_t Socket::write(const void* buf, size_t sz) { if(!isConnected()) { @@ -337,7 +377,7 @@ size_t Socket::write(const void* buf, size_t sz)throw(nut::IOException) fd_set fds; FD_ZERO(&fds); FD_SET(_sock, &fds); - int ret = select(_sock+1, NULL, &fds, NULL, &_tv); + int ret = select(_sock+1, nullptr, &fds, nullptr, &_tv); if (ret < 1) { throw nut::TimeoutException(); } @@ -349,10 +389,10 @@ size_t Socket::write(const void* buf, size_t sz)throw(nut::IOException) disconnect(); throw nut::IOException("Error while writing on socket"); } - return (size_t) res; + return static_cast(res); } -std::string Socket::read()throw(nut::IOException) +std::string Socket::read() { std::string res; char buff[256]; @@ -383,7 +423,7 @@ std::string Socket::read()throw(nut::IOException) } } -void Socket::write(const std::string& str)throw(nut::IOException) +void Socket::write(const std::string& str) { // write(str.c_str(), str.size()); // write("\n", 1); @@ -400,6 +440,24 @@ void Socket::write(const std::string& str)throw(nut::IOException) * */ +/* Pedantic builds complain about the static variable below... + * It is assumed safe to ignore since it is a std::string with + * no complex teardown at program exit. + */ +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS || defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS) +#pragma GCC diagnostic push +# ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS +# pragma GCC diagnostic ignored "-Wglobal-constructors" +# endif +# ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS +# pragma GCC diagnostic ignored "-Wexit-time-destructors" +# endif +#endif +const Feature Client::TRACKING = "TRACKING"; +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS || defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS) +#pragma GCC diagnostic pop +#endif + Client::Client() { } @@ -408,59 +466,84 @@ Client::~Client() { } -bool Client::hasDevice(const std::string& dev)throw(NutException) +bool Client::hasDevice(const std::string& dev) { std::set devs = getDeviceNames(); return devs.find(dev) != devs.end(); } -Device Client::getDevice(const std::string& name)throw(NutException) +Device Client::getDevice(const std::string& name) { if(hasDevice(name)) return Device(this, name); else - return Device(NULL, ""); + return Device(nullptr, ""); } -std::set Client::getDevices()throw(NutException) +std::set Client::getDevices() { std::set res; std::set devs = getDeviceNames(); for(std::set::iterator it=devs.begin(); it!=devs.end(); ++it) { - res.insert(Device(this, *it)); + res.insert(Device(this, *it)); } return res; } -bool Client::hasDeviceVariable(const std::string& dev, const std::string& name)throw(NutException) +bool Client::hasDeviceVariable(const std::string& dev, const std::string& name) { std::set names = getDeviceVariableNames(dev); return names.find(name) != names.end(); } -std::map > Client::getDeviceVariableValues(const std::string& dev)throw(NutException) +std::map > Client::getDeviceVariableValues(const std::string& dev) { - std::map > res; + std::map > res; - std::set names = getDeviceVariableNames(dev); - for(std::set::iterator it=names.begin(); it!=names.end(); ++it) - { - const std::string& name = *it; - res[name] = getDeviceVariableValue(dev, name); - } + std::set names = getDeviceVariableNames(dev); + for(std::set::iterator it=names.begin(); it!=names.end(); ++it) + { + const std::string& name = *it; + res[name] = getDeviceVariableValue(dev, name); + } - return res; + return res; } -bool Client::hasDeviceCommand(const std::string& dev, const std::string& name)throw(NutException) +std::map > > Client::getDevicesVariableValues(const std::set& devs) { - std::set names = getDeviceCommandNames(dev); - return names.find(name) != names.end(); + std::map > > res; + + for(std::set::const_iterator it=devs.cbegin(); it!=devs.cend(); ++it) + { + res[*it] = getDeviceVariableValues(*it); + } + + return res; } +bool Client::hasDeviceCommand(const std::string& dev, const std::string& name) +{ + std::set names = getDeviceCommandNames(dev); + return names.find(name) != names.end(); +} + +bool Client::hasFeature(const Feature& feature) +{ + try + { + // If feature is known, querying it won't throw an exception. + isFeatureEnabled(feature); + return true; + } + catch(...) + { + return false; + } +} /* * @@ -472,13 +555,15 @@ TcpClient::TcpClient(): Client(), _host("localhost"), _port(3493), +_timeout(0), _socket(new internal::Socket) { // Do not connect now } -TcpClient::TcpClient(const std::string& host, int port)throw(IOException): +TcpClient::TcpClient(const std::string& host, uint16_t port): Client(), +_timeout(0), _socket(new internal::Socket) { connect(host, port); @@ -489,14 +574,14 @@ TcpClient::~TcpClient() delete _socket; } -void TcpClient::connect(const std::string& host, int port)throw(IOException) +void TcpClient::connect(const std::string& host, uint16_t port) { _host = host; _port = port; connect(); } -void TcpClient::connect()throw(nut::IOException) +void TcpClient::connect() { _socket->connect(_host, _port); } @@ -506,7 +591,7 @@ std::string TcpClient::getHost()const return _host; } -int TcpClient::getPort()const +uint16_t TcpClient::getPort()const { return _port; } @@ -521,30 +606,29 @@ void TcpClient::disconnect() _socket->disconnect(); } -void TcpClient::setTimeout(long timeout) +void TcpClient::setTimeout(time_t timeout) { _timeout = timeout; } -long TcpClient::getTimeout()const +time_t TcpClient::getTimeout()const { return _timeout; } void TcpClient::authenticate(const std::string& user, const std::string& passwd) - throw(NutException) { detectError(sendQuery("USERNAME " + user)); detectError(sendQuery("PASSWORD " + passwd)); } -void TcpClient::logout()throw(NutException) +void TcpClient::logout() { detectError(sendQuery("LOGOUT")); _socket->disconnect(); } -Device TcpClient::getDevice(const std::string& name)throw(NutException) +Device TcpClient::getDevice(const std::string& name) { try { @@ -553,14 +637,14 @@ Device TcpClient::getDevice(const std::string& name)throw(NutException) catch(NutException& ex) { if(ex.str()=="UNKNOWN-UPS") - return Device(NULL, ""); + return Device(nullptr, ""); else throw; } return Device(this, name); } -std::set TcpClient::getDeviceNames()throw(NutException) +std::set TcpClient::getDeviceNames() { std::set res; @@ -576,15 +660,15 @@ std::set TcpClient::getDeviceNames()throw(NutException) return res; } -std::string TcpClient::getDeviceDescription(const std::string& name)throw(NutException) +std::string TcpClient::getDeviceDescription(const std::string& name) { - return get("UPSDESC", name)[0]; + return get("UPSDESC", name)[0]; } -std::set TcpClient::getDeviceVariableNames(const std::string& dev)throw(NutException) +std::set TcpClient::getDeviceVariableNames(const std::string& dev) { std::set set; - + std::vector > res = list("VAR", dev); for(size_t n=0; n TcpClient::getDeviceVariableNames(const std::string& dev)t return set; } -std::set TcpClient::getDeviceRWVariableNames(const std::string& dev)throw(NutException) +std::set TcpClient::getDeviceRWVariableNames(const std::string& dev) { std::set set; - + std::vector > res = list("RW", dev); for(size_t n=0; n TcpClient::getDeviceRWVariableNames(const std::string& dev return set; } -std::string TcpClient::getDeviceVariableDescription(const std::string& dev, const std::string& name)throw(NutException) +std::string TcpClient::getDeviceVariableDescription(const std::string& dev, const std::string& name) { return get("DESC", dev + " " + name)[0]; } -std::vector TcpClient::getDeviceVariableValue(const std::string& dev, const std::string& name)throw(NutException) +std::vector TcpClient::getDeviceVariableValue(const std::string& dev, const std::string& name) { return get("VAR", dev + " " + name); } -std::map > TcpClient::getDeviceVariableValues(const std::string& dev)throw(NutException) +std::map > TcpClient::getDeviceVariableValues(const std::string& dev) { std::map > map; - + std::vector > res = list("VAR", dev); for(size_t n=0; n > TcpClient::getDeviceVariableValu return map; } -void TcpClient::setDeviceVariable(const std::string& dev, const std::string& name, const std::string& value)throw(NutException) +std::map > > TcpClient::getDevicesVariableValues(const std::set& devs) { - std::string query = "SET VAR " + dev + " " + name + " " + escape(value); - detectError(sendQuery(query)); + std::map > > map; + + if (devs.empty()) + { + // This request might come from processing the empty valid + // response of an upsd server which was allowed to start + // with no device sections in its ups.conf + return map; + } + + std::vector queries; + for (std::set::const_iterator it=devs.cbegin(); it!=devs.cend(); ++it) + { + queries.push_back("LIST VAR " + *it); + } + sendAsyncQueries(queries); + + for (std::set::const_iterator it=devs.cbegin(); it!=devs.cend(); ++it) + { + try + { + std::map > map2; + std::vector > res = parseList("VAR " + *it); + for (std::vector >::iterator it2=res.begin(); it2!=res.end(); ++it2) + { + std::vector& vals = *it2; + std::string var = vals[0]; + vals.erase(vals.begin()); + map2[var] = vals; + } + map[*it] = map2; + } + catch (NutException&) + { + // We sent a bunch of queries, we need to process them all to clear up the backlog. + } + } + + if (map.empty()) + { + // We may fail on some devices, but not on ALL devices. + throw NutException("Invalid device"); + } + + return map; } -void TcpClient::setDeviceVariable(const std::string& dev, const std::string& name, const std::vector& values)throw(NutException) +TrackingID TcpClient::setDeviceVariable(const std::string& dev, const std::string& name, const std::string& value) +{ + std::string query = "SET VAR " + dev + " " + name + " " + escape(value); + return sendTrackingQuery(query); +} + +TrackingID TcpClient::setDeviceVariable(const std::string& dev, const std::string& name, const std::vector& values) { std::string query = "SET VAR " + dev + " " + name; for(size_t n=0; n TcpClient::getDeviceCommandNames(const std::string& dev)throw(NutException) +std::set TcpClient::getDeviceCommandNames(const std::string& dev) { std::set cmds; @@ -663,40 +796,122 @@ std::set TcpClient::getDeviceCommandNames(const std::string& dev)th return cmds; } -std::string TcpClient::getDeviceCommandDescription(const std::string& dev, const std::string& name)throw(NutException) +std::string TcpClient::getDeviceCommandDescription(const std::string& dev, const std::string& name) { return get("CMDDESC", dev + " " + name)[0]; } -void TcpClient::executeDeviceCommand(const std::string& dev, const std::string& name)throw(NutException) +TrackingID TcpClient::executeDeviceCommand(const std::string& dev, const std::string& name, const std::string& param) { - detectError(sendQuery("INSTCMD " + dev + " " + name)); + return sendTrackingQuery("INSTCMD " + dev + " " + name + " " + param); } -void TcpClient::deviceLogin(const std::string& dev)throw(NutException) +void TcpClient::deviceLogin(const std::string& dev) { detectError(sendQuery("LOGIN " + dev)); } -void TcpClient::deviceMaster(const std::string& dev)throw(NutException) +/* NOTE: "master" is deprecated since NUT v2.8.0 in favor of "primary". + * For the sake of old/new server/client interoperability, + * practical implementations should try to use one and fall + * back to the other, and only fail if both return "ERR". + */ +void TcpClient::deviceMaster(const std::string& dev) { - detectError(sendQuery("MASTER " + dev)); + try { + detectError(sendQuery("MASTER " + dev)); + } catch (NutException &exOrig) { + try { + detectError(sendQuery("PRIMARY " + dev)); + } catch (NutException &exRetry) { + NUT_UNUSED_VARIABLE(exRetry); + throw exOrig; + } + } } -void TcpClient::deviceForcedShutdown(const std::string& dev)throw(NutException) +void TcpClient::devicePrimary(const std::string& dev) +{ + try { + detectError(sendQuery("PRIMARY " + dev)); + } catch (NutException &exOrig) { + try { + detectError(sendQuery("MASTER " + dev)); + } catch (NutException &exRetry) { + NUT_UNUSED_VARIABLE(exRetry); + throw exOrig; + } + } +} + +void TcpClient::deviceForcedShutdown(const std::string& dev) { detectError(sendQuery("FSD " + dev)); } -int TcpClient::deviceGetNumLogins(const std::string& dev)throw(NutException) +int TcpClient::deviceGetNumLogins(const std::string& dev) { std::string num = get("NUMLOGINS", dev)[0]; return atoi(num.c_str()); } +TrackingResult TcpClient::getTrackingResult(const TrackingID& id) +{ + if (id.empty()) + { + return TrackingResult::SUCCESS; + } + + std::string result = sendQuery("GET TRACKING " + id); + + if (result == "PENDING") + { + return TrackingResult::PENDING; + } + else if (result == "SUCCESS") + { + return TrackingResult::SUCCESS; + } + else if (result == "ERR UNKNOWN") + { + return TrackingResult::UNKNOWN; + } + else if (result == "ERR INVALID-ARGUMENT") + { + return TrackingResult::INVALID_ARGUMENT; + } + else + { + return TrackingResult::FAILURE; + } +} + +bool TcpClient::isFeatureEnabled(const Feature& feature) +{ + std::string result = sendQuery("GET " + feature); + detectError(result); + + if (result == "ON") + { + return true; + } + else if (result == "OFF") + { + return false; + } + else + { + throw NutException("Unknown feature result " + result); + } +} +void TcpClient::setFeature(const Feature& feature, bool status) +{ + std::string result = sendQuery("SET " + feature + " " + (status ? "ON" : "OFF")); + detectError(result); +} std::vector TcpClient::get - (const std::string& subcmd, const std::string& params) throw(NutException) + (const std::string& subcmd, const std::string& params) { std::string req = subcmd; if(!params.empty()) @@ -709,19 +924,28 @@ std::vector TcpClient::get { throw NutException("Invalid response"); } - + return explode(res, req.size()); } std::vector > TcpClient::list - (const std::string& subcmd, const std::string& params) throw(NutException) + (const std::string& subcmd, const std::string& params) { std::string req = subcmd; if(!params.empty()) { req += " " + params; } - std::string res = sendQuery("LIST " + req); + std::vector query; + query.push_back("LIST " + req); + sendAsyncQueries(query); + return parseList(req); +} + +std::vector > TcpClient::parseList + (const std::string& req) +{ + std::string res = _socket->read(); detectError(res); if(res != ("BEGIN LIST " + req)) { @@ -748,13 +972,21 @@ std::vector > TcpClient::list } } -std::string TcpClient::sendQuery(const std::string& req)throw(IOException) +std::string TcpClient::sendQuery(const std::string& req) { _socket->write(req); return _socket->read(); } -void TcpClient::detectError(const std::string& req)throw(NutException) +void TcpClient::sendAsyncQueries(const std::vector& req) +{ + for (std::vector::const_iterator it = req.cbegin(); it != req.cend(); ++it) + { + _socket->write(*it); + } +} + +void TcpClient::detectError(const std::string& req) { if(req.substr(0,3)=="ERR") { @@ -821,7 +1053,7 @@ std::vector TcpClient::explode(const std::string& str, size_t begin else { temp += c; - } + } break; case QUOTED_STRING: if(c=='\\') @@ -876,7 +1108,7 @@ std::vector TcpClient::explode(const std::string& str, size_t begin std::string TcpClient::escape(const std::string& str) { std::string res = "\""; - + for(size_t n=0; n res = explode(reply); + + if (res.size() == 1 && res[0] == "OK") + { + return TrackingID(""); + } + else if (res.size() == 3 && res[0] == "OK" && res[1] == "TRACKING") + { + return TrackingID(res[2]); + } + else + { + throw NutException("Unknown query result"); + } } /* @@ -910,6 +1162,17 @@ _name(dev._name) { } +Device& Device::operator=(const Device& dev) +{ + // Self assignment? + if (this==&dev) + return *this; + + _client = dev._client; + _name = dev._name; + return *this; +} + Device::~Device() { } @@ -931,12 +1194,12 @@ Client* Device::getClient() bool Device::isOk()const { - return _client!=NULL && !_name.empty(); + return _client!=nullptr && !_name.empty(); } Device::operator bool()const { - return isOk(); + return isOk(); } bool Device::operator!()const @@ -951,89 +1214,97 @@ bool Device::operator==(const Device& dev)const bool Device::operator<(const Device& dev)const { - return getName()getDeviceDescription(getName()); } std::vector Device::getVariableValue(const std::string& name) - throw(NutException) { + if (!isOk()) throw NutException("Invalid device"); return getClient()->getDeviceVariableValue(getName(), name); } std::map > Device::getVariableValues() - throw(NutException) { + if (!isOk()) throw NutException("Invalid device"); return getClient()->getDeviceVariableValues(getName()); } -std::set Device::getVariableNames()throw(NutException) +std::set Device::getVariableNames() { - return getClient()->getDeviceVariableNames(getName()); + if (!isOk()) throw NutException("Invalid device"); + return getClient()->getDeviceVariableNames(getName()); } -std::set Device::getRWVariableNames()throw(NutException) +std::set Device::getRWVariableNames() { - return getClient()->getDeviceRWVariableNames(getName()); + if (!isOk()) throw NutException("Invalid device"); + return getClient()->getDeviceRWVariableNames(getName()); } -void Device::setVariable(const std::string& name, const std::string& value)throw(NutException) +void Device::setVariable(const std::string& name, const std::string& value) { - getClient()->setDeviceVariable(getName(), name, value); + if (!isOk()) throw NutException("Invalid device"); + getClient()->setDeviceVariable(getName(), name, value); } void Device::setVariable(const std::string& name, const std::vector& values) - throw(NutException) { - getClient()->setDeviceVariable(getName(), name, values); + if (!isOk()) throw NutException("Invalid device"); + getClient()->setDeviceVariable(getName(), name, values); } -Variable Device::getVariable(const std::string& name)throw(NutException) +Variable Device::getVariable(const std::string& name) { - if(getClient()->hasDeviceVariable(getName(), name)) - return Variable(this, name); - else - return Variable(NULL, ""); + if (!isOk()) throw NutException("Invalid device"); + if(getClient()->hasDeviceVariable(getName(), name)) + return Variable(this, name); + else + return Variable(nullptr, ""); } -std::set Device::getVariables()throw(NutException) +std::set Device::getVariables() { std::set set; + if (!isOk()) throw NutException("Invalid device"); - std::set names = getClient()->getDeviceVariableNames(getName()); - for(std::set::iterator it=names.begin(); it!=names.end(); ++it) - { + std::set names = getClient()->getDeviceVariableNames(getName()); + for(std::set::iterator it=names.begin(); it!=names.end(); ++it) + { set.insert(Variable(this, *it)); - } + } return set; } -std::set Device::getRWVariables()throw(NutException) +std::set Device::getRWVariables() { std::set set; + if (!isOk()) throw NutException("Invalid device"); - std::set names = getClient()->getDeviceRWVariableNames(getName()); - for(std::set::iterator it=names.begin(); it!=names.end(); ++it) - { + std::set names = getClient()->getDeviceRWVariableNames(getName()); + for(std::set::iterator it=names.begin(); it!=names.end(); ++it) + { set.insert(Variable(this, *it)); - } + } return set; } -std::set Device::getCommandNames()throw(NutException) +std::set Device::getCommandNames() { - return getClient()->getDeviceCommandNames(getName()); + if (!isOk()) throw NutException("Invalid device"); + return getClient()->getDeviceCommandNames(getName()); } -std::set Device::getCommands()throw(NutException) +std::set Device::getCommands() { std::set cmds; @@ -1046,36 +1317,49 @@ std::set Device::getCommands()throw(NutException) return cmds; } -Command Device::getCommand(const std::string& name)throw(NutException) +Command Device::getCommand(const std::string& name) { - if(getClient()->hasDeviceCommand(getName(), name)) - return Command(this, name); - else - return Command(NULL, ""); + if (!isOk()) throw NutException("Invalid device"); + if(getClient()->hasDeviceCommand(getName(), name)) + return Command(this, name); + else + return Command(nullptr, ""); } -void Device::executeCommand(const std::string& name)throw(NutException) +TrackingID Device::executeCommand(const std::string& name, const std::string& param) { - getClient()->executeDeviceCommand(getName(), name); + if (!isOk()) throw NutException("Invalid device"); + return getClient()->executeDeviceCommand(getName(), name, param); } -void Device::login()throw(NutException) +void Device::login() { - getClient()->deviceLogin(getName()); + if (!isOk()) throw NutException("Invalid device"); + getClient()->deviceLogin(getName()); } -void Device::master()throw(NutException) +/* Note: "master" is deprecated, but supported + * for mixing old/new client/server combos: */ +void Device::master() { - getClient()->deviceMaster(getName()); + if (!isOk()) throw NutException("Invalid device"); + getClient()->deviceMaster(getName()); } -void Device::forcedShutdown()throw(NutException) +void Device::primary() +{ + if (!isOk()) throw NutException("Invalid device"); + getClient()->devicePrimary(getName()); +} + +void Device::forcedShutdown() { } -int Device::getNumLogins()throw(NutException) +int Device::getNumLogins() { - return getClient()->deviceGetNumLogins(getName()); + if (!isOk()) throw NutException("Invalid device"); + return getClient()->deviceGetNumLogins(getName()); } /* @@ -1096,6 +1380,17 @@ _name(var._name) { } +Variable& Variable::operator=(const Variable& var) +{ + // Self assignment? + if (this==&var) + return *this; + + _device = var._device; + _name = var._name; + return *this; +} + Variable::~Variable() { } @@ -1117,7 +1412,7 @@ Device* Variable::getDevice() bool Variable::isOk()const { - return _device!=NULL && !_name.empty(); + return _device!=nullptr && !_name.empty(); } @@ -1141,22 +1436,22 @@ bool Variable::operator<(const Variable& var)const return getName() Variable::getValue()throw(NutException) +std::vector Variable::getValue() { - return getDevice()->getClient()->getDeviceVariableValue(getDevice()->getName(), getName()); + return getDevice()->getClient()->getDeviceVariableValue(getDevice()->getName(), getName()); } -std::string Variable::getDescription()throw(NutException) +std::string Variable::getDescription() { - return getDevice()->getClient()->getDeviceVariableDescription(getDevice()->getName(), getName()); + return getDevice()->getClient()->getDeviceVariableDescription(getDevice()->getName(), getName()); } -void Variable::setValue(const std::string& value)throw(NutException) +void Variable::setValue(const std::string& value) { getDevice()->setVariable(getName(), value); } -void Variable::setValues(const std::vector& values)throw(NutException) +void Variable::setValues(const std::vector& values) { getDevice()->setVariable(getName(), values); } @@ -1180,6 +1475,17 @@ _name(cmd._name) { } +Command& Command::operator=(const Command& cmd) +{ + // Self assignment? + if (this==&cmd) + return *this; + + _device = cmd._device; + _name = cmd._name; + return *this; +} + Command::~Command() { } @@ -1201,8 +1507,7 @@ Device* Command::getDevice() bool Command::isOk()const { - return _device!=NULL && !_name.empty(); - + return _device!=nullptr && !_name.empty(); } Command::operator bool()const @@ -1225,14 +1530,14 @@ bool Command::operator<(const Command& cmd)const return getName()getClient()->getDeviceCommandDescription(getDevice()->getName(), getName()); } -void Command::execute()throw(NutException) +void Command::execute(const std::string& param) { - getDevice()->executeCommand(getName()); + getDevice()->executeCommand(getName(), param); } } /* namespace nut */ @@ -1244,17 +1549,22 @@ void Command::execute()throw(NutException) extern "C" { -strarr strarr_alloc(unsigned short count) +strarr strarr_alloc(size_t count) { - strarr arr = (strarr)xcalloc(count+1, sizeof(char*)); - arr[count] = NULL; + strarr arr = static_cast(xcalloc(count+1, sizeof(char*))); + + if (arr == nullptr) { + throw nut::NutException("Out of memory"); + } + + arr[count] = nullptr; return arr; } void strarr_free(strarr arr) { char** pstr = arr; - while(*pstr!=NULL) + while(*pstr!=nullptr) { free(*pstr); ++pstr; @@ -1262,52 +1572,53 @@ void strarr_free(strarr arr) free(arr); } - -static strarr stringset_to_strarr(const std::set& strset) +strarr stringset_to_strarr(const std::set& strset) { strarr arr = strarr_alloc(strset.size()); strarr pstr = arr; for(std::set::const_iterator it=strset.begin(); it!=strset.end(); ++it) { *pstr = xstrdup(it->c_str()); + pstr++; } - return arr; + return arr; } -static strarr stringvector_to_strarr(const std::vector& strset) +strarr stringvector_to_strarr(const std::vector& strset) { strarr arr = strarr_alloc(strset.size()); strarr pstr = arr; for(std::vector::const_iterator it=strset.begin(); it!=strset.end(); ++it) { *pstr = xstrdup(it->c_str()); + pstr++; } - return arr; + return arr; } - -NUTCLIENT_TCP_t nutclient_tcp_create_client(const char* host, unsigned short port) +NUTCLIENT_TCP_t nutclient_tcp_create_client(const char* host, uint16_t port) { nut::TcpClient* client = new nut::TcpClient; try { client->connect(host, port); - return (NUTCLIENT_TCP_t)client; + return static_cast(client); } catch(nut::NutException& ex) { // TODO really catch it + NUT_UNUSED_VARIABLE(ex); delete client; - return NULL; + return nullptr; } - + } void nutclient_destroy(NUTCLIENT_t client) { if(client) { - delete (nut::Client*)client; + delete static_cast(client); } } @@ -1315,7 +1626,7 @@ int nutclient_tcp_is_connected(NUTCLIENT_TCP_t client) { if(client) { - nut::TcpClient* cl = dynamic_cast((nut::Client*)client); + nut::TcpClient* cl = dynamic_cast(static_cast(client)); if(cl) { return cl->isConnected() ? 1 : 0; @@ -1328,7 +1639,7 @@ void nutclient_tcp_disconnect(NUTCLIENT_TCP_t client) { if(client) { - nut::TcpClient* cl = dynamic_cast((nut::Client*)client); + nut::TcpClient* cl = dynamic_cast(static_cast(client)); if(cl) { cl->disconnect(); @@ -1336,12 +1647,11 @@ void nutclient_tcp_disconnect(NUTCLIENT_TCP_t client) } } - int nutclient_tcp_reconnect(NUTCLIENT_TCP_t client) { if(client) { - nut::TcpClient* cl = dynamic_cast((nut::Client*)client); + nut::TcpClient* cl = dynamic_cast(static_cast(client)); if(cl) { try @@ -1355,11 +1665,11 @@ int nutclient_tcp_reconnect(NUTCLIENT_TCP_t client) return -1; } -void nutclient_tcp_set_timeout(NUTCLIENT_TCP_t client, long timeout) +void nutclient_tcp_set_timeout(NUTCLIENT_TCP_t client, time_t timeout) { if(client) { - nut::TcpClient* cl = dynamic_cast((nut::Client*)client); + nut::TcpClient* cl = dynamic_cast(static_cast(client)); if(cl) { cl->setTimeout(timeout); @@ -1367,11 +1677,11 @@ void nutclient_tcp_set_timeout(NUTCLIENT_TCP_t client, long timeout) } } -long nutclient_tcp_get_timeout(NUTCLIENT_TCP_t client) +time_t nutclient_tcp_get_timeout(NUTCLIENT_TCP_t client) { if(client) { - nut::TcpClient* cl = dynamic_cast((nut::Client*)client); + nut::TcpClient* cl = dynamic_cast(static_cast(client)); if(cl) { return cl->getTimeout(); @@ -1380,12 +1690,11 @@ long nutclient_tcp_get_timeout(NUTCLIENT_TCP_t client) return -1; } - void nutclient_authenticate(NUTCLIENT_t client, const char* login, const char* passwd) { if(client) { - nut::Client* cl = (nut::Client*)client; + nut::Client* cl = static_cast(client); if(cl) { try @@ -1401,7 +1710,7 @@ void nutclient_logout(NUTCLIENT_t client) { if(client) { - nut::Client* cl = (nut::Client*)client; + nut::Client* cl = static_cast(client); if(cl) { try @@ -1417,7 +1726,7 @@ void nutclient_device_login(NUTCLIENT_t client, const char* dev) { if(client) { - nut::Client* cl = (nut::Client*)client; + nut::Client* cl = static_cast(client); if(cl) { try @@ -1433,7 +1742,7 @@ int nutclient_get_device_num_logins(NUTCLIENT_t client, const char* dev) { if(client) { - nut::Client* cl = (nut::Client*)client; + nut::Client* cl = static_cast(client); if(cl) { try @@ -1446,12 +1755,13 @@ int nutclient_get_device_num_logins(NUTCLIENT_t client, const char* dev) return -1; } - +/* Note: "master" is deprecated, but supported + * for mixing old/new client/server combos: */ void nutclient_device_master(NUTCLIENT_t client, const char* dev) { if(client) { - nut::Client* cl = (nut::Client*)client; + nut::Client* cl = static_cast(client); if(cl) { try @@ -1463,11 +1773,27 @@ void nutclient_device_master(NUTCLIENT_t client, const char* dev) } } +void nutclient_device_primary(NUTCLIENT_t client, const char* dev) +{ + if(client) + { + nut::Client* cl = static_cast(client); + if(cl) + { + try + { + cl->devicePrimary(dev); + } + catch(...){} + } + } +} + void nutclient_device_forced_shutdown(NUTCLIENT_t client, const char* dev) { if(client) { - nut::Client* cl = (nut::Client*)client; + nut::Client* cl = static_cast(client); if(cl) { try @@ -1483,7 +1809,7 @@ strarr nutclient_get_devices(NUTCLIENT_t client) { if(client) { - nut::Client* cl = (nut::Client*)client; + nut::Client* cl = static_cast(client); if(cl) { try @@ -1493,14 +1819,14 @@ strarr nutclient_get_devices(NUTCLIENT_t client) catch(...){} } } - return NULL; + return nullptr; } int nutclient_has_device(NUTCLIENT_t client, const char* dev) { if(client) { - nut::Client* cl = (nut::Client*)client; + nut::Client* cl = static_cast(client); if(cl) { try @@ -1517,7 +1843,7 @@ char* nutclient_get_device_description(NUTCLIENT_t client, const char* dev) { if(client) { - nut::Client* cl = (nut::Client*)client; + nut::Client* cl = static_cast(client); if(cl) { try @@ -1527,14 +1853,14 @@ char* nutclient_get_device_description(NUTCLIENT_t client, const char* dev) catch(...){} } } - return NULL; + return nullptr; } strarr nutclient_get_device_variables(NUTCLIENT_t client, const char* dev) { if(client) { - nut::Client* cl = (nut::Client*)client; + nut::Client* cl = static_cast(client); if(cl) { try @@ -1544,14 +1870,14 @@ strarr nutclient_get_device_variables(NUTCLIENT_t client, const char* dev) catch(...){} } } - return NULL; + return nullptr; } strarr nutclient_get_device_rw_variables(NUTCLIENT_t client, const char* dev) { if(client) { - nut::Client* cl = (nut::Client*)client; + nut::Client* cl = static_cast(client); if(cl) { try @@ -1561,14 +1887,14 @@ strarr nutclient_get_device_rw_variables(NUTCLIENT_t client, const char* dev) catch(...){} } } - return NULL; + return nullptr; } int nutclient_has_device_variable(NUTCLIENT_t client, const char* dev, const char* var) { if(client) { - nut::Client* cl = (nut::Client*)client; + nut::Client* cl = static_cast(client); if(cl) { try @@ -1585,7 +1911,7 @@ char* nutclient_get_device_variable_description(NUTCLIENT_t client, const char* { if(client) { - nut::Client* cl = (nut::Client*)client; + nut::Client* cl = static_cast(client); if(cl) { try @@ -1595,14 +1921,14 @@ char* nutclient_get_device_variable_description(NUTCLIENT_t client, const char* catch(...){} } } - return NULL; + return nullptr; } strarr nutclient_get_device_variable_values(NUTCLIENT_t client, const char* dev, const char* var) { if(client) { - nut::Client* cl = (nut::Client*)client; + nut::Client* cl = static_cast(client); if(cl) { try @@ -1612,14 +1938,14 @@ strarr nutclient_get_device_variable_values(NUTCLIENT_t client, const char* dev, catch(...){} } } - return NULL; + return nullptr; } void nutclient_set_device_variable_value(NUTCLIENT_t client, const char* dev, const char* var, const char* value) { if(client) { - nut::Client* cl = (nut::Client*)client; + nut::Client* cl = static_cast(client); if(cl) { try @@ -1635,13 +1961,13 @@ void nutclient_set_device_variable_values(NUTCLIENT_t client, const char* dev, c { if(client) { - nut::Client* cl = (nut::Client*)client; + nut::Client* cl = static_cast(client); if(cl) { try { std::vector vals; - strarr pstr = (strarr)values; + strarr pstr = static_cast(values); while(*pstr) { vals.push_back(std::string(*pstr)); @@ -1655,13 +1981,11 @@ void nutclient_set_device_variable_values(NUTCLIENT_t client, const char* dev, c } } - - strarr nutclient_get_device_commands(NUTCLIENT_t client, const char* dev) { if(client) { - nut::Client* cl = (nut::Client*)client; + nut::Client* cl = static_cast(client); if(cl) { try @@ -1671,15 +1995,14 @@ strarr nutclient_get_device_commands(NUTCLIENT_t client, const char* dev) catch(...){} } } - return NULL; + return nullptr; } - int nutclient_has_device_command(NUTCLIENT_t client, const char* dev, const char* cmd) { if(client) { - nut::Client* cl = (nut::Client*)client; + nut::Client* cl = static_cast(client); if(cl) { try @@ -1692,12 +2015,11 @@ int nutclient_has_device_command(NUTCLIENT_t client, const char* dev, const char return 0; } - char* nutclient_get_device_command_description(NUTCLIENT_t client, const char* dev, const char* cmd) { if(client) { - nut::Client* cl = (nut::Client*)client; + nut::Client* cl = static_cast(client); if(cl) { try @@ -1707,25 +2029,27 @@ char* nutclient_get_device_command_description(NUTCLIENT_t client, const char* d catch(...){} } } - return NULL; + return nullptr; } -void nutclient_execute_device_command(NUTCLIENT_t client, const char* dev, const char* cmd) +void nutclient_execute_device_command(NUTCLIENT_t client, const char* dev, const char* cmd, const char* param) { if(client) { - nut::Client* cl = (nut::Client*)client; + nut::Client* cl = static_cast(client); if(cl) { try { - cl->executeDeviceCommand(dev, cmd); + cl->executeDeviceCommand(dev, cmd, param); } catch(...){} } } } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT +#pragma GCC diagnostic pop +#endif + } /* extern "C" */ - - diff --git a/clients/nutclient.h b/clients/nutclient.h index ed2ea44..e1020f2 100644 --- a/clients/nutclient.h +++ b/clients/nutclient.h @@ -28,6 +28,13 @@ #include #include #include +#include +#include + +/* See include/common.h for details behind this */ +#ifndef NUT_UNUSED_VARIABLE +#define NUT_UNUSED_VARIABLE(x) (void)(x) +#endif namespace nut { @@ -51,9 +58,11 @@ class NutException : public std::exception { public: NutException(const std::string& msg):_msg(msg){} - virtual ~NutException() throw() {} - virtual const char * what() const throw() {return this->_msg.c_str();} - virtual std::string str() const throw() {return this->_msg;} + NutException(const NutException&) = default; + NutException& operator=(NutException& rhs) = default; + virtual ~NutException() override; + virtual const char * what() const noexcept override {return this->_msg.c_str();} + virtual std::string str() const noexcept {return this->_msg;} private: std::string _msg; }; @@ -65,7 +74,9 @@ class SystemException : public NutException { public: SystemException(); - virtual ~SystemException() throw() {} + SystemException(const SystemException&) = default; + SystemException& operator=(SystemException& rhs) = default; + virtual ~SystemException() override; private: static std::string err(); }; @@ -78,7 +89,9 @@ class IOException : public NutException { public: IOException(const std::string& msg):NutException(msg){} - virtual ~IOException() throw() {} + IOException(const IOException&) = default; + IOException& operator=(IOException& rhs) = default; + virtual ~IOException() override; }; /** @@ -88,7 +101,9 @@ class UnknownHostException : public IOException { public: UnknownHostException():IOException("Unknown host"){} - virtual ~UnknownHostException() throw() {} + UnknownHostException(const UnknownHostException&) = default; + UnknownHostException& operator=(UnknownHostException& rhs) = default; + virtual ~UnknownHostException() override; }; /** @@ -98,7 +113,9 @@ class NotConnectedException : public IOException { public: NotConnectedException():IOException("Not connected"){} - virtual ~NotConnectedException() throw() {} + NotConnectedException(const NotConnectedException&) = default; + NotConnectedException& operator=(NotConnectedException& rhs) = default; + virtual ~NotConnectedException() override; }; /** @@ -108,9 +125,30 @@ class TimeoutException : public IOException { public: TimeoutException():IOException("Timeout"){} - virtual ~TimeoutException() throw() {} + TimeoutException(const TimeoutException&) = default; + TimeoutException& operator=(TimeoutException& rhs) = default; + virtual ~TimeoutException() override; }; +/** + * Cookie given when performing async action, used to redeem result at a later date. + */ +typedef std::string TrackingID; + +/** + * Result of an async action. + */ +typedef enum +{ + UNKNOWN, + PENDING, + SUCCESS, + INVALID_ARGUMENT, + FAILURE, +} TrackingResult; + +typedef std::string Feature; + /** * A nut client is the starting point to dialog to NUTD. * It can connect to an NUTD then retrieve its device list. @@ -122,7 +160,7 @@ class Client friend class Variable; friend class Command; public: - ~Client(); + virtual ~Client(); /** * Intend to authenticate to a NUTD server. @@ -132,13 +170,13 @@ public: * \todo Is his method is global to all connection protocol or is it specific to TCP ? * \note Actually, authentication fails only if already set, not if bad values are sent. */ - virtual void authenticate(const std::string& user, const std::string& passwd)throw(NutException)=0; + virtual void authenticate(const std::string& user, const std::string& passwd) = 0; /** * Disconnect from the NUTD server. * \todo Is his method is global to all connection protocol or is it specific to TCP ? */ - virtual void logout()throw(NutException)=0; + virtual void logout() = 0; /** * Device manipulations. @@ -151,29 +189,29 @@ public: * \param name Name of the device. * \return The device. */ - virtual Device getDevice(const std::string& name)throw(NutException); + virtual Device getDevice(const std::string& name); /** * Retrieve the list of all devices supported by UPSD server. * \return The set of supported devices. */ - virtual std::set getDevices()throw(NutException); + virtual std::set getDevices(); /** * Test if a device is supported by the NUTD server. * \param dev Device name. * \return true if supported, false otherwise. */ - virtual bool hasDevice(const std::string& dev)throw(NutException); + virtual bool hasDevice(const std::string& dev); /** * Retrieve names of devices supported by NUTD server. * \return The set of names of supported devices. */ - virtual std::set getDeviceNames()throw(NutException)=0; + virtual std::set getDeviceNames() = 0; /** * Retrieve the description of a device. * \param name Device name. * \return Device description. */ - virtual std::string getDeviceDescription(const std::string& name)throw(NutException)=0; + virtual std::string getDeviceDescription(const std::string& name) = 0; /** \} */ /** @@ -186,54 +224,60 @@ public: * \param dev Device name * \return Variable names */ - virtual std::set getDeviceVariableNames(const std::string& dev)throw(NutException)=0; + virtual std::set getDeviceVariableNames(const std::string& dev) = 0; /** * Retrieve names of read/write variables supported by a device. * \param dev Device name * \return RW variable names */ - virtual std::set getDeviceRWVariableNames(const std::string& dev)throw(NutException)=0; + virtual std::set getDeviceRWVariableNames(const std::string& dev) = 0; /** * Test if a variable is supported by a device. * \param dev Device name * \param name Variable name * \return true if the variable is supported. */ - virtual bool hasDeviceVariable(const std::string& dev, const std::string& name)throw(NutException); + virtual bool hasDeviceVariable(const std::string& dev, const std::string& name); /** * Retrieve the description of a variable. * \param dev Device name * \param name Variable name * \return Variable description if provided. */ - virtual std::string getDeviceVariableDescription(const std::string& dev, const std::string& name)throw(NutException)=0; + virtual std::string getDeviceVariableDescription(const std::string& dev, const std::string& name) = 0; /** * Retrieve values of a variable. * \param dev Device name * \param name Variable name * \return Variable values (usually one) if available. */ - virtual std::vector getDeviceVariableValue(const std::string& dev, const std::string& name)throw(NutException)=0; + virtual std::vector getDeviceVariableValue(const std::string& dev, const std::string& name) = 0; /** * Retrieve values of all variables of a device. * \param dev Device name * \return Variable values indexed by variable names. */ - virtual std::map > getDeviceVariableValues(const std::string& dev)throw(NutException); + virtual std::map > getDeviceVariableValues(const std::string& dev); + /** + * Retrieve values of all variables of a set of devices. + * \param devs Device names + * \return Variable values indexed by variable names, indexed by device names. + */ + virtual std::map > > getDevicesVariableValues(const std::set& devs); /** * Intend to set the value of a variable. * \param dev Device name * \param name Variable name * \param value Variable value - */ - virtual void setDeviceVariable(const std::string& dev, const std::string& name, const std::string& value)throw(NutException)=0; + */ + virtual TrackingID setDeviceVariable(const std::string& dev, const std::string& name, const std::string& value) = 0; /** * Intend to set the value of a variable. * \param dev Device name * \param name Variable name - * \param value Variable value - */ - virtual void setDeviceVariable(const std::string& dev, const std::string& name, const std::vector& values)throw(NutException)=0; + * \param values Vector of variable values + */ + virtual TrackingID setDeviceVariable(const std::string& dev, const std::string& name, const std::vector& values) = 0; /** \} */ /** @@ -246,27 +290,28 @@ public: * \param dev Device name * \return Command names */ - virtual std::set getDeviceCommandNames(const std::string& dev)throw(NutException)=0; + virtual std::set getDeviceCommandNames(const std::string& dev) = 0; /** * Test if a command is supported by a device. * \param dev Device name * \param name Command name * \return true if the command is supported. */ - virtual bool hasDeviceCommand(const std::string& dev, const std::string& name)throw(NutException); + virtual bool hasDeviceCommand(const std::string& dev, const std::string& name); /** * Retrieve the description of a command. * \param dev Device name * \param name Command name * \return Command description if provided. */ - virtual std::string getDeviceCommandDescription(const std::string& dev, const std::string& name)throw(NutException)=0; + virtual std::string getDeviceCommandDescription(const std::string& dev, const std::string& name) = 0; /** * Intend to execute a command. * \param dev Device name * \param name Command name + * \param param Additional command parameter */ - virtual void executeDeviceCommand(const std::string& dev, const std::string& name)throw(NutException)=0; + virtual TrackingID executeDeviceCommand(const std::string& dev, const std::string& name, const std::string& param="") = 0; /** \} */ /** @@ -277,15 +322,33 @@ public: * Log the current user (if authenticated) for a device. * \param dev Device name. */ - virtual void deviceLogin(const std::string& dev)throw(NutException)=0; + virtual void deviceLogin(const std::string& dev) = 0; /** - * Retrieve the number of user longged in the specified device. + * Retrieve the number of user logged-in for the specified device. * \param dev Device name. * \return Number of logged-in users. */ - virtual int deviceGetNumLogins(const std::string& dev)throw(NutException)=0; - virtual void deviceMaster(const std::string& dev)throw(NutException)=0; - virtual void deviceForcedShutdown(const std::string& dev)throw(NutException)=0; + virtual int deviceGetNumLogins(const std::string& dev) = 0; + /* NOTE: "master" is deprecated since NUT v2.8.0 in favor of "primary". + * For the sake of old/new server/client interoperability, + * practical implementations should try to use one and fall + * back to the other, and only fail if both return "ERR". + */ + virtual void deviceMaster(const std::string& dev) = 0; + virtual void devicePrimary(const std::string& dev) = 0; + virtual void deviceForcedShutdown(const std::string& dev) = 0; + + /** + * Retrieve the result of a tracking ID. + * \param id Tracking ID. + */ + virtual TrackingResult getTrackingResult(const TrackingID& id) = 0; + + virtual bool hasFeature(const Feature& feature); + virtual bool isFeatureEnabled(const Feature& feature) = 0; + virtual void setFeature(const Feature& feature, bool status) = 0; + + static const Feature TRACKING; protected: Client(); @@ -297,6 +360,11 @@ protected: */ class TcpClient : public Client { + /* We have a number of direct-call methods we do not expose + * generally, but still want covered with integration tests + */ + friend class NutActiveClientTest; + public: /** * Construct a nut TcpClient object. @@ -309,21 +377,21 @@ public: * \param host Server host name. * \param port Server port. */ - TcpClient(const std::string& host, int port = 3493)throw(nut::IOException); - ~TcpClient(); + TcpClient(const std::string& host, uint16_t port = 3493); + ~TcpClient() override; /** * Connect it to the specified server. * \param host Server host name. * \param port Server port. */ - void connect(const std::string& host, int port = 3493)throw(nut::IOException); + void connect(const std::string& host, uint16_t port = 3493); /** * Connect to the server. * Host name and ports must have already set (usefull for reconnection). */ - void connect()throw(nut::IOException); + void connect(); /** * Test if the connection is active. @@ -339,13 +407,13 @@ public: * Set the timeout in seconds. * \param timeout Timeout n seconds, negative to block operations. */ - void setTimeout(long timeout); + void setTimeout(time_t timeout); /** * Retrieve the timeout. * \returns Current timeout in seconds. */ - long getTimeout()const; + time_t getTimeout()const; /** * Retriueve the host name of the server the client is connected to. @@ -356,53 +424,64 @@ public: * Retriueve the port of host of the server the client is connected to. * \return Server port */ - int getPort()const; + uint16_t getPort()const; - virtual void authenticate(const std::string& user, const std::string& passwd)throw(NutException); - virtual void logout()throw(NutException); - - virtual Device getDevice(const std::string& name)throw(NutException); - virtual std::set getDeviceNames()throw(NutException); - virtual std::string getDeviceDescription(const std::string& name)throw(NutException); + virtual void authenticate(const std::string& user, const std::string& passwd) override; + virtual void logout() override; - virtual std::set getDeviceVariableNames(const std::string& dev)throw(NutException); - virtual std::set getDeviceRWVariableNames(const std::string& dev)throw(NutException); - virtual std::string getDeviceVariableDescription(const std::string& dev, const std::string& name)throw(NutException); - virtual std::vector getDeviceVariableValue(const std::string& dev, const std::string& name)throw(NutException); - virtual std::map > getDeviceVariableValues(const std::string& dev)throw(NutException); - virtual void setDeviceVariable(const std::string& dev, const std::string& name, const std::string& value)throw(NutException); - virtual void setDeviceVariable(const std::string& dev, const std::string& name, const std::vector& values)throw(NutException); + virtual Device getDevice(const std::string& name) override; + virtual std::set getDeviceNames() override; + virtual std::string getDeviceDescription(const std::string& name) override; - virtual std::set getDeviceCommandNames(const std::string& dev)throw(NutException); - virtual std::string getDeviceCommandDescription(const std::string& dev, const std::string& name)throw(NutException); - virtual void executeDeviceCommand(const std::string& dev, const std::string& name)throw(NutException); + virtual std::set getDeviceVariableNames(const std::string& dev) override; + virtual std::set getDeviceRWVariableNames(const std::string& dev) override; + virtual std::string getDeviceVariableDescription(const std::string& dev, const std::string& name) override; + virtual std::vector getDeviceVariableValue(const std::string& dev, const std::string& name) override; + virtual std::map > getDeviceVariableValues(const std::string& dev) override; + virtual std::map > > getDevicesVariableValues(const std::set& devs) override; + virtual TrackingID setDeviceVariable(const std::string& dev, const std::string& name, const std::string& value) override; + virtual TrackingID setDeviceVariable(const std::string& dev, const std::string& name, const std::vector& values) override; - virtual void deviceLogin(const std::string& dev)throw(NutException); - virtual void deviceMaster(const std::string& dev)throw(NutException); - virtual void deviceForcedShutdown(const std::string& dev)throw(NutException); - virtual int deviceGetNumLogins(const std::string& dev)throw(NutException); + virtual std::set getDeviceCommandNames(const std::string& dev) override; + virtual std::string getDeviceCommandDescription(const std::string& dev, const std::string& name) override; + virtual TrackingID executeDeviceCommand(const std::string& dev, const std::string& name, const std::string& param="") override; + + virtual void deviceLogin(const std::string& dev) override; + /* FIXME: Protocol update needed to handle master/primary alias + * and probably an API bump also, to rename/alias the routine. + */ + virtual void deviceMaster(const std::string& dev) override; + virtual void devicePrimary(const std::string& dev) override; + virtual void deviceForcedShutdown(const std::string& dev) override; + virtual int deviceGetNumLogins(const std::string& dev) override; + + virtual TrackingResult getTrackingResult(const TrackingID& id) override; + + virtual bool isFeatureEnabled(const Feature& feature) override; + virtual void setFeature(const Feature& feature, bool status) override; protected: - std::string sendQuery(const std::string& req)throw(nut::IOException); - static void detectError(const std::string& req)throw(nut::NutException); + std::string sendQuery(const std::string& req); + void sendAsyncQueries(const std::vector& req); + static void detectError(const std::string& req); + TrackingID sendTrackingQuery(const std::string& req); - std::vector get(const std::string& subcmd, const std::string& params = "") - throw(nut::NutException); + std::vector get(const std::string& subcmd, const std::string& params = ""); - std::vector > list(const std::string& subcmd, const std::string& params = "") - throw(nut::NutException); + std::vector > list(const std::string& subcmd, const std::string& params = ""); + + std::vector > parseList(const std::string& req); static std::vector explode(const std::string& str, size_t begin=0); static std::string escape(const std::string& str); private: std::string _host; - int _port; - long _timeout; + uint16_t _port; + time_t _timeout; internal::Socket* _socket; }; - /** * Device attached to a client. * Device is a lightweight class which can be copied easily. @@ -411,9 +490,14 @@ class Device { friend class Client; friend class TcpClient; + friend class TcpClientMock; +#ifdef _NUTCLIENTTEST_BUILD + friend class NutClientTest; +#endif public: ~Device(); Device(const Device& dev); + Device& operator=(const Device& dev); /** * Retrieve the name of the device. @@ -435,112 +519,117 @@ public: bool isOk()const; /** * Test if the device is valid (has a name and is attached to a client). - * @see Device::isOk() + * @see Device::isOk() */ operator bool()const; /** * Test if the device is not valid (has no name or is not attached to any client). - * @see Device::isOk() + * @see Device::isOk() */ bool operator!()const; /** * Test if the two devices are sames (same name ad same client attached to). */ bool operator==(const Device& dev)const; - /** - * Comparison operator. - */ - bool operator<(const Device& dev)const; + /** + * Comparison operator. + */ + bool operator<(const Device& dev)const; /** * Retrieve the description of the devce if specified. */ - std::string getDescription()throw(NutException); + std::string getDescription(); /** * Intend to retrieve the value of a variable of the device. * \param name Name of the variable to get. - * \return Value of the variable, if available. + * \return Value of the variable, if available. */ - std::vector getVariableValue(const std::string& name)throw(NutException); + std::vector getVariableValue(const std::string& name); /** * Intend to retrieve values of all variables of the devices. * \return Map of all variables values indexed by their names. */ - std::map > getVariableValues()throw(NutException); + std::map > getVariableValues(); /** * Retrieve all variables names supported by the device. * \return Set of available variable names. */ - std::set getVariableNames()throw(NutException); + std::set getVariableNames(); /** * Retrieve all Read/Write variables names supported by the device. * \return Set of available Read/Write variable names. */ - std::set getRWVariableNames()throw(NutException); + std::set getRWVariableNames(); /** * Intend to set the value of a variable of the device. * \param name Variable name. * \param value New variable value. */ - void setVariable(const std::string& name, const std::string& value)throw(NutException); + void setVariable(const std::string& name, const std::string& value); /** * Intend to set values of a variable of the device. * \param name Variable name. - * \param value New variable values. + * \param values Vector of new variable values. */ - void setVariable(const std::string& name, const std::vector& values)throw(NutException); + void setVariable(const std::string& name, const std::vector& values); /** * Retrieve a Variable object representing the specified variable. - * \param name Variable name. + * \param name Variable name. * \return Variable object. */ - Variable getVariable(const std::string& name)throw(NutException); + Variable getVariable(const std::string& name); /** * Retrieve Variable objects representing all variables available for the device. * \return Set of Variable objects. */ - std::set getVariables()throw(NutException); + std::set getVariables(); /** * Retrieve Variable objects representing all Read/Write variables available for the device. * \return Set of Variable objects. */ - std::set getRWVariables()throw(NutException); + std::set getRWVariables(); /** * Retrieve names of all commands supported by the device. * \return Set of available command names. */ - std::set getCommandNames()throw(NutException); + std::set getCommandNames(); /** * Retrieve objects for all commands supported by the device. * \return Set of available Command objects. */ - std::set getCommands()throw(NutException); + std::set getCommands(); /** * Retrieve an object representing a command of the device. * \param name Command name. * \return Command object. */ - Command getCommand(const std::string& name)throw(NutException); + Command getCommand(const std::string& name); /** * Intend to execute a command on the device. * \param name Command name. + * \param param Additional command parameter */ - void executeCommand(const std::string& name)throw(NutException); + TrackingID executeCommand(const std::string& name, const std::string& param=""); /** * Login current client's user for the device. */ - void login()throw(NutException); - void master()throw(NutException); - void forcedShutdown()throw(NutException); + void login(); + /* FIXME: Protocol update needed to handle master/primary alias + * and probably an API bump also, to rename/alias the routine. + */ + void master(); + void primary(); + void forcedShutdown(); /** * Retrieve the number of logged user for the device. * \return Number of users. */ - int getNumLogins()throw(NutException); + int getNumLogins(); protected: Device(Client* client, const std::string& name); @@ -558,10 +647,15 @@ class Variable { friend class Device; friend class TcpClient; + friend class TcpClientMock; +#ifdef _NUTCLIENTTEST_BUILD + friend class NutClientTest; +#endif public: ~Variable(); Variable(const Variable& var); + Variable& operator=(const Variable& var); /** * Retrieve variable name. @@ -603,23 +697,23 @@ public: * Intend to retrieve variable value. * \return Value of the variable. */ - std::vector getValue()throw(NutException); + std::vector getValue(); /** * Intend to retireve variable description. * \return Variable description if provided. */ - std::string getDescription()throw(NutException); + std::string getDescription(); /** * Intend to set a value to the variable. * \param value New variable value. */ - void setValue(const std::string& value)throw(NutException); + void setValue(const std::string& value); /** * Intend to set (multiple) values to the variable. - * \param value New variable values. + * \param values Vector of new variable values. */ - void setValues(const std::vector& values)throw(NutException); + void setValues(const std::vector& values); protected: Variable(Device* dev, const std::string& name); @@ -637,10 +731,15 @@ class Command { friend class Device; friend class TcpClient; + friend class TcpClientMock; +#ifdef _NUTCLIENTTEST_BUILD + friend class NutClientTest; +#endif public: ~Command(); Command(const Command& cmd); + Command& operator=(const Command& cmd); /** * Retrieve command name. @@ -683,13 +782,13 @@ public: * Intend to retireve command description. * \return Command description if provided. */ - std::string getDescription()throw(NutException); + std::string getDescription(); /** - * Intend to retrieve command description. - * \return Command description if provided. + * Intend to execute the instant command on device. + * \param param Optional additional command parameter */ - void execute()throw(NutException); + void execute(const std::string& param=""); protected: Command(Device* dev, const std::string& name); @@ -722,13 +821,19 @@ typedef char** strarr; /** * Alloc an array of string. */ -strarr strarr_alloc(unsigned short count); +strarr strarr_alloc(size_t count); /** * Free an array of string. */ void strarr_free(strarr arr); +/** + * Convert C++ types into an array of string. + */ +strarr stringvector_to_strarr(const std::vector& strset); +strarr stringset_to_strarr(const std::set& strset); + /** * Nut general client types and functions. @@ -738,7 +843,7 @@ void strarr_free(strarr arr); typedef void* NUTCLIENT_t; /** - * Destroy a client. + * Destroy a client. * \param client Nut client handle. */ void nutclient_destroy(NUTCLIENT_t client); @@ -776,7 +881,11 @@ int nutclient_get_device_num_logins(NUTCLIENT_t client, const char* dev); * \param client Nut client handle. * \param dev Device name to test. */ +/* FIXME: Protocol update needed to handle master/primary alias + * and probably an API bump also, to rename/alias the routine. + */ void nutclient_device_master(NUTCLIENT_t client, const char* dev); +void nutclient_device_primary(NUTCLIENT_t client, const char* dev); /** * Set the FSD flag for the device. @@ -901,7 +1010,7 @@ char* nutclient_get_device_command_description(NUTCLIENT_t client, const char* d * \param dev Device name. * \param cmd Command name. */ -void nutclient_execute_device_command(NUTCLIENT_t client, const char* dev, const char* cmd); +void nutclient_execute_device_command(NUTCLIENT_t client, const char* dev, const char* cmd, const char* param=""); /** \} */ @@ -911,7 +1020,7 @@ void nutclient_execute_device_command(NUTCLIENT_t client, const char* dev, const * \{ */ /** - * Hidden structure representing a TCP connection to NUTD. + * Hidden structure representing a TCP connection to NUTD. * NUTCLIENT_TCP_t is back compatible to NUTCLIENT_t. */ typedef NUTCLIENT_t NUTCLIENT_TCP_t; @@ -920,9 +1029,9 @@ typedef NUTCLIENT_t NUTCLIENT_TCP_t; * Create a client to NUTD using a TCP connection. * \param host Host name to connect to. * \param port Host port. - * \return New client or NULL if failed. + * \return New client or nullptr if failed. */ -NUTCLIENT_TCP_t nutclient_tcp_create_client(const char* host, unsigned short port); +NUTCLIENT_TCP_t nutclient_tcp_create_client(const char* host, uint16_t port); /** * Test if a nut TCP client is connected. * \param client Nut TCP client handle. @@ -945,12 +1054,12 @@ int nutclient_tcp_reconnect(NUTCLIENT_TCP_t client); * Set the timeout value for the TCP connection. * \param timeout Timeout in seconds, negative for blocking. */ -void nutclient_tcp_set_timeout(NUTCLIENT_TCP_t client, long timeout); +void nutclient_tcp_set_timeout(NUTCLIENT_TCP_t client, time_t timeout); /** * Retrieve the timeout value for the TCP connection. * \return Timeout value in seconds. */ -long nutclient_tcp_get_timeout(NUTCLIENT_TCP_t client); +time_t nutclient_tcp_get_timeout(NUTCLIENT_TCP_t client); /** \} */ diff --git a/clients/nutclientmem.cpp b/clients/nutclientmem.cpp new file mode 100644 index 0000000..df97cb3 --- /dev/null +++ b/clients/nutclientmem.cpp @@ -0,0 +1,252 @@ +/* nutclientmem.cpp - nutclientmem C++ library implementation + + Copyright (C) 2021 Eric Clappier + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "nutclientmem.h" +#include + +namespace nut +{ + +/* + * + * Memory Client stub implementation + * + */ + +Device MemClientStub::getDevice(const std::string& name) +{ + NUT_UNUSED_VARIABLE(name); + throw NutException("Not implemented"); +} + +std::set MemClientStub::getDeviceNames() +{ + throw NutException("Not implemented"); +} + +std::string MemClientStub::getDeviceDescription(const std::string& name) +{ + NUT_UNUSED_VARIABLE(name); + throw NutException("Not implemented"); +} + +std::set MemClientStub::getDeviceVariableNames(const std::string& dev) +{ + NUT_UNUSED_VARIABLE(dev); + throw NutException("Not implemented"); +} + +std::set MemClientStub::getDeviceRWVariableNames(const std::string& dev) +{ + NUT_UNUSED_VARIABLE(dev); + throw NutException("Not implemented"); +} + +std::string MemClientStub::getDeviceVariableDescription(const std::string& dev, const std::string& name) +{ + NUT_UNUSED_VARIABLE(dev); + NUT_UNUSED_VARIABLE(name); + throw NutException("Not implemented"); +} + +ListValue MemClientStub::getDeviceVariableValue(const std::string& dev, const std::string& name) +{ + ListValue res; + auto it_dev = _values.find(dev); + if (it_dev != _values.end()) + { + auto map = it_dev->second; + auto it_map = map.find(name); + if (it_map != map.end()) + { + res = it_map->second; + } + } + return res; +} + +ListObject MemClientStub::getDeviceVariableValues(const std::string& dev) +{ + ListObject res; + auto it_dev = _values.find(dev); + if (it_dev != _values.end()) + { + res = it_dev->second; + } + return res; +} + +ListDevice MemClientStub::getDevicesVariableValues(const std::set& devs) +{ + ListDevice res; + for (auto itr = devs.begin(); itr != devs.end(); itr++) + { + std::string dev = *itr; + auto it_dev = _values.find(dev); + if (it_dev != _values.end()) + { + res.insert(std::pair(dev, it_dev->second)); + } + } + return res; +} + +TrackingID MemClientStub::setDeviceVariable(const std::string& dev, const std::string& name, const std::string& value) +{ + auto it_dev = _values.find(dev); + if (it_dev == _values.end()) + { + ListObject list; + _values.emplace(dev, list); + it_dev = _values.find(dev); + } + if (it_dev != _values.end()) + { + auto map = &(it_dev->second); + auto it_map = map->find(name); + if (it_map != map->end()) + { + it_map->second[0] = value; + } + else + { + ListValue list_value; + list_value.push_back(value); + map->emplace(name, list_value); + } + } + return ""; +} + +TrackingID MemClientStub::setDeviceVariable(const std::string& dev, const std::string& name, const ListValue& values) +{ + auto it_dev = _values.find(dev); + if (it_dev != _values.end()) + { + auto map = &(it_dev->second); + auto it_map = map->find(name); + if (it_map != map->end()) + { + it_map->second = values; + } + else + { + map->emplace(name, values); + } + } + return ""; +} + +std::set MemClientStub::getDeviceCommandNames(const std::string& dev) +{ + NUT_UNUSED_VARIABLE(dev); + throw NutException("Not implemented"); +} + +std::string MemClientStub::getDeviceCommandDescription(const std::string& dev, const std::string& name) +{ + NUT_UNUSED_VARIABLE(dev); + NUT_UNUSED_VARIABLE(name); + throw NutException("Not implemented"); +} + +TrackingID MemClientStub::executeDeviceCommand(const std::string& dev, const std::string& name, const std::string& param) +{ + NUT_UNUSED_VARIABLE(dev); + NUT_UNUSED_VARIABLE(name); + NUT_UNUSED_VARIABLE(param); + throw NutException("Not implemented"); +} + +void MemClientStub::deviceLogin(const std::string& dev) +{ + NUT_UNUSED_VARIABLE(dev); + throw NutException("Not implemented"); +} + +/* Note: "master" is deprecated, but supported + * for mixing old/new client/server combos: */ +void MemClientStub::deviceMaster(const std::string& dev) +{ + NUT_UNUSED_VARIABLE(dev); + throw NutException("Not implemented"); +} + +void MemClientStub::devicePrimary(const std::string& dev) +{ + NUT_UNUSED_VARIABLE(dev); + throw NutException("Not implemented"); +} + +void MemClientStub::deviceForcedShutdown(const std::string& dev) +{ + NUT_UNUSED_VARIABLE(dev); + throw NutException("Not implemented"); +} + +int MemClientStub::deviceGetNumLogins(const std::string& dev) +{ + NUT_UNUSED_VARIABLE(dev); + throw NutException("Not implemented"); +} + +TrackingResult MemClientStub::getTrackingResult(const TrackingID& id) +{ + NUT_UNUSED_VARIABLE(id); + throw NutException("Not implemented"); + //return TrackingResult::SUCCESS; +} + +bool MemClientStub::isFeatureEnabled(const Feature& feature) +{ + NUT_UNUSED_VARIABLE(feature); + throw NutException("Not implemented"); +} + +void MemClientStub::setFeature(const Feature& feature, bool status) +{ + NUT_UNUSED_VARIABLE(feature); + NUT_UNUSED_VARIABLE(status); + throw NutException("Not implemented"); +} + +} /* namespace nut */ + +/** + * C nutclient API. + */ +extern "C" { + +NUTCLIENT_MEM_t nutclient_mem_create_client() +{ + nut::MemClientStub* client = new nut::MemClientStub; + try + { + return static_cast(client); + } + catch(nut::NutException& ex) + { + // TODO really catch it + NUT_UNUSED_VARIABLE(ex); + delete client; + return nullptr; + } +} + +} /* extern "C" */ diff --git a/clients/nutclientmem.h b/clients/nutclientmem.h new file mode 100644 index 0000000..3bd2243 --- /dev/null +++ b/clients/nutclientmem.h @@ -0,0 +1,118 @@ +/* nutclientmem.h - definitions for nutclientmem C/C++ library + + Copyright (C) 2021 Eric Clappier + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef NUTCLIENTMEM_HPP_SEEN +#define NUTCLIENTMEM_HPP_SEEN + +/* Begin of C++ nutclient library declaration */ +#ifdef __cplusplus + +#include "nutclient.h" + +namespace nut +{ + +typedef std::vector ListValue; +typedef std::map ListObject; +typedef std::map ListDevice; + +/** + * Memory client stub. + * Class to stub TCPClient for test (data store in local memory). + */ +class MemClientStub : public Client +{ +public: + /** + * Construct a nut MemClientStub object. + */ + MemClientStub() {} + ~MemClientStub() override {} + + virtual void authenticate(const std::string& user, const std::string& passwd) override { + NUT_UNUSED_VARIABLE(user); + NUT_UNUSED_VARIABLE(passwd); + } + virtual void logout() override {} + + virtual Device getDevice(const std::string& name) override; + virtual std::set getDeviceNames() override; + virtual std::string getDeviceDescription(const std::string& name) override; + + virtual std::set getDeviceVariableNames(const std::string& dev) override; + virtual std::set getDeviceRWVariableNames(const std::string& dev) override; + virtual std::string getDeviceVariableDescription(const std::string& dev, const std::string& name) override; + virtual ListValue getDeviceVariableValue(const std::string& dev, const std::string& name) override; + virtual ListObject getDeviceVariableValues(const std::string& dev) override; + virtual ListDevice getDevicesVariableValues(const std::set& devs) override; + virtual TrackingID setDeviceVariable(const std::string& dev, const std::string& name, const std::string& value) override; + virtual TrackingID setDeviceVariable(const std::string& dev, const std::string& name, const ListValue& values) override; + + virtual std::set getDeviceCommandNames(const std::string& dev) override; + virtual std::string getDeviceCommandDescription(const std::string& dev, const std::string& name) override; + virtual TrackingID executeDeviceCommand(const std::string& dev, const std::string& name, const std::string& param="") override; + + virtual void deviceLogin(const std::string& dev) override; + /* Note: "master" is deprecated, but supported + * for mixing old/new client/server combos: */ + virtual void deviceMaster(const std::string& dev) override; + virtual void devicePrimary(const std::string& dev) override; + virtual void deviceForcedShutdown(const std::string& dev) override; + virtual int deviceGetNumLogins(const std::string& dev) override; + + virtual TrackingResult getTrackingResult(const TrackingID& id) override; + + virtual bool isFeatureEnabled(const Feature& feature) override; + virtual void setFeature(const Feature& feature, bool status) override; + +private: + ListDevice _values; +}; + +} /* namespace nut */ + +#endif /* __cplusplus */ +/* End of C++ nutclient library declaration */ + +/* Begin of C nutclient library declaration */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * Nut MEM client dedicated types and functions + */ +/** + * Hidden structure representing a MEM connection. + * NUTCLIENT_MEM_t is back compatible to NUTCLIENT_t. + */ +typedef NUTCLIENT_t NUTCLIENT_MEM_t; + +/** + * Create a client to NUTD using memory. + * \return New client or nullptr if failed. + */ +NUTCLIENT_MEM_t nutclient_mem_create_client(); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +/* End of C nutclient library declaration */ + +#endif /* NUTCLIENTMOCK_HPP_SEEN */ diff --git a/clients/status.h b/clients/status.h index c98c489..c643351 100644 --- a/clients/status.h +++ b/clients/status.h @@ -17,13 +17,19 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef NUT_STATUS_H_SEEN +#define NUT_STATUS_H_SEEN 1 + #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { /* *INDENT-ON* */ #endif -struct { +/* This is only used in upsstats.c, but might it also have external consumers?.. + * To move or not to move?.. + */ +static struct { char *name; char *desc; int severity; @@ -48,3 +54,4 @@ struct { /* *INDENT-ON* */ #endif +#endif /* NUT_STATUS_H_SEEN */ diff --git a/clients/upsc.c b/clients/upsc.c index ae584d3..550b74a 100644 --- a/clients/upsc.c +++ b/clients/upsc.c @@ -1,4 +1,4 @@ -/* upsc - simple "client" to test communications +/* upsc - simple "client" to test communications Copyright (C) 1999 Russell Kroll Copyright (C) 2012 Arnaud Quette @@ -25,6 +25,7 @@ #include #include +#include "nut_stdint.h" #include "upsclient.h" static char *upsname = NULL, *hostname = NULL; @@ -58,7 +59,7 @@ static void usage(const char *prog) static void printvar(const char *var) { int ret; - unsigned int numq, numa; + size_t numq, numa; const char *query[4]; char **answer; @@ -86,7 +87,7 @@ static void printvar(const char *var) } if (numa < numq) { - fatalx(EXIT_FAILURE, "Error: insufficient data (got %d args, need at least %d)", numa, numq); + fatalx(EXIT_FAILURE, "Error: insufficient data (got %zu args, need at least %zu)", numa, numq); } printf("%s\n", answer[3]); @@ -95,7 +96,7 @@ static void printvar(const char *var) static void list_vars(void) { int ret; - unsigned int numq, numa; + size_t numq, numa; const char *query[4]; char **answer; @@ -119,7 +120,7 @@ static void list_vars(void) /* VAR */ if (numa < 4) { - fatalx(EXIT_FAILURE, "Error: insufficient data (got %d args, need at least 4)", numa); + fatalx(EXIT_FAILURE, "Error: insufficient data (got %zu args, need at least 4)", numa); } printf("%s: %s\n", answer[2], answer[3]); @@ -129,7 +130,7 @@ static void list_vars(void) static void list_upses(int verbose) { int ret; - unsigned int numq, numa; + size_t numq, numa; const char *query[4]; char **answer; @@ -137,7 +138,7 @@ static void list_upses(int verbose) numq = 1; ret = upscli_list_start(ups, numq, query); - + if (ret < 0) { /* check for an old upsd */ if (upscli_upserror(ups) == UPSCLI_ERR_UNKCOMMAND) { @@ -151,7 +152,7 @@ static void list_upses(int verbose) /* UPS */ if (numa < 3) { - fatalx(EXIT_FAILURE, "Error: insufficient data (got %d args, need at least 3)", numa); + fatalx(EXIT_FAILURE, "Error: insufficient data (got %zu args, need at least 3)", numa); } if(verbose) { @@ -165,7 +166,7 @@ static void list_upses(int verbose) static void list_clients(const char *devname) { int ret; - unsigned int numq, numa; + size_t numq, numa; const char *query[4]; char **answer; @@ -188,7 +189,7 @@ static void list_clients(const char *devname) /* CLIENT
*/ if (numa < 3) { - fatalx(EXIT_FAILURE, "Error: insufficient data (got %d args, need at least 3)", numa); + fatalx(EXIT_FAILURE, "Error: insufficient data (got %zu args, need at least 3)", numa); } printf("%s\n", answer[2]); @@ -208,7 +209,8 @@ static void clean_exit(void) int main(int argc, char **argv) { - int i, port; + int i; + uint16_t port; int varlist = 0, clientlist = 0, verbose = 0; const char *prog = xbasename(argv[0]); @@ -218,7 +220,9 @@ int main(int argc, char **argv) { case 'L': verbose = 1; + goto fallthrough_case_l; case 'l': + fallthrough_case_l: varlist = 1; break; case 'c': @@ -227,6 +231,9 @@ int main(int argc, char **argv) case 'V': fatalx(EXIT_SUCCESS, "Network UPS Tools upscmd %s", UPS_VERSION); +#ifndef HAVE___ATTRIBUTE__NORETURN + exit(EXIT_SUCCESS); /* Should not get here in practice, but compiler is afraid we can fall through */ +#endif case 'h': default: diff --git a/clients/upsclient.c b/clients/upsclient.c index 43c0e79..2787783 100644 --- a/clients/upsclient.c +++ b/clients/upsclient.c @@ -25,7 +25,7 @@ #ifdef HAVE_PTHREAD /* this include is needed on AIX to have errno stored in thread local storage */ #include -#endif +#endif #include #include @@ -38,13 +38,14 @@ #include #include -#include "upsclient.h" #include "common.h" +#include "nut_stdint.h" #include "timehead.h" +#include "upsclient.h" /* WA for Solaris/i386 bug: non-blocking connect sets errno to ENOENT */ -#if (defined NUT_PLATFORM_SOLARIS && CPU_TYPE == i386) - #define SOLARIS_i386_NBCONNECT_ENOENT(status) (ENOENT == (status)) +#if (defined NUT_PLATFORM_SOLARIS) + #define SOLARIS_i386_NBCONNECT_ENOENT(status) ( (!strcmp("i386", CPU_TYPE)) ? (ENOENT == (status)) : 0 ) #else #define SOLARIS_i386_NBCONNECT_ENOENT(status) (0) #endif /* end of Solaris/i386 WA for non-blocking connect */ @@ -75,7 +76,7 @@ #define shutdown_how 2 #endif -struct { +static struct { int flags; const char *str; } upscli_errlist[] = @@ -131,7 +132,7 @@ typedef struct HOST_CERT_s { const char *certname; int certverify; int forcessl; - + struct HOST_CERT_s *next; } HOST_CERT_t; static HOST_CERT_t* upscli_find_host_cert(const char* hostname); @@ -153,7 +154,7 @@ static char* nsscertpasswd = NULL; static void ssl_debug(void) { - int e; + unsigned long e; char errmsg[SMALLBUF]; while ((e = ERR_get_error()) != 0) { @@ -162,32 +163,36 @@ static void ssl_debug(void) } } -static int ssl_error(SSL *ssl, int ret) +static int ssl_error(SSL *ssl, ssize_t ret) { int e; - e = SSL_get_error(ssl, ret); + if (ret >= INT_MAX) { + upslogx(LOG_ERR, "ssl_error() ret=%zd would not fit in an int", ret); + return -1; + } + e = SSL_get_error(ssl, (int)ret); switch (e) { case SSL_ERROR_WANT_READ: - upslogx(LOG_ERR, "ssl_error() ret=%d SSL_ERROR_WANT_READ", ret); + upslogx(LOG_ERR, "ssl_error() ret=%zd SSL_ERROR_WANT_READ", ret); break; case SSL_ERROR_WANT_WRITE: - upslogx(LOG_ERR, "ssl_error() ret=%d SSL_ERROR_WANT_WRITE", ret); + upslogx(LOG_ERR, "ssl_error() ret=%zd SSL_ERROR_WANT_WRITE", ret); break; case SSL_ERROR_SYSCALL: if (ret == 0 && ERR_peek_error() == 0) { upslogx(LOG_ERR, "ssl_error() EOF from client"); } else { - upslogx(LOG_ERR, "ssl_error() ret=%d SSL_ERROR_SYSCALL", ret); + upslogx(LOG_ERR, "ssl_error() ret=%zd SSL_ERROR_SYSCALL", ret); } break; default: - upslogx(LOG_ERR, "ssl_error() ret=%d SSL_ERROR %d", ret, e); + upslogx(LOG_ERR, "ssl_error() ret=%zd SSL_ERROR %d", ret, e); ssl_debug(); } @@ -196,9 +201,12 @@ static int ssl_error(SSL *ssl, int ret) #elif defined(WITH_NSS) /* WITH_OPENSSL */ -static char *nss_password_callback(PK11SlotInfo *slot, PRBool retry, +static char *nss_password_callback(PK11SlotInfo *slot, PRBool retry, void *arg) { + NUT_UNUSED_VARIABLE(retry); + NUT_UNUSED_VARIABLE(arg); + upslogx(LOG_INFO, "Intend to retrieve password for %s / %s: password %sconfigured", PK11_GetSlotName(slot), PK11_GetTokenName(slot), nsscertpasswd?"":"not "); return nsscertpasswd ? PL_strdup(nsscertpasswd) : NULL; @@ -233,6 +241,10 @@ static SECStatus AuthCertificateDontVerify(CERTCertDBHandle *arg, PRFileDesc *fd PRBool checksig, PRBool isServer) { UPSCONN_t *ups = (UPSCONN_t *)SSL_RevealPinArg(fd); + NUT_UNUSED_VARIABLE(arg); + NUT_UNUSED_VARIABLE(checksig); + NUT_UNUSED_VARIABLE(isServer); + upslogx(LOG_INFO, "Do not intend to authenticate server %s", ups?ups->host:""); return SECSuccess; @@ -241,6 +253,8 @@ static SECStatus AuthCertificateDontVerify(CERTCertDBHandle *arg, PRFileDesc *fd static SECStatus BadCertHandler(UPSCONN_t *arg, PRFileDesc *fd) { HOST_CERT_t* cert; + NUT_UNUSED_VARIABLE(fd); + upslogx(LOG_WARNING, "Certificate validation failed for %s", (arg&&arg->host)?arg->host:""); /* BadCertHandler is called when the NSS certificate validation is failed. @@ -288,49 +302,63 @@ static SECStatus GetClientAuthData(UPSCONN_t *arg, PRFileDesc *fd, static void HandshakeCallback(PRFileDesc *fd, UPSCONN_t *client_data) { + NUT_UNUSED_VARIABLE(fd); + upslogx(LOG_INFO, "SSL handshake done successfully with server %s", client_data->host); } #endif /* WITH_OPENSSL | WITH_NSS */ -int upscli_init(int certverify, const char *certpath, +int upscli_init(int certverify, const char *certpath, const char *certname, const char *certpasswd) { #ifdef WITH_OPENSSL - int ret, ssl_mode = SSL_VERIFY_NONE; -#if OPENSSL_VERSION_NUMBER >= 0x10000000L - const SSL_METHOD *ssl_method; -#else - SSL_METHOD *ssl_method; -#endif + long ret; + int ssl_mode = SSL_VERIFY_NONE; + NUT_UNUSED_VARIABLE(certname); + NUT_UNUSED_VARIABLE(certpasswd); #elif defined(WITH_NSS) /* WITH_OPENSSL */ SECStatus status; +#else + NUT_UNUSED_VARIABLE(certverify); + NUT_UNUSED_VARIABLE(certpath); + NUT_UNUSED_VARIABLE(certname); + NUT_UNUSED_VARIABLE(certpasswd); #endif /* WITH_OPENSSL | WITH_NSS */ - if (upscli_initialized == 1) { upslogx(LOG_WARNING, "upscli already initialized"); return -1; } - + #ifdef WITH_OPENSSL - - SSL_library_init(); + +#if OPENSSL_VERSION_NUMBER < 0x10100000L SSL_load_error_strings(); + SSL_library_init(); - ssl_method = TLSv1_client_method(); + ssl_ctx = SSL_CTX_new(SSLv23_client_method()); +#else + ssl_ctx = SSL_CTX_new(TLS_client_method()); +#endif - if (!ssl_method) { - return 0; - } - - ssl_ctx = SSL_CTX_new(ssl_method); if (!ssl_ctx) { upslogx(LOG_ERR, "Can not initialize SSL context"); return -1; } - + +#if OPENSSL_VERSION_NUMBER < 0x10100000L + /* set minimum protocol TLSv1 */ + SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3); +#else + ret = SSL_CTX_set_min_proto_version(ssl_ctx, TLS1_VERSION); + if (ret != 1) { + upslogx(LOG_ERR, "Can not set minimum protocol to TLSv1"); + return -1; + } +#endif + if (!certpath) { if (certverify == 1) { upslogx(LOG_ERR, "Can not verify certificate if any is specified"); @@ -353,13 +381,13 @@ int upscli_init(int certverify, const char *certpath, return -1; } - SSL_CTX_set_verify(ssl_ctx, ssl_mode, NULL); + SSL_CTX_set_verify(ssl_ctx, ssl_mode, NULL); } #elif defined(WITH_NSS) /* WITH_OPENSSL */ PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); - + PK11_SetPasswordFunc(nss_password_callback); - + if (certpath) { upslogx(LOG_INFO, "Init SSL with cerificate database located at %s", certpath); status = NSS_Init(certpath); @@ -372,16 +400,16 @@ int upscli_init(int certverify, const char *certpath, nss_error("upscli_init / NSS_[NoDB]_Init"); return -1; } - + status = NSS_SetDomesticPolicy(); if (status != SECSuccess) { upslogx(LOG_ERR, "Can not initialize SSL policy"); nss_error("upscli_init / NSS_SetDomesticPolicy"); return -1; } - + SSL_ClearSessionCache(); - + status = SSL_OptionSetDefault(SSL_ENABLE_SSL3, PR_TRUE); if (status != SECSuccess) { upslogx(LOG_ERR, "Can not enable SSLv3"); @@ -407,8 +435,13 @@ int upscli_init(int certverify, const char *certpath, nsscertpasswd = xstrdup(certpasswd); } verify_certificate = certverify; +#else + /* Note: historically we do not return with error here, + * just fall through to below and treat as initialized. + */ + upslogx(LOG_ERR, "upscli_init called but SSL wasn't compiled in"); #endif /* WITH_OPENSSL | WITH_NSS */ - + upscli_initialized = 1; return 1; } @@ -423,6 +456,11 @@ void upscli_add_host_cert(const char* hostname, const char* certname, int certve cert->certverify = certverify; cert->forcessl = forcessl; first_host_cert = cert; +#else + NUT_UNUSED_VARIABLE(hostname); + NUT_UNUSED_VARIABLE(certname); + NUT_UNUSED_VARIABLE(certverify); + NUT_UNUSED_VARIABLE(forcessl); #endif /* WITH_NSS */ } @@ -438,11 +476,13 @@ static HOST_CERT_t* upscli_find_host_cert(const char* hostname) cert = cert->next; } } +#else + NUT_UNUSED_VARIABLE(hostname); #endif /* WITH_NSS */ return NULL; } -int upscli_cleanup() +int upscli_cleanup(void) { #ifdef WITH_OPENSSL if (ssl_ctx) { @@ -452,7 +492,7 @@ int upscli_cleanup() #endif /* WITH_OPENSSL */ -#ifdef WITH_NSS +#ifdef WITH_NSS /* Called to force cache clearing to prevent NSS shutdown failures. * http://www.mozilla.org/projects/security/pki/nss/ref/ssl/sslfnc.html#1138601 */ @@ -465,7 +505,7 @@ int upscli_cleanup() */ PL_ArenaFinish(); #endif /* WITH_NSS */ - + upscli_initialized = 0; return 1; } @@ -477,6 +517,16 @@ const char *upscli_strerror(UPSCONN_t *ups) char sslbuf[UPSCLI_ERRBUF_LEN]; #endif +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + if (!ups) { return upscli_errlist[UPSCLI_ERR_INVALIDARG].str; } @@ -517,12 +567,12 @@ const char *upscli_strerror(UPSCONN_t *ups) if (PR_GetErrorTextLength() < UPSCLI_ERRBUF_LEN) { PR_GetErrorText(ups->errbuf); } else { - snprintf(ups->errbuf, UPSCLI_ERRBUF_LEN, + snprintf(ups->errbuf, UPSCLI_ERRBUF_LEN, "SSL error #%ld, message too long to be displayed", (long)PR_GetError()); } #else - snprintf(ups->errbuf, UPSCLI_ERRBUF_LEN, + snprintf(ups->errbuf, UPSCLI_ERRBUF_LEN, "SSL error, but SSL wasn't enabled at compile-time"); #endif /* WITH_OPENSSL | WITH_NSS */ return ups->errbuf; @@ -534,6 +584,10 @@ const char *upscli_strerror(UPSCONN_t *ups) return ups->errbuf; } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif + /* fallthrough */ snprintf(ups->errbuf, UPSCLI_ERRBUF_LEN, "Unknown error flag %d", @@ -545,9 +599,9 @@ const char *upscli_strerror(UPSCONN_t *ups) /* Read up to buflen bytes from fd and return the number of bytes read. If no data is available within d_sec + d_usec, return 0. On error, a value < 0 is returned (errno indicates error). */ -static int upscli_select_read(const int fd, void *buf, const size_t buflen, const long d_sec, const long d_usec) +static ssize_t upscli_select_read(const int fd, void *buf, const size_t buflen, const time_t d_sec, const suseconds_t d_usec) { - int ret; + ssize_t ret; fd_set fds; struct timeval tv; @@ -566,17 +620,37 @@ static int upscli_select_read(const int fd, void *buf, const size_t buflen, cons return read(fd, buf, buflen); } +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC) ) +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC +# pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif /* internal: abstract the SSL calls for the other functions */ -static int net_read(UPSCONN_t *ups, char *buf, size_t buflen) +static ssize_t net_read(UPSCONN_t *ups, char *buf, size_t buflen, const time_t timeout) { - int ret; + ssize_t ret = -1; #ifdef WITH_SSL if (ups->ssl) { #ifdef WITH_OPENSSL - ret = SSL_read(ups->ssl, buf, buflen); + /* SSL_* routines deal with int type for return and buflen + * We might need to window our I/O if we exceed 2GB (in + * 32-bit builds)... Not likely to exceed in 64-bit builds, + * but smaller systems with 16-bits might be endangered :) + */ + assert(buflen <= INT_MAX); + int iret = SSL_read(ups->ssl, buf, (int)buflen); + assert(iret <= SSIZE_MAX); + ret = (ssize_t)iret; #elif defined(WITH_NSS) /* WITH_OPENSSL */ - ret = PR_Read(ups->ssl, buf, buflen); + /* PR_* routines deal in PRInt32 type + * We might need to window our I/O if we exceed 2GB :) */ + assert(buflen <= PR_INT32_MAX); + ret = PR_Read(ups->ssl, buf, (PRInt32)buflen); #endif /* WITH_OPENSSL | WITH_NSS*/ if (ret < 1) { @@ -587,7 +661,7 @@ static int net_read(UPSCONN_t *ups, char *buf, size_t buflen) } #endif - ret = upscli_select_read(ups->fd, buf, buflen, 5, 0); + ret = upscli_select_read(ups->fd, buf, buflen, timeout, 0); /* error reading data, server disconnected? */ if (ret < 0) { @@ -602,13 +676,16 @@ static int net_read(UPSCONN_t *ups, char *buf, size_t buflen) return ret; } +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC) ) +# pragma GCC diagnostic pop +#endif /* Write up to buflen bytes to fd and return the number of bytes written. If no data is available within d_sec + d_usec, return 0. On error, a value < 0 is returned (errno indicates error). */ -static int upscli_select_write(const int fd, const void *buf, const size_t buflen, const long d_sec, const long d_usec) +static ssize_t upscli_select_write(const int fd, const void *buf, const size_t buflen, const time_t d_sec, const suseconds_t d_usec) { - int ret; + ssize_t ret; fd_set fds; struct timeval tv; @@ -627,17 +704,37 @@ static int upscli_select_write(const int fd, const void *buf, const size_t bufle return write(fd, buf, buflen); } +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC) ) +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC +# pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif /* internal: abstract the SSL calls for the other functions */ -static int net_write(UPSCONN_t *ups, const char *buf, size_t buflen) +static ssize_t net_write(UPSCONN_t *ups, const char *buf, size_t buflen, const time_t timeout) { - int ret; + ssize_t ret = -1; #ifdef WITH_SSL if (ups->ssl) { #ifdef WITH_OPENSSL - ret = SSL_write(ups->ssl, buf, buflen); + /* SSL_* routines deal with int type for return and buflen + * We might need to window our I/O if we exceed 2GB (in + * 32-bit builds)... Not likely to exceed in 64-bit builds, + * but smaller systems with 16-bits might be endangered :) + */ + assert(buflen <= INT_MAX); + int iret = SSL_write(ups->ssl, buf, (int)buflen); + assert(iret <= SSIZE_MAX); + ret = (ssize_t)iret; #elif defined(WITH_NSS) /* WITH_OPENSSL */ - ret = PR_Write(ups->ssl, buf, buflen); + /* PR_* routines deal in PRInt32 type + * We might need to window our I/O if we exceed 2GB :) */ + assert(buflen <= PR_INT32_MAX); + ret = PR_Write(ups->ssl, buf, (PRInt32)buflen); #endif /* WITH_OPENSSL | WITH_NSS */ if (ret < 1) { @@ -648,7 +745,7 @@ static int net_write(UPSCONN_t *ups, const char *buf, size_t buflen) } #endif - ret = upscli_select_write(ups->fd, buf, buflen, 0, 0); + ret = upscli_select_write(ups->fd, buf, buflen, timeout, 0); /* error writing data, server disconnected? */ if (ret < 0) { @@ -663,6 +760,9 @@ static int net_write(UPSCONN_t *ups, const char *buf, size_t buflen) return ret; } +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC) ) +# pragma GCC diagnostic pop +#endif #ifdef WITH_SSL @@ -670,7 +770,7 @@ static int net_write(UPSCONN_t *ups, const char *buf, size_t buflen) /* * 1 : OK * -1 : ERROR - * 0 : SSL NOT SUPPORTED + * 0 : SSL NOT SUPPORTED */ static int upscli_sslinit(UPSCONN_t *ups, int verifycert) { @@ -679,7 +779,7 @@ static int upscli_sslinit(UPSCONN_t *ups, int verifycert) #elif defined(WITH_NSS) /* WITH_OPENSSL */ SECStatus status; PRFileDesc *socket; - HOST_CERT_t *cert; + HOST_CERT_t *cert; #endif /* WITH_OPENSSL | WITH_NSS */ char buf[UPSCLI_NETBUF_LEN]; @@ -691,7 +791,7 @@ static int upscli_sslinit(UPSCONN_t *ups, int verifycert) "force initialisation without SSL configuration"); upscli_init(0, NULL, NULL, NULL); } - + /* see if upsd even talks SSL/TLS */ snprintf(buf, sizeof(buf), "STARTTLS\n"); @@ -708,7 +808,7 @@ static int upscli_sslinit(UPSCONN_t *ups, int verifycert) } /* upsd is happy, so let's crank up the client */ - + #ifdef WITH_OPENSSL if (!ssl_ctx) { @@ -737,7 +837,7 @@ static int upscli_sslinit(UPSCONN_t *ups, int verifycert) switch(res) { case 1: - upsdebugx(3, "SSL connected"); + upsdebugx(3, "SSL connected (%s)", SSL_get_version(ups->ssl)); break; case 0: upslog_with_errno(1, "SSL_connect do not accept handshake."); @@ -747,7 +847,7 @@ static int upscli_sslinit(UPSCONN_t *ups, int verifycert) upslog_with_errno(1, "Unknown return value from SSL_connect %d", res); ssl_error(ups->ssl, res); return -1; - } + } return 1; @@ -764,12 +864,12 @@ static int upscli_sslinit(UPSCONN_t *ups, int verifycert) nss_error("upscli_sslinit / SSL_ImportFD"); return -1; } - + if (SSL_SetPKCS11PinArg(ups->ssl, ups) == -1){ nss_error("upscli_sslinit / SSL_SetPKCS11PinArg"); return -1; } - + if (verifycert) { status = SSL_AuthCertificateHook(ups->ssl, (SSLAuthCertificate)AuthCertificate, CERT_GetDefaultCertDB()); @@ -781,19 +881,19 @@ static int upscli_sslinit(UPSCONN_t *ups, int verifycert) nss_error("upscli_sslinit / SSL_AuthCertificateHook"); return -1; } - + status = SSL_BadCertHook(ups->ssl, (SSLBadCertHandler)BadCertHandler, ups); if (status != SECSuccess) { nss_error("upscli_sslinit / SSL_BadCertHook"); return -1; } - + status = SSL_GetClientAuthDataHook(ups->ssl, (SSLGetClientAuthData)GetClientAuthData, ups); if (status != SECSuccess) { nss_error("upscli_sslinit / SSL_GetClientAuthDataHook"); return -1; } - + status = SSL_HandshakeCallback(ups->ssl, (SSLHandshakeCallback)HandshakeCallback, ups); if (status != SECSuccess) { nss_error("upscli_sslinit / SSL_HandshakeCallback"); @@ -830,9 +930,9 @@ static int upscli_sslinit(UPSCONN_t *ups, int verifycert) /* TODO : Close the connection. */ return -1; } - + return 1; - + #endif /* WITH_OPENSSL | WITH_NSS */ } @@ -840,12 +940,15 @@ static int upscli_sslinit(UPSCONN_t *ups, int verifycert) static int upscli_sslinit(UPSCONN_t *ups, int verifycert) { + NUT_UNUSED_VARIABLE(ups); + NUT_UNUSED_VARIABLE(verifycert); + return 0; /* not supported */ } #endif /* WITH_SSL */ -int upscli_tryconnect(UPSCONN_t *ups, const char *host, int port, int flags,struct timeval * timeout) +int upscli_tryconnect(UPSCONN_t *ups, const char *host, uint16_t port, int flags, struct timeval * timeout) { int sock_fd; struct addrinfo hints, *res, *ai; @@ -871,7 +974,7 @@ int upscli_tryconnect(UPSCONN_t *ups, const char *host, int port, int flags,stru return -1; } - snprintf(sport, sizeof(sport), "%hu", (unsigned short int)port); + snprintf(sport, sizeof(sport), "%ju", (uintmax_t)port); memset(&hints, 0, sizeof(hints)); @@ -1005,7 +1108,7 @@ int upscli_tryconnect(UPSCONN_t *ups, const char *host, int port, int flags,stru ups->port = port; hostcert = upscli_find_host_cert(host); - + if (hostcert != NULL) { /* An host security rule is specified. */ certverify = hostcert->certverify; @@ -1015,39 +1118,39 @@ int upscli_tryconnect(UPSCONN_t *ups, const char *host, int port, int flags,stru forcessl = (flags & UPSCLI_CONN_REQSSL) != 0 ? 1 : 0; } tryssl = (flags & UPSCLI_CONN_TRYSSL) != 0 ? 1 : 0; - + if (tryssl || forcessl) { ret = upscli_sslinit(ups, certverify); if (forcessl && ret != 1) { - upslogx(LOG_ERR, "Can not connect to %s in SSL, disconnect", host); + upslogx(LOG_ERR, "Can not connect to NUT server %s in SSL, disconnect", host); ups->upserror = UPSCLI_ERR_SSLFAIL; upscli_disconnect(ups); return -1; } else if (tryssl && ret == -1) { - upslogx(LOG_NOTICE, "Error while connecting to %s, disconnect", host); + upslogx(LOG_NOTICE, "Error while connecting to NUT server %s, disconnect", host); upscli_disconnect(ups); return -1; } else if (tryssl && ret == 0) { if (certverify != 0) { - upslogx(LOG_NOTICE, "Can not connect to %s in SSL and " + upslogx(LOG_NOTICE, "Can not connect to NUT server %s in SSL and " "certificate is needed, disconnect", host); upscli_disconnect(ups); return -1; } - upsdebugx(3, "Can not connect to %s in SSL, continue uncrypted", host); + upsdebugx(3, "Can not connect to NUT server %s in SSL, continue unencrypted", host); } else { - upslogx(LOG_INFO, "Connected to %s in SSL", host); + upslogx(LOG_INFO, "Connected to NUT server %s in SSL", host); if (certverify == 0) { /* you REALLY should set CERTVERIFY to 1 if using SSL... */ upslogx(LOG_WARNING, "Certificate verification is disabled"); } } } - + return 0; } -int upscli_connect(UPSCONN_t *ups, const char *host, int port, int flags) +int upscli_connect(UPSCONN_t *ups, const char *host, uint16_t port, int flags) { return upscli_tryconnect(ups,host,port,flags,NULL); } @@ -1058,7 +1161,7 @@ static struct { const char *text; } upsd_errlist[] = { - { UPSCLI_ERR_VARNOTSUPP, "VAR-NOT-SUPPORTED" }, + { UPSCLI_ERR_VARNOTSUPP, "VAR-NOT-SUPPORTED" }, { UPSCLI_ERR_UNKNOWNUPS, "UNKNOWN-UPS" }, { UPSCLI_ERR_ACCESSDENIED, "ACCESS-DENIED" }, { UPSCLI_ERR_PWDREQUIRED, "PASSWORD-REQUIRED" }, @@ -1083,7 +1186,7 @@ static struct { { UPSCLI_ERR_INVPASSWORD, "INVALID-PASSWORD" }, { UPSCLI_ERR_USERREQUIRED, "USERNAME-REQUIRED" }, { UPSCLI_ERR_DRVNOTCONN, "DRIVER-NOT-CONNECTED" }, - + { 0, NULL, } }; @@ -1120,9 +1223,9 @@ static int upscli_errcheck(UPSCONN_t *ups, char *buf) } static void build_cmd(char *buf, size_t bufsize, const char *cmdname, - int numarg, const char **arg) + size_t numarg, const char **arg) { - int i; + size_t i; size_t len; char enc[UPSCLI_NETBUF_LEN]; const char *format; @@ -1142,8 +1245,20 @@ static void build_cmd(char *buf, size_t bufsize, const char *cmdname, /* snprintfcat would tie us to common */ len = strlen(buf); - snprintf(buf + len, bufsize - len, format, +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + snprintf(buf + len, bufsize - len, format, pconf_encode(arg[i], enc, sizeof(enc))); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif } len = strlen(buf); @@ -1151,9 +1266,9 @@ static void build_cmd(char *buf, size_t bufsize, const char *cmdname, } /* make sure upsd is giving us what we asked for */ -static int verify_resp(int num, const char **q, char **a) +static int verify_resp(size_t num, const char **q, char **a) { - int i; + size_t i; for (i = 0; i < num; i++) { if (strcasecmp(q[i], a[i]) != 0) { @@ -1166,11 +1281,11 @@ static int verify_resp(int num, const char **q, char **a) return 1; /* OK */ } -int upscli_get(UPSCONN_t *ups, unsigned int numq, const char **query, - unsigned int *numa, char ***answer) +int upscli_get(UPSCONN_t *ups, size_t numq, const char **query, + size_t *numa, char ***answer) { char cmd[UPSCLI_NETBUF_LEN], tmp[UPSCLI_NETBUF_LEN]; - + if (!ups) { return -1; } @@ -1219,7 +1334,7 @@ int upscli_get(UPSCONN_t *ups, unsigned int numq, const char **query, return 0; } -int upscli_list_start(UPSCONN_t *ups, unsigned int numq, const char **query) +int upscli_list_start(UPSCONN_t *ups, size_t numq, const char **query) { char cmd[UPSCLI_NETBUF_LEN], tmp[UPSCLI_NETBUF_LEN]; @@ -1277,8 +1392,8 @@ int upscli_list_start(UPSCONN_t *ups, unsigned int numq, const char **query) return 0; } -int upscli_list_next(UPSCONN_t *ups, unsigned int numq, const char **query, - unsigned int *numa, char ***answer) +int upscli_list_next(UPSCONN_t *ups, size_t numq, const char **query, + size_t *numa, char ***answer) { char tmp[UPSCLI_NETBUF_LEN]; @@ -1326,9 +1441,9 @@ int upscli_list_next(UPSCONN_t *ups, unsigned int numq, const char **query, return 1; } -int upscli_sendline(UPSCONN_t *ups, const char *buf, size_t buflen) +ssize_t upscli_sendline_timeout(UPSCONN_t *ups, const char *buf, size_t buflen, const time_t timeout) { - int ret; + ssize_t ret; if (!ups) { return -1; @@ -1349,7 +1464,7 @@ int upscli_sendline(UPSCONN_t *ups, const char *buf, size_t buflen) return -1; } - ret = net_write(ups, buf, buflen); + ret = net_write(ups, buf, buflen, timeout); if (ret < 1) { upscli_disconnect(ups); @@ -1359,9 +1474,14 @@ int upscli_sendline(UPSCONN_t *ups, const char *buf, size_t buflen) return 0; } -int upscli_readline(UPSCONN_t *ups, char *buf, size_t buflen) +ssize_t upscli_sendline(UPSCONN_t *ups, const char *buf, size_t buflen) { - int ret; + return upscli_sendline_timeout(ups, buf, buflen, 0); +} + +ssize_t upscli_readline_timeout(UPSCONN_t *ups, char *buf, size_t buflen, const time_t timeout) +{ + ssize_t ret; size_t recv; if (!ups) { @@ -1387,14 +1507,17 @@ int upscli_readline(UPSCONN_t *ups, char *buf, size_t buflen) if (ups->readidx == ups->readlen) { - ret = net_read(ups, ups->readbuf, sizeof(ups->readbuf)); + ret = net_read(ups, ups->readbuf, sizeof(ups->readbuf), timeout); if (ret < 1) { upscli_disconnect(ups); return -1; } - ups->readlen = ret; + /* Here ret is safe to cast since it is >=1 and certainly + * fits under SIZE_MAX being it signed sibling + */ + ups->readlen = (size_t)ret; ups->readidx = 0; } @@ -1409,8 +1532,13 @@ int upscli_readline(UPSCONN_t *ups, char *buf, size_t buflen) return 0; } +ssize_t upscli_readline(UPSCONN_t *ups, char *buf, size_t buflen) +{ + return upscli_readline_timeout(ups, buf, buflen, DEFAULT_NETWORK_TIMEOUT); +} + /* split upsname[@hostname[:port]] into separate components */ -int upscli_splitname(const char *buf, char **upsname, char **hostname, int *port) +int upscli_splitname(const char *buf, char **upsname, char **hostname, uint16_t *port) { char *s, tmp[SMALLBUF], *last = NULL; @@ -1446,9 +1574,10 @@ int upscli_splitname(const char *buf, char **upsname, char **hostname, int *port } /* split hostname[:port] into separate components */ -int upscli_splitaddr(const char *buf, char **hostname, int *port) +int upscli_splitaddr(const char *buf, char **hostname, uint16_t *port) { char *s, tmp[SMALLBUF], *last = NULL; + long l; /* paranoia */ if ((!buf) || (!hostname) || (!port)) { @@ -1491,10 +1620,13 @@ int upscli_splitaddr(const char *buf, char **hostname, int *port) } } - if ((*(++s) == '\0') || ((*port = strtol(s, NULL, 10)) < 1 )) { + /* Check that "long" port fits in an "uint16_t" so is in IP range + * (under 65536) */ + if ((*(++s) == '\0') || ((l = strtol(s, NULL, 10)) < 1 ) || (l > 65535)) { fprintf(stderr, "upscli_splitaddr: no port specified after ':' separator\n"); return -1; } + *port = (uint16_t)l; return 0; } @@ -1518,7 +1650,7 @@ int upscli_disconnect(UPSCONN_t *ups) return 0; } - net_write(ups, "LOGOUT\n", 7); + net_write(ups, "LOGOUT\n", 7, 0); #ifdef WITH_OPENSSL if (ups->ssl) { diff --git a/clients/upsclient.h b/clients/upsclient.h index ac5fb5d..08574b8 100644 --- a/clients/upsclient.h +++ b/clients/upsclient.h @@ -21,13 +21,26 @@ #define UPSCLIENT_H_SEEN #ifdef WITH_OPENSSL - #include - #include + #include + #include #elif defined(WITH_NSS) /* WITH_OPENSSL */ #include #include #endif /* WITH_OPENSSL | WITH_NSS */ +/* Not including nut_stdint.h because this is part of end-user API */ +#if defined HAVE_INTTYPES_H + #include +#endif + +#if defined HAVE_STDINT_H + #include +#endif + +#if defined HAVE_LIMITS_H + #include +#endif + #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { @@ -41,7 +54,7 @@ extern "C" { typedef struct { char *host; - int port; + uint16_t port; int fd; int flags; int upserror; @@ -69,31 +82,33 @@ typedef struct { const char *upscli_strerror(UPSCONN_t *ups); int upscli_init(int certverify, const char *certpath, const char *certname, const char *certpasswd); -int upscli_cleanup(); +int upscli_cleanup(void); -int upscli_tryconnect(UPSCONN_t *ups, const char *host, int port, int flags, struct timeval *tv); -int upscli_connect(UPSCONN_t *ups, const char *host, int port, int flags); +int upscli_tryconnect(UPSCONN_t *ups, const char *host, uint16_t port, int flags, struct timeval *tv); +int upscli_connect(UPSCONN_t *ups, const char *host, uint16_t port, int flags); void upscli_add_host_cert(const char* hostname, const char* certname, int certverify, int forcessl); /* --- functions that only use the new names --- */ -int upscli_get(UPSCONN_t *ups, unsigned int numq, const char **query, - unsigned int *numa, char ***answer); +int upscli_get(UPSCONN_t *ups, size_t numq, const char **query, + size_t *numa, char ***answer); -int upscli_list_start(UPSCONN_t *ups, unsigned int numq, const char **query); +int upscli_list_start(UPSCONN_t *ups, size_t numq, const char **query); -int upscli_list_next(UPSCONN_t *ups, unsigned int numq, const char **query, - unsigned int *numa, char ***answer); +int upscli_list_next(UPSCONN_t *ups, size_t numq, const char **query, + size_t *numa, char ***answer); -int upscli_sendline(UPSCONN_t *ups, const char *buf, size_t buflen); +ssize_t upscli_sendline_timeout(UPSCONN_t *ups, const char *buf, size_t buflen, const time_t timeout); +ssize_t upscli_sendline(UPSCONN_t *ups, const char *buf, size_t buflen); -int upscli_readline(UPSCONN_t *ups, char *buf, size_t buflen); +ssize_t upscli_readline_timeout(UPSCONN_t *ups, char *buf, size_t buflen, const time_t timeout); +ssize_t upscli_readline(UPSCONN_t *ups, char *buf, size_t buflen); int upscli_splitname(const char *buf, char **upsname, char **hostname, - int *port); + uint16_t *port); -int upscli_splitaddr(const char *buf, char **hostname, int *port); +int upscli_splitaddr(const char *buf, char **hostname, uint16_t *port); int upscli_disconnect(UPSCONN_t *ups); @@ -103,7 +118,7 @@ int upscli_fd(UPSCONN_t *ups); int upscli_upserror(UPSCONN_t *ups); /* returns 1 if SSL mode is active for this connection */ -int upscli_ssl(UPSCONN_t *ups); +int upscli_ssl(UPSCONN_t *ups); /* upsclient error list */ diff --git a/clients/upscmd.c b/clients/upscmd.c index f4990a8..c057303 100644 --- a/clients/upscmd.c +++ b/clients/upscmd.c @@ -1,6 +1,8 @@ /* upscmd - simple "client" to test instant commands via upsd - Copyright (C) 2000 Russell Kroll + Copyright (C) + 2000 Russell Kroll + 2019 EATON (author: Arnaud Quette ) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,10 +28,13 @@ #include #include +#include "nut_stdint.h" #include "upsclient.h" -static char *upsname = NULL, *hostname = NULL; +static char *upsname = NULL, *hostname = NULL; static UPSCONN_t *ups = NULL; +static int tracking_enabled = 0; +static unsigned int timeout = DEFAULT_TRACKING_TIMEOUT; struct list_t { char *name; @@ -41,13 +46,16 @@ static void usage(const char *prog) printf("Network UPS Tools upscmd %s\n\n", UPS_VERSION); printf("usage: %s [-h]\n", prog); printf(" %s [-l ]\n", prog); - printf(" %s [-u ] [-p ] []\n\n", prog); + printf(" %s [-u ] [-p ] [-w] [-t ] []\n\n", prog); printf("Administration program to initiate instant commands on UPS hardware.\n"); printf("\n"); printf(" -h display this help text\n"); printf(" -l show available commands on UPS \n"); printf(" -u set username for command authentication\n"); printf(" -p set password for command authentication\n"); + printf(" -w wait for the completion of command by the driver\n"); + printf(" and return its actual result from the device\n"); + printf(" -t set a timeout when using -w (in seconds, default: %u)\n", DEFAULT_TRACKING_TIMEOUT); printf("\n"); printf(" UPS identifier - [@[:]]\n"); printf(" Valid instant command - test.panel.start, etc.\n"); @@ -57,7 +65,7 @@ static void usage(const char *prog) static void print_cmd(char *cmdname) { int ret; - unsigned int numq, numa; + size_t numq, numa; const char *query[4]; char **answer; @@ -80,7 +88,7 @@ static void print_cmd(char *cmdname) static void listcmds(void) { int ret; - unsigned int numq, numa; + size_t numq, numa; const char *query[4]; char **answer; struct list_t *lhead = NULL, *llast = NULL, *ltmp, *lnext; @@ -105,7 +113,7 @@ static void listcmds(void) /* CMD */ if (numa < 3) { - fatalx(EXIT_FAILURE, "Error: insufficient data (got %d args, need at least 3)", numa); + fatalx(EXIT_FAILURE, "Error: insufficient data (got %zu args, need at least 3)", numa); } /* we must first read the entire list of commands, @@ -136,9 +144,21 @@ static void listcmds(void) } } +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC) && (!defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_INSIDEFUNC) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC) ) +# pragma GCC diagnostic push +#endif +#if (!defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_INSIDEFUNC) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC) +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif +#if (!defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_INSIDEFUNC) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC) +# pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif static void do_cmd(char **argv, const int argc) { + int cmd_complete = 0; char buf[SMALLBUF]; + char tracking_id[UUID4_LEN]; + time_t start, now; if (argc > 1) { snprintf(buf, sizeof(buf), "INSTCMD %s %s %s\n", upsname, argv[0], argv[1]); @@ -154,13 +174,88 @@ static void do_cmd(char **argv, const int argc) fatalx(EXIT_FAILURE, "Instant command failed: %s", upscli_strerror(ups)); } - /* FUTURE: status cookies will tie in here */ + /* verify answer */ if (strncmp(buf, "OK", 2) != 0) { fatalx(EXIT_FAILURE, "Unexpected response from upsd: %s", buf); } + /* check for status tracking id */ + if ( + !tracking_enabled || + /* sanity check on the size: "OK TRACKING " + UUID4_LEN */ + strlen(buf) != (UUID4_LEN - 1 + strlen("OK TRACKING ")) + ) { + /* reply as usual */ + fprintf(stderr, "%s\n", buf); + return; + } + +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION +#pragma GCC diagnostic ignored "-Wformat-truncation" +#endif + /* From the check above, we know that we have exactly UUID4_LEN chars + * (aka sizeof(tracking_id)) in the buf after "OK TRACKING " prefix, + * plus the null-byte. + */ + assert (UUID4_LEN == 1 + snprintf(tracking_id, sizeof(tracking_id), "%s", buf + strlen("OK TRACKING "))); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION +#pragma GCC diagnostic pop +#endif + time(&start); + + /* send status tracking request, looping if status is PENDING */ + while (!cmd_complete) { + + /* check for timeout */ + time(&now); + if (difftime(now, start) >= timeout) + fatalx(EXIT_FAILURE, "Can't receive status tracking information: timeout"); + + snprintf(buf, sizeof(buf), "GET TRACKING %s\n", tracking_id); + + if (upscli_sendline(ups, buf, strlen(buf)) < 0) + fatalx(EXIT_FAILURE, "Can't send status tracking request: %s", upscli_strerror(ups)); + +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) ) +/* Note for gating macros above: unsuffixed HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP + * means support of contexts both inside and outside function body, so the push + * above and pop below (outside this finction) are not used. + */ +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS +/* Note that the individual warning pragmas for use inside function bodies + * are named without a _INSIDEFUNC suffix, for simplicity and legacy reasons + */ +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE +# pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif + /* and get status tracking reply */ + assert(timeout < LONG_MAX); +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) ) +# pragma GCC diagnostic pop +#endif + + if (upscli_readline_timeout(ups, buf, sizeof(buf), (long)timeout) < 0) + fatalx(EXIT_FAILURE, "Can't receive status tracking information: %s", upscli_strerror(ups)); + + if (strncmp(buf, "PENDING", 7)) + cmd_complete = 1; + else + /* wait a second before retrying */ + sleep(1); + } + fprintf(stderr, "%s\n", buf); } +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC) && (!defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_INSIDEFUNC) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC) ) +# pragma GCC diagnostic pop +#endif static void clean_exit(void) { @@ -175,12 +270,14 @@ static void clean_exit(void) int main(int argc, char **argv) { - int i, ret, port; + int i; + uint16_t port; + ssize_t ret; int have_un = 0, have_pw = 0, cmdlist = 0; - char buf[SMALLBUF], username[SMALLBUF], password[SMALLBUF]; + char buf[SMALLBUF * 2], username[SMALLBUF], password[SMALLBUF]; const char *prog = xbasename(argv[0]); - while ((i = getopt(argc, argv, "+lhu:p:V")) != -1) { + while ((i = getopt(argc, argv, "+lhu:p:t:wV")) != -1) { switch (i) { @@ -198,8 +295,20 @@ int main(int argc, char **argv) have_pw = 1; break; + case 't': + if (!str_to_uint(optarg, &timeout, 10)) + fatal_with_errno(EXIT_FAILURE, "Could not convert the provided value for timeout ('-t' option) to unsigned int"); + break; + + case 'w': + tracking_enabled = 1; + break; + case 'V': fatalx(EXIT_SUCCESS, "Network UPS Tools upscmd %s", UPS_VERSION); +#ifndef HAVE___ATTRIBUTE__NORETURN + exit(EXIT_SUCCESS); /* Should not get here in practice, but compiler is afraid we can fall through */ +#endif case 'h': default: @@ -313,6 +422,25 @@ int main(int argc, char **argv) fatalx(EXIT_FAILURE, "Set password failed: %s", upscli_strerror(ups)); } + /* enable status tracking ID */ + if (tracking_enabled) { + + snprintf(buf, sizeof(buf), "SET TRACKING ON\n"); + + if (upscli_sendline(ups, buf, strlen(buf)) < 0) { + fatalx(EXIT_FAILURE, "Can't enable command status tracking: %s", upscli_strerror(ups)); + } + + if (upscli_readline(ups, buf, sizeof(buf)) < 0) { + fatalx(EXIT_FAILURE, "Enabling command status tracking failed: %s", upscli_strerror(ups)); + } + + /* Verify the result */ + if (strncmp(buf, "OK", 2) != 0) { + fatalx(EXIT_FAILURE, "Enabling command status tracking failed. upsd answered: %s", buf); + } + } + do_cmd(&argv[1], argc - 1); exit(EXIT_SUCCESS); diff --git a/clients/upsimage.c b/clients/upsimage.c index 3d6a51d..d49156c 100644 --- a/clients/upsimage.c +++ b/clients/upsimage.c @@ -37,6 +37,7 @@ */ #include "common.h" +#include "nut_stdint.h" #include "upsclient.h" #include "cgilib.h" #include @@ -49,7 +50,7 @@ static char *monhost = NULL, *cmd = NULL; -static int port; +static uint16_t port; static char *upsname, *hostname; static UPSCONN_t ups; @@ -60,7 +61,7 @@ static UPSCONN_t ups; void parsearg(char *var, char *value) { - int i, v; + long long i, v; /* Be big enough to fit all expected inputs; truncate later */ /* avoid bogus junk from evil people */ if ((strlen(var) > MAX_CGI_STRLEN) || (strlen(value) > MAX_CGI_STRLEN)) @@ -82,17 +83,20 @@ void parsearg(char *var, char *value) for (i = 0; imgarg[i].name != NULL; i++) { if (!strcmp(imgarg[i].name, var)) { if (!strncmp(value, "0x", 2)) - v = strtoul(value + 2, (char **)NULL, 16); + v = (long long)strtoul(value + 2, (char **)NULL, 16); else - v = atoi(value); + v = (long long)atoi(value); /* avoid false numbers from bad people */ if (v < imgarg[i].min) imgarg[i].val = imgarg[i].min; else if (v > imgarg[i].max) imgarg[i].val = imgarg[i].max; - else - imgarg[i].val = v; + else { + assert (v < INT_MAX); + assert (v > INT_MIN); + imgarg[i].val = (int)v; + } return; } } @@ -111,6 +115,9 @@ static int get_imgarg(const char *name) } /* write the HTML header then have gd dump the image */ +static void drawimage(gdImagePtr im) + __attribute__((noreturn)); + static void drawimage(gdImagePtr im) { printf("Pragma: no-cache\n"); @@ -191,7 +198,7 @@ static void drawscale( if (level % step5 == 0) gdImageLine(im, 5, y, width - 5, y, col2); else - gdImageLine(im, 10, y, width - 10, y, col2); + gdImageLine(im, 10, y, width - 10, y, col2); } } @@ -200,13 +207,25 @@ static void drawscale( if (level % step10 == 0) { y = scale_height * (lvlhi - level) / range; snprintf(lbltxt, sizeof(lbltxt), "%d", level); - gdImageString(im, gdFontMediumBold, width - strlen(lbltxt)*gdFontMediumBold->w, y, - (unsigned char *) lbltxt, scale_num_color); + gdImageString(im, gdFontMediumBold, + width - (int)(strlen(lbltxt)) * gdFontMediumBold->w, + y, (unsigned char *) lbltxt, scale_num_color); } } } /* draws the bar style indicator */ +static void drawbar( + int lvllo, int lvlhi, /* min and max numbers on the scale */ + int step, int step5, int step10, /* steps for minor, submajor and major dashes */ + int redlo1, int redhi1, /* first red zone start and end */ + int redlo2, int redhi2, /* second red zone start and end */ + int grnlo, int grnhi, /* green zone start and end */ + double value, /* UPS variable value to draw */ + const char *format /* printf style format to be used when rendering summary text */ +) + __attribute__((noreturn)); + static void drawbar( int lvllo, int lvlhi, /* min and max numbers on the scale */ int step, int step5, int step10, /* steps for minor, submajor and major dashes */ @@ -240,7 +259,7 @@ static void drawbar( summary_color = color_alloc(im, get_imgarg("summary_col")); /* rescale UPS value to fit in the scale */ - bar_y = (1 - (value - lvllo) / (lvlhi - lvllo)) * scale_height; + bar_y = (int)((1.0 - (value - lvllo) / (lvlhi - lvllo)) * scale_height); /* sanity checks: */ @@ -257,9 +276,21 @@ static void drawbar( bar_color); /* stick the text version of the value at the bottom center */ +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(text, sizeof(text), format, value); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif gdImageString(im, gdFontMediumBold, - (width - strlen(text)*gdFontMediumBold->w)/2, + (width - (int)(strlen(text))*gdFontMediumBold->w)/2, height - gdFontMediumBold->h, (unsigned char *) text, summary_color); @@ -269,6 +300,9 @@ static void drawbar( } /* draws the error image */ +static void noimage(const char *fmt, ...) + __attribute__((noreturn)); + static void noimage(const char *fmt, ...) { gdImagePtr im; @@ -278,7 +312,19 @@ static void noimage(const char *fmt, ...) va_list ap; va_start(ap, fmt); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif vsnprintf(msg, sizeof(msg), fmt, ap); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif va_end(ap); width = get_imgarg("width"); @@ -293,17 +339,23 @@ static void noimage(const char *fmt, ...) if (width > height) gdImageString(im, gdFontMediumBold, - (width - strlen(msg)*gdFontMediumBold->w)/2, + (width - (int)(strlen(msg))*gdFontMediumBold->w)/2, (height - gdFontMediumBold->h)/2, (unsigned char *) msg, summary_color); else gdImageStringUp(im, gdFontMediumBold, (width - gdFontMediumBold->h)/2, - (height + strlen(msg)*gdFontMediumBold->w)/2, + (height + (int)(strlen(msg))*gdFontMediumBold->w)/2, (unsigned char *) msg, summary_color); drawimage(im); + /* NOTE: Earlier code called noimage() and then exit(EXIT_FAILURE); + * to signal an error via process exit code. Now that drawimage() + * always ends with exit(EXIT_SUCCESS) - which might make webserver + * feel good - the command-line use if any suffers no error returns. + */ + /* NOTREACHED */ } @@ -311,6 +363,10 @@ static void noimage(const char *fmt, ...) UPS variable can be determined. deviation < 0 means that values below nom should be grey instead of green */ +static void drawgeneralbar(double var, int min, int nom, int max, + int deviation, const char *format) + __attribute__((noreturn)); + static void drawgeneralbar(double var, int min, int nom, int max, int deviation, const char *format) { @@ -370,6 +426,10 @@ static void drawgeneralbar(double var, int min, int nom, int max, } /* draws input and output voltage bar style indicators */ +static void draw_utility(double var, int min, int nom, int max, + int deviation, const char *format) + __attribute__((noreturn)); + static void draw_utility(double var, int min, int nom, int max, int deviation, const char *format) { @@ -405,7 +465,7 @@ static void draw_utility(double var, int min, int nom, int max, /* Acceptable range of voltage is 85%-110% of nominal voltage * in EU at least. Be conservative and say +-10% */ - deviation = nom*0.1; + deviation = (int)(nom * 0.1); drawgeneralbar(var, min, nom, max, deviation, format); @@ -413,9 +473,17 @@ static void draw_utility(double var, int min, int nom, int max, } /* draws battery.percent bar style indicator */ -static void draw_battpct(double var, int min, int nom, int max, - int deviation, const char *format) +static void draw_battpct(double var, int min, int nom, + int max, int deviation, const char *format) + __attribute__((noreturn)); + +static void draw_battpct(double var, int min, int nom, + int max, int deviation, const char *format) { + NUT_UNUSED_VARIABLE(nom); + NUT_UNUSED_VARIABLE(max); + NUT_UNUSED_VARIABLE(deviation); + if (min < 0) { min = 50; } @@ -424,6 +492,10 @@ static void draw_battpct(double var, int min, int nom, int max, } /* draws battery.voltage bar style indicator */ +static void draw_battvolt(double var, int min, int nom, int max, + int deviation, const char *format) + __attribute__((noreturn)); + static void draw_battvolt(double var, int min, int nom, int max, int deviation, const char *format) { @@ -450,18 +522,17 @@ static void draw_battvolt(double var, int min, int nom, int max, } if(min == -1) { - min = nom/2*1.6+1; /* Assume a 2V cell is dead at 1.6V */ + min = (int)(nom/2*1.6+1); /* Assume a 2V cell is dead at 1.6V */ } if(max == -1) { - max = nom/2*2.3+1; /* Assume 2.3V float charge voltage */ + max = (int)(nom/2*2.3+1); /* Assume 2.3V float charge voltage */ } if (nom < min || nom > max) - nom = -1; + nom = -1; - - deviation = -(nom*0.05); /* 5% deviation from nominal voltage */ + deviation = (int)(-nom*0.05); /* 5% deviation from nominal voltage */ if(deviation==0) { deviation = -1; } @@ -470,33 +541,57 @@ static void draw_battvolt(double var, int min, int nom, int max, } /* draws ups.load bar style indicator */ -static void draw_upsload(double var, int min, int nom, int max, +static void draw_upsload(double var, int min, + int nom, int max, + int deviation, const char *format) + __attribute__((noreturn)); + +static void draw_upsload(double var, int min, + int nom, int max, int deviation, const char *format) { + NUT_UNUSED_VARIABLE(min); + NUT_UNUSED_VARIABLE(nom); + NUT_UNUSED_VARIABLE(max); + NUT_UNUSED_VARIABLE(deviation); + drawbar(0, 125, 5, 5, 25, 100, 125, -1, -1, 0, 50, var, format); } /* draws temperature bar style indicator */ +static void draw_temperature(double var, int min, int nom, int max, + int deviation, const char *format) + __attribute__((noreturn)); + static void draw_temperature(double var, int min, int nom, int max, int deviation, const char *format) { int hi = get_imgarg("tempmax"); int lo = get_imgarg("tempmin"); + NUT_UNUSED_VARIABLE(nom); + NUT_UNUSED_VARIABLE(deviation); drawbar(lo, hi, 1, 5, 10, lo, min, max, hi, -1, -1, var, format); } /* draws humidity bar style indicator */ +static void draw_humidity(double var, int min, int nom, int max, + int deviation, const char *format) + __attribute__((noreturn)); + static void draw_humidity(double var, int min, int nom, int max, int deviation, const char *format) { + NUT_UNUSED_VARIABLE(nom); + NUT_UNUSED_VARIABLE(deviation); + drawbar(0, 100, 2, 10, 20, 0, min, max, 100, -1, -1, var, format); } static int get_var(const char *var, char *buf, size_t buflen) { int ret; - unsigned int numq, numa; + size_t numq, numa; const char *query[4]; char **answer; @@ -523,6 +618,8 @@ int main(int argc, char **argv) char str[SMALLBUF]; int i, min, nom, max; double var = 0; + NUT_UNUSED_VARIABLE(argc); + NUT_UNUSED_VARIABLE(argv); extractcgiargs(); @@ -537,13 +634,17 @@ int main(int argc, char **argv) if (upscli_splitname(monhost, &upsname, &hostname, &port) != 0) { noimage("Invalid UPS definition (upsname[@hostname[:port]])\n"); - exit(EXIT_FAILURE); +#ifndef HAVE___ATTRIBUTE__NORETURN + exit(EXIT_FAILURE); /* Should not get here in practice, but compiler is afraid we can fall through */ +#endif } if (upscli_connect(&ups, hostname, port, 0) < 0) { noimage("Can't connect to server:\n%s\n", upscli_strerror(&ups)); - exit(EXIT_FAILURE); +#ifndef HAVE___ATTRIBUTE__NORETURN + exit(EXIT_FAILURE); /* Should not get here in practice, but compiler is afraid we can fall through */ +#endif } for (i = 0; imgvar[i].name; i++) @@ -553,7 +654,9 @@ int main(int argc, char **argv) registered with this variable */ if (!imgvar[i].drawfunc) { noimage("Draw function N/A"); - exit(EXIT_FAILURE); +#ifndef HAVE___ATTRIBUTE__NORETURN + exit(EXIT_FAILURE); /* Should not get here in practice, but compiler is afraid we can fall through */ +#endif } /* get the variable value */ @@ -564,7 +667,9 @@ int main(int argc, char **argv) snprintf(str, sizeof(str), "%s N/A", imgvar[i].name); noimage(str); - exit(EXIT_FAILURE); +#ifndef HAVE___ATTRIBUTE__NORETURN + exit(EXIT_FAILURE); /* Should not get here in practice, but compiler is afraid we can fall through */ +#endif } /* when getting minimum, nominal and maximum values, @@ -617,7 +722,9 @@ int main(int argc, char **argv) } noimage("Unknown display"); +#ifndef HAVE___ATTRIBUTE__NORETURN exit(EXIT_FAILURE); +#endif } imgvar_t imgvar[] = { diff --git a/clients/upsimagearg.h b/clients/upsimagearg.h index 9483d8d..7064b7f 100644 --- a/clients/upsimagearg.h +++ b/clients/upsimagearg.h @@ -17,25 +17,32 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef NUT_UPSIMAGEARG_H_SEEN +#define NUT_UPSIMAGEARG_H_SEEN 1 + #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { /* *INDENT-ON* */ #endif -struct { +/* This is used in upsstats.c and in upsimage.c, but compiler complains about + * non-extern definition if this is not "static". To move or not to move?.. + * Do we have cases of building binaries refering to only one of those objects? + */ +static struct { char *name; int val; /* hex digits, ala HTML */ int min; /* minimum reasonable value */ int max; /* maximum reasonable value */ -} imgarg[] = +} imgarg[] = { { "width", 100, 50, 200 }, { "height", 350, 100, 500 }, { "scale_height", 300, 100, 500 }, { "back_col", 0x000000, 0x000000, 0xffffff }, { "scale_num_col", 0xffff00, 0x000000, 0xffffff }, - { "summary_col", 0xffff00, 0x000000, 0xffffff }, + { "summary_col", 0xffff00, 0x000000, 0xffffff }, { "ok_zone_maj_col", 0x00ff00, 0x000000, 0xffffff }, { "ok_zone_min_col", 0x007800, 0x000000, 0xffffff }, { "neutral_zone_maj_col", 0xffffff, 0x000000, 0xffffff }, @@ -47,20 +54,20 @@ struct { { "tempmax", 40, -100, 150 }, { "nom_in_freq", 50, 0, 100 }, { "nom_out_freq", 50, 0, 100 }, - { NULL, 0, 0, 0 } + { NULL, 0, 0, 0 } }; typedef struct { char *name; /* name of the UPS variable */ char *minimum; /* name of minimum value UPS variable - or variable in imgarg table */ + or variable in imgarg table */ char *nominal; /* as above, only for nominal value */ char *maximum; /* as above, only for maximum value */ int deviation; /* variable deviation - width of green zone */ char *format; /* format string to generate summary text */ /* pointer to drawing function */ - void (*drawfunc)(double, int, int, int, int, const char*); + void (*drawfunc)(double, int, int, int, int, const char*); } imgvar_t; extern imgvar_t imgvar[]; @@ -71,3 +78,4 @@ extern imgvar_t imgvar[]; /* *INDENT-ON* */ #endif +#endif /* NUT_UPSIMAGEARG_H_SEEN */ diff --git a/clients/upslog.c b/clients/upslog.c index 325cdc9..a0ebeaa 100644 --- a/clients/upslog.c +++ b/clients/upslog.c @@ -20,12 +20,12 @@ /* Basic theory of operation: * * First we go through and parse as much of the status format string as - * possible. We used to do this parsing run every time, but that's a + * possible. We used to do this parsing run every time, but that's a * waste of CPU since it can't change during the program's run. * * This version does the parsing pass once, and creates a linked list of * pointers to the functions that do the work and the arg they get. - * + * * That means the main loop just has to run the linked list and call * anything it finds in there. Everything happens from there, and we * don't have to pointlessly reparse the string every time around. @@ -37,9 +37,11 @@ #include "config.h" #include "timehead.h" +#include "nut_stdint.h" #include "upslog.h" - static int port, reopen_flag = 0, exit_flag = 0; + static int reopen_flag = 0, exit_flag = 0; + static uint16_t port; static char *upsname, *hostname; static UPSCONN_t ups; @@ -79,6 +81,8 @@ static void set_exit_flag(int sig) static void set_print_now_flag(int sig) { + NUT_UNUSED_VARIABLE(sig); + /* no need to do anything, the signal will cause sleep to be interrupted */ } @@ -108,6 +112,9 @@ static void setup_signals(void) fatal_with_errno(EXIT_FAILURE, "Can't install SIGUSR1 handler"); } +static void help(const char *prog) + __attribute__((noreturn)); + static void help(const char *prog) { printf("UPS status logger.\n"); @@ -118,7 +125,9 @@ static void help(const char *prog) printf(" -f - Log format. See below for details.\n"); printf(" - Use -f \"\" so your shell doesn't break it up.\n"); printf(" -i - Time between updates, in seconds\n"); - printf(" -l - Log file name, or - for stdout\n"); + printf(" -l - Log file name, or - for stdout (foreground by default)\n"); + printf(" -F - stay foregrounded even if logging into a file\n"); + printf(" -B - stay backgrounded even if logging to stdout\n"); printf(" -p - Base name for PID file (defaults to \"%s\")\n", prog); printf(" -s - Monitor UPS - @[:]\n"); printf(" - Example: -s myups@server\n"); @@ -146,6 +155,7 @@ static void do_host(const char *arg) { int ret; char hn[LARGEBUF]; + NUT_UNUSED_VARIABLE(arg); ret = gethostname(hn, sizeof(hn)); @@ -159,11 +169,15 @@ static void do_host(const char *arg) static void do_upshost(const char *arg) { + NUT_UNUSED_VARIABLE(arg); + snprintfcat(logbuffer, sizeof(logbuffer), "%s", monhost); } static void do_pid(const char *arg) { + NUT_UNUSED_VARIABLE(arg); + snprintfcat(logbuffer, sizeof(logbuffer), "%ld", (long)getpid()); } @@ -172,6 +186,7 @@ static void do_time(const char *arg) unsigned int i; char timebuf[SMALLBUF], *format; time_t tod; + struct tm tmbuf; format = xstrdup(arg); @@ -181,7 +196,7 @@ static void do_time(const char *arg) format[i] = '%'; time(&tod); - strftime(timebuf, sizeof(timebuf), format, localtime(&tod)); + strftime(timebuf, sizeof(timebuf), format, localtime_r(&tod, &tmbuf)); snprintfcat(logbuffer, sizeof(logbuffer), "%s", timebuf); @@ -191,7 +206,7 @@ static void do_time(const char *arg) static void getvar(const char *var) { int ret; - unsigned int numq, numa; + size_t numq, numa; const char *query[4]; char **answer; @@ -235,6 +250,7 @@ static void do_var(const char *arg) static void do_etime(const char *arg) { time_t tod; + NUT_UNUSED_VARIABLE(arg); time(&tod); snprintfcat(logbuffer, sizeof(logbuffer), "%ld", (unsigned long) tod); @@ -269,7 +285,7 @@ static void add_call(void (*fptr)(const char *arg), const char *arg) tmp->next = NULL; if (last) - last->next = tmp; + last->next = tmp; else fhead = tmp; } @@ -277,8 +293,9 @@ static void add_call(void (*fptr)(const char *arg), const char *arg) /* turn the format string into a list of function calls with args */ static void compile_format(void) { - unsigned int i; - int j, found, ofs; + size_t i; + int j, found; + size_t ofs; char *cmd, *arg, *ptr; for (i = 0; i < strlen(logformat); i++) { @@ -330,7 +347,7 @@ static void compile_format(void) /* see if we know how to handle this command */ for (j = 0; logcmds[j].name != NULL; j++) { - if (strncasecmp(cmd, logcmds[j].name, + if (strncasecmp(cmd, logcmds[j].name, strlen(logcmds[j].name)) == 0) { add_call(logcmds[j].func, arg); @@ -378,7 +395,7 @@ static void run_flist(void) int main(int argc, char **argv) { - int interval = 30, i; + int interval = 30, i, foreground = -1; const char *prog = xbasename(argv[0]); time_t now, nextpoll = 0; const char *user = NULL; @@ -390,11 +407,13 @@ int main(int argc, char **argv) printf("Network UPS Tools %s %s\n", prog, UPS_VERSION); - while ((i = getopt(argc, argv, "+hs:l:i:f:u:Vp:")) != -1) { + while ((i = getopt(argc, argv, "+hs:l:i:f:u:Vp:FB")) != -1) { switch(i) { case 'h': help(prog); +#ifndef HAVE___ATTRIBUTE__NORETURN break; +#endif case 's': monhost = optarg; @@ -422,6 +441,14 @@ int main(int argc, char **argv) case 'p': pidfilebase = optarg; break; + + case 'F': + foreground = 1; + break; + + case 'B': + foreground = 0; + break; } } @@ -462,7 +489,7 @@ int main(int argc, char **argv) if (!logformat) fatalx(EXIT_FAILURE, "No format defined - but this should be impossible"); - printf("logging status of %s to %s (%is intervals)\n", + printf("logging status of %s to %s (%is intervals)\n", monhost, logfn, interval); if (upscli_splitname(monhost, &upsname, &hostname, &port) != 0) { @@ -470,7 +497,7 @@ int main(int argc, char **argv) } if (upscli_connect(&ups, hostname, port, UPSCLI_CONN_TRYSSL) < 0) - fprintf(stderr, "Warning: initial connect failed: %s\n", + fprintf(stderr, "Warning: initial connect failed: %s\n", upscli_strerror(&ups)); if (strcmp(logfn, "-") == 0) @@ -484,10 +511,19 @@ int main(int argc, char **argv) /* now drop root if we have it */ new_uid = get_user_pwent(user); - open_syslog(prog); + open_syslog(prog); - if (logfile != stdout) + if (foreground < 0) { + if (logfile == stdout) { + foreground = 1; + } else { + foreground = 0; + } + } + + if (!foreground) { background(); + } setup_signals(); @@ -502,7 +538,7 @@ int main(int argc, char **argv) if (nextpoll > now) { /* there is still time left, so sleep it off */ - sleep(difftime(nextpoll, now)); + sleep((unsigned int)(difftime(nextpoll, now))); nextpoll += interval; } else { /* we spent more time in polling than the interval allows */ @@ -510,7 +546,7 @@ int main(int argc, char **argv) } if (reopen_flag) { - upslogx(LOG_INFO, "Signal %d: reopening log file", + upslogx(LOG_INFO, "Signal %d: reopening log file", reopen_flag); reopen_log(); reopen_flag = 0; @@ -535,7 +571,7 @@ int main(int argc, char **argv) fclose(logfile); upscli_disconnect(&ups); - + exit(EXIT_SUCCESS); } diff --git a/clients/upslog.h b/clients/upslog.h index 4d0596f..2e31ec4 100644 --- a/clients/upslog.h +++ b/clients/upslog.h @@ -1,5 +1,8 @@ /* upslog.h - table of functions for handling various logging functions */ +#ifndef NUT_UPSLOG_H_SEEN +#define NUT_UPSLOG_H_SEEN 1 + #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { @@ -20,7 +23,10 @@ static void do_time(const char *arg); static void do_var(const char *arg); static void do_etime(const char *arg); -struct { +/* This is only used in upslog.c, but refers to routines declared here... + * To move or not to move?.. + */ +static struct { const char *name; void (*func)(const char *arg); } logcmds[] = @@ -31,7 +37,7 @@ struct { { "TIME", do_time }, { "VAR", do_var }, { "ETIME", do_etime }, - { NULL, (void(*)())(NULL) } + { NULL, (void(*)(const char*))(NULL) } }; #ifdef __cplusplus @@ -40,3 +46,4 @@ struct { /* *INDENT-ON* */ #endif +#endif /* NUT_UPSLOG_H_SEEN */ diff --git a/clients/upsmon.c b/clients/upsmon.c index 12823fa..4b65fc1 100644 --- a/clients/upsmon.c +++ b/clients/upsmon.c @@ -24,7 +24,10 @@ #include #include #include +#include +#include +#include "nut_stdint.h" #include "upsclient.h" #include "upsmon.h" #include "parseconf.h" @@ -37,16 +40,19 @@ static char *shutdowncmd = NULL, *notifycmd = NULL; static char *powerdownflag = NULL, *configfile = NULL; -static int minsupplies = 1, sleepval = 5, deadtime = 15; - - /* default polling interval = 5 sec */ -static int pollfreq = 5, pollfreqalert = 5; - - /* slave hosts are given 15 sec by default to logout from upsd */ -static int hostsync = 15; +static unsigned int minsupplies = 1, sleepval = 5; /* sum of all power values from config file */ -static int totalpv = 0; +static unsigned int totalpv = 0; + + /* default TTL of a device gone AWOL, 3 x polling interval = 15 sec */ +static int deadtime = 15; + + /* default polling interval = 5 sec */ +static unsigned int pollfreq = 5, pollfreqalert = 5; + + /* secondary hosts are given 15 sec by default to logout from upsd */ +static int hostsync = 15; /* default replace battery warning interval (seconds) */ static int rbwarntime = 43200; @@ -55,7 +61,7 @@ static int rbwarntime = 43200; static int nocommwarntime = 300; /* default interval between the shutdown warning and the shutdown */ -static int finaldelay = 5; +static unsigned int finaldelay = 5; /* set by SIGHUP handler, cleared after reload finishes */ static int reload_flag = 0; @@ -83,12 +89,20 @@ static int opt_af = AF_UNSPEC; static struct sigaction sa; static sigset_t nut_upsmon_sigmask; +/* Users can pass a -D[...] option to enable debugging. + * For the service tracing purposes, also the upsmon.conf + * can define a debug_min value in the global section, + * to set the minimal debug level (CLI provided value less + * than that would not have effect, can only have more). + */ +static int nut_debug_level_global = -1; + static void setflag(int *val, int flag) { *val |= flag; } -static void clearflag(int *val, int flag) +static void clearflag(int *val, int flag) { *val ^= (*val & flag); } @@ -111,9 +125,9 @@ static void wall(const char *text) fprintf(wf, "%s\n", text); pclose(wf); -} +} -static void notify(const char *notice, int flags, const char *ntype, +static void notify(const char *notice, int flags, const char *ntype, const char *upsname) { char exec[LARGEBUF]; @@ -171,11 +185,24 @@ static void do_notify(const utype_t *ups, int ntype) for (i = 0; notifylist[i].name != NULL; i++) { if (notifylist[i].type == ntype) { - upsdebugx(2, "%s: ntype 0x%04x (%s)", __func__, ntype, + upsdebugx(2, "%s: ntype 0x%04x (%s)", __func__, ntype, notifylist[i].name); - snprintf(msg, sizeof(msg), notifylist[i].msg ? notifylist[i].msg : notifylist[i].stockmsg, +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + snprintf(msg, sizeof(msg), + notifylist[i].msg ? notifylist[i].msg : notifylist[i].stockmsg, ups ? ups->sys : ""); - notify(msg, notifylist[i].flags, notifylist[i].name, +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif + notify(msg, notifylist[i].flags, notifylist[i].name, upsname); return; } @@ -184,26 +211,40 @@ static void do_notify(const utype_t *ups, int ntype) /* not found ?! */ } -/* check for master permissions on the server for this ups */ -static int checkmaster(utype_t *ups) +/* check if we need "primary" mode (managerial permissions) + * on the server for this ups, and apply for them then. + * Returns 0 in case of error, 1 otherwise (including when + * we do not need to try becoming a primary). This currently + * propagates further as the return value of do_upsd_auth(). + */ +/* TODO: Includes API change in NUT 2.8.0 to replace deprecated + * keywords "MASTER" with "PRIMARY", and "SLAVE" with "SECONDARY", + * (and backwards-compatible alias handling) + */ +static int apply_for_primary(utype_t *ups) { char buf[SMALLBUF]; + char upscli_readraw_error; - /* don't bother if we're not configured as a master for this ups */ - if (!flag_isset(ups->status, ST_MASTER)) + /* don't bother if we're not configured as a primary for this ups */ + if (!flag_isset(ups->status, ST_PRIMARY)) return 1; /* this shouldn't happen (LOGIN checks it earlier) */ if ((ups->upsname == NULL) || (strlen(ups->upsname) == 0)) { - upslogx(LOG_ERR, "Set master on UPS [%s] failed: empty upsname", + upslogx(LOG_ERR, "Set primary managerial mode on UPS [%s] failed: empty upsname", ups->sys); return 0; } - snprintf(buf, sizeof(buf), "MASTER %s\n", ups->upsname); + /* Use PRIMARY first but if talking to older server, retry with MASTER */ + snprintf(buf, sizeof(buf), "PRIMARY %s\n", ups->upsname); if (upscli_sendline(&ups->conn, buf, strlen(buf)) < 0) { - upslogx(LOG_ALERT, "Can't set master mode on UPS [%s] - %s", + /* File descriptor not suitable, net_write() errors, etc. + * Not connected to issues with PRIMARY vs. MASTER keyword. + */ + upslogx(LOG_ALERT, "Can't set primary managerial mode on UPS [%s] - %s", ups->sys, upscli_strerror(&ups->conn)); return 0; } @@ -212,14 +253,41 @@ static int checkmaster(utype_t *ups) if (!strncmp(buf, "OK", 2)) return 1; - /* not ERR, but not caught by readline either? */ + /* Try the older keyword */ + upsdebugx(3, + "%s: Server did not grant PRIMARY mode on UPS [%s], " + "retry with older MASTER keyword", + __func__, ups->upsname); + snprintf(buf, sizeof(buf), "MASTER %s\n", ups->upsname); - upslogx(LOG_ALERT, "Master privileges unavailable on UPS [%s]", + if (upscli_sendline(&ups->conn, buf, strlen(buf)) < 0) { + upslogx(LOG_ALERT, "Can't set primary managerial mode on UPS [%s] - %s", + ups->sys, upscli_strerror(&ups->conn)); + return 0; + } + + if (upscli_readline(&ups->conn, buf, sizeof(buf)) == 0) { + if (!strncmp(buf, "OK", 2)) + return 1; + + upscli_readraw_error = 0; + } + else { + upscli_readraw_error = 1; + } + } + else { + upscli_readraw_error = 1; + } + + if (upscli_readraw_error == 0) { + /* not ERR, but not caught by readline either? */ + upslogx(LOG_ALERT, "Primary managerial privileges unavailable on UPS [%s]", ups->sys); upslogx(LOG_ALERT, "Response: [%s]", buf); } else { /* something caught by readraw's parsing call */ - upslogx(LOG_ALERT, "Master privileges unavailable on UPS [%s]", + upslogx(LOG_ALERT, "Primary managerial privileges unavailable on UPS [%s]", ups->sys); upslogx(LOG_ALERT, "Reason: %s", upscli_strerror(&ups->conn)); } @@ -305,8 +373,8 @@ static int do_upsd_auth(utype_t *ups) upsdebugx(1, "Logged into UPS %s", ups->sys); setflag(&ups->status, ST_LOGIN); - /* now see if we also need to test master permissions */ - return checkmaster(ups); + /* now see if we also need to test primary managerial-mode permissions */ + return apply_for_primary(ups); } /* set flags and make announcements when a UPS has been checked successfully */ @@ -365,7 +433,7 @@ static void ups_on_batt(utype_t *ups) sleepval = pollfreqalert; /* bump up polling frequency */ - ups->linestate = 0; + ups->linestate = 0; upsdebugx(3, "%s: %s (first time)", __func__, ups->sys); @@ -417,9 +485,10 @@ static void set_pdflag(void) /* the actual shutdown procedure */ static void doshutdown(void) -{ - int ret; + __attribute__((noreturn)); +static void doshutdown(void) +{ /* this should probably go away at some point */ upslogx(LOG_CRIT, "Executing automatic power-fail shutdown"); wall("Executing automatic power-fail shutdown\n"); @@ -431,20 +500,25 @@ static void doshutdown(void) /* in the pipe model, we let the parent do this for us */ if (use_pipe) { char ch; + ssize_t wret; ch = 1; - ret = write(pipefd[1], &ch, 1); + wret = write(pipefd[1], &ch, 1); + + if (wret < 1) + upslogx(LOG_ERR, "Unable to call parent pipe for shutdown"); } else { /* one process model = we do all the work here */ + int sret; if (geteuid() != 0) upslogx(LOG_WARNING, "Not root, shutdown may fail"); set_pdflag(); - ret = system(shutdowncmd); + sret = system(shutdowncmd); - if (ret != 0) + if (sret != 0) upslogx(LOG_ERR, "Unable to call shutdown command: %s", shutdowncmd); } @@ -456,7 +530,7 @@ static void doshutdown(void) static void setfsd(utype_t *ups) { char buf[SMALLBUF]; - int ret; + ssize_t ret; /* this shouldn't happen */ if (!ups->upsname) { @@ -499,14 +573,21 @@ static void set_alarm(void) static void clear_alarm(void) { +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wstrict-prototypes" +#endif signal(SIGALRM, SIG_IGN); +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES) +# pragma GCC diagnostic pop +#endif alarm(0); } static int get_var(utype_t *ups, const char *var, char *buf, size_t bufsize) { int ret; - unsigned int numq, numa; + size_t numq, numa; const char *query[4]; char **answer; @@ -557,7 +638,7 @@ static int get_var(utype_t *ups, const char *var, char *buf, size_t bufsize) if (numa < numq) { upslogx(LOG_ERR, "%s: Error: insufficient data " - "(got %d args, need at least %d)", + "(got %zu args, need at least %zu)", var, numa, numq); return -1; } @@ -566,12 +647,16 @@ static int get_var(utype_t *ups, const char *var, char *buf, size_t bufsize) return 0; } -static void slavesync(void) +/* Called by upsmon which is the primary on some UPS(es) to wait + * until all secondaries log out from it on the shared upsd server + * or the HOSTSYNC timeout expires + */ +static void sync_secondaries(void) { utype_t *ups; char temp[SMALLBUF]; time_t start, now; - int maxlogins, logins; + long maxlogins, logins; time(&start); @@ -580,8 +665,8 @@ static void slavesync(void) for (ups = firstups; ups != NULL; ups = ups->next) { - /* only check login count on our master(s) */ - if (!flag_isset(ups->status, ST_MASTER)) + /* only check login count on devices we are the primary for */ + if (!flag_isset(ups->status, ST_PRIMARY)) continue; set_alarm(); @@ -596,11 +681,15 @@ static void slavesync(void) clear_alarm(); } - /* if no UPS has more than 1 login (us), then slaves are gone */ + /* if no UPS has more than 1 login (that would be us), + * then secondaries are all gone */ + /* TO THINK: how about redundant setups with several primary-mode + * clients managing an UPS, or possibly differend UPSes, with the + * same upsd? */ if (maxlogins <= 1) return; - /* after HOSTSYNC seconds, assume slaves are stuck and bail */ + /* after HOSTSYNC seconds, assume secondaries are stuck - and bail */ time(&now); if ((now - start) > hostsync) { @@ -612,31 +701,34 @@ static void slavesync(void) } } +static void forceshutdown(void) + __attribute__((noreturn)); + static void forceshutdown(void) { utype_t *ups; - int isamaster = 0; + int isaprimary = 0; - upsdebugx(1, "Shutting down any UPSes in MASTER mode..."); + upsdebugx(1, "Shutting down any UPSes in PRIMARY mode..."); - /* set FSD on any "master" UPS entries (forced shutdown in progress) */ + /* set FSD on any "primary" UPS entries (forced shutdown in progress) */ for (ups = firstups; ups != NULL; ups = ups->next) - if (flag_isset(ups->status, ST_MASTER)) { - isamaster = 1; + if (flag_isset(ups->status, ST_PRIMARY)) { + isaprimary = 1; setfsd(ups); } - /* if we're not a master on anything, we should shut down now */ - if (!isamaster) + /* if we're not a primary on anything, we should shut down now */ + if (!isaprimary) doshutdown(); - /* must be the master now */ - upsdebugx(1, "This system is a master... waiting for slave logout..."); + /* we must be the primary now */ + upsdebugx(1, "This system is a primary... waiting for secondaries to logout..."); - /* wait up to HOSTSYNC seconds for slaves to logout */ - slavesync(); + /* wait up to HOSTSYNC seconds for secondaries to logout */ + sync_secondaries(); - /* time expired or all the slaves are gone, so shutdown */ + /* time expired or all the secondaries are gone, so shutdown */ doshutdown(); } @@ -644,7 +736,10 @@ static int is_ups_critical(utype_t *ups) { time_t now; - /* FSD = the master is forcing a shutdown */ + /* FSD = the primary is forcing a shutdown, or a driver forwarded the flag + * from a smarter UPS depending on vendor protocol, ability and settings + * (e.g. is charging but battery too low to guarantee safety to the load) + */ if (flag_isset(ups->status, ST_FSD)) return 1; @@ -655,24 +750,37 @@ static int is_ups_critical(utype_t *ups) /* must be OB+LB now */ - /* if we're a master, declare it critical so we set FSD on it */ - if (flag_isset(ups->status, ST_MASTER)) + /* if UPS is calibrating, don't declare it critical */ + /* FIXME: Consider UPSes where we can know if they have other power + * circuits (bypass, etc.) and whether those do currently provide + * wall power to the host - and that we do not have both calibration + * and a real outage, when we still should shut down right now. + */ + if (flag_isset(ups->status, ST_CAL)) { + upslogx(LOG_WARNING, "%s: seems that UPS [%s] is OB+LB now, but " + "it is also calibrating - not declaring a critical state", + __func__, ups->upsname); + return 0; + } + + /* if we're a primary, declare it critical so we set FSD on it */ + if (flag_isset(ups->status, ST_PRIMARY)) return 1; - /* must be a slave now */ + /* must be a secondary now */ - /* FSD isn't set, so the master hasn't seen it yet */ + /* FSD isn't set, so the primary hasn't seen it yet */ time(&now); - /* give the master up to HOSTSYNC seconds before shutting down */ + /* give the primary up to HOSTSYNC seconds before shutting down */ if ((now - ups->lastnoncrit) > hostsync) { - upslogx(LOG_WARNING, "Giving up on the master for UPS [%s]", + upslogx(LOG_WARNING, "Giving up on the primary for UPS [%s]", ups->sys); return 1; } - /* there's still time left */ + /* there's still time left, maybe OB+LB will go away next time we look? */ return 0; } @@ -680,7 +788,7 @@ static int is_ups_critical(utype_t *ups) static void recalc(void) { utype_t *ups; - int val_ol = 0; + unsigned int val_ol = 0; time_t now; time(&now); @@ -707,8 +815,8 @@ static void recalc(void) ups = ups->next; } - upsdebugx(3, "Current power value: %d", val_ol); - upsdebugx(3, "Minimum power value: %d", minsupplies); + upsdebugx(3, "Current power value: %u", val_ol); + upsdebugx(3, "Minimum power value: %u", minsupplies); if (val_ol < minsupplies) forceshutdown(); @@ -741,6 +849,21 @@ static void upsreplbatt(utype_t *ups) } } +static void ups_cal(utype_t *ups) +{ + if (flag_isset(ups->status, ST_CAL)) { /* no change */ + upsdebugx(4, "%s: %s (no change)", __func__, ups->sys); + return; + } + + upsdebugx(3, "%s: %s (first time)", __func__, ups->sys); + + /* must have changed from !CAL to CAL, so notify */ + + do_notify(ups, NOTIFY_CAL); + setflag(&ups->status, ST_CAL); +} + static void ups_fsd(utype_t *ups) { if (flag_isset(ups->status, ST_FSD)) { /* no change */ @@ -770,13 +893,13 @@ static void drop_connection(utype_t *ups) } /* change some UPS parameters during reloading */ -static void redefine_ups(utype_t *ups, int pv, const char *un, - const char *pw, const char *master) +static void redefine_ups(utype_t *ups, unsigned int pv, const char *un, + const char *pw, const char *managerialOption) { ups->retain = 1; if (ups->pv != pv) { - upslogx(LOG_INFO, "UPS [%s]: redefined power value to %d", + upslogx(LOG_INFO, "UPS [%s]: redefined power value to %d", ups->sys, pv); ups->pv = pv; } @@ -792,14 +915,14 @@ static void redefine_ups(utype_t *ups, int pv, const char *un, ups->un = xstrdup(un); - /* + /* * if not logged in force a reconnection since this * may have been redefined to make a login work */ if (!flag_isset(ups->status, ST_LOGIN)) { upslogx(LOG_INFO, "UPS [%s]: retrying connection", - ups->sys); + ups->sys); drop_connection(ups); } @@ -820,7 +943,7 @@ static void redefine_ups(utype_t *ups, int pv, const char *un, if (!flag_isset(ups->status, ST_LOGIN)) { upslogx(LOG_INFO, "UPS [%s]: retrying connection", - ups->sys); + ups->sys); drop_connection(ups); } @@ -849,45 +972,75 @@ static void redefine_ups(utype_t *ups, int pv, const char *un, } } - /* slave -> master */ - if ((!strcasecmp(master, "master")) && (!flag_isset(ups->status, ST_MASTER))) { - upslogx(LOG_INFO, "UPS [%s]: redefined as master", ups->sys); - setflag(&ups->status, ST_MASTER); + /* secondary|slave -> primary|master */ + if ( ( (!strcasecmp(managerialOption, "primary")) + || (!strcasecmp(managerialOption, "master")) ) + && (!flag_isset(ups->status, ST_PRIMARY)) ) { + upslogx(LOG_INFO, "UPS [%s]: redefined as a primary", ups->sys); + setflag(&ups->status, ST_PRIMARY); - /* reset connection to ensure master mode gets checked */ + /* reset connection to ensure primary mode gets checked */ drop_connection(ups); return; } - /* master -> slave */ - if ((!strcasecmp(master, "slave")) && (flag_isset(ups->status, ST_MASTER))) { - upslogx(LOG_INFO, "UPS [%s]: redefined as slave", ups->sys); - clearflag(&ups->status, ST_MASTER); + /* primary|master -> secondary|slave */ + if ( ( (!strcasecmp(managerialOption, "secondary")) + || (!strcasecmp(managerialOption, "slave")) ) + && (flag_isset(ups->status, ST_PRIMARY)) ) { + upslogx(LOG_INFO, "UPS [%s]: redefined as a secondary", ups->sys); + clearflag(&ups->status, ST_PRIMARY); return; } } -static void addups(int reloading, const char *sys, const char *pvs, - const char *un, const char *pw, const char *master) +static void addups(int reloading, const char *sys, const char *pvs, + const char *un, const char *pw, const char *managerialOption) { - int pv; + unsigned int pv; utype_t *tmp, *last; /* the username is now required - no more host-based auth */ - if ((!sys) || (!pvs) || (!pw) || (!master) || (!un)) { + if ((!sys) || (!pvs) || (!pw) || (!managerialOption) || (!un)) { upslogx(LOG_WARNING, "Ignoring invalid MONITOR line in %s!", configfile); upslogx(LOG_WARNING, "MONITOR configuration directives require five arguments."); return; } - pv = strtol(pvs, (char **) NULL, 10); + long lpv = strtol(pvs, (char **) NULL, 10); - if (pv < 0) { - upslogx(LOG_WARNING, "UPS [%s]: ignoring invalid power value [%s]", +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) ) +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +# pragma GCC diagnostic ignored "-Wunreachable-code" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE +# pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wunreachable-code" +# pragma clang diagnostic ignored "-Wtautological-compare" +# pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif + /* Different platforms, different sizes, none fits all... */ + if (lpv < 0 || (sizeof(long) > sizeof(unsigned int) && lpv > (long)UINT_MAX)) { +#ifdef __clang__ +# pragma clang diagnostic pop +#endif +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) ) +# pragma GCC diagnostic pop +#endif + upslogx(LOG_WARNING, "UPS [%s]: ignoring invalid power value [%s]", sys, pvs); return; } + pv = (unsigned int)lpv; last = tmp = firstups; @@ -897,7 +1050,7 @@ static void addups(int reloading, const char *sys, const char *pvs, /* check for duplicates */ if (!strcmp(tmp->sys, sys)) { if (reloading) - redefine_ups(tmp, pv, un, pw, master); + redefine_ups(tmp, pv, un, pw, managerialOption); else upslogx(LOG_WARNING, "Warning: ignoring duplicate" " UPS [%s]", sys); @@ -914,10 +1067,7 @@ static void addups(int reloading, const char *sys, const char *pvs, /* build this up so the user doesn't run with bad settings */ totalpv += tmp->pv; - if (un) - tmp->un = xstrdup(un); - else - tmp->un = NULL; + tmp->un = xstrdup(un); tmp->pw = xstrdup(pw); tmp->status = 0; @@ -932,8 +1082,10 @@ static void addups(int reloading, const char *sys, const char *pvs, tmp->lastrbwarn = 0; tmp->lastncwarn = 0; - if (!strcasecmp(master, "master")) - setflag(&tmp->status, ST_MASTER); + if ( (!strcasecmp(managerialOption, "primary")) + || (!strcasecmp(managerialOption, "master")) ) { + setflag(&tmp->status, ST_PRIMARY); + } tmp->next = NULL; @@ -943,15 +1095,15 @@ static void addups(int reloading, const char *sys, const char *pvs, firstups = tmp; if (tmp->pv) - upslogx(LOG_INFO, "UPS: %s (%s) (power value %d)", tmp->sys, - flag_isset(tmp->status, ST_MASTER) ? "master" : "slave", + upslogx(LOG_INFO, "UPS: %s (%s) (power value %d)", tmp->sys, + flag_isset(tmp->status, ST_PRIMARY) ? "primary" : "secondary", tmp->pv); else upslogx(LOG_INFO, "UPS: %s (monitoring only)", tmp->sys); tmp->upsname = tmp->hostname = NULL; - if (upscli_splitname(tmp->sys, &tmp->upsname, &tmp->hostname, + if (upscli_splitname(tmp->sys, &tmp->upsname, &tmp->hostname, &tmp->port) != 0) { upslogx(LOG_ERR, "Error: unable to split UPS name [%s]", tmp->sys); @@ -960,7 +1112,7 @@ static void addups(int reloading, const char *sys, const char *pvs, if (!tmp->upsname) upslogx(LOG_WARNING, "Warning: UPS [%s]: no upsname set!", tmp->sys); -} +} static void set_notifymsg(const char *name, const char *msg) { @@ -1030,7 +1182,7 @@ static void set_notifyflag(const char *ntype, char *flags) } /* in split mode, the parent doesn't hear about reloads */ -static void checkmode(char *cfgentry, char *oldvalue, char *newvalue, +static void checkmode(char *cfgentry, char *oldvalue, char *newvalue, int reloading) { /* nothing to do if in "all as root" mode */ @@ -1054,7 +1206,7 @@ static void checkmode(char *cfgentry, char *oldvalue, char *newvalue, } /* returns 1 if used, 0 if not, so we can complain about bogus configs */ -static int parse_conf_arg(int numargs, char **arg) +static int parse_conf_arg(size_t numargs, char **arg) { /* using up to arg[1] below */ if (numargs < 2) @@ -1081,7 +1233,7 @@ static int parse_conf_arg(int numargs, char **arg) arg[1]); return 1; - } + } /* NOTIFYCMD */ if (!strcmp(arg[0], "NOTIFYCMD")) { @@ -1092,13 +1244,23 @@ static int parse_conf_arg(int numargs, char **arg) /* POLLFREQ */ if (!strcmp(arg[0], "POLLFREQ")) { - pollfreq = atoi(arg[1]); + int ipollfreq = atoi(arg[1]); + if (ipollfreq < 0) { + upsdebugx(0, "Ignoring invalid POLLFREQ value: %d", ipollfreq); + } else { + pollfreq = (unsigned int)ipollfreq; + } return 1; } /* POLLFREQALERT */ if (!strcmp(arg[0], "POLLFREQALERT")) { - pollfreqalert = atoi(arg[1]); + int ipollfreqalert = atoi(arg[1]); + if (ipollfreqalert < 0) { + upsdebugx(0, "Ignoring invalid POLLFREQALERT value: %d", ipollfreqalert); + } else { + pollfreqalert = (unsigned int)ipollfreqalert; + } return 1; } @@ -1116,7 +1278,12 @@ static int parse_conf_arg(int numargs, char **arg) /* MINSUPPLIES */ if (!strcmp(arg[0], "MINSUPPLIES")) { - minsupplies = atoi(arg[1]); + int iminsupplies = atoi(arg[1]); + if (iminsupplies < 0) { + upsdebugx(0, "Ignoring invalid MINSUPPLIES value: %d", iminsupplies); + } else { + minsupplies = (unsigned int)iminsupplies; + } return 1; } @@ -1134,12 +1301,17 @@ static int parse_conf_arg(int numargs, char **arg) /* FINALDELAY */ if (!strcmp(arg[0], "FINALDELAY")) { - finaldelay = atoi(arg[1]); + int ifinaldelay = atoi(arg[1]); + if (ifinaldelay < 0) { + upsdebugx(0, "Ignoring invalid FINALDELAY value: %d", ifinaldelay); + } else { + finaldelay = (unsigned int)ifinaldelay; + } return 1; } /* RUN_AS_USER */ - if (!strcmp(arg[0], "RUN_AS_USER")) { + if (!strcmp(arg[0], "RUN_AS_USER")) { free(run_as_user); run_as_user = xstrdup(arg[1]); return 1; @@ -1164,6 +1336,18 @@ static int parse_conf_arg(int numargs, char **arg) return 1; } + /* DEBUG_MIN (NUM) */ + /* debug_min (NUM) also acceptable, to be on par with ups.conf */ + if (!strcasecmp(arg[0], "DEBUG_MIN")) { + int lvl = -1; // typeof common/common.c: int nut_debug_level + if ( str_to_int (arg[1], &lvl, 10) && lvl >= 0 ) { + nut_debug_level_global = lvl; + } else { + upslogx(LOG_INFO, "WARNING : Invalid DEBUG_MIN value found in upsmon.conf global settings"); + } + return 1; + } + /* using up to arg[2] below */ if (numargs < 3) return 0; @@ -1178,7 +1362,7 @@ static int parse_conf_arg(int numargs, char **arg) if (!strcmp(arg[0], "NOTIFYFLAG")) { set_notifyflag(arg[1], arg[2]); return 1; - } + } /* CERTIDENT */ if (!strcmp(arg[0], "CERTIDENT")) { @@ -1188,7 +1372,7 @@ static int parse_conf_arg(int numargs, char **arg) certpasswd = xstrdup(arg[2]); return 1; } - + /* using up to arg[4] below */ if (numargs < 5) return 0; @@ -1209,7 +1393,7 @@ static int parse_conf_arg(int numargs, char **arg) fatalx(EXIT_FAILURE, "Fatal error: unusable configuration"); } - /* ("master" | "slave") */ + /* ("primary"|"master" | "secondary"|"slave") */ addups(reload_flag, arg[1], arg[2], arg[3], arg[4], arg[5]); return 1; } @@ -1241,6 +1425,13 @@ static void loadconfig(void) fatalx(EXIT_FAILURE, "%s", ctx.errmsg); } + if (reload_flag == 1) { + /* if upsmon.conf added or changed + * (or commented away) the debug_min + * setting, detect that */ + nut_debug_level_global = -1; + } + while (pconf_file_next(&ctx)) { if (pconf_parse_error(&ctx)) { upslogx(LOG_ERR, "Parse error: %s:%d: %s", @@ -1255,25 +1446,34 @@ static void loadconfig(void) unsigned int i; char errmsg[SMALLBUF]; - snprintf(errmsg, sizeof(errmsg), + snprintf(errmsg, sizeof(errmsg), "%s line %d: invalid directive", configfile, ctx.linenum); for (i = 0; i < ctx.numargs; i++) - snprintfcat(errmsg, sizeof(errmsg), " %s", + snprintfcat(errmsg, sizeof(errmsg), " %s", ctx.arglist[i]); upslogx(LOG_WARNING, "%s", errmsg); } } - pconf_finish(&ctx); + if (reload_flag == 1) { + if (nut_debug_level_global > -1) { + upslogx(LOG_INFO, + "Applying debug_min=%d from upsmon.conf", + nut_debug_level_global); + nut_debug_level = nut_debug_level_global; + } + } + + pconf_finish(&ctx); } /* SIGPIPE handler */ static void sigpipe(int sig) { - upsdebugx(1, "SIGPIPE: dazed and confused, but continuing..."); + upsdebugx(1, "SIGPIPE: dazed and confused, but continuing after signal %i...", sig); } /* SIGQUIT, SIGTERM handler */ @@ -1329,12 +1529,16 @@ static void user_fsd(int sig) static void set_reload_flag(int sig) { + NUT_UNUSED_VARIABLE(sig); + reload_flag = 1; } /* handler for alarm when getupsvarfd times out */ static void read_timeout(int sig) { + NUT_UNUSED_VARIABLE(sig); + /* don't do anything here, just return */ } @@ -1370,9 +1574,10 @@ static void setup_signals(void) /* remember the last time the ups was not critical (OB + LB) */ static void update_crittimer(utype_t *ups) { - /* if !OB or !LB, then it's not critical, so log the time */ - if ((!flag_isset(ups->status, ST_ONBATT)) || - (!flag_isset(ups->status, ST_LOWBATT))) { + /* if !OB, !LB, or CAL, then it's not critical, so log the time */ + if ((!flag_isset(ups->status, ST_ONBATT)) || + (!flag_isset(ups->status, ST_LOWBATT)) || + (flag_isset(ups->status, ST_CAL))) { time(&ups->lastnoncrit); return; @@ -1391,7 +1596,7 @@ static int try_connect(utype_t *ups) clearflag(&ups->status, ST_CONNECTED); /* force it if configured that way, just try it otherwise */ - if (forcessl == 1) + if (forcessl == 1) flags |= UPSCLI_CONN_REQSSL; else flags |= UPSCLI_CONN_TRYSSL; @@ -1432,6 +1637,9 @@ static int try_connect(utype_t *ups) /* we're definitely connected now */ setflag(&ups->status, ST_CONNECTED); + /* prevent connection leaking to NOTIFYCMD */ + fcntl(upscli_fd(&ups->conn), F_SETFD, FD_CLOEXEC); + /* now try to authenticate to upsd */ ret = do_upsd_auth(ups); @@ -1456,7 +1664,7 @@ static void parse_status(utype_t *ups, char *status) upsdebugx(2, "%s: [%s]", __func__, status); /* empty response is the same as a dead ups */ - if (!strcmp(status, "")) { + if (status == NULL || status[0] == '\0') { ups_is_gone(ups); return; } @@ -1487,6 +1695,8 @@ static void parse_status(utype_t *ups, char *status) ups_low_batt(ups); if (!strcasecmp(statword, "RB")) upsreplbatt(ups); + if (!strcasecmp(statword, "CAL")) + ups_cal(ups); /* do it last to override any possible OL */ if (!strcasecmp(statword, "FSD")) @@ -1495,7 +1705,7 @@ static void parse_status(utype_t *ups, char *status) update_crittimer(ups); statword = ptr; - } + } } /* see what the status of the UPS is and handle any changes */ @@ -1530,12 +1740,12 @@ static void pollups(utype_t *ups) case UPSCLI_ERR_UNKNOWNUPS: upslogx(LOG_ERR, "Poll UPS [%s] failed - [%s] " - "does not exist on server %s", + "does not exist on server %s", ups->sys, ups->upsname, ups->hostname); break; default: - upslogx(LOG_ERR, "Poll UPS [%s] failed - %s", + upslogx(LOG_ERR, "Poll UPS [%s] failed - %s", ups->sys, upscli_strerror(&ups->conn)); break; } @@ -1572,7 +1782,7 @@ static int pdflag_status(void) fclose(pdf); /* reasoning: say upsmon.conf is world-writable (!) and some nasty - * user puts something "important" as the power flag file. This + * user puts something "important" as the power flag file. This * keeps upsmon from utterly trashing it when starting up or powering * down at the expense of not shutting down the UPS. * @@ -1583,7 +1793,7 @@ static int pdflag_status(void) return 1; /* exists and looks good */ return -1; /* error: something else is in there */ -} +} /* only remove the flag file if it's actually from us */ static void clear_pdflag(void) @@ -1634,17 +1844,23 @@ static int check_pdflag(void) return EXIT_SUCCESS; } -static void help(const char *progname) +static void help(const char *arg_progname) + __attribute__((noreturn)); + +static void help(const char *arg_progname) { printf("Monitors UPS servers and may initiate shutdown if necessary.\n\n"); - printf("usage: %s [OPTIONS]\n\n", progname); - printf(" -c send command to running process\n"); + printf("usage: %s [OPTIONS]\n\n", arg_progname); + printf(" -c send command to running process\n"); printf(" commands:\n"); - printf(" - fsd: shutdown all master UPSes (use with caution)\n"); + printf(" - fsd: shutdown all primary-mode UPSes (use with caution)\n"); printf(" - reload: reread configuration\n"); printf(" - stop: stop monitoring and exit\n"); - printf(" -D raise debugging level\n"); + printf(" -P send the signal above to specified PID (bypassing PID file)\n"); + printf(" -D raise debugging level (and stay foreground by default)\n"); + printf(" -F stay foregrounded even if no debugging is enabled\n"); + printf(" -B stay backgrounded even if debugging is bumped\n"); printf(" -h display this help\n"); printf(" -K checks POWERDOWNFLAG, sets exit code to 0 if set\n"); printf(" -p always run privileged (disable privileged parent)\n"); @@ -1655,15 +1871,26 @@ static void help(const char *progname) exit(EXIT_SUCCESS); } +static void runparent(int fd) + __attribute__((noreturn)); + static void runparent(int fd) { - int ret; + ssize_t ret; + int sret; char ch; /* handling signals is the child's job */ +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wstrict-prototypes" +#endif signal(SIGHUP, SIG_IGN); signal(SIGUSR1, SIG_IGN); signal(SIGUSR2, SIG_IGN); +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES) +# pragma GCC diagnostic pop +#endif ret = read(fd, &ch, 1); @@ -1680,9 +1907,9 @@ static void runparent(int fd) /* have to do this here - child is unprivileged */ set_pdflag(); - ret = system(shutdowncmd); + sret = system(shutdowncmd); - if (ret != 0) + if (sret != 0) upslogx(LOG_ERR, "parent: Unable to call shutdown command: %s", shutdowncmd); @@ -1710,10 +1937,15 @@ static void start_pipe(void) close(pipefd[1]); runparent(pipefd[0]); +#ifndef HAVE___ATTRIBUTE__NORETURN exit(EXIT_FAILURE); /* NOTREACHED */ +#endif } close(pipefd[0]); + + /* prevent pipe leaking to NOTIFYCMD */ + fcntl(pipefd[1], F_SETFD, FD_CLOEXEC); } static void delete_ups(utype_t *target) @@ -1752,7 +1984,7 @@ static void delete_ups(utype_t *target) /* shouldn't happen */ upslogx(LOG_ERR, "delete_ups: UPS not found"); -} +} /* see if we can open a file */ static int check_file(const char *fn) @@ -1814,7 +2046,7 @@ static void reload_conf(void) upslogx(LOG_CRIT, "Fatal error: total power value (%d) less " "than MINSUPPLIES (%d)", totalpv, minsupplies); - fatalx(EXIT_FAILURE, "Impossible power configuation, unable to continue"); + fatalx(EXIT_FAILURE, "Impossible power configuration, unable to continue"); } /* finally clear the flag */ @@ -1846,7 +2078,7 @@ static void check_parent(void) time(&now); /* complain every 2 minutes */ - if ((now - lastwarn) < 120) + if ((now - lastwarn) < 120) return; lastwarn = now; @@ -1856,10 +2088,11 @@ static void check_parent(void) upslogx(LOG_ALERT, "Parent died - shutdown impossible"); } -int main(int argc, char *argv[]) +int main(int argc, char *argv[]) { const char *prog = xbasename(argv[0]); - int i, cmd = 0, checking_flag = 0; + int i, cmd = 0, cmdret = -1, checking_flag = 0, foreground = -1; + pid_t oldpid = -1; printf("Network UPS Tools %s %s\n", prog, UPS_VERSION); @@ -1870,7 +2103,7 @@ int main(int argc, char *argv[]) run_as_user = xstrdup(RUN_AS_USER); - while ((i = getopt(argc, argv, "+Dhic:f:pu:VK46")) != -1) { + while ((i = getopt(argc, argv, "+DFBhic:P:f:pu:VK46")) != -1) { switch (i) { case 'c': if (!strncmp(optarg, "fsd", strlen(optarg))) @@ -1884,16 +2117,30 @@ int main(int argc, char *argv[]) if (cmd == 0) help(argv[0]); break; + + case 'P': + if ((oldpid = parsepid(optarg)) < 0) + help(argv[0]); + break; + case 'D': nut_debug_level++; break; + case 'F': + foreground = 1; + break; + case 'B': + foreground = 0; + break; case 'f': free(configfile); configfile = xstrdup(optarg); break; case 'h': help(argv[0]); +#ifndef HAVE___ATTRIBUTE__NORETURN break; +#endif case 'K': checking_flag = 1; break; @@ -1915,22 +2162,56 @@ int main(int argc, char *argv[]) break; default: help(argv[0]); +#ifndef HAVE___ATTRIBUTE__NORETURN break; +#endif + } + } + + if (foreground < 0) { + if (nut_debug_level > 0) { + foreground = 1; + } else { + foreground = 0; } } if (cmd) { - sendsignal(prog, cmd); - exit(EXIT_SUCCESS); + if (oldpid < 0) { + cmdret = sendsignal(prog, cmd); + } else { + cmdret = sendsignalpid(oldpid, cmd); + } + /* exit(EXIT_SUCCESS); */ + exit((cmdret == 0)?EXIT_SUCCESS:EXIT_FAILURE); } /* otherwise, we are being asked to start. * so check if a previous instance is running by sending signal '0' * (Ie 'kill 0') */ - if (sendsignal(prog, 0) == 0) { + if (oldpid < 0) { + cmdret = sendsignal(prog, 0); + } else { + cmdret = sendsignalpid(oldpid, 0); + } + switch (cmdret) { + case 0: printf("Fatal error: A previous upsmon instance is already running!\n"); printf("Either stop the previous instance first, or use the 'reload' command.\n"); exit(EXIT_FAILURE); + + case -3: + case -2: + upslogx(LOG_WARNING, "Could not %s PID file " + "to see if previous upsmon instance is " + "already running!\n", + (cmdret == -3 ? "find" : "parse")); + break; + + case -1: + default: + /* Just failed to send signal, no competitor running */ + break; } argc -= optind; @@ -1940,6 +2221,14 @@ int main(int argc, char *argv[]) loadconfig(); + /* CLI debug level can not be smaller than debug_min specified + * in upsmon.conf. Note that non-zero debug_min does not impact + * foreground running mode. + */ + if (nut_debug_level_global > nut_debug_level) + nut_debug_level = nut_debug_level_global; + upsdebugx(1, "debug level is '%d'", nut_debug_level); + if (checking_flag) exit(check_pdflag()); @@ -1962,12 +2251,14 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - if (nut_debug_level < 1) { + if (!foreground) { background(); - } else { + } + + if (nut_debug_level >= 1) { upsdebugx(1, "debug level is '%d'", nut_debug_level); } - + /* only do the pipe stuff if the user hasn't disabled it */ if (use_pipe) { struct passwd *new_uid = get_user_pwent(run_as_user); @@ -1981,14 +2272,14 @@ int main(int argc, char *argv[]) become_user(new_uid); } else { upslogx(LOG_INFO, "Warning: running as one big root process by request (upsmon -p)"); - + writepid(prog); } - + if (upscli_init(certverify, certpath, certname, certpasswd) < 0) { exit(EXIT_FAILURE); } - + /* prep our signal handlers */ setup_signals(); diff --git a/clients/upsmon.h b/clients/upsmon.h index 2504370..d60720b 100644 --- a/clients/upsmon.h +++ b/clients/upsmon.h @@ -17,18 +17,23 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef NUT_UPSMON_H_SEEN +#define NUT_UPSMON_H_SEEN 1 + /* flags for ups->status */ -#define ST_ONLINE (1 << 0) /* UPS is on line (OL) */ -#define ST_ONBATT (1 << 1) /* UPS is on battery (OB) */ -#define ST_LOWBATT (1 << 2) /* UPS has a low battery (LB) */ -#define ST_FSD (1 << 3) /* master has set forced shutdown flag */ -#define ST_MASTER (1 << 4) /* we are the master on this UPS */ -#define ST_LOGIN (1 << 5) /* we are logged into this UPS */ -#define ST_CONNECTED (1 << 6) /* upscli_connect returned OK */ +#define ST_ONLINE (1 << 0) /* UPS is on line (OL) */ +#define ST_ONBATT (1 << 1) /* UPS is on battery (OB) */ +#define ST_LOWBATT (1 << 2) /* UPS has a low battery (LB) */ +#define ST_FSD (1 << 3) /* primary has set forced shutdown flag */ +#define ST_PRIMARY (1 << 4) /* we are the primary (manager) of this UPS */ +#define ST_MASTER ST_PRIMARY /* legacy alias */ +#define ST_LOGIN (1 << 5) /* we are logged into this UPS */ +#define ST_CONNECTED (1 << 6) /* upscli_connect returned OK */ +#define ST_CAL (1 << 7) /* UPS calibration in progress (CAL) */ /* required contents of flag file */ -#define SDMAGIC "upsmon-shutdown-file" +#define SDMAGIC "upsmon-shutdown-file" #ifdef __cplusplus /* *INDENT-OFF* */ @@ -44,9 +49,9 @@ typedef struct { char *sys; /* raw system name from .conf */ char *upsname; /* just upsname */ char *hostname; /* just hostname */ - int port; /* just the port */ + uint16_t port; /* just the port */ - int pv; /* power value from conf */ + unsigned int pv; /* power value from conf */ char *un; /* username (optional for now) */ char *pw; /* password from conf */ int status; /* status (see flags above) */ @@ -65,16 +70,17 @@ typedef struct { /* notify identifiers */ -#define NOTIFY_ONLINE 0 /* UPS went on-line */ -#define NOTIFY_ONBATT 1 /* UPS went on battery */ -#define NOTIFY_LOWBATT 2 /* UPS went to low battery */ -#define NOTIFY_FSD 3 /* Master upsmon set FSD flag */ -#define NOTIFY_COMMOK 4 /* Communication established */ -#define NOTIFY_COMMBAD 5 /* Communication lost */ -#define NOTIFY_SHUTDOWN 6 /* System shutdown in progress */ -#define NOTIFY_REPLBATT 7 /* UPS battery needs to be replaced */ -#define NOTIFY_NOCOMM 8 /* UPS hasn't been contacted in awhile */ -#define NOTIFY_NOPARENT 9 /* privileged parent process died */ +#define NOTIFY_ONLINE 0 /* UPS went on-line */ +#define NOTIFY_ONBATT 1 /* UPS went on battery */ +#define NOTIFY_LOWBATT 2 /* UPS went to low battery */ +#define NOTIFY_FSD 3 /* Primary upsmon set FSD flag */ +#define NOTIFY_COMMOK 4 /* Communication established */ +#define NOTIFY_COMMBAD 5 /* Communication lost */ +#define NOTIFY_SHUTDOWN 6 /* System shutdown in progress */ +#define NOTIFY_REPLBATT 7 /* UPS battery needs to be replaced */ +#define NOTIFY_NOCOMM 8 /* UPS hasn't been contacted in a while */ +#define NOTIFY_NOPARENT 9 /* privileged parent process died */ +#define NOTIFY_CAL 10 /* UPS is performing calibration */ /* notify flag values */ @@ -86,7 +92,10 @@ typedef struct { /* flags are set to NOTIFY_SYSLOG | NOTIFY_WALL at program init */ /* the user can override with NOTIFYFLAGS in the upsmon.conf */ -struct { +/* This is only used in upsmon.c, but might it also have external consumers?.. + * To move or not to move?.. + */ +static struct { int type; const char *name; char *msg; /* NULL until overridden */ @@ -104,6 +113,7 @@ struct { { NOTIFY_REPLBATT, "REPLBATT", NULL, "UPS %s battery needs to be replaced", NOTIFY_SYSLOG | NOTIFY_WALL }, { NOTIFY_NOCOMM, "NOCOMM", NULL, "UPS %s is unavailable", NOTIFY_SYSLOG | NOTIFY_WALL }, { NOTIFY_NOPARENT, "NOPARENT", NULL, "upsmon parent process died - shutdown impossible", NOTIFY_SYSLOG | NOTIFY_WALL }, + { NOTIFY_CAL, "CAL", NULL, "UPS %s: calibration in progress", NOTIFY_SYSLOG }, { 0, NULL, NULL, NULL, 0 } }; @@ -122,3 +132,5 @@ struct { } /* *INDENT-ON* */ #endif + +#endif /* NUT_UPSMON_H_SEEN */ diff --git a/clients/upsrw.c b/clients/upsrw.c index 3a0efb4..2789f9a 100644 --- a/clients/upsrw.c +++ b/clients/upsrw.c @@ -1,6 +1,8 @@ /* upsrw - simple client for read/write variable access (formerly upsct2) - Copyright (C) 1999 Russell Kroll + Copyright (C) + 1999 Russell Kroll + 2019 EATON (author: Arnaud Quette ) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,10 +27,14 @@ #include #include +#include "nut_stdint.h" #include "upsclient.h" +#include "extstate.h" -static char *upsname = NULL, *hostname = NULL; +static char *upsname = NULL, *hostname = NULL; static UPSCONN_t *ups = NULL; +static int tracking_enabled = 0; +static unsigned int timeout = DEFAULT_TRACKING_TIMEOUT; struct list_t { char *name; @@ -39,18 +45,22 @@ static void usage(const char *prog) { printf("Network UPS Tools %s %s\n\n", prog, UPS_VERSION); printf("usage: %s [-h]\n", prog); - printf(" %s [-s ] [-u ] [-p ] \n\n", prog); + printf(" %s [-s ] [-u ] [-p ] [-w] [-t ] \n\n", prog); printf("Demo program to set variables within UPS hardware.\n"); printf("\n"); printf(" -h display this help text\n"); printf(" -s specify variable to be changed\n"); printf(" use -s VAR=VALUE to avoid prompting for value\n"); + printf(" -l show all possible read/write variables.\n"); printf(" -u set username for command authentication\n"); printf(" -p set password for command authentication\n"); + printf(" -w wait for the completion of setting by the driver\n"); + printf(" and return its actual result from the device\n"); + printf(" -t set a timeout when using -w (in seconds, default: %u)\n", DEFAULT_TRACKING_TIMEOUT); printf("\n"); printf(" UPS identifier - [@[:]]\n"); printf("\n"); - printf("Call without -s to show all possible read/write variables.\n"); + printf("Call without -s to show all possible read/write variables (same as -l).\n"); } static void clean_exit(void) @@ -64,9 +74,21 @@ static void clean_exit(void) free(ups); } +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC) && (!defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_INSIDEFUNC) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC) ) +# pragma GCC diagnostic push +#endif +#if (!defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_INSIDEFUNC) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC) +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif +#if (!defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_INSIDEFUNC) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC) +# pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif static void do_set(const char *varname, const char *newval) { + int cmd_complete = 0; char buf[SMALLBUF], enc[SMALLBUF]; + char tracking_id[UUID4_LEN]; + time_t start, now; snprintf(buf, sizeof(buf), "SET VAR %s %s \"%s\"\n", upsname, varname, pconf_encode(newval, enc, sizeof(enc))); @@ -78,17 +100,92 @@ static void do_set(const char *varname, const char *newval) fatalx(EXIT_FAILURE, "Set variable failed: %s", upscli_strerror(ups)); } - /* FUTURE: status cookies will tie in here */ + /* verify answer */ if (strncmp(buf, "OK", 2) != 0) { fatalx(EXIT_FAILURE, "Unexpected response from upsd: %s", buf); } + /* check for status tracking id */ + if ( + !tracking_enabled || + /* sanity check on the size: "OK TRACKING " + UUID4_LEN */ + strlen(buf) != (UUID4_LEN - 1 + strlen("OK TRACKING ")) + ) { + /* reply as usual */ + fprintf(stderr, "%s\n", buf); + return; + } + +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION +#pragma GCC diagnostic ignored "-Wformat-truncation" +#endif + /* From the check above, we know that we have exactly UUID4_LEN chars + * (aka sizeof(tracking_id)) in the buf after "OK TRACKING " prefix, + * plus the null-byte. + */ + assert (UUID4_LEN == 1 + snprintf(tracking_id, sizeof(tracking_id), "%s", buf + strlen("OK TRACKING "))); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION +#pragma GCC diagnostic pop +#endif + time(&start); + + /* send status tracking request, looping if status is PENDING */ + while (!cmd_complete) { + + /* check for timeout */ + time(&now); + if (difftime(now, start) >= timeout) + fatalx(EXIT_FAILURE, "Can't receive status tracking information: timeout"); + + snprintf(buf, sizeof(buf), "GET TRACKING %s\n", tracking_id); + + if (upscli_sendline(ups, buf, strlen(buf)) < 0) + fatalx(EXIT_FAILURE, "Can't send status tracking request: %s", upscli_strerror(ups)); + +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) ) +/* Note for gating macros above: unsuffixed HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP + * means support of contexts both inside and outside function body, so the push + * above and pop below (outside this finction) are not used. + */ +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS +/* Note that the individual warning pragmas for use inside function bodies + * are named without a _INSIDEFUNC suffix, for simplicity and legacy reasons + */ +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE +# pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif + /* and get status tracking reply */ + assert(timeout < LONG_MAX); +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) ) +# pragma GCC diagnostic pop +#endif + + if (upscli_readline_timeout(ups, buf, sizeof(buf), (long)timeout) < 0) + fatalx(EXIT_FAILURE, "Can't receive status tracking information: %s", upscli_strerror(ups)); + + if (strncmp(buf, "PENDING", 7)) + cmd_complete = 1; + else + /* wait a second before retrying */ + sleep(1); + } + fprintf(stderr, "%s\n", buf); } +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC) && (!defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_INSIDEFUNC) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC) ) +# pragma GCC diagnostic pop +#endif static void do_setvar(const char *varname, char *uin, const char *pass) { - char newval[SMALLBUF], temp[SMALLBUF], user[SMALLBUF], *ptr; + char newval[SMALLBUF], temp[SMALLBUF * 2], user[SMALLBUF], *ptr; struct passwd *pw; if (uin) { @@ -177,13 +274,32 @@ static void do_setvar(const char *varname, char *uin, const char *pass) fatalx(EXIT_FAILURE, "Error: old variable names are not supported"); } + /* enable status tracking ID */ + if (tracking_enabled) { + + snprintf(temp, sizeof(temp), "SET TRACKING ON\n"); + + if (upscli_sendline(ups, temp, strlen(temp)) < 0) { + fatalx(EXIT_FAILURE, "Can't enable set variable status tracking: %s", upscli_strerror(ups)); + } + + if (upscli_readline(ups, temp, sizeof(temp)) < 0) { + fatalx(EXIT_FAILURE, "Enabling set variable status tracking failed: %s", upscli_strerror(ups)); + } + + /* Verify the result */ + if (strncmp(temp, "OK", 2) != 0) { + fatalx(EXIT_FAILURE, "Enabling set variable status tracking failed. upsd answered: %s", temp); + } + } + do_set(varname, newval); } static const char *get_data(const char *type, const char *varname) { int ret; - unsigned int numq, numa; + size_t numq, numa; char **answer; const char *query[4]; @@ -203,7 +319,7 @@ static const char *get_data(const char *type, const char *varname) return answer[3]; } -static void do_string(const char *varname, const int len) +static void do_string(const char *varname, const long len) { const char *val; @@ -214,14 +330,34 @@ static void do_string(const char *varname, const int len) } printf("Type: STRING\n"); - printf("Maximum length: %d\n", len); + printf("Maximum length: %ld\n", len); printf("Value: %s\n", val); } -static void do_enum(const char *varname) +static void do_number(const char *varname) +{ + const char *val; + + val = get_data("VAR", varname); + + if (!val) { + fatalx(EXIT_FAILURE, "do_number: can't get current value of %s", varname); + } + + printf("Type: NUMBER\n"); + printf("Value: %s\n", val); +} + +/** + * Display ENUM information + * @param varname the name of the NUT variable + * @param vartype the type of the NUT variable (ST_FLAG_STRING, ST_FLAG_NUMBER + * @param len the length of the NUT variable, if type == ST_FLAG_STRING + */ +static void do_enum(const char *varname, const int vartype, const long len) { int ret; - unsigned int numq, numa; + size_t numq, numa; char **answer, buf[SMALLBUF]; const char *query[4], *val; @@ -247,14 +383,21 @@ static void do_enum(const char *varname) ret = upscli_list_next(ups, numq, query, &numa, &answer); - printf("Type: ENUM\n"); + /* Fallback for older upsd versions */ + if (vartype != ST_FLAG_NONE) + printf("Type: ENUM %s\n", (vartype == ST_FLAG_STRING)?"STRING":"NUMBER"); + else + printf("Type: ENUM\n"); + + if (vartype == ST_FLAG_STRING) + printf("Maximum length: %ld\n", len); while (ret == 1) { /* ENUM */ if (numa < 4) { - fatalx(EXIT_FAILURE, "Error: insufficient data (got %d args, need at least 4)", numa); + fatalx(EXIT_FAILURE, "Error: insufficient data (got %zu args, need at least 4)", numa); } printf("Option: \"%s\"", answer[3]); @@ -272,7 +415,7 @@ static void do_enum(const char *varname) static void do_range(const char *varname) { int ret; - unsigned int numq, numa; + size_t numq, numa; char **answer; const char *query[4], *val; int ival, min, max; @@ -299,14 +442,15 @@ static void do_range(const char *varname) ret = upscli_list_next(ups, numq, query, &numa, &answer); - printf("Type: RANGE\n"); + /* Ranges implies a type "NUMBER" */ + printf("Type: RANGE NUMBER\n"); while (ret == 1) { /* RANGE */ if (numa < 5) { - fatalx(EXIT_FAILURE, "Error: insufficient data (got %d args, need at least 4)", numa); + fatalx(EXIT_FAILURE, "Error: insufficient data (got %zu args, need at least 4)", numa); } min = atoi(answer[3]); @@ -327,7 +471,8 @@ static void do_range(const char *varname) static void do_type(const char *varname) { int ret; - unsigned int i, numq, numa; + int is_enum = 0; /* 1 if ENUM; FIXME: add a boolean type in common.h */ + size_t i, numq, numa; char **answer; const char *query[4]; @@ -339,16 +484,18 @@ static void do_type(const char *varname) ret = upscli_get(ups, numq, query, &numa, &answer); if ((ret < 0) || (numa < numq)) { - printf("Unknown type\n"); + printf("Unknown type\n"); return; } /* TYPE ... */ for (i = 3; i < numa; i++) { + /* ENUM can be NUMBER or STRING + * just flag it for latter processing */ if (!strcasecmp(answer[i], "ENUM")) { - do_enum(varname); - return; + is_enum = 1; + continue; } if (!strcasecmp(answer[i], "RANGE")) { @@ -359,15 +506,21 @@ static void do_type(const char *varname) if (!strncasecmp(answer[i], "STRING:", 7)) { char *len = answer[i] + 7; - int length = strtol(len, NULL, 10); + long length = strtol(len, NULL, 10); - do_string(varname, length); + if (is_enum == 1) + do_enum(varname, ST_FLAG_STRING, length); + else + do_string(varname, length); return; } if (!strcasecmp(answer[i], "NUMBER")) { - printf("Type: NUMBER\n"); + if (is_enum == 1) + do_enum(varname, ST_FLAG_NUMBER, 0); + else + do_number(varname); return; } @@ -378,6 +531,10 @@ static void do_type(const char *varname) printf("Type: %s (unrecognized)\n", answer[i]); } + /* Fallback for older upsd versions, where STRING|NUMBER is not + * appended to ENUM */ + if (is_enum == 1) + do_enum(varname, ST_FLAG_NONE, 0); } static void print_rw(const char *varname) @@ -402,7 +559,7 @@ static void print_rw(const char *varname) static void print_rwlist(void) { int ret; - unsigned int numq, numa; + size_t numq, numa; const char *query[2]; char **answer; struct list_t *lhead, *llast, *ltmp, *lnext; @@ -436,7 +593,7 @@ static void print_rwlist(void) /* RW */ if (numa < 4) { - fatalx(EXIT_FAILURE, "Error: insufficient data (got %d args, need at least 4)", numa); + fatalx(EXIT_FAILURE, "Error: insufficient data (got %zu args, need at least 4)", numa); } /* sock this entry away for later */ @@ -473,22 +630,36 @@ static void print_rwlist(void) int main(int argc, char **argv) { - int i, port; + int i; + uint16_t port; const char *prog = xbasename(argv[0]); char *password = NULL, *username = NULL, *setvar = NULL; - while ((i = getopt(argc, argv, "+hs:p:u:V")) != -1) { + while ((i = getopt(argc, argv, "+hls:p:t:u:wV")) != -1) { switch (i) { case 's': setvar = optarg; break; + case 'l': + if (setvar) { + upslogx(LOG_WARNING, "Listing mode requested, overriding setvar specified earlier!"); + setvar = NULL; + } + break; case 'p': password = optarg; break; + case 't': + if (!str_to_uint(optarg, &timeout, 10)) + fatal_with_errno(EXIT_FAILURE, "Could not convert the provided value for timeout ('-t' option) to unsigned int"); + break; case 'u': username = optarg; break; + case 'w': + tracking_enabled = 1; + break; case 'V': printf("Network UPS Tools %s %s\n", prog, UPS_VERSION); exit(EXIT_SUCCESS); diff --git a/clients/upssched-cmd b/clients/upssched-cmd index 63255df..893cd49 100755 --- a/clients/upssched-cmd +++ b/clients/upssched-cmd @@ -11,8 +11,19 @@ # from your AT lines. case $1 in + onbattwarn) + # Send a notification mail + echo "The UPS has been on battery for awhile" \ + | mail -s"UPS monitor" bofh@pager.example.com + # Create a flag-file on the filesystem, for your own processing + /usr/bin/touch /some/path/ups-on-battery + ;; + ups-back-on-power) + # Delete the flag-file on the filesystem + /bin/rm -f /some/path/ups-on-battery + ;; upsgone) - logger -t upssched-cmd "The UPS has been gone for awhile" + logger -t upssched-cmd "The communication with UPS has been gone for awhile" ;; *) logger -t upssched-cmd "Unrecognized command: $1" diff --git a/clients/upssched.c b/clients/upssched.c index 97b3ed4..8bb3547 100644 --- a/clients/upssched.c +++ b/clients/upssched.c @@ -46,9 +46,12 @@ #include #include #include +#include +#include #include "upssched.h" #include "timehead.h" +#include "nut_stdint.h" typedef struct ttype_s { char *name; @@ -56,14 +59,13 @@ typedef struct ttype_s { struct ttype_s *next; } ttype_t; - ttype_t *thead = NULL; - static conn_t *connhead = NULL; - char *cmdscript = NULL, *pipefn = NULL, *lockfn = NULL; - int verbose = 0; /* use for debugging */ +static ttype_t *thead = NULL; +static conn_t *connhead = NULL; +static char *cmdscript = NULL, *pipefn = NULL, *lockfn = NULL; +static int verbose = 0; /* use for debugging */ - - /* ups name and notify type (string) as received from upsmon */ - const char *upsname, *notify_type; +/* ups name and notify type (string) as received from upsmon */ +static const char *upsname, *notify_type; #define PARENT_STARTED -2 #define PARENT_UNNECESSARY -3 @@ -179,7 +181,7 @@ static void checktimers(void) static void start_timer(const char *name, const char *ofsstr) { time_t now; - int ofs; + long ofs; ttype_t *tmp, *last; /* get the time */ @@ -194,7 +196,7 @@ static void start_timer(const char *name, const char *ofsstr) } if (verbose) - upslogx(LOG_INFO, "New timer: %s (%d seconds)", name, ofs); + upslogx(LOG_INFO, "New timer: %s (%ld seconds)", name, ofs); /* now add to the queue */ tmp = last = thead; @@ -240,7 +242,7 @@ static void cancel_timer(const char *name, const char *cname) static void us_serialize(int op) { static int pipefd[2]; - int ret; + ssize_t ret; char ch; switch(op) { @@ -270,6 +272,7 @@ static int open_sock(void) int ret, fd; struct sockaddr_un ssaddr; + check_unix_socket_filename(pipefn); fd = socket(AF_UNIX, SOCK_STREAM, 0); if (fd < 0) @@ -297,6 +300,9 @@ static int open_sock(void) if (ret < 0) fatal_with_errno(EXIT_FAILURE, "listen(%d, %d) failed", fd, US_LISTEN_BACKLOG); + /* don't leak socket to CMDSCRIPT */ + fcntl(fd, F_SETFD, FD_CLOEXEC); + return fd; } @@ -329,17 +335,40 @@ static void conn_del(conn_t *target) static int send_to_one(conn_t *conn, const char *fmt, ...) { - int ret; + ssize_t ret; + size_t buflen; va_list ap; char buf[US_SOCK_BUF_LEN]; va_start(ap, fmt); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif vsnprintf(buf, sizeof(buf), fmt, ap); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif va_end(ap); - ret = write(conn->fd, buf, strlen(buf)); + buflen = strlen(buf); + if (buflen >= SSIZE_MAX) { + /* Can't compare buflen to ret */ + upsdebugx(2, "send_to_one(): buffered message too large"); - if ((ret < 1) || (ret != (int) strlen(buf))) { + close(conn->fd); + conn_del(conn); + + return 0; /* failed */ + } + ret = write(conn->fd, buf, buflen); + + if ((ret < 1) || (ret != (ssize_t) buflen)) { upsdebugx(2, "write to fd %d failed", conn->fd); close(conn->fd); @@ -356,7 +385,7 @@ static void conn_add(int sockfd) int acc, ret; conn_t *tmp, *last; struct sockaddr_un saddr; -#if defined(__hpux) && !defined(_XOPEN_SOURCE_EXTENDED) +#if defined(__hpux) && !defined(_XOPEN_SOURCE_EXTENDED) int salen; #else socklen_t salen; @@ -370,6 +399,9 @@ static void conn_add(int sockfd) return; } + /* don't leak connection to CMDSCRIPT */ + fcntl(acc, F_SETFD, FD_CLOEXEC); + /* enable nonblocking I/O */ ret = fcntl(acc, F_GETFL, 0); @@ -440,19 +472,20 @@ static int sock_arg(conn_t *conn) return 0; } -static void log_unknown(int numarg, char **arg) +static void log_unknown(size_t numarg, char **arg) { - int i; + size_t i; upslogx(LOG_INFO, "Unknown command on socket: "); for (i = 0; i < numarg; i++) - upslogx(LOG_INFO, "arg %d: %s", i, arg[i]); + upslogx(LOG_INFO, "arg %zu: %s", i, arg[i]); } static int sock_read(conn_t *conn) { - int i, ret; + int i; + ssize_t ret; char ch; for (i = 0; i < US_MAX_READ; i++) { @@ -465,13 +498,19 @@ static int sock_read(conn_t *conn) if ((ret == -1) && (errno == EAGAIN)) return 0; + /* O_NDELAY with zero bytes means nothing to read but + * since read() follows a succesful select() with + * ready file descriptor, ret shouldn't be 0. */ + if (ret == 0) + continue; + /* some other problem */ return -1; /* error */ } ret = pconf_char(&conn->ctx, ch); - if (ret == 0) /* nothing to parse yet */ + if (ret == 0) /* nothing to parse yet */ continue; if (ret == -1) { @@ -594,6 +633,8 @@ static int try_connect(void) int pipefd, ret; struct sockaddr_un saddr; + check_unix_socket_filename(pipefn); + memset(&saddr, '\0', sizeof(saddr)); saddr.sun_family = AF_UNIX; snprintf(saddr.sun_path, sizeof(saddr.sun_path), "%s", pipefn); @@ -659,28 +700,15 @@ static int check_parent(const char *cmd, const char *arg2) exit(EXIT_FAILURE); } -static void read_timeout(int sig) -{ - /* ignore this */ - return; -} - -static void setup_sigalrm(void) -{ - struct sigaction sa; - sigset_t nut_upssched_sigmask; - - sigemptyset(&nut_upssched_sigmask); - sa.sa_mask = nut_upssched_sigmask; - sa.sa_flags = 0; - sa.sa_handler = read_timeout; - sigaction(SIGALRM, &sa, NULL); -} - static void sendcmd(const char *cmd, const char *arg1, const char *arg2) { - int i, pipefd, ret; - char buf[SMALLBUF], enc[SMALLBUF]; + int i, pipefd; + ssize_t ret; + size_t enclen, buflen; + char buf[SMALLBUF], enc[SMALLBUF + 8]; + int ret_s; + struct timeval tv; + fd_set fdread; /* insanity */ if (!arg1) @@ -696,6 +724,14 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2) snprintf(enc, sizeof(enc), "%s\n", buf); + /* Sanity checks, for static analyzers to sleep well */ + enclen = strlen(enc); + buflen = strlen(buf); + if (enclen >= SSIZE_MAX || buflen >= SSIZE_MAX) { + /* Can't compare enclen to ret below */ + fatalx(EXIT_FAILURE, "Unable to connect to daemon: buffered message too large"); + } + /* see if the parent needs to be started (and maybe start it) */ for (i = 0; i < MAX_TRIES; i++) { @@ -703,7 +739,6 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2) pipefd = check_parent(cmd, arg2); if (pipefd == PARENT_STARTED) { - /* loop back and try to connect now */ usleep(250000); continue; @@ -715,23 +750,41 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2) /* we're connected now */ - ret = write(pipefd, enc, strlen(enc)); + ret = write(pipefd, enc, enclen); /* if we can't send the whole thing, loop back and try again */ - if ((ret < 1) || (ret != (int) strlen(enc))) { + if ((ret < 1) || (ret != (ssize_t)enclen)) { upslogx(LOG_ERR, "write failed, trying again"); close(pipefd); continue; } - /* ugh - probably should use select here... */ - setup_sigalrm(); + /* select on child's pipe fd */ + do { + /* set timeout every time before call select() */ + tv.tv_sec = 1; + tv.tv_usec = 0; - alarm(2); - ret = read(pipefd, buf, sizeof(buf)); - alarm(0); + FD_ZERO(&fdread); + FD_SET(pipefd, &fdread); - signal(SIGALRM, SIG_IGN); + ret_s = select(pipefd + 1, &fdread, NULL, NULL, &tv); + switch(ret_s) { + /* select error */ + case -1: + upslogx(LOG_DEBUG, "parent select error: %s", strerror(errno)); + break; + + /* nothing to read */ + case 0: + break; + + /* available data to read */ + default: + ret = read(pipefd, buf, sizeof(buf)); + break; + } + } while (ret_s <= 0); close(pipefd); @@ -747,7 +800,7 @@ static void sendcmd(const char *cmd, const char *arg1, const char *arg2) upslogx(LOG_ERR, "read confirmation got [%s]", buf); /* try again ... */ - } + } /* loop until MAX_TRIES if no success above */ fatalx(EXIT_FAILURE, "Unable to connect to daemon and unable to start daemon"); } @@ -794,7 +847,7 @@ static void parse_at(const char *ntype, const char *un, const char *cmd, } if (!strcmp(cmd, "EXECUTE")) { - if (ca1 == '\0') { + if (ca1[0] == '\0') { upslogx(LOG_ERR, "Empty EXECUTE command argument"); return; } @@ -809,7 +862,7 @@ static void parse_at(const char *ntype, const char *un, const char *cmd, upslogx(LOG_ERR, "Invalid command: %s", cmd); } -static int conf_arg(int numargs, char **arg) +static int conf_arg(size_t numargs, char **arg) { if (numargs < 2) return 0; @@ -900,9 +953,15 @@ static void checkconf(void) int main(int argc, char **argv) { - const char *prog = xbasename(argv[0]); + const char *prog = NULL; + /* More a use for argc to avoid warnings than a real need: */ + if (argc > 0) { + xbasename(argv[0]); + } else { + xbasename("upssched"); + } - verbose = 1; /* TODO: remove when done testing */ + verbose = 1; /* TODO: remove when done testing, or add -D */ /* normally we don't have stderr, so get this going to syslog early */ open_syslog(prog); diff --git a/clients/upssched.h b/clients/upssched.h index db0c25d..1b7e8f1 100644 --- a/clients/upssched.h +++ b/clients/upssched.h @@ -1,5 +1,8 @@ /* upssched.h - supporting structures */ +#ifndef NUT_UPSSCHED_H_SEEN +#define NUT_UPSSCHED_H_SEEN 1 + #include #define SERIALIZE_INIT 1 @@ -25,3 +28,4 @@ typedef struct conn_s { /* *INDENT-ON* */ #endif +#endif /* NUT_UPSSCHED_H_SEEN */ diff --git a/clients/upsset.c b/clients/upsset.c index 8f18b7c..788b201 100644 --- a/clients/upsset.c +++ b/clients/upsset.c @@ -24,6 +24,7 @@ #include #include +#include "nut_stdint.h" #include "upsclient.h" #include "cgilib.h" #include "parseconf.h" @@ -39,12 +40,12 @@ struct list_t { #define HARD_UPSVAR_LIMIT_NUM 64 #define HARD_UPSVAR_LIMIT_LEN 256 - char *monups, *username, *password, *function, *upscommand; +static char *monups, *username, *password, *function, *upscommand; - /* set once the MAGIC_ENABLE_STRING is found in the upsset.conf */ - int magic_string_set = 0; +/* set once the MAGIC_ENABLE_STRING is found in the upsset.conf */ +static int magic_string_set = 0; -static int port; +static uint16_t port; static char *upsname, *hostname; static UPSCONN_t ups; @@ -54,7 +55,7 @@ typedef struct { void *next; } uvtype_t; - uvtype_t *firstuv = NULL; +static uvtype_t *firstuv = NULL; void parsearg(char *var, char *value) { @@ -134,7 +135,7 @@ static void do_header(const char *title) printf("\n"); printf("upsset: %s\n", title); - printf("\n"); + printf("\n"); printf("\n"); printf("
\n"); @@ -144,7 +145,7 @@ static void start_table(void) { printf("\n"); printf("\n"); } @@ -158,12 +159,12 @@ static void do_hidden(const char *next) password); if (next) - printf("\n", + printf("\n", next); } /* generate SELECT chooser from hosts.conf entries */ -static void upslist_arg(int numargs, char **arg) +static void upslist_arg(size_t numargs, char **arg) { if (numargs < 3) return; @@ -222,7 +223,7 @@ static void do_pickups(const char *currfunc) continue; } - upslist_arg(ctx.numargs, ctx.arglist); + upslist_arg(ctx.numargs, ctx.arglist); } pconf_finish(&ctx); @@ -253,6 +254,10 @@ static void do_pickups(const char *currfunc) printf("\n"); } +static void error_page(const char *next, const char *title, + const char *fmt, ...) + __attribute__((noreturn)); + static void error_page(const char *next, const char *title, const char *fmt, ...) { @@ -260,7 +265,19 @@ static void error_page(const char *next, const char *title, va_list ap; va_start(ap, fmt); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif vsnprintf(msg, sizeof(msg), fmt, ap); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif va_end(ap); do_header(title); @@ -282,6 +299,9 @@ static void error_page(const char *next, const char *title, exit(EXIT_SUCCESS); } +static void loginscreen(void) + __attribute__((noreturn)); + static void loginscreen(void) { do_header("Login"); @@ -331,7 +351,7 @@ static void upsd_connect(void) static void print_cmd(const char *cmd) { int ret; - unsigned int numq, numa; + size_t numq, numa; char **answer; const char *query[4]; @@ -354,7 +374,7 @@ static void print_cmd(const char *cmd) static void showcmds(void) { int ret; - unsigned int numq, numa; + size_t numq, numa; const char *query[2]; char **answer; struct list_t *lhead, *llast, *ltmp, *lnext; @@ -391,7 +411,7 @@ static void showcmds(void) /* CMD upsname cmdname */ if (numa < 3) { fprintf(stderr, "Error: insufficient data " - "(got %d args, need at least 3)\n", numa); + "(got %zu args, need at least 3)\n", numa); return; } @@ -466,7 +486,7 @@ static void showcmds(void) upscli_disconnect(&ups); exit(EXIT_SUCCESS); -} +} /* handle setting authentication data in the server */ static void send_auth(const char *next) @@ -491,7 +511,7 @@ static void send_auth(const char *next) "upsd version too old - USERNAME not supported"); } - error_page(next, "Can't set user name", + error_page(next, "Can't set user name", "Set user name failed: %s", upscli_strerror(&ups)); } @@ -504,7 +524,10 @@ static void send_auth(const char *next) if (upscli_readline(&ups, buf, sizeof(buf)) < 0) error_page(next, "Can't set password", "Password set failed: %s", upscli_strerror(&ups)); -} +} + +static void docmd(void) + __attribute__((noreturn)); static void docmd(void) { @@ -515,13 +538,13 @@ static void docmd(void) "Access to that host is not authorized"); /* the user is messing with us */ - if (!upscommand) - error_page("showcmds", "Form error", + if (!upscommand) + error_page("showcmds", "Form error", "No instant command selected"); /* (l)user took the default blank option */ if (strlen(upscommand) == 0) - error_page("showcmds", "Form error", + error_page("showcmds", "Form error", "No instant command selected"); upsd_connect(); @@ -595,7 +618,7 @@ static void docmd(void) static const char *get_data(const char *type, const char *varname) { int ret; - unsigned int numq, numa; + size_t numq, numa; char **answer; const char *query[4]; @@ -633,7 +656,7 @@ static void do_string(const char *varname, int maxlen) static void do_enum(const char *varname) { int ret; - unsigned int numq, numa; + size_t numq, numa; char **answer, *val; const char *query[4], *tmp; @@ -659,8 +682,9 @@ static void do_enum(const char *varname) if (ret < 0) { printf("Unavailable\n"); - fprintf(stderr, "Error doing ENUM %s %s: %s\n", + fprintf(stderr, "Error doing ENUM %s %s: %s\n", upsname, varname, upscli_strerror(&ups)); + free(val); return; } @@ -674,7 +698,7 @@ static void do_enum(const char *varname) if (numa < 4) { fprintf(stderr, "Error: insufficient data " - "(got %d args, need at least 4)\n", numa); + "(got %zu args, need at least 4)\n", numa); free(val); return; @@ -697,7 +721,7 @@ static void do_enum(const char *varname) static void do_type(const char *varname) { int ret; - unsigned int i, numq, numa; + size_t i, numq, numa; char **answer; const char *query[4]; @@ -709,7 +733,7 @@ static void do_type(const char *varname) ret = upscli_get(&ups, numq, query, &numa, &answer); if ((ret < 0) || (numa < numq)) { - printf("Unknown type\n"); + printf("Unknown type\n"); return; } @@ -727,7 +751,9 @@ static void do_type(const char *varname) /* split out the : data */ ptr = strchr(answer[i], ':'); *ptr++ = '\0'; - len = strtol(ptr, (char **) NULL, 10); + long l = strtol(ptr, (char **) NULL, 10); + assert(l <= 127); /* FIXME: Loophole about longer numbers? Why are we limited to char at all here? */ + len = (char)l; do_string(varname, len); return; @@ -741,10 +767,12 @@ static void do_type(const char *varname) } } -static void print_rw(const char *upsname, const char *varname) +static void print_rw(const char *arg_upsname, const char *varname) { const char *tmp; + printf("\n", arg_upsname); + printf("\n"); printf("\n"); } +static void showsettings(void) + __attribute__((noreturn)); + static void showsettings(void) { int ret; - unsigned int numq, numa; + size_t numq, numa; const char *query[2]; char **answer, *desc = NULL; struct list_t *lhead, *llast, *ltmp, *lnext; @@ -907,13 +938,16 @@ static int setvar(const char *var, const char *val) } /* turn a form submission of settings into SET commands for upsd */ +static void savesettings(void) + __attribute__((noreturn)); + static void savesettings(void) { int changed = 0; char *desc; uvtype_t *upsvar; - if (!checkhost(monups, &desc)) + if (!checkhost(monups, &desc)) error_page("showsettings", "Access denied", "Access to that host is not authorized"); @@ -953,6 +987,9 @@ static void savesettings(void) exit(EXIT_SUCCESS); } +static void initial_pickups(void) + __attribute__((noreturn)); + static void initial_pickups(void) { do_header("Select a UPS"); @@ -1027,10 +1064,12 @@ static void check_conf(void) fprintf(stderr, "upsset.conf does not permit execution\n"); exit(EXIT_FAILURE); -} +} int main(int argc, char **argv) { + NUT_UNUSED_VARIABLE(argc); + NUT_UNUSED_VARIABLE(argv); username = password = function = monups = NULL; printf("Content-type: text/html\n\n"); @@ -1040,15 +1079,16 @@ int main(int argc, char **argv) /* see if there's anything waiting .. the server my not close STDIN properly */ if (1) { - fd_set fds; - struct timeval tv; + fd_set fds; + struct timeval tv; - FD_ZERO(&fds); - FD_SET(STDIN_FILENO, &fds); - tv.tv_sec = 0; - tv.tv_usec = 250000; /* wait for up to 250ms for a POST response */ - if ((select(STDIN_FILENO+1, &fds, 0, 0, &tv)) > 0) - extractpostargs(); + FD_ZERO(&fds); + FD_SET(STDIN_FILENO, &fds); + tv.tv_sec = 0; + tv.tv_usec = 250000; /* wait for up to 250ms for a POST response */ + + if ((select(STDIN_FILENO+1, &fds, 0, 0, &tv)) > 0) + extractpostargs(); } if ((!username) || (!password) || (!function)) loginscreen(); @@ -1074,6 +1114,6 @@ int main(int argc, char **argv) docmd(); printf("Error: Unhandled function name [%s]\n", function); - + return 0; } diff --git a/clients/upsstats.c b/clients/upsstats.c index 07ab6ea..4b7f754 100644 --- a/clients/upsstats.c +++ b/clients/upsstats.c @@ -19,11 +19,12 @@ */ #include "common.h" +#include "nut_stdint.h" +#include "timehead.h" #include "upsclient.h" #include "status.h" #include "cgilib.h" #include "parseconf.h" -#include "timehead.h" #include "upsstats.h" #include "upsimagearg.h" @@ -36,7 +37,7 @@ static int use_celsius = 1, refreshdelay = -1, treemode = 0; /* from cgilib's checkhost() */ static char *monhostdesc = NULL; -static int port; +static uint16_t port; static char *upsname, *hostname; static char *upsimgpath="upsimage.cgi", *upsstatpath="upsstats.cgi"; static UPSCONN_t ups; @@ -103,7 +104,7 @@ static int check_ups_fd(int do_report) static int get_var(const char *var, char *buf, size_t buflen, int verbose) { int ret; - unsigned int numq, numa; + size_t numq, numa; const char *query[4]; char **answer; @@ -134,7 +135,7 @@ static int get_var(const char *var, char *buf, size_t buflen, int verbose) if (numa < numq) { if (verbose) printf("[Invalid response]\n"); - + return 0; } @@ -195,9 +196,10 @@ static int do_date(const char *buf) { char datebuf[SMALLBUF]; time_t tod; + struct tm tmbuf; time(&tod); - if (strftime(datebuf, sizeof(datebuf), buf, localtime(&tod))) { + if (strftime(datebuf, sizeof(datebuf), buf, localtime_r(&tod, &tmbuf))) { printf("%s", datebuf); return 1; } @@ -291,12 +293,12 @@ static int do_img(char *buf) /* only allow known types through */ - if (!strcmp(type, "input.voltage") - || !strcmp(type, "input.L1-N.voltage") - || !strcmp(type, "input.L2-N.voltage") + if (!strcmp(type, "input.voltage") + || !strcmp(type, "input.L1-N.voltage") + || !strcmp(type, "input.L2-N.voltage") || !strcmp(type, "input.L3-N.voltage") - || !strcmp(type, "input.L1-L2.voltage") - || !strcmp(type, "input.L2-L3.voltage") + || !strcmp(type, "input.L1-L2.voltage") + || !strcmp(type, "input.L2-L3.voltage") || !strcmp(type, "input.L3-L1.voltage")) { return get_img_val(type, "Input voltage", imgargs); } @@ -308,11 +310,11 @@ static int do_img(char *buf) return get_img_val(type, "Battery charge", imgargs); if (!strcmp(type, "output.voltage") - || !strcmp(type, "output.L1-N.voltage") - || !strcmp(type, "output.L2-N.voltage") + || !strcmp(type, "output.L1-N.voltage") + || !strcmp(type, "output.L2-N.voltage") || !strcmp(type, "output.L3-N.voltage") - || !strcmp(type, "output.L1-L2.voltage") - || !strcmp(type, "output.L2-L3.voltage") + || !strcmp(type, "output.L1-L2.voltage") + || !strcmp(type, "output.L2-L3.voltage") || !strcmp(type, "output.L3-L1.voltage")) { return get_img_val(type, "Output voltage", imgargs); } @@ -349,7 +351,7 @@ static void ups_connect(void) { static ulist_t *lastups = NULL; char *newups, *newhost; - int newport; + uint16_t newport; /* try to minimize reconnects */ if (lastups) { @@ -363,13 +365,13 @@ static void ups_connect(void) /* see if it's just on the same host */ newups = newhost = NULL; - if (upscli_splitname(currups->sys, &newups, &newhost, + if (upscli_splitname(currups->sys, &newups, &newhost, &newport) != 0) { printf("Unusable UPS definition [%s]\n", currups->sys); - fprintf(stderr, "Unusable UPS definition [%s]\n", + fprintf(stderr, "Unusable UPS definition [%s]\n", currups->sys); exit(EXIT_FAILURE); - } + } if ((!strcmp(newhost, hostname)) && (port == newport)) { free(upsname); @@ -564,7 +566,7 @@ static void do_upsimgpath(const char *s) { static void do_temp(const char *var) { char tempc[SMALLBUF]; - float tempf; + double tempf; if (!get_var(var, tempc, sizeof(tempc), 1)) return; @@ -807,7 +809,8 @@ static int do_command(char *cmd) static void parse_line(const char *buf) { char cmd[SMALLBUF]; - int i, len, do_cmd = 0; + size_t i, len; + char do_cmd = 0; for (i = 0; buf[i]; i += len) { @@ -824,9 +827,10 @@ static void parse_line(const char *buf) i++; /* skip over the '@' character */ continue; } + assert (len < INT_MAX); if (do_cmd) { - snprintf(cmd, sizeof(cmd), "%.*s", len, &buf[i]); + snprintf(cmd, sizeof(cmd), "%.*s", (int)len, &buf[i]); continue; } @@ -836,13 +840,13 @@ static void parse_line(const char *buf) } /* pass it trough */ - printf("%.*s", len, &buf[i]); + printf("%.*s", (int)len, &buf[i]); } } static void display_template(const char *tfn) { - char fn[SMALLBUF], buf[LARGEBUF]; + char fn[SMALLBUF], buf[LARGEBUF]; snprintf(fn, sizeof(fn), "%s/%s", confpath(), tfn); @@ -865,7 +869,7 @@ static void display_template(const char *tfn) static void display_tree(int verbose) { - unsigned int numq, numa; + size_t numq, numa; const char *query[4]; char **answer; @@ -890,7 +894,7 @@ static void display_tree(int verbose) printf("\n"); printf("upsstat: data tree of %s\n", currups->desc); - printf("\n"); + printf("\n"); printf("
\n"); - printf("Network UPS Tools upsset %s\n", + printf("Network UPS Tools upsset %s\n", UPS_VERSION); printf("
"); @@ -765,10 +793,13 @@ static void print_rw(const char *upsname, const char *varname) printf("
\n"); printf("\n"); - + printf("\n", answer[2]); printf("\n"); printf("\n", answer[3]); @@ -936,7 +940,7 @@ static void add_ups(char *sys, char *desc) tmp = last = ulhead; - while (tmp) { + while (tmp) { last = tmp; tmp = tmp->next; } @@ -1041,9 +1045,12 @@ static void display_single(void) int main(int argc, char **argv) { + NUT_UNUSED_VARIABLE(argc); + NUT_UNUSED_VARIABLE(argv); + extractcgiargs(); - printf("Content-type: text/html\n"); + printf("Content-type: text/html\n"); printf("Pragma: no-cache\n"); printf("\n"); diff --git a/clients/upsstats.h b/clients/upsstats.h index 84ca8ad..92ed932 100644 --- a/clients/upsstats.h +++ b/clients/upsstats.h @@ -17,6 +17,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef NUT_UPSSTATS_H_SEEN +#define NUT_UPSSTATS_H_SEEN 1 + #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { @@ -35,3 +38,4 @@ typedef struct { /* *INDENT-ON* */ #endif +#endif /* NUT_UPSSTATS_H_SEEN */ diff --git a/common/Makefile.am b/common/Makefile.am index 2bfc6e0..5ce88ab 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -8,10 +8,42 @@ libparseconf_la_SOURCES = parseconf.c # do not hard depend on '../include/nut_version.h', since it blocks # 'dist', and is only required for actual build, in which case # BUILT_SOURCES (in ../include) will ensure nut_version.h will -# be built before anything else -libcommon_la_SOURCES = common.c state.c str.c upsconf.c -libcommonclient_la_SOURCES = common.c state.c str.c +# be built before anything else... but do depend on its build area: +if BUILDING_IN_TREE +# No need for symlink hack +common.c: $(top_builddir)/include/nut_version.h +else +# Surprisingly, for some "make" implementations this dependency means +# that the "common.c" required for builds below will be seeked in the +# current directory. So for out-of-tree builds like distcheck, we have +# to symlink the "real" source to build area: +common.c: $(top_builddir)/include/nut_version.h $(srcdir)/common.c + test -s "$@" || ln -s -f "$(top_srcdir)/common/common.c" "$@" +endif + +$(top_builddir)/include/nut_version.h: + @cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F) + +libcommon_la_SOURCES = state.c str.c upsconf.c +libcommonclient_la_SOURCES = state.c str.c +if BUILDING_IN_TREE +libcommon_la_SOURCES += common.c +libcommonclient_la_SOURCES += common.c +else +nodist_libcommon_la_SOURCES = common.c +nodist_libcommonclient_la_SOURCES = common.c +CLEANFILES = $(top_builddir)/common/common.c +BUILT_SOURCES = common.c +endif + # ensure inclusion of local implementation of missing systems functions -# using LTLIBOBJS. Refer to configure.in -> AC_REPLACE_FUNCS +# using LTLIBOBJS. Refer to configure.in/.ac -> AC_REPLACE_FUNCS libcommon_la_LIBADD = libparseconf.la @LTLIBOBJS@ libcommonclient_la_LIBADD = libparseconf.la @LTLIBOBJS@ + +MAINTAINERCLEANFILES = Makefile.in .dirstamp + +# NOTE: Do not clean ".deps" in SUBDIRS of the main project, +# the root Makefile.am takes care of that! +#clean-local: +# rm -rf $(builddir)/.deps diff --git a/common/Makefile.in b/common/Makefile.in index 8710560..a6eb968 100644 --- a/common/Makefile.in +++ b/common/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.16.3 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -17,7 +17,17 @@ # Network UPS Tools: common VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -81,20 +91,27 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ +@BUILDING_IN_TREE_TRUE@am__append_1 = common.c +@BUILDING_IN_TREE_TRUE@am__append_2 = common.c subdir = common -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am atexit.c \ - snprintf.c setenv.c strerror.c $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nut_arg_with.m4 \ $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ $(top_srcdir)/m4/nut_check_libavahi.m4 \ $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ $(top_srcdir)/m4/nut_check_libgd.m4 \ $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ $(top_srcdir)/m4/nut_check_libneon.m4 \ $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ $(top_srcdir)/m4/nut_check_libnss.m4 \ @@ -103,26 +120,39 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ $(top_srcdir)/m4/nut_check_libusb.m4 \ $(top_srcdir)/m4/nut_check_libwrap.m4 \ $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ $(top_srcdir)/m4/nut_type_socklen_t.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libcommon_la_DEPENDENCIES = libparseconf.la @LTLIBOBJS@ -am_libcommon_la_OBJECTS = common.lo state.lo str.lo upsconf.lo -libcommon_la_OBJECTS = $(am_libcommon_la_OBJECTS) +am__libcommon_la_SOURCES_DIST = state.c str.c upsconf.c common.c +@BUILDING_IN_TREE_TRUE@am__objects_1 = common.lo +am_libcommon_la_OBJECTS = state.lo str.lo upsconf.lo $(am__objects_1) +@BUILDING_IN_TREE_FALSE@nodist_libcommon_la_OBJECTS = common.lo +libcommon_la_OBJECTS = $(am_libcommon_la_OBJECTS) \ + $(nodist_libcommon_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = libcommonclient_la_DEPENDENCIES = libparseconf.la @LTLIBOBJS@ -am_libcommonclient_la_OBJECTS = common.lo state.lo str.lo -libcommonclient_la_OBJECTS = $(am_libcommonclient_la_OBJECTS) +am__libcommonclient_la_SOURCES_DIST = state.c str.c common.c +am_libcommonclient_la_OBJECTS = state.lo str.lo $(am__objects_1) +@BUILDING_IN_TREE_FALSE@nodist_libcommonclient_la_OBJECTS = common.lo +libcommonclient_la_OBJECTS = $(am_libcommonclient_la_OBJECTS) \ + $(nodist_libcommonclient_la_OBJECTS) libparseconf_la_LIBADD = am_libparseconf_la_OBJECTS = parseconf.lo libparseconf_la_OBJECTS = $(am_libparseconf_la_OBJECTS) @@ -140,7 +170,12 @@ am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = $(DEPDIR)/atexit.Plo $(DEPDIR)/setenv.Plo \ + $(DEPDIR)/snprintf.Plo $(DEPDIR)/strerror.Plo \ + ./$(DEPDIR)/common.Plo ./$(DEPDIR)/parseconf.Plo \ + ./$(DEPDIR)/state.Plo ./$(DEPDIR)/str.Plo \ + ./$(DEPDIR)/upsconf.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -160,9 +195,12 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = -SOURCES = $(libcommon_la_SOURCES) $(libcommonclient_la_SOURCES) \ +SOURCES = $(libcommon_la_SOURCES) $(nodist_libcommon_la_SOURCES) \ + $(libcommonclient_la_SOURCES) \ + $(nodist_libcommonclient_la_SOURCES) \ $(libparseconf_la_SOURCES) -DIST_SOURCES = $(libcommon_la_SOURCES) $(libcommonclient_la_SOURCES) \ +DIST_SOURCES = $(am__libcommon_la_SOURCES_DIST) \ + $(am__libcommonclient_la_SOURCES_DIST) \ $(libparseconf_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ @@ -188,6 +226,8 @@ am__define_uniq_tagged_files = \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp atexit.c \ + setenv.c snprintf.c strerror.c DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) A2X = @A2X@ ACLOCAL = @ACLOCAL@ @@ -196,6 +236,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -206,6 +247,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -219,6 +261,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -231,6 +274,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -248,6 +292,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -258,21 +304,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -292,6 +346,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -305,6 +362,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -322,6 +380,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -335,6 +394,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -360,12 +422,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -378,18 +442,20 @@ udevdir = @udevdir@ AM_CFLAGS = -I$(top_srcdir)/include noinst_LTLIBRARIES = libparseconf.la libcommon.la libcommonclient.la libparseconf_la_SOURCES = parseconf.c +libcommon_la_SOURCES = state.c str.c upsconf.c $(am__append_1) +libcommonclient_la_SOURCES = state.c str.c $(am__append_2) +@BUILDING_IN_TREE_FALSE@nodist_libcommon_la_SOURCES = common.c +@BUILDING_IN_TREE_FALSE@nodist_libcommonclient_la_SOURCES = common.c +@BUILDING_IN_TREE_FALSE@CLEANFILES = $(top_builddir)/common/common.c +@BUILDING_IN_TREE_FALSE@BUILT_SOURCES = common.c -# do not hard depend on '../include/nut_version.h', since it blocks -# 'dist', and is only required for actual build, in which case -# BUILT_SOURCES (in ../include) will ensure nut_version.h will -# be built before anything else -libcommon_la_SOURCES = common.c state.c str.c upsconf.c -libcommonclient_la_SOURCES = common.c state.c str.c # ensure inclusion of local implementation of missing systems functions -# using LTLIBOBJS. Refer to configure.in -> AC_REPLACE_FUNCS +# using LTLIBOBJS. Refer to configure.in/.ac -> AC_REPLACE_FUNCS libcommon_la_LIBADD = libparseconf.la @LTLIBOBJS@ libcommonclient_la_LIBADD = libparseconf.la @LTLIBOBJS@ -all: all-am +MAINTAINERCLEANFILES = Makefile.in .dirstamp +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj @@ -405,14 +471,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu common/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu common/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -450,15 +515,21 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/atexit.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/setenv.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/snprintf.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strerror.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parseconf.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/state.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upsconf.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/atexit.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/setenv.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/snprintf.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strerror.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parseconf.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/state.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upsconf.Plo@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @@ -542,7 +613,10 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -573,11 +647,14 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am -check: check-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am all-am: Makefile $(LTLIBRARIES) installdirs: -install: install-am -install-exec: install-exec-am +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data: install-data-am uninstall: uninstall-am @@ -598,6 +675,7 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) @@ -606,13 +684,23 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am - -rm -rf $(DEPDIR) ./$(DEPDIR) + -rm -f $(DEPDIR)/atexit.Plo + -rm -f $(DEPDIR)/setenv.Plo + -rm -f $(DEPDIR)/snprintf.Plo + -rm -f $(DEPDIR)/strerror.Plo + -rm -f ./$(DEPDIR)/common.Plo + -rm -f ./$(DEPDIR)/parseconf.Plo + -rm -f ./$(DEPDIR)/state.Plo + -rm -f ./$(DEPDIR)/str.Plo + -rm -f ./$(DEPDIR)/upsconf.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -658,7 +746,15 @@ install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am - -rm -rf $(DEPDIR) ./$(DEPDIR) + -rm -f $(DEPDIR)/atexit.Plo + -rm -f $(DEPDIR)/setenv.Plo + -rm -f $(DEPDIR)/snprintf.Plo + -rm -f $(DEPDIR)/strerror.Plo + -rm -f ./$(DEPDIR)/common.Plo + -rm -f ./$(DEPDIR)/parseconf.Plo + -rm -f ./$(DEPDIR)/state.Plo + -rm -f ./$(DEPDIR)/str.Plo + -rm -f ./$(DEPDIR)/upsconf.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -677,22 +773,45 @@ ps-am: uninstall-am: -.MAKE: install-am install-strip +.MAKE: all check install install-am install-exec install-strip -.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \ - ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ + clean-generic clean-libtool clean-noinstLTLIBRARIES \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am +.PRECIOUS: Makefile + + +# do not hard depend on '../include/nut_version.h', since it blocks +# 'dist', and is only required for actual build, in which case +# BUILT_SOURCES (in ../include) will ensure nut_version.h will +# be built before anything else... but do depend on its build area: +# No need for symlink hack +@BUILDING_IN_TREE_TRUE@common.c: $(top_builddir)/include/nut_version.h +# Surprisingly, for some "make" implementations this dependency means +# that the "common.c" required for builds below will be seeked in the +# current directory. So for out-of-tree builds like distcheck, we have +# to symlink the "real" source to build area: +@BUILDING_IN_TREE_FALSE@common.c: $(top_builddir)/include/nut_version.h $(srcdir)/common.c +@BUILDING_IN_TREE_FALSE@ test -s "$@" || ln -s -f "$(top_srcdir)/common/common.c" "$@" + +$(top_builddir)/include/nut_version.h: + @cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F) + +# NOTE: Do not clean ".deps" in SUBDIRS of the main project, +# the root Makefile.am takes care of that! +#clean-local: +# rm -rf $(builddir)/.deps # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/common/common.c b/common/common.c index 6637113..f664d99 100644 --- a/common/common.c +++ b/common/common.c @@ -1,6 +1,7 @@ /* common.c - common useful functions Copyright (C) 2000 Russell Kroll + Copyright (C) 2021-2022 Jim Klimov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,8 +22,11 @@ #include #include +#include #include #include +#include +#include /* the reason we define UPS_VERSION as a static string, rather than a macro, is to make dependency tracking easier (only common.o depends @@ -32,6 +36,52 @@ #include "nut_version.h" const char *UPS_VERSION = NUT_VERSION_MACRO; +#include + +/* Know which bitness we were built for, + * to adjust the search paths for get_libname() */ +#include "nut_stdint.h" +#if UINTPTR_MAX == 0xffffffffffffffffULL +# define BUILD_64 1 +#else +# ifdef BUILD_64 +# undef BUILD_64 +# endif +#endif + +/* https://stackoverflow.com/a/12844426/4715872 */ +#include +#include +#include +pid_t get_max_pid_t() +{ +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic ignored "-Wunreachable-code" +#endif +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" +#endif + if (sizeof(pid_t) == sizeof(short)) return (pid_t)SHRT_MAX; + if (sizeof(pid_t) == sizeof(int)) return (pid_t)INT_MAX; + if (sizeof(pid_t) == sizeof(long)) return (pid_t)LONG_MAX; +#if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || (defined _STDC_C99) || (defined __C99FEATURES__) /* C99+ build mode */ +# if defined(LLONG_MAX) /* since C99 */ + if (sizeof(pid_t) == sizeof(long long)) return (pid_t)LLONG_MAX; +# endif +#endif + abort(); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic pop +#endif +} + int nut_debug_level = 0; int nut_log_level = 0; static int upslog_flags = UPSLOG_STDERR; @@ -51,7 +101,7 @@ static int xbit_test(int val, int flag) return ((val & flag) == flag); } -/* enable writing upslog_with_errno() and upslogx() type messages to +/* enable writing upslog_with_errno() and upslogx() type messages to the syslog */ void syslogbit_set(void) { @@ -126,7 +176,7 @@ void background(void) close(1); close(2); - if (pid != 0) + if (pid != 0) _exit(EXIT_SUCCESS); /* parent */ /* child */ @@ -163,8 +213,32 @@ struct passwd *get_user_pwent(const char *name) fatalx(EXIT_FAILURE, "user %s not found", name); else fatal_with_errno(EXIT_FAILURE, "getpwnam(%s)", name); - - return NULL; /* to make the compiler happy */ + +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) || (defined HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN) ) +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic ignored "-Wunreachable-code" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN +#pragma GCC diagnostic ignored "-Wunreachable-code-return" +#endif +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" +# ifdef HAVE_PRAGMA_CLANG_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN +# pragma clang diagnostic ignored "-Wunreachable-code-return" +# endif +#endif + /* Oh joy, adding unreachable "return" to make one compiler happy, + * and pragmas around to make other compilers happy, all at once! */ + return NULL; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) || (defined HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN) ) +#pragma GCC diagnostic pop +#endif } /* change to the user defined in the struct */ @@ -208,7 +282,7 @@ void writepid(const char *name) { char fn[SMALLBUF]; FILE *pidf; - int mask; + mode_t mask; /* use full path if present, else build filename in PIDPATH */ if (*name == '/') @@ -220,7 +294,9 @@ void writepid(const char *name) pidf = fopen(fn, "w"); if (pidf) { - fprintf(pidf, "%d\n", (int) getpid()); + intmax_t pid = (intmax_t)getpid(); + upsdebugx(1, "Saving PID %jd into %s", pid, fn); + fprintf(pidf, "%jd\n", pid); fclose(pidf); } else { upslog_with_errno(LOG_NOTICE, "writepid: fopen %s", fn); @@ -229,30 +305,17 @@ void writepid(const char *name) umask(mask); } -/* open pidfn, get the pid, then send it sig */ -int sendsignalfn(const char *pidfn, int sig) +/* send sig to pid, returns -1 for error, or + * zero for a successfully sent signal + */ +int sendsignalpid(pid_t pid, int sig) { - char buf[SMALLBUF]; - FILE *pidf; - int pid, ret; + int ret; - pidf = fopen(pidfn, "r"); - if (!pidf) { - upslog_with_errno(LOG_NOTICE, "fopen %s", pidfn); - return -1; - } - - if (fgets(buf, sizeof(buf), pidf) == NULL) { - upslogx(LOG_NOTICE, "Failed to read pid from %s", pidfn); - fclose(pidf); - return -1; - } - - pid = strtol(buf, (char **)NULL, 10); - - if (pid < 2) { - upslogx(LOG_NOTICE, "Ignoring invalid pid number %d", pid); - fclose(pidf); + if (pid < 2 || pid > get_max_pid_t()) { + upslogx(LOG_NOTICE, + "Ignoring invalid pid number %" PRIdMAX, + (intmax_t) pid); return -1; } @@ -261,21 +324,78 @@ int sendsignalfn(const char *pidfn, int sig) if (ret < 0) { perror("kill"); - fclose(pidf); return -1; } - /* now actually send it */ - ret = kill(pid, sig); + if (sig != 0) { + /* now actually send it */ + ret = kill(pid, sig); - if (ret < 0) { - perror("kill"); + if (ret < 0) { + perror("kill"); + return -1; + } + } + + return 0; +} + +/* parses string buffer into a pid_t if it passes + * a few sanity checks; returns -1 on error + */ +pid_t parsepid(const char *buf) +{ + pid_t pid = -1; + + /* assuming 10 digits for a long */ + intmax_t _pid = strtol(buf, (char **)NULL, 10); + if (_pid <= get_max_pid_t()) { + pid = (pid_t)_pid; + } else { + upslogx(LOG_NOTICE, "Received a pid number too big for a pid_t: %" PRIdMAX, _pid); + } + + return pid; +} + +/* open pidfn, get the pid, then send it sig + * returns negative codes for errors, or + * zero for a successfully sent signal + */ +int sendsignalfn(const char *pidfn, int sig) +{ + char buf[SMALLBUF]; + FILE *pidf; + pid_t pid = -1; + int ret = -1; + + pidf = fopen(pidfn, "r"); + if (!pidf) { + upslog_with_errno(LOG_NOTICE, "fopen %s", pidfn); + return -3; + } + + if (fgets(buf, sizeof(buf), pidf) == NULL) { + upslogx(LOG_NOTICE, "Failed to read pid from %s", pidfn); fclose(pidf); - return -1; + return -2; + } + /* TOTHINK: Original code only closed pidf before + * exiting the method, on error or "normally". + * Why not here? Do we want an (exclusive?) hold + * on it while being active in the method? + */ + + /* this method actively reports errors, if any */ + pid = parsepid(buf); + + if (pid >= 0) { + /* this method actively reports errors, if any */ + ret = sendsignalpid(pid, sig); } fclose(pidf); - return 0; + return ret; } int snprintfcat(char *dst, size_t size, const char *fmt, ...) @@ -285,14 +405,46 @@ int snprintfcat(char *dst, size_t size, const char *fmt, ...) int ret; size--; - assert(len <= size); + if (len > size) { + /* Do not truncate existing string */ + errno = ERANGE; + return -1; + } va_start(ap, fmt); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + /* Note: this code intentionally uses a caller-provided format string */ ret = vsnprintf(dst + len, size - len, fmt, ap); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif va_end(ap); dst[size] = '\0'; - return len + ret; + + /* Note: there is a standards loophole here: strlen() must return size_t + * and printf() family returns a signed int with negatives for errors. + * In theory it can overflow a 64-vs-32 bit range, or signed-vs-unsigned. + * In practice we hope to not have gigabytes-long config strings. + */ + if (ret < 0) { + return ret; + } +#ifdef INT_MAX + if ( ( (unsigned long long)len + (unsigned long long)ret ) >= (unsigned long long)INT_MAX ) { + errno = ERANGE; + return -1; + } +#endif + return (int)len + ret; } /* lazy way to send a signal if the program uses the PIDPATH */ @@ -319,7 +471,27 @@ static void vupslog(int priority, const char *fmt, va_list va, int use_strerror) int ret; char buf[LARGEBUF]; +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wformat-nonliteral" +#pragma clang diagnostic ignored "-Wformat-security" +#endif ret = vsnprintf(buf, sizeof(buf), fmt, va); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif if ((ret < 0) || (ret >= (int) sizeof(buf))) syslog(LOG_WARNING, "vupslog: vsnprintf needed more than %d bytes", @@ -329,20 +501,20 @@ static void vupslog(int priority, const char *fmt, va_list va, int use_strerror) snprintfcat(buf, sizeof(buf), ": %s", strerror(errno)); if (nut_debug_level > 0) { - static struct timeval start = { 0 }; + static struct timeval start = { 0, 0 }; struct timeval now; - + gettimeofday(&now, NULL); - + if (start.tv_sec == 0) { start = now; } - + if (start.tv_usec > now.tv_usec) { now.tv_usec += 1000000; now.tv_sec -= 1; } - + fprintf(stderr, "%4.0f.%06ld\t", difftime(now.tv_sec, start.tv_sec), (long)(now.tv_usec - start.tv_usec)); } @@ -353,7 +525,7 @@ static void vupslog(int priority, const char *fmt, va_list va, int use_strerror) } /* Return the default path for the directory containing configuration files */ -const char * confpath(void) +const char * confpath(void) { const char * path; @@ -364,33 +536,82 @@ const char * confpath(void) } /* Return the default path for the directory containing state files */ -const char * dflt_statepath(void) +const char * dflt_statepath(void) { const char * path; - if ((path = getenv("NUT_STATEPATH")) == NULL) + path = getenv("NUT_STATEPATH"); + if ( (path == NULL) || (*path == '\0') ) path = STATEPATH; return path; } -/* Return the alternate path for pid files */ -const char * altpidpath(void) +/* Return the alternate path for pid files, for processes running as non-root + * Per documentation and configure script, the fallback value is the + * state-file path as the daemon and drivers can write there too. + * Note that this differs from PIDPATH that higher-privileged daemons, such + * as upsmon, tend to use. + */ +const char * altpidpath(void) { + const char * path; + + path = getenv("NUT_ALTPIDPATH"); + if ( (path == NULL) || (*path == '\0') ) + path = getenv("NUT_STATEPATH"); + + if ( (path != NULL) && (*path != '\0') ) + return path; + #ifdef ALTPIDPATH return ALTPIDPATH; #else - return dflt_statepath(); +/* We assume, here and elsewhere, that at least STATEPATH is always defined */ + return STATEPATH; #endif } +/* Die with a standard message if socket filename is too long */ +void check_unix_socket_filename(const char *fn) { + struct sockaddr_un ssaddr; + if (strlen(fn) < sizeof(ssaddr.sun_path)) + return; + + /* Avoid useless truncated pathnames that + * other driver instances would conflict + * with, and upsd can not discover. + * Note this is quite short on many OSes + * varying 104-108 bytes (UNIX_PATH_MAX) + * as opposed to PATH_MAX or MAXPATHLEN + * typically of a kilobyte range. + */ + fatalx(EXIT_FAILURE, + "Can't create a unix domain socket: pathname '%s' " + "is too long (%zu) for 'struct sockaddr_un->sun_path' " + "on this system (%zu)", + fn, strlen(fn), sizeof(ssaddr.sun_path)); +} + /* logs the formatted string to any configured logging devices + the output of strerror(errno) */ void upslog_with_errno(int priority, const char *fmt, ...) { va_list va; va_start(va, fmt); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif vupslog(priority, fmt, va, 1); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif va_end(va); } @@ -400,44 +621,115 @@ void upslogx(int priority, const char *fmt, ...) va_list va; va_start(va, fmt); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif vupslog(priority, fmt, va, 0); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif va_end(va); } -void upsdebug_with_errno(int level, const char *fmt, ...) +void s_upsdebug_with_errno(int level, const char *fmt, ...) { va_list va; - + char fmt2[LARGEBUF]; + + /* Note: Thanks to macro wrapping, we do not quite need this + * test now, but we still need the "level" value to report + * below - when it is not zero. + */ if (nut_debug_level < level) return; +/* For debugging output, we want to prepend the debug level so the user can + * e.g. lower the level (less -D's on command line) to retain just the amount + * of logging info he needs to see at the moment. Using '-DDDDD' all the time + * is too brutal and needed high-level overview can be lost. This [D#] prefix + * can help limit this debug stream quicker, than experimentally picking ;) */ + if (level > 0) { + int ret; + ret = snprintf(fmt2, sizeof(fmt2), "[D%d] %s", level, fmt); + if ((ret < 0) || (ret >= (int) sizeof(fmt2))) { + syslog(LOG_WARNING, "upsdebug_with_errno: snprintf needed more than %d bytes", + LARGEBUF); + } else { + fmt = (const char *)fmt2; + } + } + va_start(va, fmt); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif vupslog(LOG_DEBUG, fmt, va, 1); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif va_end(va); } -void upsdebugx(int level, const char *fmt, ...) +void s_upsdebugx(int level, const char *fmt, ...) { va_list va; - + char fmt2[LARGEBUF]; + if (nut_debug_level < level) return; +/* See comments above in upsdebug_with_errno() - they apply here too. */ + if (level > 0) { + int ret; + ret = snprintf(fmt2, sizeof(fmt2), "[D%d] %s", level, fmt); + if ((ret < 0) || (ret >= (int) sizeof(fmt2))) { + syslog(LOG_WARNING, "upsdebugx: snprintf needed more than %d bytes", + LARGEBUF); + } else { + fmt = (const char *)fmt2; + } + } + va_start(va, fmt); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif vupslog(LOG_DEBUG, fmt, va, 0); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif va_end(va); } /* dump message msg and len bytes from buf to upsdebugx(level) in hexadecimal. (This function replaces Philippe Marzouk's original dump_hex() function) */ -void upsdebug_hex(int level, const char *msg, const void *buf, int len) +void s_upsdebug_hex(int level, const char *msg, const void *buf, size_t len) { char line[100]; int n; /* number of characters currently in line */ - int i; /* number of bytes output from buffer */ + size_t i; /* number of bytes output from buffer */ - n = snprintf(line, sizeof(line), "%s: (%d bytes) =>", msg, len); + n = snprintf(line, sizeof(line), "%s: (%zu bytes) =>", msg, len); + if (n < 0) goto failed; for (i = 0; i < len; i++) { @@ -447,9 +739,16 @@ void upsdebug_hex(int level, const char *msg, const void *buf, int len) } n = snprintfcat(line, sizeof(line), n ? " %02x" : "%02x", - ((unsigned char *)buf)[i]); + ((const unsigned char *)buf)[i]); + + if (n < 0) goto failed; } - upsdebugx(level, "%s", line); + + s_upsdebugx(level, "%s", line); + return; + +failed: + s_upsdebugx(level, "%s", "Failed to print a hex dump for debug"); } /* taken from www.asciitable.com */ @@ -489,29 +788,37 @@ static const char* ascii_symb[] = { }; /* dump message msg and len bytes from buf to upsdebugx(level) in ascii. */ -void upsdebug_ascii(int level, const char *msg, const void *buf, int len) +void s_upsdebug_ascii(int level, const char *msg, const void *buf, size_t len) { char line[256]; - int i; + int n; /* number of characters currently in line */ + size_t i; /* number of bytes output from buffer */ unsigned char ch; if (nut_debug_level < level) return; /* save cpu cycles */ - snprintf(line, sizeof(line), "%s", msg); + n = snprintf(line, sizeof(line), "%s", msg); + if (n < 0) goto failed; for (i=0; i= 0x80) - snprintfcat(line, sizeof(line), "%02Xh ", ch); + n = snprintfcat(line, sizeof(line), "%02Xh ", ch); else - snprintfcat(line, sizeof(line), "'%c' ", ch); + n = snprintfcat(line, sizeof(line), "'%c' ", ch); + + if (n < 0) goto failed; } - upsdebugx(level, "%s", line); + s_upsdebugx(level, "%s", line); + return; + +failed: + s_upsdebugx(level, "%s", "Failed to print an ASCII data dump for debug"); } static void vfatal(const char *fmt, va_list va, int use_strerror) @@ -521,7 +828,19 @@ static void vfatal(const char *fmt, va_list va, int use_strerror) if (xbit_test(upslog_flags, UPSLOG_SYSLOG_ON_FATAL)) xbit_set(&upslog_flags, UPSLOG_SYSLOG); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif vupslog(LOG_ERR, fmt, va, use_strerror); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif } void fatal_with_errno(int status, const char *fmt, ...) @@ -529,7 +848,19 @@ void fatal_with_errno(int status, const char *fmt, ...) va_list va; va_start(va, fmt); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif vfatal(fmt, va, (errno > 0) ? 1 : 0); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif va_end(va); exit(status); @@ -540,7 +871,19 @@ void fatalx(int status, const char *fmt, ...) va_list va; va_start(va, fmt); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif vfatal(fmt, va, 0); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif va_end(va); exit(status); @@ -587,7 +930,7 @@ char *xstrdup(const char *string) /* Read up to buflen bytes from fd and return the number of bytes read. If no data is available within d_sec + d_usec, return 0. On error, a value < 0 is returned (errno indicates error). */ -int select_read(const int fd, void *buf, const size_t buflen, const long d_sec, const long d_usec) +ssize_t select_read(const int fd, void *buf, const size_t buflen, const time_t d_sec, const suseconds_t d_usec) { int ret; fd_set fds; @@ -611,7 +954,7 @@ int select_read(const int fd, void *buf, const size_t buflen, const long d_sec, /* Write up to buflen bytes to fd and return the number of bytes written. If no data is available within d_sec + d_usec, return 0. On error, a value < 0 is returned (errno indicates error). */ -int select_write(const int fd, const void *buf, const size_t buflen, const long d_sec, const long d_usec) +ssize_t select_write(const int fd, const void *buf, const size_t buflen, const time_t d_sec, const suseconds_t d_usec) { int ret; fd_set fds; @@ -631,3 +974,106 @@ int select_write(const int fd, const void *buf, const size_t buflen, const long return write(fd, buf, buflen); } + + +/* FIXME: would be good to get more from /etc/ld.so.conf[.d] and/or + * LD_LIBRARY_PATH and a smarter dependency on build bitness; also + * note that different OSes can have their pathnames set up differently + * with regard to default/preferred bitness (maybe a "32" in the name + * should also be searched explicitly - again, IFF our build is 32-bit). + * + * General premise for this solution is that some parts of NUT (e.g. the + * nut-scanner tool, or DMF feature code) must be pre-built and distributed + * in binary packages, but only at run-time it gets to know which third-party + * libraries it should use for particular operations. This differs from e.g. + * distribution packages which group NUT driver binaries explicitly dynamically + * linked against certain OS-provided libraries for accessing this or that + * communications media and/or vendor protocol. + */ +static const char * search_paths[] = { + /* Use the library path (and bitness) provided during ./configure first */ + LIBDIR, + "/usr"LIBDIR, + "/usr/local"LIBDIR, +#ifdef BUILD_64 + /* Fall back to explicit preference of 64-bit paths as named on some OSes */ + "/usr/lib/64", + "/usr/lib64", +#endif + "/usr/lib", +#ifdef BUILD_64 + "/lib/64", + "/lib64", +#endif + "/lib", +#ifdef BUILD_64 + "/usr/local/lib/64", + "/usr/local/lib64", +#endif + "/usr/local/lib", +#ifdef AUTOTOOLS_TARGET_SHORT_ALIAS + "/usr/lib/" AUTOTOOLS_TARGET_SHORT_ALIAS, + "/usr/lib/gcc/" AUTOTOOLS_TARGET_SHORT_ALIAS, +#else +# ifdef AUTOTOOLS_HOST_SHORT_ALIAS + "/usr/lib/" AUTOTOOLS_HOST_SHORT_ALIAS, + "/usr/lib/gcc/" AUTOTOOLS_HOST_SHORT_ALIAS, +# else +# ifdef AUTOTOOLS_BUILD_SHORT_ALIAS + "/usr/lib/" AUTOTOOLS_BUILD_SHORT_ALIAS, + "/usr/lib/gcc/" AUTOTOOLS_BUILD_SHORT_ALIAS, +# endif +# endif +#endif +#ifdef AUTOTOOLS_TARGET_ALIAS + "/usr/lib/" AUTOTOOLS_TARGET_ALIAS, + "/usr/lib/gcc/" AUTOTOOLS_TARGET_ALIAS, +#else +# ifdef AUTOTOOLS_HOST_ALIAS + "/usr/lib/" AUTOTOOLS_HOST_ALIAS, + "/usr/lib/gcc/" AUTOTOOLS_HOST_ALIAS, +# else +# ifdef AUTOTOOLS_BUILD_ALIAS + "/usr/lib/" AUTOTOOLS_BUILD_ALIAS, + "/usr/lib/gcc/" AUTOTOOLS_BUILD_ALIAS, +# endif +# endif +#endif + NULL +}; + +char * get_libname(const char* base_libname) +{ + DIR *dp; + struct dirent *dirp; + int index = 0; + char *libname_path = NULL; + char current_test_path[LARGEBUF]; + size_t base_libname_length = strlen(base_libname); + + for(index = 0 ; (search_paths[index] != NULL) && (libname_path == NULL) ; index++) + { + memset(current_test_path, 0, LARGEBUF); + + if ((dp = opendir(search_paths[index])) == NULL) + continue; + + upsdebugx(2,"Looking for lib %s in directory #%d : %s", base_libname, index, search_paths[index]); + while ((dirp = readdir(dp)) != NULL) + { + upsdebugx(5,"Comparing lib %s with dirpath %s", base_libname, dirp->d_name); + int compres = strncmp(dirp->d_name, base_libname, base_libname_length); + if(compres == 0) { + snprintf(current_test_path, LARGEBUF, "%s/%s", search_paths[index], dirp->d_name); + libname_path = realpath(current_test_path, NULL); + upsdebugx(2,"Candidate path for lib %s is %s (realpath %s)", base_libname, current_test_path, (libname_path!=NULL)?libname_path:"NULL"); + if (libname_path != NULL) + break; + } + } + closedir(dp); + } + + upsdebugx(1,"Looking for lib %s, found %s", base_libname, (libname_path!=NULL)?libname_path:"NULL"); + return libname_path; +} diff --git a/common/parseconf.c b/common/parseconf.c index 7073eb1..7c284b7 100644 --- a/common/parseconf.c +++ b/common/parseconf.c @@ -26,7 +26,7 @@ * There is now a context buffer, and you call pconf_init to set it up. * All subsequent calls must have it as the first argument. There are * two entry points for parsing lines. You can have it read a file - * (pconf_file_begin and pconf_file_next), take lines directly from + * (pconf_file_begin and pconf_file_next), take lines directly from * the caller (pconf_line), or go along a character at a time (pconf_char). * The parsing is identical no matter how you feed it. * @@ -38,7 +38,7 @@ * * Fatal errors are those that involve memory allocation. If the user * defines an error handler when calling pconf_init, that function will - * be called with the error message before parseconf exits. By default + * be called with the error message before parseconf exits. By default * it will just write the message to stderr before exiting. * * Input vs. Output: @@ -57,12 +57,12 @@ * also allows you to join lines, allowing you to have logical lines * that span physical lines, just like you can do in some shells. * - * Lines normally end with a newline, but reaching EOF will also force + * Lines normally end with a newline, but reaching EOF will also force * parsing on what's been scanned so far. - * + * * Design: * - * Characters are read one at a time to drive the state machine. + * Characters are read one at a time to drive the state machine. * As words are completed (by hitting whitespace or ending a "" item), * they are committed to the next buffer in the arglist. realloc is * used, so the buffer can grow to handle bigger words. @@ -76,15 +76,20 @@ * */ +#include "common.h" + #include #include #include #include #include -#include +#include #include +#include #include "parseconf.h" +#include "attribute.h" +#include "nut_stdint.h" /* possible states */ @@ -97,6 +102,9 @@ #define STATE_ENDOFLINE 7 #define STATE_PARSEERR 8 +static void pconf_fatal(PCONF_CTX_t *ctx, const char *errtxt) + __attribute__((noreturn)); + static void pconf_fatal(PCONF_CTX_t *ctx, const char *errtxt) { if (ctx->errhandler) @@ -109,7 +117,7 @@ static void pconf_fatal(PCONF_CTX_t *ctx, const char *errtxt) static void add_arg_word(PCONF_CTX_t *ctx) { - int argpos; + size_t argpos; size_t wbuflen; /* this is where the new value goes */ @@ -122,13 +130,13 @@ static void add_arg_word(PCONF_CTX_t *ctx) ctx->maxargs = ctx->numargs; /* resize the lists */ - ctx->arglist = realloc(ctx->arglist, + ctx->arglist = realloc(ctx->arglist, sizeof(char *) * ctx->numargs); if (!ctx->arglist) pconf_fatal(ctx, "realloc arglist failed"); - ctx->argsize = realloc(ctx->argsize, + ctx->argsize = realloc(ctx->argsize, sizeof(size_t) * ctx->numargs); if (!ctx->argsize) @@ -171,7 +179,7 @@ static void addchar(PCONF_CTX_t *ctx) wbuflen = strlen(ctx->wordbuf); - /* CVE-2012-2944: only allow the subset Ascii charset from Space to ~ */ + /* CVE-2012-2944: only allow the subset of ASCII charset from Space to ~ */ if ((ctx->ch < 0x20) || (ctx->ch > 0x7f)) { fprintf(stderr, "addchar: discarding invalid character (0x%02x)!\n", ctx->ch); @@ -199,7 +207,7 @@ static void addchar(PCONF_CTX_t *ctx) ctx->wordptr = &ctx->wordbuf[wbuflen]; } - *ctx->wordptr++ = ctx->ch; + *ctx->wordptr++ = (char)ctx->ch; *ctx->wordptr = '\0'; } @@ -234,8 +242,8 @@ static int findwordstart(PCONF_CTX_t *ctx) return STATE_FINDEOL; /* space = not in a word yet, so loop back */ - if (isspace(ctx->ch)) - return STATE_FINDWORDSTART; + if (isspace((size_t)ctx->ch)) + return STATE_FINDWORDSTART; /* \ = literal = accept the next char blindly */ if (ctx->ch == '\\') @@ -255,7 +263,7 @@ static int findwordstart(PCONF_CTX_t *ctx) } return STATE_COLLECT; -} +} /* eat characters until the end of the line is found */ static int findeol(PCONF_CTX_t *ctx) @@ -274,7 +282,7 @@ static void pconf_seterr(PCONF_CTX_t *ctx, const char *errmsg) snprintf(ctx->errmsg, PCONF_ERR_LEN, "%s", errmsg); ctx->error = 1; -} +} /* quote characters inside a word bounded by "quotes" */ static int quotecollect(PCONF_CTX_t *ctx) @@ -291,7 +299,7 @@ static int quotecollect(PCONF_CTX_t *ctx) /* another " means we're done with this word */ if (ctx->ch == '"') { endofword(ctx); - + return STATE_FINDWORDSTART; } @@ -334,7 +342,7 @@ static int collect(PCONF_CTX_t *ctx) } /* space means the word is done */ - if (isspace(ctx->ch)) { + if (isspace((size_t)ctx->ch)) { endofword(ctx); return STATE_FINDWORDSTART; @@ -443,6 +451,9 @@ int pconf_file_begin(PCONF_CTX_t *ctx, const char *fn) return 0; } + /* prevent fd leaking to child processes */ + fcntl(fileno(ctx->f), F_SETFD, FD_CLOEXEC); + return 1; /* OK */ } @@ -571,7 +582,7 @@ int pconf_line(PCONF_CTX_t *ctx, const char *line) /* deal with any lingering characters */ /* still building a word? */ - if (ctx->wordptr != ctx->wordbuf) + if (ctx->wordptr != ctx->wordbuf) endofword(ctx); /* tie it off */ return 1; diff --git a/common/setenv.c b/common/setenv.c index 00f7a6b..85b8974 100644 --- a/common/setenv.c +++ b/common/setenv.c @@ -9,13 +9,14 @@ int nut_setenv(const char *name, const char *value, int overwrite) char *val; char *buffer; int rv; - + if (overwrite == 0) { val = getenv(name); if (val != NULL) { return 0; } } + buffer = xmalloc(strlen(value) + strlen(name) + 2); strcpy(buffer, name); strcat(buffer, "="); diff --git a/common/snprintf.c b/common/snprintf.c index a180269..0caa04e 100644 --- a/common/snprintf.c +++ b/common/snprintf.c @@ -35,9 +35,9 @@ * original. Also, there is now a builtin-test, just compile with: * gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm * and run snprintf for results. - * + * * Thomas Roessler 01/27/98 for mutt 0.89i - * The PGP code was using unsigned hexadecimal formats. + * The PGP code was using unsigned hexadecimal formats. * Unfortunately, unsigned formats simply didn't work. * * Michael Elkins 03/05/98 for mutt 0.90.8 @@ -54,7 +54,7 @@ #include "config.h" #include -# include +#include #include #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) @@ -102,14 +102,14 @@ /*int snprintf (char *str, size_t count, const char *fmt, ...);*/ /*int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);*/ -static void dopr (char *buffer, size_t maxlen, const char *format, +static void dopr (char *buffer, size_t maxlen, const char *format, va_list args); static void fmtstr (char *buffer, size_t *currlen, size_t maxlen, - char *value, int flags, int min, int max); + char *value, int flags, int min, int max); static void fmtint (char *buffer, size_t *currlen, size_t maxlen, - long value, int base, int min, int max, int flags); + long value, int base, int min, int max, int flags); static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, - LDOUBLE fvalue, int min, int max, int flags); + LDOUBLE fvalue, int min, int max, int flags); static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c ); /* @@ -137,10 +137,26 @@ static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c ); /* Conversion Flags */ #define DP_C_SHORT 1 +/* Note: Originally DP_C_SHORT converted to "short int" types, but modernish + * (C99+ or even earlier) standards require that the minimal type passed + * through variadic args '...' is an int, and smaller types are padded up + * to it - so value shifts in memory and erroneous access crashes can occur + * if smaller data is accessed blindly. Code below has been fixed to not pass + * "short int" anymore - it just casts the int to desired smaller type (and + * so drops the padding bits). */ #define DP_C_LONG 2 #define DP_C_LDOUBLE 3 #define DP_C_LLONG 4 +#ifdef C89PLUS +#undef C89PLUS +#endif + +#if defined(__STDC__) || defined(__STDC_VERSION__) +/* C89+ and C90+ code respectively */ +#define C89PLUS 1 +#endif + #define char_to_int(p) ((p)- '0') #define MAX(p,q) (((p) >= (q)) ? (p) : (q)) @@ -156,7 +172,7 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args) int flags; int cflags; size_t currlen; - + state = DP_S_DEFAULT; currlen = flags = cflags = min = 0; max = -1; @@ -164,237 +180,259 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args) while (state != DP_S_DONE) { - if ((ch == '\0') || (currlen >= maxlen)) + if ((ch == '\0') || (currlen >= maxlen)) state = DP_S_DONE; - switch(state) + switch(state) { case DP_S_DEFAULT: - if (ch == '%') - state = DP_S_FLAGS; - else - dopr_outch (buffer, &currlen, maxlen, ch); + if (ch == '%') + state = DP_S_FLAGS; + else + dopr_outch (buffer, &currlen, maxlen, ch); ch = *format++; break; case DP_S_FLAGS: - switch (ch) + switch (ch) { case '-': - flags |= DP_F_MINUS; + flags |= DP_F_MINUS; ch = *format++; - break; + break; case '+': - flags |= DP_F_PLUS; + flags |= DP_F_PLUS; ch = *format++; - break; + break; case ' ': - flags |= DP_F_SPACE; + flags |= DP_F_SPACE; ch = *format++; - break; + break; case '#': - flags |= DP_F_NUM; + flags |= DP_F_NUM; ch = *format++; - break; + break; case '0': - flags |= DP_F_ZERO; + flags |= DP_F_ZERO; ch = *format++; - break; + break; default: - state = DP_S_MIN; - break; + state = DP_S_MIN; + break; } break; case DP_S_MIN: - if (isdigit((unsigned char)ch)) + if (isdigit((unsigned char)ch)) { - min = 10*min + char_to_int (ch); - ch = *format++; - } - else if (ch == '*') + min = 10*min + char_to_int (ch); + ch = *format++; + } + else if (ch == '*') { - min = va_arg (args, int); - ch = *format++; - state = DP_S_DOT; - } - else - state = DP_S_DOT; + min = va_arg (args, int); + ch = *format++; + state = DP_S_DOT; + } + else + state = DP_S_DOT; break; case DP_S_DOT: - if (ch == '.') + if (ch == '.') { - state = DP_S_MAX; - ch = *format++; - } - else - state = DP_S_MOD; + state = DP_S_MAX; + ch = *format++; + } + else + state = DP_S_MOD; break; case DP_S_MAX: - if (isdigit((unsigned char)ch)) + if (isdigit((unsigned char)ch)) { - if (max < 0) - max = 0; - max = 10*max + char_to_int (ch); - ch = *format++; - } - else if (ch == '*') + if (max < 0) + max = 0; + max = 10*max + char_to_int (ch); + ch = *format++; + } + else if (ch == '*') { - max = va_arg (args, int); - ch = *format++; - state = DP_S_MOD; - } - else - state = DP_S_MOD; + max = va_arg (args, int); + ch = *format++; + state = DP_S_MOD; + } + else + state = DP_S_MOD; break; case DP_S_MOD: - switch (ch) + switch (ch) { case 'h': - cflags = DP_C_SHORT; - ch = *format++; - break; + cflags = DP_C_SHORT; + ch = *format++; + break; case 'l': - cflags = DP_C_LONG; - ch = *format++; - if (ch == 'l') { /* It's a long long */ - cflags = DP_C_LLONG; - ch = *format++; - } - break; + cflags = DP_C_LONG; + ch = *format++; + if (ch == 'l') { /* It's a long long */ + cflags = DP_C_LLONG; + ch = *format++; + } + break; case 'L': - cflags = DP_C_LDOUBLE; - ch = *format++; - break; + cflags = DP_C_LDOUBLE; + ch = *format++; + break; default: - break; + break; } state = DP_S_CONV; break; case DP_S_CONV: - switch (ch) + switch (ch) { case 'd': case 'i': - if (cflags == DP_C_SHORT) - value = va_arg (args, short int); - else if (cflags == DP_C_LONG) - value = va_arg (args, long int); - else if (cflags == DP_C_LLONG) - value = va_arg (args, LLONG); - else - value = va_arg (args, int); - fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); - break; + if (cflags == DP_C_SHORT) +#ifdef C89PLUS + value = (short int)va_arg (args, int); +#else + value = va_arg (args, short int); +#endif + else if (cflags == DP_C_LONG) + value = va_arg (args, long int); + else if (cflags == DP_C_LLONG) + value = va_arg (args, LLONG); + else + value = va_arg (args, int); + fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); + break; case 'o': - flags |= DP_F_UNSIGNED; - if (cflags == DP_C_SHORT) - value = va_arg (args, unsigned short int); - else if (cflags == DP_C_LONG) - value = (long)va_arg (args, unsigned long int); - else if (cflags == DP_C_LLONG) - value = (long)va_arg (args, unsigned LLONG); - else - value = (long)va_arg (args, unsigned int); - fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags); - break; + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) +#ifdef C89PLUS + value = (unsigned short int)va_arg (args, unsigned int); +#else + value = va_arg (args, unsigned short int); +#endif + else if (cflags == DP_C_LONG) + value = (long)va_arg (args, unsigned long int); + else if (cflags == DP_C_LLONG) + value = (long)va_arg (args, unsigned LLONG); + else + value = (long)va_arg (args, unsigned int); + fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags); + break; case 'u': - flags |= DP_F_UNSIGNED; - if (cflags == DP_C_SHORT) - value = va_arg (args, unsigned short int); - else if (cflags == DP_C_LONG) - value = (long)va_arg (args, unsigned long int); - else if (cflags == DP_C_LLONG) - value = (LLONG)va_arg (args, unsigned LLONG); - else - value = (long)va_arg (args, unsigned int); - fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); - break; + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) +#ifdef C89PLUS + value = (unsigned short int)va_arg (args, unsigned int); +#else + value = va_arg (args, unsigned short int); +#endif + else if (cflags == DP_C_LONG) + value = (long)va_arg (args, unsigned long int); + else if (cflags == DP_C_LLONG) + value = (LLONG)va_arg (args, unsigned LLONG); + else + value = (long)va_arg (args, unsigned int); + fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); + break; case 'X': - flags |= DP_F_UP; + flags |= DP_F_UP; + goto fallthrough_case_x; case 'x': - flags |= DP_F_UNSIGNED; - if (cflags == DP_C_SHORT) - value = va_arg (args, unsigned short int); - else if (cflags == DP_C_LONG) - value = (long)va_arg (args, unsigned long int); - else if (cflags == DP_C_LLONG) - value = (LLONG)va_arg (args, unsigned LLONG); - else - value = (long)va_arg (args, unsigned int); - fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags); - break; + fallthrough_case_x: + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) +#ifdef C89PLUS + value = (unsigned short int)va_arg (args, unsigned int); +#else + value = va_arg (args, unsigned short int); +#endif + else if (cflags == DP_C_LONG) + value = (long)va_arg (args, unsigned long int); + else if (cflags == DP_C_LLONG) + value = (LLONG)va_arg (args, unsigned LLONG); + else + value = (long)va_arg (args, unsigned int); + fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags); + break; case 'f': - if (cflags == DP_C_LDOUBLE) - fvalue = va_arg (args, LDOUBLE); - else - fvalue = va_arg (args, double); - /* um, floating point? */ - fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); - break; + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg (args, LDOUBLE); + else + fvalue = va_arg (args, double); + /* um, floating point? */ + fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); + break; case 'E': - flags |= DP_F_UP; + flags |= DP_F_UP; + goto fallthrough_case_e; case 'e': - if (cflags == DP_C_LDOUBLE) - fvalue = va_arg (args, LDOUBLE); - else - fvalue = va_arg (args, double); - break; + fallthrough_case_e: + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg (args, LDOUBLE); + else + fvalue = va_arg (args, double); + break; case 'G': - flags |= DP_F_UP; + flags |= DP_F_UP; + goto fallthrough_case_g; case 'g': - if (cflags == DP_C_LDOUBLE) - fvalue = va_arg (args, LDOUBLE); - else - fvalue = va_arg (args, double); - break; + fallthrough_case_g: + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg (args, LDOUBLE); + else + fvalue = va_arg (args, double); + break; case 'c': - dopr_outch (buffer, &currlen, maxlen, va_arg (args, int)); - break; + dopr_outch (buffer, &currlen, maxlen, va_arg (args, int)); + break; case 's': - strvalue = va_arg (args, char *); - if (max < 0) - max = maxlen; /* ie, no max */ - fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max); - break; + strvalue = va_arg (args, char *); + if (max < 0) + max = maxlen; /* ie, no max */ + fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max); + break; case 'p': - strvalue = va_arg (args, void *); - fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags); - break; + strvalue = va_arg (args, void *); + fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags); + break; case 'n': - if (cflags == DP_C_SHORT) - { - short int *num; - num = va_arg (args, short int *); - *num = currlen; - } - else if (cflags == DP_C_LONG) - { - long int *num; - num = va_arg (args, long int *); - *num = (long int)currlen; - } - else if (cflags == DP_C_LLONG) - { - LLONG *num; - num = va_arg (args, LLONG *); - *num = (LLONG)currlen; - } - else - { - int *num; - num = va_arg (args, int *); - *num = currlen; + if (cflags == DP_C_SHORT) + { + short int *num; + num = va_arg (args, short int *); + *num = currlen; } - break; + else if (cflags == DP_C_LONG) + { + long int *num; + num = va_arg (args, long int *); + *num = (long int)currlen; + } + else if (cflags == DP_C_LLONG) + { + LLONG *num; + num = va_arg (args, LLONG *); + *num = (LLONG)currlen; + } + else + { + int *num; + num = va_arg (args, int *); + *num = currlen; + } + break; case '%': - dopr_outch (buffer, &currlen, maxlen, ch); - break; + dopr_outch (buffer, &currlen, maxlen, ch); + break; case 'w': - /* not supported yet, treat as next char */ - ch = *format++; - break; + /* not supported yet, treat as next char */ + ch = *format++; + break; default: - /* Unknown, skip */ - break; + /* Unknown, skip */ + break; } ch = *format++; state = DP_S_DEFAULT; @@ -408,18 +446,18 @@ static void dopr (char *buffer, size_t maxlen, const char *format, va_list args) break; /* some picky compilers need this */ } } - if (currlen < maxlen - 1) + if (currlen < maxlen - 1) buffer[currlen] = '\0'; - else + else buffer[maxlen - 1] = '\0'; } static void fmtstr (char *buffer, size_t *currlen, size_t maxlen, - char *value, int flags, int min, int max) + char *value, int flags, int min, int max) { int padlen, strln; /* amount to pad */ int cnt = 0; - + if (value == 0) { value = ""; @@ -427,23 +465,23 @@ static void fmtstr (char *buffer, size_t *currlen, size_t maxlen, for (strln = 0; value[strln]; ++strln); /* strlen */ padlen = min - strln; - if (padlen < 0) + if (padlen < 0) padlen = 0; - if (flags & DP_F_MINUS) + if (flags & DP_F_MINUS) padlen = -padlen; /* Left Justify */ - while ((padlen > 0) && (cnt < max)) + while ((padlen > 0) && (cnt < max)) { dopr_outch (buffer, currlen, maxlen, ' '); --padlen; ++cnt; } - while (*value && (cnt < max)) + while (*value && (cnt < max)) { dopr_outch (buffer, currlen, maxlen, *value++); ++cnt; } - while ((padlen < 0) && (cnt < max)) + while ((padlen < 0) && (cnt < max)) { dopr_outch (buffer, currlen, maxlen, ' '); ++padlen; @@ -454,7 +492,7 @@ static void fmtstr (char *buffer, size_t *currlen, size_t maxlen, /* Have to handle DP_F_NUM (ie 0x and 0 alternates) */ static void fmtint (char *buffer, size_t *currlen, size_t maxlen, - long value, int base, int min, int max, int flags) + long value, int base, int min, int max, int flags) { int signvalue = 0; unsigned long uvalue; @@ -463,7 +501,7 @@ static void fmtint (char *buffer, size_t *currlen, size_t maxlen, int spadlen = 0; /* amount to space pad */ int zpadlen = 0; /* amount to zero pad */ int caps = 0; - + if (max < 0) max = 0; @@ -477,12 +515,12 @@ static void fmtint (char *buffer, size_t *currlen, size_t maxlen, } else if (flags & DP_F_PLUS) /* Do a sign (+/i) */ - signvalue = '+'; + signvalue = '+'; else if (flags & DP_F_SPACE) - signvalue = ' '; + signvalue = ' '; } - + if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ do { @@ -503,27 +541,27 @@ static void fmtint (char *buffer, size_t *currlen, size_t maxlen, zpadlen = MAX(zpadlen, spadlen); spadlen = 0; } - if (flags & DP_F_MINUS) + if (flags & DP_F_MINUS) spadlen = -spadlen; /* Left Justifty */ #ifdef DEBUG_SNPRINTF printf("zpad: %d, spad: %d, min: %d, max: %d, place: %d\n", - zpadlen, spadlen, min, max, place); + zpadlen, spadlen, min, max, place); #endif /* Spaces */ - while (spadlen > 0) + while (spadlen > 0) { dopr_outch (buffer, currlen, maxlen, ' '); --spadlen; } /* Sign */ - if (signvalue) + if (signvalue) dopr_outch (buffer, currlen, maxlen, signvalue); /* Zeros */ - if (zpadlen > 0) + if (zpadlen > 0) { while (zpadlen > 0) { @@ -533,9 +571,9 @@ static void fmtint (char *buffer, size_t *currlen, size_t maxlen, } /* Digits */ - while (place > 0) + while (place > 0) dopr_outch (buffer, currlen, maxlen, convert[--place]); - + /* Left Justified spaces */ while (spadlen < 0) { dopr_outch (buffer, currlen, maxlen, ' '); @@ -543,6 +581,7 @@ static void fmtint (char *buffer, size_t *currlen, size_t maxlen, } } +#ifndef HAVE_ABS_VAL static LDOUBLE abs_val (LDOUBLE value) { LDOUBLE result = value; @@ -552,7 +591,13 @@ static LDOUBLE abs_val (LDOUBLE value) return result; } +#endif +#ifndef HAVE_FCVT +/* The two routines that may get defined below are only used if we also don't + * have a fcvt() in the system. Defining and not using the routines may be a + * warning (fatal with -Werror), so we hide them here. */ +# ifndef HAVE_POW10 static LDOUBLE pow10 (int exp) { LDOUBLE result = 1; @@ -562,10 +607,12 @@ static LDOUBLE pow10 (int exp) result *= 10; exp--; } - + return result; } +# endif +# ifndef HAVE_ROUND static long round (LDOUBLE value) { long intpart; @@ -577,9 +624,11 @@ static long round (LDOUBLE value) return intpart; } +# endif +#endif /* HAVE_FCVT */ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, - LDOUBLE fvalue, int min, int max, int flags) + LDOUBLE fvalue, int min, int max, int flags) { int signvalue = 0; LDOUBLE ufvalue; @@ -601,12 +650,14 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, int iplace = 0; int fplace = 0; int padlen = 0; /* amount to pad */ - int zpadlen = 0; + int zpadlen = 0; +#ifndef HAVE_FCVT int caps = 0; long intpart; long fracpart; - - /* +#endif + + /* * AIX manpage says the default is 0, but Solaris says the default * is 6, and sprintf on AIX defaults to 6 */ @@ -622,7 +673,7 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, signvalue = '+'; else if (flags & DP_F_SPACE) - signvalue = ' '; + signvalue = ' '; #if 0 if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ @@ -631,8 +682,8 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, #ifndef HAVE_FCVT intpart = (long)ufvalue; - /* - * Sorry, we only support 9 digits past the decimal because of our + /* + * Sorry, we only support 9 digits past the decimal because of our * conversion method */ if (max > 9) @@ -650,8 +701,8 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, } #ifdef DEBUG_SNPRINTF - printf("fmtfp: %g %d.%d min=%d max=%d\n", - (double)fvalue, intpart, fracpart, min, max); + printf("fmtfp: %g %d.%d min=%d max=%d\n", + (double)fvalue, intpart, fracpart, min, max); #endif /* Convert integer part */ @@ -707,38 +758,38 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, fconvert[fplace++] = result[--r_length]; while ((dec_pt < 0) && (fplace < max)) { - fconvert[fplace++] = '0'; - dec_pt++; - } + fconvert[fplace++] = '0'; + dec_pt++; + } } else { int c; iplace=0; for(c=dec_pt; c; iconvert[iplace++] = result[--c]) - ; + ; iconvert[iplace] = '\0'; result += dec_pt; fplace = 0; - + for(c=(r_length-dec_pt); c; fconvert[fplace++] = result[--c]) - ; + ; } #endif /* fcvt */ - + /* -1 for decimal point, another -1 if we are printing a sign */ - padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); + padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); zpadlen = max - fplace; if (zpadlen < 0) zpadlen = 0; - if (padlen < 0) + if (padlen < 0) padlen = 0; - if (flags & DP_F_MINUS) + if (flags & DP_F_MINUS) padlen = -padlen; /* Left Justifty */ - if ((flags & DP_F_ZERO) && (padlen > 0)) + if ((flags & DP_F_ZERO) && (padlen > 0)) { - if (signvalue) + if (signvalue) { dopr_outch (buffer, currlen, maxlen, signvalue); --padlen; @@ -755,10 +806,10 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, dopr_outch (buffer, currlen, maxlen, ' '); --padlen; } - if (signvalue) + if (signvalue) dopr_outch (buffer, currlen, maxlen, signvalue); - while (iplace > 0) + while (iplace > 0) dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]); @@ -771,10 +822,10 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, * char to print out. */ if (max > 0) { - dopr_outch (buffer, currlen, maxlen, '.'); + dopr_outch (buffer, currlen, maxlen, '.'); - while (fplace > 0) - dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]); + while (fplace > 0) + dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]); } while (zpadlen > 0) @@ -783,7 +834,7 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, --zpadlen; } - while (padlen < 0) + while (padlen < 0) { dopr_outch (buffer, currlen, maxlen, ' '); ++padlen; @@ -820,7 +871,7 @@ static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c) char *fmt; #endif VA_LOCAL_DECL; - + VA_START (fmt); VA_SHIFT (str, char *); VA_SHIFT (count, size_t ); @@ -860,7 +911,7 @@ static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c) "%.1f", NULL }; - double fp_nums[] = { -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, + double fp_nums[] = { -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, 0.9996, 1.996, 4.136, 6442452944.1234, 0}; char *int_fmt[] = { "%-1.5d", @@ -888,9 +939,9 @@ static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c) sprintf (buf2, fp_fmt[x], fp_nums[y]); if (strcmp (buf1, buf2)) { - printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n", - fp_fmt[x], buf1, buf2); - fail++; + printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n", + fp_fmt[x], buf1, buf2); + fail++; } num++; } @@ -902,9 +953,9 @@ static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c) sprintf (buf2, int_fmt[x], int_nums[y]); if (strcmp (buf1, buf2)) { - printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n", - int_fmt[x], buf1, buf2); - fail++; + printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n", + int_fmt[x], buf1, buf2); + fail++; } num++; } diff --git a/common/state.c b/common/state.c index cb79e0f..280eac5 100644 --- a/common/state.c +++ b/common/state.c @@ -20,6 +20,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "config.h" /* must be first */ + #include #include #include @@ -124,7 +126,10 @@ static void st_tree_node_add(st_tree_t **nptr, st_tree_t *sptr) *nptr = sptr; } -/* remove a variable from a tree */ +/* remove a variable from a tree + * except for variables with ST_FLAG_IMMUTABLE + * (for override.* to survive) per issue #737 + */ int state_delinfo(st_tree_t **nptr, const char *var) { while (*nptr) { @@ -141,6 +146,11 @@ int state_delinfo(st_tree_t **nptr, const char *var) continue; } + if (node->flags & ST_FLAG_IMMUTABLE) { + upsdebugx(6, "%s: not deleting immutable variable [%s]", __func__, var); + return 0; + } + /* whatever is on the left, hang it off current right */ st_tree_node_add(&node->right, node->left); @@ -153,7 +163,7 @@ int state_delinfo(st_tree_t **nptr, const char *var) } return 0; /* not found */ -} +} /* interface */ @@ -218,7 +228,7 @@ static int st_tree_enum_add(enum_t **list, const char *enc) list = &(*list)->next; continue; } - + return 0; /* duplicate */ } @@ -303,7 +313,7 @@ int state_addrange(st_tree_t *root, const char *var, const int min, const int ma int state_setaux(st_tree_t *root, const char *var, const char *auxs) { st_tree_t *sttmp; - int aux; + long aux; /* find the tree node for var */ sttmp = state_tree_find(root, var); @@ -354,7 +364,7 @@ int state_getflags(st_tree_t *root, const char *var) return sttmp->flags; } -int state_getaux(st_tree_t *root, const char *var) +long state_getaux(st_tree_t *root, const char *var) { st_tree_t *sttmp; @@ -396,9 +406,9 @@ const range_t *state_getrangelist(st_tree_t *root, const char *var) return sttmp->range_list; } -void state_setflags(st_tree_t *root, const char *var, int numflags, char **flag) -{ - int i; +void state_setflags(st_tree_t *root, const char *var, size_t numflags, char **flag) +{ + size_t i; st_tree_t *sttmp; /* find the tree node for var */ @@ -424,6 +434,11 @@ void state_setflags(st_tree_t *root, const char *var, int numflags, char **flag) continue; } + if (!strcasecmp(flag[i], "NUMBER")) { + sttmp->flags |= ST_FLAG_NUMBER; + continue; + } + upsdebugx(2, "Unrecognized flag [%s]", flag[i]); } } diff --git a/common/str.c b/common/str.c index 092efcf..295f450 100644 --- a/common/str.c +++ b/common/str.c @@ -20,12 +20,21 @@ * */ +#include "config.h" /* must be first */ + #include #include -#include #include -#include +#ifdef HAVE_STRING_H +#include /* for strdup() and many others */ +#endif + +#ifdef HAVE_STRINGS_H +#include /* for strncasecmp() and strcasecmp() */ +#endif + +#include "nut_stdint.h" #include "str.h" char *str_trim(char *string, const char character) @@ -109,7 +118,7 @@ char *str_ltrim_space(char *string) while ( *string != '\0' && - isspace(*string) + isspace((size_t)*string) ) memmove(string, string + 1, strlen(string)); @@ -130,7 +139,7 @@ char *str_rtrim_space(char *string) while ( ptr >= string && - isspace(*ptr) + isspace((size_t)*ptr) ) *ptr-- = '\0'; @@ -252,7 +261,7 @@ int str_to_short(const char *string, short *number, const int base) return 0; } - *number = num; + *number = (short)num; return 1; } @@ -273,7 +282,7 @@ int str_to_short_strict(const char *string, short *number, const int base) return 0; } - *number = num; + *number = (short)num; return 1; } @@ -291,7 +300,7 @@ int str_to_ushort(const char *string, unsigned short *number, const int base) return 0; } - *number = num; + *number = (unsigned short)num; return 1; } @@ -309,13 +318,13 @@ int str_to_ushort_strict(const char *string, unsigned short *number, const int b return 0; } - *number = num; + *number = (unsigned short)num; return 1; } int str_to_int(const char *string, int *number, const int base) { - long num; + long num; /* long >= int, make sure we fit well */ *number = 0; @@ -330,13 +339,13 @@ int str_to_int(const char *string, int *number, const int base) return 0; } - *number = num; + *number = (int)num; return 1; } int str_to_int_strict(const char *string, int *number, const int base) { - long num; + long num; /* long >= int, make sure we fit well */ *number = 0; @@ -351,13 +360,13 @@ int str_to_int_strict(const char *string, int *number, const int base) return 0; } - *number = num; + *number = (int)num; return 1; } int str_to_uint(const char *string, unsigned int *number, const int base) { - unsigned long num; + unsigned long num; /* long >= int, make sure we fit well */ *number = 0; @@ -369,13 +378,13 @@ int str_to_uint(const char *string, unsigned int *number, const int base) return 0; } - *number = num; + *number = (unsigned int)num; return 1; } int str_to_uint_strict(const char *string, unsigned int *number, const int base) { - unsigned long num; + unsigned long num; /* long >= int, make sure we fit well */ *number = 0; @@ -387,7 +396,7 @@ int str_to_uint_strict(const char *string, unsigned int *number, const int base) return 0; } - *number = num; + *number = (unsigned int)num; return 1; } @@ -429,7 +438,7 @@ int str_to_long_strict(const char *string, long *number, const int base) if ( string == NULL || *string == '\0' || - isspace(*string) + isspace((size_t)*string) ) { errno = EINVAL; return 0; @@ -495,7 +504,7 @@ int str_to_ulong_strict(const char *string, unsigned long *number, const int bas *string == '\0' || *string == '+' || *string == '-' || - isspace(*string) + isspace((size_t)*string) ) { errno = EINVAL; return 0; @@ -559,7 +568,7 @@ int str_to_double_strict(const char *string, double *number, const int base) if ( string == NULL || *string == '\0' || - isspace(*string) + isspace((size_t)*string) ) { errno = EINVAL; return 0; @@ -605,3 +614,16 @@ int str_to_double_strict(const char *string, double *number, const int base) return 1; } + +int str_ends_with(const char *s, const char *suff) { + size_t slen; + size_t sufflen; + + if (!s) return 0; /* null string does not end with anything */ + if (!suff) return 1; /* null suffix tails anything */ + + slen = strlen(s); + sufflen = strlen(suff); + + return (slen >= sufflen) && (!memcmp(s + slen - sufflen, suff, sufflen)); +} diff --git a/common/strerror.c b/common/strerror.c index b5cecb9..e00f208 100644 --- a/common/strerror.c +++ b/common/strerror.c @@ -11,6 +11,16 @@ char *strerror(int errnum) { static char buf[32]; +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_BREAK +#pragma GCC diagnostic ignored "-Wunreachable-code-break" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic ignored "-Wunreachable-code" +#endif + switch (errnum) { #if defined (EPERM) case EPERM: @@ -498,6 +508,11 @@ char *strerror(int errnum) /* Fallback: just print the error number */ snprintf(buf, sizeof(buf), "Error %d", errnum); return buf; + +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic pop +#endif + } #endif /* HAVE_STRERROR */ diff --git a/common/upsconf.c b/common/upsconf.c index 867163b..bb7fd35 100644 --- a/common/upsconf.c +++ b/common/upsconf.c @@ -17,6 +17,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "config.h" /* must be the first header */ + #include #include #include @@ -29,14 +31,14 @@ static char *ups_section; /* handle arguments separated by parseconf */ -static void conf_args(int numargs, char **arg) +static void conf_args(size_t numargs, char **arg) { if (numargs < 1) return; /* look for section headers - [upsname] */ if ((arg[0][0] == '[') && (arg[0][strlen(arg[0])-1] == ']')) { - + free(ups_section); arg[0][strlen(arg[0])-1] = '\0'; diff --git a/conf/Makefile.am b/conf/Makefile.am index 95c0173..847c299 100644 --- a/conf/Makefile.am +++ b/conf/Makefile.am @@ -15,3 +15,27 @@ endif dist_sysconf_DATA = $(SECFILES) $(PUBFILES) $(CGI_INSTALL) nodist_sysconf_DATA = upssched.conf.sample upsmon.conf.sample + +SPELLCHECK_SRC = $(dist_sysconf_DATA) \ + upssched.conf.sample.in upsmon.conf.sample.in + +# NOTE: Due to portability, we do not use a GNU percent-wildcard extension: +#%-spellchecked: % Makefile.am $(top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) +# $(MAKE) -s -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC_ONE="$<" SPELLCHECK_DIR="$(srcdir)" $@ + +# NOTE: Portable suffix rules do not allow prerequisites, so we shim them here +# by a wildcard target in case the make implementation can put the two together. +*-spellchecked: Makefile.am $(top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) + +.sample.sample-spellchecked: + $(MAKE) -s -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC_ONE="$<" SPELLCHECK_DIR="$(srcdir)" $@ + +.in.in-spellchecked: + $(MAKE) -s -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC_ONE="$<" SPELLCHECK_DIR="$(srcdir)" $@ + +spellcheck spellcheck-interactive spellcheck-sortdict: + $(MAKE) -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC="$(SPELLCHECK_SRC)" SPELLCHECK_DIR="$(srcdir)" $@ + + +MAINTAINERCLEANFILES = Makefile.in .dirstamp +CLEANFILES = *.pdf *.html *-spellchecked diff --git a/conf/Makefile.in b/conf/Makefile.in index cc5884c..7858703 100644 --- a/conf/Makefile.in +++ b/conf/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.16.3 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -17,7 +17,17 @@ # Network UPS Tools: conf VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -82,21 +92,24 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = conf -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(srcdir)/upsmon.conf.sample.in \ - $(srcdir)/upssched.conf.sample.in \ - $(am__dist_sysconf_DATA_DIST) ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nut_arg_with.m4 \ $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ $(top_srcdir)/m4/nut_check_libavahi.m4 \ $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ $(top_srcdir)/m4/nut_check_libgd.m4 \ $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ $(top_srcdir)/m4/nut_check_libneon.m4 \ $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ $(top_srcdir)/m4/nut_check_libnss.m4 \ @@ -105,11 +118,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ $(top_srcdir)/m4/nut_check_libusb.m4 \ $(top_srcdir)/m4/nut_check_libwrap.m4 \ $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ $(top_srcdir)/m4/nut_type_socklen_t.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__dist_sysconf_DATA_DIST) \ + $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = upsmon.conf.sample upssched.conf.sample @@ -167,6 +187,9 @@ am__uninstall_files_from_dir = { \ am__installdirs = "$(DESTDIR)$(sysconfdir)" "$(DESTDIR)$(sysconfdir)" DATA = $(dist_sysconf_DATA) $(nodist_sysconf_DATA) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in \ + $(srcdir)/upsmon.conf.sample.in \ + $(srcdir)/upssched.conf.sample.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) A2X = @A2X@ ACLOCAL = @ACLOCAL@ @@ -175,6 +198,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -185,6 +209,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -198,6 +223,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -210,6 +236,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -227,6 +254,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -237,21 +266,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -271,6 +308,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -284,6 +324,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -301,6 +342,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -314,6 +356,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -339,12 +384,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -364,9 +411,15 @@ CGIPUB = hosts.conf.sample upsset.conf.sample upsstats.html.sample \ @WITH_CGI_TRUE@CGI_INSTALL = $(CGIPUB) dist_sysconf_DATA = $(SECFILES) $(PUBFILES) $(CGI_INSTALL) nodist_sysconf_DATA = upssched.conf.sample upsmon.conf.sample +SPELLCHECK_SRC = $(dist_sysconf_DATA) \ + upssched.conf.sample.in upsmon.conf.sample.in + +MAINTAINERCLEANFILES = Makefile.in .dirstamp +CLEANFILES = *.pdf *.html *-spellchecked all: all-am .SUFFIXES: +.SUFFIXES: .in .in-spellchecked .sample .sample-spellchecked $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ @@ -379,14 +432,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu conf/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu conf/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -456,7 +508,10 @@ ctags CTAGS: cscope cscopelist: -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -515,6 +570,7 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) @@ -523,6 +579,7 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am @@ -606,6 +663,25 @@ uninstall-am: uninstall-dist_sysconfDATA uninstall-nodist_sysconfDATA uninstall-am uninstall-dist_sysconfDATA \ uninstall-nodist_sysconfDATA +.PRECIOUS: Makefile + + +# NOTE: Due to portability, we do not use a GNU percent-wildcard extension: +#%-spellchecked: % Makefile.am $(top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) +# $(MAKE) -s -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC_ONE="$<" SPELLCHECK_DIR="$(srcdir)" $@ + +# NOTE: Portable suffix rules do not allow prerequisites, so we shim them here +# by a wildcard target in case the make implementation can put the two together. +*-spellchecked: Makefile.am $(top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) + +.sample.sample-spellchecked: + $(MAKE) -s -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC_ONE="$<" SPELLCHECK_DIR="$(srcdir)" $@ + +.in.in-spellchecked: + $(MAKE) -s -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC_ONE="$<" SPELLCHECK_DIR="$(srcdir)" $@ + +spellcheck spellcheck-interactive spellcheck-sortdict: + $(MAKE) -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC="$(SPELLCHECK_SRC)" SPELLCHECK_DIR="$(srcdir)" $@ # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/conf/hosts.conf.sample b/conf/hosts.conf.sample index 9a4b669..24beb82 100644 --- a/conf/hosts.conf.sample +++ b/conf/hosts.conf.sample @@ -22,7 +22,7 @@ # # MONITOR "" # -# Examples: +# Examples: # # MONITOR myups@localhost "Local UPS" # MONITOR su2200@10.64.1.1 "Finance department" diff --git a/conf/nut.conf.sample b/conf/nut.conf.sample index 9309825..ebf6c04 100644 --- a/conf/nut.conf.sample +++ b/conf/nut.conf.sample @@ -14,7 +14,7 @@ # The values of MODE can be: # - none: NUT is not configured, or use the Integrated Power Management, or use # some external system to startup NUT components. So nothing is to be started. -# - standalone: This mode address a local only configuration, with 1 UPS +# - standalone: This mode address a local only configuration, with 1 UPS # protecting the local system. This implies to start the 3 NUT layers (driver, # upsd and upsmon) and the matching configuration files. This mode can also # address UPS redundancy. @@ -26,7 +26,14 @@ # - netclient: this mode only requires upsmon. # # IMPORTANT NOTE: -# This file is intended to be sourced by shell scripts. +# This file is intended to be sourced by standard POSIX shell scripts (so +# there is no guaranteed `export VAR=VAL` syntax) and by systemd on Linux. # You MUST NOT use spaces around the equal sign! MODE=none + +# Uncomment this to allow starting the service even if ups.conf has no device +# sections at the moment. This environment variable overrides the built-in +# "false" and an optional same-named default flag that can be set in upsd.conf: +#ALLOW_NO_DEVICE=true +#export ALLOW_NO_DEVICE diff --git a/conf/ups.conf.sample b/conf/ups.conf.sample index d8faef2..a86a845 100644 --- a/conf/ups.conf.sample +++ b/conf/ups.conf.sample @@ -2,7 +2,7 @@ # # --- SECURITY NOTE --- # -# If you use snmp-ups and set a community string in here, you +# If you use snmp-ups and set a community string in here, you # will have to secure this file to keep other users from obtaining # that string. It needs to be readable by upsdrvctl and any drivers, # and by upsd. @@ -14,69 +14,98 @@ # USB devices and SNMP devices are also supported. # # This file is used by upsdrvctl to start and stop your driver(s), and -# is also used by upsd to determine which drivers to monitor. The +# is also used by upsd to determine which drivers to monitor. The # drivers themselves also read this file for configuration directives. # # The general form is: -# +# # [upsname] # driver = # port = -# < any other directives here > +# < any other directives here > # # The section header ([upsname]) can be just about anything as long as -# it is a single word inside brackets. upsd uses this to uniquely +# it is a single word inside brackets. upsd uses this to uniquely # identify a UPS on this system. # # If you have a UPS called snoopy, your section header would be "[snoopy]". # On a system called "doghouse", the line in your upsmon.conf to monitor -# it would look something like this: +# and manage it would look something like this: # -# MONITOR snoopy@doghouse 1 upsmonuser mypassword master +# MONITOR snoopy@doghouse 1 upsmonuser mypassword primary # -# It might look like this if monitoring in slave mode: +# It might look like this if monitoring in "secondary" mode (without any +# ability to directly manage the UPS) from a different system: # -# MONITOR snoopy@doghouse 1 upsmonuser mypassword slave +# MONITOR snoopy@doghouse 1 upsmonuser mypassword secondary # # Configuration directives # ------------------------ -# -# These directives are common to all drivers that support ups.conf: # -# driver: REQUIRED. Specify the program to run to talk to this UPS. -# apcsmart, bestups, and sec are some examples. +# These directives are used by upsdrvctl only and should be specified outside +# of a driver definition: # -# port: REQUIRED. The serial port where your UPS is connected. -# /dev/ttyS0 is usually the first port on Linux boxes, for example. +# maxretry: OPTIONAL. Specify the number of attempts to start the driver(s), +# in case of failure, before giving up. A delay of 'retrydelay' is +# inserted between each attempt. Caution should be taken when using +# this option, since it can impact the time taken by your system to +# start. # -# sdorder: optional. When you have multiple UPSes on your system, you -# usually need to turn them off in a certain order. upsdrvctl -# shuts down all the 0s, then the 1s, 2s, and so on. To exclude -# a UPS from the shutdown sequence, set this to -1. +# The built-in default is 1 attempt. # -# The default value for this parameter is 0. +# retrydelay: OPTIONAL. Specify the delay between each restart attempt of the +# driver(s), as specified by 'maxretry'. Caution should be taken +# when using this option, since it can impact the time taken by your +# system to start. # -# nolock: optional, and not recommended for use in this file. +# The default is 5 seconds. # -# If you put nolock in here, the driver will not lock the -# serial port every time it starts. This may allow other -# processes to seize the port if you start more than one by -# mistake. +# chroot: OPTIONAL. Used for securing. See man page for details. # -# This is only intended to be used on systems where locking -# absolutely must be disabled for the software to work. +# driverpath: OPTIONAL. Used for custom setups. See man page for details. # -# maxstartdelay: optional. This can be set as a global variable +# nowait: OPTIONAL. Tell upsdrvctl to not wait at all for the driver(s) +# to execute the requested command. Fire and forget. +# +# pollinterval: OPTIONAL. The status of the UPS will be refreshed after a +# maximum delay which is controlled by this setting (default +# 2 seconds). This may be useful if the driver is creating too +# much of a load on your system or network. +# Note that some drivers also have an option called *pollfreq* +# which controls how frequently some of the less critical +# parameters are polled. See respective driver man pages. +# + +# Set maxretry to 3 by default, this should mitigate race with slow devices: +maxretry = 3 + +# These directives can be set outside and inside a driver definition, with +# slightly different meanings per context: +# +# maxstartdelay: OPTIONAL. This can be set as a global variable # above your first UPS definition and it can also be # set in a UPS section. This value controls how long # upsdrvctl will wait for the driver to finish starting. # This keeps your system from getting stuck due to a # broken driver or UPS. -# # The default is 45 seconds. # -# synchronous: optional. The driver work by default in asynchronous -# mode (i.e *synchronous=no*). This means that all data +# debug_min: OPTIONAL. Specify a minimum debug level for all driver daemons +# (when specified at global level), or for this driver daemon +# (when specified in a driver section), e.g. for troubleshooting +# a deployment. This does not directly impact the foreground or +# background running mode. If both the global and driver level +# `debug_min` are set, the driver-level setting takes precedence. +# Command-line option `-D` can only increase this verbosity level. +# +# user, group: OPTIONAL. Overrides the compiled-in (also global-section, +# when used in driver section) default unprivileged user/group +# name for NUT device driver. Impacts access rights used for +# the socket file access (group) and communication ports (user). +# +# synchronous: OPTIONAL. The driver work by default in asynchronous +# mode (like *no*) with fallback to synchronous if sending +# fails (i.e *synchronous=auto*). This means that all data # are pushed by the driver on the communication socket to # upsd (Unix socket on Unix, Named pipe on Windows) without # waiting for these data to be actually consumed. With @@ -91,9 +120,63 @@ # The default is 'no' (i.e. asynchronous mode) for backward # compatibility of the driver behavior. # + +# These directives are common to all drivers that support ups.conf: +# +# driver: REQUIRED. Specify the program to run to talk to this UPS. +# apcsmart, bestups, and sec are some examples. +# +# port: REQUIRED. The serial port where your UPS is connected. +# /dev/ttyS0 is usually the first port on Linux boxes, for example. +# +# sdorder: OPTIONAL. When you have multiple UPSes on your system, you +# usually need to turn them off in a certain order. upsdrvctl +# shuts down all the 0s, then the 1s, 2s, and so on. To exclude +# a UPS from the shutdown sequence, set this to -1. +# +# The default value for this parameter is 0. +# +# desc: optional, to keep a note of the UPS purpose, location, etc. +# +# nolock: optional, and not recommended for use in this file. +# +# If you put nolock in here, the driver will not lock the +# serial port every time it starts. This may allow other +# processes to seize the port if you start more than one by +# mistake. +# +# This is only intended to be used on systems where locking +# absolutely must be disabled for the software to work. +# +# ignorelb: OPTIONAL. Ignore low battery condition reported by device, +# and evaluate remaining battery charge or runtime instead. +# See man page for details. +# +# usb_set_altinterface(=num): OPTIONAL. Require that NUT calls this method +# to set the interface, even if 0 (default). Some devices require +# the call to initialize; others however can get stuck due to it - +# so it is not called by default. Yet others can be composite +# devices which use a non-zero interface to represent the UPS. +# +# default.: OPTIONAL. Set a default value for which is +# used in case the UPS doesn't provide a value, but which will be +# overwritten if a value is available from the UPS, e.g.: +# default.input.voltage.nominal = 230 +# will report the nominal input voltage to be 230, unless the UPS +# eventually tells us differently. +# +# override.: OPTIONAL. Set a value for that overrides +# (for NUT) any value that may be read from the UPS. +# Used for overriding values from the UPS that are clearly wrong +# (e.g. some devices report wrong values for battery voltage): +# override.battery.voltage.nominal = 12 +# Use with caution! This will only change the appearance of the +# variable to the outside world (and NUT calculations), internally +# in the UPS the original value is used. +# # Anything else is passed through to the hardware-specific part of # the driver. -# +# # Examples # -------- # @@ -101,19 +184,19 @@ # driver on /dev/ttyS0 is: # # [powerpal] -# driver = blazer_ser -# port = /dev/ttyS0 -# desc = "Web server" +# driver = blazer_ser +# port = /dev/ttyS0 +# desc = "Web server" # # If your UPS driver requires additional settings, you can specify them # here. For example, if it supports a setting of "1234" for the # variable "cable", it would look like this: -# +# # [myups] -# driver = mydriver -# port = /dev/ttyS1 -# cable = 1234 -# desc = "Something descriptive" +# driver = mydriver +# port = /dev/ttyS1 +# cable = 1234 +# desc = "Something descriptive" # # To find out if your driver supports any extra settings, start it with # the -h option and/or read the driver's documentation. diff --git a/conf/upsd.conf.sample b/conf/upsd.conf.sample index 7292777..fb420e3 100644 --- a/conf/upsd.conf.sample +++ b/conf/upsd.conf.sample @@ -5,6 +5,8 @@ # It should only be readable by the user that upsd becomes. See the FAQ. # # Each entry below provides usage and default value. +# +# For more information, refer to upsd.conf manual page. # ======================================================================= # MAXAGE @@ -19,6 +21,29 @@ # the data fresh within the normal 15 second interval. Watch the syslog # for notifications from upsd about staleness. +# ======================================================================= +# TRACKINGDELAY +# TRACKINGDELAY 3600 +# +# This defaults to 1 hour. When instant commands and variables setting status +# tracking is enabled, status execution information are kept during this +# amount of time, and then cleaned up. + +# ======================================================================= +# ALLOW_NO_DEVICE +# ALLOW_NO_DEVICE true +# +# Normally upsd requires that at least one device section is defined in ups.conf +# when the daemon starts, to serve its data. For automatically managed services +# it may be preferred to have upsd always running, and reload the configuration +# when power devices become defined. +# +# Boolean values 'true', 'yes', 'on' and '1' mean that the server would not +# refuse to start with zero device sections found in ups.conf. +# +# Boolean values 'false', 'no', 'off' and '0' mean that the server should refuse +# to start if zero device sections were found in ups.conf. This is the default. + # ======================================================================= # STATEPATH # STATEPATH /var/run/nut @@ -27,15 +52,17 @@ # than the default that was compiled into the program. # ======================================================================= -# LISTEN
[] +# LISTEN [] # LISTEN 127.0.0.1 3493 # LISTEN ::1 3493 +# LISTEN myhostname 83493 +# LISTEN myhostname.mydomain # # This defaults to the localhost listening addresses and port 3493. # In case of IP v4 or v6 disabled kernel, only the available one will be used. # -# You may specify each interface you want upsd to listen on for connections, -# optionally with a port number. +# You may specify each interface IP address or name that you want upsd to +# listen on for connections, optionally with a port number. # # You may need this if you have multiple interfaces on your machine and # you don't want upsd to listen to all interfaces (for instance on a @@ -74,9 +101,9 @@ # # When compiled with SSL support with NSS backend, # you can enter the certificate path here. -# Certificates are stored in a dedicated database (splitted in 3 files). +# Certificates are stored in a dedicated database (split into 3 files). # Specify the path of the database directory. -# +# # See 'docs/security.txt' or the Security chapter of NUT user manual # for more information on the SSL support in NUT. @@ -88,7 +115,7 @@ # you can specify the certificate name to retrieve from database to # authenticate itself and the password # required to access certificate related private key. -# +# # See 'docs/security.txt' or the Security chapter of NUT user manual # for more information on the SSL support in NUT. @@ -103,7 +130,39 @@ # - 0 to not request to clients to provide any certificate # - 1 to require to all clients a certificate # - 2 to require to all clients a valid certificate -# +# # See 'docs/security.txt' or the Security chapter of NUT user manual # for more information on the SSL support in NUT. +# ======================================================================= +# DISABLE_WEAK_SSL +# DISABLE_WEAK_SSL true +# +# Tell upsd to disable older/weak SSL/TLS protocols and ciphers. +# +# With relatively recent versions of OpenSSL or NSS it will be restricted +# to TLSv1.2 or better. +# +# Unless you have really ancient clients, you probably want to enable this. +# Currently disabled by default to ensure compatibility with existing setups. + +# ======================================================================= +# DEBUG_MIN +# DEBUG_MIN 2 +# +# Optionally specify a minimum debug level for `upsd` data daemon, e.g. for +# troubleshooting a deployment, without impacting foreground or background +# running mode directly, and without need to edit init-scripts or service +# unit definitions. Note that command-line option `-D` can only increase +# this verbosity level. +# +# NOTE: if the running daemon receives a `reload` command, presence of the +# `DEBUG_MIN NUMBER` value in the configuration file can be used to tune +# debugging verbosity in the running service daemon (it is recommended to +# comment it away or set the minimum to explicit zero when done, to avoid +# huge journals and I/O system abuse). Keep in mind that for this run-time +# tuning, the `DEBUG_MIN` value *present* in *reloaded* configuration files +# is applied instantly and overrides any previously set value, from file +# or CLI options, regardless of older logging level being higher or lower +# than the newly found number; a missing (or commented away) value however +# does not change the previously active logging verbosity. diff --git a/conf/upsd.users.sample b/conf/upsd.users.sample index ec78eb5..c6b9f36 100644 --- a/conf/upsd.users.sample +++ b/conf/upsd.users.sample @@ -18,25 +18,25 @@ # # -------------------------------------------------------------------------- # -# actions: Let the user do certain things with upsd. -# +# actions: Let the user do certain things with upsd. +# # Valid actions are: # -# SET - change the value of certain variables in the UPS +# SET - change the value of certain variables in the UPS # FSD - set the "forced shutdown" flag in the UPS -# +# # -------------------------------------------------------------------------- # # instcmds: Let the user initiate specific instant commands. Use "ALL" -# to grant all commands automatically. There are many possible +# to grant all commands automatically. There are many possible # commands, so use 'upscmd -l' to see what your hardware supports. Here # are a few examples: # -# test.panel.start - Start a front panel test -# test.battery.start - Start battery test -# test.battery.stop - Stop battery test -# calibrate.start - Start calibration -# calibrate.stop - Stop calibration +# test.panel.start - Start a front panel test +# test.battery.start - Start battery test +# test.battery.stop - Stop battery test +# calibrate.start - Start calibration +# calibrate.stop - Stop calibration # # -------------------------------------------------------------------------- # @@ -61,12 +61,15 @@ # # To add a user for your upsmon, use this example: # -# [upsmon] -# password = pass -# upsmon master +# [upsmon] +# password = pass +# upsmon primary # or -# upsmon slave +# upsmon secondary # # The matching MONITOR line in your upsmon.conf would look like this: # -# MONITOR myups@localhost 1 upsmon pass master (or slave) +# MONITOR myups@localhost 1 upsmon pass primary (or secondary) +# +# See comments in the upsmon.conf(.sample) file for details about this +# keyword and the difference of NUT secondary and primary systems. diff --git a/conf/upsmon.conf.sample.in b/conf/upsmon.conf.sample.in index 8703eb4..aeec849 100644 --- a/conf/upsmon.conf.sample.in +++ b/conf/upsmon.conf.sample.in @@ -9,9 +9,9 @@ # waits to run the SHUTDOWNCMD. The other one switches to another userid # and does everything else. # -# The default nonprivileged user is set at compile-time with -# 'configure --with-user=...'. -# +# The default unprivileged user is set at compile-time with the option +# 'configure --with-user=...' +# # You can override it with '-u ' when starting upsmon, or just # define it here for convenience. # @@ -30,19 +30,19 @@ # RUN_AS_USER @RUN_AS_USER@ # -------------------------------------------------------------------------- -# MONITOR ("master"|"slave") +# MONITOR ("primary"|"secondary") # # List systems you want to monitor. Not all of these may supply power # to the system running upsmon, but if you want to watch it, it has to # be in this section. -# +# # You must have at least one of these declared. # # is a UPS identifier in the form @[:] # like ups@localhost, su700@mybox, etc. -# +# # Examples: -# +# # - "su700@mybox" means a UPS called "su700" on a system called "mybox" # # - "fenton@bigbox:5678" is a UPS called "fenton" on a system called @@ -54,34 +54,67 @@ # If the ups.conf on host "doghouse" has a section called "snoopy", the # identifier for it would be "snoopy@doghouse". # -# is an integer - the number of power supplies that this UPS -# feeds on this system. Most computers only have one power supply, so this -# is normally set to 1. You need a pretty big or special box to have any -# other value here. +# is an integer - the number of power supplies that this UPS +# feeds on this system. Most personal computers only have one power supply, +# so this value is normally set to 1, while most modern servers have at least +# two. You need a pretty big or special box to have any other value here. # -# You can also set this to 0 for a system that doesn't supply any power, -# but you still want to monitor. Use this when you want to hear about -# changes for a given UPS without shutting down when it goes critical, -# unless is 0. +# You can also set this to 0 for a system that doesn't take any power +# from the MONITORed supply, which you still want to monitor (e.g. for an +# administrative workstation fed from a different circuit than the datacenter +# servers it monitors). Use if 0 when you want to hear about +# changes for a given UPS without shutting down when it goes critical. # # and must match an entry in that system's -# upsd.users. If your username is "monmaster" and your password is +# upsd.users. If your username is "upsmon" and your password is # "blah", the upsd.users would look like this: # -# [monmaster] +# [upsmon] # password = blah -# upsmon master (or slave) -# -# "master" means this system will shutdown last, allowing the slaves -# time to shutdown first. +# upsmon primary # (or secondary) # -# "slave" means this system shuts down immediately when power goes critical. +# "primary" means this system will shutdown last, allowing the secondary +# systems time to shutdown first. # -# Examples: +# "secondary" means this system shuts down immediately when power goes +# critical and less than MINSUPPLIES power sources have reliable input feeds. # -# MONITOR myups@bigserver 1 monmaster blah master -# MONITOR su700@server.example.com 1 upsmon secretpass slave -# MONITOR myups@localhost 1 upsmon pass master (or slave) +# The general assumption is that the "primary" system is the one with direct +# connection to an UPS (such as serial or USB cable), so the primary system +# runs the NUT driver and 'upsd' server locally and can manage the device, +# and it would often tell the UPS to completely power itself off as a step +# in power-race avoidance (see POWERDOWNFLAG for details). +# +# Also, since the primary system stays up the longest, it suffers higher risks +# of ungraceful shutdown if the estimation of remaining runtime (or of the +# time it takes to shut down this system) was guessed wrong. By consequence, +# the "secondary" systems typically monitor the power environment state +# through the 'upsd' processes running on the remote (often "primary") systems +# and do not directly interact with an UPS (no local NUT drivers are running +# on the secondary systems). As such, secondaries typically shut down as +# soon as there is a sufficiently long power outage, or a low-battery alert +# from the UPS, or a loss of connection to the primary while the power was +# last known to be missing. +# +# This assumption and configuration can also make sense for networked UPSes, +# where a rack full of servers might overload the communications capacity +# of the networked management card on the UPS - in this case you might either +# reduce the 'snmp-ups' or 'netxml-ups' driver polling rate, or dedicate a +# "primary" server and set up the rest as "secondary" systems. +# +# In case of such large setups as mentioned above, beware also that shutdown +# times of the rack done all at once can substantially differ from smaller +# scale experiments with single-server shutdowns, since systems can compete +# for shared storage and other limited resources as they go down (and also +# not everyone may safely shut down simultaneously - e.g. a NAS or DB server +# would better go down after all its clients). You would be well served by +# higher-end UPSes with manageable thresholds to declare a critical state. +# +# Examples: +# +# MONITOR myups@bigserver 1 upswired blah primary +# MONITOR su700@server.example.com 1 upsmon secretpass secondary +# MONITOR myups@localhost 1 upsmon pass primary # (or secondary) # -------------------------------------------------------------------------- # MINSUPPLIES @@ -91,7 +124,7 @@ # put "1" in this field. # # Large/expensive server type systems usually have more, and can run with -# a few missing. The HP NetServer LH4 can run with 2 out of 4, for example, +# a few missing. Some of these can run with 2 out of 4, for example, # so you'd set that to 2. The idea is to keep the box running as long # as possible, right? # @@ -106,7 +139,15 @@ MINSUPPLIES 1 # # upsmon runs this command when the system needs to be brought down. # -# This should work just about everywhere ... if it doesn't, well, change it. +# This should work just about everywhere ... if it doesn't, well, change it, +# perhaps to a more complicated custom script. +# +# Note that while you experiment with the initial setup and want to test how +# your configuration reacts to power state changes and ultimately when power +# is reported to go critical, but do not want your system to actually turn +# off, consider setting the SHUTDOWNCMD temporarily to do something benign - +# such as posting a message with 'logger' or 'wall' or 'mailx'. Do be careful +# to plug the UPS back into the wall in a timely fashion. SHUTDOWNCMD "/sbin/shutdown -h +0" @@ -115,25 +156,32 @@ SHUTDOWNCMD "/sbin/shutdown -h +0" # # upsmon calls this to send messages when things happen # -# This command is called with the full text of the message as one argument. +# This command is called with the full text of the message (from NOTIFYMSG) +# as one argument. +# # The environment string NOTIFYTYPE will contain the type string of # whatever caused this event to happen. # +# The environment string UPSNAME will contain the name of the system/device +# that generated the change. +# # Note that this is only called for NOTIFY events that have EXEC set with # NOTIFYFLAG. See NOTIFYFLAG below for more details. # -# Making this some sort of shell script might not be a bad idea. For more -# information and ideas, see docs/scheduling.txt +# Making this some sort of shell script might not be a bad idea. +# Alternately you can use the upssched program as your NOTIFYCMD for some +# more complex setups (e.g. to ease handling of notification storms). +# For more information and ideas, see docs/scheduling.txt # # Example: # NOTIFYCMD @BINDIR@/notifyme # -------------------------------------------------------------------------- -# POLLFREQ +# POLLFREQ # # Polling frequency for normal activities, measured in seconds. # -# Adjust this to keep upsmon from flooding your network, but don't make +# Adjust this to keep upsmon from flooding your network, but don't make # it too high or it may miss certain short-lived power events. POLLFREQ 5 @@ -144,8 +192,8 @@ POLLFREQ 5 # Polling frequency in seconds while UPS on battery. # # You can make this number lower than POLLFREQ, which will make updates -# faster when any UPS is running on battery. This is a good way to tune -# network load if you have a lot of these things running. +# faster when any UPS is running on battery. This is a good way to tune +# network load if you have a lot of these things running. # # The default is 5 seconds for both this and POLLFREQ. @@ -154,17 +202,17 @@ POLLFREQALERT 5 # -------------------------------------------------------------------------- # HOSTSYNC - How long upsmon will wait before giving up on another upsmon # -# The master upsmon process uses this number when waiting for slaves to -# disconnect once it has set the forced shutdown (FSD) flag. If they -# don't disconnect after this many seconds, it goes on without them. +# The primary upsmon process uses this number when waiting for secondary +# systems to disconnect once it has set the forced shutdown (FSD) flag. +# If they don't disconnect after this many seconds, it goes on without them. # -# Similarly, upsmon slave processes wait up to this interval for the -# master upsmon to set FSD when a UPS they are monitoring goes critical - -# that is, on battery and low battery. If the master doesn't do its job, -# the slaves will shut down anyway to avoid damage to the file systems. +# Similarly, upsmon secondary processes wait up to this interval for the +# primary upsmon to set FSD when an UPS they are monitoring goes critical - +# that is, on battery and low battery. If the primary doesn't do its job, +# the secondaries will shut down anyway to avoid damage to the file systems. # # This "wait for FSD" is done to avoid races where the status changes -# to critical and back between polls by the master. +# to critical and back between polls by the primary. HOSTSYNC 15 @@ -188,11 +236,12 @@ HOSTSYNC 15 DEADTIME 15 # -------------------------------------------------------------------------- -# POWERDOWNFLAG - Flag file for forcing UPS shutdown on the master system +# POWERDOWNFLAG - Flag file for forcing UPS shutdown on the primary system # -# upsmon will create a file with this name in master mode when it's time +# upsmon will create a file with this name in primary mode when it's time # to shut down the load. You should check for this file's existence in -# your shutdown scripts and run 'upsdrvctl shutdown' if it exists. +# your shutdown scripts and run 'upsdrvctl shutdown' if it exists, to tell +# the UPS(es) to power off. # # See the config-notes.txt file in the docs subdirectory for more information. # Refer to the section: @@ -226,7 +275,7 @@ POWERDOWNFLAG /etc/killpower # ONLINE : UPS is back online # ONBATT : UPS is on battery # LOWBATT : UPS has a low battery (if also on battery, it's "critical") -# FSD : UPS is being shutdown by the master (FSD = "Forced Shutdown") +# FSD : UPS is being shutdown by the primary (FSD = "Forced Shutdown") # COMMOK : Communications established with the UPS # COMMBAD : Communications lost to the UPS # SHUTDOWN : The system is being shutdown @@ -255,7 +304,7 @@ POWERDOWNFLAG /etc/killpower # # Possible values for the flags: # -# SYSLOG - Write the message in the syslog +# SYSLOG - Write the message in the syslog # WALL - Write the message to all users on the system # EXEC - Execute NOTIFYCMD (see above) with the message # IGNORE - Don't do anything @@ -269,7 +318,7 @@ POWERDOWNFLAG /etc/killpower # every 43200 seconds, which is 12 hours. It does this by triggering a # NOTIFY_REPLBATT which is then handled by the usual notify structure # you've defined above. -# +# # If this number is not to your liking, override it here. RBWARNTIME 43200 @@ -279,7 +328,7 @@ RBWARNTIME 43200 # # upsmon will let you know through the usual notify system if it can't # talk to any of the UPS entries that are defined in this file. It will -# trigger a NOTIFY_NOCOMM by default every 300 seconds unless you +# trigger a NOTIFY_NOCOMM by default every 300 seconds unless you # change the interval with this directive. NOCOMMWARNTIME 300 @@ -287,17 +336,20 @@ NOCOMMWARNTIME 300 # -------------------------------------------------------------------------- # FINALDELAY - last sleep interval before shutting down the system # -# On a master, upsmon will wait this long after sending the NOTIFY_SHUTDOWN +# On a primary, upsmon will wait this long after sending the NOTIFY_SHUTDOWN # before executing your SHUTDOWNCMD. If you need to do something in between -# those events, increase this number. Remember, at this point your UPS is -# almost depleted, so don't make this too high. +# those events, increase this number. Remember, at this point your UPS is +# almost depleted, so don't make this too high. If needed, on high-end UPS +# devices you can usually configure when the low-battery state is announced +# based on estimated remaining run-time or on charge level of the batteries. # # Alternatively, you can set this very low so you don't wait around when # it's time to shut down. Some UPSes don't give much warning for low # battery and will require a value of 0 here for a safe shutdown. # -# Note: If FINALDELAY on the slave is greater than HOSTSYNC on the master, -# the master will give up waiting for the slave to disconnect. +# Note: If FINALDELAY on the secondary is greater than HOSTSYNC on the +# primary, the primary will give up waiting for that secondary system +# to disconnect. FINALDELAY 5 @@ -307,9 +359,9 @@ FINALDELAY 5 # When compiled with SSL support, you can enter the certificate path here. # # With NSS: -# Certificates are stored in a dedicated database (splitted in 3 files). +# Certificates are stored in a dedicated database (split into 3 files). # Specify the path of the database directory. -# +# # CERTPATH @CONFPATH@/cert/upsmon # # With OpenSSL: @@ -319,7 +371,7 @@ FINALDELAY 5 # name hash value, which must hence be available. # # CERTPATH /usr/ssl/certs -# +# # See 'docs/security.txt' or the Security chapter of NUT user manual # for more information on the SSL support in NUT. @@ -332,7 +384,7 @@ FINALDELAY 5 # required to access certificate related private key. # # CERTIDENT "my nut monitor" "MyPasSw0rD" -# +# # See 'docs/security.txt' or the Security chapter of NUT user manual # for more information on the SSL support in NUT. @@ -355,14 +407,14 @@ FINALDELAY 5 # CERTVERIFY - make upsmon verify all connections with certificates # CERTVERIFY 1 # -# When compiled with SSL support, make upsmon verify all connections with +# When compiled with SSL support, make upsmon verify all connections with # certificates. # Without this, there is no guarantee that the upsd is the right host. # Enabling this greatly reduces the risk of man in the middle attacks. # This effectively forces the use of SSL, so don't use this unless # all of your upsd hosts are ready for SSL and have their certificates # in order. -# When compiled with NSS support of SSL, can be overriden for host +# When compiled with NSS support of SSL, can be overridden for host # specified with a CERTHOST directive. @@ -376,5 +428,26 @@ FINALDELAY 5 # that nobody can sniff your sessions without a large effort. Setting # this will make upsmon drop connections if the remote upsd doesn't # support SSL, so don't use it unless all of them have it running. -# When compiled with NSS support of SSL, can be overriden for host +# When compiled with NSS support of SSL, can be overridden for host # specified with a CERTHOST directive. + +# -------------------------------------------------------------------------- +# DEBUG_MIN - specify minimal debugging level for upsmon daemon +# e.g. DEBUG_MIN 6 +# +# Optionally specify a minimum debug level for `upsmon` daemon, e.g. for +# troubleshooting a deployment, without impacting foreground or background +# running mode directly, and without need to edit init-scripts or service +# unit definitions. Note that command-line option `-D` can only increase +# this verbosity level. +# +# NOTE: if the running daemon receives a `reload` command, presence of the +# `DEBUG_MIN NUMBER` value in the configuration file can be used to tune +# debugging verbosity in the running service daemon (it is recommended to +# comment it away or set the minimum to explicit zero when done, to avoid +# huge journals and I/O system abuse). Keep in mind that for this run-time +# tuning, the `DEBUG_MIN` value *present* in *reloaded* configuration files +# is applied instantly and overrides any previously set value, from file +# or CLI options, regardless of older logging level being higher or lower +# than the newly found number; a missing (or commented away) value however +# does not change the previously active logging verbosity. diff --git a/conf/upssched.conf.sample.in b/conf/upssched.conf.sample.in index c7e625d..541dea8 100644 --- a/conf/upssched.conf.sample.in +++ b/conf/upssched.conf.sample.in @@ -25,7 +25,7 @@ CMDSCRIPT @BINDIR@/upssched-cmd # normal users can't create the file, due to the possibility of symlinking # and other evil. # -# Note: if you are running Solaris or similar, the permissions that +# Note: if you are running Solaris or similar, the permissions that # upssched sets on this file *are not enough* to keep you safe. If # your OS ignores the permissions on a FIFO, then you MUST put this in # a protected directory! @@ -67,9 +67,9 @@ CMDSCRIPT @BINDIR@/upssched-cmd # can be the special value * to apply this handler to every # possible value of . # -# Run the command via your CMDSCRIPT when it happens. +# Run the command via your CMDSCRIPT when it happens. # -# Note that any AT that matches both the and the +# Note that any AT that matches both the and the # for the current event will be used. # ============================================================================ @@ -83,9 +83,15 @@ CMDSCRIPT @BINDIR@/upssched-cmd # argument. # # Example: -# Start a timer that'll execute when any UPS (*) has been gone 10 seconds +# 1) Start a timer that will execute when communication with any UPS (*) has +# been gone for 10 seconds # # AT COMMBAD * START-TIMER upsgone 10 +# +# 2) Start a timer that will execute when any UPS (*) has been running +# on battery for 30 seconds +# +# AT ONBATT * START-TIMER onbattwarn 30 # ----------------------------------------------------------------------- # @@ -95,10 +101,15 @@ CMDSCRIPT @BINDIR@/upssched-cmd # has passed then pass the optional argument to CMDSCRIPT. # # Example: -# If a specific UPS (myups@localhost) comes back online, then stop the -# timer before it triggers -# +# 1) If a specific UPS (myups@localhost) communication is restored, then stop +# the timer before it triggers +# # AT COMMOK myups@localhost CANCEL-TIMER upsgone +# +# 2) If any UPS (*) reverts to utility power, then stop the timer before it +# triggers +# +# AT ONLINE * CANCEL-TIMER onbattwarn # ----------------------------------------------------------------------- # diff --git a/conf/upsset.conf.sample b/conf/upsset.conf.sample index 56795ba..921a20a 100644 --- a/conf/upsset.conf.sample +++ b/conf/upsset.conf.sample @@ -2,12 +2,12 @@ # # This file is provided to ensure that you do not expose your upsd server # to the world upon installing the CGI programs. Specifically, it keeps -# the upsset.cgi program from running until you have assured it that you +# the upsset.cgi program from running until you have assured it that you # have secured your web server's CGI directory. # # By default, your web server will probably let anyone access upsset.cgi # once it is installed. This means that anyone could attempt to crack -# upsd logins since they would appear to be coming from your web server, +# upsd logins since they would appear to be coming from your web server, # rather than the outside world, slipping through any ACL/ACCESS definitions. # # For this reason, you *MUST* first secure your CGI programs before @@ -17,17 +17,17 @@ # For Apache, the .htaccess file can be used in the directory with the # programs. You'll need something like this: # -# -# deny from all -# allow from your.network.addresses -# +# +# deny from all +# allow from your.network.addresses +# # # You will probably have to set "AllowOverride Limit" for this directory in # your server-level configuration file as well. # # If this doesn't make sense, then stop reading and leave this program alone. # -# Assuming you have all this done (and it works), then you may uncomment +# Assuming you have all this done (and it works), then you may uncomment # the line below and start using upsset.cgi through your web browser. # diff --git a/conf/upsstats-single.html.sample b/conf/upsstats-single.html.sample index 4d34421..4c2a6a8 100644 --- a/conf/upsstats-single.html.sample +++ b/conf/upsstats-single.html.sample @@ -17,8 +17,8 @@ @UPSSTATSPATH upsstats.cgi@ @UPSIMAGEPATH upsimage.cgi@ - + @@ -26,10 +26,16 @@ @REFRESH@ @HOSTDESC@ : @VAR ups.model@ on @HOST@ + - + -
\n"); @@ -910,12 +914,12 @@ static void display_tree(int verbose) if (numa < 4) { if (verbose) printf("[Invalid response]\n"); - + return; } printf("
%s:%s
+
@@ -51,7 +57,7 @@ -
Network UPS Tools upsstats @VERSION@ - @HOSTDESC@ - @VAR ups.model@ on @HOST@
+ @@ -195,7 +201,7 @@ @IFSUPP ambient.temperature@ @IFSUPP ambient.humidity@ -
+ @@ -203,21 +209,21 @@ @ELSE@ @IFSUPP ambient.temperature@ - @ELSE@ @IFSUPP ambient.humidity@ - @ENDIF@ - - - -
Temperature
@IMG ambient.temperature tempmin=0 tempmax=50 width=90@
Humidity
@IMG ambient.humidity width=90@
+
Temperature
@IMG ambient.temperature tempmin=0 tempmax=50@
+
Humidity
@IMG ambient.humidity@
+ @IFSUPP battery.charge@ @IFSUPP battery.voltage@ @@ -232,7 +238,7 @@
+ @IFSUPP input.L2-L3.voltage@ @@ -249,7 +255,7 @@
L1-L2
@IMG input.L1-L2.voltage width=68@
+ @IFSUPP output.L2-L3.voltage@ @@ -266,7 +272,7 @@
L1-L2
@IMG output.L1-L2.voltage width=68@
+ @IFSUPP output.L2.power.percent@ @@ -286,9 +292,12 @@
L1
@IMG output.L1.power.percent width=68@
-Valid HTML 4.0 Transitional - +
Valid CSS +Valid HTML 4.01 Strict
diff --git a/conf/upsstats.html.sample b/conf/upsstats.html.sample index e25a829..23442e0 100644 --- a/conf/upsstats.html.sample +++ b/conf/upsstats.html.sample @@ -1,6 +1,6 @@ - @REFRESH@ - + - +
- +
- - + @@ -65,20 +73,20 @@ Network UPS Tools upsstats @FOREACHUPS@ - - + - - - - - - - - @@ -180,11 +188,9 @@ Network UPS Tools upsstats
+ -Network UPS Tools upsstats +Network UPS Tools upsstats @VERSION@ - +
@DATE %a %b %d %X %Z %Y@ @@ -50,7 +58,7 @@ Network UPS Tools upsstats
System Model Status
+
@HOSTLINK@ + @VAR ups.model@ + @STATUS@ + @IFSUPP battery.charge@ @VAR battery.charge@ % @@ -89,18 +97,18 @@ Network UPS Tools upsstats @IFBETWEEN input.transfer.low input.transfer.high input.L1-L2.voltage@ @IFBETWEEN input.transfer.low input.transfer.high input.L2-L3.voltage@ @IFBETWEEN input.transfer.low input.transfer.high input.L3-L1.voltage@ - + @ELSE@ @IFSUPP input.L2-N.voltage@ @IFBETWEEN input.transfer.low input.transfer.high input.L1-N.voltage@ @IFBETWEEN input.transfer.low input.transfer.high input.L2-N.voltage@ @IFBETWEEN input.transfer.low input.transfer.high input.L3-N.voltage@ - + @ELSE@ @IFBETWEEN input.transfer.low input.transfer.high input.voltage@ - + @ELSE@ - + @ENDIF@ @IFSUPP input.L2-L3.voltage@ @@ -118,7 +126,7 @@ Network UPS Tools upsstats @ENDIF@ + @IFSUPP output.L2-L3.voltage@ @VAR output.L1-L2.voltage@ @VAR output.L2-L3.voltage@ @@ -134,7 +142,7 @@ Network UPS Tools upsstats @ENDIF@ + @IFSUPP output.L2.power.percent@ @VAR output.L1.power.percent@ @VAR output.L2.power.percent@ @@ -151,7 +159,7 @@ Network UPS Tools upsstats @ENDIF@ + @IFSUPP ups.temperature@ @UPSTEMP@ @DEGREES@ @@ -162,13 +170,13 @@ Network UPS Tools upsstats @ENDIF@ + @IFSUPP battery.runtime@ @RUNTIME@ @ENDIF@ + @TREELINK@
-
-Valid CSS! - +
+Valid CSS! +Valid HTML 4.01 Strict
diff --git a/config.guess b/config.guess index 1f5c50c..f50dcdb 100755 --- a/config.guess +++ b/config.guess @@ -1,8 +1,8 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2014 Free Software Foundation, Inc. +# Copyright 1992-2018 Free Software Foundation, Inc. -timestamp='2014-03-23' +timestamp='2018-02-24' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ timestamp='2014-03-23' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -24,12 +24,12 @@ timestamp='2014-03-23' # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # -# Originally written by Per Bothner. +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess # -# Please send patches with a ChangeLog entry to config-patches@gnu.org. +# Please send patches to . me=`echo "$0" | sed -e 's,.*/,,'` @@ -39,7 +39,7 @@ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -50,7 +50,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2014 Free Software Foundation, Inc. +Copyright 1992-2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -107,9 +107,9 @@ trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; + ,,) echo "int x;" > "$dummy.c" ; for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; @@ -132,14 +132,14 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown -case "${UNAME_SYSTEM}" in +case "$UNAME_SYSTEM" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu - eval $set_cc_for_build - cat <<-EOF > $dummy.c + eval "$set_cc_for_build" + cat <<-EOF > "$dummy.c" #include #if defined(__UCLIBC__) LIBC=uclibc @@ -149,13 +149,20 @@ Linux|GNU|GNU/*) LIBC=gnu #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" + + # If ldd exists, use it to detect musl libc. + if command -v ldd >/dev/null && \ + ldd --version 2>&1 | grep -q ^musl + then + LIBC=musl + fi ;; esac # Note: order is significant - the case branches are not exclusive. -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in +case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, @@ -168,21 +175,31 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in + UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ + "/sbin/$sysctl" 2>/dev/null || \ + "/usr/sbin/$sysctl" 2>/dev/null || \ + echo unknown)` + case "$UNAME_MACHINE_ARCH" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + earmv*) + arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` + machine="${arch}${endian}"-unknown + ;; + *) machine="$UNAME_MACHINE_ARCH"-unknown ;; esac # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in + # to ELF recently (or will in the future) and ABI. + case "$UNAME_MACHINE_ARCH" in + earm*) + os=netbsdelf + ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build + eval "$set_cc_for_build" if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then @@ -197,44 +214,67 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in os=netbsd ;; esac + # Determine ABI tags. + case "$UNAME_MACHINE_ARCH" in + earm*) + expr='s/^earmv[0-9]/-eabi/;s/eb$//' + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` + ;; + esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in + case "$UNAME_VERSION" in Debian*) release='-gnu' ;; *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" + echo "$machine-${os}${release}${abi}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" + exit ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" + exit ;; + *:MidnightBSD:*:*) + echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" exit ;; *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" exit ;; *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" exit ;; macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} + echo powerpc-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" exit ;; + *:Sortix:*:*) + echo "$UNAME_MACHINE"-unknown-sortix + exit ;; + *:Redox:*:*) + echo "$UNAME_MACHINE"-unknown-redox + exit ;; + mips:OSF1:*.*) + echo mips-dec-osf1 + exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) @@ -251,63 +291,54 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; + UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; + UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; + UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; + UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; + UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; + UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; + UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; + UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; + UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos + echo "$UNAME_MACHINE"-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos + echo "$UNAME_MACHINE"-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition @@ -319,7 +350,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} + echo arm-acorn-riscix"$UNAME_RELEASE" exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos @@ -346,38 +377,38 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} + echo i386-pc-auroraux"$UNAME_RELEASE" exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build - SUN_ARCH="i386" + eval "$set_cc_for_build" + SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then - SUN_ARCH="x86_64" + SUN_ARCH=x86_64 fi fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in @@ -386,25 +417,25 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" exit ;; sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" ;; sun4) - echo sparc-sun-sunos${UNAME_RELEASE} + echo sparc-sun-sunos"$UNAME_RELEASE" ;; esac exit ;; aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} + echo sparc-auspex-sunos"$UNAME_RELEASE" exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not @@ -415,44 +446,44 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} + echo m68k-milan-mint"$UNAME_RELEASE" exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} + echo m68k-hades-mint"$UNAME_RELEASE" exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} + echo m68k-unknown-mint"$UNAME_RELEASE" exit ;; m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} + echo m68k-apple-machten"$UNAME_RELEASE" exit ;; powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} + echo powerpc-apple-machten"$UNAME_RELEASE" exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} + echo mips-dec-ultrix"$UNAME_RELEASE" exit ;; VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} + echo vax-dec-ultrix"$UNAME_RELEASE" exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} + echo clipper-intergraph-clix"$UNAME_RELEASE" exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { @@ -461,23 +492,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} + echo mips-mips-riscos"$UNAME_RELEASE" exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax @@ -503,17 +534,17 @@ EOF AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] + if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ + [ "$TARGET_BINARY_INTERFACE"x = x ] then - echo m88k-dg-dgux${UNAME_RELEASE} + echo m88k-dg-dgux"$UNAME_RELEASE" else - echo m88k-dg-dguxbcs${UNAME_RELEASE} + echo m88k-dg-dguxbcs"$UNAME_RELEASE" fi else - echo i586-dg-dgux${UNAME_RELEASE} + echo i586-dg-dgux"$UNAME_RELEASE" fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) @@ -530,7 +561,7 @@ EOF echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id @@ -542,14 +573,14 @@ EOF if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #include main() @@ -560,7 +591,7 @@ EOF exit(0); } EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then echo "$SYSTEM_NAME" else @@ -574,26 +605,27 @@ EOF exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` + if [ -x /usr/bin/lslpp ] ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} + echo "$IBM_ARCH"-ibm-aix"$IBM_REV" exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx @@ -608,28 +640,28 @@ EOF echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + case "$UNAME_MACHINE" in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + case "$sc_cpu_version" in + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + case "$sc_kernel_bits" in + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + if [ "$HP_ARCH" = "" ]; then + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include @@ -662,13 +694,13 @@ EOF exit (0); } EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ ${HP_ARCH} = "hppa2.0w" ] + if [ "$HP_ARCH" = hppa2.0w ] then - eval $set_cc_for_build + eval "$set_cc_for_build" # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler @@ -679,23 +711,23 @@ EOF # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then - HP_ARCH="hppa2.0w" + HP_ARCH=hppa2.0w else - HP_ARCH="hppa64" + HP_ARCH=hppa64 fi fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} + echo "$HP_ARCH"-hp-hpux"$HPUX_REV" exit ;; ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux"$HPUX_REV" exit ;; 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #include int main () @@ -720,11 +752,11 @@ EOF exit (0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) @@ -733,7 +765,7 @@ EOF *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) @@ -741,9 +773,9 @@ EOF exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk + echo "$UNAME_MACHINE"-unknown-osf1mk else - echo ${UNAME_MACHINE}-unknown-osf1 + echo "$UNAME_MACHINE"-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) @@ -768,127 +800,109 @@ EOF echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" exit ;; sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} + echo sparc-unknown-bsdi"$UNAME_RELEASE" exit ;; *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in + case "$UNAME_PROCESSOR" in amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; esac + echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin + echo "$UNAME_MACHINE"-pc-cygwin exit ;; *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 + echo "$UNAME_MACHINE"-pc-mingw64 exit ;; *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 + echo "$UNAME_MACHINE"-pc-mingw32 exit ;; *:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 + echo "$UNAME_MACHINE"-pc-msys exit ;; i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 + echo "$UNAME_MACHINE"-pc-pw32 exit ;; *:Interix*:*) - case ${UNAME_MACHINE} in + case "$UNAME_MACHINE" in x86) - echo i586-pc-interix${UNAME_RELEASE} + echo i586-pc-interix"$UNAME_RELEASE" exit ;; authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} + echo x86_64-unknown-interix"$UNAME_RELEASE" exit ;; IA64) - echo ia64-unknown-interix${UNAME_RELEASE} + echo ia64-unknown-interix"$UNAME_RELEASE" exit ;; esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin + echo "$UNAME_MACHINE"-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" exit ;; i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix + echo "$UNAME_MACHINE"-pc-minix exit ;; aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in @@ -901,58 +915,64 @@ EOF EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="gnulibc1" ; fi - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arc:Linux:*:* | arceb:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arm*:Linux:*:*) - eval $set_cc_for_build + eval "$set_cc_for_build" if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi else - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf fi fi exit ;; avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" + exit ;; + e2k:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + k1om:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el @@ -966,64 +986,74 @@ EOF #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`" + test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; } ;; + mips64el:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; openrisc*:Linux:*:*) - echo or1k-unknown-linux-${LIBC} + echo or1k-unknown-linux-"$LIBC" exit ;; or32:Linux:*:* | or1k*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; padre:Linux:*:*) - echo sparc-unknown-linux-${LIBC} + echo sparc-unknown-linux-"$LIBC" exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-${LIBC} + echo hppa64-unknown-linux-"$LIBC" exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; - PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; - *) echo hppa-unknown-linux-${LIBC} ;; + PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; + PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; + *) echo hppa-unknown-linux-"$LIBC" ;; esac exit ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-${LIBC} + echo powerpc64-unknown-linux-"$LIBC" exit ;; ppc:Linux:*:*) - echo powerpc-unknown-linux-${LIBC} + echo powerpc-unknown-linux-"$LIBC" exit ;; ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-${LIBC} + echo powerpc64le-unknown-linux-"$LIBC" exit ;; ppcle:Linux:*:*) - echo powerpcle-unknown-linux-${LIBC} + echo powerpcle-unknown-linux-"$LIBC" + exit ;; + riscv32:Linux:*:* | riscv64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} + echo "$UNAME_MACHINE"-dec-linux-"$LIBC" exit ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + if objdump -f /bin/sh | grep -q elf32-x86-64; then + echo "$UNAME_MACHINE"-pc-linux-"$LIBC"x32 + else + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" + fi exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. @@ -1037,34 +1067,34 @@ EOF # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx + echo "$UNAME_MACHINE"-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop + echo "$UNAME_MACHINE"-unknown-stop exit ;; i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos + echo "$UNAME_MACHINE"-unknown-atheos exit ;; i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable + echo "$UNAME_MACHINE"-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} + echo i386-unknown-lynxos"$UNAME_RELEASE" exit ;; i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp + echo "$UNAME_MACHINE"-pc-msdosdjgpp exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + i*86:*:4.*:*) + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" fi exit ;; i*86:*:5:[678]*) @@ -1074,12 +1104,12 @@ EOF *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}" exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 @@ -1089,9 +1119,9 @@ EOF && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv32 + echo "$UNAME_MACHINE"-pc-sysv32 fi exit ;; pc:*:*:*) @@ -1099,7 +1129,7 @@ EOF # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub - # prints for the "djgpp" host, or else GDB configury will decide that + # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; @@ -1111,9 +1141,9 @@ EOF exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) @@ -1133,9 +1163,9 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; @@ -1144,28 +1174,28 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} + echo m68k-unknown-lynxos"$UNAME_RELEASE" exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} + echo sparc-unknown-lynxos"$UNAME_RELEASE" exit ;; rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} + echo rs6000-unknown-lynxos"$UNAME_RELEASE" exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} + echo powerpc-unknown-lynxos"$UNAME_RELEASE" exit ;; SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} + echo mips-dde-sysv"$UNAME_RELEASE" exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 @@ -1176,7 +1206,7 @@ EOF *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 + echo "$UNAME_MACHINE"-sni-sysv4 else echo ns32k-sni-sysv fi @@ -1196,23 +1226,23 @@ EOF exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos + echo "$UNAME_MACHINE"-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} + echo m68k-apple-aux"$UNAME_RELEASE" exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + echo mips-nec-sysv"$UNAME_RELEASE" else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv"$UNAME_RELEASE" fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. @@ -1231,46 +1261,56 @@ EOF echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} + echo sx4-nec-superux"$UNAME_RELEASE" exit ;; SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} + echo sx5-nec-superux"$UNAME_RELEASE" exit ;; SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} + echo sx6-nec-superux"$UNAME_RELEASE" exit ;; SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} + echo sx7-nec-superux"$UNAME_RELEASE" exit ;; SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} + echo sx8-nec-superux"$UNAME_RELEASE" exit ;; SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} + echo sx8r-nec-superux"$UNAME_RELEASE" + exit ;; + SX-ACE:SUPER-UX:*:*) + echo sxace-nec-superux"$UNAME_RELEASE" exit ;; Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} + echo powerpc-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval $set_cc_for_build + eval "$set_cc_for_build" if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi - if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc + fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub @@ -1281,27 +1321,33 @@ EOF # that Apple uses in portable devices. UNAME_PROCESSOR=x86_64 fi - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then + if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; - NEO-?:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} + NEO-*:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk"$UNAME_RELEASE" exit ;; NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} + echo nse-tandem-nsk"$UNAME_RELEASE" exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} + NSR-*:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSV-*:NONSTOP_KERNEL:*:*) + echo nsv-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSX-*:NONSTOP_KERNEL:*:*) + echo nsx-tandem-nsk"$UNAME_RELEASE" exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux @@ -1310,18 +1356,18 @@ EOF echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. - if test "$cputype" = "386"; then + if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi - echo ${UNAME_MACHINE}-unknown-plan9 + echo "$UNAME_MACHINE"-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 @@ -1342,14 +1388,14 @@ EOF echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} + echo mips-sei-seiux"$UNAME_RELEASE" exit ;; *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in + case "$UNAME_MACHINE" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; @@ -1358,34 +1404,48 @@ EOF echo i386-pc-xenix exit ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" exit ;; i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos + echo "$UNAME_MACHINE"-pc-rdos exit ;; i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros + echo "$UNAME_MACHINE"-pc-aros exit ;; x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx + echo "$UNAME_MACHINE"-unknown-esx + exit ;; + amd64:Isilon\ OneFS:*:*) + echo x86_64-unknown-onefs exit ;; esac +echo "$0: unable to guess system type" >&2 + +case "$UNAME_MACHINE:$UNAME_SYSTEM" in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <&2 < in order to provide the needed -information to handle your system. +If $0 has already been updated, send the following data and any +information you think might be pertinent to config-patches@gnu.org to +provide the necessary information to handle your system. config.guess timestamp = $timestamp @@ -1404,16 +1464,16 @@ hostinfo = `(hostinfo) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" EOF exit 1 # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'write-file-functions 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/config.sub b/config.sub index bba4efb..1d8e98b 100755 --- a/config.sub +++ b/config.sub @@ -1,8 +1,8 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2014 Free Software Foundation, Inc. +# Copyright 1992-2018 Free Software Foundation, Inc. -timestamp='2014-09-11' +timestamp='2018-02-22' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ timestamp='2014-09-11' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -25,7 +25,7 @@ timestamp='2014-09-11' # of the GNU General Public License, version 3 ("GPLv3"). -# Please send patches with a ChangeLog entry to config-patches@gnu.org. +# Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. @@ -33,7 +33,7 @@ timestamp='2014-09-11' # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -53,12 +53,11 @@ timestamp='2014-09-11' me=`echo "$0" | sed -e 's,.*/,,'` usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS +Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -68,7 +67,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright 1992-2014 Free Software Foundation, Inc. +Copyright 1992-2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -95,7 +94,7 @@ while test $# -gt 0 ; do *local*) # First pass through any local machine types. - echo $1 + echo "$1" exit ;; * ) @@ -113,24 +112,24 @@ esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | \ - kopensolaris*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ + kopensolaris*-gnu* | cloudabi*-eabi* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` + basic_machine=`echo "$1" | sed 's/-[^-]*$//'` + if [ "$basic_machine" != "$1" ] + then os=`echo "$1" | sed 's/.*-/-/'` else os=; fi ;; esac @@ -179,44 +178,44 @@ case $os in ;; -sco6) os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 @@ -228,10 +227,7 @@ case $os in os=-lynxos ;; -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-sequent/'` ;; -psos*) os=-psos @@ -255,15 +251,16 @@ case $basic_machine in | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ + | ba \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ - | epiphany \ - | fido | fr30 | frv \ + | e2k | epiphany \ + | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ - | i370 | i860 | i960 | ia64 \ + | i370 | i860 | i960 | ia16 | ia64 \ | ip2k | iq2000 \ | k1om \ | le32 | le64 \ @@ -299,13 +296,14 @@ case $basic_machine in | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 | or1k | or1knd | or32 \ - | pdp10 | pdp11 | pj | pjl \ + | pdp10 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pru \ | pyramid \ | riscv32 | riscv64 \ | rl78 | rx \ | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ @@ -313,7 +311,8 @@ case $basic_machine in | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | we32k \ + | visium \ + | wasm32 \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown @@ -327,11 +326,14 @@ case $basic_machine in c6x) basic_machine=tic6x-unknown ;; + leon|leon[3-9]) + basic_machine=sparc-$basic_machine + ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65) ;; ms1) basic_machine=mt-unknown @@ -360,7 +362,7 @@ case $basic_machine in ;; # Object if more than one company name word. *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. @@ -372,17 +374,18 @@ case $basic_machine in | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ + | ba-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ + | e2k-* | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ - | i*86-* | i860-* | i960-* | ia64-* \ + | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ | ip2k-* | iq2000-* \ | k1om-* \ | le32-* | le64-* \ @@ -423,13 +426,15 @@ case $basic_machine in | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pru-* \ | pyramid-* \ + | riscv32-* | riscv64-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ @@ -437,6 +442,8 @@ case $basic_machine in | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ + | visium-* \ + | wasm32-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ @@ -450,7 +457,7 @@ case $basic_machine in # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) - basic_machine=i386-unknown + basic_machine=i386-pc os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) @@ -484,7 +491,7 @@ case $basic_machine in basic_machine=x86_64-pc ;; amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl @@ -513,6 +520,9 @@ case $basic_machine in basic_machine=i386-pc os=-aros ;; + asmjs) + basic_machine=asmjs-unknown + ;; aux) basic_machine=m68k-apple os=-aux @@ -526,7 +536,7 @@ case $basic_machine in os=-linux ;; blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) @@ -534,13 +544,13 @@ case $basic_machine in os=-cnk ;; c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray @@ -629,10 +639,18 @@ case $basic_machine in basic_machine=rs6000-bull os=-bosx ;; - dpx2* | dpx2*-bull) + dpx2*) basic_machine=m68k-bull os=-sysv3 ;; + e500v[12]) + basic_machine=powerpc-unknown + os=$os"spe" + ;; + e500v[12]-*) + basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=$os"spe" + ;; ebmon29k) basic_machine=a29k-amd os=-ebmon @@ -722,9 +740,6 @@ case $basic_machine in hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; - hppa-next) - os=-nextstep3 - ;; hppaosf) basic_machine=hppa1.1-hp os=-osf @@ -737,26 +752,26 @@ case $basic_machine in basic_machine=i370-ibm ;; i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; - i386-vsta | vsta) + vsta) basic_machine=i386-unknown os=-vsta ;; @@ -774,17 +789,17 @@ case $basic_machine in basic_machine=m68k-isi os=-sysv ;; + leon-*|leon[3-9]-*) + basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'` + ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=-linux ;; - m88k-omron*) - basic_machine=m88k-omron - ;; magnum | m3230) basic_machine=mips-mips os=-sysv @@ -816,10 +831,10 @@ case $basic_machine in os=-mint ;; mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'` ;; mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k @@ -838,7 +853,7 @@ case $basic_machine in os=-msdos ;; ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i686-pc @@ -880,7 +895,7 @@ case $basic_machine in basic_machine=v70-nec os=-sysv ;; - next | m*-next ) + next | m*-next) basic_machine=m68k-next case $os in -nextstep* ) @@ -925,6 +940,12 @@ case $basic_machine in nsr-tandem) basic_machine=nsr-tandem ;; + nsv-tandem) + basic_machine=nsv-tandem + ;; + nsx-tandem) + basic_machine=nsx-tandem + ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf @@ -957,7 +978,7 @@ case $basic_machine in os=-linux ;; parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=-linux ;; pbd) @@ -973,7 +994,7 @@ case $basic_machine in basic_machine=i386-pc ;; pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc @@ -988,16 +1009,16 @@ case $basic_machine in basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould @@ -1007,23 +1028,23 @@ case $basic_machine in ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; - ppcle | powerpclittle | ppc-le | powerpc-little) + ppcle | powerpclittle) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) + ppc64le | powerpc64little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm @@ -1077,17 +1098,10 @@ case $basic_machine in sequent) basic_machine=i386-sequent ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; sh5el) basic_machine=sh5le-unknown ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) + simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; @@ -1106,7 +1120,7 @@ case $basic_machine in os=-sysv4 ;; strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun @@ -1228,6 +1242,9 @@ case $basic_machine in basic_machine=hppa1.1-winbond os=-proelf ;; + x64) + basic_machine=x86_64-pc + ;; xbox) basic_machine=i686-pc os=-mingw32 @@ -1236,20 +1253,12 @@ case $basic_machine in basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim - ;; none) basic_machine=none-none os=-none @@ -1278,10 +1287,6 @@ case $basic_machine in vax) basic_machine=vax-dec ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; pdp11) basic_machine=pdp11-dec ;; @@ -1291,9 +1296,6 @@ case $basic_machine in sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun - ;; cydra) basic_machine=cydra-cydrome ;; @@ -1313,7 +1315,7 @@ case $basic_machine in # Make sure to match an already-canonicalized machine name. ;; *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 exit 1 ;; esac @@ -1321,10 +1323,10 @@ esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'` ;; *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'` ;; *) ;; @@ -1335,8 +1337,8 @@ esac if [ x"$os" != x"" ] then case $os in - # First match some system type aliases - # that might get confused with valid system types. + # First match some system type aliases that might get confused + # with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux @@ -1347,45 +1349,48 @@ case $os in -solaris) os=-solaris2 ;; - -svr4*) - os=-sysv4 - ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; - # First accept the basic system types. + # es1800 is here to avoid being matched by es* (a different OS) + -es1800*) + os=-ose + ;; + # Now accept the basic system types. # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. + # Each alternative MUST end in a * to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* \ + | -aos* | -aros* | -cloudabi* | -sortix* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* \ + | -hiux* | -knetbsd* | -mirbsd* | -netbsd* \ + | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* \ + | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -morphos* | -superux* | -rtmk* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ + | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* | -bme* \ + | -midnightbsd*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1402,12 +1407,12 @@ case $os in -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + -sim | -xray | -os68k* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) - os=`echo $os | sed -e 's|mac|macos|'` + os=`echo "$os" | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc @@ -1416,10 +1421,10 @@ case $os in os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` + os=`echo "$os" | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` + os=`echo "$os" | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition @@ -1430,12 +1435,6 @@ case $os in -wince*) os=-wince ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; -utek*) os=-bsd ;; @@ -1460,7 +1459,7 @@ case $os in -nova*) os=-rtmk-nova ;; - -ns2 ) + -ns2) os=-nextstep2 ;; -nsk*) @@ -1482,7 +1481,7 @@ case $os in -oss*) os=-sysv3 ;; - -svr4) + -svr4*) os=-sysv4 ;; -svr3) @@ -1497,32 +1496,38 @@ case $os in -ose*) os=-ose ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; - -aros*) - os=-aros - ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; + -pikeos*) + # Until real need of OS specific support for + # particular features comes up, bare metal + # configurations are quite functional. + case $basic_machine in + arm*) + os=-eabi + ;; + *) + os=-elf + ;; + esac + ;; -nacl*) ;; + -ios) + ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2 exit 1 ;; esac @@ -1612,12 +1617,12 @@ case $basic_machine in sparc-* | *-sun) os=-sunos4.1.1 ;; + pru-*) + os=-elf + ;; *-be) os=-beos ;; - *-haiku) - os=-haiku - ;; *-ibm) os=-aix ;; @@ -1657,7 +1662,7 @@ case $basic_machine in m88k-omron*) os=-luna ;; - *-next ) + *-next) os=-nextstep ;; *-sequent) @@ -1672,9 +1677,6 @@ case $basic_machine in i370-*) os=-mvs ;; - *-next) - os=-nextstep3 - ;; *-gould) os=-sysv ;; @@ -1784,15 +1786,15 @@ case $basic_machine in vendor=stratus ;; esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"` ;; esac -echo $basic_machine$os +echo "$basic_machine$os" exit # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'write-file-functions 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/configure b/configure index f70451d..f2af308 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for nut 2.7.4. +# Generated by GNU Autoconf 2.69 for nut 2.8.0. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='nut' PACKAGE_TARNAME='nut' -PACKAGE_VERSION='2.7.4' -PACKAGE_STRING='nut 2.7.4' +PACKAGE_VERSION='2.8.0' +PACKAGE_STRING='nut 2.8.0' PACKAGE_BUGREPORT='https://github.com/networkupstools/nut/issues' PACKAGE_URL='' @@ -634,12 +634,17 @@ ac_includes_default="\ #endif" ac_config_libobj_dir=common +ac_header_list= ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS +BUILDING_IN_TREE_FALSE +BUILDING_IN_TREE_TRUE udevdir hotplugdir -systemdsystemshutdowndir +auglensdir +systemdtmpfilesdir +systemdshutdowndir systemdsystemunitdir pkgconfigdir driverexecdir @@ -652,6 +657,8 @@ RUN_AS_USER PORT SBINDIR DRVPATH +NUT_LIBEXECDIR +NUT_DATADIR LIBDIR BINDIR CONFPATH @@ -666,9 +673,12 @@ LIBLTDL_LIBS LIBLTDL_CFLAGS LIBWRAP_LIBS LIBWRAP_CFLAGS +DOC_CHECK_LIST DOC_BUILD_LIST LIBIPMI_LIBS LIBIPMI_CFLAGS +LIBMODBUS_LIBS +LIBMODBUS_CFLAGS LIBPOWERMAN_LIBS LIBPOWERMAN_CFLAGS LIBAVAHI_LIBS @@ -681,34 +691,56 @@ LIBNETSNMP_LIBS LIBNETSNMP_CFLAGS LIBGD_LDFLAGS LIBGD_CFLAGS +LIBSSL_REQUIRES LIBSSL_LIBS LIBSSL_CFLAGS NUT_NETVERSION TREE_VERSION OS_NAME now +HAVE_SNMP_FALSE +HAVE_SNMP_TRUE +WITH_SNMP_FALSE +WITH_SNMP_TRUE +WITH_VALGRIND_FALSE +WITH_VALGRIND_TRUE +HAVE_VALGRIND_FALSE +HAVE_VALGRIND_TRUE +VALGRIND SYSTEM_AIX_FALSE SYSTEM_AIX_TRUE -HAVE_ASPELL_FALSE -HAVE_ASPELL_TRUE -ASPELL -MANUALUPDATE_FALSE -MANUALUPDATE_TRUE WITH_DEVD_FALSE WITH_DEVD_TRUE WITH_UDEV_FALSE WITH_UDEV_TRUE WITH_HOTPLUG_FALSE WITH_HOTPLUG_TRUE +HAVE_AUGPARSE_FALSE +HAVE_AUGPARSE_TRUE +AUGPARSE +WITH_AUGLENS_FALSE +WITH_AUGLENS_TRUE +HAVE_CPPUNIT_FALSE +HAVE_CPPUNIT_TRUE +CPPUNIT_LIBS +CPPUNIT_CFLAGS +HAVE_CXX11_FALSE +HAVE_CXX11_TRUE HAVE_SYSTEMD_FALSE HAVE_SYSTEMD_TRUE +WITH_SOLARIS_PKG_IPS_FALSE +WITH_SOLARIS_PKG_IPS_TRUE +WITH_SOLARIS_PKG_SVR4_FALSE +WITH_SOLARIS_PKG_SVR4_TRUE +WITH_SOLARIS_SMF_FALSE +WITH_SOLARIS_SMF_TRUE WITH_PKG_CONFIG_FALSE WITH_PKG_CONFIG_TRUE -SOME_DRIVERS_FALSE -SOME_DRIVERS_TRUE WITH_DEV_FALSE WITH_DEV_TRUE +LIBTOOL_DEPS CXXCPP +LT_SYS_LIBRARY_PATH OTOOL64 OTOOL LIPO @@ -718,7 +750,6 @@ MANIFEST_TOOL ac_ct_AR DLLTOOL OBJDUMP -LN_S NM ac_ct_DUMPBIN DUMPBIN @@ -726,18 +757,41 @@ LD FGREP SED LIBTOOL -HAVE_ASCIIDOC_FALSE -HAVE_ASCIIDOC_TRUE +DOC_INSTALL_DISTED_MANS_FALSE +DOC_INSTALL_DISTED_MANS_TRUE +SKIP_MANS_FALSE +SKIP_MANS_TRUE +WITH_MANS_FALSE +WITH_MANS_TRUE +WITH_DOCS_FALSE +WITH_DOCS_TRUE WITH_ASCIIDOC_FALSE WITH_ASCIIDOC_TRUE +HAVE_ASCIIDOC_FALSE +HAVE_ASCIIDOC_TRUE +HAVE_ASPELL_FALSE +HAVE_ASPELL_TRUE +ASPELL +HAVE_SOURCE_HIGHLIGHT_FALSE +HAVE_SOURCE_HIGHLIGHT_TRUE SOURCE_HIGHLIGHT XMLLINT XSLTPROC DBLATEX A2X +MANUALUPDATE_FALSE +MANUALUPDATE_TRUE ASCIIDOC +WITH_CHECK_NIT_FALSE +WITH_CHECK_NIT_TRUE +WITH_CPPCHECK_FALSE +WITH_CPPCHECK_TRUE +HAVE_CPPCHECK_FALSE +HAVE_CPPCHECK_TRUE +CPPCHECK WITH_CGI_FALSE WITH_CGI_TRUE +GDLIB_CONFIG WITH_LIBLTDL_FALSE WITH_LIBLTDL_TRUE WITH_WRAP_FALSE @@ -756,34 +810,54 @@ WITH_FREEIPMI_FALSE WITH_FREEIPMI_TRUE WITH_IPMI_FALSE WITH_IPMI_TRUE +WITH_MODBUS_FALSE +WITH_MODBUS_TRUE WITH_LIBPOWERMAN_FALSE WITH_LIBPOWERMAN_TRUE WITH_AVAHI_FALSE WITH_AVAHI_TRUE +HAVE_NEON_FALSE +HAVE_NEON_TRUE WITH_NEON_FALSE WITH_NEON_TRUE -WITH_SNMP_FALSE -WITH_SNMP_TRUE WITH_USB_FALSE WITH_USB_TRUE +WITH_LIBUSB_0_1_FALSE +WITH_LIBUSB_0_1_TRUE +WITH_LIBUSB_1_0_FALSE +WITH_LIBUSB_1_0_TRUE WITH_SERIAL_FALSE WITH_SERIAL_TRUE -HAVE_CPPUNIT_FALSE -HAVE_CPPUNIT_TRUE -CPPUNIT_LIBS -CPPUNIT_CFLAGS -PKG_CONFIG_LIBDIR -PKG_CONFIG_PATH -PKG_CONFIG +NET_SNMP_CONFIG +LIBUSB_CONFIG +SOME_DRIVERS_FALSE +SOME_DRIVERS_TRUE +HAVE_PYTHON3_FALSE +HAVE_PYTHON3_TRUE +PYTHON3 +HAVE_PYTHON2_FALSE +HAVE_PYTHON2_TRUE +PYTHON2 +HAVE_PYTHON_FALSE +HAVE_PYTHON_TRUE +PYTHON LIBOBJS +LN_S_R RANLIB AR +LN_S am__fastdepCXX_FALSE am__fastdepCXX_TRUE CXXDEPMODE ac_ct_CXX CXXFLAGS CXX +dummy_PKG_CONFIG_LIBS +dummy_PKG_CONFIG_CFLAGS +PKG_CONFIG_LIBDIR +PKG_CONFIG_PATH +PKG_CONFIG +dummy_PKG_CONFIG MAINT MAINTAINER_MODE_FALSE MAINTAINER_MODE_TRUE @@ -797,7 +871,6 @@ am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE -am__quote am__include DEPDIR OBJEXT @@ -865,6 +938,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -883,30 +957,45 @@ PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR -SHELL' +SHELL +am__quote' ac_subst_files='' ac_user_opts=' enable_option_checking enable_silent_rules enable_dependency_tracking enable_maintainer_mode +with_pkg_config +enable_Wcolor +with_python +with_python2 +with_python3 +with_drivers with_all with_dev +with_docs +with_doc +enable_warnings +enable_Werror with_serial with_usb -with_doc -with_avahi -with_snmp_includes -with_snmp_libs +with_libusb_config with_usb_includes with_usb_libs with_snmp +with_net_snmp_config +with_snmp_includes +with_snmp_libs with_neon with_neon_includes with_neon_libs with_powerman with_powerman_includes with_powerman_libs +with_modbus +with_modbus_includes +with_modbus_libs +with_avahi with_avahi_includes with_avahi_libs with_ipmi @@ -927,12 +1016,16 @@ with_libltdl with_libltdl_includes with_libltdl_libs with_cgi +with_gdlib_config with_gd_includes with_gd_libs +enable_cppcheck +enable_check_NIT enable_shared enable_static with_pic enable_fast_install +with_aix_soname with_gnu_ld with_sysroot enable_libtool_lock @@ -946,13 +1039,20 @@ with_port with_user with_group with_logfacility -with_drivers enable_strip with_pkgconfig_dir +with_solaris_smf +with_solaris_pkg_svr4 +with_solaris_pkg_ips with_systemdsystemunitdir +with_systemdshutdowndir +with_systemdtmpfilesdir +enable_cppunit +with_augeas_lenses_dir with_hotplug_dir with_udev_dir with_devd_dir +with_valgrind ' ac_precious_vars='build_alias host_alias @@ -963,15 +1063,18 @@ LDFLAGS LIBS CPPFLAGS CPP -CXX -CXXFLAGS -CCC PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR +dummy_PKG_CONFIG_CFLAGS +dummy_PKG_CONFIG_LIBS +CXX +CXXFLAGS +CCC +LT_SYS_LIBRARY_PATH +CXXCPP CPPUNIT_CFLAGS -CPPUNIT_LIBS -CXXCPP' +CPPUNIT_LIBS' # Initialize some variables set by options. @@ -1010,6 +1113,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1262,6 +1366,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1399,7 +1512,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1512,7 +1625,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures nut 2.7.4 to adapt to many kinds of systems. +\`configure' configures nut 2.8.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1552,6 +1665,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -1583,7 +1697,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of nut 2.7.4:";; + short | recursive ) echo "Configuration of nut 2.8.0:";; esac cat <<\_ACEOF @@ -1600,30 +1714,65 @@ Optional Features: --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer + --enable-Wcolor Request that compiler output is colorized (no = + leave it up to compiler defaults) (no) + --enable-warnings enable warning presets that were picked as useful in + maintainership and CI practice (variants include + gcc-minimal, gcc-medium, gcc-hard, clang-minimal, + clang-medium, clang-hard, all; auto-choosers: hard, + medium, minimal, yes=auto='gcc or clang or all at + hardcoded default difficulty') (auto) + --enable-Werror fail the build if compiler emits any warnings (treat + them as errors) (no) + --enable-cppcheck Run a cppcheck on the codebase among checks (no) + --enable-check-NIT Run check-NIT among default checks (no) --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --enable-strip Strip debugging symbols from binaries (no) + --enable-cppunit enable CPPUNIT tests for C++ bindings Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-all enable serial, usb, snmp, neon, ipmi, powerman, cgi, - dev, avahi, linux_i2c + [--with-pkg-config=/path/to/gdlib-config] + path to program that reports development package + configuration + --with-python Use a particular program name of the python + interpeter (auto) + --with-python2 Use a particular program name of the python2 + interpeter for code that needs that version and is + not compatible with python3 (auto) + --with-python3 Use a particular program name of the python3 + interpeter for code that needs that version and is + not compatible with python2 (auto) + [--with-drivers=driver[,driver]] + Only build specific drivers (all) + --with-all enable serial, usb, snmp, neon, ipmi, powerman, + modbus, cgi, dev, avahi, linux_i2c --with-dev build and install the development files (no) + --with-docs build and install documentation (alias to + --with-doc) (man=auto) + --with-doc build and install documentation (see + docs/configure.txt for many variants of the option) + (${nut_with_docs}) --with-serial build and install serial drivers (yes) - --with-usb build and install USB drivers (auto) - --with-doc build and install documentation (no) - --with-avahi build and install Avahi support (auto) - [--with-snmp-includes=CFLAGS] - include flags for the Net-SNMP library - [--with-snmp-libs=LIBS] linker flags for the Net-SNMP library + --with-usb build and install USB drivers, optionally require + build with specified version of libusb library and + API: (auto|libusb-0.1|libusb-1.0) (auto) + [--with-libusb-config=/path/to/libusb-config] + path to program that reports LibUSB configuration [--with-usb-includes=CFLAGS] include flags for the libusb library [--with-usb-libs=LIBS] linker flags for the libusb library --with-snmp build and install SNMP drivers (auto) + [--with-net-snmp-config=/path/to/net-snmp-config] + path to program that reports Net-SNMP configuration + [--with-snmp-includes=CFLAGS] + include flags for the Net-SNMP library + [--with-snmp-libs=LIBS] linker flags for the Net-SNMP library --with-neon build and install neon based XML/HTTP driver (auto) [--with-neon-includes=CFLAGS] include flags for the neon library @@ -1633,6 +1782,12 @@ Optional Packages: include flags for the libpowerman library [--with-powerman-libs=LIBS] linker flags for the libpowerman library + --with-modbus build and install modbus drivers (auto) + [--with-modbus-includes=CFLAGS] + include flags for the libmodbus library + [--with-modbus-libs=LIBS] + linker flags for the libmodbus library + --with-avahi build and install Avahi support (auto) [--with-avahi-includes=CFLAGS] include flags for the avahi library [--with-avahi-libs=LIBS] @@ -1664,15 +1819,20 @@ Optional Packages: [--with-libltdl-libs=LIBS] linker flags for the libltdl library --with-cgi build and install the CGI programs (no) + [--with-gdlib-config=/path/to/gdlib-config] + path to program that reports GDLIB configuration [--with-gd-includes=CFLAGS] include flags for the gd library [--with-gd-libs=LDFLAGS] linker flags for the gd library --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] + --with-aix-soname=aix|svr4|both + shared library versioning (aka "SONAME") variant to + provide on AIX, [default=aix]. --with-gnu-ld assume the C compiler uses GNU ld [default=no] - --with-sysroot=DIR Search for dependent libraries within DIR - (or the compiler's sysroot if not specified). + --with-sysroot[=DIR] Search for dependent libraries within DIR (or the + compiler's sysroot if not specified). --with-statepath=PATH path for ups state files (/var/state/ups) --with-altpidpath=PATH path for driver/upsd .pid files () --with-drvpath=PATH where to install UPS drivers (EPREFIX/bin) @@ -1680,22 +1840,35 @@ Optional Packages: --with-htmlpath=PATH where to install HTML files (PREFIX/html) --with-pidpath=PATH path for .pid files (/var/run) --with-port=PORT port for network communications (3493) - --with-user=username user for programs started as root (nobody) + --with-user=username user for programs started as root (${RUN_AS_USER}) --with-group=groupname group membership of user for programs started as - root (nogroup) + root (${RUN_AS_GROUP}) --with-logfacility=FACILITY facility for log messages (LOG_DAEMON) - [--with-drivers=driver[,driver]] - Only build specific drivers (all) --with-pkgconfig-dir=PATH where to install pkg-config *.pc files (EPREFIX/lib/pkgconfig) + --with-solaris-smf=(yes|auto|no) + Enable installation of NUT scripts and manifests for + Solaris Service Management Framework (auto) + --with-solaris-pkg-svr4=(yes|auto|no) + Enable construction of Solaris SVR4 packages (auto) + --with-solaris-pkg-ips=(yes|auto|no) + Enable construction of Solaris IPS packages (auto) --with-systemdsystemunitdir=DIR Directory for systemd service files (auto) + --with-systemdshutdowndir=DIR + Directory for systemd shutdown scripts (auto) + --with-systemdtmpfilesdir=DIR + Directory for systemd tmpfiles scripts (auto) + --with-augeas-lenses-dir=PATH + where to install Augeas configuration-management + lenses (/usr/share/augeas/lenses{/dist,/}) --with-hotplug-dir=PATH where to install hotplug rules (/etc/hotplug) --with-udev-dir=PATH where to install udev rules (/lib/udev or /etc/udev) --with-devd-dir=PATH where to install devd.conf file (/usr/local/etc/devd or /etc/devd) + --with-valgrind=PATH whether to use valgrind for memory-leak testing Some influential environment variables: CC C compiler command @@ -1706,18 +1879,24 @@ Some influential environment variables: CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor - CXX C++ compiler command - CXXFLAGS C++ compiler flags PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path + dummy_PKG_CONFIG_CFLAGS + C compiler flags for dummy_PKG_CONFIG, overriding pkg-config + dummy_PKG_CONFIG_LIBS + linker flags for dummy_PKG_CONFIG, overriding pkg-config + CXX C++ compiler command + CXXFLAGS C++ compiler flags + LT_SYS_LIBRARY_PATH + User-defined run-time library search path. + CXXCPP C++ preprocessor CPPUNIT_CFLAGS C compiler flags for CPPUNIT, overriding pkg-config CPPUNIT_LIBS linker flags for CPPUNIT, overriding pkg-config - CXXCPP C++ preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -1785,7 +1964,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -nut configure 2.7.4 +nut configure 2.8.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2122,6 +2301,94 @@ fi } # ac_fn_c_try_link +# ac_fn_cxx_try_link LINENO +# ------------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_link + +# ac_fn_cxx_try_run LINENO +# ------------------------ +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_cxx_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_run + # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly @@ -2289,6 +2556,189 @@ $as_echo "$ac_res" >&6; } } # ac_fn_c_check_type +# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES +# -------------------------------------------- +# Tries to find the compile-time value of EXPR in a program that includes +# INCLUDES, setting VAR accordingly. Returns whether the value could be +# computed +ac_fn_c_compute_int () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=0 ac_mid=0 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid; break +else + as_fn_arith $ac_mid + 1 && ac_lo=$as_val + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) < 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=-1 ac_mid=-1 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=$ac_mid; break +else + as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + ac_lo= ac_hi= +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid +else + as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in #(( +?*) eval "$3=\$ac_lo"; ac_retval=0 ;; +'') ac_retval=1 ;; +esac + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +static long int longval () { return $2; } +static unsigned long int ulongval () { return $2; } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (($2) < 0) + { + long int i = longval (); + if (i != ($2)) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ($2)) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + echo >>conftest.val; read $3 &5 - (eval "$ac_link") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - test -x conftest$ac_exeext - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_cxx_try_link cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by nut $as_me 2.7.4, which was +It was created by nut $as_me 2.8.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2655,6 +3059,11 @@ $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi +as_fn_append ac_header_list " sys/time.h" +as_fn_append ac_header_list " time.h" +as_fn_append ac_header_list " sys/types.h" +as_fn_append ac_header_list " sys/socket.h" +as_fn_append ac_header_list " netdb.h" # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false @@ -2723,11 +3132,8 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -echo "Network UPS Tools version ${PACKAGE_VERSION}" ac_aux_dir= -for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do +for ac_dir in . "$srcdir"/.; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" @@ -2743,7 +3149,7 @@ for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do fi done if test -z "$ac_aux_dir"; then - as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 + as_fn_error $? "cannot find install-sh, install.sh, or shtool in . \"$srcdir\"/." "$LINENO" 5 fi # These three variables are undocumented and unsupported, @@ -2755,6 +3161,9 @@ ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +echo "Network UPS Tools version ${PACKAGE_VERSION}" # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 @@ -2866,7 +3275,6 @@ test -n "$target_alias" && NONENONEs,x,x, && program_prefix=${target_alias}- - os_get_name() { case "$1" in (*CentOS*|*CENTOS*) echo 'centos' ;; @@ -3005,10 +3413,74 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dist_cv_build_flavor" >&5 $as_echo "$dist_cv_build_flavor" >&6; } + + CFLAGS_STASHED_WARNINGS="" + CPPFLAGS_STASHED_WARNINGS="" + CXXFLAGS_STASHED_WARNINGS="" + + if test -z "$CFLAGS"; then : + +else + + TMP="" + for V in ${CFLAGS} ; do + case "$V" in + -W*|-*pedantic*) CFLAGS_STASHED_WARNINGS="${CFLAGS_STASHED_WARNINGS} ${V}" ;; + *) TMP="${TMP} ${V}" ;; + esac + done + CFLAGS="$TMP" + +fi + if test -n "${CFLAGS_STASHED_WARNINGS}"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: Stashed CFLAGS warnings to not confuse autotools probes: ${CFLAGS_STASHED_WARNINGS}" >&5 +$as_echo "$as_me: Stashed CFLAGS warnings to not confuse autotools probes: ${CFLAGS_STASHED_WARNINGS}" >&6;} +fi + + if test -z "$CPPFLAGS"; then : + +else + + TMP="" + for V in ${CPPFLAGS} ; do + case "$V" in + -W*|-*pedantic*) CPPFLAGS_STASHED_WARNINGS="${CPPFLAGS_STASHED_WARNINGS} ${V}" ;; + *) TMP="${TMP} ${V}" ;; + esac + done + CPPFLAGS="$TMP" + +fi + if test -n "${CPPFLAGS_STASHED_WARNINGS}"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: Stashed CPPFLAGS warnings to not confuse autotools probes: ${CPPFLAGS_STASHED_WARNINGS}" >&5 +$as_echo "$as_me: Stashed CPPFLAGS warnings to not confuse autotools probes: ${CPPFLAGS_STASHED_WARNINGS}" >&6;} +fi + + + if test -z "$CXXFLAGS"; then : + +else + + TMP="" + for V in ${CXXFLAGS} ; do + case "$V" in + -W*|-*pedantic*) CXXFLAGS_STASHED_WARNINGS="${CXXFLAGS_STASHED_WARNINGS} ${V}" ;; + *) TMP="${TMP} ${V}" ;; + esac + done + CXXFLAGS="$TMP" + +fi + if test -n "${CXXFLAGS_STASHED_WARNINGS}"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: Stashed CXXFLAGS warnings to not confuse autotools probes: ${CXXFLAGS_STASHED_WARNINGS}" >&5 +$as_echo "$as_me: Stashed CXXFLAGS warnings to not confuse autotools probes: ${CXXFLAGS_STASHED_WARNINGS}" >&6;} +fi + + ac_config_headers="$ac_config_headers include/config.h" -am__api_version='1.14' +am__api_version='1.16' # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or @@ -3184,12 +3656,7 @@ program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` am_aux_dir=`cd "$ac_aux_dir" && pwd` if test x"${MISSING+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; - *) - MISSING="\${SHELL} $am_aux_dir/missing" ;; - esac + MISSING="\${SHELL} '$am_aux_dir/missing'" fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then @@ -3200,7 +3667,7 @@ else $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi -if test x"${install_sh}" != xset; then +if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; @@ -3494,7 +3961,7 @@ fi # Define the identity of the package. PACKAGE='nut' - VERSION='2.7.4' + VERSION='2.8.0' cat >>confdefs.h <<_ACEOF @@ -3524,12 +3991,12 @@ MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: -# -# +# +# mkdir_p='$(MKDIR_P)' -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. +# We need awk for the "check" target (and possibly the TAP driver). The +# system "awk" is bad on some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' @@ -3576,7 +4043,7 @@ END Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation -that behaves properly: . +that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM @@ -3597,45 +4064,45 @@ $as_echo "yes" >&6; } ac_config_commands="$ac_config_commands depfiles" - -am_make=${MAKE-make} -cat > confinc << 'END' +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5 +$as_echo_n "checking whether ${MAKE-make} supports the include directive... " >&6; } +cat > confinc.mk << 'END' am__doit: - @echo this is the am__doit target + @echo this is the am__doit target >confinc.out .PHONY: am__doit END -# If we don't find an include directive, just comment out the code. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 -$as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# Ignore all kinds of additional output from 'make'. -case `$am_make -s -f confmf 2> /dev/null` in #( -*the\ am__doit\ target*) - am__include=include - am__quote= - _am_result=GNU - ;; -esac -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - case `$am_make -s -f confmf 2> /dev/null` in #( - *the\ am__doit\ target*) - am__include=.include - am__quote="\"" - _am_result=BSD +# BSD make does it like this. +echo '.include "confinc.mk" # ignored' > confmf.BSD +# Other make implementations (GNU, Solaris 10, AIX) do it like this. +echo 'include confinc.mk # ignored' > confmf.GNU +_am_result=no +for s in GNU BSD; do + { echo "$as_me:$LINENO: ${MAKE-make} -f confmf.$s && cat confinc.out" >&5 + (${MAKE-make} -f confmf.$s && cat confinc.out) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + case $?:`cat confinc.out 2>/dev/null` in #( + '0:this is the am__doit target') : + case $s in #( + BSD) : + am__include='.include' am__quote='"' ;; #( + *) : + am__include='include' am__quote='' ;; +esac ;; #( + *) : ;; - esac -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 -$as_echo "$_am_result" >&6; } -rm -f confinc confmf +esac + if test "$am__include" != "#"; then + _am_result="yes ($s style)" + break + fi +done +rm -f confinc.* confmf.* +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5 +$as_echo "${_am_result}" >&6; } # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : @@ -5094,6 +5561,8 @@ $as_echo "$ac_cv_safe_to_define___extensions__" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } # Check whether --enable-maintainer-mode was given. @@ -5120,6 +5589,360 @@ fi + + + + +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. +set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +PKG_CONFIG=$ac_cv_path_PKG_CONFIG +if test -n "$PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 +$as_echo "$PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_path_PKG_CONFIG"; then + ac_pt_PKG_CONFIG=$PKG_CONFIG + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $ac_pt_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG +if test -n "$ac_pt_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 +$as_echo "$ac_pt_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_pt_PKG_CONFIG" = x; then + PKG_CONFIG="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + PKG_CONFIG=$ac_pt_PKG_CONFIG + fi +else + PKG_CONFIG="$ac_cv_path_PKG_CONFIG" +fi + +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=0.9.0 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 +$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG="" + fi +fi + +if test -z "${nut_have_pkg_config_seen}"; then : + + nut_have_pkg_config_seen=yes + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG was already detected by autoconf" >&5 +$as_echo_n "checking whether usable PKG_CONFIG was already detected by autoconf... " >&6; } + if test -n "${PKG_CONFIG-}" && test x"${PKG_CONFIG-}" != x"false" && $PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${PKG_CONFIG}" >&5 +$as_echo "yes: ${PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + + if test x"${PKG_CONFIG-}" = x"false"; then : + have_PKG_CONFIG=yes + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_dummy_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $dummy_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_dummy_PKG_CONFIG="$dummy_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_dummy_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +dummy_PKG_CONFIG=$ac_cv_path_dummy_PKG_CONFIG +if test -n "$dummy_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dummy_PKG_CONFIG" >&5 +$as_echo "$dummy_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + +# Check whether --with-pkg-config was given. +if test "${with_pkg_config+set}" = set; then : + withval=$with_pkg_config; + case "${withval}" in + "") ;; + yes|no) + as_fn_error $? "invalid option --with(out)-pkg-config - see docs/configure.txt" "$LINENO" 5 + ;; + *) + dummy_PKG_CONFIG="${withval}" + ;; + esac + +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG is present in PATH or was set by caller" >&5 +$as_echo_n "checking whether usable PKG_CONFIG is present in PATH or was set by caller... " >&6; } + if test x"$dummy_PKG_CONFIG" = xno || test -z "$dummy_PKG_CONFIG"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + +else + if $dummy_PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${dummy_PKG_CONFIG}" >&5 +$as_echo "yes: ${dummy_PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + PKG_CONFIG="$dummy_PKG_CONFIG" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + +fi + +fi + + have_PKG_CONFIG_MACROS=no + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&6;} + dummy_RES=0 + + + if test "${dummy_RES}" = 0; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config module checker" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config module checker" >&6;} + + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pkg-config" >&5 +$as_echo_n "checking for pkg-config... " >&6; } + +if test -n "$dummy_PKG_CONFIG_CFLAGS"; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS="$dummy_PKG_CONFIG_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS=`$PKG_CONFIG --cflags "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$dummy_PKG_CONFIG_LIBS"; then + pkg_cv_dummy_PKG_CONFIG_LIBS="$dummy_PKG_CONFIG_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_LIBS=`$PKG_CONFIG --libs "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "pkg-config" 2>&1` + else + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "pkg-config" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$dummy_PKG_CONFIG_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (pkg-config) were not met: + +$dummy_PKG_CONFIG_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + dummy_PKG_CONFIG_CFLAGS=$pkg_cv_dummy_PKG_CONFIG_CFLAGS + dummy_PKG_CONFIG_LIBS=$pkg_cv_dummy_PKG_CONFIG_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + have_PKG_CONFIG_MACROS=yes +fi + + +fi + +fi + + if test x"$have_PKG_CONFIG" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&5 +$as_echo "$as_me: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&2;} + PKG_CONFIG="false" + +else + if test x"$have_PKG_CONFIG_MACROS" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&5 +$as_echo "$as_me: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&2;} + +fi + +fi + + +fi + + + + TREE_VERSION="`echo ${PACKAGE_VERSION} | awk '{ print substr($0,1,3) }'`" cat >>confdefs.h <<_ACEOF @@ -5127,7 +5950,7 @@ cat >>confdefs.h <<_ACEOF _ACEOF -NUT_NETVERSION="1.2" +NUT_NETVERSION="1.3" cat >>confdefs.h <<_ACEOF #define NUT_NETVERSION "${NUT_NETVERSION}" @@ -5148,6 +5971,13 @@ cgiexecdir='${exec_prefix}/cgi-bin' driverexecdir='${exec_prefix}/bin' htmldir='${prefix}/html' pkgconfigdir='${libdir}/pkgconfig' +auglensdir='/usr/share/augeas/lenses/dist' +if test ! -d "${auglensdir}"; then + auglensdir='/usr/share/augeas/lenses' + if test ! -d "${auglensdir}"; then + auglensdir='' + fi +fi hotplugdir='/etc/hotplug' if test ! -d "${hotplugdir}"; then hotplugdir='' @@ -5170,737 +6000,15 @@ fi RUN_AS_USER="nobody" RUN_AS_GROUP="nobody" +if test -n "`getent group nogroup`" && ! test -n "`getent group "${RUN_AS_GROUP}"`"; then : + RUN_AS_GROUP="nogroup" + +fi PIDPATH="/var/run" -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } - -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if ${ac_cv_c_compiler_gnu+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -struct stat; -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : - -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 -$as_echo_n "checking whether $CC understands -c and -o together... " >&6; } -if ${am_cv_prog_cc_c_o+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF - # Make sure it works both with $CC and with simple cc. - # Following AC_PROG_CC_C_O, we do the test twice because some - # compilers refuse to overwrite an existing .o file with -o, - # though they will create one. - am_cv_prog_cc_c_o=yes - for am_i in 1 2; do - if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 - ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } \ - && test -f conftest2.$ac_objext; then - : OK - else - am_cv_prog_cc_c_o=no - break - fi - done - rm -f core conftest* - unset am_i -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 -$as_echo "$am_cv_prog_cc_c_o" >&6; } -if test "$am_cv_prog_cc_c_o" != yes; then - # Losing compiler, so override with the script. - # FIXME: It is wrong to rewrite CC. - # But if we don't then we get into trouble of one sort or another. - # A longer-term fix would be to have automake use am__CC in this case, - # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" - CC="$am_aux_dir/compile $CC" -fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -depcc="$CC" am_compiler_list= - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 -$as_echo_n "checking dependency style of $depcc... " >&6; } -if ${am_cv_CC_dependencies_compiler_type+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named 'D' -- because '-MD' means "put the output - # in D". - rm -rf conftest.dir - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub - - am_cv_CC_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` - fi - am__universal=false - case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac - - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with - # Solaris 10 /bin/sh. - echo '/* dummy */' > sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - - # We check with '-c' and '-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle '-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs. - am__obj=sub/conftest.${OBJEXT-o} - am__minus_obj="-o $am__obj" - case $depmode in - gcc) - # This depmode causes a compiler race in universal mode. - test "$am__universal" = false || continue - ;; - nosideeffect) - # After this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested. - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - msvc7 | msvc7msys | msvisualcpp | msvcmsys) - # This compiler won't grok '-c -o', but also, the minuso test has - # not run yet. These depmodes are late enough in the game, and - # so weak that their functioning should not be impacted. - am__obj=conftest.${OBJEXT-o} - am__minus_obj= - ;; - none) break ;; - esac - if depmode=$depmode \ - source=sub/conftest.c object=$am__obj \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_CC_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_CC_dependencies_compiler_type=none -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 -$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } -CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type - - if - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then - am__fastdepCC_TRUE= - am__fastdepCC_FALSE='#' -else - am__fastdepCC_TRUE='#' - am__fastdepCC_FALSE= -fi - - ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -6424,6 +6532,83 @@ else fi +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX understands -c and -o together" >&5 +$as_echo_n "checking whether $CXX understands -c and -o together... " >&6; } +if ${ac_cv_prog_cxx_c_o+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +# We test twice because some compilers refuse to overwrite an existing +# `.o' file with `-o', although they will create one. +ac_try='$CXX $CXXFLAGS -c conftest.$ac_ext -o conftest2.$ac_objext >&5' +rm -f conftest2.* +if { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && + test -f conftest2.$ac_objext && + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + ac_cv_prog_cxx_c_o=yes +else + ac_cv_prog_cxx_c_o=no +fi +rm -f conftest* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_c_o" >&5 +$as_echo "$ac_cv_prog_cxx_c_o" >&6; } +if test $ac_cv_prog_cxx_c_o = no; then + +$as_echo "#define CXX_NO_MINUS_C_MINUS_O 1" >>confdefs.h + +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 +$as_echo_n "checking whether ln -s works... " >&6; } +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 +$as_echo "no, using $LN_S" >&6; } +fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } @@ -6964,7 +7149,3825 @@ $as_echo "#define HAVE_C_VARARRAYS 1" >>confdefs.h fi -for ac_func in flock lockf fcvt fcvtl + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if CC compiler family is GCC" >&5 +$as_echo_n "checking if CC compiler family is GCC... " >&6; } +if ${nut_cv_GCC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then : + if $CC --version 2>&1 | grep 'Free Software Foundation' > /dev/null; then : + nut_cv_GCC=yes +else + nut_cv_GCC=no +fi +else + as_fn_error $? "CC is not set" "$LINENO" 5 + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $nut_cv_GCC" >&5 +$as_echo "$nut_cv_GCC" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if CXX compiler family is GCC" >&5 +$as_echo_n "checking if CXX compiler family is GCC... " >&6; } +if ${nut_cv_GXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CXX"; then : + if $CXX --version 2>&1 | grep 'Free Software Foundation' > /dev/null; then : + nut_cv_GXX=yes +else + nut_cv_GXX=no +fi +else + as_fn_error $? "CXX is not set" "$LINENO" 5 + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $nut_cv_GXX" >&5 +$as_echo "$nut_cv_GXX" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if CPP preprocessor family is GCC" >&5 +$as_echo_n "checking if CPP preprocessor family is GCC... " >&6; } +if ${nut_cv_GPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CPP"; then : + if $CPP --version 2>&1 | grep 'Free Software Foundation' > /dev/null; then : + nut_cv_GPP=yes +else + nut_cv_GPP=no +fi +else + as_fn_error $? "CPP is not set" "$LINENO" 5 + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $nut_cv_GPP" >&5 +$as_echo "$nut_cv_GPP" >&6; } + + if test "x$GCC" = "x" && test "$nut_cv_GCC" = yes; then : + GCC=yes +fi + if test "x$GXX" = "x" && test "$nut_cv_GXX" = yes; then : + GXX=yes +fi + if test "x$GPP" = "x" && test "$nut_cv_GPP" = yes; then : + GPP=yes +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if CC compiler family is clang" >&5 +$as_echo_n "checking if CC compiler family is clang... " >&6; } +if ${nut_cv_CLANGCC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then : + if $CC --version 2>&1 | grep -E '(clang version|Apple LLVM version .*clang-)' > /dev/null; then : + nut_cv_CLANGCC=yes +else + nut_cv_CLANGCC=no +fi +else + as_fn_error $? "CC is not set" "$LINENO" 5 + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $nut_cv_CLANGCC" >&5 +$as_echo "$nut_cv_CLANGCC" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if CXX compiler family is clang" >&5 +$as_echo_n "checking if CXX compiler family is clang... " >&6; } +if ${nut_cv_CLANGXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CXX"; then : + if $CXX --version 2>&1 | grep -E '(clang version|Apple LLVM version .*clang-)' > /dev/null; then : + nut_cv_CLANGXX=yes +else + nut_cv_CLANGXX=no +fi +else + as_fn_error $? "CXX is not set" "$LINENO" 5 + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $nut_cv_CLANGXX" >&5 +$as_echo "$nut_cv_CLANGXX" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if CPP preprocessor family is clang" >&5 +$as_echo_n "checking if CPP preprocessor family is clang... " >&6; } +if ${nut_cv_CLANGPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CPP"; then : + if $CPP --version 2>&1 | grep -E '(clang version|Apple LLVM version .*clang-)' > /dev/null; then : + nut_cv_CLANGPP=yes +else + nut_cv_CLANGPP=no +fi +else + as_fn_error $? "CPP is not set" "$LINENO" 5 + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $nut_cv_CLANGPP" >&5 +$as_echo "$nut_cv_CLANGPP" >&6; } + + if test "x$CLANGCC" = "x" && test "$nut_cv_CLANGCC" = yes; then : + CLANGCC=yes +fi + if test "x$CLANGXX" = "x" && test "$nut_cv_CLANGXX" = yes; then : + CLANGXX=yes +fi + if test "x$CLANGPP" = "x" && test "$nut_cv_CLANGPP" = yes; then : + CLANGPP=yes +fi + + # Check whether --enable-Wcolor was given. +if test "${enable_Wcolor+set}" = set; then : + enableval=$enable_Wcolor; nut_enable_Wcolor="${enableval}" +else + nut_enable_Wcolor="no" + +fi + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: Detecting support for additional compiler flags" >&5 +$as_echo "$as_me: Detecting support for additional compiler flags" >&6;} + + + + + COMPILERFLAG="-Qunused-arguments" + + SAVED_CFLAGS="$CFLAGS" + SAVED_CXXFLAGS="$CXXFLAGS" + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + as_CACHEVAR=`$as_echo "ax_cv_check_cflags_-Werror_${COMPILERFLAG}" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts ${COMPILERFLAG}" >&5 +$as_echo_n "checking whether C compiler accepts ${COMPILERFLAG}... " >&6; } +if eval \${$as_CACHEVAR+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -Werror ${COMPILERFLAG}" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + if grep -E '(unrecognized.* option|did you mean|unknown argument:)' < conftest.err >/dev/null 2>/dev/null; then : + eval "$as_CACHEVAR=no" +else + eval "$as_CACHEVAR=yes" +fi +else + eval "$as_CACHEVAR=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$ax_check_save_flags +fi +eval ac_res=\$$as_CACHEVAR + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_CACHEVAR"\" = x"yes"; then : + CFLAGS="$CFLAGS ${COMPILERFLAG}" + + if test "$cross_compiling" = yes; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&5 +$as_echo "$as_me: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&2;} + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + +else + CFLAGS="$SAVED_CFLAGS" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + CFLAGS="$SAVED_CFLAGS" +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + + +else + : +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + as_CACHEVAR=`$as_echo "ax_cv_check_cxxflags_-Werror_${COMPILERFLAG}" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C++ compiler accepts ${COMPILERFLAG}" >&5 +$as_echo_n "checking whether C++ compiler accepts ${COMPILERFLAG}... " >&6; } +if eval \${$as_CACHEVAR+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CXXFLAGS + CXXFLAGS="$CXXFLAGS -Werror ${COMPILERFLAG}" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + if grep -E '(unrecognized.* option|did you mean|unknown argument:)' < conftest.err >/dev/null 2>/dev/null; then : + eval "$as_CACHEVAR=no" +else + eval "$as_CACHEVAR=yes" +fi +else + eval "$as_CACHEVAR=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXXFLAGS=$ax_check_save_flags +fi +eval ac_res=\$$as_CACHEVAR + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_CACHEVAR"\" = x"yes"; then : + CXXFLAGS="$CXXFLAGS ${COMPILERFLAG}" + + if test "$cross_compiling" = yes; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&5 +$as_echo "$as_me: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&2;} + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + +else + CXXFLAGS="$SAVED_CXXFLAGS" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_run "$LINENO"; then : + +else + CXXFLAGS="$SAVED_CXXFLAGS" +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + + +else + : +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + + + COMPILERFLAG="-Wno-reserved-identifier" + + SAVED_CFLAGS="$CFLAGS" + SAVED_CXXFLAGS="$CXXFLAGS" + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + as_CACHEVAR=`$as_echo "ax_cv_check_cflags_-Werror_${COMPILERFLAG}" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts ${COMPILERFLAG}" >&5 +$as_echo_n "checking whether C compiler accepts ${COMPILERFLAG}... " >&6; } +if eval \${$as_CACHEVAR+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -Werror ${COMPILERFLAG}" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + if grep -E '(unrecognized.* option|did you mean|unknown argument:)' < conftest.err >/dev/null 2>/dev/null; then : + eval "$as_CACHEVAR=no" +else + eval "$as_CACHEVAR=yes" +fi +else + eval "$as_CACHEVAR=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$ax_check_save_flags +fi +eval ac_res=\$$as_CACHEVAR + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_CACHEVAR"\" = x"yes"; then : + CFLAGS="$CFLAGS ${COMPILERFLAG}" + + if test "$cross_compiling" = yes; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&5 +$as_echo "$as_me: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&2;} + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + +else + CFLAGS="$SAVED_CFLAGS" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + CFLAGS="$SAVED_CFLAGS" +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + + +else + : +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + as_CACHEVAR=`$as_echo "ax_cv_check_cxxflags_-Werror_${COMPILERFLAG}" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C++ compiler accepts ${COMPILERFLAG}" >&5 +$as_echo_n "checking whether C++ compiler accepts ${COMPILERFLAG}... " >&6; } +if eval \${$as_CACHEVAR+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CXXFLAGS + CXXFLAGS="$CXXFLAGS -Werror ${COMPILERFLAG}" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + if grep -E '(unrecognized.* option|did you mean|unknown argument:)' < conftest.err >/dev/null 2>/dev/null; then : + eval "$as_CACHEVAR=no" +else + eval "$as_CACHEVAR=yes" +fi +else + eval "$as_CACHEVAR=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXXFLAGS=$ax_check_save_flags +fi +eval ac_res=\$$as_CACHEVAR + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_CACHEVAR"\" = x"yes"; then : + CXXFLAGS="$CXXFLAGS ${COMPILERFLAG}" + + if test "$cross_compiling" = yes; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&5 +$as_echo "$as_me: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&2;} + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + +else + CXXFLAGS="$SAVED_CXXFLAGS" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_run "$LINENO"; then : + +else + CXXFLAGS="$SAVED_CXXFLAGS" +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + + +else + : +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + if test x"${nut_enable_Wcolor}" = xyes; then : + + + + + COMPILERFLAG="-fdiagnostics-color=always" + + SAVED_CFLAGS="$CFLAGS" + SAVED_CXXFLAGS="$CXXFLAGS" + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + as_CACHEVAR=`$as_echo "ax_cv_check_cflags_-Werror_${COMPILERFLAG}" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts ${COMPILERFLAG}" >&5 +$as_echo_n "checking whether C compiler accepts ${COMPILERFLAG}... " >&6; } +if eval \${$as_CACHEVAR+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -Werror ${COMPILERFLAG}" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + if grep -E '(unrecognized.* option|did you mean|unknown argument:)' < conftest.err >/dev/null 2>/dev/null; then : + eval "$as_CACHEVAR=no" +else + eval "$as_CACHEVAR=yes" +fi +else + eval "$as_CACHEVAR=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$ax_check_save_flags +fi +eval ac_res=\$$as_CACHEVAR + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_CACHEVAR"\" = x"yes"; then : + CFLAGS="$CFLAGS ${COMPILERFLAG}" + + if test "$cross_compiling" = yes; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&5 +$as_echo "$as_me: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&2;} + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + +else + CFLAGS="$SAVED_CFLAGS" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + CFLAGS="$SAVED_CFLAGS" +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + + +else + : +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + as_CACHEVAR=`$as_echo "ax_cv_check_cxxflags_-Werror_${COMPILERFLAG}" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C++ compiler accepts ${COMPILERFLAG}" >&5 +$as_echo_n "checking whether C++ compiler accepts ${COMPILERFLAG}... " >&6; } +if eval \${$as_CACHEVAR+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CXXFLAGS + CXXFLAGS="$CXXFLAGS -Werror ${COMPILERFLAG}" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + if grep -E '(unrecognized.* option|did you mean|unknown argument:)' < conftest.err >/dev/null 2>/dev/null; then : + eval "$as_CACHEVAR=no" +else + eval "$as_CACHEVAR=yes" +fi +else + eval "$as_CACHEVAR=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXXFLAGS=$ax_check_save_flags +fi +eval ac_res=\$$as_CACHEVAR + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_CACHEVAR"\" = x"yes"; then : + CXXFLAGS="$CXXFLAGS ${COMPILERFLAG}" + + if test "$cross_compiling" = yes; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&5 +$as_echo "$as_me: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&2;} + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + +else + CXXFLAGS="$SAVED_CXXFLAGS" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_run "$LINENO"; then : + +else + CXXFLAGS="$SAVED_CXXFLAGS" +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + + +else + : +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: NOT checking for options to request colorized compiler output (pass --enable-Wcolor for that)" >&5 +$as_echo "$as_me: NOT checking for options to request colorized compiler output (pass --enable-Wcolor for that)" >&6;} +fi + + + + COMPILERFLAG="-Wno-unknown-warning-option" + + SAVED_CFLAGS="$CFLAGS" + SAVED_CXXFLAGS="$CXXFLAGS" + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + as_CACHEVAR=`$as_echo "ax_cv_check_cflags_-Werror_${COMPILERFLAG}" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts ${COMPILERFLAG}" >&5 +$as_echo_n "checking whether C compiler accepts ${COMPILERFLAG}... " >&6; } +if eval \${$as_CACHEVAR+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -Werror ${COMPILERFLAG}" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + if grep -E '(unrecognized.* option|did you mean|unknown argument:)' < conftest.err >/dev/null 2>/dev/null; then : + eval "$as_CACHEVAR=no" +else + eval "$as_CACHEVAR=yes" +fi +else + eval "$as_CACHEVAR=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$ax_check_save_flags +fi +eval ac_res=\$$as_CACHEVAR + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_CACHEVAR"\" = x"yes"; then : + CFLAGS="$CFLAGS ${COMPILERFLAG}" + + if test "$cross_compiling" = yes; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&5 +$as_echo "$as_me: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&2;} + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + +else + CFLAGS="$SAVED_CFLAGS" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + CFLAGS="$SAVED_CFLAGS" +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + + +else + : +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + as_CACHEVAR=`$as_echo "ax_cv_check_cxxflags_-Werror_${COMPILERFLAG}" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C++ compiler accepts ${COMPILERFLAG}" >&5 +$as_echo_n "checking whether C++ compiler accepts ${COMPILERFLAG}... " >&6; } +if eval \${$as_CACHEVAR+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CXXFLAGS + CXXFLAGS="$CXXFLAGS -Werror ${COMPILERFLAG}" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + if grep -E '(unrecognized.* option|did you mean|unknown argument:)' < conftest.err >/dev/null 2>/dev/null; then : + eval "$as_CACHEVAR=no" +else + eval "$as_CACHEVAR=yes" +fi +else + eval "$as_CACHEVAR=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXXFLAGS=$ax_check_save_flags +fi +eval ac_res=\$$as_CACHEVAR + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_CACHEVAR"\" = x"yes"; then : + CXXFLAGS="$CXXFLAGS ${COMPILERFLAG}" + + if test "$cross_compiling" = yes; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&5 +$as_echo "$as_me: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&2;} + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + +else + CXXFLAGS="$SAVED_CXXFLAGS" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_run "$LINENO"; then : + +else + CXXFLAGS="$SAVED_CXXFLAGS" +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + + +else + : +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + + if test "x$CLANGCC" = xyes -o "x$GCC" = xyes; then : + + if test -d /usr/local/include; then : + CFLAGS="-isystem /usr/local/include $CFLAGS" +fi + if test -d /usr/pkg/include; then : + CFLAGS="-isystem /usr/pkg/include $CFLAGS" +fi + +fi + if test "x$CLANGXX" = xyes -o "x$GXX" = xyes; then : + + if test -d /usr/local/include; then : + CXXFLAGS="-isystem /usr/local/include $CXXFLAGS" +fi + if test -d /usr/pkg/include; then : + CXXFLAGS="-isystem /usr/pkg/include $CXXFLAGS" +fi + +fi + + if test "x$GCC" = xyes -o "x$CLANGCC" = xyes; then : + case "${CFLAGS}" in #( + -std=*) : + ;; #( + *) : + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -std=gnu99" >&5 +$as_echo_n "checking whether C compiler accepts -std=gnu99... " >&6; } +if ${ax_cv_check_cflags__Werror__std_gnu99+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -Werror -std=gnu99" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + if grep -E '(unrecognized.* option|did you mean|unknown argument:)' < conftest.err >/dev/null 2>/dev/null; then : + ax_cv_check_cflags__Werror__std_gnu99=no +else + ax_cv_check_cflags__Werror__std_gnu99=yes +fi +else + ax_cv_check_cflags__Werror__std_gnu99=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags__Werror__std_gnu99" >&5 +$as_echo "$ax_cv_check_cflags__Werror__std_gnu99" >&6; } +if test "x$ax_cv_check_cflags__Werror__std_gnu99" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: Defaulting C standard support to GNU C99 on a GCC or CLANG compatible compiler" >&5 +$as_echo "$as_me: Defaulting C standard support to GNU C99 on a GCC or CLANG compatible compiler" >&6;} + CFLAGS="$CFLAGS -std=gnu99" + +else + : +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + ;; +esac + +fi + + if test "x$GCC" = xyes -o "x$CLANGCC" = xyes; then : + case "${CXXFLAGS}" in #( + -std=*) : + ;; #( + *) : + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C++ compiler accepts -std=gnu++11" >&5 +$as_echo_n "checking whether C++ compiler accepts -std=gnu++11... " >&6; } +if ${ax_cv_check_cxxflags__Werror__std_gnupp11+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CXXFLAGS + CXXFLAGS="$CXXFLAGS -Werror -std=gnu++11" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + if grep -E '(unrecognized.* option|did you mean|unknown argument:)' < conftest.err >/dev/null 2>/dev/null; then : + ax_cv_check_cxxflags__Werror__std_gnupp11=no +else + ax_cv_check_cxxflags__Werror__std_gnupp11=yes +fi +else + ax_cv_check_cxxflags__Werror__std_gnupp11=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXXFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cxxflags__Werror__std_gnupp11" >&5 +$as_echo "$ax_cv_check_cxxflags__Werror__std_gnupp11" >&6; } +if test "x$ax_cv_check_cxxflags__Werror__std_gnupp11" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: Defaulting C++ standard support to GNU C++11 on a GCC or CLANG compatible compiler" >&5 +$as_echo "$as_me: Defaulting C++ standard support to GNU C++11 on a GCC or CLANG compatible compiler" >&6;} + CXXFLAGS="$CXXFLAGS -std=gnu++11" + +else + : +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + ;; +esac + +fi + + + +if test -z "${nut_have_ax_c_pragmas_seen}"; then + nut_have_ax_c_pragmas_seen="yes" + + CFLAGS_SAVED="${CFLAGS}" + CXXFLAGS_SAVED="${CXXFLAGS}" + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + if test "${CLANG}" = "yes"; then : + CFLAGS="${CFLAGS_SAVED} -Werror=pragmas -Werror=unknown-pragmas -Werror=unknown-warning-option" + CXXFLAGS="${CXXFLAGS_SAVED} -Werror=pragmas -Werror=unknown-pragmas -Werror=unknown-warning-option" +else + if test "${GCC}" = "yes"; then : + CFLAGS="${CFLAGS_SAVED} -Wall -Wextra -Werror" + CXXFLAGS="${CXXFLAGS_SAVED} -Wall -Wextra -Werror" +else + CFLAGS="${CFLAGS_SAVED} -Wall -Wextra -Werror" + CXXFLAGS="${CXXFLAGS_SAVED} -Wall -Wextra -Werror" +fi + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic push and pop (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic push and pop (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_push_pop_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#pragma GCC diagnostic push +#pragma GCC diagnostic pop + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_push_pop_besidefunc=yes +else + ax_cv__pragma__gcc__diags_push_pop_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_push_pop_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_push_pop_besidefunc" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma clang diagnostic push and pop (outside functions)" >&5 +$as_echo_n "checking for pragma clang diagnostic push and pop (outside functions)... " >&6; } +if ${ax_cv__pragma__clang__diags_push_pop_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef __clang__ +#endif +#pragma clang diagnostic push +#pragma clang diagnostic pop + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__clang__diags_push_pop_besidefunc=yes +else + ax_cv__pragma__clang__diags_push_pop_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__clang__diags_push_pop_besidefunc" >&5 +$as_echo "$ax_cv__pragma__clang__diags_push_pop_besidefunc" >&6; } + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic push and pop (inside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic push and pop (inside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_push_pop_insidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic push +#pragma GCC diagnostic pop +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_push_pop_insidefunc=yes +else + ax_cv__pragma__gcc__diags_push_pop_insidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_push_pop_insidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_push_pop_insidefunc" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma clang diagnostic push and pop (inside functions)" >&5 +$as_echo_n "checking for pragma clang diagnostic push and pop (inside functions)... " >&6; } +if ${ax_cv__pragma__clang__diags_push_pop_insidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#ifdef __clang__ +#endif +#pragma clang diagnostic push +#pragma clang diagnostic pop +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__clang__diags_push_pop_insidefunc=yes +else + ax_cv__pragma__clang__diags_push_pop_insidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__clang__diags_push_pop_insidefunc" >&5 +$as_echo "$ax_cv__pragma__clang__diags_push_pop_insidefunc" >&6; } + + if test "$ax_cv__pragma__gcc__diags_push_pop_insidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_INSIDEFUNC 1" >>confdefs.h + + +fi + + if test "$ax_cv__pragma__gcc__diags_push_pop_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC 1" >>confdefs.h + + +fi + + if test "$ax_cv__pragma__gcc__diags_push_pop_besidefunc" = "yes" && test "$ax_cv__pragma__gcc__diags_push_pop_insidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP 1" >>confdefs.h + + +fi + + if test "$ax_cv__pragma__clang__diags_push_pop_insidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_CLANG_DIAGNOSTIC_PUSH_POP_INSIDEFUNC 1" >>confdefs.h + + +fi + + if test "$ax_cv__pragma__clang__diags_push_pop_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_CLANG_DIAGNOSTIC_PUSH_POP_BESIDEFUNC 1" >>confdefs.h + + +fi + + if test "$ax_cv__pragma__clang__diags_push_pop_besidefunc" = "yes" && test "$ax_cv__pragma__clang__diags_push_pop_insidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_CLANG_DIAGNOSTIC_PUSH_POP 1" >>confdefs.h + + +fi + + if test "${CLANG}" = "yes"; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma CLANG diagnostic ignored \"-Wunreachable-code-return\"" >&5 +$as_echo_n "checking for pragma CLANG diagnostic ignored \"-Wunreachable-code-return\"... " >&6; } +if ${ax_cv__pragma__clang__diags_ignored_unreachable_code_return+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma clang diagnostic ignored "-Wunreachable-code-return" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__clang__diags_ignored_unreachable_code_return=yes +else + ax_cv__pragma__clang__diags_ignored_unreachable_code_return=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__clang__diags_ignored_unreachable_code_return" >&5 +$as_echo "$ax_cv__pragma__clang__diags_ignored_unreachable_code_return" >&6; } + if test "$ax_cv__pragma__clang__diags_ignored_unreachable_code_return" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_CLANG_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma CLANG diagnostic ignored \"-Wunreachable-code-return\" (outside functions)" >&5 +$as_echo_n "checking for pragma CLANG diagnostic ignored \"-Wunreachable-code-return\" (outside functions)... " >&6; } +if ${ax_cv__pragma__clang__diags_ignored_unreachable_code_return_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma clang diagnostic ignored "-Wunreachable-code-return" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__clang__diags_ignored_unreachable_code_return_besidefunc=yes +else + ax_cv__pragma__clang__diags_ignored_unreachable_code_return_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__clang__diags_ignored_unreachable_code_return_besidefunc" >&5 +$as_echo "$ax_cv__pragma__clang__diags_ignored_unreachable_code_return_besidefunc" >&6; } + if test "$ax_cv__pragma__clang__diags_ignored_unreachable_code_return_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_CLANG_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN_BESIDEFUNC 1" >>confdefs.h + + +fi + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wunused-function\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wunused-function\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_unused_function+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wunused-function" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_unused_function=yes +else + ax_cv__pragma__gcc__diags_ignored_unused_function=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_unused_function" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_unused_function" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_unused_function" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNUSED_FUNCTION 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wformat-nonliteral\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wformat-nonliteral\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_format_nonliteral+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_format_nonliteral=yes +else + ax_cv__pragma__gcc__diags_ignored_format_nonliteral=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_format_nonliteral" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_format_nonliteral" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_format_nonliteral" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wformat-nonliteral\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wformat-nonliteral\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_format_nonliteral_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_format_nonliteral_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_format_nonliteral_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_format_nonliteral_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_format_nonliteral_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_format_nonliteral_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wformat-security\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wformat-security\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_format_security+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wformat-security" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_format_security=yes +else + ax_cv__pragma__gcc__diags_ignored_format_security=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_format_security" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_format_security" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_format_security" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wformat-security\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wformat-security\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_format_security_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wformat-security" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_format_security_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_format_security_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_format_security_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_format_security_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_format_security_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wformat-truncation\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wformat-truncation\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_format_truncation+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wformat-truncation" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_format_truncation=yes +else + ax_cv__pragma__gcc__diags_ignored_format_truncation=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_format_truncation" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_format_truncation" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_format_truncation" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wformat-truncation\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wformat-truncation\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_format_truncation_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wformat-truncation" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_format_truncation_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_format_truncation_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_format_truncation_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_format_truncation_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_format_truncation_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wstringop-truncation\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wstringop-truncation\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_stringop_truncation+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wstringop-truncation" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_stringop_truncation=yes +else + ax_cv__pragma__gcc__diags_ignored_stringop_truncation=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_stringop_truncation" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_stringop_truncation" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_stringop_truncation" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRINGOP_TRUNCATION 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wstringop-truncation\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wstringop-truncation\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_stringop_truncation_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wstringop-truncation" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_stringop_truncation_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_stringop_truncation_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_stringop_truncation_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_stringop_truncation_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_stringop_truncation_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRINGOP_TRUNCATION_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wtype-limits\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wtype-limits\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_type_limits+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wtype-limits" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_type_limits=yes +else + ax_cv__pragma__gcc__diags_ignored_type_limits=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_type_limits" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_type_limits" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_type_limits" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wtype-limits\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wtype-limits\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_type_limits_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wtype-limits" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_type_limits_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_type_limits_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_type_limits_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_type_limits_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_type_limits_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Warray-bounds\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Warray-bounds\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_array_bounds+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Warray-bounds" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_array_bounds=yes +else + ax_cv__pragma__gcc__diags_ignored_array_bounds=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_array_bounds" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_array_bounds" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_array_bounds" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ARRAY_BOUNDS 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Warray-bounds\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Warray-bounds\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_array_bounds_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Warray-bounds" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_array_bounds_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_array_bounds_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_array_bounds_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_array_bounds_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_array_bounds_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ARRAY_BOUNDS_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wtautological-type-limit-compare\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wtautological-type-limit-compare\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wtautological-type-limit-compare" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare=yes +else + ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_TYPE_LIMIT_COMPARE 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wtautological-type-limit-compare\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wtautological-type-limit-compare\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wtautological-type-limit-compare" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_TYPE_LIMIT_COMPARE_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wtautological-constant-out-of-range-compare\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wtautological-constant-out-of-range-compare\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare=yes +else + ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wtautological-constant-out-of-range-compare\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wtautological-constant-out-of-range-compare\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wtautological-unsigned-zero-compare\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wtautological-unsigned-zero-compare\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wtautological-unsigned-zero-compare" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare=yes +else + ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_UNSIGNED_ZERO_COMPARE 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wtautological-unsigned-zero-compare\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wtautological-unsigned-zero-compare\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wtautological-unsigned-zero-compare" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_UNSIGNED_ZERO_COMPARE_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wtautological-compare\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wtautological-compare\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_tautological_compare+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wtautological-compare" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_tautological_compare=yes +else + ax_cv__pragma__gcc__diags_ignored_tautological_compare=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_tautological_compare" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_tautological_compare" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_tautological_compare" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_COMPARE 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wtautological-compare\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wtautological-compare\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_tautological_compare_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wtautological-compare" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_tautological_compare_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_tautological_compare_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_tautological_compare_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_tautological_compare_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_tautological_compare_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_COMPARE_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wsign-compare\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wsign-compare\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_sign_compare+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wsign-compare" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_sign_compare=yes +else + ax_cv__pragma__gcc__diags_ignored_sign_compare=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_sign_compare" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_sign_compare" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_sign_compare" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_COMPARE 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wsign-compare\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wsign-compare\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_sign_compare_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wsign-compare" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_sign_compare_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_sign_compare_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_sign_compare_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_sign_compare_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_sign_compare_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_COMPARE_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wsign-conversion\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wsign-conversion\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_sign_conversion+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wsign-conversion" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_sign_conversion=yes +else + ax_cv__pragma__gcc__diags_ignored_sign_conversion=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_sign_conversion" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_sign_conversion" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_sign_conversion" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_CONVERSION 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wsign-conversion\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wsign-conversion\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_sign_conversion_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wsign-conversion" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_sign_conversion_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_sign_conversion_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_sign_conversion_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_sign_conversion_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_sign_conversion_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_CONVERSION_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wunreachable-code-break\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wunreachable-code-break\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_unreachable_code_break+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wunreachable-code-break" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_unreachable_code_break=yes +else + ax_cv__pragma__gcc__diags_ignored_unreachable_code_break=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_unreachable_code_break" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_break" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_break" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_BREAK 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wunreachable-code-break\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wunreachable-code-break\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_unreachable_code_break_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wunreachable-code-break" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_unreachable_code_break_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_unreachable_code_break_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_unreachable_code_break_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_break_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_break_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_BREAK_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wunreachable-code-return\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wunreachable-code-return\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_unreachable_code_return+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wunreachable-code-return" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_unreachable_code_return=yes +else + ax_cv__pragma__gcc__diags_ignored_unreachable_code_return=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_unreachable_code_return" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_return" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_return" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wunreachable-code-return\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wunreachable-code-return\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_unreachable_code_return_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wunreachable-code-return" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_unreachable_code_return_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_unreachable_code_return_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_unreachable_code_return_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_return_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_return_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wunreachable-code\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wunreachable-code\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_unreachable_code+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wunreachable-code" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_unreachable_code=yes +else + ax_cv__pragma__gcc__diags_ignored_unreachable_code=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_unreachable_code" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_unreachable_code" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wunreachable-code\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wunreachable-code\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_unreachable_code_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wunreachable-code" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_unreachable_code_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_unreachable_code_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_unreachable_code_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wformat-overflow\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wformat-overflow\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_format_overflow+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wformat-overflow" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_format_overflow=yes +else + ax_cv__pragma__gcc__diags_ignored_format_overflow=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_format_overflow" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_format_overflow" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_format_overflow" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_OVERFLOW 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wformat-overflow\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wformat-overflow\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_format_overflow_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wformat-overflow" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_format_overflow_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_format_overflow_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_format_overflow_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_format_overflow_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_format_overflow_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_OVERFLOW_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wcovered-switch-default\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wcovered-switch-default\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_covered_switch_default+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wcovered-switch-default" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_covered_switch_default=yes +else + ax_cv__pragma__gcc__diags_ignored_covered_switch_default=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_covered_switch_default" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_covered_switch_default" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_covered_switch_default" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wcovered-switch-default\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wcovered-switch-default\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_covered_switch_default_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wcovered-switch-default" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_covered_switch_default_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_covered_switch_default_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_covered_switch_default_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_covered_switch_default_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_covered_switch_default_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wextra-semi-stmt\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wextra-semi-stmt\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wextra-semi-stmt" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt=yes +else + ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXTRA_SEMI_STMT 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wextra-semi-stmt\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wextra-semi-stmt\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wextra-semi-stmt" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXTRA_SEMI_STMT_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wcast-align\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wcast-align\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_cast_align+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wcast-align" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_cast_align=yes +else + ax_cv__pragma__gcc__diags_ignored_cast_align=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_cast_align" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_cast_align" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_cast_align" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wcast-align\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wcast-align\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_cast_align_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wcast-align" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_cast_align_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_cast_align_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_cast_align_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_cast_align_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_cast_align_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wstrict-prototypes\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wstrict-prototypes\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_strict_prototypes+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wstrict-prototypes" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_strict_prototypes=yes +else + ax_cv__pragma__gcc__diags_ignored_strict_prototypes=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_strict_prototypes" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_strict_prototypes" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_strict_prototypes" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wstrict-prototypes\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wstrict-prototypes\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_strict_prototypes_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wstrict-prototypes" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_strict_prototypes_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_strict_prototypes_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_strict_prototypes_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_strict_prototypes_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_strict_prototypes_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wassign-enum\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wassign-enum\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_assign_enum+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wassign-enum" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_assign_enum=yes +else + ax_cv__pragma__gcc__diags_ignored_assign_enum=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_assign_enum" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_assign_enum" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_assign_enum" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ASSIGN_ENUM 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wassign-enum\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wassign-enum\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_assign_enum_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wassign-enum" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_assign_enum_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_assign_enum_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_assign_enum_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_assign_enum_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_assign_enum_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ASSIGN_ENUM_BESIDEFUNC 1" >>confdefs.h + + +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ pragma GCC diagnostic ignored \"-Wc++98-compat-pedantic\"" >&5 +$as_echo_n "checking for C++ pragma GCC diagnostic ignored \"-Wc++98-compat-pedantic\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wc++98-compat-pedantic" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic=yes +else + ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT_PEDANTIC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ pragma GCC diagnostic ignored \"-Wc++98-compat-pedantic\" (outside functions)" >&5 +$as_echo_n "checking for C++ pragma GCC diagnostic ignored \"-Wc++98-compat-pedantic\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wc++98-compat-pedantic" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT_PEDANTIC_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ pragma GCC diagnostic ignored \"-Wc++98-compat\"" >&5 +$as_echo_n "checking for C++ pragma GCC diagnostic ignored \"-Wc++98-compat\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_cxx98_compat+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wc++98-compat" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_cxx98_compat=yes +else + ax_cv__pragma__gcc__diags_ignored_cxx98_compat=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_cxx98_compat" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ pragma GCC diagnostic ignored \"-Wc++98-compat\" (outside functions)" >&5 +$as_echo_n "checking for C++ pragma GCC diagnostic ignored \"-Wc++98-compat\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_cxx98_compat_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wc++98-compat" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_cxx98_compat_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_cxx98_compat_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_cxx98_compat_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ pragma GCC diagnostic ignored \"-Wglobal-constructors\"" >&5 +$as_echo_n "checking for C++ pragma GCC diagnostic ignored \"-Wglobal-constructors\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_global_constructors+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wglobal-constructors" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_global_constructors=yes +else + ax_cv__pragma__gcc__diags_ignored_global_constructors=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_global_constructors" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_global_constructors" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_global_constructors" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ pragma GCC diagnostic ignored \"-Wglobal-constructors\" (outside functions)" >&5 +$as_echo_n "checking for C++ pragma GCC diagnostic ignored \"-Wglobal-constructors\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_global_constructors_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wglobal-constructors" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_global_constructors_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_global_constructors_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_global_constructors_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_global_constructors_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_global_constructors_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ pragma GCC diagnostic ignored \"-Wexit-time-destructors\"" >&5 +$as_echo_n "checking for C++ pragma GCC diagnostic ignored \"-Wexit-time-destructors\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_exit_time_destructors+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wexit-time-destructors" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_exit_time_destructors=yes +else + ax_cv__pragma__gcc__diags_ignored_exit_time_destructors=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_exit_time_destructors" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_exit_time_destructors" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_exit_time_destructors" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ pragma GCC diagnostic ignored \"-Wexit-time-destructors\" (outside functions)" >&5 +$as_echo_n "checking for C++ pragma GCC diagnostic ignored \"-Wexit-time-destructors\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_exit_time_destructors_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wexit-time-destructors" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_exit_time_destructors_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_exit_time_destructors_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_exit_time_destructors_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_exit_time_destructors_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_exit_time_destructors_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS_BESIDEFUNC 1" >>confdefs.h + + +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + if test "$ax_cv__pragma__gcc__diags_push_pop_insidefunc" = "yes"; then : + + if test "$ax_cv__pragma__gcc__diags_ignored_format_security" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_format_nonliteral" = "yes" ; then : + + +$as_echo "#define HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL 1" >>confdefs.h + + +fi + if test "$ax_cv__pragma__gcc__diags_ignored_format_truncation" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_stringop_truncation" = "yes" ; then : + + +$as_echo "#define HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION 1" >>confdefs.h + + +fi + if test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_break" = "yes" ; then : + + +$as_echo "#define HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE 1" >>confdefs.h + + +fi + if test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat" = "yes" ; then : + + +$as_echo "#define HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT 1" >>confdefs.h + + +fi + +fi + + if test "$ax_cv__pragma__gcc__diags_push_pop_besidefunc" = "yes"; then : + + if test "$ax_cv__pragma__gcc__diags_ignored_format_security" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_format_nonliteral" = "yes" ; then : + + +$as_echo "#define HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL_BESIDEFUNC 1" >>confdefs.h + + +fi + if test "$ax_cv__pragma__gcc__diags_ignored_format_truncation" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_stringop_truncation" = "yes" ; then : + + +$as_echo "#define HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION_BESIDEFUNC 1" >>confdefs.h + + +fi + if test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_break" = "yes" ; then : + + +$as_echo "#define HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_BESIDEFUNC 1" >>confdefs.h + + +fi + if test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat" = "yes" ; then : + + +$as_echo "#define HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT_BESIDEFUNC 1" >>confdefs.h + + +fi + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma BOGUSforTest" >&5 +$as_echo_n "checking for pragma BOGUSforTest... " >&6; } +if ${ax_cv__pragma__bogus+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma BOGUSforTest +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__bogus=yes +else + ax_cv__pragma__bogus=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__bogus" >&5 +$as_echo "$ax_cv__pragma__bogus" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma BOGUSforTest (outside functions)" >&5 +$as_echo_n "checking for pragma BOGUSforTest (outside functions)... " >&6; } +if ${ax_cv__pragma__bogus_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma BOGUSforTest +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__bogus_besidefunc=yes +else + ax_cv__pragma__bogus_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__bogus_besidefunc" >&5 +$as_echo "$ax_cv__pragma__bogus_besidefunc" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-WBOGUSforTest\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-WBOGUSforTest\"... " >&6; } +if ${ax_cv__pragma__bogus_diag+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-WBOGUSforTest" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__bogus_diag=yes +else + ax_cv__pragma__bogus_diag=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__bogus_diag" >&5 +$as_echo "$ax_cv__pragma__bogus_diag" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-WBOGUSforTest\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-WBOGUSforTest\" (outside functions)... " >&6; } +if ${ax_cv__pragma__bogus_diag_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-WBOGUSforTest" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__bogus_diag_besidefunc=yes +else + ax_cv__pragma__bogus_diag_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__bogus_diag_besidefunc" >&5 +$as_echo "$ax_cv__pragma__bogus_diag_besidefunc" >&6; } + + if test "${ax_cv__pragma__bogus}" != "no"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: A bogus test that was expected to fail did not! ax_cv__pragma__bogus=$ax_cv__pragma__bogus (not 'no')" >&5 +$as_echo "$as_me: WARNING: A bogus test that was expected to fail did not! ax_cv__pragma__bogus=$ax_cv__pragma__bogus (not 'no')" >&2;} +fi + + if test "${ax_cv__pragma__bogus_besidefunc}" != "no"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: A bogus test that was expected to fail did not! ax_cv__pragma__bogus_besidefunc=$ax_cv__pragma__bogus_besidefunc (not 'no')" >&5 +$as_echo "$as_me: WARNING: A bogus test that was expected to fail did not! ax_cv__pragma__bogus_besidefunc=$ax_cv__pragma__bogus_besidefunc (not 'no')" >&2;} +fi + + if test "${ax_cv__pragma__bogus_diag}" != "no"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: A bogus test that was expected to fail did not! ax_cv__pragma__bogus_diag=$ax_cv__pragma__bogus_diag (not 'no')" >&5 +$as_echo "$as_me: WARNING: A bogus test that was expected to fail did not! ax_cv__pragma__bogus_diag=$ax_cv__pragma__bogus_diag (not 'no')" >&2;} +fi + + if test "${ax_cv__pragma__bogus_diag_besidefunc}" != "no"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: A bogus test that was expected to fail did not! ax_cv__pragma__bogus_diag_besidefunc=$ax_cv__pragma__bogus_diag_besidefunc (not 'no')" >&5 +$as_echo "$as_me: WARNING: A bogus test that was expected to fail did not! ax_cv__pragma__bogus_diag_besidefunc=$ax_cv__pragma__bogus_diag_besidefunc (not 'no')" >&2;} +fi + + CFLAGS="${CFLAGS_SAVED}" + CXXFLAGS="${CXXFLAGS_SAVED}" +fi + + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__((unused)) for function arguments" >&5 +$as_echo_n "checking for __attribute__((unused)) for function arguments... " >&6; } +if ${ax_cv___attribute__unused_arg+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + static void foo( int); + static void + foo(__attribute__ ((unused)) int i) { + return; + } + +int +main () +{ +func(1); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv___attribute__unused_arg=yes +else + ax_cv___attribute__unused_arg=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv___attribute__unused_arg" >&5 +$as_echo "$ax_cv___attribute__unused_arg" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__((unused)) for functions" >&5 +$as_echo_n "checking for __attribute__((unused)) for functions... " >&6; } +if ${ax_cv___attribute__unused_func+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + static void foo(void) __attribute__ ((unused)); + static void + foo(void) { + return; + } + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv___attribute__unused_func=yes +else + ax_cv___attribute__unused_func=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv___attribute__unused_func" >&5 +$as_echo "$ax_cv___attribute__unused_func" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__((noreturn))" >&5 +$as_echo_n "checking for __attribute__((noreturn))... " >&6; } +if ${ax_cv___attribute__noreturn+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + static void foo(void) __attribute__ ((noreturn)); + static void + foo(void) { + exit(1); + } + +int +main () +{ +foo(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv___attribute__noreturn=yes +else + ax_cv___attribute__noreturn=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv___attribute__noreturn" >&5 +$as_echo "$ax_cv___attribute__noreturn" >&6; } + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for at least some __attribute__ support" >&5 +$as_echo_n "checking for at least some __attribute__ support... " >&6; } +if ${ax_cv___attribute__+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$ax_cv___attribute__unused_arg" = "yes" \ + || test "$ax_cv___attribute__unused_func" = "yes" \ + || test "$ax_cv___attribute__noreturn" = "yes" \ + ; then + ax_cv___attribute__=yes + else + ax_cv___attribute__=no + fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv___attribute__" >&5 +$as_echo "$ax_cv___attribute__" >&6; } + + if test "$ax_cv___attribute__unused_arg" = "yes"; then + +$as_echo "#define HAVE___ATTRIBUTE__UNUSED_ARG 1" >>confdefs.h + + fi + + if test "$ax_cv___attribute__unused_func" = "yes"; then + +$as_echo "#define HAVE___ATTRIBUTE__UNUSED_FUNC 1" >>confdefs.h + + fi + if test "$ax_cv___attribute__noreturn" = "yes"; then + +$as_echo "#define HAVE___ATTRIBUTE__NORETURN 1" >>confdefs.h + + fi + + if test "$ax_cv___attribute__" = "yes"; then + +$as_echo "#define HAVE___ATTRIBUTE__ 1" >>confdefs.h + + fi + + +if test -z "${nut_have_ax_c_printf_string_null_seen}"; then + nut_have_ax_c_printf_string_null_seen="yes" + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for practical support to pritnf(\"%s\", NULL)" >&5 +$as_echo_n "checking for practical support to pritnf(\"%s\", NULL)... " >&6; } +if ${ax_cv__printf_string_null+:} false; then : + $as_echo_n "(cached) " >&6 +else + + if test "$cross_compiling" = yes; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&5 +$as_echo "$as_me: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&2;} + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include + +int +main () +{ +char buf128; +char *s = NULL; +int res = snprintf(buf, sizeof(buf), "%s", s); +bufsizeof(buf)-1 = '\0'; +if (res < 0) { + printf(stderr, "FAILED to snprintf() a NULL string argument"); + exit 1; +} +if (buf0 == '\0') + printf(stderr, "RETURNED empty string from snprintf() with a NULL string argument"); + exit 0; +} +if (strcasestr(buf, 'null') == NULL) + printf(stderr, "RETURNED some string from snprintf() with a NULL string argument: '%s'", buf); + exit 0; +} +printf(stderr, "SUCCESS: RETURNED a string that contains something like 'null' from snprintf() with a NULL string argument: '%s'", buf); +exit 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ax_cv__printf_string_null=yes +else + ax_cv__printf_string_null=no + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include + +int +main () +{ +char buf128; +char *s = NULL; +int res = snprintf(buf, sizeof(buf), "%s", s); +bufsizeof(buf)-1 = '\0'; +if (res < 0) { + printf(stderr, "FAILED to snprintf() a NULL string argument"); + exit 1; +} +if (buf0 == '\0') + printf(stderr, "RETURNED empty string from snprintf() with a NULL string argument"); + exit 0; +} +if (strcasestr(buf, 'null') == NULL) + printf(stderr, "RETURNED some string from snprintf() with a NULL string argument: '%s'", buf); + exit 0; +} +printf(stderr, "SUCCESS: RETURNED a string that contains something like 'null' from snprintf() with a NULL string argument: '%s'", buf); +exit 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ax_cv__printf_string_null=yes +else + ax_cv__printf_string_null=no + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__printf_string_null" >&5 +$as_echo "$ax_cv__printf_string_null" >&6; } + + if test "$ax_cv__printf_string_null" = "yes"; then : + + +$as_echo "#define HAVE_PRINTF_STRING_NULL 1" >>confdefs.h + + +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +fi + +for ac_func in flock lockf fcvt fcvtl pow10 round abs_val abs do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -6976,6 +10979,173 @@ _ACEOF fi done + +ac_fn_c_check_header_mongrel "$LINENO" "float.h" "ac_cv_header_float_h" "$ac_includes_default" +if test "x$ac_cv_header_float_h" = xyes; then : + +$as_echo "#define HAVE_FLOAT_H 1" >>confdefs.h + +fi + + +ac_fn_c_check_header_mongrel "$LINENO" "math.h" "ac_cv_header_math_h" "$ac_includes_default" +if test "x$ac_cv_header_math_h" = xyes; then : + +$as_echo "#define HAVE_MATH_H 1" >>confdefs.h + +fi + + +for ac_func in fabs fabsf fabsl +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + +ac_fn_c_check_header_mongrel "$LINENO" "limits.h" "ac_cv_header_limits_h" "$ac_includes_default" +if test "x$ac_cv_header_limits_h" = xyes; then : + +$as_echo "#define HAVE_LIMITS_H 1" >>confdefs.h + +fi + + + +ac_fn_c_check_header_mongrel "$LINENO" "signal.h" "ac_cv_header_signal_h" "$ac_includes_default" +if test "x$ac_cv_header_signal_h" = xyes; then : + +$as_echo "#define HAVE_SIGNAL_H 1" >>confdefs.h + +fi + + + +ac_fn_c_check_header_mongrel "$LINENO" "sys/signal.h" "ac_cv_header_sys_signal_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_signal_h" = xyes; then : + +$as_echo "#define HAVE_SYS_SIGNAL_H 1" >>confdefs.h + +fi + + + +ac_fn_c_check_header_mongrel "$LINENO" "sys/resource.h" "ac_cv_header_sys_resource_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_resource_h" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct rlimit and getrlimit()" >&5 +$as_echo_n "checking for struct rlimit and getrlimit()... " >&6; } + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include + +int +main () +{ +struct rlimit limit; +getrlimit(RLIMIT_NOFILE, &limit); +/* Do not care about actual return value in this test, + * normally check for non-zero meaning to look in errno */ + + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +$as_echo "#define HAVE_SYS_RESOURCE_H 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; } + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +fi + + + +ac_fn_c_check_header_mongrel "$LINENO" "semaphore.h" "ac_cv_header_semaphore_h" "$ac_includes_default" +if test "x$ac_cv_header_semaphore_h" = xyes; then : + +$as_echo "#define HAVE_SEMAPHORE_H 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sem_t, sem_init() and sem_destroy()" >&5 +$as_echo_n "checking for sem_t, sem_init() and sem_destroy()... " >&6; } + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include + +int +main () +{ +sem_t semaphore; +sem_init(&semaphore, 0, 4); +sem_destroy(&semaphore); +/* Do not care about actual return value in this test, + * normally check for non-zero meaning to look in errno */ + + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +$as_echo "#define HAVE_SEMAPHORE 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; } + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +fi + + + for ac_func in cfsetispeed tcsendbreak do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` @@ -7025,6 +11195,354 @@ cat >>confdefs.h <<_ACEOF _ACEOF +{ $as_echo "$as_me:${as_lineno-$LINENO}: ----------------------------------------------------------------------- +The next few tests look for required C library routines; if something is +not found, you may need to enable a different C standard or extension macro +version. You may also have to configure without extreme warning levels +since autotools tests fail those on their own and assume system lacks +stuff (although note we try to not involve standard -W* flags here). +-----------------------------------------------------------------------" >&5 +$as_echo "$as_me: ----------------------------------------------------------------------- +The next few tests look for required C library routines; if something is +not found, you may need to enable a different C standard or extension macro +version. You may also have to configure without extreme warning levels +since autotools tests fail those on their own and assume system lacks +stuff (although note we try to not involve standard -W* flags here). +-----------------------------------------------------------------------" >&6;} + for ac_func in strtok_r fileno localtime_r sigemptyset sigaction +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Required C library routine not found; try adding -D_POSIX_C_SOURCE=200112L" >&5 +$as_echo "$as_me: WARNING: Required C library routine not found; try adding -D_POSIX_C_SOURCE=200112L" >&2;} +fi +done + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +ac_fn_c_check_header_mongrel "$LINENO" "string.h" "ac_cv_header_string_h" "$ac_includes_default" +if test "x$ac_cv_header_string_h" = xyes; then : + +$as_echo "#define HAVE_STRING_H 1" >>confdefs.h + +fi + + + +ac_fn_c_check_header_mongrel "$LINENO" "strings.h" "ac_cv_header_strings_h" "$ac_includes_default" +if test "x$ac_cv_header_strings_h" = xyes; then : + +$as_echo "#define HAVE_STRINGS_H 1" >>confdefs.h + +fi + + + +CODE_STRINGINCL='#ifdef HAVE_STRING_H +#include +#endif +#ifdef HAVE_STRINGS_H +#include +#endif' + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for strcasecmp(s1,s2)" >&5 +$as_echo_n "checking for strcasecmp(s1,s2)... " >&6; } +if ${ac_cv_func_strcasecmp+:} false; then : + $as_echo_n "(cached) " >&6 +else + + if test "$cross_compiling" = yes; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&5 +$as_echo "$as_me: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&2;} + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$CODE_STRINGINCL +int +main () +{ +if (strcasecmp("STR1", "str1") != 0) return 1 + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_func_strcasecmp=yes +else + ac_cv_func_strcasecmp=no + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$CODE_STRINGINCL +int +main () +{ +if (strcasecmp("STR1", "str1") != 0) return 1 + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_func_strcasecmp=yes +else + ac_cv_func_strcasecmp=no + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strcasecmp" >&5 +$as_echo "$ac_cv_func_strcasecmp" >&6; } +if test x"${ac_cv_func_strcasecmp}" = xyes; then : + +$as_echo "#define HAVE_STRCASECMP 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Required C library routine strcasecmp not found; try adding __EXTENSIONS__" >&5 +$as_echo "$as_me: WARNING: Required C library routine strcasecmp not found; try adding __EXTENSIONS__" >&2;} + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for strncasecmp(s1,s2,n)" >&5 +$as_echo_n "checking for strncasecmp(s1,s2,n)... " >&6; } +if ${ac_cv_func_strncasecmp+:} false; then : + $as_echo_n "(cached) " >&6 +else + + if test "$cross_compiling" = yes; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&5 +$as_echo "$as_me: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&2;} + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$CODE_STRINGINCL +int +main () +{ +if (strncasecmp("STR1", "strX", 2) != 0) return 1 + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_func_strncasecmp=yes +else + ac_cv_func_strncasecmp=no + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$CODE_STRINGINCL +int +main () +{ +if (strncasecmp("STR1", "strX", 2) != 0) return 1 + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_func_strncasecmp=yes +else + ac_cv_func_strncasecmp=no + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strncasecmp" >&5 +$as_echo "$ac_cv_func_strncasecmp" >&6; } +if test x"${ac_cv_func_strncasecmp}" = xyes; then : + +$as_echo "#define HAVE_STRNCASECMP 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Required C library routine strncasecmp not found; try adding __EXTENSIONS__" >&5 +$as_echo "$as_me: WARNING: Required C library routine strncasecmp not found; try adding __EXTENSIONS__" >&2;} + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for strdup(s)" >&5 +$as_echo_n "checking for strdup(s)... " >&6; } +if ${ac_cv_func_strdup+:} false; then : + $as_echo_n "(cached) " >&6 +else + + if test "$cross_compiling" = yes; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&5 +$as_echo "$as_me: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&2;} + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$CODE_STRINGINCL +int +main () +{ +int res = 0; +char *t = "Test"; +char *s = strdup(t); +if (!s || !(s[0]=='T'&&s[1]=='e'&&s[2]=='s'&&s[3]=='t'&&s[4]=='\0') || s == t) res = 1; +if (s) free (s); +if (res != 0) return res +/* autoconf adds ";return 0;" */ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_func_strdup=yes +else + ac_cv_func_strdup=no + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$CODE_STRINGINCL +int +main () +{ +int res = 0; +char *t = "Test"; +char *s = strdup(t); +if (!s || !(s[0]=='T'&&s[1]=='e'&&s[2]=='s'&&s[3]=='t'&&s[4]=='\0') || s == t) res = 1; +if (s) free (s); +if (res != 0) return res +/* autoconf adds ";return 0;" */ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_func_strdup=yes +else + ac_cv_func_strdup=no + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strdup" >&5 +$as_echo "$ac_cv_func_strdup" >&6; } +if test x"${ac_cv_func_strdup}" = xyes; then : + +$as_echo "#define HAVE_STRDUP 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Required C library routine strdup not found; try adding -D_POSIX_C_SOURCE=200112L" >&5 +$as_echo "$as_me: WARNING: Required C library routine strdup not found; try adding -D_POSIX_C_SOURCE=200112L" >&2;} + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for usleep(us)" >&5 +$as_echo_n "checking for usleep(us)... " >&6; } +if ${ac_cv_func_usleep+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +useconds_t us = 1000; +if (usleep(us) != 0) return 1 /* per doc, no erros are returned actually*/ +/* autoconf adds ";return 0;" */ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_func_usleep=yes +else + ac_cv_func_usleep=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_usleep" >&5 +$as_echo "$ac_cv_func_usleep" >&6; } +if test x"${ac_cv_func_usleep}" = xyes; then : + +$as_echo "#define HAVE_USLEEP 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Required C library routine usleep not found; try adding -D_POSIX_C_SOURCE=200112L" >&5 +$as_echo "$as_me: WARNING: Required C library routine usleep not found; try adding -D_POSIX_C_SOURCE=200112L" >&2;} + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -sr works" >&5 +$as_echo_n "checking whether ln -sr works... " >&6; } +LN_S_R="cp -pR" +if test "$as_ln_s" = "ln -s" ; then + LN_S_R="ln" + DIR1="$(mktemp -d "dir1.XXXXXXX")" && \ + DIR2="$(mktemp -d "dir2.XXXXXXX")" && \ + touch "${DIR1}/a" && \ + $as_ln_s -r "${DIR1}/a" "${DIR2}/b" && \ + ls -la "${DIR2}/b" | grep '\.\./' > /dev/null && \ + LN_S_R="$as_ln_s -r" + rm -rf "${DIR1}" "${DIR2}" +fi +LN_S_R=${LN_S_R} + +if test "$LN_S_R" = "ln -s -r" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S_R" >&5 +$as_echo "no, using $LN_S_R" >&6; } +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for unsigned long long int" >&5 $as_echo_n "checking for unsigned long long int... " >&6; } @@ -7037,18 +11555,18 @@ else /* end confdefs.h. */ /* For now, do not test the preprocessor; as of 2007 there are too many - implementations with broken preprocessors. Perhaps this can - be revisited in 2012. In the meantime, code should not expect - #if to work with literals wider than 32 bits. */ + implementations with broken preprocessors. Perhaps this can + be revisited in 2012. In the meantime, code should not expect + #if to work with literals wider than 32 bits. */ /* Test literals. */ long long int ll = 9223372036854775807ll; long long int nll = -9223372036854775807LL; unsigned long long int ull = 18446744073709551615ULL; /* Test constant expressions. */ typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) - ? 1 : -1)]; + ? 1 : -1)]; typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1 - ? 1 : -1)]; + ? 1 : -1)]; int i = 63; int main () @@ -7057,9 +11575,9 @@ main () long long int llmax = 9223372036854775807ll; unsigned long long int ullmax = 18446744073709551615ull; return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) - | (llmax / ll) | (llmax % ll) - | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) - | (ullmax / ull) | (ullmax % ull)); + | (llmax / ll) | (llmax % ll) + | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) + | (ullmax / ull) | (ullmax % ull)); ; return 0; } @@ -7150,33 +11668,33 @@ if ${ac_cv_type_long_long_int+:} false; then : else ac_cv_type_long_long_int=yes if test "x${ac_cv_prog_cc_c99-no}" = xno; then - ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int - if test $ac_cv_type_long_long_int = yes; then - if test "$cross_compiling" = yes; then : + ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int + if test $ac_cv_type_long_long_int = yes; then + if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include - #ifndef LLONG_MAX - # define HALF \ - (1LL << (sizeof (long long int) * CHAR_BIT - 2)) - # define LLONG_MAX (HALF - 1 + HALF) - #endif + #ifndef LLONG_MAX + # define HALF \ + (1LL << (sizeof (long long int) * CHAR_BIT - 2)) + # define LLONG_MAX (HALF - 1 + HALF) + #endif int main () { long long int n = 1; - int i; - for (i = 0; ; i++) - { - long long int m = n << i; - if (m >> i != n) - return 1; - if (LLONG_MAX / 2 < m) - break; - } - return 0; + int i; + for (i = 0; ; i++) + { + long long int m = n << i; + if (m >> i != n) + return 1; + if (LLONG_MAX / 2 < m) + break; + } + return 0; ; return 0; } @@ -7190,7 +11708,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi - fi + fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_long_long_int" >&5 @@ -7247,217 +11765,6 @@ fi - - - - - - - - - -if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. -set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_PKG_CONFIG+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $PKG_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -PKG_CONFIG=$ac_cv_path_PKG_CONFIG -if test -n "$PKG_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 -$as_echo "$PKG_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_path_PKG_CONFIG"; then - ac_pt_PKG_CONFIG=$PKG_CONFIG - # Extract the first word of "pkg-config", so it can be a program name with args. -set dummy pkg-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $ac_pt_PKG_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG -if test -n "$ac_pt_PKG_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 -$as_echo "$ac_pt_PKG_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_pt_PKG_CONFIG" = x; then - PKG_CONFIG="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - PKG_CONFIG=$ac_pt_PKG_CONFIG - fi -else - PKG_CONFIG="$ac_cv_path_PKG_CONFIG" -fi - -fi -if test -n "$PKG_CONFIG"; then - _pkg_min_version=0.9.0 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 -$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } - if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - PKG_CONFIG="" - fi -fi - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CPPUNIT" >&5 -$as_echo_n "checking for CPPUNIT... " >&6; } - -if test -n "$CPPUNIT_CFLAGS"; then - pkg_cv_CPPUNIT_CFLAGS="$CPPUNIT_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"cppunit\""; } >&5 - ($PKG_CONFIG --exists --print-errors "cppunit") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_CPPUNIT_CFLAGS=`$PKG_CONFIG --cflags "cppunit" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$CPPUNIT_LIBS"; then - pkg_cv_CPPUNIT_LIBS="$CPPUNIT_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"cppunit\""; } >&5 - ($PKG_CONFIG --exists --print-errors "cppunit") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_CPPUNIT_LIBS=`$PKG_CONFIG --libs "cppunit" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - CPPUNIT_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "cppunit" 2>&1` - else - CPPUNIT_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "cppunit" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$CPPUNIT_PKG_ERRORS" >&5 - - have_cppunit=no -elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - have_cppunit=no -else - CPPUNIT_CFLAGS=$pkg_cv_CPPUNIT_CFLAGS - CPPUNIT_LIBS=$pkg_cv_CPPUNIT_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - have_cppunit=yes -fi -if test "${have_cppunit}" != "yes" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libcppunit not found." >&5 -$as_echo "$as_me: WARNING: libcppunit not found." >&2;} -fi - if test "${have_cppunit}" = "yes"; then - HAVE_CPPUNIT_TRUE= - HAVE_CPPUNIT_FALSE='#' -else - HAVE_CPPUNIT_TRUE='#' - HAVE_CPPUNIT_FALSE= -fi - - -if ( test "${GCC}" = "yes" ) -then - CFLAGS="${CFLAGS} -Wall -Wsign-compare" -fi - case ${target_os} in solaris2* ) CFLAGS="${CFLAGS} -D_REENTRANT" @@ -7734,42 +12041,10 @@ if test "$ac_res" != no; then : fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 -$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } -if ${ac_cv_header_time+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -int -main () -{ -if ((struct tm *) 0) -return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_time=yes -else - ac_cv_header_time=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 -$as_echo "$ac_cv_header_time" >&6; } -if test $ac_cv_header_time = yes; then -$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h -fi - -for ac_header in sys/modem.h stdarg.h varargs.h sys/termios.h sys/time.h + for ac_header in $ac_header_list do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default @@ -7784,7 +12059,39 @@ fi done -# pthread related checks + + + + + + + + + + +if test "$ac_cv_header_sys_time_h" = yes; then : + +$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h + + +fi + +for ac_header in sys/modem.h stdarg.h varargs.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_create" >&5 $as_echo_n "checking for library containing pthread_create... " >&6; } if ${ac_cv_search_pthread_create+:} false; then : @@ -7841,12 +12148,310 @@ if test "$ac_res" != no; then : $as_echo "#define HAVE_PTHREAD 1" >>confdefs.h + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_tryjoin_np" >&5 +$as_echo_n "checking for library containing pthread_tryjoin_np... " >&6; } +if ${ac_cv_search_pthread_tryjoin_np+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_tryjoin_np (); +int +main () +{ +return pthread_tryjoin_np (); + ; + return 0; +} +_ACEOF +for ac_lib in '' pthread; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_pthread_tryjoin_np=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_pthread_tryjoin_np+:} false; then : + break +fi +done +if ${ac_cv_search_pthread_tryjoin_np+:} false; then : + +else + ac_cv_search_pthread_tryjoin_np=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_tryjoin_np" >&5 +$as_echo "$ac_cv_search_pthread_tryjoin_np" >&6; } +ac_res=$ac_cv_search_pthread_tryjoin_np +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +$as_echo "#define HAVE_PTHREAD_TRYJOIN 1" >>confdefs.h + +fi + + fi - ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "#include -#include + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for windows.h" >&5 +$as_echo_n "checking for windows.h... " >&6; } +if ${nut_cv_header_windows_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +#undef inline +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include + +int +main () +{ + +#if defined(__CYGWIN__) || defined(__CEGCC__) + HAVE_WINDOWS_H shall not be defined. +#else + int dummy=2*WINVER; +#endif + + ; + return 0; +} + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + nut_cv_header_windows_h="yes" + +else + + nut_cv_header_windows_h="no" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $nut_cv_header_windows_h" >&5 +$as_echo "$nut_cv_header_windows_h" >&6; } + case "$nut_cv_header_windows_h" in + yes) + +cat >>confdefs.h <<_ACEOF +#define HAVE_WINDOWS_H 1 +_ACEOF + + ;; + esac + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for winsock2.h" >&5 +$as_echo_n "checking for winsock2.h... " >&6; } +if ${nut_cv_header_winsock2_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +#undef inline +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#include + +int +main () +{ + +#if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__) + HAVE_WINSOCK2_H shall not be defined. +#else + int dummy=2*IPPROTO_ESP; +#endif + + ; + return 0; +} + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + nut_cv_header_winsock2_h="yes" + +else + + nut_cv_header_winsock2_h="no" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $nut_cv_header_winsock2_h" >&5 +$as_echo "$nut_cv_header_winsock2_h" >&6; } + case "$nut_cv_header_winsock2_h" in + yes) + +cat >>confdefs.h <<_ACEOF +#define HAVE_WINSOCK2_H 1 +_ACEOF + + ;; + esac + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ws2tcpip.h" >&5 +$as_echo_n "checking for ws2tcpip.h... " >&6; } +if ${nut_cv_header_ws2tcpip_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +#undef inline +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#include +#include + +int +main () +{ + +#if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__) + HAVE_WS2TCPIP_H shall not be defined. +#else + int dummy=2*IP_PKTINFO; +#endif + + ; + return 0; +} + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + nut_cv_header_ws2tcpip_h="yes" + +else + + nut_cv_header_ws2tcpip_h="no" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $nut_cv_header_ws2tcpip_h" >&5 +$as_echo "$nut_cv_header_ws2tcpip_h" >&6; } + case "$nut_cv_header_ws2tcpip_h" in + yes) + +cat >>confdefs.h <<_ACEOF +#define HAVE_WS2TCPIP_H 1 +_ACEOF + + ;; + esac + + + HEADERS_SOCKLEN_T=' +#undef inline +#ifdef HAVE_WINDOWS_H +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501) +# undef _WIN32_WINNT +# define _WIN32_WINNT 0x0501 +# endif +# include +# ifdef HAVE_WINSOCK2_H +# include +# ifdef HAVE_WS2TCPIP_H +# include +# endif +# endif +# define GNICALLCONV WSAAPI +# define GNICALLLINK WINSOCK_API_LINKAGE +#else +# ifdef HAVE_SYS_TYPES_H +# include +# endif +# ifdef HAVE_SYS_SOCKET_H +# include +# endif +# ifdef HAVE_NETDB_H +# include +# endif +# define GNICALLCONV +# define GNICALLLINK +#endif +' + ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "${HEADERS_SOCKLEN_T} " if test "x$ac_cv_type_socklen_t" = xyes; then : @@ -7860,22 +12465,26 @@ else # Systems have either "struct sockaddr *" or # "void *" as the second argument to getpeername + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + nut_cv_socklen_t_equiv= - for arg2 in "struct sockaddr" void; do - for t in int size_t unsigned long "unsigned long"; do + for arg1 in "int" "SOCKET"; do + for arg2 in "struct sockaddr" void; do + for arg3 in int size_t unsigned long "unsigned long"; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -#include -#include - - int getpeername (int, $arg2 *, $t *); +${HEADERS_SOCKLEN_T} + GNICALLLINK int GNICALLCONV getpeername ($arg1, $arg2 *, $arg3 *); int main () { - $t len; + $arg3 len; getpeername(0,0,&len); ; @@ -7884,13 +12493,20 @@ main () _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - nut_cv_socklen_t_equiv="$t" + nut_cv_socklen_t_equiv="$arg3" break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done + done done + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + if test "x$nut_cv_socklen_t_equiv" = x; then as_fn_error $? "Cannot find a type to use in place of socklen_t" "$LINENO" 5 @@ -7909,6 +12525,746 @@ fi + for ac_header in sys/types.h sys/socket.h netdb.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking types of arguments for getnameinfo" >&5 +$as_echo_n "checking types of arguments for getnameinfo... " >&6; } +if ${nut_cv_func_getnameinfo_args+:} false; then : + $as_echo_n "(cached) " >&6 +else + + nut_cv_func_getnameinfo_args="unknown" + for gni_arg1 in 'const struct sockaddr *' 'struct sockaddr *' 'void *'; do + for gni_arg2 in 'socklen_t' 'size_t' 'int'; do + for gni_arg46 in 'socklen_t' 'size_t' 'int' 'unsigned int'; do + for gni_arg7 in 'int' 'unsigned int'; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +#undef inline +#ifdef HAVE_WINDOWS_H +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501) +# undef _WIN32_WINNT +# define _WIN32_WINNT 0x0501 +# endif +# include +# ifdef HAVE_WINSOCK2_H +# include +# ifdef HAVE_WS2TCPIP_H +# include +# endif +# endif +# define GNICALLCONV WSAAPI +#else +# ifdef HAVE_SYS_TYPES_H +# include +# endif +# ifdef HAVE_SYS_SOCKET_H +# include +# endif +# ifdef HAVE_NETDB_H +# include +# endif +# define GNICALLCONV +#endif + extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2, + char *, $gni_arg46, + char *, $gni_arg46, + $gni_arg7); + +int +main () +{ + + $gni_arg2 salen=0; + $gni_arg46 hostlen=0; + $gni_arg46 servlen=0; + $gni_arg7 flags=0; + int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags); + + ; + return 0; +} + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + nut_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7" + break 4 + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done + done + done + done + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $nut_cv_func_getnameinfo_args" >&5 +$as_echo "$nut_cv_func_getnameinfo_args" >&6; } + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + if test "$nut_cv_func_getnameinfo_args" = "unknown"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find proper types to use for getnameinfo args" >&5 +$as_echo "$as_me: WARNING: Cannot find proper types to use for getnameinfo args" >&2;} + else + gni_prev_IFS=$IFS; IFS=',' + set dummy `echo "$nut_cv_func_getnameinfo_args" | sed 's/\*/\*/g'` + IFS=$gni_prev_IFS + shift + +cat >>confdefs.h <<_ACEOF +#define GETNAMEINFO_TYPE_ARG1 $1 +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define GETNAMEINFO_TYPE_ARG2 $2 +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define GETNAMEINFO_TYPE_ARG46 $3 +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define GETNAMEINFO_TYPE_ARG7 $4 +_ACEOF + + fi + + + + if test -z "${nut_with_python}"; then : + + +# Check whether --with-python was given. +if test "${with_python+set}" = set; then : + withval=$with_python; nut_with_python="${withval}" +else + nut_with_python="auto" + +fi + + + + PYTHON="" + case ${nut_with_python} in #( + auto|yes|"") : + for ac_prog in python python3 python2 +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_PYTHON+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PYTHON"; then + ac_cv_prog_PYTHON="$PYTHON" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_PYTHON="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PYTHON=$ac_cv_prog_PYTHON +if test -n "$PYTHON"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5 +$as_echo "$PYTHON" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$PYTHON" && break +done +test -n "$PYTHON" || PYTHON="_python_runtime" + ;; #( + no) : + PYTHON="no" ;; #( + *) : + PYTHON="${nut_with_python}" + ;; +esac + + case ${PYTHON} in #( + _python_runtime) : + + PYTHON="/usr/bin/env python" + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: A python program name was not detected during configuration, will default to '$PYTHON' (scripts will fail if that is not in PATH at run time)" >&5 +$as_echo "$as_me: WARNING: A python program name was not detected during configuration, will default to '$PYTHON' (scripts will fail if that is not in PATH at run time)" >&2;} ;; #( + no) : + ;; #( + /*" "*" "*) : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: A python program name is not a single token (was specified with more than one argument?), so shebangs can be not reliable" >&5 +$as_echo "$as_me: WARNING: A python program name is not a single token (was specified with more than one argument?), so shebangs can be not reliable" >&2;} + ;; #( + /*) : + ;; #( + *" "*" "*) : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: A python program name is not a single token (was specified with more than one argument?), so shebangs can be not reliable" >&5 +$as_echo "$as_me: WARNING: A python program name is not a single token (was specified with more than one argument?), so shebangs can be not reliable" >&2;} + PYTHON="/usr/bin/env ${PYTHON}" + ;; #( + *" "*) : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: A python program name is not a single token (was specified with an argument?), so /usr/bin/env shebangs can be not reliable" >&5 +$as_echo "$as_me: WARNING: A python program name is not a single token (was specified with an argument?), so /usr/bin/env shebangs can be not reliable" >&2;} + PYTHON="/usr/bin/env ${PYTHON}" + ;; #( + *) : + PYTHON="/usr/bin/env ${PYTHON}" + ;; #( + *) : + ;; +esac + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking python interpeter to call" >&5 +$as_echo_n "checking python interpeter to call... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${PYTHON}" >&5 +$as_echo "${PYTHON}" >&6; } + PYTHON=${PYTHON} + + if test "${PYTHON}" != "no"; then + HAVE_PYTHON_TRUE= + HAVE_PYTHON_FALSE='#' +else + HAVE_PYTHON_TRUE='#' + HAVE_PYTHON_FALSE= +fi + + if test -n "${PYTHON}"; then : + export PYTHON +fi + +fi + + + if test -z "${nut_with_python2}"; then : + + +# Check whether --with-python2 was given. +if test "${with_python2+set}" = set; then : + withval=$with_python2; nut_with_python2="${withval}" +else + nut_with_python2="auto" + +fi + + + + PYTHON2="" + case ${nut_with_python2} in #( + auto|yes|"") : + for ac_prog in python2 python2.7 python-2.7 python +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_PYTHON2+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PYTHON2"; then + ac_cv_prog_PYTHON2="$PYTHON2" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_PYTHON2="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PYTHON2=$ac_cv_prog_PYTHON2 +if test -n "$PYTHON2"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON2" >&5 +$as_echo "$PYTHON2" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$PYTHON2" && break +done +test -n "$PYTHON2" || PYTHON2="_python2_runtime" + ;; #( + no) : + PYTHON2="no" ;; #( + *) : + PYTHON2="${nut_with_python2}" + ;; +esac + + case ${PYTHON2} in #( + _python2_runtime) : + + PYTHON2="/usr/bin/env python2" + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: A python2 program name was not detected during configuration, will default to '$PYTHON2' (scripts will fail if that is not in PATH at run time)" >&5 +$as_echo "$as_me: WARNING: A python2 program name was not detected during configuration, will default to '$PYTHON2' (scripts will fail if that is not in PATH at run time)" >&2;} ;; #( + no) : + ;; #( + /*" "*" "*) : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: A python2 program name is not a single token (was specified with more than one argument?), so shebangs can be not reliable" >&5 +$as_echo "$as_me: WARNING: A python2 program name is not a single token (was specified with more than one argument?), so shebangs can be not reliable" >&2;} + ;; #( + /*) : + ;; #( + *" "*" "*) : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: A python2 program name is not a single token (was specified with more than one argument?), so shebangs can be not reliable" >&5 +$as_echo "$as_me: WARNING: A python2 program name is not a single token (was specified with more than one argument?), so shebangs can be not reliable" >&2;} + PYTHON2="/usr/bin/env ${PYTHON2}" + ;; #( + *" "*) : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: A python2 program name is not a single token (was specified with an argument?), so /usr/bin/env shebangs can be not reliable" >&5 +$as_echo "$as_me: WARNING: A python2 program name is not a single token (was specified with an argument?), so /usr/bin/env shebangs can be not reliable" >&2;} + PYTHON2="/usr/bin/env ${PYTHON2}" + ;; #( + *) : + PYTHON2="/usr/bin/env ${PYTHON2}" + ;; #( + *) : + ;; +esac + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking python2 interpeter to call" >&5 +$as_echo_n "checking python2 interpeter to call... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${PYTHON2}" >&5 +$as_echo "${PYTHON2}" >&6; } + PYTHON2=${PYTHON2} + + if test "${PYTHON2}" != "no"; then + HAVE_PYTHON2_TRUE= + HAVE_PYTHON2_FALSE='#' +else + HAVE_PYTHON2_TRUE='#' + HAVE_PYTHON2_FALSE= +fi + + if test -n "${PYTHON2}"; then : + export PYTHON2 +fi + +fi + + + if test -z "${nut_with_python3}"; then : + + +# Check whether --with-python3 was given. +if test "${with_python3+set}" = set; then : + withval=$with_python3; nut_with_python3="${withval}" +else + nut_with_python3="auto" + +fi + + + + PYTHON3="" + case ${nut_with_python3} in #( + auto|yes|"") : + for ac_prog in python3 python3.9 python-3.9 python3.7 python-3.7 python3.5 python-3.5 python +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_PYTHON3+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$PYTHON3"; then + ac_cv_prog_PYTHON3="$PYTHON3" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_PYTHON3="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +PYTHON3=$ac_cv_prog_PYTHON3 +if test -n "$PYTHON3"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON3" >&5 +$as_echo "$PYTHON3" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$PYTHON3" && break +done +test -n "$PYTHON3" || PYTHON3="_python3_runtime" + ;; #( + no) : + PYTHON3="no" ;; #( + *) : + PYTHON3="${nut_with_python3}" + ;; +esac + + case ${PYTHON3} in #( + _python3_runtime) : + + PYTHON3="/usr/bin/env python3" + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: A python3 program name was not detected during configuration, will default to '$PYTHON3' (scripts will fail if that is not in PATH at run time)" >&5 +$as_echo "$as_me: WARNING: A python3 program name was not detected during configuration, will default to '$PYTHON3' (scripts will fail if that is not in PATH at run time)" >&2;} ;; #( + no) : + ;; #( + /*" "*" "*) : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: A python3 program name is not a single token (was specified with more than one argument?), so shebangs can be not reliable" >&5 +$as_echo "$as_me: WARNING: A python3 program name is not a single token (was specified with more than one argument?), so shebangs can be not reliable" >&2;} + ;; #( + /*) : + ;; #( + *" "*" "*) : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: A python3 program name is not a single token (was specified with more than one argument?), so shebangs can be not reliable" >&5 +$as_echo "$as_me: WARNING: A python3 program name is not a single token (was specified with more than one argument?), so shebangs can be not reliable" >&2;} + PYTHON3="/usr/bin/env ${PYTHON3}" + ;; #( + *" "*) : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: A python3 program name is not a single token (was specified with an argument?), so /usr/bin/env shebangs can be not reliable" >&5 +$as_echo "$as_me: WARNING: A python3 program name is not a single token (was specified with an argument?), so /usr/bin/env shebangs can be not reliable" >&2;} + PYTHON3="/usr/bin/env ${PYTHON3}" + ;; #( + *) : + PYTHON3="/usr/bin/env ${PYTHON3}" + ;; #( + *) : + ;; +esac + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking python3 interpeter to call" >&5 +$as_echo_n "checking python3 interpeter to call... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${PYTHON3}" >&5 +$as_echo "${PYTHON3}" >&6; } + PYTHON3=${PYTHON3} + + if test "${PYTHON3}" != "no"; then + HAVE_PYTHON3_TRUE= + HAVE_PYTHON3_FALSE='#' +else + HAVE_PYTHON3_TRUE='#' + HAVE_PYTHON3_FALSE= +fi + + if test -n "${PYTHON3}"; then : + export PYTHON3 +fi + +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which drivers to build" >&5 +$as_echo_n "checking which drivers to build... " >&6; } + +# Check whether --with-drivers was given. +if test "${with_drivers+set}" = set; then : + withval=$with_drivers; + case "${withval}" in + yes|no|'') + as_fn_error $? "invalid option --with(out)-drivers - see docs/configure.txt" "$LINENO" 5 + ;; + all) + DRIVER_BUILD_LIST="all" + if test -z "${with_serial}"; then with_serial="yes"; fi + if test -z "${with_usb}"; then with_usb="yes"; fi + if test -z "${with_snmp}"; then with_snmp="yes"; fi + if test -z "${with_neon}"; then with_neon="yes"; fi + if test -z "${with_powerman}"; then with_powerman="yes"; fi + if test -z "${with_modbus}"; then with_modbus="yes"; fi + if test -z "${with_ipmi}"; then with_ipmi="yes"; fi + + if test -z "${with_linux_i2c}"; then + case ${target_os} in + linux*) with_linux_i2c="yes";; + *) with_linux_i2c="auto";; + esac + fi + if test -z "${with_macosx_ups}"; then + if test -d /System/Library/Frameworks/IOKit.framework/ ; then + with_macosx_ups="yes" + else + with_macosx_ups="auto" + fi + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${DRIVER_BUILD_LIST}" >&5 +$as_echo "${DRIVER_BUILD_LIST}" >&6; } + ;; + auto) + DRIVER_BUILD_LIST="all" + if test -z "${with_serial}"; then with_serial="${withval}"; fi + if test -z "${with_usb}"; then with_usb="${withval}"; fi + if test -z "${with_snmp}"; then with_snmp="${withval}"; fi + if test -z "${with_neon}"; then with_neon="${withval}"; fi + if test -z "${with_powerman}"; then with_powerman="${withval}"; fi + if test -z "${with_modbus}"; then with_modbus="${withval}"; fi + if test -z "${with_ipmi}"; then with_ipmi="${withval}"; fi + if test -z "${with_linux_i2c}"; then with_linux_i2c="${withval}"; fi + if test -z "${with_macosx_ups}"; then with_macosx_ups="${withval}"; fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${DRIVER_BUILD_LIST}" >&5 +$as_echo "${DRIVER_BUILD_LIST}" >&6; } + ;; + *) + DRIVER_BUILD_LIST="`echo ${withval} | sed 's/,/ /g'`" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${DRIVER_BUILD_LIST}" >&5 +$as_echo "${DRIVER_BUILD_LIST}" >&6; } + + if test -n "$DRIVER_BUILD_LIST"; then : + DRVLIST_NAMES=" + SERIAL_DRIVERLIST USB_LIBUSB_DRIVERLIST SERIAL_USB_DRIVERLIST + SNMP_DRIVERLIST NEONXML_DRIVERLIST + MACOSX_DRIVERLIST MODBUS_DRIVERLIST LINUX_I2C_DRIVERLIST + POWERMAN_DRIVERLIST IPMI_DRIVERLIST" + + get_drvlist() ( + LB="["; RB="]" + SPACE="`printf "$LB"' \t'"$RB"`" + SPACES="${SPACE}*" + sed -e "s/${SPACES}""$LB"'+'"$RB"'*='"${SPACES}/=/" \ + -e "s/^${SPACES}//" < drivers/Makefile.am \ + | { + C=false; V=false + while read LINE ; do + case "$LINE" in + *'\') C=true; if $V ; then echo "$LINE" ; fi ;; + *) C=false; V=false ;; + esac + case "$LINE" in + "$1"=*) + echo "$LINE" | sed -e 's,^'"$LB"'^='"$RB"'*=,,' -e 's,\$,,' + V=$C + ;; + esac + done + } | tr '\n' ' ' | sed -e "s,${SPACE}${SPACES}, ," -e "s,${SPACES}\$,," + ) + + for DRVLIST_NAME in $DRVLIST_NAMES; do + OUT="`get_drvlist "$DRVLIST_NAME"`" \ + && test -n "$OUT" || OUT="" + eval $DRVLIST_NAME="\$OUT" + { $as_echo "$as_me:${as_lineno-$LINENO}: Will check custom driver selection against $DRVLIST_NAME=\"$OUT\"" >&5 +$as_echo "$as_me: Will check custom driver selection against $DRVLIST_NAME=\"$OUT\"" >&6;} + done + + for DRV in $DRIVER_BUILD_LIST ; do + + DRV_HITS="" + for DRVLIST_NAME in $DRVLIST_NAMES; do + eval DRVLIST="\${$DRVLIST_NAME}" + + for DN in $DRVLIST ; do + if test x"$DN" = x"$DRV"; then : + + DRV_HITS="$DRV_HITS $DRVLIST_NAME" + case "$DRVLIST_NAME" in #( + SERIAL_DRIVERLIST) : + + if test -z "${with_serial}"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: Requiring --with-serial=yes for driver \"$DRV\"" >&5 +$as_echo "$as_me: Requiring --with-serial=yes for driver \"$DRV\"" >&6;} + with_serial=yes + +fi ;; #( + USB_LIBUSB_DRIVERLIST) : + + if test -z "${with_usb}"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: Requiring --with-usb=yes for driver \"$DRV\"" >&5 +$as_echo "$as_me: Requiring --with-usb=yes for driver \"$DRV\"" >&6;} + with_usb=yes + +fi ;; #( + SERIAL_USB_DRIVERLIST) : + + if test -z "${with_usb}"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: Requiring --with-usb=yes for driver \"$DRV\"" >&5 +$as_echo "$as_me: Requiring --with-usb=yes for driver \"$DRV\"" >&6;} + with_usb=yes + +fi + if test -z "${with_serial}"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: Requiring --with-serial=yes for driver \"$DRV\"" >&5 +$as_echo "$as_me: Requiring --with-serial=yes for driver \"$DRV\"" >&6;} + with_serial=yes + +fi ;; #( + SNMP_DRIVERLIST) : + + if test -z "${with_snmp}"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: Requiring --with-snmp=yes for driver \"$DRV\"" >&5 +$as_echo "$as_me: Requiring --with-snmp=yes for driver \"$DRV\"" >&6;} + with_snmp=yes + +fi ;; #( + NEONXML_DRIVERLIST) : + + if test -z "${with_neon}"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: Requiring --with-neon=yes for driver \"$DRV\"" >&5 +$as_echo "$as_me: Requiring --with-neon=yes for driver \"$DRV\"" >&6;} + with_neon=yes + +fi ;; #( + MACOSX_DRIVERLIST) : + + if test -z "${with_macosx_ups}"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: Requiring --with-macosx-ups=yes for driver \"$DRV\"" >&5 +$as_echo "$as_me: Requiring --with-macosx-ups=yes for driver \"$DRV\"" >&6;} + with_macosx_ups=yes + +fi ;; #( + MODBUS_DRIVERLIST) : + + if test -z "${with_modbus}"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: Requiring --with-modbus=yes for driver \"$DRV\"" >&5 +$as_echo "$as_me: Requiring --with-modbus=yes for driver \"$DRV\"" >&6;} + with_modbus=yes + +fi ;; #( + LINUX_I2C_DRIVERLIST) : + + if test -z "${with_linux_i2c}"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: Requiring --with-linux-i2c=yes for driver \"$DRV\"" >&5 +$as_echo "$as_me: Requiring --with-linux-i2c=yes for driver \"$DRV\"" >&6;} + with_linux_i2c=yes + +fi ;; #( + POWERMAN_DRIVERLIST) : + + if test -z "${with_powerman}"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: Requiring --with-powerman=yes for driver \"$DRV\"" >&5 +$as_echo "$as_me: Requiring --with-powerman=yes for driver \"$DRV\"" >&6;} + with_powerman=yes + +fi ;; #( + IPMI_DRIVERLIST) : + + if test -z "${with_ipmi}"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: Requiring --with-ipmi=yes for driver \"$DRV\"" >&5 +$as_echo "$as_me: Requiring --with-ipmi=yes for driver \"$DRV\"" >&6;} + with_ipmi=yes + +fi ;; #( + *) : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unhandled DRVLIST_NAME=$DRVLIST_NAME" >&5 +$as_echo "$as_me: WARNING: Unhandled DRVLIST_NAME=$DRVLIST_NAME" >&2;} + ;; +esac + break + +fi + done + done + if test -z "${DRV_HITS}"; then : + as_fn_error $? "Requested driver '$DRV' is not defined in drivers/Makefile.am (or configure.ac has a bug/lag detecting driver lists)" "$LINENO" 5 +fi + + done + +fi + + ;; + esac + +else + + DRIVER_BUILD_LIST="all" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: all available" >&5 +$as_echo "all available" >&6; } + +fi + + if test "${DRIVER_BUILD_LIST}" != "all"; then + SOME_DRIVERS_TRUE= + SOME_DRIVERS_FALSE='#' +else + SOME_DRIVERS_TRUE='#' + SOME_DRIVERS_FALSE= +fi + + +if test "${DRIVER_BUILD_LIST}" != "all"; then + if test -z "${nut_report_feature_flag}"; then + nut_report_feature_flag="1" + ac_clean_files="${ac_clean_files} conf_nut_report_feature" + echo > conf_nut_report_feature + echo "Configuration summary:" >> conf_nut_report_feature + echo "======================" >> conf_nut_report_feature + fi + echo "only build specific drivers: ${DRIVER_BUILD_LIST}" >> conf_nut_report_feature + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-all" >&5 $as_echo_n "checking for --with-all... " >&6; } @@ -7917,16 +13273,32 @@ $as_echo_n "checking for --with-all... " >&6; } if test "${with_all+set}" = set; then : withval=$with_all; if test -n "${withval}"; then - if test -z "${with_serial}"; then with_serial="${withval}"; fi + if test -z "${with_serial}"; then with_serial="${withval}"; fi if test -z "${with_usb}"; then with_usb="${withval}"; fi if test -z "${with_snmp}"; then with_snmp="${withval}"; fi if test -z "${with_neon}"; then with_neon="${withval}"; fi if test -z "${with_powerman}"; then with_powerman="${withval}"; fi - if test -z "${with_cgi}"; then with_cgi="${withval}"; fi + if test -z "${with_modbus}"; then with_modbus="${withval}"; fi + if test -z "${with_ipmi}"; then with_ipmi="${withval}"; fi + + if test -z "${with_linux_i2c}"; then + with_linux_i2c="${withval}" + case ${target_os} in + linux*) ;; + *) test x"${withval}" = xno || with_linux_i2c="auto" ;; + esac + fi + if test -z "${with_macosx_ups}"; then + with_macosx_ups="${withval}" + if ! test -d /System/Library/Frameworks/IOKit.framework/ ; then + test x"${withval}" = xno || with_macosx_ups="auto" + fi + fi + + if test -z "${with_cgi}"; then with_cgi="${withval}"; fi if test -z "${with_dev}"; then with_dev="${withval}"; fi if test -z "${with_avahi}"; then with_avahi="${withval}"; fi - if test -z "${with_ipmi}"; then with_ipmi="${withval}"; fi - if test -z "${with_linux_i2c}"; then with_linux_i2c="${withval}"; fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: \"${withval}\"" >&5 $as_echo "\"${withval}\"" >&6; } else @@ -7954,6 +13326,48 @@ fi + +# Check whether --with-docs was given. +if test "${with_docs+set}" = set; then : + withval=$with_docs; nut_with_docs="${withval}" +else + nut_with_docs="man=auto" + +fi + + + +# Check whether --with-doc was given. +if test "${with_doc+set}" = set; then : + withval=$with_doc; nut_with_doc="${withval}" +else + nut_with_doc="${nut_with_docs}" + +fi + + + + # Check whether --enable-warnings was given. +if test "${enable_warnings+set}" = set; then : + enableval=$enable_warnings; nut_enable_warnings="${enableval}" +else + nut_enable_warnings="auto" + +fi + + + # Check whether --enable-Werror was given. +if test "${enable_Werror+set}" = set; then : + enableval=$enable_Werror; nut_enable_Werror="${enableval}" +else + nut_enable_Werror="no" + +fi + + + + + # Check whether --with-serial was given. if test "${with_serial+set}" = set; then : withval=$with_serial; nut_with_serial="${withval}" @@ -7964,6 +13378,8 @@ fi + + # Check whether --with-usb was given. if test "${with_usb+set}" = set; then : withval=$with_usb; nut_with_usb="${withval}" @@ -7973,170 +13389,472 @@ else fi - -# Check whether --with-doc was given. -if test "${with_doc+set}" = set; then : - withval=$with_doc; nut_with_doc="${withval}" -else - nut_with_doc="no" - -fi - - - -# Check whether --with-avahi was given. -if test "${with_avahi+set}" = set; then : - withval=$with_avahi; nut_with_avahi="${withval}" -else - nut_with_avahi="auto" - -fi - - - - - - -if test -z "${nut_have_libnetsnmp_seen}"; then - nut_have_libnetsnmp_seen=yes - - CFLAGS_ORIG="${CFLAGS}" - LIBS_ORIG="${LIBS}" - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Net-SNMP version via net-snmp-config" >&5 -$as_echo_n "checking for Net-SNMP version via net-snmp-config... " >&6; } - SNMP_VERSION=`net-snmp-config --version 2>/dev/null` - if test "$?" != "0" -o -z "${SNMP_VERSION}"; then - SNMP_VERSION="none" - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${SNMP_VERSION} found" >&5 -$as_echo "${SNMP_VERSION} found" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Net-SNMP cflags" >&5 -$as_echo_n "checking for Net-SNMP cflags... " >&6; } - -# Check whether --with-snmp-includes was given. -if test "${with_snmp_includes+set}" = set; then : - withval=$with_snmp_includes; - case "${withval}" in - yes|no) - as_fn_error $? "invalid option --with(out)-snmp-includes - see docs/configure.txt" "$LINENO" 5 - ;; - *) - CFLAGS="${withval}" - ;; - esac - -else - CFLAGS="`net-snmp-config --base-cflags 2>/dev/null`" -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${CFLAGS}" >&5 -$as_echo "${CFLAGS}" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Net-SNMP libs" >&5 -$as_echo_n "checking for Net-SNMP libs... " >&6; } - -# Check whether --with-snmp-libs was given. -if test "${with_snmp_libs+set}" = set; then : - withval=$with_snmp_libs; - case "${withval}" in - yes|no) - as_fn_error $? "invalid option --with(out)-snmp-libs - see docs/configure.txt" "$LINENO" 5 - ;; - *) - LIBS="${withval}" - ;; - esac - -else - LIBS="`net-snmp-config --libs 2>/dev/null`" -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${LIBS}" >&5 -$as_echo "${LIBS}" >&6; } - - for ac_header in net-snmp/net-snmp-config.h -do : - ac_fn_c_check_header_compile "$LINENO" "net-snmp/net-snmp-config.h" "ac_cv_header_net_snmp_net_snmp_config_h" "$ac_includes_default -" -if test "x$ac_cv_header_net_snmp_net_snmp_config_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_NET_SNMP_NET_SNMP_CONFIG_H 1 -_ACEOF - nut_have_libnetsnmp=yes -else - nut_have_libnetsnmp=no -fi - -done - - for ac_func in init_snmp -do : - ac_fn_c_check_func "$LINENO" "init_snmp" "ac_cv_func_init_snmp" -if test "x$ac_cv_func_init_snmp" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_INIT_SNMP 1 -_ACEOF - -else - nut_have_libnetsnmp=no -fi -done - - - if test "${nut_have_libnetsnmp}" = "yes"; then - LIBNETSNMP_CFLAGS="${CFLAGS}" - LIBNETSNMP_LIBS="${LIBS}" - fi - - CFLAGS="${CFLAGS_ORIG}" - LIBS="${LIBS_ORIG}" -fi - +nut_usb_lib="" if test -z "${nut_have_libusb_seen}"; then nut_have_libusb_seen=yes +if test -z "${nut_have_pkg_config_seen}"; then : + + nut_have_pkg_config_seen=yes + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG was already detected by autoconf" >&5 +$as_echo_n "checking whether usable PKG_CONFIG was already detected by autoconf... " >&6; } + if test -n "${PKG_CONFIG-}" && test x"${PKG_CONFIG-}" != x"false" && $PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${PKG_CONFIG}" >&5 +$as_echo "yes: ${PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + + if test x"${PKG_CONFIG-}" = x"false"; then : + have_PKG_CONFIG=yes + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_dummy_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $dummy_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_dummy_PKG_CONFIG="$dummy_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_dummy_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +dummy_PKG_CONFIG=$ac_cv_path_dummy_PKG_CONFIG +if test -n "$dummy_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dummy_PKG_CONFIG" >&5 +$as_echo "$dummy_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + +# Check whether --with-pkg-config was given. +if test "${with_pkg_config+set}" = set; then : + withval=$with_pkg_config; + case "${withval}" in + "") ;; + yes|no) + as_fn_error $? "invalid option --with(out)-pkg-config - see docs/configure.txt" "$LINENO" 5 + ;; + *) + dummy_PKG_CONFIG="${withval}" + ;; + esac + +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG is present in PATH or was set by caller" >&5 +$as_echo_n "checking whether usable PKG_CONFIG is present in PATH or was set by caller... " >&6; } + if test x"$dummy_PKG_CONFIG" = xno || test -z "$dummy_PKG_CONFIG"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + +else + if $dummy_PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${dummy_PKG_CONFIG}" >&5 +$as_echo "yes: ${dummy_PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + PKG_CONFIG="$dummy_PKG_CONFIG" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + +fi + +fi + + have_PKG_CONFIG_MACROS=no + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&6;} + dummy_RES=0 + + + if test "${dummy_RES}" = 0; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config module checker" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config module checker" >&6;} + + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pkg-config" >&5 +$as_echo_n "checking for pkg-config... " >&6; } + +if test -n "$dummy_PKG_CONFIG_CFLAGS"; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS="$dummy_PKG_CONFIG_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS=`$PKG_CONFIG --cflags "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$dummy_PKG_CONFIG_LIBS"; then + pkg_cv_dummy_PKG_CONFIG_LIBS="$dummy_PKG_CONFIG_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_LIBS=`$PKG_CONFIG --libs "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "pkg-config" 2>&1` + else + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "pkg-config" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$dummy_PKG_CONFIG_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (pkg-config) were not met: + +$dummy_PKG_CONFIG_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + dummy_PKG_CONFIG_CFLAGS=$pkg_cv_dummy_PKG_CONFIG_CFLAGS + dummy_PKG_CONFIG_LIBS=$pkg_cv_dummy_PKG_CONFIG_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + have_PKG_CONFIG_MACROS=yes +fi + + +fi + +fi + + if test x"$have_PKG_CONFIG" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&5 +$as_echo "$as_me: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&2;} + PKG_CONFIG="false" + +else + if test x"$have_PKG_CONFIG_MACROS" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&5 +$as_echo "$as_me: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&2;} + +fi + +fi + + +fi + CFLAGS_ORIG="${CFLAGS}" LIBS_ORIG="${LIBS}" + CFLAGS="" + LIBS="" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libusb version via pkg-config" >&5 -$as_echo_n "checking for libusb version via pkg-config... " >&6; } - LIBUSB_VERSION="`pkg-config --silence-errors --modversion libusb 2>/dev/null`" - if test "$?" = "0" -a -n "${LIBUSB_VERSION}"; then - CFLAGS="`pkg-config --silence-errors --cflags libusb 2>/dev/null`" - LIBS="`pkg-config --silence-errors --libs libusb 2>/dev/null`" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking via libusb-config" >&5 -$as_echo_n "checking via libusb-config... " >&6; } - LIBUSB_VERSION="`libusb-config --version 2>/dev/null`" - if test "$?" = "0" -a -n "${LIBUSB_VERSION}"; then - CFLAGS="`libusb-config --cflags 2>/dev/null`" - LIBS="`libusb-config --libs 2>/dev/null`" - else + nut_usb_lib="" + + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libusb-1.0 version via pkg-config" >&5 +$as_echo_n "checking for libusb-1.0 version via pkg-config... " >&6; } + LIBUSB_1_0_VERSION="`$PKG_CONFIG --silence-errors --modversion libusb-1.0 2>/dev/null`" \ + && test -n "${LIBUSB_1_0_VERSION}" \ + || LIBUSB_1_0_VERSION="none" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${LIBUSB_1_0_VERSION} found" >&5 +$as_echo "${LIBUSB_1_0_VERSION} found" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libusb(-0.1) version via pkg-config" >&5 +$as_echo_n "checking for libusb(-0.1) version via pkg-config... " >&6; } + LIBUSB_0_1_VERSION="`$PKG_CONFIG --silence-errors --modversion libusb 2>/dev/null`" \ + && test -n "${LIBUSB_0_1_VERSION}" \ + || LIBUSB_0_1_VERSION="none" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${LIBUSB_0_1_VERSION} found" >&5 +$as_echo "${LIBUSB_0_1_VERSION} found" >&6; } + +else + LIBUSB_0_1_VERSION="none" + LIBUSB_1_0_VERSION="none" + { $as_echo "$as_me:${as_lineno-$LINENO}: can not check libusb settings via pkg-config" >&5 +$as_echo "$as_me: can not check libusb settings via pkg-config" >&6;} + + +fi + + for ac_prog in libusb-config +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_LIBUSB_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $LIBUSB_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_LIBUSB_CONFIG="$LIBUSB_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_LIBUSB_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +LIBUSB_CONFIG=$ac_cv_path_LIBUSB_CONFIG +if test -n "$LIBUSB_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBUSB_CONFIG" >&5 +$as_echo "$LIBUSB_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$LIBUSB_CONFIG" && break +done +test -n "$LIBUSB_CONFIG" || LIBUSB_CONFIG="none" + + + +# Check whether --with-libusb-config was given. +if test "${with_libusb_config+set}" = set; then : + withval=$with_libusb_config; + case "${withval}" in #( + "") : + ;; #( + yes|no) : + + as_fn_error $? "invalid option --with(out)-libusb-config - see docs/configure.txt" "$LINENO" 5 + ;; #( + *) : + LIBUSB_CONFIG="${withval}" + + ;; +esac + + +fi + + + if test x"${LIBUSB_CONFIG}" != xnone; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking via ${LIBUSB_CONFIG}" >&5 +$as_echo_n "checking via ${LIBUSB_CONFIG}... " >&6; } + LIBUSB_CONFIG_VERSION="`$LIBUSB_CONFIG --version 2>/dev/null`" \ + && test -n "${LIBUSB_CONFIG_VERSION}" \ + || LIBUSB_CONFIG_VERSION="none" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${LIBUSB_CONFIG_VERSION} found" >&5 +$as_echo "${LIBUSB_CONFIG_VERSION} found" >&6; } + +else + LIBUSB_CONFIG_VERSION="none" + +fi + + if test x"${LIBUSB_1_0_VERSION}" != xnone; then : + LIBUSB_VERSION="${LIBUSB_1_0_VERSION}" + nut_usb_lib="(libusb-1.0)" + +else + if test x"${LIBUSB_0_1_VERSION}" != xnone; then : + LIBUSB_VERSION="${LIBUSB_0_1_VERSION}" + nut_usb_lib="(libusb-0.1)" + +else + LIBUSB_VERSION="${LIBUSB_CONFIG_VERSION}" + if test x"${LIBUSB_CONFIG_VERSION}" != xnone; then : + nut_usb_lib="(libusb-0.1-config)" +else + nut_usb_lib="" + +fi + +fi + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libusb preferred version" >&5 +$as_echo_n "checking for libusb preferred version... " >&6; } + case "${nut_with_usb}" in #( + auto) : + ;; #( + yes) : + ;; #( + no) : + ;; #( + libusb-1.0|1.0) : + + if test x"${LIBUSB_1_0_VERSION}" = xnone; then : + as_fn_error $? "option --with-usb=${withval} was required, but this library version was not detected" "$LINENO" 5 + +fi + LIBUSB_VERSION="${LIBUSB_1_0_VERSION}" + nut_usb_lib="(libusb-1.0)" + ;; #( + libusb-0.1|0.1) : + + if test x"${LIBUSB_0_1_VERSION}" = xnone \ + && test x"${LIBUSB_CONFIG_VERSION}" = xnone; then : + as_fn_error $? "option --with-usb=${withval} was required, but this library version was not detected" "$LINENO" 5 + +fi + if test x"${LIBUSB_0_1_VERSION}" != xnone; then : + LIBUSB_VERSION="${LIBUSB_0_1_VERSION}" + nut_usb_lib="(libusb-0.1)" + +else + LIBUSB_VERSION="${LIBUSB_CONFIG_VERSION}" + nut_usb_lib="(libusb-0.1-config)" + +fi + ;; #( + *) : + as_fn_error $? "invalid option value --with-usb=${withval} - see docs/configure.txt" "$LINENO" 5 + + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${LIBUSB_VERSION} ${nut_usb_lib}" >&5 +$as_echo "${LIBUSB_VERSION} ${nut_usb_lib}" >&6; } + + if test x"${LIBUSB_1_0_VERSION}" != xnone && test x"${nut_usb_lib}" != x"(libusb-1.0)" ; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: libusb-1.0 support was detected, but another was chosen ${nut_usb_lib}" >&5 +$as_echo "$as_me: libusb-1.0 support was detected, but another was chosen ${nut_usb_lib}" >&6;} + +fi + + case ${nut_usb_lib} in #( + "(libusb-1.0)") : + + CFLAGS="`$PKG_CONFIG --silence-errors --cflags libusb-1.0 2>/dev/null`" + LIBS="`$PKG_CONFIG --silence-errors --libs libusb-1.0 2>/dev/null`" + ;; #( + "(libusb-0.1)") : + + CFLAGS="`$PKG_CONFIG --silence-errors --cflags libusb 2>/dev/null`" + LIBS="`$PKG_CONFIG --silence-errors --libs libusb 2>/dev/null`" + ;; #( + "(libusb-0.1-config)") : + + CFLAGS="`$LIBUSB_CONFIG --cflags 2>/dev/null`" + LIBS="`$LIBUSB_CONFIG --libs 2>/dev/null`" + ;; #( + *) : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Defaulting libusb configuration" >&5 +$as_echo "$as_me: WARNING: Defaulting libusb configuration" >&2;} LIBUSB_VERSION="none" CFLAGS="" LIBS="-lusb" - fi - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${LIBUSB_VERSION} found" >&5 -$as_echo "${LIBUSB_VERSION} found" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libusb cflags" >&5 + ;; +esac + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libusb cflags" >&5 $as_echo_n "checking for libusb cflags... " >&6; } # Check whether --with-usb-includes was given. if test "${with_usb_includes+set}" = set; then : withval=$with_usb_includes; - case "${withval}" in - yes|no) - as_fn_error $? "invalid option --with(out)-usb-includes - see docs/configure.txt" "$LINENO" 5 - ;; - *) - CFLAGS="${withval}" - ;; - esac + case "${withval}" in #( + yes|no) : + + as_fn_error $? "invalid option --with(out)-usb-includes - see docs/configure.txt" "$LINENO" 5 + ;; #( + *) : + CFLAGS="${withval}" + + ;; +esac fi @@ -8149,21 +13867,138 @@ $as_echo_n "checking for libusb ldflags... " >&6; } # Check whether --with-usb-libs was given. if test "${with_usb_libs+set}" = set; then : withval=$with_usb_libs; - case "${withval}" in - yes|no) - as_fn_error $? "invalid option --with(out)-usb-libs - see docs/configure.txt" "$LINENO" 5 - ;; - *) - LIBS="${withval}" - ;; - esac + case "${withval}" in #( + yes|no) : + + as_fn_error $? "invalid option --with(out)-usb-libs - see docs/configure.txt" "$LINENO" 5 + ;; #( + *) : + LIBS="${withval}" + + ;; +esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${LIBS}" >&5 $as_echo "${LIBS}" >&6; } - for ac_header in usb.h + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + if test -n "${LIBUSB_VERSION}"; then + test -n "$PKG_CONFIG" \ + && test x"${nut_usb_lib}" = x"(libusb-1.0)" \ + && $PKG_CONFIG --silence-errors --atleast-version=1.0 libusb-1.0 2>/dev/null + if test "$?" = "0"; then + for ac_header in libusb.h +do : + ac_fn_c_check_header_compile "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default +" +if test "x$ac_cv_header_libusb_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBUSB_H 1 +_ACEOF + nut_have_libusb=yes +else + nut_have_libusb=no +fi + +done + + for ac_func in libusb_init +do : + ac_fn_c_check_func "$LINENO" "libusb_init" "ac_cv_func_libusb_init" +if test "x$ac_cv_func_libusb_init" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBUSB_INIT 1 +_ACEOF + +else + nut_have_libusb=no +fi +done + + for ac_func in libusb_strerror +do : + ac_fn_c_check_func "$LINENO" "libusb_strerror" "ac_cv_func_libusb_strerror" +if test "x$ac_cv_func_libusb_strerror" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBUSB_STRERROR 1 +_ACEOF + +else + nut_have_libusb=no; nut_have_libusb_strerror=no +fi +done + + if test "${nut_have_libusb_strerror}" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libusb_strerror() not found; install libusbx to use libusb 1.0 API. See https://github.com/networkupstools/nut/issues/509" >&5 +$as_echo "$as_me: WARNING: libusb_strerror() not found; install libusbx to use libusb 1.0 API. See https://github.com/networkupstools/nut/issues/509" >&2;} + fi + if test "${nut_have_libusb}" = "yes"; then + for ac_func in libusb_kernel_driver_active +do : + ac_fn_c_check_func "$LINENO" "libusb_kernel_driver_active" "ac_cv_func_libusb_kernel_driver_active" +if test "x$ac_cv_func_libusb_kernel_driver_active" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBUSB_KERNEL_DRIVER_ACTIVE 1 +_ACEOF + +fi +done + + for ac_func in libusb_set_auto_detach_kernel_driver +do : + ac_fn_c_check_func "$LINENO" "libusb_set_auto_detach_kernel_driver" "ac_cv_func_libusb_set_auto_detach_kernel_driver" +if test "x$ac_cv_func_libusb_set_auto_detach_kernel_driver" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBUSB_SET_AUTO_DETACH_KERNEL_DRIVER 1 +_ACEOF + +fi +done + + for ac_func in libusb_detach_kernel_driver +do : + ac_fn_c_check_func "$LINENO" "libusb_detach_kernel_driver" "ac_cv_func_libusb_detach_kernel_driver" +if test "x$ac_cv_func_libusb_detach_kernel_driver" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBUSB_DETACH_KERNEL_DRIVER 1 +_ACEOF + +fi +done + + for ac_func in libusb_detach_kernel_driver_np +do : + ac_fn_c_check_func "$LINENO" "libusb_detach_kernel_driver_np" "ac_cv_func_libusb_detach_kernel_driver_np" +if test "x$ac_cv_func_libusb_detach_kernel_driver_np" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBUSB_DETACH_KERNEL_DRIVER_NP 1 +_ACEOF + +fi +done + + + for ac_func in usb_detach_kernel_driver_np +do : + ac_fn_c_check_func "$LINENO" "usb_detach_kernel_driver_np" "ac_cv_func_usb_detach_kernel_driver_np" +if test "x$ac_cv_func_usb_detach_kernel_driver_np" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_USB_DETACH_KERNEL_DRIVER_NP 1 +_ACEOF + +fi +done + + fi + else + for ac_header in usb.h do : ac_fn_c_check_header_compile "$LINENO" "usb.h" "ac_cv_header_usb_h" "$ac_includes_default " @@ -8178,7 +14013,22 @@ fi done - for ac_func in usb_init + for ac_func in usb_init +do : + ac_fn_c_check_func "$LINENO" "usb_init" "ac_cv_func_usb_init" +if test "x$ac_cv_func_usb_init" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_USB_INIT 1 +_ACEOF + +else + + if test "${nut_have_libusb}" = "yes" && test "$LIBUSB_VERSION" = "none" && test -z "$LIBS"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libusb is just present in path" >&5 +$as_echo_n "checking if libusb is just present in path... " >&6; } + LIBS="-L/usr/lib -L/usr/local/lib -lusb" + unset ac_cv_func_usb_init || true + for ac_func in usb_init do : ac_fn_c_check_func "$LINENO" "usb_init" "ac_cv_func_usb_init" if test "x$ac_cv_func_usb_init" = xyes; then : @@ -8191,8 +14041,18 @@ else fi done + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${nut_have_libusb}" >&5 +$as_echo "${nut_have_libusb}" >&6; } - if test "${nut_have_libusb}" = "yes"; then +else + nut_have_libusb=no + +fi + +fi +done + + if test "${nut_have_libusb}" = "yes"; then for ac_func in usb_detach_kernel_driver_np do : ac_fn_c_check_func "$LINENO" "usb_detach_kernel_driver_np" "ac_cv_func_usb_detach_kernel_driver_np" @@ -8204,15 +14064,205 @@ _ACEOF fi done + + for ac_func in libusb_kernel_driver_active +do : + ac_fn_c_check_func "$LINENO" "libusb_kernel_driver_active" "ac_cv_func_libusb_kernel_driver_active" +if test "x$ac_cv_func_libusb_kernel_driver_active" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBUSB_KERNEL_DRIVER_ACTIVE 1 +_ACEOF + +fi +done + + for ac_func in libusb_set_auto_detach_kernel_driver +do : + ac_fn_c_check_func "$LINENO" "libusb_set_auto_detach_kernel_driver" "ac_cv_func_libusb_set_auto_detach_kernel_driver" +if test "x$ac_cv_func_libusb_set_auto_detach_kernel_driver" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBUSB_SET_AUTO_DETACH_KERNEL_DRIVER 1 +_ACEOF + +fi +done + + for ac_func in libusb_detach_kernel_driver +do : + ac_fn_c_check_func "$LINENO" "libusb_detach_kernel_driver" "ac_cv_func_libusb_detach_kernel_driver" +if test "x$ac_cv_func_libusb_detach_kernel_driver" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBUSB_DETACH_KERNEL_DRIVER 1 +_ACEOF + +fi +done + + for ac_func in libusb_detach_kernel_driver_np +do : + ac_fn_c_check_func "$LINENO" "libusb_detach_kernel_driver_np" "ac_cv_func_libusb_detach_kernel_driver_np" +if test "x$ac_cv_func_libusb_detach_kernel_driver_np" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBUSB_DETACH_KERNEL_DRIVER_NP 1 +_ACEOF + +fi +done + + fi + fi + else + nut_have_libusb=no + fi + + if test "${nut_have_libusb}" = "yes"; then : + + + case "${target_os}" in #( + solaris2.1*) : + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Solaris 10 / 11 specific configuration for usb drivers" >&5 +$as_echo_n "checking for Solaris 10 / 11 specific configuration for usb drivers... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing nanosleep" >&5 +$as_echo_n "checking for library containing nanosleep... " >&6; } +if ${ac_cv_search_nanosleep+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char nanosleep (); +int +main () +{ +return nanosleep (); + ; + return 0; +} +_ACEOF +for ac_lib in '' rt; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_nanosleep=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_nanosleep+:} false; then : + break +fi +done +if ${ac_cv_search_nanosleep+:} false; then : + +else + ac_cv_search_nanosleep=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_nanosleep" >&5 +$as_echo "$ac_cv_search_nanosleep" >&6; } +ac_res=$ac_cv_search_nanosleep +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + + LIBS="-R/usr/sfw/lib ${LIBS}" + +$as_echo "#define SUN_LIBUSB 1" >>confdefs.h + + SUN_LIBUSB=1 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${LIBS}" >&5 +$as_echo "${LIBS}" >&6; } + ;; #( + hpux11*) : + + CFLAGS="${CFLAGS} -lpthread" + + ;; #( + *) : + ;; +esac + +fi + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + if test "${nut_have_libusb}" = "yes"; then : + LIBUSB_CFLAGS="${CFLAGS}" LIBUSB_LIBS="${LIBS}" + +else + + case "${nut_with_usb}" in #( + no|auto) : + ;; #( + yes|1.0|0.1|libusb-1.0|libusb-0.1) : + as_fn_error $? "USB drivers requested, but libusb not found." "$LINENO" 5 + + ;; #( + *) : + ;; +esac + +fi + + if test "${nut_with_usb}" = "no"; then + if test -n "${nut_usb_lib}" && test "${nut_usb_lib}" != none ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: libusb was detected ${nut_usb_lib}, but a build without USB drivers was requested" >&5 +$as_echo "$as_me: libusb was detected ${nut_usb_lib}, but a build without USB drivers was requested" >&6;} + fi + nut_usb_lib="" + else + nut_with_usb="${nut_have_libusb}" fi + + if test "${nut_with_usb}" = "yes" && test "${nut_usb_lib}" = "(libusb-1.0)"; then : + +$as_echo "#define WITH_LIBUSB_1_0 1" >>confdefs.h + +else + +$as_echo "#define WITH_LIBUSB_1_0 0" >>confdefs.h + + +fi + + if test "${nut_with_usb}" = "yes" && test "${nut_usb_lib}" = "(libusb-0.1)" -o "${nut_usb_lib}" = "(libusb-0.1-config)"; then : + +$as_echo "#define WITH_LIBUSB_0_1 1" >>confdefs.h + +else + +$as_echo "#define WITH_LIBUSB_0_1 0" >>confdefs.h + + +fi + CFLAGS="${CFLAGS_ORIG}" LIBS="${LIBS_ORIG}" fi + # Check whether --with-snmp was given. if test "${with_snmp+set}" = set; then : withval=$with_snmp; nut_with_snmp="${withval}" @@ -8226,17 +14276,481 @@ fi if test -z "${nut_have_libnetsnmp_seen}"; then nut_have_libnetsnmp_seen=yes +if test -z "${nut_have_pkg_config_seen}"; then : + + nut_have_pkg_config_seen=yes + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG was already detected by autoconf" >&5 +$as_echo_n "checking whether usable PKG_CONFIG was already detected by autoconf... " >&6; } + if test -n "${PKG_CONFIG-}" && test x"${PKG_CONFIG-}" != x"false" && $PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${PKG_CONFIG}" >&5 +$as_echo "yes: ${PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + + if test x"${PKG_CONFIG-}" = x"false"; then : + have_PKG_CONFIG=yes + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_dummy_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $dummy_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_dummy_PKG_CONFIG="$dummy_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_dummy_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +dummy_PKG_CONFIG=$ac_cv_path_dummy_PKG_CONFIG +if test -n "$dummy_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dummy_PKG_CONFIG" >&5 +$as_echo "$dummy_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + +# Check whether --with-pkg-config was given. +if test "${with_pkg_config+set}" = set; then : + withval=$with_pkg_config; + case "${withval}" in + "") ;; + yes|no) + as_fn_error $? "invalid option --with(out)-pkg-config - see docs/configure.txt" "$LINENO" 5 + ;; + *) + dummy_PKG_CONFIG="${withval}" + ;; + esac + +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG is present in PATH or was set by caller" >&5 +$as_echo_n "checking whether usable PKG_CONFIG is present in PATH or was set by caller... " >&6; } + if test x"$dummy_PKG_CONFIG" = xno || test -z "$dummy_PKG_CONFIG"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + +else + if $dummy_PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${dummy_PKG_CONFIG}" >&5 +$as_echo "yes: ${dummy_PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + PKG_CONFIG="$dummy_PKG_CONFIG" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + +fi + +fi + + have_PKG_CONFIG_MACROS=no + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&6;} + dummy_RES=0 + + + if test "${dummy_RES}" = 0; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config module checker" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config module checker" >&6;} + + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pkg-config" >&5 +$as_echo_n "checking for pkg-config... " >&6; } + +if test -n "$dummy_PKG_CONFIG_CFLAGS"; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS="$dummy_PKG_CONFIG_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS=`$PKG_CONFIG --cflags "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$dummy_PKG_CONFIG_LIBS"; then + pkg_cv_dummy_PKG_CONFIG_LIBS="$dummy_PKG_CONFIG_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_LIBS=`$PKG_CONFIG --libs "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "pkg-config" 2>&1` + else + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "pkg-config" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$dummy_PKG_CONFIG_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (pkg-config) were not met: + +$dummy_PKG_CONFIG_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + dummy_PKG_CONFIG_CFLAGS=$pkg_cv_dummy_PKG_CONFIG_CFLAGS + dummy_PKG_CONFIG_LIBS=$pkg_cv_dummy_PKG_CONFIG_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + have_PKG_CONFIG_MACROS=yes +fi + + +fi + +fi + + if test x"$have_PKG_CONFIG" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&5 +$as_echo "$as_me: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&2;} + PKG_CONFIG="false" + +else + if test x"$have_PKG_CONFIG_MACROS" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&5 +$as_echo "$as_me: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&2;} + +fi + +fi + + +fi + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + CFLAGS_ORIG="${CFLAGS}" LIBS_ORIG="${LIBS}" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Net-SNMP version via net-snmp-config" >&5 -$as_echo_n "checking for Net-SNMP version via net-snmp-config... " >&6; } - SNMP_VERSION=`net-snmp-config --version 2>/dev/null` - if test "$?" != "0" -o -z "${SNMP_VERSION}"; then - SNMP_VERSION="none" - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${SNMP_VERSION} found" >&5 + + # The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void *" >&5 +$as_echo_n "checking size of void *... " >&6; } +if ${ac_cv_sizeof_void_p+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (void *))" "ac_cv_sizeof_void_p" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_void_p" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (void *) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_void_p=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_void_p" >&5 +$as_echo "$ac_cv_sizeof_void_p" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_VOID_P $ac_cv_sizeof_void_p +_ACEOF + + + NET_SNMP_CONFIG="none" + case "${ac_cv_sizeof_void_p}" in #( + 4) : + for ac_prog in net-snmp-config-32 net-snmp-config +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_NET_SNMP_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $NET_SNMP_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_NET_SNMP_CONFIG="$NET_SNMP_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_NET_SNMP_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +NET_SNMP_CONFIG=$ac_cv_path_NET_SNMP_CONFIG +if test -n "$NET_SNMP_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NET_SNMP_CONFIG" >&5 +$as_echo "$NET_SNMP_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$NET_SNMP_CONFIG" && break +done +test -n "$NET_SNMP_CONFIG" || NET_SNMP_CONFIG="none" + ;; #( + 8) : + for ac_prog in net-snmp-config-64 net-snmp-config +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_NET_SNMP_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $NET_SNMP_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_NET_SNMP_CONFIG="$NET_SNMP_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_NET_SNMP_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +NET_SNMP_CONFIG=$ac_cv_path_NET_SNMP_CONFIG +if test -n "$NET_SNMP_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NET_SNMP_CONFIG" >&5 +$as_echo "$NET_SNMP_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$NET_SNMP_CONFIG" && break +done +test -n "$NET_SNMP_CONFIG" || NET_SNMP_CONFIG="none" + ;; #( + *) : + for ac_prog in net-snmp-config +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_NET_SNMP_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $NET_SNMP_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_NET_SNMP_CONFIG="$NET_SNMP_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_NET_SNMP_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +NET_SNMP_CONFIG=$ac_cv_path_NET_SNMP_CONFIG +if test -n "$NET_SNMP_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NET_SNMP_CONFIG" >&5 +$as_echo "$NET_SNMP_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$NET_SNMP_CONFIG" && break +done +test -n "$NET_SNMP_CONFIG" || NET_SNMP_CONFIG="none" + + ;; +esac + + prefer_NET_SNMP_CONFIG=false + +# Check whether --with-net-snmp-config was given. +if test "${with_net_snmp_config+set}" = set; then : + withval=$with_net_snmp_config; + case "${withval}" in + ""|yes) prefer_NET_SNMP_CONFIG=true ;; + no) + prefer_NET_SNMP_CONFIG=false + ;; + *) + NET_SNMP_CONFIG="${withval}" + prefer_NET_SNMP_CONFIG=true + ;; + esac + +fi + + + if test x"$have_PKG_CONFIG" = xyes && ! "${prefer_NET_SNMP_CONFIG}" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Net-SNMP version via pkg-config" >&5 +$as_echo_n "checking for Net-SNMP version via pkg-config... " >&6; } + SNMP_VERSION="`$PKG_CONFIG --silence-errors --modversion netsnmp 2>/dev/null`" + if test "$?" = "0" -a -n "${SNMP_VERSION}" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${SNMP_VERSION} found" >&5 $as_echo "${SNMP_VERSION} found" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none found" >&5 +$as_echo "none found" >&6; } + prefer_NET_SNMP_CONFIG=true + fi + fi + + if test "$NET_SNMP_CONFIG" = none ; then + prefer_NET_SNMP_CONFIG=false + fi + + if "${prefer_NET_SNMP_CONFIG}" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Net-SNMP version via ${NET_SNMP_CONFIG}" >&5 +$as_echo_n "checking for Net-SNMP version via ${NET_SNMP_CONFIG}... " >&6; } + SNMP_VERSION="`${NET_SNMP_CONFIG} --version 2>/dev/null`" + if test "$?" != "0" -o -z "${SNMP_VERSION}"; then + SNMP_VERSION="none" + prefer_NET_SNMP_CONFIG=false + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${SNMP_VERSION} found" >&5 +$as_echo "${SNMP_VERSION} found" >&6; } + fi + + if test x"$have_PKG_CONFIG" != xyes && ! "${prefer_NET_SNMP_CONFIG}" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: did not find either net-snmp-config or pkg-config for net-snmp" >&5 +$as_echo "$as_me: WARNING: did not find either net-snmp-config or pkg-config for net-snmp" >&2;} + fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Net-SNMP cflags" >&5 $as_echo_n "checking for Net-SNMP cflags... " >&6; } @@ -8254,7 +14768,16 @@ if test "${with_snmp_includes+set}" = set; then : esac else - CFLAGS="`net-snmp-config --base-cflags 2>/dev/null`" + if "${prefer_NET_SNMP_CONFIG}"; then : + CFLAGS="`${NET_SNMP_CONFIG} --base-cflags 2>/dev/null`" +else + if test x"$have_PKG_CONFIG" = xyes; then : + CFLAGS="`$PKG_CONFIG --silence-errors --cflags netsnmp 2>/dev/null`" + +fi + +fi + fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${CFLAGS}" >&5 @@ -8276,7 +14799,17 @@ if test "${with_snmp_libs+set}" = set; then : esac else - LIBS="`net-snmp-config --libs 2>/dev/null`" + if "${prefer_NET_SNMP_CONFIG}"; then : + LIBS="`${NET_SNMP_CONFIG} --libs 2>/dev/null`" +else + if test x"$have_PKG_CONFIG" = xyes; then : + LIBS="`$PKG_CONFIG --silence-errors --libs netsnmp 2>/dev/null`" +else + LIBS="-lnetsnmp" +fi + +fi + fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${LIBS}" >&5 @@ -8311,16 +14844,476 @@ fi done - if test "${nut_have_libnetsnmp}" = "yes"; then + if test "${nut_have_libnetsnmp}" = "yes"; then : + LIBNETSNMP_CFLAGS="${CFLAGS}" LIBNETSNMP_LIBS="${LIBS}" - fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for defined usmAESPrivProtocol" >&5 +$as_echo_n "checking for defined usmAESPrivProtocol... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +oid * pProto = usmAESPrivProtocol; + +int +main () +{ + + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol 1 +_ACEOF + + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol 0 +_ACEOF + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for defined usmAES128PrivProtocol" >&5 +$as_echo_n "checking for defined usmAES128PrivProtocol... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +oid * pProto = usmAES128PrivProtocol; + +int +main () +{ + + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_usmAES128PrivProtocol 1 +_ACEOF + + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_usmAES128PrivProtocol 0 +_ACEOF + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for defined usmDESPrivProtocol" >&5 +$as_echo_n "checking for defined usmDESPrivProtocol... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +oid * pProto = usmDESPrivProtocol; +#ifdef NETSNMP_DISABLE_DES +#error "NETSNMP_DISABLE_DES is defined" +#endif + +int +main () +{ + + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_usmDESPrivProtocol 1 +_ACEOF + + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_usmDESPrivProtocol 0 +_ACEOF + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for defined usmHMAC256SHA384AuthProtocol" >&5 +$as_echo_n "checking for defined usmHMAC256SHA384AuthProtocol... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +oid * pProto = usmHMAC256SHA384AuthProtocol; +#ifndef HAVE_EVP_SHA384 +#error "HAVE_EVP_SHA384 is NOT defined" +#endif + +int +main () +{ + + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_usmHMAC256SHA384AuthProtocol 1 +_ACEOF + + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_usmHMAC256SHA384AuthProtocol 0 +_ACEOF + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for defined usmHMAC384SHA512AuthProtocol" >&5 +$as_echo_n "checking for defined usmHMAC384SHA512AuthProtocol... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +oid * pProto = usmHMAC384SHA512AuthProtocol; +#ifndef HAVE_EVP_SHA384 +#error "HAVE_EVP_SHA384 is NOT defined" +#endif + +int +main () +{ + + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_usmHMAC384SHA512AuthProtocol 1 +_ACEOF + + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_usmHMAC384SHA512AuthProtocol 0 +_ACEOF + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for defined usmHMAC192SHA256AuthProtocol" >&5 +$as_echo_n "checking for defined usmHMAC192SHA256AuthProtocol... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +oid * pProto = usmHMAC192SHA256AuthProtocol; +#ifndef HAVE_EVP_SHA224 +#error "HAVE_EVP_SHA224 is NOT defined" +#endif + +int +main () +{ + + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_usmHMAC192SHA256AuthProtocol 1 +_ACEOF + + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_usmHMAC192SHA256AuthProtocol 0 +_ACEOF + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for defined usmAES192PrivProtocol" >&5 +$as_echo_n "checking for defined usmAES192PrivProtocol... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +oid * pProto = usmAES192PrivProtocol; +#ifndef NETSNMP_DRAFT_BLUMENTHAL_AES_04 +#error "NETSNMP_DRAFT_BLUMENTHAL_AES_04 is NOT defined" +#endif + +int +main () +{ + + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_usmAES192PrivProtocol 1 +_ACEOF + + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_usmAES192PrivProtocol 0 +_ACEOF + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for defined usmAES256PrivProtocol" >&5 +$as_echo_n "checking for defined usmAES256PrivProtocol... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +oid * pProto = usmAES256PrivProtocol; +#ifndef NETSNMP_DRAFT_BLUMENTHAL_AES_04 +#error "NETSNMP_DRAFT_BLUMENTHAL_AES_04 is NOT defined" +#endif + +int +main () +{ + + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_usmAES256PrivProtocol 1 +_ACEOF + + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_usmAES256PrivProtocol 0 +_ACEOF + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for defined usmHMACMD5AuthProtocol" >&5 +$as_echo_n "checking for defined usmHMACMD5AuthProtocol... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +oid * pProto = usmHMACMD5AuthProtocol; +#ifdef NETSNMP_DISABLE_MD5 +#error "NETSNMP_DISABLE_MD5 is defined" +#endif + +int +main () +{ + + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_usmHMACMD5AuthProtocol 1 +_ACEOF + + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_usmHMACMD5AuthProtocol 0 +_ACEOF + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for defined usmHMACSHA1AuthProtocol" >&5 +$as_echo_n "checking for defined usmHMACSHA1AuthProtocol... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +oid * pProto = usmHMACSHA1AuthProtocol; + +int +main () +{ + + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_usmHMACSHA1AuthProtocol 1 +_ACEOF + + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_usmHMACSHA1AuthProtocol 0 +_ACEOF + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for defined NETSNMP_DRAFT_BLUMENTHAL_AES_04" >&5 +$as_echo_n "checking for defined NETSNMP_DRAFT_BLUMENTHAL_AES_04... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +int num = NETSNMP_DRAFT_BLUMENTHAL_AES_04 + 1; /* if defined, NETSNMP_DRAFT_BLUMENTHAL_AES_04 is 1 */ + +int +main () +{ + + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_DRAFT_BLUMENTHAL_AES_04 1 +_ACEOF + + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +cat >>confdefs.h <<_ACEOF +#define NUT_HAVE_LIBNETSNMP_DRAFT_BLUMENTHAL_AES_04 0 +_ACEOF + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + CFLAGS="${CFLAGS_ORIG}" LIBS="${LIBS_ORIG}" fi + # Check whether --with-neon was given. if test "${with_neon+set}" = set; then : withval=$with_neon; nut_with_neon="${withval}" @@ -8334,18 +15327,260 @@ fi if test -z "${nut_have_neon_seen}"; then nut_have_neon_seen=yes +if test -z "${nut_have_pkg_config_seen}"; then : + + nut_have_pkg_config_seen=yes + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG was already detected by autoconf" >&5 +$as_echo_n "checking whether usable PKG_CONFIG was already detected by autoconf... " >&6; } + if test -n "${PKG_CONFIG-}" && test x"${PKG_CONFIG-}" != x"false" && $PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${PKG_CONFIG}" >&5 +$as_echo "yes: ${PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + + if test x"${PKG_CONFIG-}" = x"false"; then : + have_PKG_CONFIG=yes + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_dummy_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $dummy_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_dummy_PKG_CONFIG="$dummy_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_dummy_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +dummy_PKG_CONFIG=$ac_cv_path_dummy_PKG_CONFIG +if test -n "$dummy_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dummy_PKG_CONFIG" >&5 +$as_echo "$dummy_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + +# Check whether --with-pkg-config was given. +if test "${with_pkg_config+set}" = set; then : + withval=$with_pkg_config; + case "${withval}" in + "") ;; + yes|no) + as_fn_error $? "invalid option --with(out)-pkg-config - see docs/configure.txt" "$LINENO" 5 + ;; + *) + dummy_PKG_CONFIG="${withval}" + ;; + esac + +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG is present in PATH or was set by caller" >&5 +$as_echo_n "checking whether usable PKG_CONFIG is present in PATH or was set by caller... " >&6; } + if test x"$dummy_PKG_CONFIG" = xno || test -z "$dummy_PKG_CONFIG"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + +else + if $dummy_PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${dummy_PKG_CONFIG}" >&5 +$as_echo "yes: ${dummy_PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + PKG_CONFIG="$dummy_PKG_CONFIG" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + +fi + +fi + + have_PKG_CONFIG_MACROS=no + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&6;} + dummy_RES=0 + + + if test "${dummy_RES}" = 0; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config module checker" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config module checker" >&6;} + + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pkg-config" >&5 +$as_echo_n "checking for pkg-config... " >&6; } + +if test -n "$dummy_PKG_CONFIG_CFLAGS"; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS="$dummy_PKG_CONFIG_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS=`$PKG_CONFIG --cflags "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$dummy_PKG_CONFIG_LIBS"; then + pkg_cv_dummy_PKG_CONFIG_LIBS="$dummy_PKG_CONFIG_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_LIBS=`$PKG_CONFIG --libs "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "pkg-config" 2>&1` + else + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "pkg-config" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$dummy_PKG_CONFIG_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (pkg-config) were not met: + +$dummy_PKG_CONFIG_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + dummy_PKG_CONFIG_CFLAGS=$pkg_cv_dummy_PKG_CONFIG_CFLAGS + dummy_PKG_CONFIG_LIBS=$pkg_cv_dummy_PKG_CONFIG_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + have_PKG_CONFIG_MACROS=yes +fi + + +fi + +fi + + if test x"$have_PKG_CONFIG" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&5 +$as_echo "$as_me: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&2;} + PKG_CONFIG="false" + +else + if test x"$have_PKG_CONFIG_MACROS" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&5 +$as_echo "$as_me: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&2;} + +fi + +fi + + +fi + CFLAGS_ORIG="${CFLAGS}" LIBS_ORIG="${LIBS}" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libneon version via pkg-config (0.25.0 minimum required)" >&5 + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libneon version via pkg-config (0.25.0 minimum required)" >&5 $as_echo_n "checking for libneon version via pkg-config (0.25.0 minimum required)... " >&6; } - NEON_VERSION="`pkg-config --silence-errors --modversion neon 2>/dev/null`" - if test "$?" != "0" -o -z "${NEON_VERSION}"; then - NEON_VERSION="none" - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${NEON_VERSION} found" >&5 + NEON_VERSION="`$PKG_CONFIG --silence-errors --modversion neon 2>/dev/null`" + if test "$?" != "0" -o -z "${NEON_VERSION}"; then + NEON_VERSION="none" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${NEON_VERSION} found" >&5 $as_echo "${NEON_VERSION} found" >&6; } +else + NEON_VERSION="none" + { $as_echo "$as_me:${as_lineno-$LINENO}: can not check libneon settings via pkg-config" >&5 +$as_echo "$as_me: can not check libneon settings via pkg-config" >&6;} + + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libneon cflags" >&5 $as_echo_n "checking for libneon cflags... " >&6; } @@ -8362,7 +15597,14 @@ if test "${with_neon_includes+set}" = set; then : esac else - CFLAGS="`pkg-config --silence-errors --cflags neon 2>/dev/null`" + + if test x"$have_PKG_CONFIG" = xyes; then : + CFLAGS="`$PKG_CONFIG --silence-errors --cflags neon 2>/dev/null`" || CFLAGS="-I/usr/include/neon -I/usr/local/include/neon" +else + CFLAGS="-I/usr/include/neon -I/usr/local/include/neon" + +fi + fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${CFLAGS}" >&5 @@ -8384,7 +15626,14 @@ if test "${with_neon_libs+set}" = set; then : esac else - LIBS="`pkg-config --silence-errors --libs neon 2>/dev/null`" + + if test x"$have_PKG_CONFIG" = xyes; then : + LIBS="`$PKG_CONFIG --silence-errors --libs neon 2>/dev/null`" || LIBS="-lneon" +else + LIBS="-lneon" + +fi + fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${LIBS}" >&5 @@ -8441,6 +15690,7 @@ done fi + # Check whether --with-powerman was given. if test "${with_powerman+set}" = set; then : withval=$with_powerman; nut_with_powerman="${withval}" @@ -8454,9 +15704,271 @@ fi if test -z "${nut_have_libpowerman_seen}"; then nut_have_libpowerman_seen=yes +if test -z "${nut_have_pkg_config_seen}"; then : + + nut_have_pkg_config_seen=yes + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG was already detected by autoconf" >&5 +$as_echo_n "checking whether usable PKG_CONFIG was already detected by autoconf... " >&6; } + if test -n "${PKG_CONFIG-}" && test x"${PKG_CONFIG-}" != x"false" && $PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${PKG_CONFIG}" >&5 +$as_echo "yes: ${PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + + if test x"${PKG_CONFIG-}" = x"false"; then : + have_PKG_CONFIG=yes + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_dummy_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $dummy_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_dummy_PKG_CONFIG="$dummy_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_dummy_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +dummy_PKG_CONFIG=$ac_cv_path_dummy_PKG_CONFIG +if test -n "$dummy_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dummy_PKG_CONFIG" >&5 +$as_echo "$dummy_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + +# Check whether --with-pkg-config was given. +if test "${with_pkg_config+set}" = set; then : + withval=$with_pkg_config; + case "${withval}" in + "") ;; + yes|no) + as_fn_error $? "invalid option --with(out)-pkg-config - see docs/configure.txt" "$LINENO" 5 + ;; + *) + dummy_PKG_CONFIG="${withval}" + ;; + esac + +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG is present in PATH or was set by caller" >&5 +$as_echo_n "checking whether usable PKG_CONFIG is present in PATH or was set by caller... " >&6; } + if test x"$dummy_PKG_CONFIG" = xno || test -z "$dummy_PKG_CONFIG"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + +else + if $dummy_PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${dummy_PKG_CONFIG}" >&5 +$as_echo "yes: ${dummy_PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + PKG_CONFIG="$dummy_PKG_CONFIG" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + +fi + +fi + + have_PKG_CONFIG_MACROS=no + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&6;} + dummy_RES=0 + + + if test "${dummy_RES}" = 0; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config module checker" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config module checker" >&6;} + + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pkg-config" >&5 +$as_echo_n "checking for pkg-config... " >&6; } + +if test -n "$dummy_PKG_CONFIG_CFLAGS"; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS="$dummy_PKG_CONFIG_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS=`$PKG_CONFIG --cflags "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$dummy_PKG_CONFIG_LIBS"; then + pkg_cv_dummy_PKG_CONFIG_LIBS="$dummy_PKG_CONFIG_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_LIBS=`$PKG_CONFIG --libs "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "pkg-config" 2>&1` + else + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "pkg-config" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$dummy_PKG_CONFIG_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (pkg-config) were not met: + +$dummy_PKG_CONFIG_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + dummy_PKG_CONFIG_CFLAGS=$pkg_cv_dummy_PKG_CONFIG_CFLAGS + dummy_PKG_CONFIG_LIBS=$pkg_cv_dummy_PKG_CONFIG_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + have_PKG_CONFIG_MACROS=yes +fi + + +fi + +fi + + if test x"$have_PKG_CONFIG" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&5 +$as_echo "$as_me: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&2;} + PKG_CONFIG="false" + +else + if test x"$have_PKG_CONFIG_MACROS" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&5 +$as_echo "$as_me: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&2;} + +fi + +fi + + +fi + CFLAGS_ORIG="${CFLAGS}" LIBS_ORIG="${LIBS}" + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LLNC libpowerman version via pkg-config" >&5 +$as_echo_n "checking for LLNC libpowerman version via pkg-config... " >&6; } + POWERMAN_VERSION="`$PKG_CONFIG --silence-errors --modversion libpowerman 2>/dev/null`" + if test "$?" != "0" ; then # -o -z "${POWERMAN_VERSION}"; then + POWERMAN_VERSION="none" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: '${POWERMAN_VERSION}' found" >&5 +$as_echo "'${POWERMAN_VERSION}' found" >&6; } + +else + POWERMAN_VERSION="none" + { $as_echo "$as_me:${as_lineno-$LINENO}: can not check LLNC libpowerman settings via pkg-config" >&5 +$as_echo "$as_me: can not check LLNC libpowerman settings via pkg-config" >&6;} + + +fi + + if test x"$POWERMAN_VERSION" != xnone; then : + CFLAGS="`$PKG_CONFIG --silence-errors --cflags libpowerman 2>/dev/null`" + LIBS="`$PKG_CONFIG --silence-errors --libs libpowerman 2>/dev/null`" + +else + CFLAGS="" + LIBS="" + + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libpowerman cflags" >&5 $as_echo_n "checking for libpowerman cflags... " >&6; } @@ -8472,8 +15984,6 @@ if test "${with_powerman_includes+set}" = set; then : ;; esac -else - CFLAGS="`pkg-config --silence-errors --cflags libpowerman 2>/dev/null`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${CFLAGS}" >&5 @@ -8494,8 +16004,6 @@ if test "${with_powerman_libs+set}" = set; then : ;; esac -else - LIBS="`pkg-config --silence-errors --libs libpowerman 2>/dev/null`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${LIBS}" >&5 @@ -8524,8 +16032,34 @@ if test "x$ac_cv_func_pm_connect" = xyes; then : #define HAVE_PM_CONNECT 1 _ACEOF +else + + if test "${nut_have_libpowerman}" = "yes" && test "$POWERMAN_VERSION" = "none" && test -z "$LIBS"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libpowerman is just present in path" >&5 +$as_echo_n "checking if libpowerman is just present in path... " >&6; } + LIBS="-L/usr/lib -L/usr/local/lib -lpowerman" + unset ac_cv_func_pm_connect || true + for ac_func in pm_connect +do : + ac_fn_c_check_func "$LINENO" "pm_connect" "ac_cv_func_pm_connect" +if test "x$ac_cv_func_pm_connect" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_PM_CONNECT 1 +_ACEOF + else nut_have_libpowerman=no +fi +done + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${nut_have_libpowerman}" >&5 +$as_echo "${nut_have_libpowerman}" >&6; } + +else + nut_have_libpowerman=no + +fi + fi done @@ -8541,30 +16075,3220 @@ done fi -if test -z "${nut_have_avahi_seen}"; then - nut_have_avahi_seen=yes + +# Check whether --with-modbus was given. +if test "${with_modbus+set}" = set; then : + withval=$with_modbus; nut_with_modbus="${withval}" +else + nut_with_modbus="auto" + +fi + + + +if test -z "${nut_have_libmodbus_seen}"; then + nut_have_libmodbus_seen=yes CFLAGS_ORIG="${CFLAGS}" LIBS_ORIG="${LIBS}" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for avahi-core version via pkg-config (0.6.30 minimum required)" >&5 +if test -z "${nut_have_pkg_config_seen}"; then : + + nut_have_pkg_config_seen=yes + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG was already detected by autoconf" >&5 +$as_echo_n "checking whether usable PKG_CONFIG was already detected by autoconf... " >&6; } + if test -n "${PKG_CONFIG-}" && test x"${PKG_CONFIG-}" != x"false" && $PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${PKG_CONFIG}" >&5 +$as_echo "yes: ${PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + + if test x"${PKG_CONFIG-}" = x"false"; then : + have_PKG_CONFIG=yes + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_dummy_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $dummy_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_dummy_PKG_CONFIG="$dummy_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_dummy_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +dummy_PKG_CONFIG=$ac_cv_path_dummy_PKG_CONFIG +if test -n "$dummy_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dummy_PKG_CONFIG" >&5 +$as_echo "$dummy_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + +# Check whether --with-pkg-config was given. +if test "${with_pkg_config+set}" = set; then : + withval=$with_pkg_config; + case "${withval}" in + "") ;; + yes|no) + as_fn_error $? "invalid option --with(out)-pkg-config - see docs/configure.txt" "$LINENO" 5 + ;; + *) + dummy_PKG_CONFIG="${withval}" + ;; + esac + +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG is present in PATH or was set by caller" >&5 +$as_echo_n "checking whether usable PKG_CONFIG is present in PATH or was set by caller... " >&6; } + if test x"$dummy_PKG_CONFIG" = xno || test -z "$dummy_PKG_CONFIG"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + +else + if $dummy_PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${dummy_PKG_CONFIG}" >&5 +$as_echo "yes: ${dummy_PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + PKG_CONFIG="$dummy_PKG_CONFIG" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + +fi + +fi + + have_PKG_CONFIG_MACROS=no + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&6;} + dummy_RES=0 + + + if test "${dummy_RES}" = 0; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config module checker" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config module checker" >&6;} + + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pkg-config" >&5 +$as_echo_n "checking for pkg-config... " >&6; } + +if test -n "$dummy_PKG_CONFIG_CFLAGS"; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS="$dummy_PKG_CONFIG_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS=`$PKG_CONFIG --cflags "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$dummy_PKG_CONFIG_LIBS"; then + pkg_cv_dummy_PKG_CONFIG_LIBS="$dummy_PKG_CONFIG_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_LIBS=`$PKG_CONFIG --libs "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "pkg-config" 2>&1` + else + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "pkg-config" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$dummy_PKG_CONFIG_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (pkg-config) were not met: + +$dummy_PKG_CONFIG_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + dummy_PKG_CONFIG_CFLAGS=$pkg_cv_dummy_PKG_CONFIG_CFLAGS + dummy_PKG_CONFIG_LIBS=$pkg_cv_dummy_PKG_CONFIG_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + have_PKG_CONFIG_MACROS=yes +fi + + +fi + +fi + + if test x"$have_PKG_CONFIG" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&5 +$as_echo "$as_me: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&2;} + PKG_CONFIG="false" + +else + if test x"$have_PKG_CONFIG_MACROS" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&5 +$as_echo "$as_me: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&2;} + +fi + +fi + + +fi + + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libmodbus version via pkg-config" >&5 +$as_echo_n "checking for libmodbus version via pkg-config... " >&6; } + LIBMODBUS_VERSION="`$PKG_CONFIG --silence-errors --modversion libmodbus 2>/dev/null`" + if test "$?" != "0" -o -z "${LIBMODBUS_VERSION}"; then + LIBMODBUS_VERSION="none" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${LIBMODBUS_VERSION} found" >&5 +$as_echo "${LIBMODBUS_VERSION} found" >&6; } + +else + LIBMODBUS_VERSION="none" + { $as_echo "$as_me:${as_lineno-$LINENO}: can not check libmodbus settings via pkg-config" >&5 +$as_echo "$as_me: can not check libmodbus settings via pkg-config" >&6;} + + +fi + + if test x"$LIBMODBUS_VERSION" != xnone; then : + CFLAGS="`$PKG_CONFIG --silence-errors --cflags libmodbus 2>/dev/null`" + LIBS="`$PKG_CONFIG --silence-errors --libs libmodbus 2>/dev/null`" + +else + CFLAGS="-I/usr/include/modbus" + LIBS="-lmodbus" + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libmodbus cflags" >&5 +$as_echo_n "checking for libmodbus cflags... " >&6; } + +# Check whether --with-modbus-includes was given. +if test "${with_modbus_includes+set}" = set; then : + withval=$with_modbus_includes; + case "${withval}" in + yes|no) + as_fn_error $? "invalid option --with(out)-modbus-includes - see docs/configure.txt" "$LINENO" 5 + ;; + *) + CFLAGS="${withval}" + ;; + esac + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${CFLAGS}" >&5 +$as_echo "${CFLAGS}" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libmodbus ldflags" >&5 +$as_echo_n "checking for libmodbus ldflags... " >&6; } + +# Check whether --with-modbus-libs was given. +if test "${with_modbus_libs+set}" = set; then : + withval=$with_modbus_libs; + case "${withval}" in + yes|no) + as_fn_error $? "invalid option --with(out)-modbus-libs - see docs/configure.txt" "$LINENO" 5 + ;; + *) + LIBS="${withval}" + ;; + esac + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${LIBS}" >&5 +$as_echo "${LIBS}" >&6; } + + for ac_header in modbus.h +do : + ac_fn_c_check_header_compile "$LINENO" "modbus.h" "ac_cv_header_modbus_h" "$ac_includes_default +" +if test "x$ac_cv_header_modbus_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_MODBUS_H 1 +_ACEOF + nut_have_libmodbus=yes +else + nut_have_libmodbus=no +fi + +done + + for ac_func in modbus_new_rtu +do : + ac_fn_c_check_func "$LINENO" "modbus_new_rtu" "ac_cv_func_modbus_new_rtu" +if test "x$ac_cv_func_modbus_new_rtu" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_MODBUS_NEW_RTU 1 +_ACEOF + +else + nut_have_libmodbus=no +fi +done + + for ac_func in modbus_new_tcp +do : + ac_fn_c_check_func "$LINENO" "modbus_new_tcp" "ac_cv_func_modbus_new_tcp" +if test "x$ac_cv_func_modbus_new_tcp" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_MODBUS_NEW_TCP 1 +_ACEOF + +else + nut_have_libmodbus=no +fi +done + + for ac_func in modbus_set_byte_timeout +do : + ac_fn_c_check_func "$LINENO" "modbus_set_byte_timeout" "ac_cv_func_modbus_set_byte_timeout" +if test "x$ac_cv_func_modbus_set_byte_timeout" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_MODBUS_SET_BYTE_TIMEOUT 1 +_ACEOF + +else + nut_have_libmodbus=no +fi +done + + for ac_func in modbus_set_response_timeout +do : + ac_fn_c_check_func "$LINENO" "modbus_set_response_timeout" "ac_cv_func_modbus_set_response_timeout" +if test "x$ac_cv_func_modbus_set_response_timeout" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_MODBUS_SET_RESPONSE_TIMEOUT 1 +_ACEOF + +else + nut_have_libmodbus=no +fi +done + + + if test x"$nut_have_libmodbus" = xyes; then : + +if test -z "${nut_have_ax_c_pragmas_seen}"; then + nut_have_ax_c_pragmas_seen="yes" + + CFLAGS_SAVED="${CFLAGS}" + CXXFLAGS_SAVED="${CXXFLAGS}" + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + if test "${CLANG}" = "yes"; then : + CFLAGS="${CFLAGS_SAVED} -Werror=pragmas -Werror=unknown-pragmas -Werror=unknown-warning-option" + CXXFLAGS="${CXXFLAGS_SAVED} -Werror=pragmas -Werror=unknown-pragmas -Werror=unknown-warning-option" +else + if test "${GCC}" = "yes"; then : + CFLAGS="${CFLAGS_SAVED} -Wall -Wextra -Werror" + CXXFLAGS="${CXXFLAGS_SAVED} -Wall -Wextra -Werror" +else + CFLAGS="${CFLAGS_SAVED} -Wall -Wextra -Werror" + CXXFLAGS="${CXXFLAGS_SAVED} -Wall -Wextra -Werror" +fi + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic push and pop (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic push and pop (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_push_pop_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#pragma GCC diagnostic push +#pragma GCC diagnostic pop + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_push_pop_besidefunc=yes +else + ax_cv__pragma__gcc__diags_push_pop_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_push_pop_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_push_pop_besidefunc" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma clang diagnostic push and pop (outside functions)" >&5 +$as_echo_n "checking for pragma clang diagnostic push and pop (outside functions)... " >&6; } +if ${ax_cv__pragma__clang__diags_push_pop_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef __clang__ +#endif +#pragma clang diagnostic push +#pragma clang diagnostic pop + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__clang__diags_push_pop_besidefunc=yes +else + ax_cv__pragma__clang__diags_push_pop_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__clang__diags_push_pop_besidefunc" >&5 +$as_echo "$ax_cv__pragma__clang__diags_push_pop_besidefunc" >&6; } + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic push and pop (inside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic push and pop (inside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_push_pop_insidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic push +#pragma GCC diagnostic pop +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_push_pop_insidefunc=yes +else + ax_cv__pragma__gcc__diags_push_pop_insidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_push_pop_insidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_push_pop_insidefunc" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma clang diagnostic push and pop (inside functions)" >&5 +$as_echo_n "checking for pragma clang diagnostic push and pop (inside functions)... " >&6; } +if ${ax_cv__pragma__clang__diags_push_pop_insidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#ifdef __clang__ +#endif +#pragma clang diagnostic push +#pragma clang diagnostic pop +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__clang__diags_push_pop_insidefunc=yes +else + ax_cv__pragma__clang__diags_push_pop_insidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__clang__diags_push_pop_insidefunc" >&5 +$as_echo "$ax_cv__pragma__clang__diags_push_pop_insidefunc" >&6; } + + if test "$ax_cv__pragma__gcc__diags_push_pop_insidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_INSIDEFUNC 1" >>confdefs.h + + +fi + + if test "$ax_cv__pragma__gcc__diags_push_pop_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC 1" >>confdefs.h + + +fi + + if test "$ax_cv__pragma__gcc__diags_push_pop_besidefunc" = "yes" && test "$ax_cv__pragma__gcc__diags_push_pop_insidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP 1" >>confdefs.h + + +fi + + if test "$ax_cv__pragma__clang__diags_push_pop_insidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_CLANG_DIAGNOSTIC_PUSH_POP_INSIDEFUNC 1" >>confdefs.h + + +fi + + if test "$ax_cv__pragma__clang__diags_push_pop_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_CLANG_DIAGNOSTIC_PUSH_POP_BESIDEFUNC 1" >>confdefs.h + + +fi + + if test "$ax_cv__pragma__clang__diags_push_pop_besidefunc" = "yes" && test "$ax_cv__pragma__clang__diags_push_pop_insidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_CLANG_DIAGNOSTIC_PUSH_POP 1" >>confdefs.h + + +fi + + if test "${CLANG}" = "yes"; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma CLANG diagnostic ignored \"-Wunreachable-code-return\"" >&5 +$as_echo_n "checking for pragma CLANG diagnostic ignored \"-Wunreachable-code-return\"... " >&6; } +if ${ax_cv__pragma__clang__diags_ignored_unreachable_code_return+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma clang diagnostic ignored "-Wunreachable-code-return" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__clang__diags_ignored_unreachable_code_return=yes +else + ax_cv__pragma__clang__diags_ignored_unreachable_code_return=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__clang__diags_ignored_unreachable_code_return" >&5 +$as_echo "$ax_cv__pragma__clang__diags_ignored_unreachable_code_return" >&6; } + if test "$ax_cv__pragma__clang__diags_ignored_unreachable_code_return" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_CLANG_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma CLANG diagnostic ignored \"-Wunreachable-code-return\" (outside functions)" >&5 +$as_echo_n "checking for pragma CLANG diagnostic ignored \"-Wunreachable-code-return\" (outside functions)... " >&6; } +if ${ax_cv__pragma__clang__diags_ignored_unreachable_code_return_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma clang diagnostic ignored "-Wunreachable-code-return" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__clang__diags_ignored_unreachable_code_return_besidefunc=yes +else + ax_cv__pragma__clang__diags_ignored_unreachable_code_return_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__clang__diags_ignored_unreachable_code_return_besidefunc" >&5 +$as_echo "$ax_cv__pragma__clang__diags_ignored_unreachable_code_return_besidefunc" >&6; } + if test "$ax_cv__pragma__clang__diags_ignored_unreachable_code_return_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_CLANG_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN_BESIDEFUNC 1" >>confdefs.h + + +fi + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wunused-function\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wunused-function\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_unused_function+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wunused-function" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_unused_function=yes +else + ax_cv__pragma__gcc__diags_ignored_unused_function=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_unused_function" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_unused_function" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_unused_function" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNUSED_FUNCTION 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wformat-nonliteral\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wformat-nonliteral\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_format_nonliteral+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_format_nonliteral=yes +else + ax_cv__pragma__gcc__diags_ignored_format_nonliteral=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_format_nonliteral" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_format_nonliteral" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_format_nonliteral" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wformat-nonliteral\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wformat-nonliteral\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_format_nonliteral_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_format_nonliteral_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_format_nonliteral_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_format_nonliteral_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_format_nonliteral_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_format_nonliteral_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wformat-security\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wformat-security\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_format_security+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wformat-security" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_format_security=yes +else + ax_cv__pragma__gcc__diags_ignored_format_security=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_format_security" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_format_security" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_format_security" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wformat-security\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wformat-security\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_format_security_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wformat-security" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_format_security_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_format_security_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_format_security_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_format_security_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_format_security_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wformat-truncation\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wformat-truncation\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_format_truncation+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wformat-truncation" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_format_truncation=yes +else + ax_cv__pragma__gcc__diags_ignored_format_truncation=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_format_truncation" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_format_truncation" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_format_truncation" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wformat-truncation\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wformat-truncation\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_format_truncation_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wformat-truncation" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_format_truncation_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_format_truncation_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_format_truncation_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_format_truncation_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_format_truncation_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wstringop-truncation\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wstringop-truncation\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_stringop_truncation+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wstringop-truncation" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_stringop_truncation=yes +else + ax_cv__pragma__gcc__diags_ignored_stringop_truncation=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_stringop_truncation" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_stringop_truncation" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_stringop_truncation" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRINGOP_TRUNCATION 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wstringop-truncation\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wstringop-truncation\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_stringop_truncation_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wstringop-truncation" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_stringop_truncation_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_stringop_truncation_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_stringop_truncation_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_stringop_truncation_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_stringop_truncation_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRINGOP_TRUNCATION_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wtype-limits\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wtype-limits\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_type_limits+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wtype-limits" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_type_limits=yes +else + ax_cv__pragma__gcc__diags_ignored_type_limits=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_type_limits" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_type_limits" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_type_limits" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wtype-limits\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wtype-limits\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_type_limits_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wtype-limits" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_type_limits_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_type_limits_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_type_limits_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_type_limits_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_type_limits_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Warray-bounds\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Warray-bounds\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_array_bounds+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Warray-bounds" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_array_bounds=yes +else + ax_cv__pragma__gcc__diags_ignored_array_bounds=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_array_bounds" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_array_bounds" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_array_bounds" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ARRAY_BOUNDS 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Warray-bounds\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Warray-bounds\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_array_bounds_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Warray-bounds" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_array_bounds_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_array_bounds_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_array_bounds_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_array_bounds_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_array_bounds_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ARRAY_BOUNDS_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wtautological-type-limit-compare\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wtautological-type-limit-compare\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wtautological-type-limit-compare" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare=yes +else + ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_TYPE_LIMIT_COMPARE 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wtautological-type-limit-compare\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wtautological-type-limit-compare\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wtautological-type-limit-compare" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_TYPE_LIMIT_COMPARE_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wtautological-constant-out-of-range-compare\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wtautological-constant-out-of-range-compare\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare=yes +else + ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wtautological-constant-out-of-range-compare\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wtautological-constant-out-of-range-compare\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wtautological-unsigned-zero-compare\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wtautological-unsigned-zero-compare\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wtautological-unsigned-zero-compare" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare=yes +else + ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_UNSIGNED_ZERO_COMPARE 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wtautological-unsigned-zero-compare\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wtautological-unsigned-zero-compare\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wtautological-unsigned-zero-compare" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_UNSIGNED_ZERO_COMPARE_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wtautological-compare\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wtautological-compare\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_tautological_compare+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wtautological-compare" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_tautological_compare=yes +else + ax_cv__pragma__gcc__diags_ignored_tautological_compare=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_tautological_compare" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_tautological_compare" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_tautological_compare" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_COMPARE 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wtautological-compare\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wtautological-compare\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_tautological_compare_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wtautological-compare" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_tautological_compare_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_tautological_compare_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_tautological_compare_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_tautological_compare_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_tautological_compare_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_COMPARE_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wsign-compare\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wsign-compare\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_sign_compare+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wsign-compare" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_sign_compare=yes +else + ax_cv__pragma__gcc__diags_ignored_sign_compare=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_sign_compare" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_sign_compare" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_sign_compare" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_COMPARE 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wsign-compare\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wsign-compare\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_sign_compare_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wsign-compare" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_sign_compare_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_sign_compare_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_sign_compare_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_sign_compare_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_sign_compare_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_COMPARE_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wsign-conversion\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wsign-conversion\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_sign_conversion+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wsign-conversion" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_sign_conversion=yes +else + ax_cv__pragma__gcc__diags_ignored_sign_conversion=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_sign_conversion" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_sign_conversion" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_sign_conversion" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_CONVERSION 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wsign-conversion\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wsign-conversion\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_sign_conversion_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wsign-conversion" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_sign_conversion_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_sign_conversion_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_sign_conversion_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_sign_conversion_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_sign_conversion_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_CONVERSION_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wunreachable-code-break\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wunreachable-code-break\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_unreachable_code_break+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wunreachable-code-break" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_unreachable_code_break=yes +else + ax_cv__pragma__gcc__diags_ignored_unreachable_code_break=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_unreachable_code_break" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_break" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_break" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_BREAK 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wunreachable-code-break\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wunreachable-code-break\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_unreachable_code_break_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wunreachable-code-break" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_unreachable_code_break_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_unreachable_code_break_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_unreachable_code_break_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_break_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_break_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_BREAK_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wunreachable-code-return\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wunreachable-code-return\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_unreachable_code_return+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wunreachable-code-return" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_unreachable_code_return=yes +else + ax_cv__pragma__gcc__diags_ignored_unreachable_code_return=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_unreachable_code_return" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_return" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_return" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wunreachable-code-return\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wunreachable-code-return\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_unreachable_code_return_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wunreachable-code-return" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_unreachable_code_return_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_unreachable_code_return_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_unreachable_code_return_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_return_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_return_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wunreachable-code\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wunreachable-code\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_unreachable_code+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wunreachable-code" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_unreachable_code=yes +else + ax_cv__pragma__gcc__diags_ignored_unreachable_code=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_unreachable_code" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_unreachable_code" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wunreachable-code\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wunreachable-code\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_unreachable_code_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wunreachable-code" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_unreachable_code_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_unreachable_code_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_unreachable_code_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wformat-overflow\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wformat-overflow\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_format_overflow+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wformat-overflow" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_format_overflow=yes +else + ax_cv__pragma__gcc__diags_ignored_format_overflow=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_format_overflow" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_format_overflow" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_format_overflow" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_OVERFLOW 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wformat-overflow\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wformat-overflow\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_format_overflow_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wformat-overflow" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_format_overflow_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_format_overflow_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_format_overflow_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_format_overflow_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_format_overflow_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_OVERFLOW_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wcovered-switch-default\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wcovered-switch-default\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_covered_switch_default+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wcovered-switch-default" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_covered_switch_default=yes +else + ax_cv__pragma__gcc__diags_ignored_covered_switch_default=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_covered_switch_default" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_covered_switch_default" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_covered_switch_default" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wcovered-switch-default\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wcovered-switch-default\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_covered_switch_default_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wcovered-switch-default" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_covered_switch_default_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_covered_switch_default_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_covered_switch_default_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_covered_switch_default_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_covered_switch_default_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wextra-semi-stmt\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wextra-semi-stmt\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wextra-semi-stmt" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt=yes +else + ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXTRA_SEMI_STMT 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wextra-semi-stmt\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wextra-semi-stmt\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wextra-semi-stmt" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXTRA_SEMI_STMT_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wcast-align\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wcast-align\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_cast_align+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wcast-align" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_cast_align=yes +else + ax_cv__pragma__gcc__diags_ignored_cast_align=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_cast_align" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_cast_align" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_cast_align" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wcast-align\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wcast-align\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_cast_align_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wcast-align" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_cast_align_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_cast_align_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_cast_align_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_cast_align_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_cast_align_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wstrict-prototypes\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wstrict-prototypes\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_strict_prototypes+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wstrict-prototypes" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_strict_prototypes=yes +else + ax_cv__pragma__gcc__diags_ignored_strict_prototypes=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_strict_prototypes" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_strict_prototypes" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_strict_prototypes" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wstrict-prototypes\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wstrict-prototypes\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_strict_prototypes_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wstrict-prototypes" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_strict_prototypes_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_strict_prototypes_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_strict_prototypes_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_strict_prototypes_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_strict_prototypes_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wassign-enum\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wassign-enum\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_assign_enum+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wassign-enum" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_assign_enum=yes +else + ax_cv__pragma__gcc__diags_ignored_assign_enum=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_assign_enum" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_assign_enum" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_assign_enum" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ASSIGN_ENUM 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-Wassign-enum\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-Wassign-enum\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_assign_enum_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wassign-enum" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_assign_enum_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_assign_enum_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_assign_enum_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_assign_enum_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_assign_enum_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ASSIGN_ENUM_BESIDEFUNC 1" >>confdefs.h + + +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ pragma GCC diagnostic ignored \"-Wc++98-compat-pedantic\"" >&5 +$as_echo_n "checking for C++ pragma GCC diagnostic ignored \"-Wc++98-compat-pedantic\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wc++98-compat-pedantic" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic=yes +else + ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT_PEDANTIC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ pragma GCC diagnostic ignored \"-Wc++98-compat-pedantic\" (outside functions)" >&5 +$as_echo_n "checking for C++ pragma GCC diagnostic ignored \"-Wc++98-compat-pedantic\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wc++98-compat-pedantic" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT_PEDANTIC_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ pragma GCC diagnostic ignored \"-Wc++98-compat\"" >&5 +$as_echo_n "checking for C++ pragma GCC diagnostic ignored \"-Wc++98-compat\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_cxx98_compat+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wc++98-compat" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_cxx98_compat=yes +else + ax_cv__pragma__gcc__diags_ignored_cxx98_compat=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_cxx98_compat" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ pragma GCC diagnostic ignored \"-Wc++98-compat\" (outside functions)" >&5 +$as_echo_n "checking for C++ pragma GCC diagnostic ignored \"-Wc++98-compat\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_cxx98_compat_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wc++98-compat" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_cxx98_compat_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_cxx98_compat_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_cxx98_compat_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ pragma GCC diagnostic ignored \"-Wglobal-constructors\"" >&5 +$as_echo_n "checking for C++ pragma GCC diagnostic ignored \"-Wglobal-constructors\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_global_constructors+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wglobal-constructors" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_global_constructors=yes +else + ax_cv__pragma__gcc__diags_ignored_global_constructors=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_global_constructors" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_global_constructors" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_global_constructors" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ pragma GCC diagnostic ignored \"-Wglobal-constructors\" (outside functions)" >&5 +$as_echo_n "checking for C++ pragma GCC diagnostic ignored \"-Wglobal-constructors\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_global_constructors_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wglobal-constructors" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_global_constructors_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_global_constructors_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_global_constructors_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_global_constructors_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_global_constructors_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS_BESIDEFUNC 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ pragma GCC diagnostic ignored \"-Wexit-time-destructors\"" >&5 +$as_echo_n "checking for C++ pragma GCC diagnostic ignored \"-Wexit-time-destructors\"... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_exit_time_destructors+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-Wexit-time-destructors" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_exit_time_destructors=yes +else + ax_cv__pragma__gcc__diags_ignored_exit_time_destructors=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_exit_time_destructors" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_exit_time_destructors" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_exit_time_destructors" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS 1" >>confdefs.h + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ pragma GCC diagnostic ignored \"-Wexit-time-destructors\" (outside functions)" >&5 +$as_echo_n "checking for C++ pragma GCC diagnostic ignored \"-Wexit-time-destructors\" (outside functions)... " >&6; } +if ${ax_cv__pragma__gcc__diags_ignored_exit_time_destructors_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-Wexit-time-destructors" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv__pragma__gcc__diags_ignored_exit_time_destructors_besidefunc=yes +else + ax_cv__pragma__gcc__diags_ignored_exit_time_destructors_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__gcc__diags_ignored_exit_time_destructors_besidefunc" >&5 +$as_echo "$ax_cv__pragma__gcc__diags_ignored_exit_time_destructors_besidefunc" >&6; } + if test "$ax_cv__pragma__gcc__diags_ignored_exit_time_destructors_besidefunc" = "yes"; then : + + +$as_echo "#define HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS_BESIDEFUNC 1" >>confdefs.h + + +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + if test "$ax_cv__pragma__gcc__diags_push_pop_insidefunc" = "yes"; then : + + if test "$ax_cv__pragma__gcc__diags_ignored_format_security" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_format_nonliteral" = "yes" ; then : + + +$as_echo "#define HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL 1" >>confdefs.h + + +fi + if test "$ax_cv__pragma__gcc__diags_ignored_format_truncation" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_stringop_truncation" = "yes" ; then : + + +$as_echo "#define HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION 1" >>confdefs.h + + +fi + if test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_break" = "yes" ; then : + + +$as_echo "#define HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE 1" >>confdefs.h + + +fi + if test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat" = "yes" ; then : + + +$as_echo "#define HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT 1" >>confdefs.h + + +fi + +fi + + if test "$ax_cv__pragma__gcc__diags_push_pop_besidefunc" = "yes"; then : + + if test "$ax_cv__pragma__gcc__diags_ignored_format_security" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_format_nonliteral" = "yes" ; then : + + +$as_echo "#define HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL_BESIDEFUNC 1" >>confdefs.h + + +fi + if test "$ax_cv__pragma__gcc__diags_ignored_format_truncation" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_stringop_truncation" = "yes" ; then : + + +$as_echo "#define HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION_BESIDEFUNC 1" >>confdefs.h + + +fi + if test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_break" = "yes" ; then : + + +$as_echo "#define HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_BESIDEFUNC 1" >>confdefs.h + + +fi + if test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat" = "yes" ; then : + + +$as_echo "#define HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT_BESIDEFUNC 1" >>confdefs.h + + +fi + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma BOGUSforTest" >&5 +$as_echo_n "checking for pragma BOGUSforTest... " >&6; } +if ${ax_cv__pragma__bogus+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma BOGUSforTest +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__bogus=yes +else + ax_cv__pragma__bogus=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__bogus" >&5 +$as_echo "$ax_cv__pragma__bogus" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma BOGUSforTest (outside functions)" >&5 +$as_echo_n "checking for pragma BOGUSforTest (outside functions)... " >&6; } +if ${ax_cv__pragma__bogus_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma BOGUSforTest +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__bogus_besidefunc=yes +else + ax_cv__pragma__bogus_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__bogus_besidefunc" >&5 +$as_echo "$ax_cv__pragma__bogus_besidefunc" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-WBOGUSforTest\"" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-WBOGUSforTest\"... " >&6; } +if ${ax_cv__pragma__bogus_diag+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void func(void) { +#pragma GCC diagnostic ignored "-WBOGUSforTest" +} + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__bogus_diag=yes +else + ax_cv__pragma__bogus_diag=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__bogus_diag" >&5 +$as_echo "$ax_cv__pragma__bogus_diag" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma GCC diagnostic ignored \"-WBOGUSforTest\" (outside functions)" >&5 +$as_echo_n "checking for pragma GCC diagnostic ignored \"-WBOGUSforTest\" (outside functions)... " >&6; } +if ${ax_cv__pragma__bogus_diag_besidefunc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#pragma GCC diagnostic ignored "-WBOGUSforTest" +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ax_cv__pragma__bogus_diag_besidefunc=yes +else + ax_cv__pragma__bogus_diag_besidefunc=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv__pragma__bogus_diag_besidefunc" >&5 +$as_echo "$ax_cv__pragma__bogus_diag_besidefunc" >&6; } + + if test "${ax_cv__pragma__bogus}" != "no"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: A bogus test that was expected to fail did not! ax_cv__pragma__bogus=$ax_cv__pragma__bogus (not 'no')" >&5 +$as_echo "$as_me: WARNING: A bogus test that was expected to fail did not! ax_cv__pragma__bogus=$ax_cv__pragma__bogus (not 'no')" >&2;} +fi + + if test "${ax_cv__pragma__bogus_besidefunc}" != "no"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: A bogus test that was expected to fail did not! ax_cv__pragma__bogus_besidefunc=$ax_cv__pragma__bogus_besidefunc (not 'no')" >&5 +$as_echo "$as_me: WARNING: A bogus test that was expected to fail did not! ax_cv__pragma__bogus_besidefunc=$ax_cv__pragma__bogus_besidefunc (not 'no')" >&2;} +fi + + if test "${ax_cv__pragma__bogus_diag}" != "no"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: A bogus test that was expected to fail did not! ax_cv__pragma__bogus_diag=$ax_cv__pragma__bogus_diag (not 'no')" >&5 +$as_echo "$as_me: WARNING: A bogus test that was expected to fail did not! ax_cv__pragma__bogus_diag=$ax_cv__pragma__bogus_diag (not 'no')" >&2;} +fi + + if test "${ax_cv__pragma__bogus_diag_besidefunc}" != "no"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: A bogus test that was expected to fail did not! ax_cv__pragma__bogus_diag_besidefunc=$ax_cv__pragma__bogus_diag_besidefunc (not 'no')" >&5 +$as_echo "$as_me: WARNING: A bogus test that was expected to fail did not! ax_cv__pragma__bogus_diag_besidefunc=$ax_cv__pragma__bogus_diag_besidefunc (not 'no')" >&2;} +fi + + CFLAGS="${CFLAGS_SAVED}" + CXXFLAGS="${CXXFLAGS_SAVED}" +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking types of arguments for modbus_set_byte_timeout" >&5 +$as_echo_n "checking types of arguments for modbus_set_byte_timeout... " >&6; } +if ${nut_cv_func_modbus_set_byte_timeout_args+:} false; then : + $as_echo_n "(cached) " >&6 +else + nut_cv_func_modbus_set_byte_timeout_args="unknown" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include + +int +main () +{ +modbus_t *ctx; struct timeval to = (struct timeval){0}; +modbus_set_byte_timeout(ctx, &to); + ; + return 0; +} + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + nut_cv_func_modbus_set_byte_timeout_args="timeval" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include + +int +main () +{ +modbus_t *ctx; uint32_t to_sec = 10, to_usec = 50; +struct timeval to = (struct timeval){0}; +/* TODO: Clarify and detect warning names and + * so pragmas for signed/unsigned assignment (e.g. + * for timeval definitions that have "long" fields) + */ +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_COMPARE +# pragma GCC diagnostic ignored "-Wsign-compare" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_CONVERSION +# pragma GCC diagnostic ignored "-Wsign-conversion" +#endif +to.tv_sec = to_sec; +to.tv_usec = to_usec; +modbus_set_byte_timeout(ctx, &to); + + ; + return 0; +} + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + nut_cv_func_modbus_set_byte_timeout_args="timeval_numeric_fields" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include + +int +main () +{ +modbus_t *ctx; struct timeval to = (struct timeval){0}; +/* TODO: Clarify and detect warning names and + * so pragmas for signed/unsigned assignment (e.g. + * for timeval definitions that have "long" fields) + */ +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_COMPARE +# pragma GCC diagnostic ignored "-Wsign-compare" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_CONVERSION +# pragma GCC diagnostic ignored "-Wsign-conversion" +#endif +uint32_t to_sec = to.tv_sec, to_usec = to.tv_usec; +modbus_set_byte_timeout(ctx, to_sec, to_usec); + + ; + return 0; +} + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + nut_cv_func_modbus_set_byte_timeout_args="sec_usec_uint32_cast_timeval_fields" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include + +int +main () +{ +modbus_t *ctx; uint32_t to_sec = 0, to_usec = 0; +modbus_set_byte_timeout(ctx, to_sec, to_usec); + ; + return 0; +} + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + nut_cv_func_modbus_set_byte_timeout_args="sec_usec_uint32" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $nut_cv_func_modbus_set_byte_timeout_args" >&5 +$as_echo "$nut_cv_func_modbus_set_byte_timeout_args" >&6; } + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Found types to use for modbus_set_byte_timeout: ${nut_cv_func_modbus_set_byte_timeout_args}" >&5 +$as_echo "Found types to use for modbus_set_byte_timeout: ${nut_cv_func_modbus_set_byte_timeout_args}" >&6; } + COMMENT="Define to specify timeout method args approach for libmodbus" + case "${nut_cv_func_modbus_set_byte_timeout_args}" in #( + timeval_numeric_fields) : + +$as_echo "#define NUT_MODBUS_TIMEOUT_ARG_timeval_numeric_fields 1" >>confdefs.h + ;; #( + timeval) : + +$as_echo "#define NUT_MODBUS_TIMEOUT_ARG_timeval 1" >>confdefs.h + ;; #( + sec_usec_uint32_cast_timeval_fields) : + +$as_echo "#define NUT_MODBUS_TIMEOUT_ARG_sec_usec_uint32_cast_timeval_fields 1" >>confdefs.h + ;; #( + sec_usec_uint32) : + +$as_echo "#define NUT_MODBUS_TIMEOUT_ARG_sec_usec_uint32 1" >>confdefs.h + ;; #( + *) : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find proper types to use for modbus_set_byte_timeout" >&5 +$as_echo "$as_me: WARNING: Cannot find proper types to use for modbus_set_byte_timeout" >&2;} + nut_have_libmodbus=no + ;; +esac + +fi + + if test x"${nut_have_libmodbus}" = x"yes"; then : + LIBMODBUS_CFLAGS="${CFLAGS}" + LIBMODBUS_LIBS="${LIBS}" + +fi + + CFLAGS="${CFLAGS_ORIG}" + LIBS="${LIBS_ORIG}" +fi + + + +# Check whether --with-avahi was given. +if test "${with_avahi+set}" = set; then : + withval=$with_avahi; nut_with_avahi="${withval}" +else + nut_with_avahi="auto" + +fi + + + +if test -z "${nut_have_avahi_seen}"; then + nut_have_avahi_seen=yes + +if test -z "${nut_have_pkg_config_seen}"; then : + + nut_have_pkg_config_seen=yes + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG was already detected by autoconf" >&5 +$as_echo_n "checking whether usable PKG_CONFIG was already detected by autoconf... " >&6; } + if test -n "${PKG_CONFIG-}" && test x"${PKG_CONFIG-}" != x"false" && $PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${PKG_CONFIG}" >&5 +$as_echo "yes: ${PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + + if test x"${PKG_CONFIG-}" = x"false"; then : + have_PKG_CONFIG=yes + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_dummy_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $dummy_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_dummy_PKG_CONFIG="$dummy_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_dummy_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +dummy_PKG_CONFIG=$ac_cv_path_dummy_PKG_CONFIG +if test -n "$dummy_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dummy_PKG_CONFIG" >&5 +$as_echo "$dummy_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + +# Check whether --with-pkg-config was given. +if test "${with_pkg_config+set}" = set; then : + withval=$with_pkg_config; + case "${withval}" in + "") ;; + yes|no) + as_fn_error $? "invalid option --with(out)-pkg-config - see docs/configure.txt" "$LINENO" 5 + ;; + *) + dummy_PKG_CONFIG="${withval}" + ;; + esac + +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG is present in PATH or was set by caller" >&5 +$as_echo_n "checking whether usable PKG_CONFIG is present in PATH or was set by caller... " >&6; } + if test x"$dummy_PKG_CONFIG" = xno || test -z "$dummy_PKG_CONFIG"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + +else + if $dummy_PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${dummy_PKG_CONFIG}" >&5 +$as_echo "yes: ${dummy_PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + PKG_CONFIG="$dummy_PKG_CONFIG" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + +fi + +fi + + have_PKG_CONFIG_MACROS=no + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&6;} + dummy_RES=0 + + + if test "${dummy_RES}" = 0; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config module checker" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config module checker" >&6;} + + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pkg-config" >&5 +$as_echo_n "checking for pkg-config... " >&6; } + +if test -n "$dummy_PKG_CONFIG_CFLAGS"; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS="$dummy_PKG_CONFIG_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS=`$PKG_CONFIG --cflags "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$dummy_PKG_CONFIG_LIBS"; then + pkg_cv_dummy_PKG_CONFIG_LIBS="$dummy_PKG_CONFIG_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_LIBS=`$PKG_CONFIG --libs "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "pkg-config" 2>&1` + else + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "pkg-config" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$dummy_PKG_CONFIG_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (pkg-config) were not met: + +$dummy_PKG_CONFIG_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + dummy_PKG_CONFIG_CFLAGS=$pkg_cv_dummy_PKG_CONFIG_CFLAGS + dummy_PKG_CONFIG_LIBS=$pkg_cv_dummy_PKG_CONFIG_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + have_PKG_CONFIG_MACROS=yes +fi + + +fi + +fi + + if test x"$have_PKG_CONFIG" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&5 +$as_echo "$as_me: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&2;} + PKG_CONFIG="false" + +else + if test x"$have_PKG_CONFIG_MACROS" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&5 +$as_echo "$as_me: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&2;} + +fi + +fi + + +fi + + CFLAGS_ORIG="${CFLAGS}" + LIBS_ORIG="${LIBS}" + + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for avahi-core version via pkg-config (0.6.30 minimum required)" >&5 $as_echo_n "checking for avahi-core version via pkg-config (0.6.30 minimum required)... " >&6; } - AVAHI_CORE_VERSION="`pkg-config --silence-errors --modversion avahi-core 2>/dev/null`" - if test "$?" != "0" -o -z "${AVAHI_CORE_VERSION}"; then - AVAHI_CORE_VERSION="none" - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${AVAHI_CORE_VERSION} found" >&5 + AVAHI_CORE_VERSION="`$PKG_CONFIG --silence-errors --modversion avahi-core 2>/dev/null`" + if test "$?" != "0" -o -z "${AVAHI_CORE_VERSION}"; then + AVAHI_CORE_VERSION="none" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${AVAHI_CORE_VERSION} found" >&5 $as_echo "${AVAHI_CORE_VERSION} found" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for avahi-client version via pkg-config (0.6.30 minimum required)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for avahi-client version via pkg-config (0.6.30 minimum required)" >&5 $as_echo_n "checking for avahi-client version via pkg-config (0.6.30 minimum required)... " >&6; } - AVAHI_CLIENT_VERSION="`pkg-config --silence-errors --modversion avahi-client 2>/dev/null`" - if test "$?" != "0" -o -z "${AVAHI_CLIENT_VERSION}"; then - AVAHI_CLIENT_VERSION="none" - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${AVAHI_CLIENT_VERSION} found" >&5 + AVAHI_CLIENT_VERSION="`$PKG_CONFIG --silence-errors --modversion avahi-client 2>/dev/null`" + if test "$?" != "0" -o -z "${AVAHI_CLIENT_VERSION}"; then + AVAHI_CLIENT_VERSION="none" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${AVAHI_CLIENT_VERSION} found" >&5 $as_echo "${AVAHI_CLIENT_VERSION} found" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: can not check avahi settings via pkg-config" >&5 +$as_echo "$as_me: can not check avahi settings via pkg-config" >&6;} + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for avahi cflags" >&5 $as_echo_n "checking for avahi cflags... " >&6; } @@ -8581,7 +19305,14 @@ if test "${with_avahi_includes+set}" = set; then : esac else - CFLAGS="`pkg-config --silence-errors --cflags avahi-core avahi-client 2>/dev/null`" + + if test x"$have_PKG_CONFIG" = xyes; then : + CFLAGS="`$PKG_CONFIG --silence-errors --cflags avahi-core avahi-client 2>/dev/null`" || CFLAGS="-I/usr/local/include -I/usr/include -L/usr/local/lib -L/usr/lib" +else + CFLAGS="-I/usr/local/include -I/usr/include -L/usr/local/lib -L/usr/lib" + +fi + fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${CFLAGS}" >&5 @@ -8603,7 +19334,14 @@ if test "${with_avahi_libs+set}" = set; then : esac else - LIBS="`pkg-config --silence-errors --libs avahi-core avahi-client 2>/dev/null`" + + if test x"$have_PKG_CONFIG" = xyes; then : + LIBS="`$PKG_CONFIG --silence-errors --libs avahi-core avahi-client 2>/dev/null`" || LIBS="-lavahi-core -lavahi-client" +else + LIBS="-lavahi-core -lavahi-client" + +fi + fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${LIBS}" >&5 @@ -8679,79 +19417,150 @@ fi -case ${target_os} in - solaris2.1* ) - echo Checking for Solaris 10 / 11 specific configuration for usb drivers - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing nanosleep" >&5 -$as_echo_n "checking for library containing nanosleep... " >&6; } -if ${ac_cv_search_nanosleep+:} false; then : - $as_echo_n "(cached) " >&6 +if test "${nut_with_serial}" != "no"; then : + if test "${nut_with_serial}" != "yes"; then : + nut_with_serial="auto" +fi + + CFLAGS_SAVED_SERIAL="${CFLAGS}" + if test "${GCC}" = yes; then : + CFLAGS_SAVED_WERROR="${CFLAGS} -Wall -Werror" + CFLAGS_SAVED_WNOERROR="${CFLAGS} -Wno-error" + else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext + CFLAGS_SAVED_WERROR="${CFLAGS}" + CFLAGS_SAVED_WNOERROR="${CFLAGS}" + +fi + + + CFLAGS="${CFLAGS_SAVED_WERROR}" + for ac_header in sys/termios.h +do : + ac_fn_c_check_header_compile "$LINENO" "sys/termios.h" "ac_cv_header_sys_termios_h" "$ac_includes_default +" +if test "x$ac_cv_header_sys_termios_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_TERMIOS_H 1 +_ACEOF + +else + + CFLAGS="${CFLAGS_SAVED_WNOERROR}" + for ac_header in termios.h +do : + ac_fn_c_check_header_compile "$LINENO" "termios.h" "ac_cv_header_termios_h" "$ac_includes_default +" +if test "x$ac_cv_header_termios_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_TERMIOS_H 1 +_ACEOF + +else + + for ac_header in sys/termios.h +do : + ac_fn_c_check_header_compile "$LINENO" "sys/termios.h" "ac_cv_header_sys_termios_h" "$ac_includes_default +" +if test "x$ac_cv_header_sys_termios_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_TERMIOS_H 1 +_ACEOF + +fi + +done + + +fi + +done + + +fi + +done + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct termios and speed_t" >&5 +$as_echo_n "checking for struct termios and speed_t... " >&6; } + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char nanosleep (); +#if defined(HAVE_SYS_TERMIOS_H) +# include /* for speed_t */ +#else +# if defined(HAVE_TERMIOS_H) +# include +# endif /* HAVE_TERMIOS_H */ +#endif /* HAVE_SYS_TERMIOS_H */ +void getspeed(speed_t* b) { *b = B19200; } + int main () { -return nanosleep (); +struct termios tio; +if (!tcgetattr(0, &tio)) { return 1; } +speed_t baudrate; +getspeed(&baudrate); + + ; return 0; } _ACEOF -for ac_lib in '' rt; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_nanosleep=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_nanosleep+:} false; then : - break -fi -done -if ${ac_cv_search_nanosleep+:} false; then : +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; } + nut_have_serial_types=yes else - ac_cv_search_nanosleep=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_nanosleep" >&5 -$as_echo "$ac_cv_search_nanosleep" >&6; } -ac_res=$ac_cv_search_nanosleep -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, struct termios and/or speed_t not found in discovered headers" >&5 +$as_echo "no, struct termios and/or speed_t not found in discovered headers" >&6; } + nut_have_serial_types=no + fi - - LIBUSB_LIBS="-R/usr/sfw/lib ${LIBUSB_LIBS}" - -$as_echo "#define SUN_LIBUSB 1" >>confdefs.h - - SUN_LIBUSB=1 - ;; - hpux11*) - CFLAGS="${CFLAGS} -lpthread" -esac +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + CFLAGS="${CFLAGS_SAVED_SERIAL}" -if test "${nut_with_serial}" != "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can build serial drivers" >&5 +$as_echo_n "checking whether we can build serial drivers... " >&6; } + if test "${nut_have_serial_types}" = yes; then : + if test "${nut_with_serial}" = "auto"; then : nut_with_serial="yes" +fi +else + if test "${nut_with_serial}" = "auto"; then : + nut_with_serial="no" +fi + if test "${nut_with_serial}" = "yes"; then : + as_fn_error $? "no, and were required to" "$LINENO" 5 +fi + +fi + if test "${nut_with_serial}" = "yes"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + fi @@ -8787,19 +19596,28 @@ _ACEOF -if test "${nut_with_usb}" = "yes" -a "${nut_have_libusb}" != "yes"; then - as_fn_error $? "\"USB drivers requested, but libusb not found.\"" "$LINENO" 5 + if test "${nut_usb_lib}" = "(libusb-1.0)"; then + WITH_LIBUSB_1_0_TRUE= + WITH_LIBUSB_1_0_FALSE='#' +else + WITH_LIBUSB_1_0_TRUE='#' + WITH_LIBUSB_1_0_FALSE= fi -if test "${nut_with_usb}" != "no"; then - nut_with_usb="${nut_have_libusb}" + if test "${nut_usb_lib}" = "(libusb-0.1)" -o "${nut_usb_lib}" = "(libusb-0.1-config)"; then + WITH_LIBUSB_0_1_TRUE= + WITH_LIBUSB_0_1_FALSE='#' +else + WITH_LIBUSB_0_1_TRUE='#' + WITH_LIBUSB_0_1_FALSE= fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build USB drivers" >&5 $as_echo_n "checking whether to build USB drivers... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${nut_with_usb} " >&5 -$as_echo "${nut_with_usb} " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${nut_with_usb} ${nut_usb_lib}" >&5 +$as_echo "${nut_with_usb} ${nut_usb_lib}" >&6; } if test -z "${nut_report_feature_flag}"; then nut_report_feature_flag="1" ac_clean_files="${ac_clean_files} conf_nut_report_feature" @@ -8807,7 +19625,7 @@ $as_echo "${nut_with_usb} " >&6; } echo "Configuration summary:" >> conf_nut_report_feature echo "======================" >> conf_nut_report_feature fi - echo "build USB drivers: ${nut_with_usb} " >> conf_nut_report_feature + echo "build USB drivers: ${nut_with_usb} ${nut_usb_lib}" >> conf_nut_report_feature if test "${nut_with_usb}" = "yes"; then @@ -8828,49 +19646,8 @@ _ACEOF -if test "${nut_with_snmp}" = "yes" -a "${nut_have_libnetsnmp}" != "yes"; then - as_fn_error $? "\"Net-SNMP libraries not found, required for SNMP drivers\"" "$LINENO" 5 -fi - -if test "${nut_with_snmp}" != "no"; then - nut_with_snmp="${nut_have_libnetsnmp}" -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build SNMP drivers" >&5 -$as_echo_n "checking whether to build SNMP drivers... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${nut_with_snmp} " >&5 -$as_echo "${nut_with_snmp} " >&6; } - if test -z "${nut_report_feature_flag}"; then - nut_report_feature_flag="1" - ac_clean_files="${ac_clean_files} conf_nut_report_feature" - echo > conf_nut_report_feature - echo "Configuration summary:" >> conf_nut_report_feature - echo "======================" >> conf_nut_report_feature - fi - echo "build SNMP drivers: ${nut_with_snmp} " >> conf_nut_report_feature - - - if test "${nut_with_snmp}" = "yes"; then - WITH_SNMP_TRUE= - WITH_SNMP_FALSE='#' -else - WITH_SNMP_TRUE='#' - WITH_SNMP_FALSE= -fi - - if test "${nut_with_snmp}" = "yes"; then - -cat >>confdefs.h <<_ACEOF -#define WITH_SNMP 1 -_ACEOF - - fi - - - if test "${nut_with_neon}" = "yes" -a "${nut_have_neon}" != "yes"; then - as_fn_error $? "\"neon libraries not found, required for neon based XML/HTTP driver\"" "$LINENO" 5 + as_fn_error $? "neon libraries not found, required for neon based XML/HTTP driver" "$LINENO" 5 fi if test "${nut_with_neon}" != "no"; then @@ -8908,10 +19685,18 @@ _ACEOF fi + if test "${nut_have_neon}" = "yes"; then + HAVE_NEON_TRUE= + HAVE_NEON_FALSE='#' +else + HAVE_NEON_TRUE='#' + HAVE_NEON_FALSE= +fi + if test "${nut_with_avahi}" = "yes" -a "${nut_have_avahi}" != "yes"; then - as_fn_error $? "\"avahi libraries not found\"" "$LINENO" 5 + as_fn_error $? "avahi libraries not found" "$LINENO" 5 fi if test "${nut_with_avahi}" != "no"; then @@ -8953,7 +19738,7 @@ _ACEOF if test "${nut_with_powerman}" = "yes" -a "${nut_have_libpowerman}" != "yes"; then - as_fn_error $? "\"Powerman client libraries not found, required for Powerman PDU client driver\"" "$LINENO" 5 + as_fn_error $? "Powerman client libraries not found, required for Powerman PDU client driver" "$LINENO" 5 fi if test "${nut_with_powerman}" != "no"; then @@ -8993,6 +19778,46 @@ _ACEOF +if test "${nut_with_modbus}" = "yes" -a "${nut_have_libmodbus}" != "yes"; then + as_fn_error $? "modbus library not found, required for Modbus driver" "$LINENO" 5 +fi + +if test "${nut_with_modbus}" != "no"; then + nut_with_modbus="${nut_have_libmodbus}" +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build Modbus driver" >&5 +$as_echo_n "checking whether to build Modbus driver... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${nut_with_modbus} " >&5 +$as_echo "${nut_with_modbus} " >&6; } + if test -z "${nut_report_feature_flag}"; then + nut_report_feature_flag="1" + ac_clean_files="${ac_clean_files} conf_nut_report_feature" + echo > conf_nut_report_feature + echo "Configuration summary:" >> conf_nut_report_feature + echo "======================" >> conf_nut_report_feature + fi + echo "build Modbus driver: ${nut_with_modbus} " >> conf_nut_report_feature + + + if test "${nut_with_modbus}" = "yes"; then + WITH_MODBUS_TRUE= + WITH_MODBUS_FALSE='#' +else + WITH_MODBUS_TRUE='#' + WITH_MODBUS_FALSE= +fi + + if test "${nut_with_modbus}" = "yes"; then + +cat >>confdefs.h <<_ACEOF +#define WITH_MODBUS 1 +_ACEOF + + fi + + nut_ipmi_lib="" @@ -9022,23 +19847,271 @@ if test "${nut_with_ipmi}" != "no"; then if test -z "${nut_have_libfreeipmi_seen}"; then nut_have_libfreeipmi_seen=yes +if test -z "${nut_have_pkg_config_seen}"; then : + + nut_have_pkg_config_seen=yes + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG was already detected by autoconf" >&5 +$as_echo_n "checking whether usable PKG_CONFIG was already detected by autoconf... " >&6; } + if test -n "${PKG_CONFIG-}" && test x"${PKG_CONFIG-}" != x"false" && $PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${PKG_CONFIG}" >&5 +$as_echo "yes: ${PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + + if test x"${PKG_CONFIG-}" = x"false"; then : + have_PKG_CONFIG=yes + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_dummy_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $dummy_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_dummy_PKG_CONFIG="$dummy_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_dummy_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +dummy_PKG_CONFIG=$ac_cv_path_dummy_PKG_CONFIG +if test -n "$dummy_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dummy_PKG_CONFIG" >&5 +$as_echo "$dummy_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + +# Check whether --with-pkg-config was given. +if test "${with_pkg_config+set}" = set; then : + withval=$with_pkg_config; + case "${withval}" in + "") ;; + yes|no) + as_fn_error $? "invalid option --with(out)-pkg-config - see docs/configure.txt" "$LINENO" 5 + ;; + *) + dummy_PKG_CONFIG="${withval}" + ;; + esac + +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG is present in PATH or was set by caller" >&5 +$as_echo_n "checking whether usable PKG_CONFIG is present in PATH or was set by caller... " >&6; } + if test x"$dummy_PKG_CONFIG" = xno || test -z "$dummy_PKG_CONFIG"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + +else + if $dummy_PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${dummy_PKG_CONFIG}" >&5 +$as_echo "yes: ${dummy_PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + PKG_CONFIG="$dummy_PKG_CONFIG" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + +fi + +fi + + have_PKG_CONFIG_MACROS=no + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&6;} + dummy_RES=0 + + + if test "${dummy_RES}" = 0; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config module checker" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config module checker" >&6;} + + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pkg-config" >&5 +$as_echo_n "checking for pkg-config... " >&6; } + +if test -n "$dummy_PKG_CONFIG_CFLAGS"; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS="$dummy_PKG_CONFIG_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS=`$PKG_CONFIG --cflags "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$dummy_PKG_CONFIG_LIBS"; then + pkg_cv_dummy_PKG_CONFIG_LIBS="$dummy_PKG_CONFIG_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_LIBS=`$PKG_CONFIG --libs "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "pkg-config" 2>&1` + else + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "pkg-config" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$dummy_PKG_CONFIG_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (pkg-config) were not met: + +$dummy_PKG_CONFIG_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + dummy_PKG_CONFIG_CFLAGS=$pkg_cv_dummy_PKG_CONFIG_CFLAGS + dummy_PKG_CONFIG_LIBS=$pkg_cv_dummy_PKG_CONFIG_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + have_PKG_CONFIG_MACROS=yes +fi + + +fi + +fi + + if test x"$have_PKG_CONFIG" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&5 +$as_echo "$as_me: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&2;} + PKG_CONFIG="false" + +else + if test x"$have_PKG_CONFIG_MACROS" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&5 +$as_echo "$as_me: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&2;} + +fi + +fi + + +fi + CFLAGS_ORIG="${CFLAGS}" LIBS_ORIG="${LIBS}" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FreeIPMI version via pkg-config" >&5 + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FreeIPMI version via pkg-config" >&5 $as_echo_n "checking for FreeIPMI version via pkg-config... " >&6; } - FREEIPMI_VERSION="`pkg-config --silence-errors --modversion libfreeipmi 2>/dev/null`" - if test "$?" = "0" -a -n "${FREEIPMI_VERSION}"; then - CFLAGS="`pkg-config --silence-errors --cflags libfreeipmi libipmimonitoring 2>/dev/null`" - LIBS="`pkg-config --silence-errors --libs libfreeipmi libipmimonitoring 2>/dev/null`" - else - FREEIPMI_VERSION="none" - CFLAGS="" - LIBS="-lfreeipmi -lipmimonitoring" - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${FREEIPMI_VERSION} found" >&5 + FREEIPMI_VERSION="`$PKG_CONFIG --silence-errors --modversion libfreeipmi 2>/dev/null`" + if test "$?" != "0" -o -z "${FREEIPMI_VERSION}"; then + FREEIPMI_VERSION="none" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${FREEIPMI_VERSION} found" >&5 $as_echo "${FREEIPMI_VERSION} found" >&6; } +else + FREEIPMI_VERSION="none" + { $as_echo "$as_me:${as_lineno-$LINENO}: can not check FreeIPMI settings via pkg-config" >&5 +$as_echo "$as_me: can not check FreeIPMI settings via pkg-config" >&6;} + + +fi + + if test x"$FREEIPMI_VERSION" != xnone; then : + CFLAGS="`$PKG_CONFIG --silence-errors --cflags libfreeipmi libipmimonitoring 2>/dev/null`" + LIBS="`$PKG_CONFIG --silence-errors --libs libfreeipmi libipmimonitoring 2>/dev/null`" + +else + CFLAGS="" + LIBS="-lfreeipmi -lipmimonitoring" + + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FreeIPMI cflags" >&5 $as_echo_n "checking for FreeIPMI cflags... " >&6; } @@ -9486,7 +20559,7 @@ $as_echo "#define HAVE_FREEIPMI_MONITORING 1" >>confdefs.h fi if test "${nut_have_freeipmi}" != "yes"; then - as_fn_error $? "\"GNU FreeIPMI not found, required for IPMI support\"" "$LINENO" 5 + as_fn_error $? "FreeIPMI not found, required for IPMI support" "$LINENO" 5 fi nut_with_ipmi="yes" else @@ -9494,23 +20567,271 @@ fi if test -z "${nut_have_libfreeipmi_seen}"; then nut_have_libfreeipmi_seen=yes +if test -z "${nut_have_pkg_config_seen}"; then : + + nut_have_pkg_config_seen=yes + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG was already detected by autoconf" >&5 +$as_echo_n "checking whether usable PKG_CONFIG was already detected by autoconf... " >&6; } + if test -n "${PKG_CONFIG-}" && test x"${PKG_CONFIG-}" != x"false" && $PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${PKG_CONFIG}" >&5 +$as_echo "yes: ${PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + + if test x"${PKG_CONFIG-}" = x"false"; then : + have_PKG_CONFIG=yes + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_dummy_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $dummy_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_dummy_PKG_CONFIG="$dummy_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_dummy_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +dummy_PKG_CONFIG=$ac_cv_path_dummy_PKG_CONFIG +if test -n "$dummy_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dummy_PKG_CONFIG" >&5 +$as_echo "$dummy_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + +# Check whether --with-pkg-config was given. +if test "${with_pkg_config+set}" = set; then : + withval=$with_pkg_config; + case "${withval}" in + "") ;; + yes|no) + as_fn_error $? "invalid option --with(out)-pkg-config - see docs/configure.txt" "$LINENO" 5 + ;; + *) + dummy_PKG_CONFIG="${withval}" + ;; + esac + +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG is present in PATH or was set by caller" >&5 +$as_echo_n "checking whether usable PKG_CONFIG is present in PATH or was set by caller... " >&6; } + if test x"$dummy_PKG_CONFIG" = xno || test -z "$dummy_PKG_CONFIG"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + +else + if $dummy_PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${dummy_PKG_CONFIG}" >&5 +$as_echo "yes: ${dummy_PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + PKG_CONFIG="$dummy_PKG_CONFIG" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + +fi + +fi + + have_PKG_CONFIG_MACROS=no + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&6;} + dummy_RES=0 + + + if test "${dummy_RES}" = 0; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config module checker" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config module checker" >&6;} + + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pkg-config" >&5 +$as_echo_n "checking for pkg-config... " >&6; } + +if test -n "$dummy_PKG_CONFIG_CFLAGS"; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS="$dummy_PKG_CONFIG_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS=`$PKG_CONFIG --cflags "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$dummy_PKG_CONFIG_LIBS"; then + pkg_cv_dummy_PKG_CONFIG_LIBS="$dummy_PKG_CONFIG_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_LIBS=`$PKG_CONFIG --libs "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "pkg-config" 2>&1` + else + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "pkg-config" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$dummy_PKG_CONFIG_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (pkg-config) were not met: + +$dummy_PKG_CONFIG_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + dummy_PKG_CONFIG_CFLAGS=$pkg_cv_dummy_PKG_CONFIG_CFLAGS + dummy_PKG_CONFIG_LIBS=$pkg_cv_dummy_PKG_CONFIG_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + have_PKG_CONFIG_MACROS=yes +fi + + +fi + +fi + + if test x"$have_PKG_CONFIG" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&5 +$as_echo "$as_me: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&2;} + PKG_CONFIG="false" + +else + if test x"$have_PKG_CONFIG_MACROS" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&5 +$as_echo "$as_me: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&2;} + +fi + +fi + + +fi + CFLAGS_ORIG="${CFLAGS}" LIBS_ORIG="${LIBS}" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FreeIPMI version via pkg-config" >&5 + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FreeIPMI version via pkg-config" >&5 $as_echo_n "checking for FreeIPMI version via pkg-config... " >&6; } - FREEIPMI_VERSION="`pkg-config --silence-errors --modversion libfreeipmi 2>/dev/null`" - if test "$?" = "0" -a -n "${FREEIPMI_VERSION}"; then - CFLAGS="`pkg-config --silence-errors --cflags libfreeipmi libipmimonitoring 2>/dev/null`" - LIBS="`pkg-config --silence-errors --libs libfreeipmi libipmimonitoring 2>/dev/null`" - else - FREEIPMI_VERSION="none" - CFLAGS="" - LIBS="-lfreeipmi -lipmimonitoring" - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${FREEIPMI_VERSION} found" >&5 + FREEIPMI_VERSION="`$PKG_CONFIG --silence-errors --modversion libfreeipmi 2>/dev/null`" + if test "$?" != "0" -o -z "${FREEIPMI_VERSION}"; then + FREEIPMI_VERSION="none" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${FREEIPMI_VERSION} found" >&5 $as_echo "${FREEIPMI_VERSION} found" >&6; } +else + FREEIPMI_VERSION="none" + { $as_echo "$as_me:${as_lineno-$LINENO}: can not check FreeIPMI settings via pkg-config" >&5 +$as_echo "$as_me: can not check FreeIPMI settings via pkg-config" >&6;} + + +fi + + if test x"$FREEIPMI_VERSION" != xnone; then : + CFLAGS="`$PKG_CONFIG --silence-errors --cflags libfreeipmi libipmimonitoring 2>/dev/null`" + LIBS="`$PKG_CONFIG --silence-errors --libs libfreeipmi libipmimonitoring 2>/dev/null`" + +else + CFLAGS="" + LIBS="-lfreeipmi -lipmimonitoring" + + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FreeIPMI cflags" >&5 $as_echo_n "checking for FreeIPMI cflags... " >&6; } @@ -9959,7 +21280,7 @@ fi if test "${nut_have_freeipmi}" != "yes"; then if test "${nut_with_ipmi}" = "yes"; then - as_fn_error $? "\"FreeIPMI not found, required for IPMI support\"" "$LINENO" 5 + as_fn_error $? "FreeIPMI not found, required for IPMI support" "$LINENO" 5 fi nut_with_ipmi="no" else @@ -10030,6 +21351,9 @@ if test "${nut_with_macosx_ups}" != no; then if test -d /System/Library/Frameworks/IOKit.framework/ ; then nut_with_macosx_ups="yes" else + if test "${nut_with_macosx_ups}" = yes; then + as_fn_error $? "macosx-ups was required but can not be fulfilled for this build: not MacOS" "$LINENO" 5 + fi nut_with_macosx_ups="no" fi fi @@ -10079,8 +21403,115 @@ fi if test "${nut_with_linux_i2c}" != no; then case ${target_os} in linux* ) - ac_fn_c_check_decl "$LINENO" "i2c_smbus_read_word_data" "ac_cv_have_decl_i2c_smbus_read_word_data" "#include + ac_fn_c_check_header_mongrel "$LINENO" "linux/i2c-dev.h" "ac_cv_header_linux_i2c_dev_h" "$ac_includes_default" +if test "x$ac_cv_header_linux_i2c_dev_h" = xyes; then : + +$as_echo "#define HAVE_LINUX_I2C_DEV_H 1" >>confdefs.h + + +fi + + + ac_fn_c_check_header_mongrel "$LINENO" "i2c/smbus.h" "ac_cv_header_i2c_smbus_h" "$ac_includes_default" +if test "x$ac_cv_header_i2c_smbus_h" = xyes; then : + +$as_echo "#define HAVE_LINUX_SMBUS_H 1" >>confdefs.h + + +fi + + + ac_fn_c_check_decl "$LINENO" "i2c_smbus_access" "ac_cv_have_decl_i2c_smbus_access" "#include + #ifdef HAVE_LINUX_I2C_DEV_H #include + #endif + #ifdef HAVE_LINUX_SMBUS_H + #include + #endif + + +" +if test "x$ac_cv_have_decl_i2c_smbus_access" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_I2C_SMBUS_ACCESS $ac_have_decl +_ACEOF +if test $ac_have_decl = 1; then : + +else + if test "${nut_with_linux_i2c}" = "yes"; then : + as_fn_error $? "i2c was required but can not be fulfilled for this build" "$LINENO" 5 +else + nut_with_linux_i2c="no" +fi +fi +ac_fn_c_check_decl "$LINENO" "i2c_smbus_read_byte_data" "ac_cv_have_decl_i2c_smbus_read_byte_data" "#include + #ifdef HAVE_LINUX_I2C_DEV_H + #include + #endif + #ifdef HAVE_LINUX_SMBUS_H + #include + #endif + + +" +if test "x$ac_cv_have_decl_i2c_smbus_read_byte_data" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_I2C_SMBUS_READ_BYTE_DATA $ac_have_decl +_ACEOF +if test $ac_have_decl = 1; then : + +else + if test "${nut_with_linux_i2c}" = "yes"; then : + as_fn_error $? "i2c was required but can not be fulfilled for this build" "$LINENO" 5 +else + nut_with_linux_i2c="no" +fi +fi +ac_fn_c_check_decl "$LINENO" "i2c_smbus_write_byte_data" "ac_cv_have_decl_i2c_smbus_write_byte_data" "#include + #ifdef HAVE_LINUX_I2C_DEV_H + #include + #endif + #ifdef HAVE_LINUX_SMBUS_H + #include + #endif + + +" +if test "x$ac_cv_have_decl_i2c_smbus_write_byte_data" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_I2C_SMBUS_WRITE_BYTE_DATA $ac_have_decl +_ACEOF +if test $ac_have_decl = 1; then : + +else + if test "${nut_with_linux_i2c}" = "yes"; then : + as_fn_error $? "i2c was required but can not be fulfilled for this build" "$LINENO" 5 +else + nut_with_linux_i2c="no" +fi +fi +ac_fn_c_check_decl "$LINENO" "i2c_smbus_read_word_data" "ac_cv_have_decl_i2c_smbus_read_word_data" "#include + #ifdef HAVE_LINUX_I2C_DEV_H + #include + #endif + #ifdef HAVE_LINUX_SMBUS_H + #include + #endif " @@ -10094,12 +21525,21 @@ cat >>confdefs.h <<_ACEOF #define HAVE_DECL_I2C_SMBUS_READ_WORD_DATA $ac_have_decl _ACEOF if test $ac_have_decl = 1; then : - nut_with_linux_i2c="yes" + +else + if test "${nut_with_linux_i2c}" = "yes"; then : + as_fn_error $? "i2c was required but can not be fulfilled for this build" "$LINENO" 5 else nut_with_linux_i2c="no" fi +fi ac_fn_c_check_decl "$LINENO" "i2c_smbus_write_word_data" "ac_cv_have_decl_i2c_smbus_write_word_data" "#include + #ifdef HAVE_LINUX_I2C_DEV_H #include + #endif + #ifdef HAVE_LINUX_SMBUS_H + #include + #endif " @@ -10113,12 +21553,21 @@ cat >>confdefs.h <<_ACEOF #define HAVE_DECL_I2C_SMBUS_WRITE_WORD_DATA $ac_have_decl _ACEOF if test $ac_have_decl = 1; then : - nut_with_linux_i2c="yes" + +else + if test "${nut_with_linux_i2c}" = "yes"; then : + as_fn_error $? "i2c was required but can not be fulfilled for this build" "$LINENO" 5 else nut_with_linux_i2c="no" fi +fi ac_fn_c_check_decl "$LINENO" "i2c_smbus_read_block_data" "ac_cv_have_decl_i2c_smbus_read_block_data" "#include + #ifdef HAVE_LINUX_I2C_DEV_H #include + #endif + #ifdef HAVE_LINUX_SMBUS_H + #include + #endif " @@ -10132,13 +21581,83 @@ cat >>confdefs.h <<_ACEOF #define HAVE_DECL_I2C_SMBUS_READ_BLOCK_DATA $ac_have_decl _ACEOF if test $ac_have_decl = 1; then : + +else + if test "${nut_with_linux_i2c}" = "yes"; then : + as_fn_error $? "i2c was required but can not be fulfilled for this build" "$LINENO" 5 +else + nut_with_linux_i2c="no" +fi +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing i2c_smbus_read_byte, i2c_smbus_access, i2c_smbus_read_byte_data, i2c_smbus_write_byte_datai2c_smbus_write_byte_data, i2c_smbus_read_word_data, i2c_smbus_write_word_data, i2c_smbus_read_block_data" >&5 +$as_echo_n "checking for library containing i2c_smbus_read_byte, i2c_smbus_access, i2c_smbus_read_byte_data, i2c_smbus_write_byte_datai2c_smbus_write_byte_data, i2c_smbus_read_word_data, i2c_smbus_write_word_data, i2c_smbus_read_block_data... " >&6; } +if ${ac_cv_search_i2c_smbus_read_byte__i2c_smbus_access__i2c_smbus_read_byte_data__i2c_smbus_write_byte_datai2c_smbus_write_byte_data__i2c_smbus_read_word_data__i2c_smbus_write_word_data__i2c_smbus_read_block_data+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char i2c_smbus_read_byte, i2c_smbus_access, i2c_smbus_read_byte_data, i2c_smbus_write_byte_datai2c_smbus_write_byte_data, i2c_smbus_read_word_data, i2c_smbus_write_word_data, i2c_smbus_read_block_data (); +int +main () +{ +return i2c_smbus_read_byte, i2c_smbus_access, i2c_smbus_read_byte_data, i2c_smbus_write_byte_datai2c_smbus_write_byte_data, i2c_smbus_read_word_data, i2c_smbus_write_word_data, i2c_smbus_read_block_data (); + ; + return 0; +} +_ACEOF +for ac_lib in '' i2c; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_i2c_smbus_read_byte__i2c_smbus_access__i2c_smbus_read_byte_data__i2c_smbus_write_byte_datai2c_smbus_write_byte_data__i2c_smbus_read_word_data__i2c_smbus_write_word_data__i2c_smbus_read_block_data=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_i2c_smbus_read_byte__i2c_smbus_access__i2c_smbus_read_byte_data__i2c_smbus_write_byte_datai2c_smbus_write_byte_data__i2c_smbus_read_word_data__i2c_smbus_write_word_data__i2c_smbus_read_block_data+:} false; then : + break +fi +done +if ${ac_cv_search_i2c_smbus_read_byte__i2c_smbus_access__i2c_smbus_read_byte_data__i2c_smbus_write_byte_datai2c_smbus_write_byte_data__i2c_smbus_read_word_data__i2c_smbus_write_word_data__i2c_smbus_read_block_data+:} false; then : + +else + ac_cv_search_i2c_smbus_read_byte__i2c_smbus_access__i2c_smbus_read_byte_data__i2c_smbus_write_byte_datai2c_smbus_write_byte_data__i2c_smbus_read_word_data__i2c_smbus_write_word_data__i2c_smbus_read_block_data=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_i2c_smbus_read_byte__i2c_smbus_access__i2c_smbus_read_byte_data__i2c_smbus_write_byte_datai2c_smbus_write_byte_data__i2c_smbus_read_word_data__i2c_smbus_write_word_data__i2c_smbus_read_block_data" >&5 +$as_echo "$ac_cv_search_i2c_smbus_read_byte__i2c_smbus_access__i2c_smbus_read_byte_data__i2c_smbus_write_byte_datai2c_smbus_write_byte_data__i2c_smbus_read_word_data__i2c_smbus_write_word_data__i2c_smbus_read_block_data" >&6; } +ac_res=$ac_cv_search_i2c_smbus_read_byte__i2c_smbus_access__i2c_smbus_read_byte_data__i2c_smbus_write_byte_datai2c_smbus_write_byte_data__i2c_smbus_read_word_data__i2c_smbus_write_word_data__i2c_smbus_read_block_data +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" nut_with_linux_i2c="yes" +else + if test "${nut_with_linux_i2c}" = "yes"; then : + as_fn_error $? "i2c was required but can not be fulfilled for this build" "$LINENO" 5 else nut_with_linux_i2c="no" +fi + fi ;; * ) + if test "${nut_with_linux_i2c}" = yes; then + as_fn_error $? "i2c was required but can not be fulfilled for this build: not linux" "$LINENO" 5 + fi nut_with_linux_i2c="no" ;; esac @@ -10215,23 +21734,284 @@ if test "${nut_with_ssl}" != "no"; then if test -z "${nut_have_libnss_seen}"; then nut_have_libnss_seen=yes +if test -z "${nut_have_pkg_config_seen}"; then : + + nut_have_pkg_config_seen=yes + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG was already detected by autoconf" >&5 +$as_echo_n "checking whether usable PKG_CONFIG was already detected by autoconf... " >&6; } + if test -n "${PKG_CONFIG-}" && test x"${PKG_CONFIG-}" != x"false" && $PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${PKG_CONFIG}" >&5 +$as_echo "yes: ${PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + + if test x"${PKG_CONFIG-}" = x"false"; then : + have_PKG_CONFIG=yes + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_dummy_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $dummy_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_dummy_PKG_CONFIG="$dummy_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_dummy_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +dummy_PKG_CONFIG=$ac_cv_path_dummy_PKG_CONFIG +if test -n "$dummy_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dummy_PKG_CONFIG" >&5 +$as_echo "$dummy_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + +# Check whether --with-pkg-config was given. +if test "${with_pkg_config+set}" = set; then : + withval=$with_pkg_config; + case "${withval}" in + "") ;; + yes|no) + as_fn_error $? "invalid option --with(out)-pkg-config - see docs/configure.txt" "$LINENO" 5 + ;; + *) + dummy_PKG_CONFIG="${withval}" + ;; + esac + +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG is present in PATH or was set by caller" >&5 +$as_echo_n "checking whether usable PKG_CONFIG is present in PATH or was set by caller... " >&6; } + if test x"$dummy_PKG_CONFIG" = xno || test -z "$dummy_PKG_CONFIG"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + +else + if $dummy_PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${dummy_PKG_CONFIG}" >&5 +$as_echo "yes: ${dummy_PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + PKG_CONFIG="$dummy_PKG_CONFIG" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + +fi + +fi + + have_PKG_CONFIG_MACROS=no + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&6;} + dummy_RES=0 + + + if test "${dummy_RES}" = 0; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config module checker" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config module checker" >&6;} + + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pkg-config" >&5 +$as_echo_n "checking for pkg-config... " >&6; } + +if test -n "$dummy_PKG_CONFIG_CFLAGS"; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS="$dummy_PKG_CONFIG_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS=`$PKG_CONFIG --cflags "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$dummy_PKG_CONFIG_LIBS"; then + pkg_cv_dummy_PKG_CONFIG_LIBS="$dummy_PKG_CONFIG_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_LIBS=`$PKG_CONFIG --libs "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "pkg-config" 2>&1` + else + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "pkg-config" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$dummy_PKG_CONFIG_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (pkg-config) were not met: + +$dummy_PKG_CONFIG_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + dummy_PKG_CONFIG_CFLAGS=$pkg_cv_dummy_PKG_CONFIG_CFLAGS + dummy_PKG_CONFIG_LIBS=$pkg_cv_dummy_PKG_CONFIG_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + have_PKG_CONFIG_MACROS=yes +fi + + +fi + +fi + + if test x"$have_PKG_CONFIG" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&5 +$as_echo "$as_me: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&2;} + PKG_CONFIG="false" + +else + if test x"$have_PKG_CONFIG_MACROS" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&5 +$as_echo "$as_me: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&2;} + +fi + +fi + + +fi + CFLAGS_ORIG="${CFLAGS}" LIBS_ORIG="${LIBS}" + REQUIRES_ORIG="${REQUIRES}" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mozilla NSS version via pkg-config" >&5 -$as_echo_n "checking for Mozilla NSS version via pkg-config... " >&6; } - NSS_VERSION="`pkg-config --silence-errors --modversion nss 2>/dev/null`" - if test "$?" = "0" -a -n "${NSS_VERSION}"; then - CFLAGS="`pkg-config --silence-errors --cflags nss 2>/dev/null`" - LIBS="`pkg-config --silence-errors --libs nss 2>/dev/null`" - else - NSS_VERSION="none" - CFLAGS="" - LIBS="-lnss3 -lnssutil3 -lsmime3 -lssl3 -lplds4 -lplc4 -lnspr4" + SAVED_GCC="$GCC" + SAVED_CC="$CC" + if ( test "${GCC}" = "yes" ) + then + case "$CFLAGS$LDFLAGS" in + *-m32*) CC="$CC -m32" ;; + *-m64*) CC="$CC -m64" ;; + esac fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${NSS_VERSION} found" >&5 + + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mozilla NSS version via pkg-config" >&5 +$as_echo_n "checking for Mozilla NSS version via pkg-config... " >&6; } + NSS_VERSION="`$PKG_CONFIG --silence-errors --modversion nss 2>/dev/null`" + if test "$?" != "0" -o -z "${NSS_VERSION}"; then + NSS_VERSION="none" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${NSS_VERSION} found" >&5 $as_echo "${NSS_VERSION} found" >&6; } +else + NSS_VERSION="none" + { $as_echo "$as_me:${as_lineno-$LINENO}: can not check libnss settings via pkg-config" >&5 +$as_echo "$as_me: can not check libnss settings via pkg-config" >&6;} + + +fi + + if test x"$NSS_VERSION" != xnone; then : + CFLAGS="`$PKG_CONFIG --silence-errors --cflags nss 2>/dev/null`" + LIBS="`$PKG_CONFIG --silence-errors --libs nss 2>/dev/null`" + REQUIRES="nss" + +else + CFLAGS="" + LIBS="-lnss3 -lnssutil3 -lsmime3 -lssl3 -lplds4 -lplc4 -lnspr4" + REQUIRES="nss" + + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mozilla NSS cflags" >&5 $as_echo_n "checking for Mozilla NSS cflags... " >&6; } @@ -10272,7 +22052,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${LIBS}" >&5 $as_echo "${LIBS}" >&6; } - for ac_func in NSS_Init + for ac_func in NSS_Init do : ac_fn_c_check_func "$LINENO" "NSS_Init" "ac_cv_func_NSS_Init" if test "x$ac_cv_func_NSS_Init" = xyes; then : @@ -10313,37 +22093,292 @@ $as_echo "#define WITH_NSS 1" >>confdefs.h LIBSSL_CFLAGS="${CFLAGS}" LIBSSL_LIBS="${LIBS}" + LIBSSL_REQUIRES="${REQUIRES}" fi CFLAGS="${CFLAGS_ORIG}" LIBS="${LIBS_ORIG}" + REQUIRES="${REQUIRES_ORIG}" + GCC="$SAVED_GCC" + CC="$SAVED_CC" fi if test "${nut_have_libnss}" != "yes"; then - as_fn_error $? "\"Mozilla NSS not found, required for SSL support\"" "$LINENO" 5 + as_fn_error $? "Mozilla NSS not found (required for SSL support)" "$LINENO" 5 fi elif test "${nut_with_openssl}" = "yes"; then if test -z "${nut_have_libopenssl_seen}"; then nut_have_libopenssl_seen=yes +if test -z "${nut_have_pkg_config_seen}"; then : + + nut_have_pkg_config_seen=yes + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG was already detected by autoconf" >&5 +$as_echo_n "checking whether usable PKG_CONFIG was already detected by autoconf... " >&6; } + if test -n "${PKG_CONFIG-}" && test x"${PKG_CONFIG-}" != x"false" && $PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${PKG_CONFIG}" >&5 +$as_echo "yes: ${PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + + if test x"${PKG_CONFIG-}" = x"false"; then : + have_PKG_CONFIG=yes + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_dummy_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $dummy_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_dummy_PKG_CONFIG="$dummy_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_dummy_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +dummy_PKG_CONFIG=$ac_cv_path_dummy_PKG_CONFIG +if test -n "$dummy_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dummy_PKG_CONFIG" >&5 +$as_echo "$dummy_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + +# Check whether --with-pkg-config was given. +if test "${with_pkg_config+set}" = set; then : + withval=$with_pkg_config; + case "${withval}" in + "") ;; + yes|no) + as_fn_error $? "invalid option --with(out)-pkg-config - see docs/configure.txt" "$LINENO" 5 + ;; + *) + dummy_PKG_CONFIG="${withval}" + ;; + esac + +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG is present in PATH or was set by caller" >&5 +$as_echo_n "checking whether usable PKG_CONFIG is present in PATH or was set by caller... " >&6; } + if test x"$dummy_PKG_CONFIG" = xno || test -z "$dummy_PKG_CONFIG"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + +else + if $dummy_PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${dummy_PKG_CONFIG}" >&5 +$as_echo "yes: ${dummy_PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + PKG_CONFIG="$dummy_PKG_CONFIG" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + +fi + +fi + + have_PKG_CONFIG_MACROS=no + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&6;} + dummy_RES=0 + + + if test "${dummy_RES}" = 0; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config module checker" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config module checker" >&6;} + + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pkg-config" >&5 +$as_echo_n "checking for pkg-config... " >&6; } + +if test -n "$dummy_PKG_CONFIG_CFLAGS"; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS="$dummy_PKG_CONFIG_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS=`$PKG_CONFIG --cflags "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$dummy_PKG_CONFIG_LIBS"; then + pkg_cv_dummy_PKG_CONFIG_LIBS="$dummy_PKG_CONFIG_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_LIBS=`$PKG_CONFIG --libs "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "pkg-config" 2>&1` + else + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "pkg-config" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$dummy_PKG_CONFIG_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (pkg-config) were not met: + +$dummy_PKG_CONFIG_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + dummy_PKG_CONFIG_CFLAGS=$pkg_cv_dummy_PKG_CONFIG_CFLAGS + dummy_PKG_CONFIG_LIBS=$pkg_cv_dummy_PKG_CONFIG_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + have_PKG_CONFIG_MACROS=yes +fi + + +fi + +fi + + if test x"$have_PKG_CONFIG" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&5 +$as_echo "$as_me: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&2;} + PKG_CONFIG="false" + +else + if test x"$have_PKG_CONFIG_MACROS" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&5 +$as_echo "$as_me: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&2;} + +fi + +fi + + +fi + CFLAGS_ORIG="${CFLAGS}" LIBS_ORIG="${LIBS}" + REQUIRES_ORIG="${REQUIRES}" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenSSL version via pkg-config" >&5 + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenSSL version via pkg-config" >&5 $as_echo_n "checking for OpenSSL version via pkg-config... " >&6; } - OPENSSL_VERSION="`pkg-config --silence-errors --modversion openssl 2>/dev/null`" - if test "$?" = "0" -a -n "${OPENSSL_VERSION}"; then - CFLAGS="`pkg-config --silence-errors --cflags openssl 2>/dev/null`" - LIBS="`pkg-config --silence-errors --libs openssl 2>/dev/null`" - else - OPENSSL_VERSION="none" - CFLAGS="" - LIBS="-lssl -lcrypto" - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${OPENSSL_VERSION} found" >&5 + OPENSSL_VERSION="`$PKG_CONFIG --silence-errors --modversion openssl 2>/dev/null`" + if test "$?" != "0" -o -z "${OPENSSL_VERSION}"; then + OPENSSL_VERSION="none" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${OPENSSL_VERSION} found" >&5 $as_echo "${OPENSSL_VERSION} found" >&6; } +else + OPENSSL_VERSION="none" + { $as_echo "$as_me:${as_lineno-$LINENO}: can not check OpenSSL settings via pkg-config" >&5 +$as_echo "$as_me: can not check OpenSSL settings via pkg-config" >&6;} + + +fi + + if test x"$OPENSSL_VERSION" != xnone; then : + CFLAGS="`$PKG_CONFIG --silence-errors --cflags openssl 2>/dev/null`" + LIBS="`$PKG_CONFIG --silence-errors --libs openssl 2>/dev/null`" + REQUIRES="openssl" + +else + CFLAGS="" + LIBS="-lssl -lcrypto" + REQUIRES="openssl" + + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenSSL cflags" >&5 $as_echo_n "checking for OpenSSL cflags... " >&6; } @@ -10399,12 +22434,12 @@ fi done - for ac_func in SSL_library_init + for ac_func in SSL_CTX_new do : - ac_fn_c_check_func "$LINENO" "SSL_library_init" "ac_cv_func_SSL_library_init" -if test "x$ac_cv_func_SSL_library_init" = xyes; then : + ac_fn_c_check_func "$LINENO" "SSL_CTX_new" "ac_cv_func_SSL_CTX_new" +if test "x$ac_cv_func_SSL_CTX_new" = xyes; then : cat >>confdefs.h <<_ACEOF -#define HAVE_SSL_LIBRARY_INIT 1 +#define HAVE_SSL_CTX_NEW 1 _ACEOF else @@ -10424,37 +22459,290 @@ $as_echo "#define WITH_OPENSSL 1" >>confdefs.h LIBSSL_CFLAGS="${CFLAGS}" LIBSSL_LIBS="${LIBS}" + LIBSSL_REQUIRES="${REQUIRES}" fi CFLAGS="${CFLAGS_ORIG}" LIBS="${LIBS_ORIG}" + REQUIRES="${REQUIRES_ORIG}" fi if test "${nut_have_openssl}" != "yes"; then - as_fn_error $? "\"OpenSSL not found, required for SSL support\"" "$LINENO" 5 + as_fn_error $? "OpenSSL not found (required for SSL support)" "$LINENO" 5 fi else if test -z "${nut_have_libopenssl_seen}"; then nut_have_libopenssl_seen=yes +if test -z "${nut_have_pkg_config_seen}"; then : + + nut_have_pkg_config_seen=yes + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG was already detected by autoconf" >&5 +$as_echo_n "checking whether usable PKG_CONFIG was already detected by autoconf... " >&6; } + if test -n "${PKG_CONFIG-}" && test x"${PKG_CONFIG-}" != x"false" && $PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${PKG_CONFIG}" >&5 +$as_echo "yes: ${PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + + if test x"${PKG_CONFIG-}" = x"false"; then : + have_PKG_CONFIG=yes + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_dummy_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $dummy_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_dummy_PKG_CONFIG="$dummy_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_dummy_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +dummy_PKG_CONFIG=$ac_cv_path_dummy_PKG_CONFIG +if test -n "$dummy_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dummy_PKG_CONFIG" >&5 +$as_echo "$dummy_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + +# Check whether --with-pkg-config was given. +if test "${with_pkg_config+set}" = set; then : + withval=$with_pkg_config; + case "${withval}" in + "") ;; + yes|no) + as_fn_error $? "invalid option --with(out)-pkg-config - see docs/configure.txt" "$LINENO" 5 + ;; + *) + dummy_PKG_CONFIG="${withval}" + ;; + esac + +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG is present in PATH or was set by caller" >&5 +$as_echo_n "checking whether usable PKG_CONFIG is present in PATH or was set by caller... " >&6; } + if test x"$dummy_PKG_CONFIG" = xno || test -z "$dummy_PKG_CONFIG"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + +else + if $dummy_PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${dummy_PKG_CONFIG}" >&5 +$as_echo "yes: ${dummy_PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + PKG_CONFIG="$dummy_PKG_CONFIG" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + +fi + +fi + + have_PKG_CONFIG_MACROS=no + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&6;} + dummy_RES=0 + + + if test "${dummy_RES}" = 0; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config module checker" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config module checker" >&6;} + + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pkg-config" >&5 +$as_echo_n "checking for pkg-config... " >&6; } + +if test -n "$dummy_PKG_CONFIG_CFLAGS"; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS="$dummy_PKG_CONFIG_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS=`$PKG_CONFIG --cflags "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$dummy_PKG_CONFIG_LIBS"; then + pkg_cv_dummy_PKG_CONFIG_LIBS="$dummy_PKG_CONFIG_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_LIBS=`$PKG_CONFIG --libs "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "pkg-config" 2>&1` + else + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "pkg-config" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$dummy_PKG_CONFIG_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (pkg-config) were not met: + +$dummy_PKG_CONFIG_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + dummy_PKG_CONFIG_CFLAGS=$pkg_cv_dummy_PKG_CONFIG_CFLAGS + dummy_PKG_CONFIG_LIBS=$pkg_cv_dummy_PKG_CONFIG_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + have_PKG_CONFIG_MACROS=yes +fi + + +fi + +fi + + if test x"$have_PKG_CONFIG" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&5 +$as_echo "$as_me: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&2;} + PKG_CONFIG="false" + +else + if test x"$have_PKG_CONFIG_MACROS" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&5 +$as_echo "$as_me: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&2;} + +fi + +fi + + +fi + CFLAGS_ORIG="${CFLAGS}" LIBS_ORIG="${LIBS}" + REQUIRES_ORIG="${REQUIRES}" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenSSL version via pkg-config" >&5 + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenSSL version via pkg-config" >&5 $as_echo_n "checking for OpenSSL version via pkg-config... " >&6; } - OPENSSL_VERSION="`pkg-config --silence-errors --modversion openssl 2>/dev/null`" - if test "$?" = "0" -a -n "${OPENSSL_VERSION}"; then - CFLAGS="`pkg-config --silence-errors --cflags openssl 2>/dev/null`" - LIBS="`pkg-config --silence-errors --libs openssl 2>/dev/null`" - else - OPENSSL_VERSION="none" - CFLAGS="" - LIBS="-lssl -lcrypto" - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${OPENSSL_VERSION} found" >&5 + OPENSSL_VERSION="`$PKG_CONFIG --silence-errors --modversion openssl 2>/dev/null`" + if test "$?" != "0" -o -z "${OPENSSL_VERSION}"; then + OPENSSL_VERSION="none" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${OPENSSL_VERSION} found" >&5 $as_echo "${OPENSSL_VERSION} found" >&6; } +else + OPENSSL_VERSION="none" + { $as_echo "$as_me:${as_lineno-$LINENO}: can not check OpenSSL settings via pkg-config" >&5 +$as_echo "$as_me: can not check OpenSSL settings via pkg-config" >&6;} + + +fi + + if test x"$OPENSSL_VERSION" != xnone; then : + CFLAGS="`$PKG_CONFIG --silence-errors --cflags openssl 2>/dev/null`" + LIBS="`$PKG_CONFIG --silence-errors --libs openssl 2>/dev/null`" + REQUIRES="openssl" + +else + CFLAGS="" + LIBS="-lssl -lcrypto" + REQUIRES="openssl" + + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenSSL cflags" >&5 $as_echo_n "checking for OpenSSL cflags... " >&6; } @@ -10510,12 +22798,12 @@ fi done - for ac_func in SSL_library_init + for ac_func in SSL_CTX_new do : - ac_fn_c_check_func "$LINENO" "SSL_library_init" "ac_cv_func_SSL_library_init" -if test "x$ac_cv_func_SSL_library_init" = xyes; then : + ac_fn_c_check_func "$LINENO" "SSL_CTX_new" "ac_cv_func_SSL_CTX_new" +if test "x$ac_cv_func_SSL_CTX_new" = xyes; then : cat >>confdefs.h <<_ACEOF -#define HAVE_SSL_LIBRARY_INIT 1 +#define HAVE_SSL_CTX_NEW 1 _ACEOF else @@ -10535,10 +22823,12 @@ $as_echo "#define WITH_OPENSSL 1" >>confdefs.h LIBSSL_CFLAGS="${CFLAGS}" LIBSSL_LIBS="${LIBS}" + LIBSSL_REQUIRES="${REQUIRES}" fi CFLAGS="${CFLAGS_ORIG}" LIBS="${LIBS_ORIG}" + REQUIRES="${REQUIRES_ORIG}" fi if test "${nut_have_openssl}" != "yes"; then @@ -10546,23 +22836,284 @@ fi if test -z "${nut_have_libnss_seen}"; then nut_have_libnss_seen=yes +if test -z "${nut_have_pkg_config_seen}"; then : + + nut_have_pkg_config_seen=yes + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG was already detected by autoconf" >&5 +$as_echo_n "checking whether usable PKG_CONFIG was already detected by autoconf... " >&6; } + if test -n "${PKG_CONFIG-}" && test x"${PKG_CONFIG-}" != x"false" && $PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${PKG_CONFIG}" >&5 +$as_echo "yes: ${PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + + if test x"${PKG_CONFIG-}" = x"false"; then : + have_PKG_CONFIG=yes + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_dummy_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $dummy_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_dummy_PKG_CONFIG="$dummy_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_dummy_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +dummy_PKG_CONFIG=$ac_cv_path_dummy_PKG_CONFIG +if test -n "$dummy_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dummy_PKG_CONFIG" >&5 +$as_echo "$dummy_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + +# Check whether --with-pkg-config was given. +if test "${with_pkg_config+set}" = set; then : + withval=$with_pkg_config; + case "${withval}" in + "") ;; + yes|no) + as_fn_error $? "invalid option --with(out)-pkg-config - see docs/configure.txt" "$LINENO" 5 + ;; + *) + dummy_PKG_CONFIG="${withval}" + ;; + esac + +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG is present in PATH or was set by caller" >&5 +$as_echo_n "checking whether usable PKG_CONFIG is present in PATH or was set by caller... " >&6; } + if test x"$dummy_PKG_CONFIG" = xno || test -z "$dummy_PKG_CONFIG"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + +else + if $dummy_PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${dummy_PKG_CONFIG}" >&5 +$as_echo "yes: ${dummy_PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + PKG_CONFIG="$dummy_PKG_CONFIG" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + +fi + +fi + + have_PKG_CONFIG_MACROS=no + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&6;} + dummy_RES=0 + + + if test "${dummy_RES}" = 0; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config module checker" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config module checker" >&6;} + + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pkg-config" >&5 +$as_echo_n "checking for pkg-config... " >&6; } + +if test -n "$dummy_PKG_CONFIG_CFLAGS"; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS="$dummy_PKG_CONFIG_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS=`$PKG_CONFIG --cflags "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$dummy_PKG_CONFIG_LIBS"; then + pkg_cv_dummy_PKG_CONFIG_LIBS="$dummy_PKG_CONFIG_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_LIBS=`$PKG_CONFIG --libs "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "pkg-config" 2>&1` + else + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "pkg-config" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$dummy_PKG_CONFIG_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (pkg-config) were not met: + +$dummy_PKG_CONFIG_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + dummy_PKG_CONFIG_CFLAGS=$pkg_cv_dummy_PKG_CONFIG_CFLAGS + dummy_PKG_CONFIG_LIBS=$pkg_cv_dummy_PKG_CONFIG_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + have_PKG_CONFIG_MACROS=yes +fi + + +fi + +fi + + if test x"$have_PKG_CONFIG" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&5 +$as_echo "$as_me: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&2;} + PKG_CONFIG="false" + +else + if test x"$have_PKG_CONFIG_MACROS" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&5 +$as_echo "$as_me: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&2;} + +fi + +fi + + +fi + CFLAGS_ORIG="${CFLAGS}" LIBS_ORIG="${LIBS}" + REQUIRES_ORIG="${REQUIRES}" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mozilla NSS version via pkg-config" >&5 -$as_echo_n "checking for Mozilla NSS version via pkg-config... " >&6; } - NSS_VERSION="`pkg-config --silence-errors --modversion nss 2>/dev/null`" - if test "$?" = "0" -a -n "${NSS_VERSION}"; then - CFLAGS="`pkg-config --silence-errors --cflags nss 2>/dev/null`" - LIBS="`pkg-config --silence-errors --libs nss 2>/dev/null`" - else - NSS_VERSION="none" - CFLAGS="" - LIBS="-lnss3 -lnssutil3 -lsmime3 -lssl3 -lplds4 -lplc4 -lnspr4" + SAVED_GCC="$GCC" + SAVED_CC="$CC" + if ( test "${GCC}" = "yes" ) + then + case "$CFLAGS$LDFLAGS" in + *-m32*) CC="$CC -m32" ;; + *-m64*) CC="$CC -m64" ;; + esac fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${NSS_VERSION} found" >&5 + + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mozilla NSS version via pkg-config" >&5 +$as_echo_n "checking for Mozilla NSS version via pkg-config... " >&6; } + NSS_VERSION="`$PKG_CONFIG --silence-errors --modversion nss 2>/dev/null`" + if test "$?" != "0" -o -z "${NSS_VERSION}"; then + NSS_VERSION="none" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${NSS_VERSION} found" >&5 $as_echo "${NSS_VERSION} found" >&6; } +else + NSS_VERSION="none" + { $as_echo "$as_me:${as_lineno-$LINENO}: can not check libnss settings via pkg-config" >&5 +$as_echo "$as_me: can not check libnss settings via pkg-config" >&6;} + + +fi + + if test x"$NSS_VERSION" != xnone; then : + CFLAGS="`$PKG_CONFIG --silence-errors --cflags nss 2>/dev/null`" + LIBS="`$PKG_CONFIG --silence-errors --libs nss 2>/dev/null`" + REQUIRES="nss" + +else + CFLAGS="" + LIBS="-lnss3 -lnssutil3 -lsmime3 -lssl3 -lplds4 -lplc4 -lnspr4" + REQUIRES="nss" + + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mozilla NSS cflags" >&5 $as_echo_n "checking for Mozilla NSS cflags... " >&6; } @@ -10603,7 +23154,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${LIBS}" >&5 $as_echo "${LIBS}" >&6; } - for ac_func in NSS_Init + for ac_func in NSS_Init do : ac_fn_c_check_func "$LINENO" "NSS_Init" "ac_cv_func_NSS_Init" if test "x$ac_cv_func_NSS_Init" = xyes; then : @@ -10644,18 +23195,22 @@ $as_echo "#define WITH_NSS 1" >>confdefs.h LIBSSL_CFLAGS="${CFLAGS}" LIBSSL_LIBS="${LIBS}" + LIBSSL_REQUIRES="${REQUIRES}" fi CFLAGS="${CFLAGS_ORIG}" LIBS="${LIBS_ORIG}" + REQUIRES="${REQUIRES_ORIG}" + GCC="$SAVED_GCC" + CC="$SAVED_CC" fi if test "${nut_have_libnss}" != "yes"; then if test "${nut_with_ssl}" = "yes"; then - as_fn_error $? "\"Mozilla NSS and OpenSSL neither found, but are needed for the requested SSL support\"" "$LINENO" 5 + as_fn_error $? "Neither Mozilla NSS nor OpenSSL was found, but one is needed for the requested SSL support." "$LINENO" 5 else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"Mozilla NSS and OpenSSL neither found, required for SSL support\"" >&5 -$as_echo "$as_me: WARNING: \"Mozilla NSS and OpenSSL neither found, required for SSL support\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Neither Mozilla NSS nor OpenSSL was found (required for SSL support)" >&5 +$as_echo "$as_me: WARNING: Neither Mozilla NSS nor OpenSSL was found (required for SSL support)" >&2;} fi nut_with_ssl="no" else @@ -10812,6 +23367,12 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing request_init" >&5 $as_echo_n "checking for library containing request_init... " >&6; } + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -10866,6 +23427,12 @@ rm -f core conftest.err conftest.$ac_objext \ fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + if test "${nut_have_libwrap}" = "yes"; then @@ -10881,7 +23448,7 @@ fi fi if test "${nut_with_wrap}" = "yes" -a "${nut_have_libwrap}" != "yes"; then - as_fn_error $? "\"libwrap not found\"" "$LINENO" 5 + as_fn_error $? "libwrap not found" "$LINENO" 5 fi if test "${nut_with_wrap}" != "no"; then @@ -11069,7 +23636,7 @@ fi fi if test "${nut_with_libltdl}" = "yes" -a "${nut_have_libltdl}" != "yes"; then - as_fn_error $? "\"libltdl not found\"" "$LINENO" 5 + as_fn_error $? "libltdl not found" "$LINENO" 5 fi if test "${nut_with_libltdl}" != "no"; then @@ -11135,38 +23702,369 @@ if test "${nut_with_cgi}" != "no"; then if test -z "${nut_have_libgd_seen}"; then nut_have_libgd_seen=yes +if test -z "${nut_have_pkg_config_seen}"; then : + + nut_have_pkg_config_seen=yes + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG was already detected by autoconf" >&5 +$as_echo_n "checking whether usable PKG_CONFIG was already detected by autoconf... " >&6; } + if test -n "${PKG_CONFIG-}" && test x"${PKG_CONFIG-}" != x"false" && $PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${PKG_CONFIG}" >&5 +$as_echo "yes: ${PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + + if test x"${PKG_CONFIG-}" = x"false"; then : + have_PKG_CONFIG=yes + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_dummy_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $dummy_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_dummy_PKG_CONFIG="$dummy_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_dummy_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +dummy_PKG_CONFIG=$ac_cv_path_dummy_PKG_CONFIG +if test -n "$dummy_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dummy_PKG_CONFIG" >&5 +$as_echo "$dummy_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + +# Check whether --with-pkg-config was given. +if test "${with_pkg_config+set}" = set; then : + withval=$with_pkg_config; + case "${withval}" in + "") ;; + yes|no) + as_fn_error $? "invalid option --with(out)-pkg-config - see docs/configure.txt" "$LINENO" 5 + ;; + *) + dummy_PKG_CONFIG="${withval}" + ;; + esac + +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether usable PKG_CONFIG is present in PATH or was set by caller" >&5 +$as_echo_n "checking whether usable PKG_CONFIG is present in PATH or was set by caller... " >&6; } + if test x"$dummy_PKG_CONFIG" = xno || test -z "$dummy_PKG_CONFIG"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + +else + if $dummy_PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes: ${dummy_PKG_CONFIG}" >&5 +$as_echo "yes: ${dummy_PKG_CONFIG}" >&6; } + have_PKG_CONFIG=yes + PKG_CONFIG="$dummy_PKG_CONFIG" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=false + have_PKG_CONFIG=no + + +fi + +fi + +fi + + have_PKG_CONFIG_MACROS=no + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config (${PKG_CONFIG})" >&6;} + dummy_RES=0 + + + if test "${dummy_RES}" = 0; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autoconf macro support of pkg-config module checker" >&5 +$as_echo "$as_me: checking for autoconf macro support of pkg-config module checker" >&6;} + + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pkg-config" >&5 +$as_echo_n "checking for pkg-config... " >&6; } + +if test -n "$dummy_PKG_CONFIG_CFLAGS"; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS="$dummy_PKG_CONFIG_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_CFLAGS=`$PKG_CONFIG --cflags "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$dummy_PKG_CONFIG_LIBS"; then + pkg_cv_dummy_PKG_CONFIG_LIBS="$dummy_PKG_CONFIG_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pkg-config\""; } >&5 + ($PKG_CONFIG --exists --print-errors "pkg-config") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_dummy_PKG_CONFIG_LIBS=`$PKG_CONFIG --libs "pkg-config" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "pkg-config" 2>&1` + else + dummy_PKG_CONFIG_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "pkg-config" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$dummy_PKG_CONFIG_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (pkg-config) were not met: + +$dummy_PKG_CONFIG_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables dummy_PKG_CONFIG_CFLAGS +and dummy_PKG_CONFIG_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + dummy_PKG_CONFIG_CFLAGS=$pkg_cv_dummy_PKG_CONFIG_CFLAGS + dummy_PKG_CONFIG_LIBS=$pkg_cv_dummy_PKG_CONFIG_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + have_PKG_CONFIG_MACROS=yes +fi + + +fi + +fi + + if test x"$have_PKG_CONFIG" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&5 +$as_echo "$as_me: WARNING: pkg-config program is needed to look for further dependencies (will be skipped)" >&2;} + PKG_CONFIG="false" + +else + if test x"$have_PKG_CONFIG_MACROS" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&5 +$as_echo "$as_me: WARNING: pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly" >&2;} + +fi + +fi + + +fi + CFLAGS_ORIG="${CFLAGS}" LDFLAGS_ORIG="${LDFLAGS}" LIBS_ORIG="${LIBS}" + CFLAGS="" + LDFLAGS="" + LIBS="" - CFLAGS="" - LDFLAGS="-L/usr/X11R6/lib" - LIBS="-lgd -lpng -lz -ljpeg -lfreetype -lm -lXpm -lX11" - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gd version via gdlib-config" >&5 -$as_echo_n "checking for gd version via gdlib-config... " >&6; } - GD_VERSION=`gdlib-config --version 2>/dev/null` - if test "$?" != "0" -o -z "${GD_VERSION}"; then - GD_VERSION="none" - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${GD_VERSION} found" >&5 + if test x"$have_PKG_CONFIG" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gd version via pkg-config" >&5 +$as_echo_n "checking for gd version via pkg-config... " >&6; } + GD_VERSION="`$PKG_CONFIG --silence-errors --modversion gdlib 2>/dev/null`" + if test "$?" != "0" -o -z "${GD_VERSION}"; then + GD_VERSION="none" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${GD_VERSION} found" >&5 $as_echo "${GD_VERSION} found" >&6; } - case "${GD_VERSION}" in - none) - ;; - 2.0.5 | 2.0.6 | 2.0.7) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: gd ${GD_VERSION} detected, unable to use gdlib-config script" >&5 -$as_echo "$as_me: WARNING: gd ${GD_VERSION} detected, unable to use gdlib-config script" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: If gd detection fails, upgrade gd or use --with-gd-includes and --with-gd-libs" >&5 +else + GD_VERSION="none" + { $as_echo "$as_me:${as_lineno-$LINENO}: can not check libgd settings via pkg-config" >&5 +$as_echo "$as_me: can not check libgd settings via pkg-config" >&6;} + + +fi + + if test x"$GD_VERSION" != xnone; then : + CFLAGS="`$PKG_CONFIG --silence-errors --cflags gdlib 2>/dev/null`" + LIBS="`$PKG_CONFIG --silence-errors --libs gdlib 2>/dev/null`" + +else + CFLAGS="" + LDFLAGS="-L/usr/X11R6/lib" + LIBS="-lgd -lpng -lz -ljpeg -lfreetype -lm -lXpm -lX11" + + for ac_prog in gdlib-config +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_GDLIB_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $GDLIB_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_GDLIB_CONFIG="$GDLIB_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_GDLIB_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +GDLIB_CONFIG=$ac_cv_path_GDLIB_CONFIG +if test -n "$GDLIB_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GDLIB_CONFIG" >&5 +$as_echo "$GDLIB_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$GDLIB_CONFIG" && break +done +test -n "$GDLIB_CONFIG" || GDLIB_CONFIG="none" + + +# Check whether --with-gdlib-config was given. +if test "${with_gdlib_config+set}" = set; then : + withval=$with_gdlib_config; + case "${withval}" in + "") ;; + yes|no) + as_fn_error $? "invalid option --with(out)-gdlib-config - see docs/configure.txt" "$LINENO" 5 + ;; + *) + GDLIB_CONFIG="${withval}" + ;; + esac + +fi + + + if test x"$GDLIB_CONFIG" != xnone; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gd version via ${GDLIB_CONFIG}" >&5 +$as_echo_n "checking for gd version via ${GDLIB_CONFIG}... " >&6; } + GD_VERSION="`${GDLIB_CONFIG} --version 2>/dev/null`" + if test "$?" != "0" -o -z "${GD_VERSION}"; then + GD_VERSION="none" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${GD_VERSION} found" >&5 +$as_echo "${GD_VERSION} found" >&6; } + +else + GD_VERSION="none" + +fi + + case "${GD_VERSION}" in + none) + ;; + 2.0.5 | 2.0.6 | 2.0.7) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: gd ${GD_VERSION} detected, unable to use ${GDLIB_CONFIG} script" >&5 +$as_echo "$as_me: WARNING: gd ${GD_VERSION} detected, unable to use ${GDLIB_CONFIG} script" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: If gd detection fails, upgrade gd or use --with-gd-includes and --with-gd-libs" >&5 $as_echo "$as_me: WARNING: If gd detection fails, upgrade gd or use --with-gd-includes and --with-gd-libs" >&2;} - ;; - *) - CFLAGS="`gdlib-config --includes 2>/dev/null`" - LDFLAGS="`gdlib-config --ldflags 2>/dev/null`" - LIBS="`gdlib-config --libs 2>/dev/null`" - ;; - esac + ;; + *) + CFLAGS="`${GDLIB_CONFIG} --includes 2>/dev/null`" + LDFLAGS="`${GDLIB_CONFIG} --ldflags 2>/dev/null`" + LIBS="`${GDLIB_CONFIG} --libs 2>/dev/null`" + ;; + esac + + +fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gd include flags" >&5 $as_echo_n "checking for gd include flags... " >&6; } @@ -11280,7 +24178,86 @@ if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" else + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for more gd library flags" >&5 +$as_echo_n "checking for more gd library flags... " >&6; } + if test -n "${with_gd_libs}" || test x"$have_PKG_CONFIG" != xyes; then : nut_have_libgd=no +else + + _LIBS_PRIVATE="`$PKG_CONFIG --silence-errors --libs gdlib --static 2>/dev/null`" + if test -z "${_LIBS_PRIVATE}"; then : + nut_have_libgd=no +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking with gdlib.pc Libs.private" >&5 +$as_echo_n "checking with gdlib.pc Libs.private... " >&6; } + LDFLAGS="$LDFLAGS $_LIBS_PRIVATE" + unset ac_cv_search_gdImagePng + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gdImagePng" >&5 +$as_echo_n "checking for library containing gdImagePng... " >&6; } +if ${ac_cv_search_gdImagePng+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char gdImagePng (); +int +main () +{ +return gdImagePng (); + ; + return 0; +} +_ACEOF +for ac_lib in '' gd; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_gdImagePng=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_gdImagePng+:} false; then : + break +fi +done +if ${ac_cv_search_gdImagePng+:} false; then : + +else + ac_cv_search_gdImagePng=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gdImagePng" >&5 +$as_echo "$ac_cv_search_gdImagePng" >&6; } +ac_res=$ac_cv_search_gdImagePng +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +else + nut_have_libgd=no +fi + + +fi + unset _LIBS_PRIVATE + +fi + fi @@ -11341,10 +24318,200 @@ _ACEOF + # Check whether --enable-cppcheck was given. +if test "${enable_cppcheck+set}" = set; then : + enableval=$enable_cppcheck; nut_enable_cppcheck="${enableval}" +else + nut_enable_cppcheck="no" + +fi + + + +if test -z "${nut_have_cppcheck_seen}"; then + nut_have_cppcheck_seen=yes + CPPCHECK_MIN_VERSION="1.0" + + for ac_prog in cppcheck +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_CPPCHECK+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $CPPCHECK in + [\\/]* | ?:[\\/]*) + ac_cv_path_CPPCHECK="$CPPCHECK" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_CPPCHECK="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +CPPCHECK=$ac_cv_path_CPPCHECK +if test -n "$CPPCHECK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPPCHECK" >&5 +$as_echo "$CPPCHECK" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CPPCHECK" && break +done + + if test -n "${CPPCHECK}"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cppcheck version" >&5 +$as_echo_n "checking for cppcheck version... " >&6; } + CPPCHECK_VERSION="`${CPPCHECK} --version 2>/dev/null`" + CPPCHECK_VERSION="${CPPCHECK_VERSION##* }" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${CPPCHECK_VERSION} found" >&5 +$as_echo "${CPPCHECK_VERSION} found" >&6; } + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if cppcheck version is okay (minimum required ${CPPCHECK_MIN_VERSION})" >&5 +$as_echo_n "checking if cppcheck version is okay (minimum required ${CPPCHECK_MIN_VERSION})... " >&6; } + + + + # Used to indicate true or false condition + ax_compare_version=false + + # Convert the two version strings to be compared into a format that + # allows a simple string comparison. The end result is that a version + # string of the form 1.12.5-r617 will be converted to the form + # 0001001200050617. In other words, each number is zero padded to four + # digits, and non digits are removed. + + ax_compare_version_A=`echo "${CPPCHECK_VERSION}" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version_B=`echo "${CPPCHECK_MIN_VERSION}" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version=`echo "x$ax_compare_version_A +x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` + + + + if test "$ax_compare_version" = "true" ; then + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + nut_have_cppcheck="yes" + + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + nut_have_cppcheck="no" + + fi + + + if test "${nut_have_cppcheck}" = "yes"; then + HAVE_CPPCHECK_TRUE= + HAVE_CPPCHECK_FALSE='#' +else + HAVE_CPPCHECK_TRUE='#' + HAVE_CPPCHECK_FALSE= +fi + +fi + + +case "${nut_enable_cppcheck}" in + yes) if test "${nut_have_cppcheck}" = "no" ; then + as_fn_error $? "Requested to --enable-cppcheck but did not find a good one" "$LINENO" 5 + fi + WITH_CPPCHECK=yes + ;; + no) WITH_CPPCHECK=no ;; + auto) if test "${nut_have_cppcheck}" = "yes" ; then + WITH_CPPCHECK=no + else + WITH_CPPCHECK=no + fi + ;; +esac + + if test "${WITH_CPPCHECK}" = "yes"; then + WITH_CPPCHECK_TRUE= + WITH_CPPCHECK_FALSE='#' +else + WITH_CPPCHECK_TRUE='#' + WITH_CPPCHECK_FALSE= +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to run NIT among default make check target" >&5 +$as_echo_n "checking whether to run NIT among default make check target... " >&6; } +nut_enable_check_NIT="no" +# Check whether --enable-check-NIT was given. +if test "${enable_check_NIT+set}" = set; then : + enableval=$enable_check_NIT; + case "${enableval}" in + no) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + nut_enable_check_NIT="yes" + ;; + esac + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi + + + if test "${nut_enable_check_NIT}" = "yes"; then + WITH_CHECK_NIT_TRUE= + WITH_CHECK_NIT_FALSE='#' +else + WITH_CHECK_NIT_TRUE='#' + WITH_CHECK_NIT_FALSE= +fi + + if test -z "${nut_have_asciidoc_seen}"; then nut_have_asciidoc_seen=yes + # Note: this is for both asciidoc and a2x at this time + ASCIIDOC_MIN_VERSION="8.6.3" + # Note: this is checked in the configure script if PDF is of interest at all + DBLATEX_MIN_VERSION="0.2.5" for ac_prog in asciidoc do @@ -11399,6 +24566,14 @@ $as_echo_n "checking for asciiDoc version... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ASCIIDOC_VERSION} found" >&5 $as_echo "${ASCIIDOC_VERSION} found" >&6; } fi + if test -n "${ASCIIDOC}"; then + MANUALUPDATE_TRUE= + MANUALUPDATE_FALSE='#' +else + MANUALUPDATE_TRUE='#' + MANUALUPDATE_FALSE= +fi + for ac_prog in a2x do @@ -11612,6 +24787,10 @@ done $as_echo_n "checking for xmllint version... " >&6; } XMLLINT_VERSION="`${XMLLINT} --version 2>/dev/null`" XMLLINT_VERSION="${XMLLINT_VERSION##* }" + if test -z "${XMLLINT_VERSION}" ; then + XMLLINT_VERSION="`${XMLLINT} --version 2>&1 | grep version`" + XMLLINT_VERSION="${XMLLINT_VERSION##* }" + fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${XMLLINT_VERSION} found" >&5 $as_echo "${XMLLINT_VERSION} found" >&6; } fi @@ -11661,194 +24840,71 @@ fi test -n "$SOURCE_HIGHLIGHT" && break done - + if test -n "$SOURCE_HIGHLIGHT"; then + HAVE_SOURCE_HIGHLIGHT_TRUE= + HAVE_SOURCE_HIGHLIGHT_FALSE='#' +else + HAVE_SOURCE_HIGHLIGHT_TRUE='#' + HAVE_SOURCE_HIGHLIGHT_FALSE= fi -case "${nut_with_doc}" in - yes|all|auto) - nut_doc_build_list="html-single html-chunked pdf" - ;; - no) - nut_doc_build_list="" - ;; - *) - nut_doc_build_list="`echo ${nut_with_doc} | sed 's/,/ /g'`" - ;; + for ac_prog in aspell +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_ASPELL+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $ASPELL in + [\\/]* | ?:[\\/]*) + ac_cv_path_ASPELL="$ASPELL" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_ASPELL="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; esac - -for nut_doc_build_target in ${nut_doc_build_list}; do - case "${nut_doc_build_target}" in - html-single) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if asciidoc version can build ${nut_doc_build_target} (minimum required 8.6.3)" >&5 -$as_echo_n "checking if asciidoc version can build ${nut_doc_build_target} (minimum required 8.6.3)... " >&6; } - - - - # Used to indicate true or false condition - ax_compare_version=false - - # Convert the two version strings to be compared into a format that - # allows a simple string comparison. The end result is that a version - # string of the form 1.12.5-r617 will be converted to the form - # 0001001200050617. In other words, each number is zero padded to four - # digits, and non digits are removed. - - ax_compare_version_A=`echo "${ASCIIDOC_VERSION}" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ - -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ - -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ - -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ - -e 's/[^0-9]//g'` - - - ax_compare_version_B=`echo "8.6.3" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ - -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ - -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ - -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ - -e 's/[^0-9]//g'` - - - ax_compare_version=`echo "x$ax_compare_version_A -x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` - - - - if test "$ax_compare_version" = "true" ; then - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - DOC_BUILD_LIST="${DOC_BUILD_LIST} ${nut_doc_build_target}" - - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +fi +ASPELL=$ac_cv_path_ASPELL +if test -n "$ASPELL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ASPELL" >&5 +$as_echo "$ASPELL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - DOC_NOBUILD_LIST="${DOC_NOBUILD_LIST} ${nut_doc_build_target}" - - fi - - ;; - - html-chunked) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if a2x version can build ${nut_doc_build_target} (minimum required 8.6.3)" >&5 -$as_echo_n "checking if a2x version can build ${nut_doc_build_target} (minimum required 8.6.3)... " >&6; } +fi - - # Used to indicate true or false condition - ax_compare_version=false - - # Convert the two version strings to be compared into a format that - # allows a simple string comparison. The end result is that a version - # string of the form 1.12.5-r617 will be converted to the form - # 0001001200050617. In other words, each number is zero padded to four - # digits, and non digits are removed. - - ax_compare_version_A=`echo "${A2X_VERSION}" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ - -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ - -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ - -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ - -e 's/[^0-9]//g'` - - - ax_compare_version_B=`echo "8.6.3" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ - -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ - -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ - -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ - -e 's/[^0-9]//g'` - - - ax_compare_version=`echo "x$ax_compare_version_A -x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` - - - - if test "$ax_compare_version" = "true" ; then - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - DOC_BUILD_LIST="${DOC_BUILD_LIST} ${nut_doc_build_target}" - - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - DOC_NOBUILD_LIST="${DOC_NOBUILD_LIST} ${nut_doc_build_target}" - - fi - - ;; - - pdf) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if dblatex version can build ${nut_doc_build_target} (minimum required 0.2.5)" >&5 -$as_echo_n "checking if dblatex version can build ${nut_doc_build_target} (minimum required 0.2.5)... " >&6; } - - - - # Used to indicate true or false condition - ax_compare_version=false - - # Convert the two version strings to be compared into a format that - # allows a simple string comparison. The end result is that a version - # string of the form 1.12.5-r617 will be converted to the form - # 0001001200050617. In other words, each number is zero padded to four - # digits, and non digits are removed. - - ax_compare_version_A=`echo "${DBLATEX_VERSION}" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ - -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ - -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ - -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ - -e 's/[^0-9]//g'` - - - ax_compare_version_B=`echo "0.2.5" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ - -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ - -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ - -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ - -e 's/[^0-9]//g'` - - - ax_compare_version=`echo "x$ax_compare_version_A -x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` - - - - if test "$ax_compare_version" = "true" ; then - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - DOC_BUILD_LIST="${DOC_BUILD_LIST} ${nut_doc_build_target}" - - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - DOC_NOBUILD_LIST="${DOC_NOBUILD_LIST} ${nut_doc_build_target}" - - fi - - ;; - esac + test -n "$ASPELL" && break done -case "${nut_with_doc}" in -auto) - if test -n "${DOC_BUILD_LIST}"; then - nut_with_doc="yes" - else - nut_with_doc="no" - fi - ;; -no) - ;; -*) - if test -z "${DOC_NOBUILD_LIST}"; then - nut_with_doc="yes" - else - as_fn_error $? "\"Unable to build ${DOC_NOBUILD_LIST} documentation (check for 'no' results above)\"" "$LINENO" 5 - fi - ;; -esac + if test -n "$ASPELL"; then + HAVE_ASPELL_TRUE= + HAVE_ASPELL_FALSE='#' +else + HAVE_ASPELL_TRUE='#' + HAVE_ASPELL_FALSE= +fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if asciidoc version can build manpages (minimum required 8.6.3)" >&5 -$as_echo_n "checking if asciidoc version can build manpages (minimum required 8.6.3)... " >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if asciidoc version can build manpages (minimum required ${ASCIIDOC_MIN_VERSION})" >&5 +$as_echo_n "checking if asciidoc version can build manpages (minimum required ${ASCIIDOC_MIN_VERSION})... " >&6; } @@ -11868,7 +24924,7 @@ $as_echo_n "checking if asciidoc version can build manpages (minimum required 8. -e 's/[^0-9]//g'` - ax_compare_version_B=`echo "8.6.3" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + ax_compare_version_B=`echo "${ASCIIDOC_MIN_VERSION}" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ @@ -11882,20 +24938,20 @@ x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version if test "$ax_compare_version" = "true" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - nut_have_asciidoc="yes" + nut_have_asciidoc="yes" else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - nut_have_asciidoc="no" + nut_have_asciidoc="no" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if a2x version can build manpages (minimum required 8.6.3)" >&5 -$as_echo_n "checking if a2x version can build manpages (minimum required 8.6.3)... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if a2x version can build manpages (minimum required ${ASCIIDOC_MIN_VERSION})" >&5 +$as_echo_n "checking if a2x version can build manpages (minimum required ${ASCIIDOC_MIN_VERSION})... " >&6; } @@ -11915,7 +24971,7 @@ $as_echo_n "checking if a2x version can build manpages (minimum required 8.6.3). -e 's/[^0-9]//g'` - ax_compare_version_B=`echo "8.6.3" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + ax_compare_version_B=`echo "${ASCIIDOC_MIN_VERSION}" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ @@ -11929,50 +24985,67 @@ x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version if test "$ax_compare_version" = "true" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - nut_have_asciidoc="no" + nut_have_asciidoc="no" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if xsltproc is present (mandatory for man page regeneration)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if xsltproc is present (mandatory for man page regeneration)" >&5 $as_echo_n "checking if xsltproc is present (mandatory for man page regeneration)... " >&6; } -if test -n "${XSLTPROC}"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + if test -n "${XSLTPROC}"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - nut_have_asciidoc="no" -fi + nut_have_asciidoc="no" + fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if xmllint is present (mandatory for man page regeneration)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if xmllint is present (mandatory for man page regeneration)" >&5 $as_echo_n "checking if xmllint is present (mandatory for man page regeneration)... " >&6; } -if test -n "${XMLLINT}"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + if test -n "${XMLLINT}"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - nut_have_asciidoc="no" + nut_have_asciidoc="no" + fi + + if test "${nut_have_asciidoc}" = "yes"; then + HAVE_ASCIIDOC_TRUE= + HAVE_ASCIIDOC_FALSE='#' +else + HAVE_ASCIIDOC_TRUE='#' + HAVE_ASCIIDOC_FALSE= fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if source-highlight is present (preferable for documentation generation)" >&5 + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we have all the tools mandatory for man page regeneration" >&5 +$as_echo_n "checking if we have all the tools mandatory for man page regeneration... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${nut_have_asciidoc}" >&5 +$as_echo "${nut_have_asciidoc}" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if source-highlight is present (preferable for documentation generation)" >&5 $as_echo_n "checking if source-highlight is present (preferable for documentation generation)... " >&6; } -if test -n "${SOURCE_HIGHLIGHT}"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + if test -n "${SOURCE_HIGHLIGHT}"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } + fi + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build and install documentation" >&5 $as_echo_n "checking whether to build and install documentation... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${nut_with_doc} " >&5 @@ -12004,28 +25077,429 @@ _ACEOF fi - if test "${nut_have_asciidoc}" = "yes"; then - HAVE_ASCIIDOC_TRUE= - HAVE_ASCIIDOC_FALSE='#' -else - HAVE_ASCIIDOC_TRUE='#' - HAVE_ASCIIDOC_FALSE= +DOC_INSTALL_DISTED_MANS=no + +case "${nut_with_doc}" in + yes|all|all=yes) + nut_doc_build_list="man html-single html-chunked pdf" + ;; + auto|all=auto) + nut_doc_build_list="man=auto html-single=auto html-chunked=auto pdf=auto" + ;; + skip|all=skip) + nut_doc_build_list="man=skip html-single=skip html-chunked=skip pdf=skip" + ;; + no|all=no) + nut_doc_build_list="" + ;; + "") + nut_doc_build_list="" + { $as_echo "$as_me:${as_lineno-$LINENO}: Got explicit empty list of document formats to build; nothing will be generated" >&5 +$as_echo "$as_me: Got explicit empty list of document formats to build; nothing will be generated" >&6;} + ;; + *) + nut_doc_build_list="`echo ${nut_with_doc} | sed 's/,/ /g'`" + { $as_echo "$as_me:${as_lineno-$LINENO}: Got explicit list of document formats to build or not: ${nut_doc_build_list}; formats not listed will be silently skipped" >&5 +$as_echo "$as_me: Got explicit list of document formats to build or not: ${nut_doc_build_list}; formats not listed will be silently skipped" >&6;} + ;; +esac + +if test -z "${abs_srcdir}" ; then + case "${srcdir}" in + /*) abs_srcdir="${srcdir}";; + "") as_fn_error $? "Can not detect 'srcdir'" "$LINENO" 5 ;; + *) abs_srcdir="$(cd "${srcdir}" && pwd)" || as_fn_error $? "Can not detect 'srcdir'" "$LINENO" 5 ;; + esac fi +DOCTESTDIR="$(mktemp -d configure-test.docbuild.$$.XXXXXXX)" && \ +DOCTESTDIR="$(cd "$DOCTESTDIR" && pwd)" + +for nut_doc_build_target in $nut_doc_build_list; do + case "${nut_doc_build_target}" in + *=*=*) rm -rf "${DOCTESTDIR}" + as_fn_error $? "Invalid documentation format option: ${nut_doc_build_target}" "$LINENO" 5 ;; + *=*) + nut_doc_build_target_base="`echo "${nut_doc_build_target}" | sed 's,=.*$,,'`" + nut_doc_build_target_flag="`echo "${nut_doc_build_target}" | sed 's,^.*=,,'`" + ;; + *) + nut_doc_build_target_base="${nut_doc_build_target}" + nut_doc_build_target_flag="yes" + ;; + esac + case "${nut_doc_build_target_flag}" in + yes|no|auto|skip) ;; + "") nut_doc_build_target_flag="yes" ;; + *) rm -rf "${DOCTESTDIR}" + as_fn_error $? "Invalid documentation format option: ${nut_doc_build_target}" "$LINENO" 5 ;; + esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking desire and ability to build ${nut_doc_build_target_base} documentation" >&5 +$as_echo_n "checking desire and ability to build ${nut_doc_build_target_base} documentation... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${nut_doc_build_target_flag}" >&5 +$as_echo "${nut_doc_build_target_flag}" >&6; } + + case "${nut_doc_build_target}" in + *=no|*=skip) + DOC_SKIPBUILD_LIST="${DOC_SKIPBUILD_LIST} ${nut_doc_build_target_base}" + ;; -if test "${nut_with_doc}" = "yes"; then - if test -z "${nut_report_feature_flag}"; then + html-single*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if asciidoc version can build ${nut_doc_build_target_base} (minimum required ${ASCIIDOC_MIN_VERSION})" >&5 +$as_echo_n "checking if asciidoc version can build ${nut_doc_build_target_base} (minimum required ${ASCIIDOC_MIN_VERSION})... " >&6; } + can_build_doc_html_single=no + + + + # Used to indicate true or false condition + ax_compare_version=false + + # Convert the two version strings to be compared into a format that + # allows a simple string comparison. The end result is that a version + # string of the form 1.12.5-r617 will be converted to the form + # 0001001200050617. In other words, each number is zero padded to four + # digits, and non digits are removed. + + ax_compare_version_A=`echo "${ASCIIDOC_VERSION}" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version_B=`echo "${ASCIIDOC_MIN_VERSION}" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version=`echo "x$ax_compare_version_A +x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` + + + + if test "$ax_compare_version" = "true" ; then + + ( cd "$DOCTESTDIR" && ${A2X} --attribute=xhtml11_format --format=xhtml --xsl-file="${abs_srcdir}"/docs/xhtml.xsl --destination-dir=. "${abs_srcdir}"/docs/asciidoc.txt && test -s asciidoc.html ) && can_build_doc_html_single=yes + rm -f "$DOCTESTDIR"/asciidoc*.htm* + + fi + + if test "${can_build_doc_html_single}" = yes ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + DOC_BUILD_LIST="${DOC_BUILD_LIST} ${nut_doc_build_target_base}" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + if test "${nut_doc_build_target_flag}" = "yes" ; then + DOC_CANNOTBUILD_LIST="${DOC_CANNOTBUILD_LIST} ${nut_doc_build_target_base}" + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to build ${nut_doc_build_target_base} documentation which you requested" >&5 +$as_echo "$as_me: WARNING: Unable to build ${nut_doc_build_target_base} documentation which you requested" >&2;} + else + DOC_SKIPBUILD_LIST="${DOC_SKIPBUILD_LIST} ${nut_doc_build_target_base}" + fi + fi + ;; + + html-chunked*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if a2x version can build ${nut_doc_build_target_base} (minimum required ${ASCIIDOC_MIN_VERSION})" >&5 +$as_echo_n "checking if a2x version can build ${nut_doc_build_target_base} (minimum required ${ASCIIDOC_MIN_VERSION})... " >&6; } + can_build_doc_html_chunked=no + + + + # Used to indicate true or false condition + ax_compare_version=false + + # Convert the two version strings to be compared into a format that + # allows a simple string comparison. The end result is that a version + # string of the form 1.12.5-r617 will be converted to the form + # 0001001200050617. In other words, each number is zero padded to four + # digits, and non digits are removed. + + ax_compare_version_A=`echo "${A2X_VERSION}" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version_B=`echo "${ASCIIDOC_MIN_VERSION}" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version=`echo "x$ax_compare_version_A +x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` + + + + if test "$ax_compare_version" = "true" ; then + + ( cd "$DOCTESTDIR" && ${A2X} --attribute=chunked_format --format=chunked --xsl-file="${abs_srcdir}"/docs/chunked.xsl --destination-dir=. "${abs_srcdir}"/docs/FAQ.txt && test -s FAQ.chunked/index.html ) && can_build_doc_html_chunked=yes + rm -rf "${DOCTESTDIR}"/FAQ*.chunked* + + fi + + if test "${can_build_doc_html_chunked}" = yes ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + DOC_BUILD_LIST="${DOC_BUILD_LIST} ${nut_doc_build_target_base}" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + if test "${nut_doc_build_target_flag}" = "yes" ; then + DOC_CANNOTBUILD_LIST="${DOC_CANNOTBUILD_LIST} ${nut_doc_build_target_base}" + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to build ${nut_doc_build_target_base} documentation which you requested" >&5 +$as_echo "$as_me: WARNING: Unable to build ${nut_doc_build_target_base} documentation which you requested" >&2;} + else + DOC_SKIPBUILD_LIST="${DOC_SKIPBUILD_LIST} ${nut_doc_build_target_base}" + fi + fi + ;; + + pdf*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if dblatex version can build ${nut_doc_build_target_base} (minimum required ${DBLATEX_MIN_VERSION})" >&5 +$as_echo_n "checking if dblatex version can build ${nut_doc_build_target_base} (minimum required ${DBLATEX_MIN_VERSION})... " >&6; } + can_build_doc_pdf=no + + + + # Used to indicate true or false condition + ax_compare_version=false + + # Convert the two version strings to be compared into a format that + # allows a simple string comparison. The end result is that a version + # string of the form 1.12.5-r617 will be converted to the form + # 0001001200050617. In other words, each number is zero padded to four + # digits, and non digits are removed. + + ax_compare_version_A=`echo "${DBLATEX_VERSION}" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version_B=`echo "${DBLATEX_MIN_VERSION}" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version=`echo "x$ax_compare_version_A +x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` + + + + if test "$ax_compare_version" = "true" ; then + + ( cd "$DOCTESTDIR" && ${A2X} --format=pdf --destination-dir=. "${abs_srcdir}"/docs/asciidoc.txt && test -s asciidoc.pdf ) && can_build_doc_pdf=yes + rm -f "${DOCTESTDIR}"/asciidoc.pdf + + fi + + if test "${can_build_doc_pdf}" = yes ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + DOC_BUILD_LIST="${DOC_BUILD_LIST} ${nut_doc_build_target_base}" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + if test "${nut_doc_build_target_flag}" = "yes" ; then + DOC_CANNOTBUILD_LIST="${DOC_CANNOTBUILD_LIST} ${nut_doc_build_target_base}" + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to build ${nut_doc_build_target_base} documentation which you requested" >&5 +$as_echo "$as_me: WARNING: Unable to build ${nut_doc_build_target_base} documentation which you requested" >&2;} + else + DOC_SKIPBUILD_LIST="${DOC_SKIPBUILD_LIST} ${nut_doc_build_target_base}" + fi + fi + ;; + + man*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can build ${nut_doc_build_target_base}" >&5 +$as_echo_n "checking if we can build ${nut_doc_build_target_base}... " >&6; } + can_build_doc_man=no + if test "${nut_have_asciidoc}" = yes ; then + ( cd "$DOCTESTDIR" && ${A2X} --format manpage --destination-dir=. --xsltproc-opts="--nonet" "${abs_srcdir}"/docs/man/snmp-ups.txt && test -s snmp-ups.8 ) && can_build_doc_man=yes + rm -f "${DOCTESTDIR}"/snmp-ups.8 + fi + if test "${can_build_doc_man}" = yes ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + DOC_BUILD_LIST="${DOC_BUILD_LIST} ${nut_doc_build_target_base}" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + if test "${nut_doc_build_target_flag}" = "yes" ; then + DOC_CANNOTBUILD_LIST="${DOC_CANNOTBUILD_LIST} ${nut_doc_build_target_base}" + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to build ${nut_doc_build_target_base} documentation which you requested" >&5 +$as_echo "$as_me: WARNING: Unable to build ${nut_doc_build_target_base} documentation which you requested" >&2;} + else + DOC_SKIPBUILD_LIST="${DOC_SKIPBUILD_LIST} ${nut_doc_build_target_base}" + if test "${nut_doc_build_target_flag}" = "auto" ; then + if test -s "${abs_srcdir}"/docs/man/snmp-ups.8 ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to build ${nut_doc_build_target_base} documentation, but can install pre-built distributed copies" >&5 +$as_echo "$as_me: WARNING: Unable to build ${nut_doc_build_target_base} documentation, but can install pre-built distributed copies" >&2;} + DOC_INSTALL_DISTED_MANS="yes" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to build ${nut_doc_build_target_base} documentation, and unable to install pre-built distributed copies because they are absent" >&5 +$as_echo "$as_me: WARNING: Unable to build ${nut_doc_build_target_base} documentation, and unable to install pre-built distributed copies because they are absent" >&2;} + fi + fi # Other variants include "no", "skip"... + fi + fi + ;; + + *) rm -rf "${DOCTESTDIR}" + as_fn_error $? "--with-doc option refers to unknown documentation format: $nut_doc_build_target" "$LINENO" 5 ;; + + esac +done +rm -rf "${DOCTESTDIR}" + +case "${nut_with_doc}" in +auto) + if test -n "${DOC_BUILD_LIST}"; then + nut_with_doc="yes" + else + nut_with_doc="no" + fi + ;; +no) + ;; +*) + if test -n "${DOC_CANNOTBUILD_LIST}"; then + as_fn_error $? "Unable to build${DOC_CANNOTBUILD_LIST} documentation (check for 'no' results above)" "$LINENO" 5 + fi + + if test -n "${DOC_SKIPBUILD_LIST}"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Skipping build of${DOC_SKIPBUILD_LIST} documentation (check for 'skip' results above)" >&5 +$as_echo "$as_me: Skipping build of${DOC_SKIPBUILD_LIST} documentation (check for 'skip' results above)" >&6;} + fi + + if test -n "${DOC_BUILD_LIST}"; then + nut_with_doc="yes" + else + nut_with_doc="no" + fi + ;; +esac + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build specific documentation format(s)" >&5 +$as_echo_n "checking whether to build specific documentation format(s)... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${nut_with_doc} ${DOC_BUILD_LIST}" >&5 +$as_echo "${nut_with_doc} ${DOC_BUILD_LIST}" >&6; } + if test -z "${nut_report_feature_flag}"; then nut_report_feature_flag="1" ac_clean_files="${ac_clean_files} conf_nut_report_feature" echo > conf_nut_report_feature echo "Configuration summary:" >> conf_nut_report_feature echo "======================" >> conf_nut_report_feature fi - echo "only build specific documentation format: ${DOC_BUILD_LIST}" >> conf_nut_report_feature + echo "build specific documentation format(s): ${nut_with_doc} ${DOC_BUILD_LIST}" >> conf_nut_report_feature + + if test "${nut_with_doc}" = "yes"; then + WITH_DOCS_TRUE= + WITH_DOCS_FALSE='#' +else + WITH_DOCS_TRUE='#' + WITH_DOCS_FALSE= +fi + + if test "${nut_with_doc}" = "yes"; then + +cat >>confdefs.h <<_ACEOF +#define WITH_DOCS 1 +_ACEOF + + fi + + +# To cater for less portable make's, precalculate the target list +# for "make check" in "docs/" here... +DOC_CHECK_LIST="" +if test "${nut_with_doc}" = yes ; then + for V in $DOC_BUILD_LIST ; do + DOC_CHECK_LIST="$DOC_CHECK_LIST check-$V" + done +fi + +WITH_MANS=no +SKIP_MANS=no +if echo "${DOC_BUILD_LIST}" | grep -w "man" >/dev/null || test "${DOC_INSTALL_DISTED_MANS}" = "yes" ; then + WITH_MANS=yes +fi +if echo "${DOC_SKIPBUILD_LIST}" | grep -w "man" >/dev/null ; then + SKIP_MANS=yes +fi + if test "${WITH_MANS}" = "yes"; then + WITH_MANS_TRUE= + WITH_MANS_FALSE='#' +else + WITH_MANS_TRUE='#' + WITH_MANS_FALSE= +fi + + if test "${SKIP_MANS}" = "yes"; then + SKIP_MANS_TRUE= + SKIP_MANS_FALSE='#' +else + SKIP_MANS_TRUE='#' + SKIP_MANS_FALSE= +fi + + if test "${DOC_INSTALL_DISTED_MANS}" = "yes"; then + DOC_INSTALL_DISTED_MANS_TRUE= + DOC_INSTALL_DISTED_MANS_FALSE='#' +else + DOC_INSTALL_DISTED_MANS_TRUE='#' + DOC_INSTALL_DISTED_MANS_FALSE= fi + +if ( test "${GCC}" = "yes" ) +then + + CFLAGS_SAVED_NOPEDANTIC="$CFLAGS" + case "${CFLAGS}" in #( + *"-pedantic"*) : + CFLAGS="${CFLAGS} -Wno-pedantic" ;; #( + *) : + ;; +esac + case "${CFLAGS}" in #( + *"-Werror"*) : + CFLAGS="${CFLAGS} -Wno-error" ;; #( + *) : + ;; +esac + case "${CFLAGS}" in #( + *"-flto"*) : + CFLAGS="${CFLAGS} -ffat-lto-objects" ;; #( + *) : + ;; +esac +fi + + +SAVED_GCC="$GCC" +SAVED_CC="$CC" +if ( test "${GCC}" = "yes" ) +then + case "$CFLAGS$LDFLAGS" in + *-m32*) CC="$CC -m32" ;; + *-m64*) CC="$CC -m64" ;; + esac +fi case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 @@ -12034,8 +25508,8 @@ esac -macro_version='2.4.2' -macro_revision='1.3337' +macro_version='2.4.6' +macro_revision='2.4.6' @@ -12049,7 +25523,7 @@ macro_revision='1.3337' -ltmain="$ac_aux_dir/ltmain.sh" +ltmain=$ac_aux_dir/ltmain.sh # Backslashify metacharacters that are still active within # double-quoted strings. @@ -12098,7 +25572,7 @@ func_echo_all () $ECHO "" } -case "$ECHO" in +case $ECHO in printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 $as_echo "printf" >&6; } ;; print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 @@ -12291,19 +25765,19 @@ test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : - withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes + withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld -if test "$GCC" = yes; then +if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw + # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; @@ -12317,7 +25791,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; } while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done - test -z "$LD" && LD="$ac_prog" + test -z "$LD" && LD=$ac_prog ;; "") # If it fails, then pretend we aren't using GCC. @@ -12328,7 +25802,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; } with_gnu_ld=unknown ;; esac -elif test "$with_gnu_ld" = yes; then +elif test yes = "$with_gnu_ld"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else @@ -12339,32 +25813,32 @@ if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" + lt_cv_path_LD=$ac_dir/$ac_prog # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } @@ -12407,33 +25881,38 @@ if ${lt_cv_path_NM+:} false; then : else if test -n "$NM"; then # Let the user override the test. - lt_cv_path_NM="$NM" + lt_cv_path_NM=$NM else - lt_nm_to_check="${ac_tool_prefix}nm" + lt_nm_to_check=${ac_tool_prefix}nm if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. - tmp_nm="$ac_dir/$lt_tmp_nm" - if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + tmp_nm=$ac_dir/$lt_tmp_nm + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # Adding the 'sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file - case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in - */dev/null* | *'Invalid file or object type'*) + # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty + case $build_os in + mingw*) lt_bad_file=conftest.nm/nofile ;; + *) lt_bad_file=/dev/null ;; + esac + case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in + *$lt_bad_file* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" - break + break 2 ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" - break + break 2 ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but @@ -12444,15 +25923,15 @@ else esac fi done - IFS="$lt_save_ifs" + IFS=$lt_save_ifs done : ${lt_cv_path_NM=no} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 $as_echo "$lt_cv_path_NM" >&6; } -if test "$lt_cv_path_NM" != "no"; then - NM="$lt_cv_path_NM" +if test no != "$lt_cv_path_NM"; then + NM=$lt_cv_path_NM else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : @@ -12558,9 +26037,9 @@ esac fi fi - case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in + case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in *COFF*) - DUMPBIN="$DUMPBIN -symbols" + DUMPBIN="$DUMPBIN -symbols -headers" ;; *) DUMPBIN=: @@ -12568,8 +26047,8 @@ fi esac fi - if test "$DUMPBIN" != ":"; then - NM="$DUMPBIN" + if test : != "$DUMPBIN"; then + NM=$DUMPBIN fi fi test -z "$NM" && NM=nm @@ -12602,17 +26081,6 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 $as_echo "$lt_cv_nm_interface" >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 -$as_echo_n "checking whether ln -s works... " >&6; } -LN_S=$as_ln_s -if test "$LN_S" = "ln -s"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 -$as_echo "no, using $LN_S" >&6; } -fi - # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } @@ -12620,7 +26088,7 @@ if ${lt_cv_sys_max_cmd_len+:} false; then : $as_echo_n "(cached) " >&6 else i=0 - teststring="ABCD" + teststring=ABCD case $build_os in msdosdjgpp*) @@ -12660,7 +26128,7 @@ else lt_cv_sys_max_cmd_len=8192; ;; - netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) + bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` @@ -12711,22 +26179,22 @@ else *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len" && \ - test undefined != "$lt_cv_sys_max_cmd_len"; then + test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. - for i in 1 2 3 4 5 6 7 8 ; do + for i in 1 2 3 4 5 6 7 8; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. - while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ + while { test X`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && - test $i != 17 # 1/2 MB should be enough + test 17 != "$i" # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring @@ -12744,7 +26212,7 @@ else fi -if test -n $lt_cv_sys_max_cmd_len ; then +if test -n "$lt_cv_sys_max_cmd_len"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 $as_echo "$lt_cv_sys_max_cmd_len" >&6; } else @@ -12762,30 +26230,6 @@ max_cmd_len=$lt_cv_sys_max_cmd_len : ${MV="mv -f"} : ${RM="rm -f"} -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 -$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } -# Try some XSI features -xsi_shell=no -( _lt_dummy="a/b/c" - test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ - = c,a/b,b/c, \ - && eval 'test $(( 1 + 1 )) -eq 2 \ - && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ - && xsi_shell=yes -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 -$as_echo "$xsi_shell" >&6; } - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 -$as_echo_n "checking whether the shell understands \"+=\"... " >&6; } -lt_shell_append=no -( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ - >/dev/null 2>&1 \ - && lt_shell_append=yes -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 -$as_echo "$lt_shell_append" >&6; } - - if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else @@ -12908,13 +26352,13 @@ esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in cygwin* | mingw* | pw32* | cegcc*) - if test "$GCC" != yes; then + if test yes != "$GCC"; then reload_cmds=false fi ;; darwin*) - if test "$GCC" = yes; then - reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' + if test yes = "$GCC"; then + reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi @@ -13042,13 +26486,13 @@ lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. -# `unknown' -- same as none, but documents that we really don't know. +# 'unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path -# which responds to the $file_magic_cmd with a given extended regex. -# If you have `file' or equivalent on your system and you're not sure -# whether `pass_all' will *always* work, you probably want this one. +# that responds to the $file_magic_cmd with a given extended regex. +# If you have 'file' or equivalent on your system and you're not sure +# whether 'pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) @@ -13075,8 +26519,7 @@ mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. - # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. - if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then + if ( file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else @@ -13172,8 +26615,8 @@ newos6*) lt_cv_deplibs_check_method=pass_all ;; -openbsd*) - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then +openbsd* | bitrig*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' @@ -13226,6 +26669,9 @@ sysv4 | sysv4.3*) tpf*) lt_cv_deplibs_check_method=pass_all ;; +os2*) + lt_cv_deplibs_check_method=pass_all + ;; esac fi @@ -13383,8 +26829,8 @@ else case $host_os in cygwin* | mingw* | pw32* | cegcc*) - # two different shell functions defined in ltmain.sh - # decide which to use based on capabilities of $DLLTOOL + # two different shell functions defined in ltmain.sh; + # decide which one to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib @@ -13396,7 +26842,7 @@ cygwin* | mingw* | pw32* | cegcc*) ;; *) # fallback: assume linklib IS sharedlib - lt_cv_sharedlib_from_linklib_cmd="$ECHO" + lt_cv_sharedlib_from_linklib_cmd=$ECHO ;; esac @@ -13513,7 +26959,7 @@ esac fi : ${AR=ar} -: ${AR_FLAGS=cru} +: ${AR_FLAGS=cr} @@ -13550,7 +26996,7 @@ if ac_fn_c_try_compile "$LINENO"; then : ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } - if test "$ac_status" -eq 0; then + if test 0 -eq "$ac_status"; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 @@ -13558,7 +27004,7 @@ if ac_fn_c_try_compile "$LINENO"; then : ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } - if test "$ac_status" -ne 0; then + if test 0 -ne "$ac_status"; then lt_cv_ar_at_file=@ fi fi @@ -13571,7 +27017,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 $as_echo "$lt_cv_ar_at_file" >&6; } -if test "x$lt_cv_ar_at_file" = xno; then +if test no = "$lt_cv_ar_at_file"; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file @@ -13788,7 +27234,7 @@ old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in - openbsd*) + bitrig* | openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) @@ -13878,7 +27324,7 @@ cygwin* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then symcode='[ABCDEGRST]' fi ;; @@ -13911,14 +27357,44 @@ case `$NM -V 2>&1` in symcode='[ABCDGIRSTW]' ;; esac +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Gets list of data symbols to import. + lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" + # Adjust the below global symbol transforms to fixup imported variables. + lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" + lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" + lt_c_name_lib_hook="\ + -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ + -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" +else + # Disable hooks by default. + lt_cv_sys_global_symbol_to_import= + lt_cdecl_hook= + lt_c_name_hook= + lt_c_name_lib_hook= +fi + # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. -lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" +lt_cv_sys_global_symbol_to_cdecl="sed -n"\ +$lt_cdecl_hook\ +" -e 's/^T .* \(.*\)$/extern int \1();/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ +$lt_c_name_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" + +# Transform an extracted symbol line into symbol name with lib prefix and +# symbol address. +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ +$lt_c_name_lib_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" # Handle CRLF in mingw tool chain opt_cr= @@ -13936,21 +27412,24 @@ for ac_symprfx in "" "_"; do # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then - # Fake it for dumpbin and say T for any non-static function - # and D for any global variable. + # Fake it for dumpbin and say T for any non-static function, + # D for any global variable and I for any imported variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ +" /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ +" /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ +" /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ -" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ -" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ -" s[1]~/^[@?]/{print s[1], s[1]; next};"\ -" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ +" {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ +" {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ +" s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" @@ -13981,11 +27460,8 @@ _LT_EOF test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 - (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s "$nlist"; then + $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&5 + if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&5 && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" @@ -13998,11 +27474,11 @@ _LT_EOF if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ -#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) -/* DATA imports from DLLs on WIN32 con't be const, because runtime +#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE +/* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST -#elif defined(__osf__) +#elif defined __osf__ /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else @@ -14028,7 +27504,7 @@ lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF - $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext + $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; @@ -14048,13 +27524,13 @@ _LT_EOF mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS - LIBS="conftstm.$ac_objext" + LIBS=conftstm.$ac_objext CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s conftest${ac_exeext}; then + test $ac_status = 0; } && test -s conftest$ac_exeext; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS @@ -14075,7 +27551,7 @@ _LT_EOF rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. - if test "$pipe_works" = yes; then + if test yes = "$pipe_works"; then break else lt_cv_sys_global_symbol_pipe= @@ -14117,6 +27593,16 @@ fi + + + + + + + + + + @@ -14140,9 +27626,9 @@ fi lt_sysroot= -case ${with_sysroot} in #( +case $with_sysroot in #( yes) - if test "$GCC" = yes; then + if test yes = "$GCC"; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( @@ -14152,8 +27638,8 @@ case ${with_sysroot} in #( no|'') ;; #( *) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5 -$as_echo "${with_sysroot}" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5 +$as_echo "$with_sysroot" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac @@ -14165,18 +27651,99 @@ $as_echo "${lt_sysroot:-no}" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5 +$as_echo_n "checking for a working dd... " >&6; } +if ${ac_cv_path_lt_DD+:} false; then : + $as_echo_n "(cached) " >&6 +else + printf 0123456789abcdef0123456789abcdef >conftest.i +cat conftest.i conftest.i >conftest2.i +: ${lt_DD:=$DD} +if test -z "$lt_DD"; then + ac_path_lt_DD_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in dd; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_lt_DD="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_lt_DD" || continue +if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: +fi + $ac_path_lt_DD_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_lt_DD"; then + : + fi +else + ac_cv_path_lt_DD=$lt_DD +fi + +rm -f conftest.i conftest2.i conftest.out +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5 +$as_echo "$ac_cv_path_lt_DD" >&6; } + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5 +$as_echo_n "checking how to truncate binary pipes... " >&6; } +if ${lt_cv_truncate_bin+:} false; then : + $as_echo_n "(cached) " >&6 +else + printf 0123456789abcdef0123456789abcdef >conftest.i +cat conftest.i conftest.i >conftest2.i +lt_cv_truncate_bin= +if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" +fi +rm -f conftest.i conftest2.i conftest.out +test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5 +$as_echo "$lt_cv_truncate_bin" >&6; } + + + + + + + +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +func_cc_basename () +{ + for cc_temp in $*""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +} + # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes +test no = "$enable_libtool_lock" || enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) - # Find out which ABI we are using. + # Find out what ABI is being produced by ac_compile, and set mode + # options accordingly. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 @@ -14185,24 +27752,25 @@ ia64-*-hpux*) test $ac_status = 0; }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) - HPUX_IA64_MODE="32" + HPUX_IA64_MODE=32 ;; *ELF-64*) - HPUX_IA64_MODE="64" + HPUX_IA64_MODE=64 ;; esac fi rm -rf conftest* ;; *-*-irix6*) - # Find out which ABI we are using. + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - if test "$lt_cv_prog_gnu_ld" = yes; then + if test yes = "$lt_cv_prog_gnu_ld"; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" @@ -14231,9 +27799,50 @@ ia64-*-hpux*) rm -rf conftest* ;; +mips64*-*linux*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo '#line '$LINENO' "configure"' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + emul=elf + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + emul="${emul}32" + ;; + *64-bit*) + emul="${emul}64" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *MSB*) + emul="${emul}btsmip" + ;; + *LSB*) + emul="${emul}ltsmip" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *N32*) + emul="${emul}n32" + ;; + esac + LD="${LD-ld} -m $emul" + fi + rm -rf conftest* + ;; + x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) - # Find out which ABI we are using. + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. Note that the listed cases only cover the + # situations where additional linker options are needed (such as when + # doing 32-bit compilation for a host where ld defaults to 64-bit, or + # vice versa); the common cases where no linker options are needed do + # not appear in the list. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 @@ -14256,10 +27865,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) ;; esac ;; - powerpc64le-*) + powerpc64le-*linux*) LD="${LD-ld} -m elf32lppclinux" ;; - powerpc64-*) + powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) @@ -14278,10 +27887,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; - powerpcle-*) + powerpcle-*linux*) LD="${LD-ld} -m elf64lppc" ;; - powerpc-*) + powerpc-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) @@ -14299,7 +27908,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" + SAVE_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } @@ -14339,13 +27948,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 $as_echo "$lt_cv_cc_needs_belf" >&6; } - if test x"$lt_cv_cc_needs_belf" != x"yes"; then + if test yes != "$lt_cv_cc_needs_belf"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" + CFLAGS=$SAVE_CFLAGS fi ;; *-*solaris*) - # Find out which ABI we are using. + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 @@ -14357,7 +27967,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; } case $lt_cv_prog_gnu_ld in yes*) case $host in - i?86-*-solaris*) + i?86-*-solaris*|x86_64-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) @@ -14366,7 +27976,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; } esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then - LD="${LD-ld}_sol2" + LD=${LD-ld}_sol2 fi ;; *) @@ -14382,7 +27992,7 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; } ;; esac -need_locks="$enable_libtool_lock" +need_locks=$enable_libtool_lock if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. @@ -14493,7 +28103,7 @@ else fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 $as_echo "$lt_cv_path_mainfest_tool" >&6; } -if test "x$lt_cv_path_mainfest_tool" != xyes; then +if test yes != "$lt_cv_path_mainfest_tool"; then MANIFEST_TOOL=: fi @@ -14996,7 +28606,7 @@ if ${lt_cv_apple_cc_single_mod+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no - if test -z "${LT_MULTI_MODULE}"; then + if test -z "$LT_MULTI_MODULE"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the @@ -15014,7 +28624,7 @@ else cat conftest.err >&5 # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. - elif test -f libconftest.dylib && test $_lt_result -eq 0; then + elif test -f libconftest.dylib && test 0 = "$_lt_result"; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 @@ -15053,7 +28663,7 @@ else fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - LDFLAGS="$save_LDFLAGS" + LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 @@ -15070,8 +28680,8 @@ int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 - echo "$AR cru libconftest.a conftest.o" >&5 - $AR cru libconftest.a conftest.o 2>&5 + echo "$AR cr libconftest.a conftest.o" >&5 + $AR cr libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF @@ -15082,7 +28692,7 @@ _LT_EOF _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&5 - elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then + elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then lt_cv_ld_force_load=yes else cat conftest.err >&5 @@ -15095,32 +28705,32 @@ fi $as_echo "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) - _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; + _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; darwin1.*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[91]*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - 10.[012]*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - 10.*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + 10.0,*86*-darwin8*|10.0,*-darwin[912]*) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + 10.[012][,.]*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; + 10.*|11.*) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; esac ;; esac - if test "$lt_cv_apple_cc_single_mod" = "yes"; then + if test yes = "$lt_cv_apple_cc_single_mod"; then _lt_dar_single_mod='$single_module' fi - if test "$lt_cv_ld_exported_symbols_list" = "yes"; then - _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' + if test yes = "$lt_cv_ld_exported_symbols_list"; then + _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' else - _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' + _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' fi - if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then + if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= @@ -15128,6 +28738,41 @@ $as_echo "$lt_cv_ld_force_load" >&6; } ;; esac +# func_munge_path_list VARIABLE PATH +# ----------------------------------- +# VARIABLE is name of variable containing _space_ separated list of +# directories to be munged by the contents of PATH, which is string +# having a format: +# "DIR[:DIR]:" +# string "DIR[ DIR]" will be prepended to VARIABLE +# ":DIR[:DIR]" +# string "DIR[ DIR]" will be appended to VARIABLE +# "DIRP[:DIRP]::[DIRA:]DIRA" +# string "DIRP[ DIRP]" will be prepended to VARIABLE and string +# "DIRA[ DIRA]" will be appended to VARIABLE +# "DIR[:DIR]" +# VARIABLE will be replaced by "DIR[ DIR]" +func_munge_path_list () +{ + case x$2 in + x) + ;; + *:) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" + ;; + x:*) + eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" + ;; + *::*) + eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" + eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" + ;; + *) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" + ;; + esac +} + for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default @@ -15143,12 +28788,11 @@ done - func_stripname_cnf () { - case ${2} in - .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; + case $2 in + .*) func_stripname_result=`$ECHO "$3" | $SED "s%^$1%%; s%\\\\$2\$%%"`;; + *) func_stripname_result=`$ECHO "$3" | $SED "s%^$1%%; s%$2\$%%"`;; esac } # func_stripname_cnf @@ -15175,14 +28819,14 @@ if test "${enable_shared+set}" = set; then : *) enable_shared=no # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_shared=yes fi done - IFS="$lt_save_ifs" + IFS=$lt_save_ifs ;; esac else @@ -15206,14 +28850,14 @@ if test "${enable_static+set}" = set; then : *) enable_static=no # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_static=yes fi done - IFS="$lt_save_ifs" + IFS=$lt_save_ifs ;; esac else @@ -15237,14 +28881,14 @@ if test "${with_pic+set}" = set; then : *) pic_mode=default # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for lt_pkg in $withval; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done - IFS="$lt_save_ifs" + IFS=$lt_save_ifs ;; esac else @@ -15252,8 +28896,6 @@ else fi -test -z "$pic_mode" && pic_mode=default - @@ -15269,14 +28911,14 @@ if test "${enable_fast_install+set}" = set; then : *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done - IFS="$lt_save_ifs" + IFS=$lt_save_ifs ;; esac else @@ -15290,11 +28932,63 @@ fi + shared_archive_member_spec= +case $host,$enable_shared in +power*-*-aix[5-9]*,yes) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5 +$as_echo_n "checking which variant of shared library versioning to provide... " >&6; } + +# Check whether --with-aix-soname was given. +if test "${with_aix_soname+set}" = set; then : + withval=$with_aix_soname; case $withval in + aix|svr4|both) + ;; + *) + as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5 + ;; + esac + lt_cv_with_aix_soname=$with_aix_soname +else + if ${lt_cv_with_aix_soname+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_with_aix_soname=aix +fi + + with_aix_soname=$lt_cv_with_aix_soname +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5 +$as_echo "$with_aix_soname" >&6; } + if test aix != "$with_aix_soname"; then + # For the AIX way of multilib, we name the shared archive member + # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', + # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. + # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, + # the AIX toolchain works better with OBJECT_MODE set (default 32). + if test 64 = "${OBJECT_MODE-32}"; then + shared_archive_member_spec=shr_64 + else + shared_archive_member_spec=shr + fi + fi + ;; +*) + with_aix_soname=aix + ;; +esac + + + + + + + # This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ltmain" +LIBTOOL_DEPS=$ltmain # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' @@ -15343,7 +29037,7 @@ test -z "$LN_S" && LN_S="ln -s" -if test -n "${ZSH_VERSION+set}" ; then +if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi @@ -15382,7 +29076,7 @@ aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. - if test "X${COLLECT_NAMES+set}" != Xset; then + if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi @@ -15393,14 +29087,14 @@ esac ofile=libtool can_build_shared=yes -# All known linkers require a `.a' archive for static linking (except MSVC, +# All known linkers require a '.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a -with_gnu_ld="$lt_cv_prog_gnu_ld" +with_gnu_ld=$lt_cv_prog_gnu_ld -old_CC="$CC" -old_CFLAGS="$CFLAGS" +old_CC=$CC +old_CFLAGS=$CFLAGS # Set sane defaults for various variables test -z "$CC" && CC=cc @@ -15409,15 +29103,8 @@ test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o -for cc_temp in $compiler""; do - case $cc_temp in - compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; - distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +func_cc_basename $compiler +cc_basename=$func_cc_basename_result # Only perform the check for file, if the check method requires it @@ -15432,22 +29119,22 @@ if ${lt_cv_path_MAGIC_CMD+:} false; then : else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + lt_save_MAGIC_CMD=$MAGIC_CMD + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/${ac_tool_prefix}file; then - lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" + if test -f "$ac_dir/${ac_tool_prefix}file"; then + lt_cv_path_MAGIC_CMD=$ac_dir/"${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : @@ -15470,13 +29157,13 @@ _LT_EOF break fi done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" + IFS=$lt_save_ifs + MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac fi -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } @@ -15498,22 +29185,22 @@ if ${lt_cv_path_MAGIC_CMD+:} false; then : else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + lt_save_MAGIC_CMD=$MAGIC_CMD + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/file; then - lt_cv_path_MAGIC_CMD="$ac_dir/file" + if test -f "$ac_dir/file"; then + lt_cv_path_MAGIC_CMD=$ac_dir/"file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : @@ -15536,13 +29223,13 @@ _LT_EOF break fi done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" + IFS=$lt_save_ifs + MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac fi -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } @@ -15563,7 +29250,7 @@ esac # Use C for the default configuration in the libtool script -lt_save_CC="$CC" +lt_save_CC=$CC ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -15625,7 +29312,7 @@ if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= -if test "$GCC" = yes; then +if test yes = "$GCC"; then case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; @@ -15641,7 +29328,7 @@ else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="-fno-rtti -fno-exceptions" + lt_compiler_flag="-fno-rtti -fno-exceptions" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins @@ -15671,7 +29358,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } -if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then +if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : @@ -15689,17 +29376,18 @@ lt_prog_compiler_pic= lt_prog_compiler_static= - if test "$GCC" = yes; then + if test yes = "$GCC"; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi + lt_prog_compiler_pic='-fPIC' ;; amigaos*) @@ -15710,8 +29398,8 @@ lt_prog_compiler_static= ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. + # adding the '-m68020' flag to GCC prevents building anything better, + # like '-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac @@ -15727,6 +29415,11 @@ lt_prog_compiler_static= # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' + case $host_os in + os2*) + lt_prog_compiler_static='$wl-static' + ;; + esac ;; darwin* | rhapsody*) @@ -15797,7 +29490,7 @@ lt_prog_compiler_static= case $host_os in aix*) lt_prog_compiler_wl='-Wl,' - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else @@ -15805,10 +29498,29 @@ lt_prog_compiler_static= fi ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic='-fno-common' + case $cc_basename in + nagfor*) + # NAG Fortran compiler + lt_prog_compiler_wl='-Wl,-Wl,,' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + esac + ;; + mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' + case $host_os in + os2*) + lt_prog_compiler_static='$wl-static' + ;; + esac ;; hpux9* | hpux10* | hpux11*) @@ -15824,7 +29536,7 @@ lt_prog_compiler_static= ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? - lt_prog_compiler_static='${wl}-a ${wl}archive' + lt_prog_compiler_static='$wl-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) @@ -15835,12 +29547,18 @@ lt_prog_compiler_static= linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in - # old Intel for x86_64 which still supported -KPIC. + # old Intel for x86_64, which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; + # flang / f18. f95 an alias for gfortran or flang on Debian + flang* | f18* | f95*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) @@ -15860,6 +29578,12 @@ lt_prog_compiler_static= lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) @@ -15957,7 +29681,7 @@ lt_prog_compiler_static= ;; sysv4*MP*) - if test -d /usr/nec ;then + if test -d /usr/nec; then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi @@ -15986,7 +29710,7 @@ lt_prog_compiler_static= fi case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: + # For platforms that do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; @@ -16018,7 +29742,7 @@ else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$lt_prog_compiler_pic -DPIC" + lt_compiler_flag="$lt_prog_compiler_pic -DPIC" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins @@ -16048,7 +29772,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; } -if test x"$lt_cv_prog_compiler_pic_works" = xyes; then +if test yes = "$lt_cv_prog_compiler_pic_works"; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; @@ -16080,7 +29804,7 @@ if ${lt_cv_prog_compiler_static_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no - save_LDFLAGS="$LDFLAGS" + save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then @@ -16099,13 +29823,13 @@ else fi fi $RM -r conftest* - LDFLAGS="$save_LDFLAGS" + LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 $as_echo "$lt_cv_prog_compiler_static_works" >&6; } -if test x"$lt_cv_prog_compiler_static_works" = xyes; then +if test yes = "$lt_cv_prog_compiler_static_works"; then : else lt_prog_compiler_static= @@ -16225,8 +29949,8 @@ $as_echo "$lt_cv_prog_compiler_c_o" >&6; } -hard_links="nottested" -if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then +hard_links=nottested +if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } @@ -16238,9 +29962,9 @@ $as_echo_n "checking if we can lock with hard links... " >&6; } ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } - if test "$hard_links" = no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 -$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + if test no = "$hard_links"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 +$as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} need_locks=warn fi else @@ -16283,9 +30007,9 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude - # it will be wrapped by ` (' and `)$', so one must not match beginning or - # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', - # as well as any symbol that contains `d'. + # it will be wrapped by ' (' and ')$', so one must not match beginning or + # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', + # as well as any symbol that contains 'd'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if @@ -16300,7 +30024,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. - if test "$GCC" != yes; then + if test yes != "$GCC"; then with_gnu_ld=no fi ;; @@ -16308,7 +30032,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; - openbsd*) + openbsd* | bitrig*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) @@ -16321,7 +30045,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no - if test "$with_gnu_ld" = yes; then + if test yes = "$with_gnu_ld"; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility @@ -16343,24 +30067,24 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie esac fi - if test "$lt_use_gnu_ld_interface" = yes; then + if test yes = "$lt_use_gnu_ld_interface"; then # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' + wlarc='$wl' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - export_dynamic_flag_spec='${wl}--export-dynamic' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + export_dynamic_flag_spec='$wl--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then - whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + whole_archive_flag_spec=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no - case `$LD -v 2>&1` in + case `$LD -v | $SED -e 's/(^)\+)\s\+//' 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... @@ -16373,7 +30097,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then + if test ia64 != "$host_cpu"; then ld_shlibs=no cat <<_LT_EOF 1>&2 @@ -16392,7 +30116,7 @@ _LT_EOF case $host_cpu in powerpc) # see comment about AmigaOS4 .so support - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) @@ -16408,7 +30132,7 @@ _LT_EOF allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME - archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else ld_shlibs=no fi @@ -16418,7 +30142,7 @@ _LT_EOF # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' - export_dynamic_flag_spec='${wl}--export-all-symbols' + export_dynamic_flag_spec='$wl--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes @@ -16426,61 +30150,89 @@ _LT_EOF exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file, use it as + # is; otherwise, prepend EXPORTS... + archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; haiku*) - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' link_all_deplibs=yes ;; + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + shrext_cmds=.dll + archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + enable_shared_with_static_runtimes=yes + ;; + interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - export_dynamic_flag_spec='${wl}-E' + hardcode_libdir_flag_spec='$wl-rpath,$libdir' + export_dynamic_flag_spec='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no - if test "$host_os" = linux-dietlibc; then + if test linux-dietlibc = "$host_os"; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ - && test "$tmp_diet" = no + && test no = "$tmp_diet" then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler - whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers - whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; @@ -16491,42 +30243,47 @@ _LT_EOF lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; + nagfor*) # NAGFOR 5.3 + tmp_sharedflag='-Wl,-shared' ;; xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 - whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' compiler_needs_object=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 - whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac - archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then + if test yes = "$supports_anon_versioning"; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi case $cc_basename in + tcc*) + export_dynamic_flag_spec='-rdynamic' + ;; xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then + if test yes = "$supports_anon_versioning"; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac @@ -16540,8 +30297,8 @@ _LT_EOF archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' fi ;; @@ -16559,8 +30316,8 @@ _LT_EOF _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi @@ -16572,7 +30329,7 @@ _LT_EOF ld_shlibs=no cat <<_LT_EOF 1>&2 -*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify @@ -16587,9 +30344,9 @@ _LT_EOF # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi @@ -16606,15 +30363,15 @@ _LT_EOF *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac - if test "$ld_shlibs" = no; then + if test no = "$ld_shlibs"; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= @@ -16630,7 +30387,7 @@ _LT_EOF # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes - if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported @@ -16638,34 +30395,57 @@ _LT_EOF ;; aix[4-9]*) - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' - no_entry_flag="" + no_entry_flag= else # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - # Also, AIX nm treats weak defined symbols like other global - # defined symbols, whereas GNU nm marks them as "W". + # -C means demangle to GNU nm, but means don't demangle to AIX nm. + # Without the "-l" option, or with the "-B" option, AIX nm treats + # weak defined symbols like other global defined symbols, whereas + # GNU nm marks them as "W". + # While the 'weak' keyword is ignored in the Export File, we need + # it in the Import File for the 'aix-soname' feature, so we have + # to replace the "-B" option with "-P" for AIX nm. if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else - export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. + # have runtime linking enabled, and use it for executables. + # For shared libraries, we enable/disable runtime linking + # depending on the kind of the shared library created - + # when "with_aix_soname,aix_use_runtimelinking" is: + # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables + # "aix,yes" lib.so shared, rtl:yes, for executables + # lib.a static archive + # "both,no" lib.so.V(shr.o) shared, rtl:yes + # lib.a(lib.so.V) shared, rtl:no, for executables + # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a(lib.so.V) shared, rtl:no + # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a static archive case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then aix_use_runtimelinking=yes break fi done + if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then + # With aix-soname=svr4, we create the lib.so.V shared archives only, + # so we don't have lib.a shared libs to link our executables. + # We have to force runtime linking in this case. + aix_use_runtimelinking=yes + LDFLAGS="$LDFLAGS -Wl,-brtl" + fi ;; esac @@ -16684,13 +30464,21 @@ _LT_EOF hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes - file_list_spec='${wl}-f,' + file_list_spec='$wl-f,' + case $with_aix_soname,$aix_use_runtimelinking in + aix,*) ;; # traditional, no import file + svr4,* | *,yes) # use import file + # The Import File defines what to hardcode. + hardcode_direct=no + hardcode_direct_absolute=no + ;; + esac - if test "$GCC" = yes; then + if test yes = "$GCC"; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` + collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then @@ -16709,36 +30497,42 @@ _LT_EOF ;; esac shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' + if test yes = "$aix_use_runtimelinking"; then + shared_flag="$shared_flag "'$wl-G' fi - link_all_deplibs=no + # Need to ensure runtime linking is disabled for the traditional + # shared library, or the linker may eventually find shared libraries + # /with/ Import File - we do not want to mix them. + shared_flag_aix='-shared' + shared_flag_svr4='-shared $wl-G' else # not using gcc - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' + if test yes = "$aix_use_runtimelinking"; then + shared_flag='$wl-G' else - shared_flag='${wl}-bM:SRE' + shared_flag='$wl-bM:SRE' fi + shared_flag_aix='$wl-bM:SRE' + shared_flag_svr4='$wl-G' fi fi - export_dynamic_flag_spec='${wl}-bexpall' + export_dynamic_flag_spec='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes - if test "$aix_use_runtimelinking" = yes; then + if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. - if test "${lt_cv_aix_libpath+set}" = set; then + if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : @@ -16773,7 +30567,7 @@ fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then - lt_cv_aix_libpath_="/usr/lib:/lib" + lt_cv_aix_libpath_=/usr/lib:/lib fi fi @@ -16781,17 +30575,17 @@ fi aix_libpath=$lt_cv_aix_libpath_ fi - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" - archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + if test ia64 = "$host_cpu"; then + hardcode_libdir_flag_spec='$wl-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. - if test "${lt_cv_aix_libpath+set}" = set; then + if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : @@ -16826,7 +30620,7 @@ fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then - lt_cv_aix_libpath_="/usr/lib:/lib" + lt_cv_aix_libpath_=/usr/lib:/lib fi fi @@ -16834,21 +30628,33 @@ fi aix_libpath=$lt_cv_aix_libpath_ fi - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. - no_undefined_flag=' ${wl}-bernotok' - allow_undefined_flag=' ${wl}-berok' - if test "$with_gnu_ld" = yes; then + no_undefined_flag=' $wl-bernotok' + allow_undefined_flag=' $wl-berok' + if test yes = "$with_gnu_ld"; then # We only use this code for GNU lds that support --whole-archive. - whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi archive_cmds_need_lc=yes - # This is similar to how AIX traditionally builds its shared libraries. - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + archive_expsym_cmds='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' + # -brtl affects multiple linker settings, -berok does not and is overridden later + compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`' + if test svr4 != "$with_aix_soname"; then + # This is similar to how AIX traditionally builds its shared libraries. + archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' + fi + if test aix != "$with_aix_soname"; then + archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' + else + # used by -dlpreopen to get the symbols + archive_expsym_cmds="$archive_expsym_cmds"'~$MV $output_objdir/$realname.d/$soname $output_objdir' + fi + archive_expsym_cmds="$archive_expsym_cmds"'~$RM -r $output_objdir/$realname.d' fi fi ;; @@ -16857,7 +30663,7 @@ fi case $host_cpu in powerpc) # see comment about AmigaOS4 .so support - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) @@ -16887,16 +30693,17 @@ fi # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" + shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. - archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; - else - sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; - fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ - linknames=' + archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then + cp "$export_symbols" "$output_objdir/$soname.def"; + echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; + else + $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes @@ -16905,18 +30712,18 @@ fi # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' postlink_cmds='lt_outputfile="@OUTPUT@"~ - lt_tool_outputfile="@TOOL_OUTPUT@"~ - case $lt_outputfile in - *.exe|*.EXE) ;; - *) - lt_outputfile="$lt_outputfile.exe" - lt_tool_outputfile="$lt_tool_outputfile.exe" - ;; - esac~ - if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; - $RM "$lt_outputfile.manifest"; - fi' + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile=$lt_outputfile.exe + lt_tool_outputfile=$lt_tool_outputfile.exe + ;; + esac~ + if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' ;; *) # Assume MSVC wrapper @@ -16925,7 +30732,7 @@ fi # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" + shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. @@ -16944,24 +30751,24 @@ fi hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported - if test "$lt_cv_ld_force_load" = "yes"; then - whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + if test yes = "$lt_cv_ld_force_load"; then + whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi link_all_deplibs=yes - allow_undefined_flag="$_lt_dar_allow_undefined" + allow_undefined_flag=$_lt_dar_allow_undefined case $cc_basename in - ifort*) _lt_dar_can_shared=yes ;; + ifort*|nagfor*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac - if test "$_lt_dar_can_shared" = "yes"; then + if test yes = "$_lt_dar_can_shared"; then output_verbose_link_cmd=func_echo_all - archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" - module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" - archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" - module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" + module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" + archive_expsym_cmds="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" + module_expsym_cmds="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" else ld_shlibs=no @@ -17003,33 +30810,33 @@ fi ;; hpux9*) - if test "$GCC" = yes; then - archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + if test yes = "$GCC"; then + archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else - archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' fi - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes - export_dynamic_flag_spec='${wl}-E' + export_dynamic_flag_spec='$wl-E' ;; hpux10*) - if test "$GCC" = yes && test "$with_gnu_ld" = no; then - archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + if test yes,no = "$GCC,$with_gnu_ld"; then + archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + if test no = "$with_gnu_ld"; then + hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes - export_dynamic_flag_spec='${wl}-E' + export_dynamic_flag_spec='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes @@ -17037,25 +30844,25 @@ fi ;; hpux11*) - if test "$GCC" = yes && test "$with_gnu_ld" = no; then + if test yes,no = "$GCC,$with_gnu_ld"; then case $host_cpu in hppa*64*) - archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) - archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) - archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) - archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) - archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) @@ -17067,7 +30874,7 @@ if ${lt_cv_prog_compiler__b+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler__b=no - save_LDFLAGS="$LDFLAGS" + save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -b" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then @@ -17086,14 +30893,14 @@ else fi fi $RM -r conftest* - LDFLAGS="$save_LDFLAGS" + LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 $as_echo "$lt_cv_prog_compiler__b" >&6; } -if test x"$lt_cv_prog_compiler__b" = xyes; then - archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' +if test yes = "$lt_cv_prog_compiler__b"; then + archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi @@ -17101,8 +30908,8 @@ fi ;; esac fi - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + if test no = "$with_gnu_ld"; then + hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: case $host_cpu in @@ -17113,7 +30920,7 @@ fi *) hardcode_direct=yes hardcode_direct_absolute=yes - export_dynamic_flag_spec='${wl}-E' + export_dynamic_flag_spec='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. @@ -17124,8 +30931,8 @@ fi ;; irix5* | irix6* | nonstopux*) - if test "$GCC" = yes; then - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + if test yes = "$GCC"; then + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. @@ -17135,8 +30942,8 @@ $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " > if ${lt_cv_irix_exported_symbol+:} false; then : $as_echo_n "(cached) " >&6 else - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } @@ -17148,24 +30955,35 @@ else fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - LDFLAGS="$save_LDFLAGS" + LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 $as_echo "$lt_cv_irix_exported_symbol" >&6; } - if test "$lt_cv_irix_exported_symbol" = yes; then - archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' + if test yes = "$lt_cv_irix_exported_symbol"; then + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' fi + link_all_deplibs=no else - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; + linux*) + case $cc_basename in + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + ld_shlibs=yes + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out @@ -17180,7 +30998,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; } newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; @@ -17188,27 +31006,19 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; } *nto* | *qnx*) ;; - openbsd*) + openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - export_dynamic_flag_spec='${wl}-E' + archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' + hardcode_libdir_flag_spec='$wl-rpath,$libdir' + export_dynamic_flag_spec='$wl-E' else - case $host_os in - openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-R$libdir' - ;; - *) - archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - ;; - esac + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='$wl-rpath,$libdir' fi else ld_shlibs=no @@ -17219,33 +31029,53 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; } hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported - archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' - old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + shrext_cmds=.dll + archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + enable_shared_with_static_runtimes=yes ;; osf3*) - if test "$GCC" = yes; then - allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + if test yes = "$GCC"; then + allow_undefined_flag=' $wl-expect_unresolved $wl\*' + archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' fi archive_cmds_need_lc='no' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + if test yes = "$GCC"; then + allow_undefined_flag=' $wl-expect_unresolved $wl\*' + archive_cmds='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' else allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ - $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' + $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' @@ -17256,24 +31086,24 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; } solaris*) no_undefined_flag=' -z defs' - if test "$GCC" = yes; then - wlarc='${wl}' - archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + if test yes = "$GCC"; then + wlarc='$wl' + archive_cmds='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' - archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_cmds='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' + $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) - wlarc='${wl}' - archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' + wlarc='$wl' + archive_cmds='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi @@ -17283,11 +31113,11 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; } solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. GCC discards it without `$wl', + # but understands '-z linker_flag'. GCC discards it without '$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) - if test "$GCC" = yes; then - whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + if test yes = "$GCC"; then + whole_archive_flag_spec='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi @@ -17297,10 +31127,10 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; } ;; sunos4*) - if test "x$host_vendor" = xsequent; then + if test sequent = "$host_vendor"; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. - archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi @@ -17349,43 +31179,43 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; } ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) - no_undefined_flag='${wl}-z,text' + no_undefined_flag='$wl-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' - if test "$GCC" = yes; then - archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + if test yes = "$GCC"; then + archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else - archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not + # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. - no_undefined_flag='${wl}-z,text' - allow_undefined_flag='${wl}-z,nodefs' + no_undefined_flag='$wl-z,text' + allow_undefined_flag='$wl-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no - hardcode_libdir_flag_spec='${wl}-R,$libdir' + hardcode_libdir_flag_spec='$wl-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes - export_dynamic_flag_spec='${wl}-Bexport' + export_dynamic_flag_spec='$wl-Bexport' runpath_var='LD_RUN_PATH' - if test "$GCC" = yes; then - archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + if test yes = "$GCC"; then + archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else - archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; @@ -17400,10 +31230,10 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; } ;; esac - if test x$host_vendor = xsni; then + if test sni = "$host_vendor"; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - export_dynamic_flag_spec='${wl}-Blargedynsym' + export_dynamic_flag_spec='$wl-Blargedynsym' ;; esac fi @@ -17411,7 +31241,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 $as_echo "$ld_shlibs" >&6; } -test "$ld_shlibs" = no && can_build_shared=no +test no = "$ld_shlibs" && can_build_shared=no with_gnu_ld=$with_gnu_ld @@ -17437,7 +31267,7 @@ x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes - if test "$enable_shared" = yes && test "$GCC" = yes; then + if test yes,yes = "$GCC,$enable_shared"; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. @@ -17652,14 +31482,14 @@ esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } -if test "$GCC" = yes; then +if test yes = "$GCC"; then case $host_os in - darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; - *) lt_awk_arg="/^libraries:/" ;; + darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; + *) lt_awk_arg='/^libraries:/' ;; esac case $host_os in - mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;; - *) lt_sed_strip_eq="s,=/,/,g" ;; + mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;; + *) lt_sed_strip_eq='s|=/|/|g' ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in @@ -17675,28 +31505,35 @@ if test "$GCC" = yes; then ;; esac # Ok, now we have the path, separated by spaces, we can step through it - # and add multilib dir if necessary. + # and add multilib dir if necessary... lt_tmp_lt_search_path_spec= - lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + # ...but if some path component already ends with the multilib dir we assume + # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). + case "$lt_multi_os_dir; $lt_search_path_spec " in + "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) + lt_multi_os_dir= + ;; + esac for lt_sys_path in $lt_search_path_spec; do - if test -d "$lt_sys_path/$lt_multi_os_dir"; then - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" - else + if test -d "$lt_sys_path$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" + elif test -n "$lt_multi_os_dir"; then test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' -BEGIN {RS=" "; FS="/|\n";} { - lt_foo=""; - lt_count=0; +BEGIN {RS = " "; FS = "/|\n";} { + lt_foo = ""; + lt_count = 0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { - lt_foo="/" $lt_i lt_foo; + lt_foo = "/" $lt_i lt_foo; } else { lt_count--; } @@ -17710,7 +31547,7 @@ BEGIN {RS=" "; FS="/|\n";} { # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ - $SED 's,/\([A-Za-z]:\),\1,g'` ;; + $SED 's|/\([A-Za-z]:\)|\1|g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else @@ -17719,7 +31556,7 @@ fi library_names_spec= libname_spec='lib$name' soname_spec= -shrext_cmds=".so" +shrext_cmds=.so postinstall_cmds= postuninstall_cmds= finish_cmds= @@ -17736,14 +31573,16 @@ hardcode_into_libs=no # flags to be left without arguments need_version=unknown + + case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + library_names_spec='$libname$release$shared_ext$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' + soname_spec='$libname$release$shared_ext$major' ;; aix[4-9]*) @@ -17751,41 +31590,91 @@ aix[4-9]*) need_lib_prefix=no need_version=no hardcode_into_libs=yes - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in + # the line '#! .'. This would cause the generated library to + # depend on '.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' - echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then + echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # Using Import Files as archive members, it is possible to support + # filename-based versioning of shared library archives on AIX. While + # this would work for both with and without runtime linking, it will + # prevent static linking of such archives. So we do filename-based + # shared library versioning with .so extension only, which is used + # when both runtime linking and shared linking is enabled. + # Unfortunately, runtime linking may impact performance, so we do + # not want this to be the default eventually. Also, we use the + # versioned .so libs for executables only if there is the -brtl + # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. + # To allow for filename-based versioning support, we need to create + # libNAME.so.V as an archive file, containing: + # *) an Import File, referring to the versioned filename of the + # archive as well as the shared archive member, telling the + # bitwidth (32 or 64) of that shared object, and providing the + # list of exported symbols of that shared object, eventually + # decorated with the 'weak' keyword + # *) the shared object with the F_LOADONLY flag set, to really avoid + # it being seen by the linker. + # At run time we better use the real file rather than another symlink, + # but for link time we create the symlink libNAME.so -> libNAME.so.V + + case $with_aix_soname,$aix_use_runtimelinking in + # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then + aix,yes) # traditional libtool + dynamic_linker='AIX unversionable lib.so' # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + aix,no) # traditional AIX only + dynamic_linker='AIX lib.a(lib.so.V)' # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + ;; + svr4,*) # full svr4 only + dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,yes) # both, prefer svr4 + dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # unpreferred sharedlib libNAME.a needs extra handling + postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' + postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,no) # both, prefer aix + dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)" + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling + postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' + postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' + ;; + esac shlibpath_var=LIBPATH fi ;; @@ -17795,18 +31684,18 @@ amigaos*) powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) - library_names_spec='${libname}${shared_ext}' + library_names_spec='$libname$shared_ext' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; @@ -17814,8 +31703,8 @@ beos*) bsdi[45]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" @@ -17827,7 +31716,7 @@ bsdi[45]*) cygwin* | mingw* | pw32* | cegcc*) version_type=windows - shrext_cmds=".dll" + shrext_cmds=.dll need_version=no need_lib_prefix=no @@ -17836,8 +31725,8 @@ cygwin* | mingw* | pw32* | cegcc*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ @@ -17853,17 +31742,17 @@ cygwin* | mingw* | pw32* | cegcc*) case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; esac dynamic_linker='Win32 ld.exe' @@ -17872,8 +31761,8 @@ cygwin* | mingw* | pw32* | cegcc*) *,cl*) # Native MSVC libname_spec='$name' - soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - library_names_spec='${libname}.dll.lib' + soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + library_names_spec='$libname.dll.lib' case $build_os in mingw*) @@ -17900,7 +31789,7 @@ cygwin* | mingw* | pw32* | cegcc*) sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) - sys_lib_search_path_spec="$LIB" + sys_lib_search_path_spec=$LIB if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` @@ -17913,8 +31802,8 @@ cygwin* | mingw* | pw32* | cegcc*) esac # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' @@ -17927,7 +31816,7 @@ cygwin* | mingw* | pw32* | cegcc*) *) # Assume MSVC wrapper - library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac @@ -17940,8 +31829,8 @@ darwin* | rhapsody*) version_type=darwin need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' + library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' + soname_spec='$libname$release$major$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' @@ -17954,8 +31843,8 @@ dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; @@ -17973,12 +31862,13 @@ freebsd* | dragonfly*) version_type=freebsd-$objformat case $version_type in freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' need_version=no need_lib_prefix=no ;; freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' need_version=yes ;; esac @@ -18008,10 +31898,10 @@ haiku*) need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LIBRARY_PATH - shlibpath_overrides_runpath=yes + shlibpath_overrides_runpath=no sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; @@ -18029,14 +31919,15 @@ hpux9* | hpux10* | hpux11*) dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + if test 32 = "$HPUX_IA64_MODE"; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + sys_lib_dlsearch_path_spec=/usr/lib/hpux32 else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + sys_lib_dlsearch_path_spec=/usr/lib/hpux64 fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' @@ -18044,8 +31935,8 @@ hpux9* | hpux10* | hpux11*) dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; @@ -18054,8 +31945,8 @@ hpux9* | hpux10* | hpux11*) dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... @@ -18068,8 +31959,8 @@ interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no @@ -18080,7 +31971,7 @@ irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) - if test "$lt_cv_prog_gnu_ld" = yes; then + if test yes = "$lt_cv_prog_gnu_ld"; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix @@ -18088,8 +31979,8 @@ irix5* | irix6* | nonstopux*) esac need_lib_prefix=no need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= @@ -18108,8 +31999,8 @@ irix5* | irix6* | nonstopux*) esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" + sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" hardcode_into_libs=yes ;; @@ -18118,13 +32009,33 @@ linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; +linux*android*) + version_type=none # Android doesn't support versioned libraries. + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext' + soname_spec='$libname$release$shared_ext' + finish_cmds= + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + dynamic_linker='Android linker' + # Don't embed -rpath directories since the linker doesn't support them. + hardcode_libdir_flag_spec='-L$libdir' + ;; + # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no @@ -18168,7 +32079,12 @@ fi # before this can be enabled. hardcode_into_libs=yes - # Append ld.so.conf contents to the search path + # Ideally, we could use ldconfig to report *all* directores which are + # searched for libraries, however this is still not possible. Aside from not + # being certain /sbin/ldconfig is available, command + # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, + # even though it is searched at run-time. Try to do the best guess by + # appending ld.so.conf contents (and includes) to the search path. if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" @@ -18200,12 +32116,12 @@ netbsd*) need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH @@ -18215,7 +32131,7 @@ netbsd*) newsos6) version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; @@ -18224,58 +32140,68 @@ newsos6) version_type=qnx need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; -openbsd*) +openbsd* | bitrig*) version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" + sys_lib_dlsearch_path_spec=/usr/lib need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + need_version=no + else + need_version=yes + fi + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[89] | openbsd2.[89].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi + shlibpath_overrides_runpath=yes ;; os2*) libname_spec='$name' - shrext_cmds=".dll" + version_type=windows + shrext_cmds=.dll + need_version=no need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' + # OS/2 can only load a DLL with a base name of 8 characters or less. + soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; + v=$($ECHO $release$versuffix | tr -d .-); + n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); + $ECHO $n$v`$shared_ext' + library_names_spec='${libname}_dll.$libext' dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH + shlibpath_var=BEGINLIBPATH + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; rdos*) @@ -18286,8 +32212,8 @@ solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes @@ -18297,11 +32223,11 @@ solaris*) sunos4*) version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then + if test yes = "$with_gnu_ld"; then need_lib_prefix=no fi need_version=yes @@ -18309,8 +32235,8 @@ sunos4*) sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) @@ -18331,24 +32257,24 @@ sysv4 | sysv4.3*) ;; sysv4*MP*) - if test -d /usr/nec ;then + if test -d /usr/nec; then version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' + library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' + soname_spec='$libname$shared_ext.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf + version_type=sco need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then + if test yes = "$with_gnu_ld"; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' @@ -18366,7 +32292,7 @@ tpf*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes @@ -18374,8 +32300,8 @@ tpf*) uts4*) version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; @@ -18385,20 +32311,35 @@ uts4*) esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } -test "$dynamic_linker" = no && can_build_shared=no +test no = "$dynamic_linker" && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then +if test yes = "$GCC"; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi -if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then - sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then + sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec fi -if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then - sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" + +if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then + sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec fi +# remember unaugmented sys_lib_dlsearch_path content for libtool script decls... +configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec + +# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code +func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" + +# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool +configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH + + + + + + @@ -18495,15 +32436,15 @@ $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || - test "X$hardcode_automatic" = "Xyes" ; then + test yes = "$hardcode_automatic"; then # We can hardcode non-existent directories. - if test "$hardcode_direct" != no && + if test no != "$hardcode_direct" && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one - ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && - test "$hardcode_minus_L" != no; then + ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, )" && + test no != "$hardcode_minus_L"; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else @@ -18518,12 +32459,12 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 $as_echo "$hardcode_action" >&6; } -if test "$hardcode_action" = relink || - test "$inherit_rpath" = yes; then +if test relink = "$hardcode_action" || + test yes = "$inherit_rpath"; then # Fast installation is not supported enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then +elif test yes = "$shlibpath_overrides_runpath" || + test no = "$enable_shared"; then # Fast installation is not necessary enable_fast_install=needless fi @@ -18533,7 +32474,7 @@ fi - if test "x$enable_dlopen" != xyes; then + if test yes != "$enable_dlopen"; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown @@ -18543,23 +32484,23 @@ else case $host_os in beos*) - lt_cv_dlopen="load_add_on" + lt_cv_dlopen=load_add_on lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) - lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen=LoadLibrary lt_cv_dlopen_libs= ;; cygwin*) - lt_cv_dlopen="dlopen" + lt_cv_dlopen=dlopen lt_cv_dlopen_libs= ;; darwin*) - # if libdl is installed we need to link against it + # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : @@ -18597,10 +32538,10 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" + lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl else - lt_cv_dlopen="dyld" + lt_cv_dlopen=dyld lt_cv_dlopen_libs= lt_cv_dlopen_self=yes @@ -18608,10 +32549,18 @@ fi ;; + tpf*) + # Don't try to run any link tests for TPF. We know it's impossible + # because TPF is a cross-compiler, and we know how we open DSOs. + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + lt_cv_dlopen_self=no + ;; + *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes; then : - lt_cv_dlopen="shl_load" + lt_cv_dlopen=shl_load else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } @@ -18650,11 +32599,11 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes; then : - lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" + lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes; then : - lt_cv_dlopen="dlopen" + lt_cv_dlopen=dlopen else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } @@ -18693,7 +32642,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" + lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } @@ -18732,7 +32681,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = xyes; then : - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" + lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } @@ -18771,7 +32720,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = xyes; then : - lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" + lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld fi @@ -18792,21 +32741,21 @@ fi ;; esac - if test "x$lt_cv_dlopen" != xno; then - enable_dlopen=yes - else + if test no = "$lt_cv_dlopen"; then enable_dlopen=no + else + enable_dlopen=yes fi case $lt_cv_dlopen in dlopen) - save_CPPFLAGS="$CPPFLAGS" - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + save_CPPFLAGS=$CPPFLAGS + test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" - save_LDFLAGS="$LDFLAGS" + save_LDFLAGS=$LDFLAGS wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - save_LIBS="$LIBS" + save_LIBS=$LIBS LIBS="$lt_cv_dlopen_libs $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 @@ -18814,7 +32763,7 @@ $as_echo_n "checking whether a program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self+:} false; then : $as_echo_n "(cached) " >&6 else - if test "$cross_compiling" = yes; then : + if test yes = "$cross_compiling"; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 @@ -18861,9 +32810,9 @@ else # endif #endif -/* When -fvisbility=hidden is used, assume the code has been annotated +/* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ -#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) +#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif @@ -18893,7 +32842,7 @@ _LT_EOF (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then + test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in @@ -18913,14 +32862,14 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 $as_echo "$lt_cv_dlopen_self" >&6; } - if test "x$lt_cv_dlopen_self" = xyes; then + if test yes = "$lt_cv_dlopen_self"; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self_static+:} false; then : $as_echo_n "(cached) " >&6 else - if test "$cross_compiling" = yes; then : + if test yes = "$cross_compiling"; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 @@ -18967,9 +32916,9 @@ else # endif #endif -/* When -fvisbility=hidden is used, assume the code has been annotated +/* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ -#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) +#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif @@ -18999,7 +32948,7 @@ _LT_EOF (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then + test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in @@ -19020,9 +32969,9 @@ fi $as_echo "$lt_cv_dlopen_self_static" >&6; } fi - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - LIBS="$save_LIBS" + CPPFLAGS=$save_CPPFLAGS + LDFLAGS=$save_LDFLAGS + LIBS=$save_LIBS ;; esac @@ -19066,7 +33015,7 @@ else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) - if test -n "$STRIP" ; then + if test -n "$STRIP"; then striplib="$STRIP -x" old_striplib="$STRIP -S" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 @@ -19094,7 +33043,7 @@ fi - # Report which library types will actually be built + # Report what library types will actually be built { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 $as_echo_n "checking if libtool supports shared libraries... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 @@ -19102,13 +33051,13 @@ $as_echo "$can_build_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 $as_echo_n "checking whether to build shared libraries... " >&6; } - test "$can_build_shared" = "no" && enable_shared=no + test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) - test "$enable_shared" = yes && enable_static=no + test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' @@ -19116,8 +33065,12 @@ $as_echo_n "checking whether to build shared libraries... " >&6; } ;; aix[4-9]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no + if test ia64 != "$host_cpu"; then + case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in + yes,aix,yes) ;; # shared object as lib.so file only + yes,svr4,*) ;; # shared object as lib.so archive member only + yes,*) enable_static=no ;; # shared object in lib.a archive as well + esac fi ;; esac @@ -19127,7 +33080,7 @@ $as_echo "$enable_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 $as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes + test yes = "$enable_shared" || enable_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 $as_echo "$enable_static" >&6; } @@ -19141,11 +33094,11 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu -CC="$lt_save_CC" +CC=$lt_save_CC - if test -n "$CXX" && ( test "X$CXX" != "Xno" && - ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || - (test "X$CXX" != "Xg++"))) ; then + if test -n "$CXX" && ( test no != "$CXX" && + ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) || + (test g++ != "$CXX"))); then ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -19324,7 +33277,7 @@ objext_CXX=$objext # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_caught_CXX_error" != yes; then +if test yes != "$_lt_caught_CXX_error"; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" @@ -19385,46 +33338,39 @@ $RM -r conftest* CFLAGS=$CXXFLAGS compiler=$CC compiler_CXX=$CC - for cc_temp in $compiler""; do - case $cc_temp in - compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; - distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` + func_cc_basename $compiler +cc_basename=$func_cc_basename_result if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately - if test "$GXX" = yes; then + if test yes = "$GXX"; then lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' else lt_prog_compiler_no_builtin_flag_CXX= fi - if test "$GXX" = yes; then + if test yes = "$GXX"; then # Set up default GNU C++ configuration # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : - withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes + withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld -if test "$GCC" = yes; then +if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw + # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; @@ -19438,7 +33384,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; } while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done - test -z "$LD" && LD="$ac_prog" + test -z "$LD" && LD=$ac_prog ;; "") # If it fails, then pretend we aren't using GCC. @@ -19449,7 +33395,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; } with_gnu_ld=unknown ;; esac -elif test "$with_gnu_ld" = yes; then +elif test yes = "$with_gnu_ld"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else @@ -19460,32 +33406,32 @@ if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" + lt_cv_path_LD=$ac_dir/$ac_prog # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } @@ -19521,22 +33467,22 @@ with_gnu_ld=$lt_cv_prog_gnu_ld # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. - if test "$with_gnu_ld" = yes; then - archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + if test yes = "$with_gnu_ld"; then + archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir' + export_dynamic_flag_spec_CXX='$wl--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) - wlarc='${wl}' + wlarc='$wl' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then - whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + whole_archive_flag_spec_CXX=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else whole_archive_flag_spec_CXX= fi @@ -19555,7 +33501,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else GXX=no @@ -19573,18 +33519,30 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie ld_shlibs_CXX=no ;; aix[4-9]*) - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' - no_entry_flag="" + no_entry_flag= else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. + # have runtime linking enabled, and use it for executables. + # For shared libraries, we enable/disable runtime linking + # depending on the kind of the shared library created - + # when "with_aix_soname,aix_use_runtimelinking" is: + # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables + # "aix,yes" lib.so shared, rtl:yes, for executables + # lib.a static archive + # "both,no" lib.so.V(shr.o) shared, rtl:yes + # lib.a(lib.so.V) shared, rtl:no, for executables + # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a(lib.so.V) shared, rtl:no + # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a static archive case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do case $ld_flag in @@ -19594,6 +33552,13 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie ;; esac done + if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then + # With aix-soname=svr4, we create the lib.so.V shared archives only, + # so we don't have lib.a shared libs to link our executables. + # We have to force runtime linking in this case. + aix_use_runtimelinking=yes + LDFLAGS="$LDFLAGS -Wl,-brtl" + fi ;; esac @@ -19612,13 +33577,21 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie hardcode_direct_absolute_CXX=yes hardcode_libdir_separator_CXX=':' link_all_deplibs_CXX=yes - file_list_spec_CXX='${wl}-f,' + file_list_spec_CXX='$wl-f,' + case $with_aix_soname,$aix_use_runtimelinking in + aix,*) ;; # no import file + svr4,* | *,yes) # use import file + # The Import File defines what to hardcode. + hardcode_direct_CXX=no + hardcode_direct_absolute_CXX=no + ;; + esac - if test "$GXX" = yes; then + if test yes = "$GXX"; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` + collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then @@ -19636,36 +33609,44 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie fi esac shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' + if test yes = "$aix_use_runtimelinking"; then + shared_flag=$shared_flag' $wl-G' fi + # Need to ensure runtime linking is disabled for the traditional + # shared library, or the linker may eventually find shared libraries + # /with/ Import File - we do not want to mix them. + shared_flag_aix='-shared' + shared_flag_svr4='-shared $wl-G' else # not using gcc - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' + if test yes = "$aix_use_runtimelinking"; then + shared_flag='$wl-G' else - shared_flag='${wl}-bM:SRE' + shared_flag='$wl-bM:SRE' fi + shared_flag_aix='$wl-bM:SRE' + shared_flag_svr4='$wl-G' fi fi - export_dynamic_flag_spec_CXX='${wl}-bexpall' + export_dynamic_flag_spec_CXX='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. always_export_symbols_CXX=yes - if test "$aix_use_runtimelinking" = yes; then + if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. - allow_undefined_flag_CXX='-berok' + # The "-G" linker flag allows undefined symbols. + no_undefined_flag_CXX='-bernotok' # Determine the default libpath from the value encoded in an empty # executable. - if test "${lt_cv_aix_libpath+set}" = set; then + if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath__CXX+:} false; then : @@ -19700,7 +33681,7 @@ fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath__CXX"; then - lt_cv_aix_libpath__CXX="/usr/lib:/lib" + lt_cv_aix_libpath__CXX=/usr/lib:/lib fi fi @@ -19708,18 +33689,18 @@ fi aix_libpath=$lt_cv_aix_libpath__CXX fi - hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" + hardcode_libdir_flag_spec_CXX='$wl-blibpath:$libdir:'"$aix_libpath" - archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib' + if test ia64 = "$host_cpu"; then + hardcode_libdir_flag_spec_CXX='$wl-R $libdir:/usr/lib:/lib' allow_undefined_flag_CXX="-z nodefs" - archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. - if test "${lt_cv_aix_libpath+set}" = set; then + if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath__CXX+:} false; then : @@ -19754,7 +33735,7 @@ fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath__CXX"; then - lt_cv_aix_libpath__CXX="/usr/lib:/lib" + lt_cv_aix_libpath__CXX=/usr/lib:/lib fi fi @@ -19762,22 +33743,34 @@ fi aix_libpath=$lt_cv_aix_libpath__CXX fi - hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" + hardcode_libdir_flag_spec_CXX='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. - no_undefined_flag_CXX=' ${wl}-bernotok' - allow_undefined_flag_CXX=' ${wl}-berok' - if test "$with_gnu_ld" = yes; then + no_undefined_flag_CXX=' $wl-bernotok' + allow_undefined_flag_CXX=' $wl-berok' + if test yes = "$with_gnu_ld"; then # We only use this code for GNU lds that support --whole-archive. - whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + whole_archive_flag_spec_CXX='$wl--whole-archive$convenience $wl--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec_CXX='$convenience' fi archive_cmds_need_lc_CXX=yes - # This is similar to how AIX traditionally builds its shared - # libraries. - archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + archive_expsym_cmds_CXX='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' + # -brtl affects multiple linker settings, -berok does not and is overridden later + compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`' + if test svr4 != "$with_aix_soname"; then + # This is similar to how AIX traditionally builds its shared + # libraries. Need -bnortl late, we may have -brtl in LDFLAGS. + archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' + fi + if test aix != "$with_aix_soname"; then + archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' + else + # used by -dlpreopen to get the symbols + archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$MV $output_objdir/$realname.d/$soname $output_objdir' + fi + archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$RM -r $output_objdir/$realname.d' fi fi ;; @@ -19787,7 +33780,7 @@ fi allow_undefined_flag_CXX=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME - archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else ld_shlibs_CXX=no fi @@ -19815,57 +33808,58 @@ fi # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" + shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. - archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; - else - $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; - fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ - linknames=' + archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + archive_expsym_cmds_CXX='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then + cp "$export_symbols" "$output_objdir/$soname.def"; + echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; + else + $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, CXX)='true' enable_shared_with_static_runtimes_CXX=yes # Don't use ranlib old_postinstall_cmds_CXX='chmod 644 $oldlib' postlink_cmds_CXX='lt_outputfile="@OUTPUT@"~ - lt_tool_outputfile="@TOOL_OUTPUT@"~ - case $lt_outputfile in - *.exe|*.EXE) ;; - *) - lt_outputfile="$lt_outputfile.exe" - lt_tool_outputfile="$lt_tool_outputfile.exe" - ;; - esac~ - func_to_tool_file "$lt_outputfile"~ - if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; - $RM "$lt_outputfile.manifest"; - fi' + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile=$lt_outputfile.exe + lt_tool_outputfile=$lt_tool_outputfile.exe + ;; + esac~ + func_to_tool_file "$lt_outputfile"~ + if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' ;; *) # g++ # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec_CXX='-L$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-all-symbols' + export_dynamic_flag_spec_CXX='$wl--export-all-symbols' allow_undefined_flag_CXX=unsupported always_export_symbols_CXX=no enable_shared_with_static_runtimes_CXX=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file, use it as + # is; otherwise, prepend EXPORTS... + archive_expsym_cmds_CXX='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs_CXX=no fi @@ -19879,27 +33873,27 @@ fi hardcode_direct_CXX=no hardcode_automatic_CXX=yes hardcode_shlibpath_var_CXX=unsupported - if test "$lt_cv_ld_force_load" = "yes"; then - whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + if test yes = "$lt_cv_ld_force_load"; then + whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec_CXX='' fi link_all_deplibs_CXX=yes - allow_undefined_flag_CXX="$_lt_dar_allow_undefined" + allow_undefined_flag_CXX=$_lt_dar_allow_undefined case $cc_basename in - ifort*) _lt_dar_can_shared=yes ;; + ifort*|nagfor*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac - if test "$_lt_dar_can_shared" = "yes"; then + if test yes = "$_lt_dar_can_shared"; then output_verbose_link_cmd=func_echo_all - archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" - module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" - archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" - module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" - if test "$lt_cv_apple_cc_single_mod" != "yes"; then - archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" - archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" + archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" + module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" + archive_expsym_cmds_CXX="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" + module_expsym_cmds_CXX="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" + if test yes != "$lt_cv_apple_cc_single_mod"; then + archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil" + archive_expsym_cmds_CXX="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" fi else @@ -19908,6 +33902,34 @@ fi ;; + os2*) + hardcode_libdir_flag_spec_CXX='-L$libdir' + hardcode_minus_L_CXX=yes + allow_undefined_flag_CXX=unsupported + shrext_cmds=.dll + archive_cmds_CXX='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + archive_expsym_cmds_CXX='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + old_archive_From_new_cmds_CXX='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + enable_shared_with_static_runtimes_CXX=yes + ;; + dgux*) case $cc_basename in ec++*) @@ -19943,14 +33965,14 @@ fi ;; haiku*) - archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' link_all_deplibs_CXX=yes ;; hpux9*) - hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' + hardcode_libdir_flag_spec_CXX='$wl+b $wl$libdir' hardcode_libdir_separator_CXX=: - export_dynamic_flag_spec_CXX='${wl}-E' + export_dynamic_flag_spec_CXX='$wl-E' hardcode_direct_CXX=yes hardcode_minus_L_CXX=yes # Not in the search PATH, # but as the default @@ -19962,7 +33984,7 @@ fi ld_shlibs_CXX=no ;; aCC*) - archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. @@ -19971,11 +33993,11 @@ fi # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) - if test "$GXX" = yes; then - archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + if test yes = "$GXX"; then + archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support ld_shlibs_CXX=no @@ -19985,15 +34007,15 @@ fi ;; hpux10*|hpux11*) - if test $with_gnu_ld = no; then - hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' + if test no = "$with_gnu_ld"; then + hardcode_libdir_flag_spec_CXX='$wl+b $wl$libdir' hardcode_libdir_separator_CXX=: case $host_cpu in hppa*64*|ia64*) ;; *) - export_dynamic_flag_spec_CXX='${wl}-E' + export_dynamic_flag_spec_CXX='$wl-E' ;; esac fi @@ -20019,13 +34041,13 @@ fi aCC*) case $host_cpu in hppa*64*) - archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + archive_cmds_CXX='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) - archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + archive_cmds_CXX='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) - archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + archive_cmds_CXX='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists @@ -20036,20 +34058,20 @@ fi # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) - if test "$GXX" = yes; then - if test $with_gnu_ld = no; then + if test yes = "$GXX"; then + if test no = "$with_gnu_ld"; then case $host_cpu in hppa*64*) - archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + archive_cmds_CXX='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) - archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + archive_cmds_CXX='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) - archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + archive_cmds_CXX='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi @@ -20064,22 +34086,22 @@ fi interix[3-9]*) hardcode_direct_CXX=no hardcode_shlibpath_var_CXX=no - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - export_dynamic_flag_spec_CXX='${wl}-E' + hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir' + export_dynamic_flag_spec_CXX='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. - archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds_CXX='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ - archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is @@ -20088,17 +34110,17 @@ fi old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) - if test "$GXX" = yes; then - if test "$with_gnu_ld" = no; then - archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + if test yes = "$GXX"; then + if test no = "$with_gnu_ld"; then + archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else - archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' + archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib' fi fi link_all_deplibs_CXX=yes ;; esac - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir' hardcode_libdir_separator_CXX=: inherit_rpath_CXX=yes ;; @@ -20111,8 +34133,8 @@ fi # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. - archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' + archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. @@ -20121,10 +34143,10 @@ fi # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir' + export_dynamic_flag_spec_CXX='$wl--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. @@ -20138,59 +34160,59 @@ fi # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) - archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac - archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; esac archive_cmds_need_lc_CXX=no - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-dynamic' - whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir' + export_dynamic_flag_spec_CXX='$wl--export-dynamic' + whole_archive_flag_spec_CXX='$wl--whole-archive$convenience $wl--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [1-5].* | *pgcpp\ [1-5].*) prelink_cmds_CXX='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ - compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ + compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' old_archive_cmds_CXX='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ - $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ - $RANLIB $oldlib' + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ + $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ + $RANLIB $oldlib' archive_cmds_CXX='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols - archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' - archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; esac - hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-dynamic' - whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + hardcode_libdir_flag_spec_CXX='$wl--rpath $wl$libdir' + export_dynamic_flag_spec_CXX='$wl--export-dynamic' + whole_archive_flag_spec_CXX='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' ;; cxx*) # Compaq C++ - archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib $wl-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec_CXX='-rpath $libdir' @@ -20204,18 +34226,18 @@ fi # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' - export_dynamic_flag_spec_CXX='${wl}--export-dynamic' - archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then + hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir' + export_dynamic_flag_spec_CXX='$wl--export-dynamic' + archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + if test yes = "$supports_anon_versioning"; then archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi ;; *) @@ -20223,10 +34245,10 @@ fi *Sun\ C*) # Sun C++ 5.9 no_undefined_flag_CXX=' -zdefs' - archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' + archive_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + archive_expsym_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols' hardcode_libdir_flag_spec_CXX='-R$libdir' - whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + whole_archive_flag_spec_CXX='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' compiler_needs_object_CXX=yes # Not sure whether something based on @@ -20284,22 +34306,17 @@ fi ld_shlibs_CXX=yes ;; - openbsd2*) - # C++ shared libraries are fairly broken - ld_shlibs_CXX=no - ;; - - openbsd*) + openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then hardcode_direct_CXX=yes hardcode_shlibpath_var_CXX=no hardcode_direct_absolute_CXX=yes archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' - export_dynamic_flag_spec_CXX='${wl}-E' - whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then + archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib' + export_dynamic_flag_spec_CXX='$wl-E' + whole_archive_flag_spec_CXX=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else @@ -20315,9 +34332,9 @@ fi # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. - archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir' hardcode_libdir_separator_CXX=: # Archives containing C++ object files must be created using @@ -20335,17 +34352,17 @@ fi cxx*) case $host in osf3*) - allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + allow_undefined_flag_CXX=' $wl-expect_unresolved $wl\*' + archive_cmds_CXX='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir' ;; *) allow_undefined_flag_CXX=' -expect_unresolved \*' - archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + archive_cmds_CXX='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ - echo "-hidden">> $lib.exp~ - $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ - $RM $lib.exp' + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~ + $RM $lib.exp' hardcode_libdir_flag_spec_CXX='-rpath $libdir' ;; esac @@ -20360,27 +34377,27 @@ fi # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' + if test yes,no = "$GXX,$with_gnu_ld"; then + allow_undefined_flag_CXX=' $wl-expect_unresolved $wl\*' case $host in osf3*) - archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + archive_cmds_CXX='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' ;; *) - archive_cmds_CXX='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' ;; esac - hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir' hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else # FIXME: insert proper C++ library support @@ -20420,9 +34437,9 @@ fi # Sun C++ 4.2, 5.x and Centerline C++ archive_cmds_need_lc_CXX=yes no_undefined_flag_CXX=' -zdefs' - archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + archive_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' hardcode_libdir_flag_spec_CXX='-R$libdir' hardcode_shlibpath_var_CXX=no @@ -20430,7 +34447,7 @@ fi solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. + # but understands '-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract' ;; @@ -20447,42 +34464,42 @@ fi ;; gcx*) # Green Hills C++ Compiler - archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - no_undefined_flag_CXX=' ${wl}-z ${wl}defs' + if test yes,no = "$GXX,$with_gnu_ld"; then + no_undefined_flag_CXX=' $wl-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then - archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else - # g++ 2.7 appears to require `-G' NOT `-shared' on this + # g++ 2.7 appears to require '-G' NOT '-shared' on this # platform. - archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + archive_cmds_CXX='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' fi - hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' + hardcode_libdir_flag_spec_CXX='$wl-R $wl$libdir' case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) - whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + whole_archive_flag_spec_CXX='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' ;; esac fi @@ -20491,52 +34508,52 @@ fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) - no_undefined_flag_CXX='${wl}-z,text' + no_undefined_flag_CXX='$wl-z,text' archive_cmds_need_lc_CXX=no hardcode_shlibpath_var_CXX=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) - archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds_CXX='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) - archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds_CXX='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not + # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. - no_undefined_flag_CXX='${wl}-z,text' - allow_undefined_flag_CXX='${wl}-z,nodefs' + no_undefined_flag_CXX='$wl-z,text' + allow_undefined_flag_CXX='$wl-z,nodefs' archive_cmds_need_lc_CXX=no hardcode_shlibpath_var_CXX=no - hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir' + hardcode_libdir_flag_spec_CXX='$wl-R,$libdir' hardcode_libdir_separator_CXX=':' link_all_deplibs_CXX=yes - export_dynamic_flag_spec_CXX='${wl}-Bexport' + export_dynamic_flag_spec_CXX='$wl-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) - archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds_CXX='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' old_archive_cmds_CXX='$CC -Tprelink_objects $oldobjs~ - '"$old_archive_cmds_CXX" + '"$old_archive_cmds_CXX" reload_cmds_CXX='$CC -Tprelink_objects $reload_objs~ - '"$reload_cmds_CXX" + '"$reload_cmds_CXX" ;; *) - archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds_CXX='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; @@ -20568,10 +34585,10 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 $as_echo "$ld_shlibs_CXX" >&6; } - test "$ld_shlibs_CXX" = no && can_build_shared=no + test no = "$ld_shlibs_CXX" && can_build_shared=no - GCC_CXX="$GXX" - LD_CXX="$LD" + GCC_CXX=$GXX + LD_CXX=$LD ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change @@ -20615,13 +34632,13 @@ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do - case ${prev}${p} in + case $prev$p in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. - if test $p = "-L" || - test $p = "-R"; then + if test x-L = "$p" || + test x-R = "$p"; then prev=$p continue fi @@ -20637,16 +34654,16 @@ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac - if test "$pre_test_object_deps_done" = no; then - case ${prev} in + if test no = "$pre_test_object_deps_done"; then + case $prev in -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$compiler_lib_search_path_CXX"; then - compiler_lib_search_path_CXX="${prev}${p}" + compiler_lib_search_path_CXX=$prev$p else - compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}" + compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} $prev$p" fi ;; # The "-l" case would never come before the object being @@ -20654,9 +34671,9 @@ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 esac else if test -z "$postdeps_CXX"; then - postdeps_CXX="${prev}${p}" + postdeps_CXX=$prev$p else - postdeps_CXX="${postdeps_CXX} ${prev}${p}" + postdeps_CXX="${postdeps_CXX} $prev$p" fi fi prev= @@ -20671,15 +34688,15 @@ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 continue fi - if test "$pre_test_object_deps_done" = no; then + if test no = "$pre_test_object_deps_done"; then if test -z "$predep_objects_CXX"; then - predep_objects_CXX="$p" + predep_objects_CXX=$p else predep_objects_CXX="$predep_objects_CXX $p" fi else if test -z "$postdep_objects_CXX"; then - postdep_objects_CXX="$p" + postdep_objects_CXX=$p else postdep_objects_CXX="$postdep_objects_CXX $p" fi @@ -20709,51 +34726,6 @@ interix[3-9]*) postdep_objects_CXX= postdeps_CXX= ;; - -linux*) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - - # The more standards-conforming stlport4 library is - # incompatible with the Cstd library. Avoid specifying - # it if it's in CXXFLAGS. Ignore libCrun as - # -library=stlport4 depends on it. - case " $CXX $CXXFLAGS " in - *" -library=stlport4 "*) - solaris_use_stlport4=yes - ;; - esac - - if test "$solaris_use_stlport4" != yes; then - postdeps_CXX='-library=Cstd -library=Crun' - fi - ;; - esac - ;; - -solaris*) - case $cc_basename in - CC* | sunCC*) - # The more standards-conforming stlport4 library is - # incompatible with the Cstd library. Avoid specifying - # it if it's in CXXFLAGS. Ignore libCrun as - # -library=stlport4 depends on it. - case " $CXX $CXXFLAGS " in - *" -library=stlport4 "*) - solaris_use_stlport4=yes - ;; - esac - - # Adding this requires a known-good setup of shared libraries for - # Sun compiler versions before 5.6, else PIC objects from an old - # archive will be linked into the output, leading to subtle bugs. - if test "$solaris_use_stlport4" != yes; then - postdeps_CXX='-library=Cstd -library=Crun' - fi - ;; - esac - ;; esac @@ -20762,7 +34734,7 @@ case " $postdeps_CXX " in esac compiler_lib_search_dirs_CXX= if test -n "${compiler_lib_search_path_CXX}"; then - compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` + compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | $SED -e 's! -L! !g' -e 's!^ !!'` fi @@ -20801,17 +34773,18 @@ lt_prog_compiler_static_CXX= # C++ specific cases for pic, static, wl, etc. - if test "$GXX" = yes; then + if test yes = "$GXX"; then lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='-static' case $host_os in aix*) # All AIX code is PIC. - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_CXX='-Bstatic' fi + lt_prog_compiler_pic_CXX='-fPIC' ;; amigaos*) @@ -20822,8 +34795,8 @@ lt_prog_compiler_static_CXX= ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. + # adding the '-m68020' flag to GCC prevents building anything better, + # like '-m68040'. lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4' ;; esac @@ -20838,6 +34811,11 @@ lt_prog_compiler_static_CXX= # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic_CXX='-DDLL_EXPORT' + case $host_os in + os2*) + lt_prog_compiler_static_CXX='$wl-static' + ;; + esac ;; darwin* | rhapsody*) # PIC is the default on this platform @@ -20887,7 +34865,7 @@ lt_prog_compiler_static_CXX= case $host_os in aix[4-9]*) # All AIX code is PIC. - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_CXX='-Bstatic' else @@ -20927,14 +34905,14 @@ lt_prog_compiler_static_CXX= case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' - if test "$host_cpu" != ia64; then + lt_prog_compiler_static_CXX='$wl-a ${wl}archive' + if test ia64 != "$host_cpu"; then lt_prog_compiler_pic_CXX='+Z' fi ;; aCC*) lt_prog_compiler_wl_CXX='-Wl,' - lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' + lt_prog_compiler_static_CXX='$wl-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default @@ -20971,7 +34949,7 @@ lt_prog_compiler_static_CXX= lt_prog_compiler_pic_CXX='-fPIC' ;; ecpc* ) - # old Intel C++ for x86_64 which still supported -KPIC. + # old Intel C++ for x86_64, which still supported -KPIC. lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-static' @@ -21116,7 +35094,7 @@ lt_prog_compiler_static_CXX= fi case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: + # For platforms that do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic_CXX= ;; @@ -21148,7 +35126,7 @@ else lt_cv_prog_compiler_pic_works_CXX=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" + lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins @@ -21178,7 +35156,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5 $as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; } -if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then +if test yes = "$lt_cv_prog_compiler_pic_works_CXX"; then case $lt_prog_compiler_pic_CXX in "" | " "*) ;; *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; @@ -21204,7 +35182,7 @@ if ${lt_cv_prog_compiler_static_works_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works_CXX=no - save_LDFLAGS="$LDFLAGS" + save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then @@ -21223,13 +35201,13 @@ else fi fi $RM -r conftest* - LDFLAGS="$save_LDFLAGS" + LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5 $as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; } -if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then +if test yes = "$lt_cv_prog_compiler_static_works_CXX"; then : else lt_prog_compiler_static_CXX= @@ -21343,8 +35321,8 @@ $as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } -hard_links="nottested" -if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then +hard_links=nottested +if test no = "$lt_cv_prog_compiler_c_o_CXX" && test no != "$need_locks"; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } @@ -21356,9 +35334,9 @@ $as_echo_n "checking if we can lock with hard links... " >&6; } ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } - if test "$hard_links" = no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 -$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + if test no = "$hard_links"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 +$as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} need_locks=warn fi else @@ -21375,17 +35353,21 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie case $host_os in aix[4-9]*) # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - # Also, AIX nm treats weak defined symbols like other global defined - # symbols, whereas GNU nm marks them as "W". + # -C means demangle to GNU nm, but means don't demangle to AIX nm. + # Without the "-l" option, or with the "-B" option, AIX nm treats + # weak defined symbols like other global defined symbols, whereas + # GNU nm marks them as "W". + # While the 'weak' keyword is ignored in the Export File, we need + # it in the Import File for the 'aix-soname' feature, so we have + # to replace the "-B" option with "-P" for AIX nm. if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else - export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + export_symbols_cmds_CXX='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi ;; pw32*) - export_symbols_cmds_CXX="$ltdll_cmds" + export_symbols_cmds_CXX=$ltdll_cmds ;; cygwin* | mingw* | cegcc*) case $cc_basename in @@ -21408,7 +35390,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 $as_echo "$ld_shlibs_CXX" >&6; } -test "$ld_shlibs_CXX" = no && can_build_shared=no +test no = "$ld_shlibs_CXX" && can_build_shared=no with_gnu_ld_CXX=$with_gnu_ld @@ -21425,7 +35407,7 @@ x|xyes) # Assume -lc should be added archive_cmds_need_lc_CXX=yes - if test "$enable_shared" = yes && test "$GCC" = yes; then + if test yes,yes = "$GCC,$enable_shared"; then case $archive_cmds_CXX in *'~'*) # FIXME: we may have to deal with multi-command sequences. @@ -21553,7 +35535,7 @@ $as_echo_n "checking dynamic linker characteristics... " >&6; } library_names_spec= libname_spec='lib$name' soname_spec= -shrext_cmds=".so" +shrext_cmds=.so postinstall_cmds= postuninstall_cmds= finish_cmds= @@ -21570,14 +35552,16 @@ hardcode_into_libs=no # flags to be left without arguments need_version=unknown + + case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + library_names_spec='$libname$release$shared_ext$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' + soname_spec='$libname$release$shared_ext$major' ;; aix[4-9]*) @@ -21585,41 +35569,91 @@ aix[4-9]*) need_lib_prefix=no need_version=no hardcode_into_libs=yes - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in + # the line '#! .'. This would cause the generated library to + # depend on '.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' - echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then + echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # Using Import Files as archive members, it is possible to support + # filename-based versioning of shared library archives on AIX. While + # this would work for both with and without runtime linking, it will + # prevent static linking of such archives. So we do filename-based + # shared library versioning with .so extension only, which is used + # when both runtime linking and shared linking is enabled. + # Unfortunately, runtime linking may impact performance, so we do + # not want this to be the default eventually. Also, we use the + # versioned .so libs for executables only if there is the -brtl + # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. + # To allow for filename-based versioning support, we need to create + # libNAME.so.V as an archive file, containing: + # *) an Import File, referring to the versioned filename of the + # archive as well as the shared archive member, telling the + # bitwidth (32 or 64) of that shared object, and providing the + # list of exported symbols of that shared object, eventually + # decorated with the 'weak' keyword + # *) the shared object with the F_LOADONLY flag set, to really avoid + # it being seen by the linker. + # At run time we better use the real file rather than another symlink, + # but for link time we create the symlink libNAME.so -> libNAME.so.V + + case $with_aix_soname,$aix_use_runtimelinking in + # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then + aix,yes) # traditional libtool + dynamic_linker='AIX unversionable lib.so' # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + aix,no) # traditional AIX only + dynamic_linker='AIX lib.a(lib.so.V)' # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + ;; + svr4,*) # full svr4 only + dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,yes) # both, prefer svr4 + dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # unpreferred sharedlib libNAME.a needs extra handling + postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' + postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,no) # both, prefer aix + dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)" + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling + postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' + postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' + ;; + esac shlibpath_var=LIBPATH fi ;; @@ -21629,18 +35663,18 @@ amigaos*) powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) - library_names_spec='${libname}${shared_ext}' + library_names_spec='$libname$shared_ext' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; @@ -21648,8 +35682,8 @@ beos*) bsdi[45]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" @@ -21661,7 +35695,7 @@ bsdi[45]*) cygwin* | mingw* | pw32* | cegcc*) version_type=windows - shrext_cmds=".dll" + shrext_cmds=.dll need_version=no need_lib_prefix=no @@ -21670,8 +35704,8 @@ cygwin* | mingw* | pw32* | cegcc*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ @@ -21687,16 +35721,16 @@ cygwin* | mingw* | pw32* | cegcc*) case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; esac dynamic_linker='Win32 ld.exe' @@ -21705,8 +35739,8 @@ cygwin* | mingw* | pw32* | cegcc*) *,cl*) # Native MSVC libname_spec='$name' - soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - library_names_spec='${libname}.dll.lib' + soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + library_names_spec='$libname.dll.lib' case $build_os in mingw*) @@ -21733,7 +35767,7 @@ cygwin* | mingw* | pw32* | cegcc*) sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) - sys_lib_search_path_spec="$LIB" + sys_lib_search_path_spec=$LIB if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` @@ -21746,8 +35780,8 @@ cygwin* | mingw* | pw32* | cegcc*) esac # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' @@ -21760,7 +35794,7 @@ cygwin* | mingw* | pw32* | cegcc*) *) # Assume MSVC wrapper - library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac @@ -21773,8 +35807,8 @@ darwin* | rhapsody*) version_type=darwin need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' + library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' + soname_spec='$libname$release$major$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' @@ -21786,8 +35820,8 @@ dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; @@ -21805,12 +35839,13 @@ freebsd* | dragonfly*) version_type=freebsd-$objformat case $version_type in freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' need_version=no need_lib_prefix=no ;; freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' need_version=yes ;; esac @@ -21840,10 +35875,10 @@ haiku*) need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LIBRARY_PATH - shlibpath_overrides_runpath=yes + shlibpath_overrides_runpath=no sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; @@ -21861,14 +35896,15 @@ hpux9* | hpux10* | hpux11*) dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + if test 32 = "$HPUX_IA64_MODE"; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + sys_lib_dlsearch_path_spec=/usr/lib/hpux32 else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + sys_lib_dlsearch_path_spec=/usr/lib/hpux64 fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' @@ -21876,8 +35912,8 @@ hpux9* | hpux10* | hpux11*) dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; @@ -21886,8 +35922,8 @@ hpux9* | hpux10* | hpux11*) dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... @@ -21900,8 +35936,8 @@ interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no @@ -21912,7 +35948,7 @@ irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) - if test "$lt_cv_prog_gnu_ld" = yes; then + if test yes = "$lt_cv_prog_gnu_ld"; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix @@ -21920,8 +35956,8 @@ irix5* | irix6* | nonstopux*) esac need_lib_prefix=no need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= @@ -21940,8 +35976,8 @@ irix5* | irix6* | nonstopux*) esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" + sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" hardcode_into_libs=yes ;; @@ -21950,13 +35986,33 @@ linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; +linux*android*) + version_type=none # Android doesn't support versioned libraries. + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext' + soname_spec='$libname$release$shared_ext' + finish_cmds= + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + dynamic_linker='Android linker' + # Don't embed -rpath directories since the linker doesn't support them. + hardcode_libdir_flag_spec_CXX='-L$libdir' + ;; + # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no @@ -22000,7 +36056,12 @@ fi # before this can be enabled. hardcode_into_libs=yes - # Append ld.so.conf contents to the search path + # Ideally, we could use ldconfig to report *all* directores which are + # searched for libraries, however this is still not possible. Aside from not + # being certain /sbin/ldconfig is available, command + # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, + # even though it is searched at run-time. Try to do the best guess by + # appending ld.so.conf contents (and includes) to the search path. if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" @@ -22032,12 +36093,12 @@ netbsd*) need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH @@ -22047,7 +36108,7 @@ netbsd*) newsos6) version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; @@ -22056,58 +36117,68 @@ newsos6) version_type=qnx need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; -openbsd*) +openbsd* | bitrig*) version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" + sys_lib_dlsearch_path_spec=/usr/lib need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + need_version=no + else + need_version=yes + fi + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[89] | openbsd2.[89].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi + shlibpath_overrides_runpath=yes ;; os2*) libname_spec='$name' - shrext_cmds=".dll" + version_type=windows + shrext_cmds=.dll + need_version=no need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' + # OS/2 can only load a DLL with a base name of 8 characters or less. + soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; + v=$($ECHO $release$versuffix | tr -d .-); + n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); + $ECHO $n$v`$shared_ext' + library_names_spec='${libname}_dll.$libext' dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH + shlibpath_var=BEGINLIBPATH + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; rdos*) @@ -22118,8 +36189,8 @@ solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes @@ -22129,11 +36200,11 @@ solaris*) sunos4*) version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then + if test yes = "$with_gnu_ld"; then need_lib_prefix=no fi need_version=yes @@ -22141,8 +36212,8 @@ sunos4*) sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) @@ -22163,24 +36234,24 @@ sysv4 | sysv4.3*) ;; sysv4*MP*) - if test -d /usr/nec ;then + if test -d /usr/nec; then version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' + library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' + soname_spec='$libname$shared_ext.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf + version_type=sco need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then + if test yes = "$with_gnu_ld"; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' @@ -22198,7 +36269,7 @@ tpf*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes @@ -22206,8 +36277,8 @@ tpf*) uts4*) version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; @@ -22217,20 +36288,32 @@ uts4*) esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } -test "$dynamic_linker" = no && can_build_shared=no +test no = "$dynamic_linker" && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then +if test yes = "$GCC"; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi -if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then - sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then + sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec fi -if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then - sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" + +if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then + sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec fi +# remember unaugmented sys_lib_dlsearch_path content for libtool script decls... +configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec + +# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code +func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" + +# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool +configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH + + + @@ -22273,15 +36356,15 @@ $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action_CXX= if test -n "$hardcode_libdir_flag_spec_CXX" || test -n "$runpath_var_CXX" || - test "X$hardcode_automatic_CXX" = "Xyes" ; then + test yes = "$hardcode_automatic_CXX"; then # We can hardcode non-existent directories. - if test "$hardcode_direct_CXX" != no && + if test no != "$hardcode_direct_CXX" && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one - ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no && - test "$hardcode_minus_L_CXX" != no; then + ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" && + test no != "$hardcode_minus_L_CXX"; then # Linking always hardcodes the temporary library directory. hardcode_action_CXX=relink else @@ -22296,12 +36379,12 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5 $as_echo "$hardcode_action_CXX" >&6; } -if test "$hardcode_action_CXX" = relink || - test "$inherit_rpath_CXX" = yes; then +if test relink = "$hardcode_action_CXX" || + test yes = "$inherit_rpath_CXX"; then # Fast installation is not supported enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then +elif test yes = "$shlibpath_overrides_runpath" || + test no = "$enable_shared"; then # Fast installation is not necessary enable_fast_install=needless fi @@ -22324,7 +36407,7 @@ fi lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld -fi # test "$_lt_caught_CXX_error" != yes +fi # test yes != "$_lt_caught_CXX_error" ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -22355,6 +36438,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu +GCC="$SAVED_GCC" +CC="$SAVED_CC" + +if ( test "${GCC}" = "yes" ) +then + CFLAGS="$CFLAGS_SAVED_NOPEDANTIC" +fi + if test "${nut_with_dev}" != "no"; then nut_with_dev="yes" else @@ -22367,14 +36458,14 @@ if test "${enable_static+set}" = set; then : *) enable_static=no # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_static=yes fi done - IFS="$lt_save_ifs" + IFS=$lt_save_ifs ;; esac else @@ -22683,9 +36774,9 @@ _ACEOF $as_echo "${RUN_AS_GROUP}" >&6; } if test "${nut_user_given}" = "yes" -a "${nut_group_given}" = "no"; then - as_fn_error $? "\"If you specify --with-user, you also must specify --with-group\"" "$LINENO" 5 + as_fn_error $? "If you specify --with-user, you also must specify --with-group" "$LINENO" 5 elif test "${nut_user_given}" = "no" -a "${nut_group_given}" = "yes"; then - as_fn_error $? "\"If you specify --with-group, you also must specify --with-user\"" "$LINENO" 5 + as_fn_error $? "If you specify --with-group, you also must specify --with-user" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking facility for syslog" >&5 @@ -22717,67 +36808,27 @@ _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${LOGFACILITY}" >&5 $as_echo "${LOGFACILITY}" >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which drivers to build" >&5 -$as_echo_n "checking which drivers to build... " >&6; } - -# Check whether --with-drivers was given. -if test "${with_drivers+set}" = set; then : - withval=$with_drivers; - case "${withval}" in - yes|no) - as_fn_error $? "invalid option --with(out)-drivers - see docs/configure.txt" "$LINENO" 5 - ;; - *) - DRIVER_BUILD_LIST=`echo ${withval} | sed "s/,/ /g"` - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${DRIVER_BUILD_LIST}" >&5 -$as_echo "${DRIVER_BUILD_LIST}" >&6; } - ;; - esac - -else - - DRIVER_BUILD_LIST="all" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: all available" >&5 -$as_echo "all available" >&6; } - -fi - - if test "${DRIVER_BUILD_LIST}" != "all"; then - SOME_DRIVERS_TRUE= - SOME_DRIVERS_FALSE='#' -else - SOME_DRIVERS_TRUE='#' - SOME_DRIVERS_FALSE= -fi - - -if test "${DRIVER_BUILD_LIST}" != "all"; then - if test -z "${nut_report_feature_flag}"; then - nut_report_feature_flag="1" - ac_clean_files="${ac_clean_files} conf_nut_report_feature" - echo > conf_nut_report_feature - echo "Configuration summary:" >> conf_nut_report_feature - echo "======================" >> conf_nut_report_feature - fi - echo "only build specific drivers: ${DRIVER_BUILD_LIST}" >> conf_nut_report_feature - -fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking which driver man pages to install" >&5 $as_echo_n "checking which driver man pages to install... " >&6; } -if test "${DRIVER_BUILD_LIST}" = "all"; then - DRIVER_MAN_LIST=all - { $as_echo "$as_me:${as_lineno-$LINENO}: result: all available" >&5 +if test "${WITH_MANS}" = "yes"; then + if test "${DRIVER_BUILD_LIST}" = "all"; then + DRIVER_MAN_LIST=all + { $as_echo "$as_me:${as_lineno-$LINENO}: result: all available" >&5 $as_echo "all available" >&6; } + else + DRIVER_MAN_LIST="" + for i in ${DRIVER_BUILD_LIST}; do + if test -f ${srcdir}/docs/man/$i.8; then + DRIVER_MAN_LIST="${DRIVER_MAN_LIST} $i.8" + fi + done + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${DRIVER_MAN_LIST}" >&5 +$as_echo "${DRIVER_MAN_LIST}" >&6; } + fi else DRIVER_MAN_LIST="" - for i in ${DRIVER_BUILD_LIST}; do - if test -f ${srcdir}/docs/man/$i.8; then - DRIVER_MAN_LIST="${DRIVER_MAN_LIST} $i.8" - fi - done - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${DRIVER_MAN_LIST}" >&5 -$as_echo "${DRIVER_MAN_LIST}" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none (manpages disabled)" >&5 +$as_echo "none (manpages disabled)" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to strip debug symbols" >&5 @@ -22785,7 +36836,7 @@ $as_echo_n "checking whether to strip debug symbols... " >&6; } # Check whether --enable-strip was given. if test "${enable_strip+set}" = set; then : enableval=$enable_strip; - case "${withval}" in + case "${enableval}" in no) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } @@ -22840,135 +36891,147 @@ else fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to install Solaris SMF files" >&5 +$as_echo_n "checking whether to install Solaris SMF files... " >&6; } +solarissmf="auto" - - - - - - -if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. -set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_PKG_CONFIG+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $PKG_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -PKG_CONFIG=$ac_cv_path_PKG_CONFIG -if test -n "$PKG_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 -$as_echo "$PKG_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - +# Check whether --with-solaris-smf was given. +if test "${with_solaris_smf+set}" = set; then : + withval=$with_solaris_smf; + case "${withval}" in + auto|"") + solarissmf="auto" + ;; + yes|no) + solarissmf="${withval}" + ;; + *) + as_fn_error $? "Unexpected argument for --with-solaris-smf=${withval}" "$LINENO" 5 + ;; + esac fi -if test -z "$ac_cv_path_PKG_CONFIG"; then - ac_pt_PKG_CONFIG=$PKG_CONFIG - # Extract the first word of "pkg-config", so it can be a program name with args. -set dummy pkg-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $ac_pt_PKG_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - ;; -esac -fi -ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG -if test -n "$ac_pt_PKG_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 -$as_echo "$ac_pt_PKG_CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - if test "x$ac_pt_PKG_CONFIG" = x; then - PKG_CONFIG="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - PKG_CONFIG=$ac_pt_PKG_CONFIG - fi -else - PKG_CONFIG="$ac_cv_path_PKG_CONFIG" -fi - -fi -if test -n "$PKG_CONFIG"; then - _pkg_min_version=0.9.0 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 -$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } - if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } +if test x"$solarissmf" = xauto ; then + if test -x /usr/sbin/svcadm && test -x /usr/sbin/svccfg && test -x /usr/bin/svcs ; then + solarissmf="yes" else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - PKG_CONFIG="" + solarissmf="no" fi fi -systemdsystemunitdir=`$PKG_CONFIG --variable=systemdsystemunitdir systemd` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to install systemd files" >&5 -$as_echo_n "checking whether to install systemd files... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${solarissmf}" >&5 +$as_echo "${solarissmf}" >&6; } + if test x"$solarissmf" = x"yes"; then + WITH_SOLARIS_SMF_TRUE= + WITH_SOLARIS_SMF_FALSE='#' +else + WITH_SOLARIS_SMF_TRUE='#' + WITH_SOLARIS_SMF_FALSE= +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to make Solaris SVR4 packages" >&5 +$as_echo_n "checking whether to make Solaris SVR4 packages... " >&6; } +solarispkg_svr4="auto" + +# Check whether --with-solaris-pkg-svr4 was given. +if test "${with_solaris_pkg_svr4+set}" = set; then : + withval=$with_solaris_pkg_svr4; + case "${withval}" in + auto|"") + solarispkg_svr4="auto" + ;; + yes|no) + solarispkg_svr4="${withval}" + ;; + *) + as_fn_error $? "Unexpected argument for --with-solaris-pkg-svr4=${withval}" "$LINENO" 5 + ;; + esac + +fi + + +if test x"$solarispkg_svr4" = xauto ; then + if test -x /usr/bin/pkgtrans && test -x /usr/bin/pkgmk && test -x /usr/bin/pkgproto ; then + solarispkg_svr4="yes" + else + solarispkg_svr4="no" + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${solarispkg_svr4}" >&5 +$as_echo "${solarispkg_svr4}" >&6; } + if test x"$solarispkg_svr4" = x"yes"; then + WITH_SOLARIS_PKG_SVR4_TRUE= + WITH_SOLARIS_PKG_SVR4_FALSE='#' +else + WITH_SOLARIS_PKG_SVR4_TRUE='#' + WITH_SOLARIS_PKG_SVR4_FALSE= +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to make Solaris IPS packages" >&5 +$as_echo_n "checking whether to make Solaris IPS packages... " >&6; } +solarispkg_ips="auto" + +# Check whether --with-solaris-pkg-ips was given. +if test "${with_solaris_pkg_ips+set}" = set; then : + withval=$with_solaris_pkg_ips; + case "${withval}" in + auto|"") + solarispkg_ips="auto" + ;; + yes|no) + solarispkg_ips="${withval}" + ;; + *) + as_fn_error $? "Unexpected argument for --with-solaris-pkg-ips=${withval}" "$LINENO" 5 + ;; + esac + +fi + + +if test x"$solarispkg_ips" = xauto ; then + if test -x /usr/bin/pkg && test -x /usr/bin/pkgmogrify && test -x /usr/bin/pkgdepend ; then + solarispkg_ips="yes" + else + solarispkg_ips="no" + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${solarispkg_ips}" >&5 +$as_echo "${solarispkg_ips}" >&6; } + if test x"$solarispkg_ips" = x"yes"; then + WITH_SOLARIS_PKG_IPS_TRUE= + WITH_SOLARIS_PKG_IPS_FALSE='#' +else + WITH_SOLARIS_PKG_IPS_TRUE='#' + WITH_SOLARIS_PKG_IPS_FALSE= +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to install systemd unit files" >&5 +$as_echo_n "checking whether to install systemd unit files... " >&6; } # Check whether --with-systemdsystemunitdir was given. if test "${with_systemdsystemunitdir+set}" = set; then : - withval=$with_systemdsystemunitdir; - case "${withval}" in - yes|auto) + withval=$with_systemdsystemunitdir; systemdsystemunitdir="${withval}" +else + systemdsystemunitdir="auto" +fi + +case "${systemdsystemunitdir}" in + yes|auto|"") + if test x"$have_PKG_CONFIG" = xyes; then : + systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir systemd 2>/dev/null`" && test -n "$systemdsystemunitdir" || systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir libsystemd 2>/dev/null`" +else + if test "${withval}" = yes; then : + as_fn_error $? "--with-systemdsystemunitdir=${withval} was requested, but PKG_CONFIG could not be queried for the system settings" "$LINENO" 5 +fi + systemdsystemunitdir="" + +fi ;; no) systemdsystemunitdir="" @@ -22976,12 +37039,9 @@ if test "${with_systemdsystemunitdir+set}" = set; then : *) systemdsystemunitdir="${withval}" ;; - esac - -fi - +esac +if test "${systemdsystemunitdir}" = "auto" ; then systemdsystemunitdir=""; fi if test -n "${systemdsystemunitdir}"; then - systemdsystemshutdowndir="${libdir}/systemd/system-shutdown" { $as_echo "$as_me:${as_lineno-$LINENO}: result: using ${systemdsystemunitdir}" >&5 $as_echo "using ${systemdsystemunitdir}" >&6; } else @@ -22997,6 +37057,561 @@ else fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to install systemd shutdown files" >&5 +$as_echo_n "checking whether to install systemd shutdown files... " >&6; } + +# Check whether --with-systemdshutdowndir was given. +if test "${with_systemdshutdowndir+set}" = set; then : + withval=$with_systemdshutdowndir; systemdshutdowndir="${withval}" +else + systemdshutdowndir="auto" +fi + +if test -n "${systemdsystemunitdir}"; then + case "${systemdshutdowndir}" in + yes|auto|"") + if test x"$have_PKG_CONFIG" = xyes; then : + systemdshutdowndir="`$PKG_CONFIG --variable=systemdshutdowndir systemd 2>/dev/null`" && test -n "$systemdshutdowndir" || systemdshutdowndir="`$PKG_CONFIG --variable=systemdshutdowndir libsystemd 2>/dev/null`" +else + if test "${systemdshutdowndir}" = yes; then : + as_fn_error $? "--with-systemdshutdowndir=${systemdshutdowndir} was requested, but PKG_CONFIG could not be queried for the system settings" "$LINENO" 5 +fi + systemdshutdowndir="" + +fi + ;; + no) + systemdshutdowndir="" + ;; + *) + systemdshutdowndir="${withval}" + ;; + esac +fi +if test "${systemdshutdowndir}" = "auto" ; then systemdshutdowndir=""; fi +if test -n "${systemdshutdowndir}"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: using ${systemdshutdowndir}" >&5 +$as_echo "using ${systemdshutdowndir}" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to install systemd tmpfiles files" >&5 +$as_echo_n "checking whether to install systemd tmpfiles files... " >&6; } + +# Check whether --with-systemdtmpfilesdir was given. +if test "${with_systemdtmpfilesdir+set}" = set; then : + withval=$with_systemdtmpfilesdir; systemdtmpfilesdir="${withval}" +else + systemdtmpfilesdir="auto" +fi + +case "${systemdtmpfilesdir}" in + yes|auto|"") + if test x"$have_PKG_CONFIG" = xyes; then : + systemdtmpfilesdir="`$PKG_CONFIG --variable=tmpfilesdir systemd 2>/dev/null`" && test -n "$systemdtmpfilesdir" || systemdtmpfilesdir="`$PKG_CONFIG --variable=tmpfilesdir libsystemd 2>/dev/null`" +else + if test "${systemdtmpfilesdir}" = yes; then : + as_fn_error $? "--with-systemdtmpfilesdir=${systemdtmpfilesdir} was requested, but PKG_CONFIG could not be queried for the system settings" "$LINENO" 5 +fi + systemdtmpfilesdir="" + +fi + ;; + no) + systemdtmpfilesdir="" + ;; + *) + systemdtmpfilesdir="${withval}" + ;; +esac +if test "${systemdtmpfilesdir}" = "auto" ; then systemdtmpfilesdir=""; fi +if test -n "${systemdtmpfilesdir}"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: using ${systemdtmpfilesdir}" >&5 +$as_echo "using ${systemdtmpfilesdir}" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++11 support in current compiler" >&5 +$as_echo_n "checking for C++11 support in current compiler... " >&6; } +have_cxx11=unknown +my_CXXFLAGS="$CXXFLAGS" +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + +CPLUSPLUS_DECL=' +#include +#if __cplusplus < 201103L + #error This library needs at least a C++11 compliant compiler +#endif +' +CPLUSPLUS_MAIN='printf("%ld\n", __cplusplus);' + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +${CPLUSPLUS_DECL} +int +main () +{ +${CPLUSPLUS_MAIN} + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, out of the box" >&5 +$as_echo "yes, out of the box" >&6; } + have_cxx11=yes +else + case "${CXXFLAGS}" in #( + *"-std="*) : + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, not with the standard already set in CXXFLAGS='${CXXFLAGS}'" >&5 +$as_echo "no, not with the standard already set in CXXFLAGS='${CXXFLAGS}'" >&6; } + have_cxx11=no, + ;; #( + *) : + + CXXFLAGS="$CXXFLAGS -std=c++11" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +${CPLUSPLUS_DECL} +int +main () +{ +${CPLUSPLUS_MAIN} + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, GCC-style (as C++11)" >&5 +$as_echo "yes, GCC-style (as C++11)" >&6; } + have_cxx11=yes +else + CXXFLAGS="$CXXFLAGS -std=c++0x" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +${CPLUSPLUS_DECL} +int +main () +{ +${CPLUSPLUS_MAIN} + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, GCC-style (as C++0X)" >&5 +$as_echo "yes, GCC-style (as C++0X)" >&6; } + have_cxx11=yes +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + CXXFLAGS="$my_CXXFLAGS" + have_cxx11=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if test "${have_cxx11}" = "yes"; then + HAVE_CXX11_TRUE= + HAVE_CXX11_FALSE='#' +else + HAVE_CXX11_TRUE='#' + HAVE_CXX11_FALSE= +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +unset CPLUSPLUS_MAIN +unset CPLUSPLUS_DECL + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for have_cppunit" >&5 +$as_echo_n "checking for have_cppunit... " >&6; } +have_cppunit="no" +CPPUNIT_NUT_CXXFLAGS="" +if test x"$have_PKG_CONFIG" = xyes; then : + if test x"${have_cxx11}" = xyes; then : + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cppunit" >&5 +$as_echo_n "checking for cppunit... " >&6; } + +if test -n "$CPPUNIT_CFLAGS"; then + pkg_cv_CPPUNIT_CFLAGS="$CPPUNIT_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"cppunit\""; } >&5 + ($PKG_CONFIG --exists --print-errors "cppunit") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_CPPUNIT_CFLAGS=`$PKG_CONFIG --cflags "cppunit" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$CPPUNIT_LIBS"; then + pkg_cv_CPPUNIT_LIBS="$CPPUNIT_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"cppunit\""; } >&5 + ($PKG_CONFIG --exists --print-errors "cppunit") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_CPPUNIT_LIBS=`$PKG_CONFIG --libs "cppunit" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + CPPUNIT_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "cppunit" 2>&1` + else + CPPUNIT_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "cppunit" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$CPPUNIT_PKG_ERRORS" >&5 + + have_cppunit=no +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + have_cppunit=no +else + CPPUNIT_CFLAGS=$pkg_cv_CPPUNIT_CFLAGS + CPPUNIT_LIBS=$pkg_cv_CPPUNIT_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + have_cppunit=yes +fi + if test "${have_cppunit}" != "yes"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libcppunit not found - those C++ tests will not be built." >&5 +$as_echo "$as_me: WARNING: libcppunit not found - those C++ tests will not be built." >&2;} + have_cppunit=no +else + if test -n "$CXX"; then : + if $CXX --version 2>&1 | grep 'Free Software Foundation' > /dev/null; then : + CPPUNIT_NUT_CXXFLAGS="-g -O0" +fi +fi + +fi + +fi + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config not found, can not look properly for libcppunit - those C++ tests will not be built." >&5 +$as_echo "$as_me: WARNING: pkg-config not found, can not look properly for libcppunit - those C++ tests will not be built." >&2;} + have_cppunit=no + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${have_cppunit}" >&5 +$as_echo "${have_cppunit}" >&6; } + +if test "${have_cppunit}" = "yes"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if current toolkit can build and run cppunit tests (e.g. no ABI issues, related segfaults, etc.)" >&5 +$as_echo_n "checking if current toolkit can build and run cppunit tests (e.g. no ABI issues, related segfaults, etc.)... " >&6; } + CPLUSPLUS_DECL=' +#include +#include +#include +#include +#include + +class ExampleTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE( ExampleTest ); + CPPUNIT_TEST( testOne ); + CPPUNIT_TEST_SUITE_END(); +public: + void setUp() {}; + void tearDown() {}; + void testOne(); +}; +CPPUNIT_TEST_SUITE_REGISTRATION( ExampleTest ); +void ExampleTest::testOne() +{ + int i = 1; + float f = 1.0; + int cast = static_cast(f); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Casted float is not the expected int (assert_eq)", i, cast ); + CPPUNIT_ASSERT_MESSAGE("Casted float is not the expected int (assert)", (i == cast) ); +} +' + + CPLUSPLUS_MAIN=' +CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); +CppUnit::TextUi::TestRunner runner; +runner.addTest( suite ); +runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), std::cerr ) ); +bool res = runner.run(); +return res ? 0 : 1; +' + + my_CXXFLAGS="$CXXFLAGS" + my_LDFLAGS="$LDFLAGS" + my_LIBS="$LIBS" + CXXFLAGS="$myCXXFLAGS $pkg_cv_CPPUNIT_CFLAGS $pkg_cv_CPPUNIT_CXXFLAGS" + LDFLAGS="$my_LDFLAGS $pkg_cv_CPPUNIT_LDFLAGS" + LIBS="$my_LIBS $pkg_cv_CPPUNIT_LIBS" + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + if test "$cross_compiling" = yes; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&5 +$as_echo "$as_me: WARNING: Current build is a cross-build, so not running test binaries, just linking them" >&2;} + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +${CPLUSPLUS_DECL} +int +main () +{ +${CPLUSPLUS_MAIN} + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + have_cppunit=yes +else + have_cppunit=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +${CPLUSPLUS_DECL} +int +main () +{ +${CPLUSPLUS_MAIN} + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_run "$LINENO"; then : + have_cppunit=yes +else + have_cppunit=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + + CXXFLAGS="$my_CXXFLAGS" + LDFLAGS="$my_LDFLAGS" + LIBS="$my_LIBS" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + unset CPLUSPLUS_MAIN + unset CPLUSPLUS_DECL + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${have_cppunit}" >&5 +$as_echo "${have_cppunit}" >&6; } + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for impact from --enable-cppunit option - should we build cppunit tests?" >&5 +$as_echo_n "checking for impact from --enable-cppunit option - should we build cppunit tests?... " >&6; } +# Check whether --enable-cppunit was given. +if test "${enable_cppunit+set}" = set; then : + enableval=$enable_cppunit; case "${enableval}" in #( + "yes") : + if test x"${have_cppunit}" = xyes; then : + +else + as_fn_error $? "--with-cppunit=yes can not be satisfied" "$LINENO" 5 +fi ;; #( + "no") : + have_cppunit=no + ;; #( + *) : + ;; +esac +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${have_cppunit}" >&5 +$as_echo "${have_cppunit}" >&6; } + + if test "${have_cppunit}" = "yes"; then + HAVE_CPPUNIT_TRUE= + HAVE_CPPUNIT_FALSE='#' +else + HAVE_CPPUNIT_TRUE='#' + HAVE_CPPUNIT_FALSE= +fi + + +cat >>confdefs.h <<_ACEOF +#define CPPUNIT_NUT_CXXFLAGS $CPPUNIT_NUT_CXXFLAGS +_ACEOF + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to install Augeas configuration-management lenses" >&5 +$as_echo_n "checking whether to install Augeas configuration-management lenses... " >&6; } + +# Check whether --with-augeas-lenses-dir was given. +if test "${with_augeas_lenses_dir+set}" = set; then : + withval=$with_augeas_lenses_dir; + case "${withval}" in + yes) + if test -z "${auglensdir}"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "augeas lenses directory requested but not found in default location" "$LINENO" 5 + fi + if ! test -s scripts/augeas/nutupsconf.aug.in ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "augeas lenses directory requested but a non-trivial scripts/augeas/nutupsconf.aug.in was not provided by autogen.sh or dist archive" "$LINENO" 5 + fi + ;; + auto) + if ! test -s scripts/augeas/nutupsconf.aug.in ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: augeas lenses directory skipped because a non-trivial scripts/augeas/nutupsconf.aug.in was not provided by autogen.sh or dist archive" >&5 +$as_echo "$as_me: WARNING: augeas lenses directory skipped because a non-trivial scripts/augeas/nutupsconf.aug.in was not provided by autogen.sh or dist archive" >&2;} + auglensdir="" + fi + ;; + no) + auglensdir="" + ;; + *) + auglensdir="${withval}" + ;; + esac + +fi + +if test -n "${auglensdir}"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: using ${auglensdir}" >&5 +$as_echo "using ${auglensdir}" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + if test -n "${auglensdir}"; then + WITH_AUGLENS_TRUE= + WITH_AUGLENS_FALSE='#' +else + WITH_AUGLENS_TRUE='#' + WITH_AUGLENS_FALSE= +fi + + +for ac_prog in augparse +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_AUGPARSE+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $AUGPARSE in + [\\/]* | ?:[\\/]*) + ac_cv_path_AUGPARSE="$AUGPARSE" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_AUGPARSE="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +AUGPARSE=$ac_cv_path_AUGPARSE +if test -n "$AUGPARSE"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AUGPARSE" >&5 +$as_echo "$AUGPARSE" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AUGPARSE" && break +done +test -n "$AUGPARSE" || AUGPARSE="none" + + if test "x${AUGPARSE}" != "xnone"; then + HAVE_AUGPARSE_TRUE= + HAVE_AUGPARSE_FALSE='#' +else + HAVE_AUGPARSE_TRUE='#' + HAVE_AUGPARSE_FALSE= +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable Augeas configuration-management lenses tests" >&5 +$as_echo_n "checking whether to enable Augeas configuration-management lenses tests... " >&6; } +if test "x${AUGPARSE}" != xnone ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to install hotplug rules" >&5 $as_echo_n "checking whether to install hotplug rules... " >&6; } @@ -23008,7 +37623,7 @@ if test "${with_hotplug_dir+set}" = set; then : if test -z "${hotplugdir}"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - as_fn_error $? "\"hotplug directory requested but not found\"" "$LINENO" 5 + as_fn_error $? "hotplug directory requested but not found" "$LINENO" 5 fi ;; auto) @@ -23050,10 +37665,20 @@ if test "${with_udev_dir+set}" = set; then : if test -z "${udevdir}"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - as_fn_error $? "\"udev directory requested but not found\"" "$LINENO" 5 + as_fn_error $? "udev directory requested but not found" "$LINENO" 5 + fi + if test "${nut_with_usb}" = yes && ! test -s scripts/udev/nut-usbups.rules.in ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "udev directory and USB driver support requested but a non-trivial scripts/udev/nut-usbups.rules.in was not provided by autogen.sh or dist archive" "$LINENO" 5 fi ;; auto) + if test "${nut_with_usb}" = yes && ! test -s scripts/udev/nut-usbups.rules.in ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: udev directory skipped because a non-trivial scripts/udev/nut-usbups.rules.in was not provided by autogen.sh or dist archive" >&5 +$as_echo "$as_me: WARNING: udev directory skipped because a non-trivial scripts/udev/nut-usbups.rules.in was not provided by autogen.sh or dist archive" >&2;} + udevdir="" + fi ;; no) udevdir="" @@ -23093,10 +37718,20 @@ if test "${with_devd_dir+set}" = set; then : if test -z "${devddir}"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - as_fn_error $? "\"devd directory requested but not found\"" "$LINENO" 5 + as_fn_error $? "devd directory requested but not found" "$LINENO" 5 + fi + if test "${nut_with_usb}" = yes && ! test -s scripts/devd/nut-usbups.rules.in -a -s scripts/devd/nut-usb.conf.in ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "devd directory and USB driver support requested but non-trivial scripts/devd/nut-usbups.rules.in and scripts/devd/nut-usb.conf.in were not provided by autogen.sh or dist archive" "$LINENO" 5 fi ;; auto) + if test "${nut_with_usb}" = yes && ! test -s scripts/devd/nut-usbups.rules.in -a -s scripts/devd/nut-usb.conf.in ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: devd directory skipped because non-trivial scripts/devd/nut-usbups.rules.in and scripts/devd/nut-usb.conf.in were not provided by autogen.sh or dist archive" >&5 +$as_echo "$as_me: WARNING: devd directory skipped because non-trivial scripts/devd/nut-usbups.rules.in and scripts/devd/nut-usb.conf.in were not provided by autogen.sh or dist archive" >&2;} + devddir="" + fi ;; no) devddir="" @@ -23125,162 +37760,6 @@ fi -for ac_prog in asciidoc -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ASCIIDOC+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $ASCIIDOC in - [\\/]* | ?:[\\/]*) - ac_cv_path_ASCIIDOC="$ASCIIDOC" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_ASCIIDOC="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -ASCIIDOC=$ac_cv_path_ASCIIDOC -if test -n "$ASCIIDOC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ASCIIDOC" >&5 -$as_echo "$ASCIIDOC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ASCIIDOC" && break -done -test -n "$ASCIIDOC" || ASCIIDOC="none" - - if test "x$ASCIIDOC" != "xnone"; then - MANUALUPDATE_TRUE= - MANUALUPDATE_FALSE='#' -else - MANUALUPDATE_TRUE='#' - MANUALUPDATE_FALSE= -fi - -for ac_prog in a2x -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_A2X+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $A2X in - [\\/]* | ?:[\\/]*) - ac_cv_path_A2X="$A2X" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_A2X="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -A2X=$ac_cv_path_A2X -if test -n "$A2X"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $A2X" >&5 -$as_echo "$A2X" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$A2X" && break -done -test -n "$A2X" || A2X="none" - - -for ac_prog in aspell -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ASPELL+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $ASPELL in - [\\/]* | ?:[\\/]*) - ac_cv_path_ASPELL="$ASPELL" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_ASPELL="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -ASPELL=$ac_cv_path_ASPELL -if test -n "$ASPELL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ASPELL" >&5 -$as_echo "$ASPELL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ASPELL" && break -done -test -n "$ASPELL" || ASPELL="none" - - if test "x$ASPELL" != "xnone"; then - HAVE_ASPELL_TRUE= - HAVE_ASPELL_FALSE='#' -else - HAVE_ASPELL_TRUE='#' - HAVE_ASPELL_FALSE= -fi - - if test "xAIX" = "x`uname -s 2>/dev/null`"; then SYSTEM_AIX_TRUE= SYSTEM_AIX_FALSE='#' @@ -23292,10 +37771,202 @@ fi cat >>confdefs.h <<_ACEOF -#define CPU_TYPE $target_cpu +#define CPU_TYPE "$target_cpu" _ACEOF +for ac_prog in valgrind +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_VALGRIND+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $VALGRIND in + [\\/]* | ?:[\\/]*) + ac_cv_path_VALGRIND="$VALGRIND" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_VALGRIND="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +VALGRIND=$ac_cv_path_VALGRIND +if test -n "$VALGRIND"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $VALGRIND" >&5 +$as_echo "$VALGRIND" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$VALGRIND" && break +done +test -n "$VALGRIND" || VALGRIND="none" + +if test -n "${VALGRIND}"; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether valgrind is usable on current platform" >&5 +$as_echo_n "checking whether valgrind is usable on current platform... " >&6; } + if ( ${VALGRIND} --help >/dev/null 2>/dev/null ); then : + if ( ${VALGRIND} /bin/sh -c true >/dev/null 2>/dev/null ); then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + VALGRIND="none" + +fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + VALGRIND="none" + +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use valgrind for memory-leak testing" >&5 +$as_echo_n "checking whether to use valgrind for memory-leak testing... " >&6; } + +# Check whether --with-valgrind was given. +if test "${with_valgrind+set}" = set; then : + withval=$with_valgrind; + case "${withval}" in + yes) + if test "x$VALGRIND" = "xnone"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "valgrind requested but not found" "$LINENO" 5 + fi + with_valgrind="yes" + ;; + auto) + with_valgrind="auto" + ;; + no) + with_valgrind="no" + ;; + *) + for ac_prog in "${withval}" +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_VALGRIND+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $VALGRIND in + [\\/]* | ?:[\\/]*) + ac_cv_path_VALGRIND="$VALGRIND" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_VALGRIND="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +VALGRIND=$ac_cv_path_VALGRIND +if test -n "$VALGRIND"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $VALGRIND" >&5 +$as_echo "$VALGRIND" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$VALGRIND" && break +done +test -n "$VALGRIND" || VALGRIND="none" + + if test "x$VALGRIND" = "xnone"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "valgrind requested but not found" "$LINENO" 5 + fi + with_valgrind="yes" + ;; + esac + +fi + + +if test "x${with_valgrind}" = xauto; then + if test "x$VALGRIND" = "xnone"; then + with_valgrind="no" + else + with_valgrind="yes" + fi +fi + +if test "x${with_valgrind}" = xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: using ${VALGRIND}" >&5 +$as_echo "using ${VALGRIND}" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: Do not forget to build with debug (e.g. pass '-g' in CFLAGS for GCC) for best results with valgrind tests" >&5 +$as_echo "$as_me: Do not forget to build with debug (e.g. pass '-g' in CFLAGS for GCC) for best results with valgrind tests" >&6;} +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + if test "x${VALGRIND}" != "xnone"; then + HAVE_VALGRIND_TRUE= + HAVE_VALGRIND_FALSE='#' +else + HAVE_VALGRIND_TRUE='#' + HAVE_VALGRIND_FALSE= +fi + + if test "x${with_valgrind}" = "xyes"; then + WITH_VALGRIND_TRUE= + WITH_VALGRIND_FALSE='#' +else + WITH_VALGRIND_TRUE='#' + WITH_VALGRIND_FALSE= +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build cppunit tests using valgrind support" >&5 +$as_echo_n "checking whether to build cppunit tests using valgrind support... " >&6; } +if test "x${with_valgrind}" = xyes && test "x${have_cppunit}" = xyes ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + conftemp="${sysconfdir}" eval conftemp=\"${conftemp}\" eval conftemp=\"${conftemp}\" @@ -23310,6 +37981,7 @@ conftemp="${datadir}" eval conftemp=\"${conftemp}\" eval conftemp=\"${conftemp}\" DATADIR=${conftemp} +NUT_DATADIR=${conftemp} cat >>confdefs.h <<_ACEOF #define DATADIR "${conftemp}" @@ -23346,6 +38018,136 @@ cat >>confdefs.h <<_ACEOF _ACEOF +conftemp="${libexecdir}" +eval conftemp=\"${conftemp}\" +eval conftemp=\"${conftemp}\" +LIBEXECDIR=${conftemp} + +cat >>confdefs.h <<_ACEOF +#define LIBEXECDIR "${conftemp}" +_ACEOF + + + + +if test "${nut_with_snmp}" = "yes" -a "${nut_have_libnetsnmp}" != "yes"; then + as_fn_error $? "Net-SNMP libraries not found, required for SNMP drivers" "$LINENO" 5 +fi + +if test "${nut_with_snmp}" != "no"; then + nut_with_snmp="${nut_have_libnetsnmp}" +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build SNMP drivers" >&5 +$as_echo_n "checking whether to build SNMP drivers... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${nut_with_snmp} " >&5 +$as_echo "${nut_with_snmp} " >&6; } + if test -z "${nut_report_feature_flag}"; then + nut_report_feature_flag="1" + ac_clean_files="${ac_clean_files} conf_nut_report_feature" + echo > conf_nut_report_feature + echo "Configuration summary:" >> conf_nut_report_feature + echo "======================" >> conf_nut_report_feature + fi + echo "build SNMP drivers: ${nut_with_snmp} " >> conf_nut_report_feature + + + if test "${nut_with_snmp}" = "yes"; then + WITH_SNMP_TRUE= + WITH_SNMP_FALSE='#' +else + WITH_SNMP_TRUE='#' + WITH_SNMP_FALSE= +fi + + if test "${nut_with_snmp}" = "yes"; then + +cat >>confdefs.h <<_ACEOF +#define WITH_SNMP 1 +_ACEOF + + fi + + if test "${nut_have_libsnmp}" = "yes"; then + HAVE_SNMP_TRUE= + HAVE_SNMP_FALSE='#' +else + HAVE_SNMP_TRUE='#' + HAVE_SNMP_FALSE= +fi + + + +if test -n "${host_alias}" ; then + +cat >>confdefs.h <<_ACEOF +#define AUTOTOOLS_HOST_ALIAS "${host_alias}" +_ACEOF + +else + if test -n "${host}" ; then + +cat >>confdefs.h <<_ACEOF +#define AUTOTOOLS_HOST_ALIAS "${host}" +_ACEOF + + fi +fi +if test -n "${build_alias}" ; then + +cat >>confdefs.h <<_ACEOF +#define AUTOTOOLS_BUILD_ALIAS "${build_alias}" +_ACEOF + +else + if test -n "${build}" ; then + +cat >>confdefs.h <<_ACEOF +#define AUTOTOOLS_BUILD_ALIAS "${build}" +_ACEOF + + fi +fi +if test -n "${target_alias}" ; then + +cat >>confdefs.h <<_ACEOF +#define AUTOTOOLS_TARGET_ALIAS "${target_alias}" +_ACEOF + +else + if test -n "${target}" ; then + +cat >>confdefs.h <<_ACEOF +#define AUTOTOOLS_TARGET_ALIAS "${target}" +_ACEOF + + fi +fi + +if test -n "${host_cpu}" -a -n "${host_os}" ; then + +cat >>confdefs.h <<_ACEOF +#define AUTOTOOLS_HOST_SHORT_ALIAS "${host_cpu}-${host_os}" +_ACEOF + +fi +if test -n "${build_cpu}" -a -n "${build_os}" ; then + +cat >>confdefs.h <<_ACEOF +#define AUTOTOOLS_BUILD_SHORT_ALIAS "${build_cpu}-${build_os}" +_ACEOF + +fi +if test -n "${target_cpu}" -a -n "${target_os}" ; then + +cat >>confdefs.h <<_ACEOF +#define AUTOTOOLS_TARGET_SHORT_ALIAS "${target_cpu}-${target_os}" +_ACEOF + +fi + + now=`TZ=UTC date +%Y-%m-%d` @@ -23387,6 +38189,9 @@ now=`TZ=UTC date +%Y-%m-%d` +NUT_DATADIR=`eval echo "${DATADIR}"` + +NUT_LIBEXECDIR=`eval echo "${LIBEXECDIR}"` @@ -23400,7 +38205,735 @@ now=`TZ=UTC date +%Y-%m-%d` -ac_config_files="$ac_config_files clients/Makefile common/Makefile conf/Makefile conf/upsmon.conf.sample conf/upssched.conf.sample data/html/header.html data/html/Makefile data/Makefile data/driver.list docs/Makefile docs/docinfo.xml docs/man/Makefile drivers/Makefile include/Makefile lib/libupsclient-config lib/libupsclient.pc lib/libnutclient.pc lib/libnutscan.pc lib/Makefile scripts/Aix/nut-aix.spec scripts/augeas/Makefile scripts/augeas/nutnutconf.aug scripts/augeas/nutupsconf.aug scripts/augeas/nutupsdconf.aug scripts/augeas/nutupsdusers.aug scripts/augeas/nutupsmonconf.aug scripts/augeas/nutupsschedconf.aug scripts/augeas/nuthostsconf.aug scripts/augeas/nutupssetconf.aug scripts/avahi/nut.service scripts/devd/Makefile scripts/devd/nut-usb.conf scripts/hotplug/Makefile scripts/hotplug/libhidups scripts/HP-UX/nut.psf scripts/HP-UX/postinstall scripts/python/Makefile scripts/systemd/Makefile scripts/systemd/nut-driver.service scripts/systemd/nut-monitor.service scripts/systemd/nut-server.service scripts/systemd/nutshutdown scripts/Solaris/Makefile scripts/Solaris/pkginfo scripts/Solaris/postinstall scripts/Solaris/preremove scripts/Solaris/nut scripts/udev/Makefile scripts/udev/nut-ipmipsu.rules scripts/udev/nut-usbups.rules scripts/ufw/nut.ufw.profile scripts/Makefile server/Makefile tools/Makefile tools/nut-scanner/Makefile tests/Makefile Makefile" + + + + + + + + + if test "x$GCC" = xyes -o "x$CLANGCC" = xyes; then : + case "${CFLAGS}" in #( + *-std=*) : + ;; #( + *) : + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -std=gnu99" >&5 +$as_echo_n "checking whether C compiler accepts -std=gnu99... " >&6; } +if ${ax_cv_check_cflags__Werror__std_gnu99+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -Werror -std=gnu99" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + if grep -E '(unrecognized.* option|did you mean|unknown argument:)' < conftest.err >/dev/null 2>/dev/null; then : + ax_cv_check_cflags__Werror__std_gnu99=no +else + ax_cv_check_cflags__Werror__std_gnu99=yes +fi +else + ax_cv_check_cflags__Werror__std_gnu99=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags__Werror__std_gnu99" >&5 +$as_echo "$ax_cv_check_cflags__Werror__std_gnu99" >&6; } +if test "x$ax_cv_check_cflags__Werror__std_gnu99" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: Defaulting C standard support to GNU C99 on a GCC or CLANG compatible compiler" >&5 +$as_echo "$as_me: Defaulting C standard support to GNU C99 on a GCC or CLANG compatible compiler" >&6;} + CFLAGS="$CFLAGS -std=gnu99" + +else + : +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + ;; +esac + +fi + + if test "x$GCC" = xyes -o "x$CLANGCC" = xyes; then : + case "${CXXFLAGS}" in #( + *-std=*) : + ;; #( + *) : + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C++ compiler accepts -std=gnu++11" >&5 +$as_echo_n "checking whether C++ compiler accepts -std=gnu++11... " >&6; } +if ${ax_cv_check_cxxflags__Werror__std_gnupp11+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CXXFLAGS + CXXFLAGS="$CXXFLAGS -Werror -std=gnu++11" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + if grep -E '(unrecognized.* option|did you mean|unknown argument:)' < conftest.err >/dev/null 2>/dev/null; then : + ax_cv_check_cxxflags__Werror__std_gnupp11=no +else + ax_cv_check_cxxflags__Werror__std_gnupp11=yes +fi +else + ax_cv_check_cxxflags__Werror__std_gnupp11=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXXFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cxxflags__Werror__std_gnupp11" >&5 +$as_echo "$ax_cv_check_cxxflags__Werror__std_gnupp11" >&6; } +if test "x$ax_cv_check_cxxflags__Werror__std_gnupp11" = xyes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: Defaulting C++ standard support to GNU C++11 on a GCC or CLANG compatible compiler" >&5 +$as_echo "$as_me: Defaulting C++ standard support to GNU C++11 on a GCC or CLANG compatible compiler" >&6;} + CXXFLAGS="$CXXFLAGS -std=gnu++11" + +else + : +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + ;; +esac + +fi + + + +nut_warning_difficulty="medium" +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to pre-set warnings (from '${nut_enable_warnings}')" >&5 +$as_echo_n "checking whether to pre-set warnings (from '${nut_enable_warnings}')... " >&6; } +case "${nut_enable_warnings}" in #( + no|all|gcc-legacy|gcc-minimal|clang-minimal|gcc-medium|clang-medium|gcc-hard|clang-hard) : + ;; #( + clang) : + nut_enable_warnings="${nut_enable_warnings}-${nut_warning_difficulty}" ;; #( + gcc) : + + case "${CFLAGS}" in #( + *89*|*90*|*ansi*) : + nut_enable_warnings="${nut_enable_warnings}-minimal" ;; #( + *) : + nut_enable_warnings="${nut_enable_warnings}-${nut_warning_difficulty}" + ;; +esac ;; #( + yes|auto|"") : + + if test "${CLANGCC}" = "yes"; then : + nut_enable_warnings="clang-${nut_warning_difficulty}" +else + if test "${GCC}" = "yes"; then : + + case "${CFLAGS}" in #( + *89*|*90*|*ansi*) : + nut_enable_warnings="gcc-minimal" ;; #( + *) : + case "`$CC --version | grep -i gcc`" in #( + *" "1.*|*" "2.*|3.*|*" "4.0*|*" "4.1*|*" "4.2*|*" "4.3*) : + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Very old GCC in use, disabling warnings" >&5 +$as_echo "$as_me: WARNING: Very old GCC in use, disabling warnings" >&2;} + nut_enable_Werror="no" + nut_enable_warnings="no" ;; #( + *" "4.4*|*" "4.5*|*" "4.6*|*" "4.7*|*" "4.8*) : + nut_enable_warnings="gcc-legacy" ;; #( + *) : + nut_enable_warnings="gcc-${nut_warning_difficulty}" + ;; +esac + ;; +esac +else + nut_enable_warnings="all" +fi + +fi + ;; #( + hard|auto-hard|auto=hard) : + + if test "${CLANGCC}" = "yes"; then : + nut_enable_warnings="clang-hard" +else + if test "${GCC}" = "yes"; then : + nut_enable_warnings="gcc-hard" +else + nut_enable_warnings="all" +fi + +fi + ;; #( + medium|auto-medium|auto=medium) : + + if test "${CLANGCC}" = "yes"; then : + nut_enable_warnings="clang-medium" +else + if test "${GCC}" = "yes"; then : + nut_enable_warnings="gcc-medium" +else + nut_enable_warnings="all" +fi + +fi + ;; #( + minimal|auto-minimal|auto=minimal) : + + if test "${CLANGCC}" = "yes"; then : + nut_enable_warnings="clang-minimal" +else + if test "${GCC}" = "yes"; then : + nut_enable_warnings="gcc-minimal" +else + nut_enable_warnings="all" +fi + +fi + ;; #( + legacy) : + if test "${GCC}" = "yes"; then : + nut_enable_warnings="gcc-legacy" +else + nut_enable_warnings="no" +fi ;; #( + *) : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unsupported variant for --enable-warnings=${nut_enable_warnings}, ignored" >&5 +$as_echo "$as_me: WARNING: Unsupported variant for --enable-warnings=${nut_enable_warnings}, ignored" >&2;} + nut_enable_warnings="no" + + ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: \"${nut_enable_warnings}\"" >&5 +$as_echo "\"${nut_enable_warnings}\"" >&6; } + +case "${nut_enable_warnings}" in #( + all) : + + CFLAGS="${CFLAGS} -Wall" + CXXFLAGS="${CXXFLAGS} -Wall" + ;; #( + clang-hard) : + + CFLAGS="${CFLAGS} -ferror-limit=0 -Wno-system-headers -Wall -Wextra -Weverything -Wno-disabled-macro-expansion -Wno-unused-macros -Wno-reserved-id-macro -Wno-padded -Wno-documentation -Wno-cast-qual -pedantic" + CXXFLAGS="${CXXFLAGS} -ferror-limit=0 -Wno-system-headers -Wall -Wextra -Weverything -Wno-disabled-macro-expansion -Wno-unused-macros -Wno-reserved-id-macro -Wno-padded -Wno-documentation -Wno-cast-qual -Wno-c++98-compat-pedantic -Wno-c++98-compat" + ;; #( + clang-medium) : + + CFLAGS="${CFLAGS} -ferror-limit=0 -Wno-system-headers -Wall -Wextra -Weverything -Wno-disabled-macro-expansion -Wno-unused-macros -Wno-reserved-id-macro -Wno-padded -Wno-documentation -Wno-cast-qual -pedantic -Wno-float-conversion -Wno-double-promotion -Wno-implicit-float-conversion -Wno-conversion -Wno-incompatible-pointer-types-discards-qualifiers" + CXXFLAGS="${CXXFLAGS} -ferror-limit=0 -Wno-system-headers -Wall -Wextra -Weverything -Wno-disabled-macro-expansion -Wno-unused-macros -Wno-reserved-id-macro -Wno-padded -Wno-documentation -Wno-cast-qual -Wno-c++98-compat-pedantic -Wno-c++98-compat" + ;; #( + clang-minimal) : + + CFLAGS="${CFLAGS} -ferror-limit=0 -Wall -Wextra -Wno-documentation" + CXXFLAGS="${CXXFLAGS} -ferror-limit=0 -Wall -Wextra -Wno-documentation" + ;; #( + gcc-legacy) : + CFLAGS="${CFLAGS} -Wall -Wsign-compare" ;; #( + gcc-minimal) : + + CFLAGS="${CFLAGS} -Wall -Wsign-compare" + CXXFLAGS="${CXXFLAGS} -Wall -Wextra" + case "${CFLAGS}" in #( + *89*|*90*|*ansi*) : + ;; #( + *) : + CFLAGS="${CFLAGS} -Wextra -pedantic" + ;; +esac + ;; #( + gcc-medium|gcc-hard) : + + CFLAGS="${CFLAGS} -Wno-system-headers -Wall -Wextra -Wsign-compare" + CXXFLAGS="${CXXFLAGS} -Wno-system-headers -Wall -Wextra" + case "${CFLAGS}" in #( + *89*|*90*|*ansi*) : + ;; #( + *) : + CFLAGS="${CFLAGS} -pedantic" + ;; +esac + + ;; #( + *) : + ;; +esac + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to make warnings fatal" >&5 +$as_echo_n "checking whether to make warnings fatal... " >&6; } +case "${nut_enable_Werror}" in #( + yes|auto) : + + CFLAGS="${CFLAGS} -Werror" + CXXFLAGS="${CXXFLAGS} -Werror" + ;; #( + no) : + + CFLAGS="${CFLAGS} -Wno-error" + CXXFLAGS="${CXXFLAGS} -Wno-error" + + ;; #( + *) : + ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: \"${nut_enable_Werror}\"" >&5 +$as_echo "\"${nut_enable_Werror}\"" >&6; } + +ac_fn_c_check_header_mongrel "$LINENO" "string.h" "ac_cv_header_string_h" "$ac_includes_default" +if test "x$ac_cv_header_string_h" = xyes; then : + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + CFLAGS_SAVED="${CFLAGS}" + CFLAGS_BUILTIN_STR="-fno-builtin-strchr -fno-builtin-strcmp -fno-builtin-strncmp" + CFLAGS="${CFLAGS} -Werror -Wunreachable-code ${LIBNETSNMP_CFLAGS} ${LIBLTDL_CFLAGS} ${LIBNEON_CFLAGS} ${LIBSSL_CFLAGS}" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we should disable string built-ins" >&5 +$as_echo_n "checking whether we should disable string built-ins... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +char *s = "v1", c = '%'; +if (strcmp(s, "v1") != 0) return 1; +if (strchr(s, '1') == NULL) return 1; +if (strchr(s, c) != NULL) return 1 +/* no ";return 0;" here - autoconf adds one */ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + CFLAGS="${CFLAGS_SAVED}" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, they are not a problem" >&5 +$as_echo "no, they are not a problem" >&6; } +else + CFLAGS="${CFLAGS_BUILTIN_STR} ${CFLAGS}" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +char *s = "v1", c = '%'; +if (strcmp(s, "v1") != 0) return 1; +if (strchr(s, '1') == NULL) return 1; +if (strchr(s, c) != NULL) return 1 +/* no ";return 0;" here - autoconf adds one */ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + CFLAGS="${CFLAGS_BUILTIN_STR} ${CFLAGS_SAVED}" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, this solves a problem" >&5 +$as_echo "yes, this solves a problem" >&6; } +else + CFLAGS="${CFLAGS_SAVED} -Werror -Wno-unreachable-code ${LIBNETSNMP_CFLAGS} ${LIBLTDL_CFLAGS} ${LIBNEON_CFLAGS} ${LIBSSL_CFLAGS}" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +char *s = "mibs", c = '%'; +/* Macro version of strcmp() has problems with strings shorter than + * 3 or 4 bytes, so to avoid nailing "-Warray-bounds" as well, + * here we just test for longer strings - existing NUT sources were + * fixed for this situation already */ +if (strcmp(s, "mibs") != 0) return 1; +if (strchr(s, 'b') == NULL) return 1; +if (strchr(s, c) != NULL) return 1 +/* no ";return 0;" here - autoconf adds one */ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + CFLAGS="${CFLAGS_SAVED}" + LIBLTDL_CFLAGS="${LIBLTDL_CFLAGS} -Wno-unreachable-code" + LIBNETSNMP_CFLAGS="${LIBNETSNMP_CFLAGS} -Wno-unreachable-code" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, but -Wno-unreachable-code solves the problem for this compiler" >&5 +$as_echo "no, but -Wno-unreachable-code solves the problem for this compiler" >&6; } +else + CFLAGS="${CFLAGS_SAVED}" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, this does not solve the problem or is not supported" >&5 +$as_echo "no, this does not solve the problem or is not supported" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +fi + + + +ac_fn_c_check_header_mongrel "$LINENO" "arpa/inet.h" "ac_cv_header_arpa_inet_h" "$ac_includes_default" +if test "x$ac_cv_header_arpa_inet_h" = xyes; then : + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + CFLAGS_SAVED="${CFLAGS}" + CFLAGS_BUILTIN_NTOHL="-fno-builtin-htonl -fno-builtin-ntohl" + CFLAGS="${CFLAGS} -Werror -Wunreachable-code -Wshadow ${LIBNETSNMP_CFLAGS} ${LIBLTDL_CFLAGS} ${LIBNEON_CFLAGS} ${LIBSSL_CFLAGS}" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we should disable htonl/ntohl built-ins" >&5 +$as_echo_n "checking whether we should disable htonl/ntohl built-ins... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +struct in_addr sin = {0}; +sin.s_addr = htonl((ntohl(sin.s_addr) + 1)) +/* no ";return 0;" here - autoconf adds one */ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + CFLAGS="${CFLAGS_SAVED}" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, they are not a problem" >&5 +$as_echo "no, they are not a problem" >&6; } +else + CFLAGS="${CFLAGS_BUILTIN_NTOHL} ${CFLAGS}" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +struct in_addr sin = {0}; +sin.s_addr = htonl((ntohl(sin.s_addr) + 1)) +/* no ";return 0;" here - autoconf adds one */ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + CFLAGS="${CFLAGS_BUILTIN_NTOHL} ${CFLAGS_SAVED}" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, this solves a problem" >&5 +$as_echo "yes, this solves a problem" >&6; } +else + CFLAGS="${CFLAGS_SAVED} -Werror -Wno-shadow ${LIBNETSNMP_CFLAGS} ${LIBLTDL_CFLAGS} ${LIBNEON_CFLAGS} ${LIBSSL_CFLAGS}" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +struct in_addr sin = {0}; +sin.s_addr = htonl((ntohl(sin.s_addr) + 1)) + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + CFLAGS="${CFLAGS_SAVED}" + LIBLTDL_CFLAGS="${LIBLTDL_CFLAGS} -Wno-shadow" + LIBNETSNMP_CFLAGS="${LIBNETSNMP_CFLAGS} -Wno-shadow" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, but -Wno-shadow solves the problem for this compiler" >&5 +$as_echo "no, but -Wno-shadow solves the problem for this compiler" >&6; } +else + CFLAGS="${CFLAGS_SAVED}" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, this does not solve the problem or is not supported" >&5 +$as_echo "no, this does not solve the problem or is not supported" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +fi + + + + + if test -n "${CFLAGS_STASHED_WARNINGS}"; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: Applying back the stashed CFLAGS warnings" >&5 +$as_echo "$as_me: Applying back the stashed CFLAGS warnings" >&6;} + CFLAGS="${CFLAGS} ${CFLAGS_STASHED_WARNINGS}" + { $as_echo "$as_me:${as_lineno-$LINENO}: Ended up with: '${CFLAGS}'" >&5 +$as_echo "$as_me: Ended up with: '${CFLAGS}'" >&6;} + +fi + + if test -n "${CPPFLAGS_STASHED_WARNINGS}"; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: Applying back the stashed CPPFLAGS warnings" >&5 +$as_echo "$as_me: Applying back the stashed CPPFLAGS warnings" >&6;} + CPPFLAGS="${CPPFLAGS} ${CPPFLAGS_STASHED_WARNINGS}" + { $as_echo "$as_me:${as_lineno-$LINENO}: Ended up with: '${CPPFLAGS}'" >&5 +$as_echo "$as_me: Ended up with: '${CPPFLAGS}'" >&6;} + +fi + + if test -n "${CXXFLAGS_STASHED_WARNINGS}"; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: Applying back the stashed CXXFLAGS warnings" >&5 +$as_echo "$as_me: Applying back the stashed CXXFLAGS warnings" >&6;} + CXXFLAGS="${CXXFLAGS} ${CXXFLAGS_STASHED_WARNINGS}" + { $as_echo "$as_me:${as_lineno-$LINENO}: Ended up with: '${CXXFLAGS}'" >&5 +$as_echo "$as_me: Ended up with: '${CXXFLAGS}'" >&6;} + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for top build dir for this configure run" >&5 +$as_echo_n "checking for top build dir for this configure run... " >&6; } +TOP_BUILDDIR="" +if test -n "${ac_abs_top_builddir}" && test -d "${ac_abs_top_builddir}"; then : + TOP_BUILDDIR="${ac_abs_top_builddir}" +else + if test -n "${ac_pwd}" && test -d "${ac_pwd}"; then : + TOP_BUILDDIR="${ac_pwd}" +else + TOP_BUILDDIR="`dirname "$0"`" + TOP_BUILDDIR="`cd "$TOP_BUILDDIR" && pwd`" || as_fn_error $? "Can not detect TOP_BUILDDIR" "$LINENO" 5 + +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: \"${TOP_BUILDDIR}\"" >&5 +$as_echo "\"${TOP_BUILDDIR}\"" >&6; } + +ABS_TOP_BUILDDIR="`cd "${TOP_BUILDDIR}" && pwd`" || as_fn_error $? "Can not detect ABS_TOP_BUILDDIR" "$LINENO" 5 +ABS_TOP_SRCDIR="`cd "${abs_srcdir}" && pwd`" || as_fn_error $? "Can not detect ABS_TOP_SRCDIR" "$LINENO" 5 + if test "${ABS_TOP_BUILDDIR}" = "${ABS_TOP_SRCDIR}"; then + BUILDING_IN_TREE_TRUE= + BUILDING_IN_TREE_FALSE='#' +else + BUILDING_IN_TREE_TRUE='#' + BUILDING_IN_TREE_FALSE= +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to customize ${TOP_BUILDDIR}/scripts/systemd/nut-common.tmpfiles.in for this system" >&5 +$as_echo_n "checking whether to customize ${TOP_BUILDDIR}/scripts/systemd/nut-common.tmpfiles.in for this system... " >&6; } +if test -n "$systemdtmpfilesdir"; then : + mkdir -p "${TOP_BUILDDIR}"/scripts/systemd + cat > "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF +# State file (e.g. upsd to driver) and pidfile location for NUT: +d @STATEPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - +X @STATEPATH@/nut +EOF + if test "$STATEPATH" != "$PIDPATH"; then : + cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF +d @PIDPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - +X @PIDPATH@/nut +EOF +fi + if test -n "$ALTPIDPATH" && test "$STATEPATH" != "$ALTPIDPATH" && test "$PIDPATH" != "$ALTPIDPATH"; then : + cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF +d @ALTPIDPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - +X @ALTPIDPATH@/nut +EOF +fi + if test -n "$ALTSTATEPATH" && test "$STATEPATH" != "$ALTSTATEPATH" && test "$ALTSTATEPATH" != "$ALTPIDPATH" && test "$PIDPATH" != "$ALTSTATEPATH"; then : + cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF +d @ALTSTATEPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - +X @ALTSTATEPATH@/nut +EOF +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 +$as_echo "done" >&6; } + +{ $as_echo "$as_me:${as_lineno-$LINENO}: Generating \"data\" files from templates, see below for executable scripts" >&5 +$as_echo "$as_me: Generating \"data\" files from templates, see below for executable scripts" >&6;} +ac_config_files="$ac_config_files clients/Makefile common/Makefile conf/Makefile conf/upsmon.conf.sample conf/upssched.conf.sample data/html/header.html data/html/Makefile data/Makefile data/driver.list docs/Makefile docs/cables/Makefile docs/docinfo.xml docs/man/Makefile drivers/Makefile include/Makefile lib/libupsclient-config lib/libupsclient.pc lib/libnutclient.pc lib/libnutclientstub.pc lib/libnutscan.pc lib/Makefile scripts/Aix/nut-aix.spec scripts/augeas/Makefile scripts/augeas/nutnutconf.aug scripts/augeas/nutupsdconf.aug scripts/augeas/nutupsdusers.aug scripts/augeas/nutupsmonconf.aug scripts/augeas/nutupsschedconf.aug scripts/augeas/nuthostsconf.aug scripts/augeas/nutupssetconf.aug scripts/avahi/nut.service scripts/devd/Makefile scripts/hotplug/Makefile scripts/hotplug/libhidups scripts/HP-UX/nut.psf scripts/python/Makefile scripts/python/module/PyNUT.py scripts/upsdrvsvcctl/Makefile scripts/systemd/Makefile scripts/systemd/nut-common.tmpfiles scripts/systemd/nut-driver@.service scripts/systemd/nut-monitor.service scripts/systemd/nut-server.service scripts/systemd/nut-driver-enumerator.service scripts/systemd/nut-driver-enumerator.path scripts/Solaris/nut-driver-enumerator.xml scripts/Solaris/nut-driver.xml scripts/Solaris/nut-monitor.xml scripts/Solaris/nut-server.xml scripts/Solaris/nut.xml scripts/Solaris/Makefile scripts/Solaris/pkginfo scripts/udev/Makefile scripts/udev/nut-ipmipsu.rules scripts/ufw/Makefile scripts/ufw/nut.ufw.profile scripts/Makefile server/Makefile tools/Makefile tools/nut-scanner/Makefile tests/Makefile tests/NIT/Makefile Makefile" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: Generating templated script files that should be marked executable" >&5 +$as_echo "$as_me: Generating templated script files that should be marked executable" >&6;} + + ac_config_files="$ac_config_files scripts/Aix/nut.init" + + + ac_config_files="$ac_config_files scripts/HP-UX/postinstall" + + + ac_config_files="$ac_config_files scripts/python/app/NUT-Monitor-py2gtk2" + + + ac_config_files="$ac_config_files scripts/python/app/NUT-Monitor-py3qt5" + + + ac_config_files="$ac_config_files scripts/augeas/gen-nutupsconf-aug.py" + + + ac_config_files="$ac_config_files scripts/python/module/test_nutclient.py" + + + ac_config_files="$ac_config_files scripts/upsdrvsvcctl/nut-driver-enumerator.sh" + + + ac_config_files="$ac_config_files scripts/upsdrvsvcctl/upsdrvsvcctl" + + + ac_config_files="$ac_config_files scripts/systemd/nutshutdown" + + + ac_config_files="$ac_config_files scripts/Solaris/svc-nut-server" + + + ac_config_files="$ac_config_files scripts/Solaris/svc-nut-monitor" + + + ac_config_files="$ac_config_files scripts/Solaris/precheck.py" + + + ac_config_files="$ac_config_files scripts/Solaris/preinstall" + + + ac_config_files="$ac_config_files scripts/Solaris/postinstall" + + + ac_config_files="$ac_config_files scripts/Solaris/preremove" + + + ac_config_files="$ac_config_files scripts/Solaris/postremove" + + + ac_config_files="$ac_config_files scripts/Solaris/preproto.pl" + + + ac_config_files="$ac_config_files scripts/Solaris/nut" + + + ac_config_files="$ac_config_files tools/gitlog2changelog.py" + + + ac_config_files="$ac_config_files tools/nut-snmpinfo.py" + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: Generating templated script files whose templates might have been generated (or not) by autogen.sh calling our helper scripts" >&5 +$as_echo "$as_me: Generating templated script files whose templates might have been generated (or not) by autogen.sh calling our helper scripts" >&6;} + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to generate scripts/augeas/nutupsconf.aug" >&5 +$as_echo_n "checking whether to generate scripts/augeas/nutupsconf.aug... " >&6; } + if test -s scripts/augeas/nutupsconf.aug.in && ! test -f scripts/augeas/nutupsconf.aug.in.AUTOGEN_WITHOUT; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + ac_config_files="$ac_config_files scripts/augeas/nutupsconf.aug" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to generate scripts/udev/nut-usbups.rules" >&5 +$as_echo_n "checking whether to generate scripts/udev/nut-usbups.rules... " >&6; } + if test -s scripts/udev/nut-usbups.rules.in && ! test -f scripts/udev/nut-usbups.rules.in.AUTOGEN_WITHOUT; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + ac_config_files="$ac_config_files scripts/udev/nut-usbups.rules" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to generate scripts/devd/nut-usb.conf" >&5 +$as_echo_n "checking whether to generate scripts/devd/nut-usb.conf... " >&6; } + if test -s scripts/devd/nut-usb.conf.in && ! test -f scripts/devd/nut-usb.conf.in.AUTOGEN_WITHOUT; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + ac_config_files="$ac_config_files scripts/devd/nut-usb.conf" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi + cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -23539,35 +39072,51 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then - as_fn_error $? "conditional \"am__fastdepCC\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${HAVE_CPPUNIT_TRUE}" && test -z "${HAVE_CPPUNIT_FALSE}"; then - as_fn_error $? "conditional \"HAVE_CPPUNIT\" was never defined. +if test -z "${HAVE_PYTHON_TRUE}" && test -z "${HAVE_PYTHON_FALSE}"; then + as_fn_error $? "conditional \"HAVE_PYTHON\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HAVE_PYTHON2_TRUE}" && test -z "${HAVE_PYTHON2_FALSE}"; then + as_fn_error $? "conditional \"HAVE_PYTHON2\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HAVE_PYTHON3_TRUE}" && test -z "${HAVE_PYTHON3_FALSE}"; then + as_fn_error $? "conditional \"HAVE_PYTHON3\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${SOME_DRIVERS_TRUE}" && test -z "${SOME_DRIVERS_FALSE}"; then + as_fn_error $? "conditional \"SOME_DRIVERS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${WITH_SERIAL_TRUE}" && test -z "${WITH_SERIAL_FALSE}"; then as_fn_error $? "conditional \"WITH_SERIAL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${WITH_LIBUSB_1_0_TRUE}" && test -z "${WITH_LIBUSB_1_0_FALSE}"; then + as_fn_error $? "conditional \"WITH_LIBUSB_1_0\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${WITH_LIBUSB_0_1_TRUE}" && test -z "${WITH_LIBUSB_0_1_FALSE}"; then + as_fn_error $? "conditional \"WITH_LIBUSB_0_1\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${WITH_USB_TRUE}" && test -z "${WITH_USB_FALSE}"; then as_fn_error $? "conditional \"WITH_USB\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${WITH_SNMP_TRUE}" && test -z "${WITH_SNMP_FALSE}"; then - as_fn_error $? "conditional \"WITH_SNMP\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi if test -z "${WITH_NEON_TRUE}" && test -z "${WITH_NEON_FALSE}"; then as_fn_error $? "conditional \"WITH_NEON\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${HAVE_NEON_TRUE}" && test -z "${HAVE_NEON_FALSE}"; then + as_fn_error $? "conditional \"HAVE_NEON\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${WITH_AVAHI_TRUE}" && test -z "${WITH_AVAHI_FALSE}"; then as_fn_error $? "conditional \"WITH_AVAHI\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -23576,6 +39125,10 @@ if test -z "${WITH_LIBPOWERMAN_TRUE}" && test -z "${WITH_LIBPOWERMAN_FALSE}"; th as_fn_error $? "conditional \"WITH_LIBPOWERMAN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${WITH_MODBUS_TRUE}" && test -z "${WITH_MODBUS_FALSE}"; then + as_fn_error $? "conditional \"WITH_MODBUS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${WITH_IPMI_TRUE}" && test -z "${WITH_IPMI_FALSE}"; then as_fn_error $? "conditional \"WITH_IPMI\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -23616,34 +39169,98 @@ if test -z "${WITH_CGI_TRUE}" && test -z "${WITH_CGI_FALSE}"; then as_fn_error $? "conditional \"WITH_CGI\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${WITH_ASCIIDOC_TRUE}" && test -z "${WITH_ASCIIDOC_FALSE}"; then - as_fn_error $? "conditional \"WITH_ASCIIDOC\" was never defined. +if test -z "${HAVE_CPPCHECK_TRUE}" && test -z "${HAVE_CPPCHECK_FALSE}"; then + as_fn_error $? "conditional \"HAVE_CPPCHECK\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${WITH_CPPCHECK_TRUE}" && test -z "${WITH_CPPCHECK_FALSE}"; then + as_fn_error $? "conditional \"WITH_CPPCHECK\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${WITH_CHECK_NIT_TRUE}" && test -z "${WITH_CHECK_NIT_FALSE}"; then + as_fn_error $? "conditional \"WITH_CHECK_NIT\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${MANUALUPDATE_TRUE}" && test -z "${MANUALUPDATE_FALSE}"; then + as_fn_error $? "conditional \"MANUALUPDATE\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HAVE_SOURCE_HIGHLIGHT_TRUE}" && test -z "${HAVE_SOURCE_HIGHLIGHT_FALSE}"; then + as_fn_error $? "conditional \"HAVE_SOURCE_HIGHLIGHT\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HAVE_ASPELL_TRUE}" && test -z "${HAVE_ASPELL_FALSE}"; then + as_fn_error $? "conditional \"HAVE_ASPELL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_ASCIIDOC_TRUE}" && test -z "${HAVE_ASCIIDOC_FALSE}"; then as_fn_error $? "conditional \"HAVE_ASCIIDOC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${WITH_DEV_TRUE}" && test -z "${WITH_DEV_FALSE}"; then - as_fn_error $? "conditional \"WITH_DEV\" was never defined. +if test -z "${WITH_ASCIIDOC_TRUE}" && test -z "${WITH_ASCIIDOC_FALSE}"; then + as_fn_error $? "conditional \"WITH_ASCIIDOC\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${WITH_DOCS_TRUE}" && test -z "${WITH_DOCS_FALSE}"; then + as_fn_error $? "conditional \"WITH_DOCS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${WITH_MANS_TRUE}" && test -z "${WITH_MANS_FALSE}"; then + as_fn_error $? "conditional \"WITH_MANS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${SKIP_MANS_TRUE}" && test -z "${SKIP_MANS_FALSE}"; then + as_fn_error $? "conditional \"SKIP_MANS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${DOC_INSTALL_DISTED_MANS_TRUE}" && test -z "${DOC_INSTALL_DISTED_MANS_FALSE}"; then + as_fn_error $? "conditional \"DOC_INSTALL_DISTED_MANS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${WITH_DEV_TRUE}" && test -z "${WITH_DEV_FALSE}"; then as_fn_error $? "conditional \"WITH_DEV\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${SOME_DRIVERS_TRUE}" && test -z "${SOME_DRIVERS_FALSE}"; then - as_fn_error $? "conditional \"SOME_DRIVERS\" was never defined. +if test -z "${WITH_DEV_TRUE}" && test -z "${WITH_DEV_FALSE}"; then + as_fn_error $? "conditional \"WITH_DEV\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${WITH_PKG_CONFIG_TRUE}" && test -z "${WITH_PKG_CONFIG_FALSE}"; then as_fn_error $? "conditional \"WITH_PKG_CONFIG\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${WITH_SOLARIS_SMF_TRUE}" && test -z "${WITH_SOLARIS_SMF_FALSE}"; then + as_fn_error $? "conditional \"WITH_SOLARIS_SMF\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${WITH_SOLARIS_PKG_SVR4_TRUE}" && test -z "${WITH_SOLARIS_PKG_SVR4_FALSE}"; then + as_fn_error $? "conditional \"WITH_SOLARIS_PKG_SVR4\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${WITH_SOLARIS_PKG_IPS_TRUE}" && test -z "${WITH_SOLARIS_PKG_IPS_FALSE}"; then + as_fn_error $? "conditional \"WITH_SOLARIS_PKG_IPS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${HAVE_SYSTEMD_TRUE}" && test -z "${HAVE_SYSTEMD_FALSE}"; then as_fn_error $? "conditional \"HAVE_SYSTEMD\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${HAVE_CXX11_TRUE}" && test -z "${HAVE_CXX11_FALSE}"; then + as_fn_error $? "conditional \"HAVE_CXX11\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HAVE_CPPUNIT_TRUE}" && test -z "${HAVE_CPPUNIT_FALSE}"; then + as_fn_error $? "conditional \"HAVE_CPPUNIT\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${WITH_AUGLENS_TRUE}" && test -z "${WITH_AUGLENS_FALSE}"; then + as_fn_error $? "conditional \"WITH_AUGLENS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HAVE_AUGPARSE_TRUE}" && test -z "${HAVE_AUGPARSE_FALSE}"; then + as_fn_error $? "conditional \"HAVE_AUGPARSE\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${WITH_HOTPLUG_TRUE}" && test -z "${WITH_HOTPLUG_FALSE}"; then as_fn_error $? "conditional \"WITH_HOTPLUG\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -23656,18 +39273,30 @@ if test -z "${WITH_DEVD_TRUE}" && test -z "${WITH_DEVD_FALSE}"; then as_fn_error $? "conditional \"WITH_DEVD\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${MANUALUPDATE_TRUE}" && test -z "${MANUALUPDATE_FALSE}"; then - as_fn_error $? "conditional \"MANUALUPDATE\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${HAVE_ASPELL_TRUE}" && test -z "${HAVE_ASPELL_FALSE}"; then - as_fn_error $? "conditional \"HAVE_ASPELL\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi if test -z "${SYSTEM_AIX_TRUE}" && test -z "${SYSTEM_AIX_FALSE}"; then as_fn_error $? "conditional \"SYSTEM_AIX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${HAVE_VALGRIND_TRUE}" && test -z "${HAVE_VALGRIND_FALSE}"; then + as_fn_error $? "conditional \"HAVE_VALGRIND\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${WITH_VALGRIND_TRUE}" && test -z "${WITH_VALGRIND_FALSE}"; then + as_fn_error $? "conditional \"WITH_VALGRIND\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${WITH_SNMP_TRUE}" && test -z "${WITH_SNMP_FALSE}"; then + as_fn_error $? "conditional \"WITH_SNMP\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HAVE_SNMP_TRUE}" && test -z "${HAVE_SNMP_FALSE}"; then + as_fn_error $? "conditional \"HAVE_SNMP\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${BUILDING_IN_TREE_TRUE}" && test -z "${BUILDING_IN_TREE_FALSE}"; then + as_fn_error $? "conditional \"BUILDING_IN_TREE\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 @@ -24065,7 +39694,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by nut $as_me 2.7.4, which was +This file was extended by nut $as_me 2.8.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -24131,7 +39760,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -nut config.status 2.7.4 +nut config.status 2.8.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -24250,7 +39879,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # -AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" +AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}" # The HP-UX ksh and POSIX shell print the target directory to stdout @@ -24266,6 +39895,7 @@ enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' +shared_archive_member_spec='`$ECHO "$shared_archive_member_spec" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' @@ -24315,10 +39945,13 @@ compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_import='`$ECHO "$lt_cv_sys_global_symbol_to_import" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' +lt_cv_nm_interface='`$ECHO "$lt_cv_nm_interface" | $SED "$delay_single_quote_subst"`' nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' +lt_cv_truncate_bin='`$ECHO "$lt_cv_truncate_bin" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' @@ -24383,7 +40016,8 @@ finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' -sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' +configure_time_dlsearch_path='`$ECHO "$configure_time_dlsearch_path" | $SED "$delay_single_quote_subst"`' +configure_time_lt_sys_library_path='`$ECHO "$configure_time_lt_sys_library_path" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' @@ -24488,9 +40122,12 @@ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ +lt_cv_sys_global_symbol_to_import \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ +lt_cv_nm_interface \ nm_file_list_spec \ +lt_cv_truncate_bin \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_pic \ lt_prog_compiler_wl \ @@ -24556,7 +40193,7 @@ postdeps_CXX \ compiler_lib_search_path_CXX; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" @@ -24583,7 +40220,8 @@ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ -sys_lib_dlsearch_path_spec \ +configure_time_dlsearch_path \ +configure_time_lt_sys_library_path \ reload_cmds_CXX \ old_archive_cmds_CXX \ old_archive_from_new_cmds_CXX \ @@ -24597,7 +40235,7 @@ prelink_cmds_CXX \ postlink_cmds_CXX; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" @@ -24606,19 +40244,16 @@ postlink_cmds_CXX; do done ac_aux_dir='$ac_aux_dir' -xsi_shell='$xsi_shell' -lt_shell_append='$lt_shell_append' -# See if we are running on zsh, and set the options which allow our +# See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes INIT. -if test -n "\${ZSH_VERSION+set}" ; then +if test -n "\${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' - TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile' @@ -24648,6 +40283,7 @@ do "data/Makefile") CONFIG_FILES="$CONFIG_FILES data/Makefile" ;; "data/driver.list") CONFIG_FILES="$CONFIG_FILES data/driver.list" ;; "docs/Makefile") CONFIG_FILES="$CONFIG_FILES docs/Makefile" ;; + "docs/cables/Makefile") CONFIG_FILES="$CONFIG_FILES docs/cables/Makefile" ;; "docs/docinfo.xml") CONFIG_FILES="$CONFIG_FILES docs/docinfo.xml" ;; "docs/man/Makefile") CONFIG_FILES="$CONFIG_FILES docs/man/Makefile" ;; "drivers/Makefile") CONFIG_FILES="$CONFIG_FILES drivers/Makefile" ;; @@ -24655,12 +40291,12 @@ do "lib/libupsclient-config") CONFIG_FILES="$CONFIG_FILES lib/libupsclient-config" ;; "lib/libupsclient.pc") CONFIG_FILES="$CONFIG_FILES lib/libupsclient.pc" ;; "lib/libnutclient.pc") CONFIG_FILES="$CONFIG_FILES lib/libnutclient.pc" ;; + "lib/libnutclientstub.pc") CONFIG_FILES="$CONFIG_FILES lib/libnutclientstub.pc" ;; "lib/libnutscan.pc") CONFIG_FILES="$CONFIG_FILES lib/libnutscan.pc" ;; "lib/Makefile") CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;; "scripts/Aix/nut-aix.spec") CONFIG_FILES="$CONFIG_FILES scripts/Aix/nut-aix.spec" ;; "scripts/augeas/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/augeas/Makefile" ;; "scripts/augeas/nutnutconf.aug") CONFIG_FILES="$CONFIG_FILES scripts/augeas/nutnutconf.aug" ;; - "scripts/augeas/nutupsconf.aug") CONFIG_FILES="$CONFIG_FILES scripts/augeas/nutupsconf.aug" ;; "scripts/augeas/nutupsdconf.aug") CONFIG_FILES="$CONFIG_FILES scripts/augeas/nutupsdconf.aug" ;; "scripts/augeas/nutupsdusers.aug") CONFIG_FILES="$CONFIG_FILES scripts/augeas/nutupsdusers.aug" ;; "scripts/augeas/nutupsmonconf.aug") CONFIG_FILES="$CONFIG_FILES scripts/augeas/nutupsmonconf.aug" ;; @@ -24669,32 +40305,60 @@ do "scripts/augeas/nutupssetconf.aug") CONFIG_FILES="$CONFIG_FILES scripts/augeas/nutupssetconf.aug" ;; "scripts/avahi/nut.service") CONFIG_FILES="$CONFIG_FILES scripts/avahi/nut.service" ;; "scripts/devd/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/devd/Makefile" ;; - "scripts/devd/nut-usb.conf") CONFIG_FILES="$CONFIG_FILES scripts/devd/nut-usb.conf" ;; "scripts/hotplug/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/hotplug/Makefile" ;; "scripts/hotplug/libhidups") CONFIG_FILES="$CONFIG_FILES scripts/hotplug/libhidups" ;; "scripts/HP-UX/nut.psf") CONFIG_FILES="$CONFIG_FILES scripts/HP-UX/nut.psf" ;; - "scripts/HP-UX/postinstall") CONFIG_FILES="$CONFIG_FILES scripts/HP-UX/postinstall" ;; "scripts/python/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/python/Makefile" ;; + "scripts/python/module/PyNUT.py") CONFIG_FILES="$CONFIG_FILES scripts/python/module/PyNUT.py" ;; + "scripts/upsdrvsvcctl/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/upsdrvsvcctl/Makefile" ;; "scripts/systemd/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/systemd/Makefile" ;; - "scripts/systemd/nut-driver.service") CONFIG_FILES="$CONFIG_FILES scripts/systemd/nut-driver.service" ;; + "scripts/systemd/nut-common.tmpfiles") CONFIG_FILES="$CONFIG_FILES scripts/systemd/nut-common.tmpfiles" ;; + "scripts/systemd/nut-driver@.service") CONFIG_FILES="$CONFIG_FILES scripts/systemd/nut-driver@.service" ;; "scripts/systemd/nut-monitor.service") CONFIG_FILES="$CONFIG_FILES scripts/systemd/nut-monitor.service" ;; "scripts/systemd/nut-server.service") CONFIG_FILES="$CONFIG_FILES scripts/systemd/nut-server.service" ;; - "scripts/systemd/nutshutdown") CONFIG_FILES="$CONFIG_FILES scripts/systemd/nutshutdown" ;; + "scripts/systemd/nut-driver-enumerator.service") CONFIG_FILES="$CONFIG_FILES scripts/systemd/nut-driver-enumerator.service" ;; + "scripts/systemd/nut-driver-enumerator.path") CONFIG_FILES="$CONFIG_FILES scripts/systemd/nut-driver-enumerator.path" ;; + "scripts/Solaris/nut-driver-enumerator.xml") CONFIG_FILES="$CONFIG_FILES scripts/Solaris/nut-driver-enumerator.xml" ;; + "scripts/Solaris/nut-driver.xml") CONFIG_FILES="$CONFIG_FILES scripts/Solaris/nut-driver.xml" ;; + "scripts/Solaris/nut-monitor.xml") CONFIG_FILES="$CONFIG_FILES scripts/Solaris/nut-monitor.xml" ;; + "scripts/Solaris/nut-server.xml") CONFIG_FILES="$CONFIG_FILES scripts/Solaris/nut-server.xml" ;; + "scripts/Solaris/nut.xml") CONFIG_FILES="$CONFIG_FILES scripts/Solaris/nut.xml" ;; "scripts/Solaris/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/Solaris/Makefile" ;; "scripts/Solaris/pkginfo") CONFIG_FILES="$CONFIG_FILES scripts/Solaris/pkginfo" ;; - "scripts/Solaris/postinstall") CONFIG_FILES="$CONFIG_FILES scripts/Solaris/postinstall" ;; - "scripts/Solaris/preremove") CONFIG_FILES="$CONFIG_FILES scripts/Solaris/preremove" ;; - "scripts/Solaris/nut") CONFIG_FILES="$CONFIG_FILES scripts/Solaris/nut" ;; "scripts/udev/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/udev/Makefile" ;; "scripts/udev/nut-ipmipsu.rules") CONFIG_FILES="$CONFIG_FILES scripts/udev/nut-ipmipsu.rules" ;; - "scripts/udev/nut-usbups.rules") CONFIG_FILES="$CONFIG_FILES scripts/udev/nut-usbups.rules" ;; + "scripts/ufw/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/ufw/Makefile" ;; "scripts/ufw/nut.ufw.profile") CONFIG_FILES="$CONFIG_FILES scripts/ufw/nut.ufw.profile" ;; "scripts/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/Makefile" ;; "server/Makefile") CONFIG_FILES="$CONFIG_FILES server/Makefile" ;; "tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;; "tools/nut-scanner/Makefile") CONFIG_FILES="$CONFIG_FILES tools/nut-scanner/Makefile" ;; "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;; + "tests/NIT/Makefile") CONFIG_FILES="$CONFIG_FILES tests/NIT/Makefile" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "scripts/Aix/nut.init") CONFIG_FILES="$CONFIG_FILES scripts/Aix/nut.init" ;; + "scripts/HP-UX/postinstall") CONFIG_FILES="$CONFIG_FILES scripts/HP-UX/postinstall" ;; + "scripts/python/app/NUT-Monitor-py2gtk2") CONFIG_FILES="$CONFIG_FILES scripts/python/app/NUT-Monitor-py2gtk2" ;; + "scripts/python/app/NUT-Monitor-py3qt5") CONFIG_FILES="$CONFIG_FILES scripts/python/app/NUT-Monitor-py3qt5" ;; + "scripts/augeas/gen-nutupsconf-aug.py") CONFIG_FILES="$CONFIG_FILES scripts/augeas/gen-nutupsconf-aug.py" ;; + "scripts/python/module/test_nutclient.py") CONFIG_FILES="$CONFIG_FILES scripts/python/module/test_nutclient.py" ;; + "scripts/upsdrvsvcctl/nut-driver-enumerator.sh") CONFIG_FILES="$CONFIG_FILES scripts/upsdrvsvcctl/nut-driver-enumerator.sh" ;; + "scripts/upsdrvsvcctl/upsdrvsvcctl") CONFIG_FILES="$CONFIG_FILES scripts/upsdrvsvcctl/upsdrvsvcctl" ;; + "scripts/systemd/nutshutdown") CONFIG_FILES="$CONFIG_FILES scripts/systemd/nutshutdown" ;; + "scripts/Solaris/svc-nut-server") CONFIG_FILES="$CONFIG_FILES scripts/Solaris/svc-nut-server" ;; + "scripts/Solaris/svc-nut-monitor") CONFIG_FILES="$CONFIG_FILES scripts/Solaris/svc-nut-monitor" ;; + "scripts/Solaris/precheck.py") CONFIG_FILES="$CONFIG_FILES scripts/Solaris/precheck.py" ;; + "scripts/Solaris/preinstall") CONFIG_FILES="$CONFIG_FILES scripts/Solaris/preinstall" ;; + "scripts/Solaris/postinstall") CONFIG_FILES="$CONFIG_FILES scripts/Solaris/postinstall" ;; + "scripts/Solaris/preremove") CONFIG_FILES="$CONFIG_FILES scripts/Solaris/preremove" ;; + "scripts/Solaris/postremove") CONFIG_FILES="$CONFIG_FILES scripts/Solaris/postremove" ;; + "scripts/Solaris/preproto.pl") CONFIG_FILES="$CONFIG_FILES scripts/Solaris/preproto.pl" ;; + "scripts/Solaris/nut") CONFIG_FILES="$CONFIG_FILES scripts/Solaris/nut" ;; + "tools/gitlog2changelog.py") CONFIG_FILES="$CONFIG_FILES tools/gitlog2changelog.py" ;; + "tools/nut-snmpinfo.py") CONFIG_FILES="$CONFIG_FILES tools/nut-snmpinfo.py" ;; + "scripts/augeas/nutupsconf.aug") CONFIG_FILES="$CONFIG_FILES scripts/augeas/nutupsconf.aug" ;; + "scripts/udev/nut-usbups.rules") CONFIG_FILES="$CONFIG_FILES scripts/udev/nut-usbups.rules" ;; + "scripts/devd/nut-usb.conf") CONFIG_FILES="$CONFIG_FILES scripts/devd/nut-usb.conf" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac @@ -25294,29 +40958,35 @@ $as_echo "$as_me: executing $ac_file commands" >&6;} # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. - case $CONFIG_FILES in - *\'*) eval set x "$CONFIG_FILES" ;; - *) set x $CONFIG_FILES ;; - esac + # TODO: see whether this extra hack can be removed once we start + # requiring Autoconf 2.70 or later. + case $CONFIG_FILES in #( + *\'*) : + eval set x "$CONFIG_FILES" ;; #( + *) : + set x $CONFIG_FILES ;; #( + *) : + ;; +esac shift - for mf + # Used to flag and report bootstrapping failures. + am_rc=0 + for am_mf do # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named 'Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # Grep'ing the whole file is not good either: AIX grep has a line + am_mf=`$as_echo "$am_mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile which includes + # dependency-tracking related rules and includes. + # Grep'ing the whole file directly is not great: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. - if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then - dirpart=`$as_dirname -- "$mf" || -$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$mf" : 'X\(//\)[^/]' \| \ - X"$mf" : 'X\(//\)$' \| \ - X"$mf" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$mf" | + sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ + || continue + am_dirpart=`$as_dirname -- "$am_mf" || +$as_expr X"$am_mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$am_mf" : 'X\(//\)[^/]' \| \ + X"$am_mf" : 'X\(//\)$' \| \ + X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$am_mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -25334,106 +41004,100 @@ $as_echo X"$mf" | q } s/.*/./; q'` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running 'make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "$am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`$as_dirname -- "$file" || -$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$file" : 'X\(//\)[^/]' \| \ - X"$file" : 'X\(//\)$' \| \ - X"$file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + am_filepart=`$as_basename -- "$am_mf" || +$as_expr X/"$am_mf" : '.*/\([^/][^/]*\)/*$' \| \ + X"$am_mf" : 'X\(//\)$' \| \ + X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$am_mf" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } - /^X\(\/\/\)[^/].*/{ + /^X\/\(\/\/\)$/{ s//\1/ q } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ + /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` - as_dir=$dirpart/$fdir; as_fn_mkdir_p - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done + { echo "$as_me:$LINENO: cd "$am_dirpart" \ + && sed -e '/# am--include-marker/d' "$am_filepart" \ + | $MAKE -f - am--depfiles" >&5 + (cd "$am_dirpart" \ + && sed -e '/# am--include-marker/d' "$am_filepart" \ + | $MAKE -f - am--depfiles) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } || am_rc=$? done + if test $am_rc -ne 0; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "Something went wrong bootstrapping makefile fragments + for automatic dependency tracking. If GNU make was not used, consider + re-running the configure script with MAKE=\"gmake\" (or whatever is + necessary). You can also try re-running configure with the + '--disable-dependency-tracking' option to at least be able to build + the package (albeit without support for automatic dependency tracking). +See \`config.log' for more details" "$LINENO" 5; } + fi + { am_dirpart=; unset am_dirpart;} + { am_filepart=; unset am_filepart;} + { am_mf=; unset am_mf;} + { am_rc=; unset am_rc;} + rm -f conftest-deps.mk } ;; "libtool":C) - # See if we are running on zsh, and set the options which allow our + # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes. - if test -n "${ZSH_VERSION+set}" ; then + if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi - cfgfile="${ofile}T" + cfgfile=${ofile}T trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL - -# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# Generated automatically by $as_me ($PACKAGE) $VERSION # NOTE: Changes made to this file will be lost: look at ltmain.sh. + +# Provide generalized library-building support services. +# Written by Gordon Matzigkeit, 1996 + +# Copyright (C) 2014 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# GNU Libtool is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of of the License, or +# (at your option) any later version. # -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program or library that is built +# using GNU Libtool, you may include this file under the same +# distribution terms that you use for the rest of that program. # -# This file is part of GNU Libtool. -# -# GNU Libtool is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or (at your option) any later version. -# -# As a special exception to the GNU General Public License, -# if you distribute this file as part of a program or library that -# is built using GNU Libtool, you may include this file under the -# same distribution terms that you use for the rest of that program. -# -# GNU Libtool is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of +# GNU Libtool is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with GNU Libtool; see the file COPYING. If not, a copy -# can be downloaded from http://www.gnu.org/licenses/gpl.html, or -# obtained by writing to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# along with this program. If not, see . # The names of the tagged configurations supported by this script. -available_tags="CXX " +available_tags='CXX ' + +# Configured defaults for sys_lib_dlsearch_path munging. +: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} # ### BEGIN LIBTOOL CONFIG @@ -25453,6 +41117,9 @@ pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install +# Shared archive member basename,for filename based shared library versioning on AIX. +shared_archive_member_spec=$shared_archive_member_spec + # Shell to use when invoking shell scripts. SHELL=$lt_SHELL @@ -25570,18 +41237,27 @@ global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl +# Transform the output of nm into a list of symbols to manually relocate. +global_symbol_to_import=$lt_lt_cv_sys_global_symbol_to_import + # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix +# The name lister interface. +nm_interface=$lt_lt_cv_nm_interface + # Specify filename containing input files for \$NM. nm_file_list_spec=$lt_nm_file_list_spec -# The root where to search for dependent libraries,and in which our libraries should be installed. +# The root where to search for dependent libraries,and where our libraries should be installed. lt_sysroot=$lt_sysroot +# Command to truncate a binary pipe. +lt_truncate_bin=$lt_lt_cv_truncate_bin + # The name of the directory that contains temporary libtool files. objdir=$objdir @@ -25672,8 +41348,11 @@ hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec -# Run-time system search path for libraries. -sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec +# Detected run-time system search path for libraries. +sys_lib_dlsearch_path_spec=$lt_configure_time_dlsearch_path + +# Explicit LT_SYS_LIBRARY_PATH set during ./configure time. +configure_time_lt_sys_library_path=$lt_configure_time_lt_sys_library_path # Whether dlopen is supported. dlopen_support=$enable_dlopen @@ -25766,13 +41445,13 @@ hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator -# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes +# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct -# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes +# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary and the resulting library dependency is -# "absolute",i.e impossible to change by setting \${shlibpath_var} if the +# "absolute",i.e impossible to change by setting \$shlibpath_var if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute @@ -25836,6 +41515,65 @@ compiler_lib_search_path=$lt_compiler_lib_search_path # ### END LIBTOOL CONFIG +_LT_EOF + + cat <<'_LT_EOF' >> "$cfgfile" + +# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE + +# func_munge_path_list VARIABLE PATH +# ----------------------------------- +# VARIABLE is name of variable containing _space_ separated list of +# directories to be munged by the contents of PATH, which is string +# having a format: +# "DIR[:DIR]:" +# string "DIR[ DIR]" will be prepended to VARIABLE +# ":DIR[:DIR]" +# string "DIR[ DIR]" will be appended to VARIABLE +# "DIRP[:DIRP]::[DIRA:]DIRA" +# string "DIRP[ DIRP]" will be prepended to VARIABLE and string +# "DIRA[ DIRA]" will be appended to VARIABLE +# "DIR[:DIR]" +# VARIABLE will be replaced by "DIR[ DIR]" +func_munge_path_list () +{ + case x$2 in + x) + ;; + *:) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" + ;; + x:*) + eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" + ;; + *::*) + eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" + eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" + ;; + *) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" + ;; + esac +} + + +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +func_cc_basename () +{ + for cc_temp in $*""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +} + + +# ### END FUNCTIONS SHARED WITH CONFIGURE + _LT_EOF case $host_os in @@ -25844,7 +41582,7 @@ _LT_EOF # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. -if test "X${COLLECT_NAMES+set}" != Xset; then +if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi @@ -25853,7 +41591,7 @@ _LT_EOF esac -ltmain="$ac_aux_dir/ltmain.sh" +ltmain=$ac_aux_dir/ltmain.sh # We use sed instead of cat because bash on DJGPP gets confused if @@ -25863,165 +41601,6 @@ ltmain="$ac_aux_dir/ltmain.sh" sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) - if test x"$xsi_shell" = xyes; then - sed -e '/^func_dirname ()$/,/^} # func_dirname /c\ -func_dirname ()\ -{\ -\ case ${1} in\ -\ */*) func_dirname_result="${1%/*}${2}" ;;\ -\ * ) func_dirname_result="${3}" ;;\ -\ esac\ -} # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_basename ()$/,/^} # func_basename /c\ -func_basename ()\ -{\ -\ func_basename_result="${1##*/}"\ -} # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\ -func_dirname_and_basename ()\ -{\ -\ case ${1} in\ -\ */*) func_dirname_result="${1%/*}${2}" ;;\ -\ * ) func_dirname_result="${3}" ;;\ -\ esac\ -\ func_basename_result="${1##*/}"\ -} # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_stripname ()$/,/^} # func_stripname /c\ -func_stripname ()\ -{\ -\ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\ -\ # positional parameters, so assign one to ordinary parameter first.\ -\ func_stripname_result=${3}\ -\ func_stripname_result=${func_stripname_result#"${1}"}\ -\ func_stripname_result=${func_stripname_result%"${2}"}\ -} # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\ -func_split_long_opt ()\ -{\ -\ func_split_long_opt_name=${1%%=*}\ -\ func_split_long_opt_arg=${1#*=}\ -} # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\ -func_split_short_opt ()\ -{\ -\ func_split_short_opt_arg=${1#??}\ -\ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\ -} # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\ -func_lo2o ()\ -{\ -\ case ${1} in\ -\ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\ -\ *) func_lo2o_result=${1} ;;\ -\ esac\ -} # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_xform ()$/,/^} # func_xform /c\ -func_xform ()\ -{\ - func_xform_result=${1%.*}.lo\ -} # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_arith ()$/,/^} # func_arith /c\ -func_arith ()\ -{\ - func_arith_result=$(( $* ))\ -} # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_len ()$/,/^} # func_len /c\ -func_len ()\ -{\ - func_len_result=${#1}\ -} # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - -fi - -if test x"$lt_shell_append" = xyes; then - sed -e '/^func_append ()$/,/^} # func_append /c\ -func_append ()\ -{\ - eval "${1}+=\\${2}"\ -} # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\ -func_append_quoted ()\ -{\ -\ func_quote_for_eval "${2}"\ -\ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\ -} # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - # Save a `func_append' function call where possible by direct use of '+=' - sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") - test 0 -eq $? || _lt_function_replace_fail=: -else - # Save a `func_append' function call even when '+=' is not available - sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") - test 0 -eq $? || _lt_function_replace_fail=: -fi - -if test x"$_lt_function_replace_fail" = x":"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5 -$as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;} -fi - - mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" @@ -26108,13 +41687,13 @@ hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX -# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes +# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct_CXX -# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes +# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary and the resulting library dependency is -# "absolute",i.e impossible to change by setting \${shlibpath_var} if the +# "absolute",i.e impossible to change by setting \$shlibpath_var if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute_CXX @@ -26180,6 +41759,26 @@ compiler_lib_search_path=$lt_compiler_lib_search_path_CXX _LT_EOF ;; + "scripts/Aix/nut.init":F) chmod +x "scripts/Aix/nut.init" ;; + "scripts/HP-UX/postinstall":F) chmod +x "scripts/HP-UX/postinstall" ;; + "scripts/python/app/NUT-Monitor-py2gtk2":F) chmod +x "scripts/python/app/NUT-Monitor-py2gtk2" ;; + "scripts/python/app/NUT-Monitor-py3qt5":F) chmod +x "scripts/python/app/NUT-Monitor-py3qt5" ;; + "scripts/augeas/gen-nutupsconf-aug.py":F) chmod +x "scripts/augeas/gen-nutupsconf-aug.py" ;; + "scripts/python/module/test_nutclient.py":F) chmod +x "scripts/python/module/test_nutclient.py" ;; + "scripts/upsdrvsvcctl/nut-driver-enumerator.sh":F) chmod +x "scripts/upsdrvsvcctl/nut-driver-enumerator.sh" ;; + "scripts/upsdrvsvcctl/upsdrvsvcctl":F) chmod +x "scripts/upsdrvsvcctl/upsdrvsvcctl" ;; + "scripts/systemd/nutshutdown":F) chmod +x "scripts/systemd/nutshutdown" ;; + "scripts/Solaris/svc-nut-server":F) chmod +x "scripts/Solaris/svc-nut-server" ;; + "scripts/Solaris/svc-nut-monitor":F) chmod +x "scripts/Solaris/svc-nut-monitor" ;; + "scripts/Solaris/precheck.py":F) chmod +x "scripts/Solaris/precheck.py" ;; + "scripts/Solaris/preinstall":F) chmod +x "scripts/Solaris/preinstall" ;; + "scripts/Solaris/postinstall":F) chmod +x "scripts/Solaris/postinstall" ;; + "scripts/Solaris/preremove":F) chmod +x "scripts/Solaris/preremove" ;; + "scripts/Solaris/postremove":F) chmod +x "scripts/Solaris/postremove" ;; + "scripts/Solaris/preproto.pl":F) chmod +x "scripts/Solaris/preproto.pl" ;; + "scripts/Solaris/nut":F) chmod +x "scripts/Solaris/nut" ;; + "tools/gitlog2changelog.py":F) chmod +x "tools/gitlog2changelog.py" ;; + "tools/nut-snmpinfo.py":F) chmod +x "tools/nut-snmpinfo.py" ;; esac done # for ac_tag @@ -26222,3 +41821,12 @@ fi cat conf_nut_report_feature + echo "------------------" + echo "Compiler settings:" + printf 'CC \t:%s\n' "$CC" + printf 'CFLAGS \t:%s\n' "$CFLAGS" + printf 'CXX \t:%s\n' "$CXX" + printf 'CXXFLAGS\t:%s\n' "$CXXFLAGS" + printf 'CPP \t:%s\n' "$CPP" + printf 'CPPFLAGS\t:%s\n' "$CPPFLAGS" + diff --git a/configure.ac b/configure.ac index 41db8d3..3aa26c2 100644 --- a/configure.ac +++ b/configure.ac @@ -2,32 +2,40 @@ dnl +------------------------------------------------------------------+ dnl | Network UPS Tools: configure.ac | dnl +------------------------------------------------------------------+ -dnl NUT version number is defined here, with a Git suffix in include/nut_version.h -AC_INIT(nut, 2.7.4, [https://github.com/networkupstools/nut/issues]) +dnl NUT version number is defined here, with a Git suffixed macro like +dnl NUT_VERSION_MACRO "2.7.4-2838-gdfc3ac08" +dnl in include/nut_version.h (generated by make) +AC_INIT([nut],[2.8.0],[https://github.com/networkupstools/nut/issues]) AC_CONFIG_AUX_DIR([.]) AC_CONFIG_SRCDIR(server/upsd.c) AC_CONFIG_MACRO_DIR([m4]) echo "Network UPS Tools version ${PACKAGE_VERSION}" -AC_CANONICAL_SYSTEM +AC_CANONICAL_TARGET NUT_CHECK_OS -AC_CONFIG_HEADER(include/config.h) +NUT_STASH_WARNINGS +AC_CONFIG_HEADERS([include/config.h]) AC_PREFIX_DEFAULT(/usr/local/ups) AM_INIT_AUTOMAKE([subdir-objects]) -dnl we need Autoconf 2.60 or better to enable features of Posix that are extensions to C +dnl we need Autoconf 2.61 or better to enable features of Posix that are extensions to C +dnl (and actually 2.64 or better for m4/ax_check_compile_flag.m4 when it is sourced) AC_MSG_CHECKING(for autoconf macro to enable system extensions) -m4_version_prereq(2.60, [ +m4_version_prereq(2.61, [ AC_MSG_RESULT(yes) AC_USE_SYSTEM_EXTENSIONS ], [ AC_MSG_RESULT(no) ]) +AC_PREREQ([2.64]) + dnl Use "./configure --enable-maintainer-mode" to keep Makefile.in and Makefile dnl in sync after Git updates. AM_MAINTAINER_MODE -dnl PKG_PROG_PKG_CONFIG +dnl Some systems have older autotools without direct macro support for PKG_CONF* +NUT_CHECK_PKGCONFIG + dnl Various version related processing dnl ---------------------------------- @@ -45,7 +53,7 @@ AC_DEFINE_UNQUOTED(TREE_VERSION, "${TREE_VERSION}", [NUT tree version]) dnl Should not be necessary, since old servers have well-defined errors for dnl unsupported commands: -NUT_NETVERSION="1.2" +NUT_NETVERSION="1.3" AC_DEFINE_UNQUOTED(NUT_NETVERSION, "${NUT_NETVERSION}", [NUT network protocol version]) @@ -67,6 +75,13 @@ cgiexecdir='${exec_prefix}/cgi-bin' driverexecdir='${exec_prefix}/bin' htmldir='${prefix}/html' pkgconfigdir='${libdir}/pkgconfig' +auglensdir='/usr/share/augeas/lenses/dist' +if test ! -d "${auglensdir}"; then + auglensdir='/usr/share/augeas/lenses' + if test ! -d "${auglensdir}"; then + auglensdir='' + fi +fi hotplugdir='/etc/hotplug' if test ! -d "${hotplugdir}"; then hotplugdir='' @@ -89,6 +104,9 @@ fi RUN_AS_USER="nobody" RUN_AS_GROUP="nobody" +AS_IF([test -n "`getent group nogroup`" && ! test -n "`getent group "${RUN_AS_GROUP}"`"], + [RUN_AS_GROUP="nogroup"] +) PIDPATH="/var/run" dnl Define directory where LIBOBJS replacement functions are @@ -96,26 +114,243 @@ AC_CONFIG_LIBOBJ_DIR([common]) dnl +------------------------------------------------------------------- -AC_PROG_CC +dnl AC_PROG_CC +dnl Macro AC_PROG_CC_C99 is obsolete; use AC_PROG_CC +dnl Note that NUT does not support building with C89 anyway +dnl AC_PROG_CC_C99 dnl Needed for per-target flags AM_PROG_CC_C_O AC_PROG_CPP AC_PROG_CXX +AC_PROG_CXX_C_O AC_PROG_INSTALL +AC_PROG_MKDIR_P +AC_PROG_LN_S AC_PROG_EGREP AC_PATH_PROG(AR, ar) AC_CHECK_TOOL(RANLIB, ranlib, :) -dnl Postpone call to AC_PROG_LIBTOOL to allow disabling static lib +dnl Postpone call to LT_INIT/AC_CONFIG_FILES to allow disabling static lib AC_C_BIGENDIAN AC_C_INLINE AC_C_FLEXIBLE_ARRAY_MEMBER AC_C_VARARRAYS -AC_CHECK_FUNCS(flock lockf fcvt fcvtl) +dnl Note: the compiler/pragma/attr methods below are custom for NUT codebase: +NUT_COMPILER_FAMILY +dnl Help find warning/error details in a wall of text (must be processed before NUT_COMPILER_FAMILY_FLAGS): +NUT_ARG_ENABLE([Wcolor], + [Request that compiler output is colorized (no = leave it up to compiler defaults)], + [no]) +NUT_COMPILER_FAMILY_FLAGS +AX_C_PRAGMAS +AX_C___ATTRIBUTE__ +AX_C_PRINTF_STRING_NULL +AC_CHECK_FUNCS(flock lockf fcvt fcvtl pow10 round abs_val abs) + +AC_CHECK_HEADER([float.h], + [AC_DEFINE([HAVE_FLOAT_H], [1], + [Define to 1 if you have .])]) +AC_CHECK_HEADER([math.h], + [AC_DEFINE([HAVE_MATH_H], [1], + [Define to 1 if you have .])]) +AC_CHECK_FUNCS(fabs fabsf fabsl, [], [], +[#ifdef HAVE_MATH_H +# include +#endif +#ifdef HAVE_FLOAT_H +# include +#endif]) + +AC_CHECK_HEADER([limits.h], + [AC_DEFINE([HAVE_LIMITS_H], [1], + [Define to 1 if you have .])]) + +AC_CHECK_HEADER([signal.h], + [AC_DEFINE([HAVE_SIGNAL_H], [1], + [Define to 1 if you have .])]) + +AC_CHECK_HEADER([sys/signal.h], + [AC_DEFINE([HAVE_SYS_SIGNAL_H], [1], + [Define to 1 if you have .])]) + +AC_CHECK_HEADER([sys/resource.h], + [AC_MSG_CHECKING([for struct rlimit and getrlimit()]) + AC_LANG_PUSH([C]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +#include +], +[struct rlimit limit; +getrlimit(RLIMIT_NOFILE, &limit); +/* Do not care about actual return value in this test, + * normally check for non-zero meaning to look in errno */ +] + )], + [AC_DEFINE([HAVE_SYS_RESOURCE_H], [1], + [Define to 1 if you have with usable struct rlimit and getrlimit().]) + AC_MSG_RESULT([ok]) + ], + [AC_MSG_RESULT([no])] + ) + AC_LANG_POP([C]) + ] +) + +AC_CHECK_HEADER([semaphore.h], + [AC_DEFINE([HAVE_SEMAPHORE_H], [1], + [Define to 1 if you have .]) + AC_MSG_CHECKING([for sem_t, sem_init() and sem_destroy()]) + AC_LANG_PUSH([C]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +#include +], +[sem_t semaphore; +sem_init(&semaphore, 0, 4); +sem_destroy(&semaphore); +/* Do not care about actual return value in this test, + * normally check for non-zero meaning to look in errno */ +] + )], + [AC_DEFINE([HAVE_SEMAPHORE], [1], + [Define to 1 if you have with usable sem_t sem_init() and sem_destroy().]) + AC_MSG_RESULT([ok]) + ], + [AC_MSG_RESULT([no])] + ) + AC_LANG_POP([C]) + ] +) + AC_CHECK_FUNCS(cfsetispeed tcsendbreak) AC_CHECK_FUNCS(seteuid setsid getpassphrase) AC_CHECK_FUNCS(on_exit strptime setlogmask) AC_CHECK_DECLS(LOG_UPTO, [], [], [#include ]) +dnl These common routines are not available in strict C standard library +dnl compilation modes (not part of ANSI or later standard), only in GNU, +dnl POSIX or other extension modes. Note that on modern systems they are +dnl available, just hidden in headers - so AC_CHECK_FUNCS() finds them +dnl by adding a declaration, while the "real" codebase can't use them. +AC_MSG_NOTICE( +[----------------------------------------------------------------------- +The next few tests look for required C library routines; if something is +not found, you may need to enable a different C standard or extension macro +version. You may also have to configure without extreme warning levels +since autotools tests fail those on their own and assume system lacks +stuff (although note we try to not involve standard -W* flags here). +-----------------------------------------------------------------------]) +dnl# AC_CHECK_FUNCS(strcasecmp strncasecmp, +dnl# [], [AC_MSG_WARN([Required C library routine not found; try adding __EXTENSIONS__])]) +dnl These appear with CFLAGS="-std=c99 -D_POSIX_C_SOURCE=200112L": +dnl# Methods below currently do not cause build errors for C99+ modes so are +dnl# not tested as thoroughly as those further below: + AC_CHECK_FUNCS(strtok_r fileno localtime_r sigemptyset sigaction, + [], [AC_MSG_WARN([Required C library routine not found; try adding -D_POSIX_C_SOURCE=200112L])]) + +AC_LANG_PUSH([C]) + +AC_CHECK_HEADER([string.h], + [AC_DEFINE([HAVE_STRING_H], [1], + [Define to 1 if you have .])]) + +AC_CHECK_HEADER([strings.h], + [AC_DEFINE([HAVE_STRINGS_H], [1], + [Define to 1 if you have .])]) + +CODE_STRINGINCL='#ifdef HAVE_STRING_H +#include +#endif +#ifdef HAVE_STRINGS_H +#include +#endif' + +AC_CACHE_CHECK([for strcasecmp(s1,s2)], + [ac_cv_func_strcasecmp], + [AX_RUN_OR_LINK_IFELSE( + [AC_LANG_PROGRAM([$CODE_STRINGINCL], + [if (strcasecmp("STR1", "str1") != 0) return 1])], + [ac_cv_func_strcasecmp=yes], [ac_cv_func_strcasecmp=no] + )]) +AS_IF([test x"${ac_cv_func_strcasecmp}" = xyes], + [AC_DEFINE([HAVE_STRCASECMP], 1, [defined if standard library has, and C standard allows, the strcasecmp(s1,s2) method])], + [AC_MSG_WARN([Required C library routine strcasecmp not found; try adding __EXTENSIONS__])] + ) + +AC_CACHE_CHECK([for strncasecmp(s1,s2,n)], + [ac_cv_func_strncasecmp], + [AX_RUN_OR_LINK_IFELSE( + [AC_LANG_PROGRAM([$CODE_STRINGINCL], + [if (strncasecmp("STR1", "strX", 2) != 0) return 1])], + [ac_cv_func_strncasecmp=yes], [ac_cv_func_strncasecmp=no] + )]) +AS_IF([test x"${ac_cv_func_strncasecmp}" = xyes], + [AC_DEFINE([HAVE_STRNCASECMP], 1, [defined if standard library has, and C standard allows, the strncasecmp(s1,s2,n) method])], + [AC_MSG_WARN([Required C library routine strncasecmp not found; try adding __EXTENSIONS__])] + ) + +AC_CACHE_CHECK([for strdup(s)], + [ac_cv_func_strdup], + [AX_RUN_OR_LINK_IFELSE( + [AC_LANG_PROGRAM([$CODE_STRINGINCL], + [[int res = 0; +char *t = "Test"; +char *s = strdup(t); +if (!s || !(s[0]=='T'&&s[1]=='e'&&s[2]=='s'&&s[3]=='t'&&s[4]=='\0') || s == t) res = 1; +if (s) free (s); +if (res != 0) return res +/* autoconf adds ";return 0;" */ +]])], + [ac_cv_func_strdup=yes], [ac_cv_func_strdup=no] + )]) +AS_IF([test x"${ac_cv_func_strdup}" = xyes], + [AC_DEFINE([HAVE_STRDUP], 1, [defined if standard library has, and C standard allows, the strdup(s) method])], + [AC_MSG_WARN([Required C library routine strdup not found; try adding -D_POSIX_C_SOURCE=200112L])] + ) + +AC_CACHE_CHECK([for usleep(us)], + [ac_cv_func_usleep], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include + ]], + [[useconds_t us = 1000; +if (usleep(us) != 0) return 1 /* per doc, no erros are returned actually*/ +/* autoconf adds ";return 0;" */ +]])], + [ac_cv_func_usleep=yes], [ac_cv_func_usleep=no] + )]) +AS_IF([test x"${ac_cv_func_usleep}" = xyes], + [AC_DEFINE([HAVE_USLEEP], 1, [defined if standard library has, and C standard allows, the usleep(us) method])], + [AC_MSG_WARN([Required C library routine usleep not found; try adding -D_POSIX_C_SOURCE=200112L])] + ) + +AC_LANG_POP([C]) + +dnl These routines' arg types differ in strict C standard mode +dnl from what they use in the modes expected by NUT codebase: +dnl bind() : /usr/include/x86_64-linux-gnu/sys/socket.h:123:12: note: expected '__CONST_SOCKADDR_ARG {aka union }' but argument is of type 'struct sockaddr *' +dnl accept() : /usr/include/x86_64-linux-gnu/sys/socket.h:243:12: note: expected '__SOCKADDR_ARG {aka union }' but argument is of type 'struct sockaddr *' +dnl connect() : /usr/include/x86_64-linux-gnu/sys/socket.h:137:12: note: expected '__CONST_SOCKADDR_ARG {aka union }' but argument is of type 'const struct sockaddr *' +dnl sendto() : /usr/include/x86_64-linux-gnu/sys/socket.h:163:16: note: expected '__CONST_SOCKADDR_ARG {aka union }' but argument is of type 'struct sockaddr *' +dnl recvfrom() : /usr/include/x86_64-linux-gnu/bits/socket2.h:64:1: note: expected '__SOCKADDR_ARG {aka union }' but argument is of type 'struct sockaddr *' + +AC_MSG_CHECKING([whether ln -sr works]) +dnl We need to relative-symlink some files. Or hardlink. Or copy... +LN_S_R="cp -pR" +if test "$as_ln_s" = "ln -s" ; then + LN_S_R="ln" + DIR1="$(mktemp -d "dir1.XXXXXXX")" && \ + DIR2="$(mktemp -d "dir2.XXXXXXX")" && \ + touch "${DIR1}/a" && \ + $as_ln_s -r "${DIR1}/a" "${DIR2}/b" && \ + ls -la "${DIR2}/b" | grep '\.\./' > /dev/null && \ + LN_S_R="$as_ln_s -r" + rm -rf "${DIR1}" "${DIR2}" +fi +AC_SUBST([LN_S_R], [${LN_S_R}]) +if test "$LN_S_R" = "ln -s -r" ; then + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no, using $LN_S_R]) +fi + dnl the following may add stuff to LIBOBJS (is this still needed?) AC_CHECK_FUNCS(vsnprintf snprintf, [], [ AC_LIBOBJ(snprintf) @@ -125,27 +360,6 @@ AC_CHECK_FUNCS(vsnprintf snprintf, [], [ AC_REPLACE_FUNCS(setenv strerror atexit) - -dnl -dnl Tests for CppUnit availability and usability -dnl Using CppUnit implies C++ support! -dnl Theoretically, libcppunit-dev will pull up to g++, through libstdc++... -dnl AM_PATH_CPPUNIT(1.9.6) - -PKG_CHECK_MODULES(CPPUNIT, cppunit, have_cppunit=yes, have_cppunit=no) -if test "${have_cppunit}" != "yes" ; then - AC_MSG_WARN([libcppunit not found.]) -fi -AM_CONDITIONAL(HAVE_CPPUNIT, test "${have_cppunit}" = "yes") - -dnl -dnl Only use these when compiling with gcc -dnl -if ( test "${GCC}" = "yes" ) -then - CFLAGS="${CFLAGS} -Wall -Wsign-compare" -fi - case ${target_os} in solaris2* ) dnl On Solaris, this allows errno to use thread local storage @@ -202,43 +416,292 @@ AC_CHECK_DECLS(__func__, [], [ AC_DEFINE(__func__, __LINE__, [Replace missing __func__ declaration]) ], [AC_INCLUDES_DEFAULT]) ], [AC_INCLUDES_DEFAULT]) - + dnl Solaris compatibility - check for -lnsl and -lsocket AC_SEARCH_LIBS(gethostbyname, nsl) AC_SEARCH_LIBS(connect, socket) -AC_HEADER_TIME -AC_CHECK_HEADERS(sys/modem.h stdarg.h varargs.h sys/termios.h sys/time.h, [], [], [AC_INCLUDES_DEFAULT]) +dnl All current systems provide time.h; it need not be checked for. +dnl Not all systems provide sys/time.h, but those that do, all allow +dnl you to include it and time.h simultaneously. +dnl NUT codebase provides the include/timehead.h to wrap these nuances. +AC_CHECK_HEADERS_ONCE([sys/time.h time.h sys/types.h sys/socket.h netdb.h]) +AS_IF([test "$ac_cv_header_sys_time_h" = yes], + [AC_DEFINE([TIME_WITH_SYS_TIME],[1],[Define to 1 if you can safely include both + and . This macro is deemed obsolete by autotools.]) + ], []) -# pthread related checks +AC_CHECK_HEADERS(sys/modem.h stdarg.h varargs.h, [], [], [AC_INCLUDES_DEFAULT]) + + +dnl pthread related checks +dnl Note: pthread_tryjoin_np() should be available since glibc 2.3.3, according +dnl to https://man7.org/linux/man-pages/man3/pthread_tryjoin_np.3.html AC_SEARCH_LIBS([pthread_create], [pthread], - [AC_DEFINE(HAVE_PTHREAD, 1, [Define to enable pthread support code])], + [AC_DEFINE(HAVE_PTHREAD, 1, [Define to enable pthread support code]) + AC_SEARCH_LIBS([pthread_tryjoin_np], [pthread], + [AC_DEFINE(HAVE_PTHREAD_TRYJOIN, 1, [Define to enable pthread_tryjoin support code])], + []) + ], []) dnl ---------------------------------------------------------------------- dnl Check for types and define possible replacements NUT_TYPE_SOCKLEN_T +NUT_FUNC_GETNAMEINFO_ARGTYPES + +dnl ---------------------------------------------------------------------- +dnl Check for python binary program names per language version +dnl to embed into scripts and Make rules +NUT_CHECK_PYTHON +NUT_CHECK_PYTHON2 +NUT_CHECK_PYTHON3 + +dnl ---------------------------------------------------------------------- +dnl check for --with-drivers=all (or --with-drivers=name[,name...]) flag + +dnl Autoconf versions before 2.62 do not allow consecutive quadrigraphs +dnl (square brackets), so the help string depends on the version used +AC_MSG_CHECKING(which drivers to build) +AC_ARG_WITH(drivers, + AS_HELP_STRING([m4_version_prereq(2.62, + [@<:@--with-drivers=driver@<:@,driver@:>@@:>@], + [[[[--with-drivers=driver@<:@,driver@:>@]]]])], + [Only build specific drivers (all)]), +[ + case "${withval}" in + yes|no|'') + AC_MSG_ERROR(invalid option --with(out)-drivers - see docs/configure.txt) + ;; + all) + dnl Explicit request to build all drivers (unless specified), or fail + DRIVER_BUILD_LIST="all" + if test -z "${with_serial}"; then with_serial="yes"; fi + if test -z "${with_usb}"; then with_usb="yes"; fi + if test -z "${with_snmp}"; then with_snmp="yes"; fi + if test -z "${with_neon}"; then with_neon="yes"; fi + if test -z "${with_powerman}"; then with_powerman="yes"; fi + if test -z "${with_modbus}"; then with_modbus="yes"; fi + if test -z "${with_ipmi}"; then with_ipmi="yes"; fi + + dnl Platform-dependent snowflakes that are required or auto: + if test -z "${with_linux_i2c}"; then + case ${target_os} in + linux*) with_linux_i2c="yes";; + *) with_linux_i2c="auto";; + esac + fi + if test -z "${with_macosx_ups}"; then + if test -d /System/Library/Frameworks/IOKit.framework/ ; then + with_macosx_ups="yes" + else + with_macosx_ups="auto" + fi + fi + AC_MSG_RESULT(${DRIVER_BUILD_LIST}) + ;; + auto) + dnl Explicit request to build all drivers that we can + DRIVER_BUILD_LIST="all" + if test -z "${with_serial}"; then with_serial="${withval}"; fi + if test -z "${with_usb}"; then with_usb="${withval}"; fi + if test -z "${with_snmp}"; then with_snmp="${withval}"; fi + if test -z "${with_neon}"; then with_neon="${withval}"; fi + if test -z "${with_powerman}"; then with_powerman="${withval}"; fi + if test -z "${with_modbus}"; then with_modbus="${withval}"; fi + if test -z "${with_ipmi}"; then with_ipmi="${withval}"; fi + if test -z "${with_linux_i2c}"; then with_linux_i2c="${withval}"; fi + if test -z "${with_macosx_ups}"; then with_macosx_ups="${withval}"; fi + AC_MSG_RESULT(${DRIVER_BUILD_LIST}) + ;; + *) + DRIVER_BUILD_LIST="`echo ${withval} | sed 's/,/ /g'`" + AC_MSG_RESULT(${DRIVER_BUILD_LIST}) + + AS_IF([test -n "$DRIVER_BUILD_LIST"], + [dnl DRVLIST is occasionally synced with drivers/Makefile.am + dnl NOTE: Currently "USB_DRIVERLIST" is not used standalone: + DRVLIST_NAMES=" + SERIAL_DRIVERLIST USB_LIBUSB_DRIVERLIST SERIAL_USB_DRIVERLIST + SNMP_DRIVERLIST NEONXML_DRIVERLIST + MACOSX_DRIVERLIST MODBUS_DRIVERLIST LINUX_I2C_DRIVERLIST + POWERMAN_DRIVERLIST IPMI_DRIVERLIST" + + get_drvlist() ( + dnl Note escaped brackets - "against" m4 parser + m4_version_prereq(2.62, + [LB="@<:@"; RB="@:>@"], + [LB="[["; RB="]]"] + ) + SPACE="`printf "$LB"' \t'"$RB"`" + SPACES="${SPACE}*" + sed -e "s/${SPACES}""$LB"'+'"$RB"'*='"${SPACES}/=/" \ + -e "s/^${SPACES}//" < drivers/Makefile.am \ + | { + C=false; V=false + while read LINE ; do + case "$LINE" in + *'\') C=true; if $V ; then echo "$LINE" ; fi ;; + *) C=false; V=false ;; + esac + case "$LINE" in + "$1"=*) + echo "$LINE" | sed -e 's,^'"$LB"'^='"$RB"'*=,,' -e 's,\$,,' + V=$C + ;; + esac + done + } | tr '\n' ' ' | sed -e "s,${SPACE}${SPACES}, ," -e "s,${SPACES}\$,," + ) + + for DRVLIST_NAME in $DRVLIST_NAMES; do + OUT="`get_drvlist "$DRVLIST_NAME"`" \ + && test -n "$OUT" || OUT="" + eval $DRVLIST_NAME="\$OUT" + AC_MSG_NOTICE([Will check custom driver selection against $DRVLIST_NAME="$OUT"]) + done + + dnl Note: do not quote the expansion below to keep it multi-token: + for DRV in $DRIVER_BUILD_LIST ; do + + DRV_HITS="" + dnl #DEVEL-DEBUG# AC_MSG_NOTICE([= Checking DRV="$DRV"]) + for DRVLIST_NAME in $DRVLIST_NAMES; do + dnl #DEVEL-DEBUG# AC_MSG_NOTICE([== Checking DRVLIST_NAME="$DRVLIST_NAME"]) + eval DRVLIST="\${$DRVLIST_NAME}" + dnl #DEVEL-DEBUG# AC_MSG_NOTICE([== Contents DRVLIST="$DRVLIST"]) + + for DN in $DRVLIST ; do + dnl #DEVEL-DEBUG# AC_MSG_NOTICE([=== Checking DN="$DN"]) + AS_IF([test x"$DN" = x"$DRV"], [ + DRV_HITS="$DRV_HITS $DRVLIST_NAME" + AS_CASE(["$DRVLIST_NAME"], + + [SERIAL_DRIVERLIST], [ + AS_IF([test -z "${with_serial}"], + [AC_MSG_NOTICE([Requiring --with-serial=yes for driver "$DRV"]) + with_serial=yes] + )], + [USB_LIBUSB_DRIVERLIST], [ + AS_IF([test -z "${with_usb}"], + [AC_MSG_NOTICE([Requiring --with-usb=yes for driver "$DRV"]) + with_usb=yes] + )], + [SERIAL_USB_DRIVERLIST], [ + dnl e.g. nutdrv_qx that can do both + AS_IF([test -z "${with_usb}"], + [AC_MSG_NOTICE([Requiring --with-usb=yes for driver "$DRV"]) + with_usb=yes] + ) + AS_IF([test -z "${with_serial}"], + [AC_MSG_NOTICE([Requiring --with-serial=yes for driver "$DRV"]) + with_serial=yes] + )], + [SNMP_DRIVERLIST], [ + AS_IF([test -z "${with_snmp}"], + [AC_MSG_NOTICE([Requiring --with-snmp=yes for driver "$DRV"]) + with_snmp=yes] + )], + [NEONXML_DRIVERLIST], [ + AS_IF([test -z "${with_neon}"], + [AC_MSG_NOTICE([Requiring --with-neon=yes for driver "$DRV"]) + with_neon=yes] + )], + [MACOSX_DRIVERLIST], [ + dnl NOTE: This one is a bit special, + dnl just one certain driver so far + AS_IF([test -z "${with_macosx_ups}"], + [AC_MSG_NOTICE([Requiring --with-macosx-ups=yes for driver "$DRV"]) + with_macosx_ups=yes] + )], + [MODBUS_DRIVERLIST], [ + AS_IF([test -z "${with_modbus}"], + [AC_MSG_NOTICE([Requiring --with-modbus=yes for driver "$DRV"]) + with_modbus=yes] + )], + [LINUX_I2C_DRIVERLIST], [ + AS_IF([test -z "${with_linux_i2c}"], + [AC_MSG_NOTICE([Requiring --with-linux-i2c=yes for driver "$DRV"]) + with_linux_i2c=yes] + )], + [POWERMAN_DRIVERLIST], [ + AS_IF([test -z "${with_powerman}"], + [AC_MSG_NOTICE([Requiring --with-powerman=yes for driver "$DRV"]) + with_powerman=yes] + )], + [IPMI_DRIVERLIST], [ + AS_IF([test -z "${with_ipmi}"], + [AC_MSG_NOTICE([Requiring --with-ipmi=yes for driver "$DRV"]) + with_ipmi=yes] + )], + + [AC_MSG_WARN([Unhandled DRVLIST_NAME=$DRVLIST_NAME])] + ) + break + dnl Break once, maybe a driver hits several categories + ]) + done + done + AS_IF([test -z "${DRV_HITS}"], + [AC_MSG_ERROR([Requested driver '$DRV' is not defined in drivers/Makefile.am (or configure.ac has a bug/lag detecting driver lists)])]) + + done + ]) + + ;; + esac +], [ + dnl Implicit request to build whatever is enabled; + dnl do not force --with-all here: + DRIVER_BUILD_LIST="all" + AC_MSG_RESULT(all available) +]) +AM_CONDITIONAL(SOME_DRIVERS, test "${DRIVER_BUILD_LIST}" != "all") + +if test "${DRIVER_BUILD_LIST}" != "all"; then + NUT_REPORT([only build specific drivers], [${DRIVER_BUILD_LIST}]) +fi dnl ---------------------------------------------------------------------- dnl check for --with-all (or --without-all, or --with-all=auto) flag AC_MSG_CHECKING(for --with-all) AC_ARG_WITH(all, - AS_HELP_STRING([--with-all], [enable serial, usb, snmp, neon, ipmi, powerman, cgi, dev, avahi, linux_i2c]), + AS_HELP_STRING([--with-all], [enable serial, usb, snmp, neon, ipmi, powerman, modbus, cgi, dev, avahi, linux_i2c]), [ if test -n "${withval}"; then dnl Note: we allow "no" as a positive value, because dnl this is what the user expects from --without-all + dnl Note: these settings do not touch generation of + dnl "--with-docs=...", that is handled separately if test -z "${with_serial}"; then with_serial="${withval}"; fi if test -z "${with_usb}"; then with_usb="${withval}"; fi if test -z "${with_snmp}"; then with_snmp="${withval}"; fi if test -z "${with_neon}"; then with_neon="${withval}"; fi if test -z "${with_powerman}"; then with_powerman="${withval}"; fi + if test -z "${with_modbus}"; then with_modbus="${withval}"; fi + if test -z "${with_ipmi}"; then with_ipmi="${withval}"; fi + + dnl Platform-dependent snowflakes that are required or auto: + if test -z "${with_linux_i2c}"; then + with_linux_i2c="${withval}" + case ${target_os} in + linux*) ;; + *) test x"${withval}" = xno || with_linux_i2c="auto" ;; + esac + fi + if test -z "${with_macosx_ups}"; then + with_macosx_ups="${withval}" + if ! test -d /System/Library/Frameworks/IOKit.framework/ ; then + test x"${withval}" = xno || with_macosx_ups="auto" + fi + fi + + dnl These are not driver families, but other features: if test -z "${with_cgi}"; then with_cgi="${withval}"; fi if test -z "${with_dev}"; then with_dev="${withval}"; fi if test -z "${with_avahi}"; then with_avahi="${withval}"; fi - if test -z "${with_ipmi}"; then with_ipmi="${withval}"; fi - if test -z "${with_linux_i2c}"; then with_linux_i2c="${withval}"; fi + AC_MSG_RESULT("${withval}") else AC_MSG_RESULT(not given) @@ -249,98 +712,156 @@ AC_ARG_WITH(all, dnl ---------------------------------------------------------------------- dnl declare a number of --with-FEATURE options. Do this early, so that -dnl they are listed near the top by "./configure --help" +dnl they are listed near the top by "./configure --help"; however, +dnl note that options with further investigation methods are listed +dnl a bit below to be grouped with their additional with/enable help. NUT_ARG_WITH([dev], [build and install the development files], [no]) -NUT_ARG_WITH([serial], [build and install serial drivers], [yes]) -NUT_ARG_WITH([usb], [build and install USB drivers], [auto]) -NUT_ARG_WITH([doc], [build and install documentation], [no]) -NUT_ARG_WITH([avahi], [build and install Avahi support], [auto]) + +dnl The NUT legacy option was --with-doc; however to simplify configuration +dnl in some common packaging frameworks, we also allow --with-docs as +dnl a second-class citizen (if both are set, the old option name wins). +dnl Also note that the legacy default was "man=yes" due to requirements +dnl of the "make distcheck", but it was reduced to "man=auto" so that +dnl the usual builds can pass by default on systems without asciidoc. +NUT_ARG_WITH([docs], [build and install documentation (alias to --with-doc)], [man=auto]) +NUT_ARG_WITH([doc], [build and install documentation (see docs/configure.txt for many variants of the option)], [${nut_with_docs}]) + +dnl NOTE: Until X-Mas 2021, the default was "legacy" (now "medium") +NUT_ARG_ENABLE([warnings], + [enable warning presets that were picked as useful in maintainership and CI practice (variants include gcc-minimal, gcc-medium, gcc-hard, clang-minimal, clang-medium, clang-hard, all; auto-choosers: hard, medium, minimal, yes=auto='gcc or clang or all at hardcoded default difficulty')], + [auto]) +NUT_ARG_ENABLE([Werror], + [fail the build if compiler emits any warnings (treat them as errors)], + [no]) +dnl To help find warning/error details in a wall of text, see --enable-Wcolor handled above dnl ---------------------------------------------------------------------- dnl Check for presence and compiler flags of various libraries +NUT_ARG_WITH([serial], [build and install serial drivers], [yes]) + dnl These checks are performed unconditionally, even if the corresponding dnl --with-* options are not given. This is because we cannot predict dnl what will be in the --with-drivers argument. -NUT_CHECK_LIBNETSNMP +NUT_ARG_WITH([usb], [build and install USB drivers, optionally require build with specified version of libusb library and API: (auto|libusb-0.1|libusb-1.0)], [auto]) +nut_usb_lib="" NUT_CHECK_LIBUSB + NUT_ARG_WITH([snmp], [build and install SNMP drivers], [auto]) NUT_CHECK_LIBNETSNMP + NUT_ARG_WITH([neon], [build and install neon based XML/HTTP driver], [auto]) NUT_CHECK_LIBNEON + NUT_ARG_WITH([powerman], [build and install Powerman PDU client driver], [auto]) NUT_CHECK_LIBPOWERMAN + +NUT_ARG_WITH([modbus], [build and install modbus drivers], [auto]) +NUT_CHECK_LIBMODBUS + +NUT_ARG_WITH([avahi], [build and install Avahi support], [auto]) NUT_CHECK_LIBAVAHI -dnl ---------------------------------------------------------------------- -dnl additional USB-related checks - -dnl Solaris 10/11 USB handling (need librt and libusb runtime path) -dnl HPUX, since v11, needs an explicit activation of pthreads -case ${target_os} in - solaris2.1* ) - echo Checking for Solaris 10 / 11 specific configuration for usb drivers - AC_SEARCH_LIBS(nanosleep, rt) - LIBUSB_LIBS="-R/usr/sfw/lib ${LIBUSB_LIBS}" - dnl FIXME: Sun's libusb doesn't support timeout (so blocks notification) - dnl and need to call libusb close upon reconnection - AC_DEFINE(SUN_LIBUSB, 1, [Define to 1 for Sun version of the libusb.]) - SUN_LIBUSB=1 - ;; - hpux11*) - CFLAGS="${CFLAGS} -lpthread" -esac - - dnl ---------------------------------------------------------------------- dnl checks related to --with-serial dnl ${nut_with_serial}: any value except "yes" or "no" is treated as "auto". -if test "${nut_with_serial}" != "no"; then - nut_with_serial="yes" -fi +dnl Below we try to detect if we can build serial drivers, and if we must? +AS_IF([test "${nut_with_serial}" != "no"], + [AS_IF([test "${nut_with_serial}" != "yes"],[nut_with_serial="auto"]) + + CFLAGS_SAVED_SERIAL="${CFLAGS}" + AS_IF([test "${GCC}" = yes], + [CFLAGS_SAVED_WERROR="${CFLAGS} -Wall -Werror" + CFLAGS_SAVED_WNOERROR="${CFLAGS} -Wno-error" + ], + [CFLAGS_SAVED_WERROR="${CFLAGS}" + CFLAGS_SAVED_WNOERROR="${CFLAGS}" + ]) + + dnl At least recent *BSD distros have deprecated sys/termios.h and spew + dnl warnings that termios.h should be used instead. This is redundantly + dnl fatal for pedantic builds where we aim to have no warnings in code. + dnl So there AC_CHECK_HEADERS does find the header, but we don't really + dnl want to use it unless we have no choice: if there is a warning while + dnl trying sys/ version, try the plain header path (without fatal warnings), + dnl and only if that is missing - retry with the sys/ version again (and + dnl no warnings still). + + CFLAGS="${CFLAGS_SAVED_WERROR}" + AC_CHECK_HEADERS(sys/termios.h, [], [ + CFLAGS="${CFLAGS_SAVED_WNOERROR}" + AC_CHECK_HEADERS(termios.h, [], [ + AC_CHECK_HEADERS(sys/termios.h, [], [], [AC_INCLUDES_DEFAULT]) + ], [AC_INCLUDES_DEFAULT]) + ], [AC_INCLUDES_DEFAULT]) + + dnl CFLAGS at this point suffice for surviving a compilation with termios.h + + dnl Don't mind the stupid code below, it just probes the tokens and + dnl sails around compiler warnings + AC_MSG_CHECKING([for struct termios and speed_t]) + AC_LANG_PUSH([C]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +#if defined(HAVE_SYS_TERMIOS_H) +# include /* for speed_t */ +#else +# if defined(HAVE_TERMIOS_H) +# include +# endif /* HAVE_TERMIOS_H */ +#endif /* HAVE_SYS_TERMIOS_H */ +void getspeed(speed_t* b) { *b = B19200; } +], +[struct termios tio; +if (!tcgetattr(0, &tio)) { return 1; } +speed_t baudrate; +getspeed(&baudrate); +] + )], + [AC_MSG_RESULT([ok]) + nut_have_serial_types=yes + ], + [AC_MSG_RESULT([no, struct termios and/or speed_t not found in discovered headers]) + nut_have_serial_types=no + ] + ) + AC_LANG_POP([C]) + + dnl Restore common set-or-discovered CFLAGS + CFLAGS="${CFLAGS_SAVED_SERIAL}" + + AC_MSG_CHECKING([whether we can build serial drivers]) + AS_IF([test "${nut_have_serial_types}" = yes], + [AS_IF([test "${nut_with_serial}" = "auto"],[nut_with_serial="yes"])], + [AS_IF([test "${nut_with_serial}" = "auto"],[nut_with_serial="no"]) + AS_IF([test "${nut_with_serial}" = "yes"],[AC_MSG_ERROR([no, and were required to])]) + ]) + AS_IF([test "${nut_with_serial}" = "yes"], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no])]) +]) NUT_REPORT_FEATURE([build serial drivers], [${nut_with_serial}], [], [WITH_SERIAL], [Define to enable serial support]) dnl ---------------------------------------------------------------------- -dnl checks related to --with-usb +dnl checks related to --with-usb are in its m4 file and NUT_CHECK_LIBUSB() called above -dnl ${nut_with_usb}: any value except "yes" or "no" is treated as "auto". -if test "${nut_with_usb}" = "yes" -a "${nut_have_libusb}" != "yes"; then - AC_MSG_ERROR(["USB drivers requested, but libusb not found."]) -fi +dnl Note: there is no libusb-config script (and variable) for libusb-1.0 +AM_CONDITIONAL(WITH_LIBUSB_1_0, test "${nut_usb_lib}" = "(libusb-1.0)") +AM_CONDITIONAL(WITH_LIBUSB_0_1, test "${nut_usb_lib}" = "(libusb-0.1)" -o "${nut_usb_lib}" = "(libusb-0.1-config)") -if test "${nut_with_usb}" != "no"; then - nut_with_usb="${nut_have_libusb}" -fi - -NUT_REPORT_FEATURE([build USB drivers], [${nut_with_usb}], [], +NUT_REPORT_FEATURE([build USB drivers], [${nut_with_usb}], [${nut_usb_lib}], [WITH_USB], [Define to enable USB support]) -dnl ---------------------------------------------------------------------- -dnl checks related to --with-snmp - -dnl ${nut_with_snmp}: any value except "yes" or "no" is treated as "auto". -if test "${nut_with_snmp}" = "yes" -a "${nut_have_libnetsnmp}" != "yes"; then - AC_MSG_ERROR(["Net-SNMP libraries not found, required for SNMP drivers"]) -fi - -if test "${nut_with_snmp}" != "no"; then - nut_with_snmp="${nut_have_libnetsnmp}" -fi - -NUT_REPORT_FEATURE([build SNMP drivers], [${nut_with_snmp}], [], - [WITH_SNMP], [Define to enable SNMP support]) - dnl ---------------------------------------------------------------------- dnl checks related to --with-neon dnl ${nut_with_neon}: any value except "yes" or "no" is treated as "auto". if test "${nut_with_neon}" = "yes" -a "${nut_have_neon}" != "yes"; then - AC_MSG_ERROR(["neon libraries not found, required for neon based XML/HTTP driver"]) + AC_MSG_ERROR([neon libraries not found, required for neon based XML/HTTP driver]) fi if test "${nut_with_neon}" != "no"; then @@ -349,13 +870,14 @@ fi NUT_REPORT_FEATURE([build neon based XML driver], [${nut_with_neon}], [], [WITH_NEON], [Define to enable Neon HTTP support]) +AM_CONDITIONAL([HAVE_NEON], [test "${nut_have_neon}" = "yes"]) dnl ---------------------------------------------------------------------- dnl checks related to --with-avahi dnl ${nut_with_avahi}: any value except "yes" or "no" is treated as "auto". if test "${nut_with_avahi}" = "yes" -a "${nut_have_avahi}" != "yes"; then - AC_MSG_ERROR(["avahi libraries not found"]) + AC_MSG_ERROR([avahi libraries not found]) fi if test "${nut_with_avahi}" != "no"; then @@ -371,7 +893,7 @@ dnl checks related to --with-powerman dnl ${nut_with_powerman}: any value except "yes" or "no" is treated as "auto". if test "${nut_with_powerman}" = "yes" -a "${nut_have_libpowerman}" != "yes"; then - AC_MSG_ERROR(["Powerman client libraries not found, required for Powerman PDU client driver"]) + AC_MSG_ERROR([Powerman client libraries not found, required for Powerman PDU client driver]) fi if test "${nut_with_powerman}" != "no"; then @@ -382,6 +904,20 @@ NUT_REPORT_FEATURE([build Powerman PDU client driver], [${nut_with_powerman}], [ [WITH_LIBPOWERMAN], [Define to enable Powerman PDU support]) dnl ---------------------------------------------------------------------- +dnl checks related to --with-modbus + +dnl ${nut_with_modbus}: any value except "yes" or "no" is treated as "auto". +if test "${nut_with_modbus}" = "yes" -a "${nut_have_libmodbus}" != "yes"; then + AC_MSG_ERROR([modbus library not found, required for Modbus driver]) +fi + +if test "${nut_with_modbus}" != "no"; then + nut_with_modbus="${nut_have_libmodbus}" +fi + +NUT_REPORT_FEATURE([build Modbus driver], [${nut_with_modbus}], [], + [WITH_MODBUS], [Define to enable Modbus support]) +dnl ---------------------------------------------------------------------- dnl Check for with-ipmi, and --with-freeipmi (or --with-openipmi) dnl Only one can be enabled at a time, with a preference for FreeIPMI dnl if both are available (since it is the only one supported ATM!!) @@ -392,21 +928,21 @@ NUT_ARG_WITH([ipmi], [build and install IPMI PSU driver], [auto]) NUT_ARG_WITH([freeipmi], [enable IPMI support using FreeIPMI], [auto]) dnl NUT_ARG_WITH([openipmi], [enable IPMI support using OpenIPMI], [auto]) -dnl ${nut_with_ipmi}: any value except "yes" or "no" is treated as "auto". +dnl ${nut_with_ipmi}: any value except "yes" or "no" is treated as "auto". if test "${nut_with_ipmi}" != "no"; then dnl check if FreeIPMI (and maybe later OpenIPMI) was explicitly requested if test "${nut_with_freeipmi}" = "yes"; then NUT_CHECK_LIBFREEIPMI if test "${nut_have_freeipmi}" != "yes"; then - AC_MSG_ERROR(["GNU FreeIPMI not found, required for IPMI support"]) + AC_MSG_ERROR([FreeIPMI not found, required for IPMI support]) fi dnl Implies --with-ipmi nut_with_ipmi="yes" dnl elif test "${nut_with_openipmi}" = "yes"; then - dnl AC_MSG_ERROR(["OpenIPMI is not yet supported"]) + dnl AC_MSG_ERROR([OpenIPMI is not yet supported]) dnl NUT_CHECK_LIBOPENIPMI dnl if test "${nut_have_openipmi}" != "yes"; then - dnl AC_MSG_ERROR(["OpenIPMI not found, required for IPMI support"]) + dnl AC_MSG_ERROR([OpenIPMI not found, required for IPMI support]) dnl fi dnl Implies --with-ipmi dnl nut_with_ipmi="yes" @@ -416,13 +952,13 @@ if test "${nut_with_ipmi}" != "no"; then NUT_CHECK_LIBFREEIPMI if test "${nut_have_freeipmi}" != "yes"; then if test "${nut_with_ipmi}" = "yes"; then - AC_MSG_ERROR(["FreeIPMI not found, required for IPMI support"]) + AC_MSG_ERROR([FreeIPMI not found, required for IPMI support]) fi nut_with_ipmi="no" dnl NUT_CHECK_OPENIPMI dnl if test "${nut_have_openipmi}" != "yes"; then dnl if test "${nut_with_ipmi}" = "yes"; then - dnl AC_MSG_ERROR(["GNU FreeIPMI and OpenIPMI neither found, required for IPMI support"]) + dnl AC_MSG_ERROR([Neither GNU FreeIPMI nor OpenIPMI was found (required for IPMI support)]) dnl fi dnl nut_with_ipmi="no" dnl else @@ -460,6 +996,9 @@ if test "${nut_with_macosx_ups}" != no; then if test -d /System/Library/Frameworks/IOKit.framework/ ; then nut_with_macosx_ups="yes" else + if test "${nut_with_macosx_ups}" = yes; then + AC_MSG_ERROR([macosx-ups was required but can not be fulfilled for this build: not MacOS]) + fi nut_with_macosx_ups="no" fi fi @@ -475,16 +1014,47 @@ NUT_ARG_WITH([linux_i2c], [build and install i2c drivers], [auto]) if test "${nut_with_linux_i2c}" != no; then case ${target_os} in linux* ) + AC_CHECK_HEADER( + [linux/i2c-dev.h], + [AC_DEFINE([HAVE_LINUX_I2C_DEV_H], [1], + [Define to 1 if you have .])] + ) + AC_CHECK_HEADER( + [i2c/smbus.h], + [AC_DEFINE([HAVE_LINUX_SMBUS_H], [1], + [Define to 1 if you have .])] + ) AC_CHECK_DECLS( - [i2c_smbus_read_word_data, i2c_smbus_write_word_data, i2c_smbus_read_block_data], - [nut_with_linux_i2c="yes"], - [nut_with_linux_i2c="no"], + [i2c_smbus_access, i2c_smbus_read_byte_data, i2c_smbus_write_byte_data, i2c_smbus_read_word_data, i2c_smbus_write_word_data, i2c_smbus_read_block_data], + [], dnl # nut_with_linux_i2c="yes" + [AS_IF([test "${nut_with_linux_i2c}" = "yes"], + [AC_MSG_ERROR(i2c was required but can not be fulfilled for this build)], + [nut_with_linux_i2c="no"])], [#include + #ifdef HAVE_LINUX_I2C_DEV_H #include + #endif + #ifdef HAVE_LINUX_SMBUS_H + #include + #endif ] ) + dnl Builds for bitness/arch other than system default can be + dnl "compromised" by lack of respective binary library, so + dnl even if we have the right headers, ultimate link fails. + dnl Note: here we keep the verdict from above, or make it worse. + AC_SEARCH_LIBS([i2c_smbus_read_byte, i2c_smbus_access, i2c_smbus_read_byte_data, i2c_smbus_write_byte_datai2c_smbus_write_byte_data, i2c_smbus_read_word_data, i2c_smbus_write_word_data, i2c_smbus_read_block_data], + [i2c], + [nut_with_linux_i2c="yes"], + [AS_IF([test "${nut_with_linux_i2c}" = "yes"], + [AC_MSG_ERROR(i2c was required but can not be fulfilled for this build)], + [nut_with_linux_i2c="no"]) + ]) ;; * ) + if test "${nut_with_linux_i2c}" = yes; then + AC_MSG_ERROR([i2c was required but can not be fulfilled for this build: not linux]) + fi nut_with_linux_i2c="no" ;; esac @@ -508,18 +1078,18 @@ NUT_ARG_WITH([ssl], [enable SSL support (either NSS or OpenSSL)], [auto]) NUT_ARG_WITH([nss], [enable SSL support using Mozilla NSS], [auto]) NUT_ARG_WITH([openssl], [enable SSL support using OpenSSL], [auto]) -dnl ${nut_with_ssl}: any value except "yes" or "no" is treated as "auto". +dnl ${nut_with_ssl}: any value except "yes" or "no" is treated as "auto". if test "${nut_with_ssl}" != "no"; then dnl check if either NSS or OpenSSL was explicitly requested if test "${nut_with_nss}" = "yes"; then NUT_CHECK_LIBNSS if test "${nut_have_libnss}" != "yes"; then - AC_MSG_ERROR(["Mozilla NSS not found, required for SSL support"]) + AC_MSG_ERROR([Mozilla NSS not found (required for SSL support)]) fi elif test "${nut_with_openssl}" = "yes"; then NUT_CHECK_LIBOPENSSL if test "${nut_have_openssl}" != "yes"; then - AC_MSG_ERROR(["OpenSSL not found, required for SSL support"]) + AC_MSG_ERROR([OpenSSL not found (required for SSL support)]) fi else dnl Prefer OpenSSL over NSS otherwise @@ -529,9 +1099,9 @@ if test "${nut_with_ssl}" != "no"; then if test "${nut_have_libnss}" != "yes"; then dnl Only abort if SSL has been explicitly requested by the user if test "${nut_with_ssl}" = "yes"; then - AC_MSG_ERROR(["Mozilla NSS and OpenSSL neither found, but are needed for the requested SSL support"]) + AC_MSG_ERROR([Neither Mozilla NSS nor OpenSSL was found, but one is needed for the requested SSL support.]) else - AC_MSG_WARN(["Mozilla NSS and OpenSSL neither found, required for SSL support"]) + AC_MSG_WARN([Neither Mozilla NSS nor OpenSSL was found (required for SSL support)]) fi nut_with_ssl="no" else @@ -561,7 +1131,7 @@ if test "${nut_with_wrap}" != "no"; then fi if test "${nut_with_wrap}" = "yes" -a "${nut_have_libwrap}" != "yes"; then - AC_MSG_ERROR(["libwrap not found"]) + AC_MSG_ERROR([libwrap not found]) fi if test "${nut_with_wrap}" != "no"; then @@ -584,7 +1154,7 @@ if test "${nut_with_libltdl}" != "no"; then fi if test "${nut_with_libltdl}" = "yes" -a "${nut_have_libltdl}" != "yes"; then - AC_MSG_ERROR(["libltdl not found"]) + AC_MSG_ERROR([libltdl not found]) fi if test "${nut_with_libltdl}" != "no"; then @@ -594,7 +1164,7 @@ fi NUT_REPORT_FEATURE([enable libltdl (Libtool dlopen abstraction) support], [${nut_with_libltdl}], [], [WITH_LIBLTDL], [Define to enable libltdl (Libtool dlopen abstraction) support]) -dnl Explicitely report if we are building nut-scanner or not +dnl Explicitly report if we are building nut-scanner or not dnl since it requires libltdl NUT_REPORT([build nut-scanner], [${nut_with_libltdl}]) @@ -622,61 +1192,234 @@ NUT_REPORT_FEATURE([build CGI programs], [${nut_with_cgi}], [], dnl ---------------------------------------------------------------------- +dnl checks related to --enable-cppcheck +dnl Currently this is experimental; maybe change default to auto in the future +dnl At that point, see also defaults in ci_build.sh then (to avoid the workload +dnl unless desired). +NUT_ARG_ENABLE([cppcheck], [Run a cppcheck on the codebase among checks], [no]) +NUT_CHECK_CPPCHECK + +case "${nut_enable_cppcheck}" in + yes) if test "${nut_have_cppcheck}" = "no" ; then + AC_MSG_ERROR([Requested to --enable-cppcheck but did not find a good one]) + fi + WITH_CPPCHECK=yes + ;; + no) WITH_CPPCHECK=no ;; + auto) if test "${nut_have_cppcheck}" = "yes" ; then + WITH_CPPCHECK=no + else + WITH_CPPCHECK=no + fi + ;; +esac + +AM_CONDITIONAL(WITH_CPPCHECK, test "${WITH_CPPCHECK}" = "yes") + +dnl ---------------------------------------------------------------------- +dnl checks related to --enable-check-NIT + +AC_MSG_CHECKING(whether to run NIT among default make check target) +nut_enable_check_NIT="no" +AC_ARG_ENABLE([check-NIT], + AS_HELP_STRING([--enable-check-NIT], [Run check-NIT among default checks (no)]), +[ + case "${enableval}" in + no) + AC_MSG_RESULT(no) + ;; + *) + AC_MSG_RESULT(yes) + nut_enable_check_NIT="yes" + ;; + esac +], [ + AC_MSG_RESULT(no) +]) + +AM_CONDITIONAL(WITH_CHECK_NIT, test "${nut_enable_check_NIT}" = "yes") + +dnl ---------------------------------------------------------------------- dnl checks related to --with-doc dnl Always check for AsciiDoc prerequisites, since even if --with-doc dnl is set to 'no', we may still want to build some doc targets manually +dnl (so enable the Makefile recipes for those targets if tools are available) NUT_CHECK_ASCIIDOC +NUT_REPORT_FEATURE([build and install documentation], [${nut_with_doc}], [], + [WITH_ASCIIDOC], [Define to enable Asciidoc support]) + +DOC_INSTALL_DISTED_MANS=no + case "${nut_with_doc}" in - yes|all|auto) - nut_doc_build_list="html-single html-chunked pdf" + yes|all|all=yes) + nut_doc_build_list="man html-single html-chunked pdf" ;; - no) + auto|all=auto) + nut_doc_build_list="man=auto html-single=auto html-chunked=auto pdf=auto" + ;; + skip|all=skip) + nut_doc_build_list="man=skip html-single=skip html-chunked=skip pdf=skip" + ;; + no|all=no) nut_doc_build_list="" ;; +dnl If user passed --with-doc='' they they want nothing, right? + "") + nut_doc_build_list="" + AC_MSG_NOTICE([Got explicit empty list of document formats to build; nothing will be generated]) + ;; *) nut_doc_build_list="`echo ${nut_with_doc} | sed 's/,/ /g'`" + AC_MSG_NOTICE([Got explicit list of document formats to build or not: ${nut_doc_build_list}; formats not listed will be silently skipped]) ;; esac -for nut_doc_build_target in ${nut_doc_build_list}; do +if test -z "${abs_srcdir}" ; then + case "${srcdir}" in + /*) abs_srcdir="${srcdir}";; + "") AC_MSG_ERROR([Can not detect 'srcdir']) ;; + *) abs_srcdir="$(cd "${srcdir}" && pwd)" || AC_MSG_ERROR([Can not detect 'srcdir']) ;; + esac +fi +DOCTESTDIR="$(mktemp -d configure-test.docbuild.$$.XXXXXXX)" && \ +DOCTESTDIR="$(cd "$DOCTESTDIR" && pwd)" + +dnl Note: Do not cover ${nut_doc_build_list} in braces or quotes here, +dnl to ensure that it is processed as several space-separated tokens +for nut_doc_build_target in $nut_doc_build_list; do case "${nut_doc_build_target}" in - html-single) - AC_MSG_CHECKING([if asciidoc version can build ${nut_doc_build_target} (minimum required 8.6.3)]) - AX_COMPARE_VERSION([${ASCIIDOC_VERSION}], [ge], [8.6.3], [ - AC_MSG_RESULT(yes) - DOC_BUILD_LIST="${DOC_BUILD_LIST} ${nut_doc_build_target}" - ], [ - AC_MSG_RESULT(no) - DOC_NOBUILD_LIST="${DOC_NOBUILD_LIST} ${nut_doc_build_target}" - ]) + *=*=*) rm -rf "${DOCTESTDIR}" + AC_MSG_ERROR([Invalid documentation format option: ${nut_doc_build_target}]) ;; + *=*) + nut_doc_build_target_base="`echo "${nut_doc_build_target}" | sed 's,=.*$,,'`" + nut_doc_build_target_flag="`echo "${nut_doc_build_target}" | sed 's,^.*=,,'`" ;; - - html-chunked) - AC_MSG_CHECKING([if a2x version can build ${nut_doc_build_target} (minimum required 8.6.3)]) - AX_COMPARE_VERSION([${A2X_VERSION}], [ge], [8.6.3], [ - AC_MSG_RESULT(yes) - DOC_BUILD_LIST="${DOC_BUILD_LIST} ${nut_doc_build_target}" - ], [ - AC_MSG_RESULT(no) - DOC_NOBUILD_LIST="${DOC_NOBUILD_LIST} ${nut_doc_build_target}" - ]) - ;; - - pdf) - AC_MSG_CHECKING([if dblatex version can build ${nut_doc_build_target} (minimum required 0.2.5)]) - AX_COMPARE_VERSION([${DBLATEX_VERSION}], [ge], [0.2.5], [ - AC_MSG_RESULT(yes) - DOC_BUILD_LIST="${DOC_BUILD_LIST} ${nut_doc_build_target}" - ], [ - AC_MSG_RESULT(no) - DOC_NOBUILD_LIST="${DOC_NOBUILD_LIST} ${nut_doc_build_target}" - ]) + *) + nut_doc_build_target_base="${nut_doc_build_target}" + nut_doc_build_target_flag="yes" ;; esac + case "${nut_doc_build_target_flag}" in + yes|no|auto|skip) ;; + "") nut_doc_build_target_flag="yes" ;; + *) rm -rf "${DOCTESTDIR}" + AC_MSG_ERROR([Invalid documentation format option: ${nut_doc_build_target}]) ;; + esac + AC_MSG_CHECKING([desire and ability to build ${nut_doc_build_target_base} documentation]) + AC_MSG_RESULT([${nut_doc_build_target_flag}]) + + case "${nut_doc_build_target}" in + *=no|*=skip) + DOC_SKIPBUILD_LIST="${DOC_SKIPBUILD_LIST} ${nut_doc_build_target_base}" + ;; + +dnl Notes: Document options below assume either no flag value (which +dnl by default means "yes"), "yes" which is a requirement, or "auto" +dnl to detect if we can build the wanted documentation format and yet +dnl not fail if we have no tools to generate it (so add to SKIP list). + + html-single*) + AC_MSG_CHECKING([if asciidoc version can build ${nut_doc_build_target_base} (minimum required ${ASCIIDOC_MIN_VERSION})]) + can_build_doc_html_single=no + AX_COMPARE_VERSION([${ASCIIDOC_VERSION}], [ge], [${ASCIIDOC_MIN_VERSION}], [ + ( cd "$DOCTESTDIR" && ${A2X} --attribute=xhtml11_format --format=xhtml --xsl-file="${abs_srcdir}"/docs/xhtml.xsl --destination-dir=. "${abs_srcdir}"/docs/asciidoc.txt && test -s asciidoc.html ) && can_build_doc_html_single=yes + rm -f "$DOCTESTDIR"/asciidoc*.htm* + ], []) + if test "${can_build_doc_html_single}" = yes ; then + AC_MSG_RESULT(yes) + DOC_BUILD_LIST="${DOC_BUILD_LIST} ${nut_doc_build_target_base}" + else + AC_MSG_RESULT(no) + if test "${nut_doc_build_target_flag}" = "yes" ; then + DOC_CANNOTBUILD_LIST="${DOC_CANNOTBUILD_LIST} ${nut_doc_build_target_base}" + AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation which you requested]) + else + DOC_SKIPBUILD_LIST="${DOC_SKIPBUILD_LIST} ${nut_doc_build_target_base}" + fi + fi + ;; + + html-chunked*) + AC_MSG_CHECKING([if a2x version can build ${nut_doc_build_target_base} (minimum required ${ASCIIDOC_MIN_VERSION})]) + can_build_doc_html_chunked=no + AX_COMPARE_VERSION([${A2X_VERSION}], [ge], [${ASCIIDOC_MIN_VERSION}], [ + ( cd "$DOCTESTDIR" && ${A2X} --attribute=chunked_format --format=chunked --xsl-file="${abs_srcdir}"/docs/chunked.xsl --destination-dir=. "${abs_srcdir}"/docs/FAQ.txt && test -s FAQ.chunked/index.html ) && can_build_doc_html_chunked=yes + rm -rf "${DOCTESTDIR}"/FAQ*.chunked* + ], []) + if test "${can_build_doc_html_chunked}" = yes ; then + AC_MSG_RESULT(yes) + DOC_BUILD_LIST="${DOC_BUILD_LIST} ${nut_doc_build_target_base}" + else + AC_MSG_RESULT(no) + if test "${nut_doc_build_target_flag}" = "yes" ; then + DOC_CANNOTBUILD_LIST="${DOC_CANNOTBUILD_LIST} ${nut_doc_build_target_base}" + AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation which you requested]) + else + DOC_SKIPBUILD_LIST="${DOC_SKIPBUILD_LIST} ${nut_doc_build_target_base}" + fi + fi + ;; + + pdf*) + AC_MSG_CHECKING([if dblatex version can build ${nut_doc_build_target_base} (minimum required ${DBLATEX_MIN_VERSION})]) + can_build_doc_pdf=no + AX_COMPARE_VERSION([${DBLATEX_VERSION}], [ge], [${DBLATEX_MIN_VERSION}], [ + ( cd "$DOCTESTDIR" && ${A2X} --format=pdf --destination-dir=. "${abs_srcdir}"/docs/asciidoc.txt && test -s asciidoc.pdf ) && can_build_doc_pdf=yes + rm -f "${DOCTESTDIR}"/asciidoc.pdf + ], []) + if test "${can_build_doc_pdf}" = yes ; then + AC_MSG_RESULT(yes) + DOC_BUILD_LIST="${DOC_BUILD_LIST} ${nut_doc_build_target_base}" + else + AC_MSG_RESULT(no) + if test "${nut_doc_build_target_flag}" = "yes" ; then + DOC_CANNOTBUILD_LIST="${DOC_CANNOTBUILD_LIST} ${nut_doc_build_target_base}" + AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation which you requested]) + else + DOC_SKIPBUILD_LIST="${DOC_SKIPBUILD_LIST} ${nut_doc_build_target_base}" + fi + fi + ;; + + man*) + AC_MSG_CHECKING([if we can build ${nut_doc_build_target_base}]) + can_build_doc_man=no + if test "${nut_have_asciidoc}" = yes ; then + ( cd "$DOCTESTDIR" && ${A2X} --format manpage --destination-dir=. --xsltproc-opts="--nonet" "${abs_srcdir}"/docs/man/snmp-ups.txt && test -s snmp-ups.8 ) && can_build_doc_man=yes + rm -f "${DOCTESTDIR}"/snmp-ups.8 + fi + if test "${can_build_doc_man}" = yes ; then + AC_MSG_RESULT(yes) + DOC_BUILD_LIST="${DOC_BUILD_LIST} ${nut_doc_build_target_base}" + else + AC_MSG_RESULT(no) + if test "${nut_doc_build_target_flag}" = "yes" ; then + DOC_CANNOTBUILD_LIST="${DOC_CANNOTBUILD_LIST} ${nut_doc_build_target_base}" + AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation which you requested]) + else + DOC_SKIPBUILD_LIST="${DOC_SKIPBUILD_LIST} ${nut_doc_build_target_base}" + if test "${nut_doc_build_target_flag}" = "auto" ; then +dnl Test that groff files exist (building from distributed tarball, not git repo) + if test -s "${abs_srcdir}"/docs/man/snmp-ups.8 ; then + AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation, but can install pre-built distributed copies]) + DOC_INSTALL_DISTED_MANS="yes" + else + AC_MSG_WARN([Unable to build ${nut_doc_build_target_base} documentation, and unable to install pre-built distributed copies because they are absent]) + fi + fi # Other variants include "no", "skip"... + fi + fi + ;; + + *) rm -rf "${DOCTESTDIR}" + AC_MSG_ERROR([--with-doc option refers to unknown documentation format: $nut_doc_build_target]) ;; + + esac done +rm -rf "${DOCTESTDIR}" case "${nut_with_doc}" in auto) @@ -685,76 +1428,106 @@ auto) else nut_with_doc="no" fi - ;; + ;; no) ;; *) - if test -z "${DOC_NOBUILD_LIST}"; then + if test -n "${DOC_CANNOTBUILD_LIST}"; then + AC_MSG_ERROR([Unable to build${DOC_CANNOTBUILD_LIST} documentation (check for 'no' results above)]) + fi + + if test -n "${DOC_SKIPBUILD_LIST}"; then + AC_MSG_NOTICE([Skipping build of${DOC_SKIPBUILD_LIST} documentation (check for 'skip' results above)]) + fi + + if test -n "${DOC_BUILD_LIST}"; then nut_with_doc="yes" else - AC_MSG_ERROR(["Unable to build ${DOC_NOBUILD_LIST} documentation (check for 'no' results above)"]) + nut_with_doc="no" fi ;; esac -AC_MSG_CHECKING([if asciidoc version can build manpages (minimum required 8.6.3)]) -AX_COMPARE_VERSION([${ASCIIDOC_VERSION}], [ge], [8.6.3], [ - AC_MSG_RESULT(yes) - nut_have_asciidoc="yes" -], [ - AC_MSG_RESULT(no) - nut_have_asciidoc="no" -]) +NUT_REPORT_FEATURE([build specific documentation format(s)], [${nut_with_doc}], [${DOC_BUILD_LIST}], + [WITH_DOCS], [Define to enable overall documentation generation]) -AC_MSG_CHECKING([if a2x version can build manpages (minimum required 8.6.3)]) -AX_COMPARE_VERSION([${A2X_VERSION}], [ge], [8.6.3], [ - AC_MSG_RESULT(yes) -], [ - AC_MSG_RESULT(no) - nut_have_asciidoc="no" -]) - -dnl TODO: test for docbook-xsl files (maybe build a test man page?) -dnl https://github.com/networkupstools/nut/issues/162 -AC_MSG_CHECKING([if xsltproc is present (mandatory for man page regeneration)]) -if test -n "${XSLTPROC}"; then - AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) - nut_have_asciidoc="no" +# To cater for less portable make's, precalculate the target list +# for "make check" in "docs/" here... +DOC_CHECK_LIST="" +if test "${nut_with_doc}" = yes ; then + for V in $DOC_BUILD_LIST ; do + DOC_CHECK_LIST="$DOC_CHECK_LIST check-$V" + done fi -AC_MSG_CHECKING([if xmllint is present (mandatory for man page regeneration)]) -if test -n "${XMLLINT}"; then - AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) - nut_have_asciidoc="no" +WITH_MANS=no +SKIP_MANS=no +if echo "${DOC_BUILD_LIST}" | grep -w "man" >/dev/null || test "${DOC_INSTALL_DISTED_MANS}" = "yes" ; then + WITH_MANS=yes fi - -AC_MSG_CHECKING([if source-highlight is present (preferable for documentation generation)]) -if test -n "${SOURCE_HIGHLIGHT}"; then - AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) -fi - -NUT_REPORT_FEATURE([build and install documentation], [${nut_with_doc}], [], - [WITH_ASCIIDOC], [Define to enable Asciidoc support]) - -dnl Notes: we also keep HAVE_ASCIIDOC for implicit targets, such as manpage -dnl building -AM_CONDITIONAL([HAVE_ASCIIDOC], [test "${nut_have_asciidoc}" = "yes"]) - -if test "${nut_with_doc}" = "yes"; then - NUT_REPORT([only build specific documentation format], [${DOC_BUILD_LIST}]) +if echo "${DOC_SKIPBUILD_LIST}" | grep -w "man" >/dev/null ; then + SKIP_MANS=yes fi +dnl Generally WITH_MANS=no is intentionally fatal for "make distcheck" +dnl But some larger distcheck suites check mans once and then focus on +dnl other aspects of the project, so they can explicitly skip docs (or +dnl just mans) instead. Note that for WITH_MANS=yes the SKIP_MANS value +dnl is effectively ignored by docs/man/Makefile.am at this time. +AM_CONDITIONAL(WITH_MANS, test "${WITH_MANS}" = "yes") +AM_CONDITIONAL(SKIP_MANS, test "${SKIP_MANS}" = "yes") +AM_CONDITIONAL(DOC_INSTALL_DISTED_MANS, test "${DOC_INSTALL_DISTED_MANS}" = "yes") dnl ---------------------------------------------------------------------- dnl checks related to --with-dev dnl We only init libtool there to allow AC_DISABLE_STATIC -AC_PROG_LIBTOOL +if ( test "${GCC}" = "yes" ) +then + dnl # Avoid new compilers' warnings/errors about libtool distro flaws in this test like: + dnl # error: ISO C forbids conversion of function pointer to object pointer type [-Werror=pedantic] + dnl # {"nm_test_func", (void *) &nm_test_func}, + dnl # or ones about LTO (-flto -fno-common) as discussed and suggested + dnl # in https://www.mail-archive.com/libtool@gnu.org/msg14037.html - + dnl # all leading to undefined "global_symbol_pipe" in the generated + dnl # libtool script, and resulting in errors like `... | | ...` below : + dnl # libtool: link: /usr/bin/nm -B .libs/upsclient.o \ + dnl # ../common/.libs/libcommonclient.a | | /usr/bin/sed 's/.* //' \ + dnl # | sort | uniq > .libs/libupsclient.exp + dnl # ../libtool: syntax error: `|' unexpected + + CFLAGS_SAVED_NOPEDANTIC="$CFLAGS" + AS_CASE(["${CFLAGS}"],[*"-pedantic"*],[CFLAGS="${CFLAGS} -Wno-pedantic"]) + AS_CASE(["${CFLAGS}"],[*"-Werror"*],[CFLAGS="${CFLAGS} -Wno-error"]) + AS_CASE(["${CFLAGS}"],[*"-flto"*],[CFLAGS="${CFLAGS} -ffat-lto-objects"]) +fi + +dnl See https://www.gnu.org/software/libtool/manual/html_node/LT_005fINIT.html +dnl #OBSOLETED:# LT_INIT and AC_PROG_LIBTOOL + +dnl # Hack around the libtool script: as of version 58 (current in 2021), +dnl # they use code like below to detect library paths: +dnl # if test yes = "$GCC"; then ... lt_search_path_spec=`$CC -print-search-dirs | ... +dnl # which explodes when non-default architecture is used for the build, +dnl # where e.g. "CC=gcc" and "CFLAGS=-m32" on a 64-bit capable system. +dnl # And similarly for compilation-checks to link third-party libraries. +SAVED_GCC="$GCC" +SAVED_CC="$CC" +if ( test "${GCC}" = "yes" ) +then + case "$CFLAGS$LDFLAGS" in + *-m32*) CC="$CC -m32" ;; + *-m64*) CC="$CC -m64" ;; + esac +fi +LT_INIT +AC_SUBST([LIBTOOL_DEPS]) +GCC="$SAVED_GCC" +CC="$SAVED_CC" + +if ( test "${GCC}" = "yes" ) +then + CFLAGS="$CFLAGS_SAVED_NOPEDANTIC" +fi dnl ${nut_with_dev}: any value except "yes" or "no" is treated as "auto". if test "${nut_with_dev}" != "no"; then @@ -903,7 +1676,7 @@ AC_MSG_RESULT(${PORT}) AC_MSG_CHECKING(user to run as) AC_ARG_WITH(user, - AS_HELP_STRING([--with-user=username], [user for programs started as root (nobody)]), + AS_HELP_STRING([--with-user=username], [user for programs started as root (${RUN_AS_USER})]), [ case "${withval}" in yes|no) @@ -922,7 +1695,7 @@ AC_MSG_RESULT(${RUN_AS_USER}) AC_MSG_CHECKING(group membership of user to run as) AC_ARG_WITH(group, - AS_HELP_STRING([--with-group=groupname], [group membership of user for programs started as root (nogroup)]), + AS_HELP_STRING([--with-group=groupname], [group membership of user for programs started as root (${RUN_AS_GROUP})]), [ case "${withval}" in yes|no) @@ -941,9 +1714,9 @@ AC_MSG_RESULT(${RUN_AS_GROUP}) dnl check that --with-user is given if --with-group is given. if test "${nut_user_given}" = "yes" -a "${nut_group_given}" = "no"; then - AC_MSG_ERROR(["If you specify --with-user, you also must specify --with-group"]) + AC_MSG_ERROR([If you specify --with-user, you also must specify --with-group]) elif test "${nut_user_given}" = "no" -a "${nut_group_given}" = "yes"; then - AC_MSG_ERROR(["If you specify --with-group, you also must specify --with-user"]) + AC_MSG_ERROR([If you specify --with-group, you also must specify --with-user]) fi AC_MSG_CHECKING(facility for syslog) @@ -964,53 +1737,30 @@ AC_ARG_WITH(logfacility, AC_DEFINE_UNQUOTED(LOG_FACILITY, ${LOGFACILITY}, [Desired syslog facility - see syslog(3)]) AC_MSG_RESULT(${LOGFACILITY}) -dnl Autoconf versions before 2.62 do not allow consecutive quadrigraphs, -dnl so the help string depends on the version used -AC_MSG_CHECKING(which drivers to build) -AC_ARG_WITH(drivers, - AS_HELP_STRING([m4_version_prereq(2.62, - [@<:@--with-drivers=driver@<:@,driver@:>@@:>@], - [[[[--with-drivers=driver@<:@,driver@:>@]]]])], - [Only build specific drivers (all)]), -[ - case "${withval}" in - yes|no) - AC_MSG_ERROR(invalid option --with(out)-drivers - see docs/configure.txt) - ;; - *) - DRIVER_BUILD_LIST=`echo ${withval} | sed "s/,/ /g"` - AC_MSG_RESULT(${DRIVER_BUILD_LIST}) - ;; - esac -], [ - DRIVER_BUILD_LIST="all" - AC_MSG_RESULT(all available) -]) -AM_CONDITIONAL(SOME_DRIVERS, test "${DRIVER_BUILD_LIST}" != "all") - -if test "${DRIVER_BUILD_LIST}" != "all"; then - NUT_REPORT([only build specific drivers], [${DRIVER_BUILD_LIST}]) -fi - AC_MSG_CHECKING(which driver man pages to install) -if test "${DRIVER_BUILD_LIST}" = "all"; then - DRIVER_MAN_LIST=all - AC_MSG_RESULT(all available) +if test "${WITH_MANS}" = "yes"; then + if test "${DRIVER_BUILD_LIST}" = "all"; then + DRIVER_MAN_LIST=all + AC_MSG_RESULT(all available) + else + DRIVER_MAN_LIST="" + for i in ${DRIVER_BUILD_LIST}; do + if test -f ${srcdir}/docs/man/$i.8; then + DRIVER_MAN_LIST="${DRIVER_MAN_LIST} $i.8" + fi + done + AC_MSG_RESULT(${DRIVER_MAN_LIST}) + fi else DRIVER_MAN_LIST="" - for i in ${DRIVER_BUILD_LIST}; do - if test -f ${srcdir}/docs/man/$i.8; then - DRIVER_MAN_LIST="${DRIVER_MAN_LIST} $i.8" - fi - done - AC_MSG_RESULT(${DRIVER_MAN_LIST}) + AC_MSG_RESULT([none (manpages disabled)]) fi AC_MSG_CHECKING(whether to strip debug symbols) AC_ARG_ENABLE(strip, AS_HELP_STRING([--enable-strip], [Strip debugging symbols from binaries (no)]), [ - case "${withval}" in + case "${enableval}" in no) AC_MSG_RESULT(no) ;; @@ -1045,14 +1795,106 @@ else fi AM_CONDITIONAL(WITH_PKG_CONFIG, test -n "${pkgconfigdir}") -PKG_PROG_PKG_CONFIG -systemdsystemunitdir=`$PKG_CONFIG --variable=systemdsystemunitdir systemd` -AC_MSG_CHECKING(whether to install systemd files) -AC_ARG_WITH([systemdsystemunitdir], - AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files (auto)]), +AC_MSG_CHECKING(whether to install Solaris SMF files) +solarissmf="auto" +AC_ARG_WITH([solaris-smf], + AS_HELP_STRING([--with-solaris-smf=(yes|auto|no)], [Enable installation of NUT scripts and manifests for Solaris Service Management Framework (auto)]), [ case "${withval}" in - yes|auto) + auto|"") + solarissmf="auto" + ;; + yes|no) + solarissmf="${withval}" + ;; + *) + AC_MSG_ERROR([Unexpected argument for --with-solaris-smf=${withval}]) + ;; + esac +], []) + +if test x"$solarissmf" = xauto ; then + if test -x /usr/sbin/svcadm && test -x /usr/sbin/svccfg && test -x /usr/bin/svcs ; then + solarissmf="yes" + else + solarissmf="no" + fi +fi +AC_MSG_RESULT([${solarissmf}]) +AM_CONDITIONAL(WITH_SOLARIS_SMF, test x"$solarissmf" = x"yes") + +AC_MSG_CHECKING(whether to make Solaris SVR4 packages) +solarispkg_svr4="auto" +AC_ARG_WITH([solaris-pkg-svr4], + AS_HELP_STRING([--with-solaris-pkg-svr4=(yes|auto|no)], [Enable construction of Solaris SVR4 packages (auto)]), +[ + case "${withval}" in + auto|"") + solarispkg_svr4="auto" + ;; + yes|no) + solarispkg_svr4="${withval}" + ;; + *) + AC_MSG_ERROR([Unexpected argument for --with-solaris-pkg-svr4=${withval}]) + ;; + esac +], []) + +if test x"$solarispkg_svr4" = xauto ; then + if test -x /usr/bin/pkgtrans && test -x /usr/bin/pkgmk && test -x /usr/bin/pkgproto ; then + solarispkg_svr4="yes" + else + solarispkg_svr4="no" + fi +fi +AC_MSG_RESULT([${solarispkg_svr4}]) +AM_CONDITIONAL(WITH_SOLARIS_PKG_SVR4, test x"$solarispkg_svr4" = x"yes") + +AC_MSG_CHECKING(whether to make Solaris IPS packages) +solarispkg_ips="auto" +AC_ARG_WITH([solaris-pkg-ips], + AS_HELP_STRING([--with-solaris-pkg-ips=(yes|auto|no)], [Enable construction of Solaris IPS packages (auto)]), +[ + case "${withval}" in + auto|"") + solarispkg_ips="auto" + ;; + yes|no) + solarispkg_ips="${withval}" + ;; + *) + AC_MSG_ERROR([Unexpected argument for --with-solaris-pkg-ips=${withval}]) + ;; + esac +], []) + +if test x"$solarispkg_ips" = xauto ; then + if test -x /usr/bin/pkg && test -x /usr/bin/pkgmogrify && test -x /usr/bin/pkgdepend ; then + solarispkg_ips="yes" + else + solarispkg_ips="no" + fi +fi +AC_MSG_RESULT([${solarispkg_ips}]) +AM_CONDITIONAL(WITH_SOLARIS_PKG_IPS, test x"$solarispkg_ips" = x"yes") + +dnl Note: Currently there is no reliable automatic detection - +dnl users have to ask they want systemd units installed, or +dnl risk auto-detection like seen below. +AC_MSG_CHECKING(whether to install systemd unit files) +AC_ARG_WITH([systemdsystemunitdir], + AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files (auto)]), + [systemdsystemunitdir="${withval}"], + [systemdsystemunitdir="auto"]) +case "${systemdsystemunitdir}" in + yes|auto|"") + AS_IF([test x"$have_PKG_CONFIG" = xyes], + [systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir systemd 2>/dev/null`" && test -n "$systemdsystemunitdir" || systemdsystemunitdir="`$PKG_CONFIG --variable=systemdsystemunitdir libsystemd 2>/dev/null`"], + [AS_IF([test "${withval}" = yes], + [AC_MSG_ERROR([--with-systemdsystemunitdir=${withval} was requested, but PKG_CONFIG could not be queried for the system settings])]) + systemdsystemunitdir="" + ]) ;; no) systemdsystemunitdir="" @@ -1060,18 +1902,273 @@ AC_ARG_WITH([systemdsystemunitdir], *) systemdsystemunitdir="${withval}" ;; - esac -], []) -dnl Override installation directory, with the local installation -dnl prefix. This is needed for 'distcheck*' targets, otherwise -dnl files will try to get intalled to the actual system directories +esac +if test "${systemdsystemunitdir}" = "auto" ; then systemdsystemunitdir=""; fi if test -n "${systemdsystemunitdir}"; then - systemdsystemshutdowndir="${libdir}/systemd/system-shutdown" AC_MSG_RESULT(using ${systemdsystemunitdir}) else AC_MSG_RESULT(no) fi AM_CONDITIONAL(HAVE_SYSTEMD, test "$systemdsystemunitdir" != "") +dnl This option is only provided so that make distcheck can override it, +dnl otherwise we ask pkg-config whenever --with-systemdsystemunitdir is +dnl given + +AC_MSG_CHECKING(whether to install systemd shutdown files) +AC_ARG_WITH([systemdshutdowndir], + AS_HELP_STRING([--with-systemdshutdowndir=DIR], [Directory for systemd shutdown scripts (auto)]), + [systemdshutdowndir="${withval}"], + [systemdshutdowndir="auto"]) +dnl Note: this option is enabled only if systemdsystemunitdir is not trivial +if test -n "${systemdsystemunitdir}"; then + case "${systemdshutdowndir}" in + yes|auto|"") + AS_IF([test x"$have_PKG_CONFIG" = xyes], + [systemdshutdowndir="`$PKG_CONFIG --variable=systemdshutdowndir systemd 2>/dev/null`" && test -n "$systemdshutdowndir" || systemdshutdowndir="`$PKG_CONFIG --variable=systemdshutdowndir libsystemd 2>/dev/null`"], + [AS_IF([test "${systemdshutdowndir}" = yes], + [AC_MSG_ERROR([--with-systemdshutdowndir=${systemdshutdowndir} was requested, but PKG_CONFIG could not be queried for the system settings])]) + systemdshutdowndir="" + ]) + ;; + no) + systemdshutdowndir="" + ;; + *) + systemdshutdowndir="${withval}" + ;; + esac +fi +if test "${systemdshutdowndir}" = "auto" ; then systemdshutdowndir=""; fi +if test -n "${systemdshutdowndir}"; then + AC_MSG_RESULT(using ${systemdshutdowndir}) +else + AC_MSG_RESULT(no) +fi + +dnl Note: if (systemd-)tmpfiles tech is present, it can be useful even for +dnl daemons starting not as systemd units, to pre-create /var/run/nut etc. +AC_MSG_CHECKING([whether to install systemd tmpfiles files]) +AC_ARG_WITH([systemdtmpfilesdir], + AS_HELP_STRING([--with-systemdtmpfilesdir=DIR], [Directory for systemd tmpfiles scripts (auto)]), + [systemdtmpfilesdir="${withval}"], + [systemdtmpfilesdir="auto"]) +case "${systemdtmpfilesdir}" in + yes|auto|"") + AS_IF([test x"$have_PKG_CONFIG" = xyes], + [systemdtmpfilesdir="`$PKG_CONFIG --variable=tmpfilesdir systemd 2>/dev/null`" && test -n "$systemdtmpfilesdir" || systemdtmpfilesdir="`$PKG_CONFIG --variable=tmpfilesdir libsystemd 2>/dev/null`"], + [AS_IF([test "${systemdtmpfilesdir}" = yes], + [AC_MSG_ERROR([--with-systemdtmpfilesdir=${systemdtmpfilesdir} was requested, but PKG_CONFIG could not be queried for the system settings])]) + systemdtmpfilesdir="" + ]) + ;; + no) + systemdtmpfilesdir="" + ;; + *) + systemdtmpfilesdir="${withval}" + ;; +esac +if test "${systemdtmpfilesdir}" = "auto" ; then systemdtmpfilesdir=""; fi +if test -n "${systemdtmpfilesdir}"; then + AC_MSG_RESULT(using ${systemdtmpfilesdir}) +else + AC_MSG_RESULT(no) +fi + +dnl +dnl Tests for CppUnit availability and usability (will be built if we can, +dnl and if valgrind is enabled for this configuration - reported below). +dnl Using CppUnit implies C++ support! +dnl Theoretically, libcppunit-dev will pull up to g++, through libstdc++... +dnl AM_PATH_CPPUNIT(1.9.6) + +dnl # Tests with gcc-4.8 require this C++11 option to be provided explicitly +dnl # gcc-4.6 does not support this yet; newer gcc's should be ok by default. +dnl # Could use `AX_CXX_COMPILE_STDCXX_11([noext], [optional])` if it were +dnl # available everywhere. Or AX_CHECK_COMPILE_FLAG if it was ubiquitous: +dnl ###AX_CHECK_COMPILE_FLAG([-std=c++11], +dnl ### [CXXFLAGS="$CXXFLAGS -std=c++11" +dnl ### have_cxx11=yes], +dnl ### [have_cxx11=no]) + +AC_MSG_CHECKING(for C++11 support in current compiler) +have_cxx11=unknown +my_CXXFLAGS="$CXXFLAGS" +AC_LANG_PUSH([C++]) + +CPLUSPLUS_DECL=' +#include +#if __cplusplus < 201103L + #error This library needs at least a C++11 compliant compiler +#endif +' +CPLUSPLUS_MAIN='printf("%ld\n", __cplusplus);' + +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[${CPLUSPLUS_DECL}]], [[${CPLUSPLUS_MAIN}]])], + [AC_MSG_RESULT([yes, out of the box]) + have_cxx11=yes], + [AS_CASE(["${CXXFLAGS}"], + [*"-std="*], [ + AC_MSG_RESULT([no, not with the standard already set in CXXFLAGS='${CXXFLAGS}']) + have_cxx11=no, + ],[ + CXXFLAGS="$CXXFLAGS -std=c++11" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[${CPLUSPLUS_DECL}]], [[${CPLUSPLUS_MAIN}]])], + [AC_MSG_RESULT([yes, GCC-style (as C++11)]) + have_cxx11=yes], + [CXXFLAGS="$CXXFLAGS -std=c++0x" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[${CPLUSPLUS_DECL}]], [[${CPLUSPLUS_MAIN}]])], + [AC_MSG_RESULT([yes, GCC-style (as C++0X)]) + have_cxx11=yes], + [AC_MSG_RESULT([no]) + CXXFLAGS="$my_CXXFLAGS" + have_cxx11=no])])])]) +AM_CONDITIONAL(HAVE_CXX11, test "${have_cxx11}" = "yes") +AC_LANG_POP([C++]) +unset CPLUSPLUS_MAIN +unset CPLUSPLUS_DECL + +AC_MSG_CHECKING(for have_cppunit) +have_cppunit="no" +CPPUNIT_NUT_CXXFLAGS="" +AS_IF([test x"$have_PKG_CONFIG" = xyes], + [AS_IF([test x"${have_cxx11}" = xyes], + [ifdef([PKG_CHECK_MODULES], [PKG_CHECK_MODULES(CPPUNIT, cppunit, have_cppunit=yes, have_cppunit=no)], [have_cppunit=no]) + AS_IF([test "${have_cppunit}" != "yes"], + [AC_MSG_WARN([libcppunit not found - those C++ tests will not be built.]) + have_cppunit=no], + [AS_IF([test -n "$CXX"], + [AS_IF([$CXX --version 2>&1 | grep 'Free Software Foundation' > /dev/null], + [CPPUNIT_NUT_CXXFLAGS="-g -O0"])]) + ]) + ]) + ], [AC_MSG_WARN([pkg-config not found, can not look properly for libcppunit - those C++ tests will not be built.]) + have_cppunit=no] +) +AC_MSG_RESULT(${have_cppunit}) + +dnl On some systems, CppUnit inexplicably fails with trivial assertions +dnl so it should not be enabled with those environments, corrupting the +dnl test results with misleading errors. +dnl Tracked in https://github.com/networkupstools/nut/issues/1126 +dnl One such situation was e.g. "clang++ + arm64(QEMU) + -m64" while +dnl this was not seen with other compilers or bitness on same system. +AS_IF([test "${have_cppunit}" = "yes"], + [AC_MSG_CHECKING([if current toolkit can build and run cppunit tests (e.g. no ABI issues, related segfaults, etc.)]) + dnl Code below is largely a stripped variant of our tests/example.cpp and cpputest.cpp + CPLUSPLUS_DECL=' +#include +#include +#include +#include +#include + +class ExampleTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE( ExampleTest ); + CPPUNIT_TEST( testOne ); + CPPUNIT_TEST_SUITE_END(); +public: + void setUp() {}; + void tearDown() {}; + void testOne(); +}; +CPPUNIT_TEST_SUITE_REGISTRATION( ExampleTest ); +void ExampleTest::testOne() +{ + int i = 1; + float f = 1.0; + int cast = static_cast(f); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Casted float is not the expected int (assert_eq)", i, cast ); + CPPUNIT_ASSERT_MESSAGE("Casted float is not the expected int (assert)", (i == cast) ); +} +' + + CPLUSPLUS_MAIN=' +CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); +CppUnit::TextUi::TestRunner runner; +runner.addTest( suite ); +runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), std::cerr ) ); +bool res = runner.run(); +return res ? 0 : 1; +' + + my_CXXFLAGS="$CXXFLAGS" + my_LDFLAGS="$LDFLAGS" + my_LIBS="$LIBS" + CXXFLAGS="$myCXXFLAGS $pkg_cv_CPPUNIT_CFLAGS $pkg_cv_CPPUNIT_CXXFLAGS" + LDFLAGS="$my_LDFLAGS $pkg_cv_CPPUNIT_LDFLAGS" + LIBS="$my_LIBS $pkg_cv_CPPUNIT_LIBS" + AC_LANG_PUSH([C++]) + AX_RUN_OR_LINK_IFELSE([AC_LANG_PROGRAM([[${CPLUSPLUS_DECL}]], [[${CPLUSPLUS_MAIN}]])], + [have_cppunit=yes], [have_cppunit=no]) + CXXFLAGS="$my_CXXFLAGS" + LDFLAGS="$my_LDFLAGS" + LIBS="$my_LIBS" + AC_LANG_POP([C++]) + unset CPLUSPLUS_MAIN + unset CPLUSPLUS_DECL + ]) +AC_MSG_RESULT(${have_cppunit}) + +dnl # By default keep the originally detected have_cppunit value +AC_MSG_CHECKING(for impact from --enable-cppunit option - should we build cppunit tests?) +AC_ARG_ENABLE(cppunit, + [AS_HELP_STRING([--enable-cppunit], [enable CPPUNIT tests for C++ bindings])], + [AS_CASE(["${enableval}"], + ["yes"], [AS_IF([test x"${have_cppunit}" = xyes], [], [AC_MSG_ERROR([--with-cppunit=yes can not be satisfied])])], + ["no"], [have_cppunit=no] + )]) +AC_MSG_RESULT(${have_cppunit}) + +AM_CONDITIONAL(HAVE_CPPUNIT, test "${have_cppunit}" = "yes") +AC_DEFINE_UNQUOTED(CPPUNIT_NUT_CXXFLAGS, $CPPUNIT_NUT_CXXFLAGS, [Compiler flags for cppunit tests]) + +AC_MSG_CHECKING(whether to install Augeas configuration-management lenses) +AC_ARG_WITH(augeas-lenses-dir, + AS_HELP_STRING([--with-augeas-lenses-dir=PATH], [where to install Augeas configuration-management lenses (/usr/share/augeas/lenses{/dist,/})]), +[ + case "${withval}" in + yes) + if test -z "${auglensdir}"; then + AC_MSG_RESULT(no) + AC_MSG_ERROR([augeas lenses directory requested but not found in default location]) + fi + if ! test -s scripts/augeas/nutupsconf.aug.in ; then + AC_MSG_RESULT(no) + AC_MSG_ERROR([augeas lenses directory requested but a non-trivial scripts/augeas/nutupsconf.aug.in was not provided by autogen.sh or dist archive]) + fi + ;; + auto) + if ! test -s scripts/augeas/nutupsconf.aug.in ; then + AC_MSG_WARN([augeas lenses directory skipped because a non-trivial scripts/augeas/nutupsconf.aug.in was not provided by autogen.sh or dist archive]) + auglensdir="" + fi + ;; + no) + auglensdir="" + ;; + *) + auglensdir="${withval}" + ;; + esac +], []) +if test -n "${auglensdir}"; then + AC_MSG_RESULT(using ${auglensdir}) +else + AC_MSG_RESULT(no) +fi +AM_CONDITIONAL(WITH_AUGLENS, test -n "${auglensdir}") + +AC_PATH_PROGS([AUGPARSE], [augparse], [none]) +AM_CONDITIONAL([HAVE_AUGPARSE], [test "x${AUGPARSE}" != "xnone"]) +AC_MSG_CHECKING([whether to enable Augeas configuration-management lenses tests]) +if test "x${AUGPARSE}" != xnone ; then + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) +fi + AC_MSG_CHECKING(whether to install hotplug rules) AC_ARG_WITH(hotplug-dir, @@ -1081,7 +2178,7 @@ AC_ARG_WITH(hotplug-dir, yes) if test -z "${hotplugdir}"; then AC_MSG_RESULT(no) - AC_MSG_ERROR(["hotplug directory requested but not found"]) + AC_MSG_ERROR([hotplug directory requested but not found]) fi ;; auto) @@ -1109,10 +2206,18 @@ AC_ARG_WITH(udev-dir, yes) if test -z "${udevdir}"; then AC_MSG_RESULT(no) - AC_MSG_ERROR(["udev directory requested but not found"]) + AC_MSG_ERROR([udev directory requested but not found]) + fi + if test "${nut_with_usb}" = yes && ! test -s scripts/udev/nut-usbups.rules.in ; then + AC_MSG_RESULT(no) + AC_MSG_ERROR([udev directory and USB driver support requested but a non-trivial scripts/udev/nut-usbups.rules.in was not provided by autogen.sh or dist archive]) fi ;; auto) + if test "${nut_with_usb}" = yes && ! test -s scripts/udev/nut-usbups.rules.in ; then + AC_MSG_WARN([udev directory skipped because a non-trivial scripts/udev/nut-usbups.rules.in was not provided by autogen.sh or dist archive]) + udevdir="" + fi ;; no) udevdir="" @@ -1139,10 +2244,18 @@ AC_ARG_WITH(devd-dir, yes) if test -z "${devddir}"; then AC_MSG_RESULT(no) - AC_MSG_ERROR(["devd directory requested but not found"]) + AC_MSG_ERROR([devd directory requested but not found]) + fi + if test "${nut_with_usb}" = yes && ! test -s scripts/devd/nut-usbups.rules.in -a -s scripts/devd/nut-usb.conf.in ; then + AC_MSG_RESULT(no) + AC_MSG_ERROR([devd directory and USB driver support requested but non-trivial scripts/devd/nut-usbups.rules.in and scripts/devd/nut-usb.conf.in were not provided by autogen.sh or dist archive]) fi ;; auto) + if test "${nut_with_usb}" = yes && ! test -s scripts/devd/nut-usbups.rules.in -a -s scripts/devd/nut-usb.conf.in ; then + AC_MSG_WARN([devd directory skipped because non-trivial scripts/devd/nut-usbups.rules.in and scripts/devd/nut-usb.conf.in were not provided by autogen.sh or dist archive]) + devddir="" + fi ;; no) devddir="" @@ -1161,21 +2274,97 @@ AM_CONDITIONAL(WITH_DEVD, test -n "${devddir}") dnl -AC_PATH_PROGS([ASCIIDOC], [asciidoc], [none]) -AM_CONDITIONAL([MANUALUPDATE], [test "x$ASCIIDOC" != "xnone"]) -AC_PATH_PROGS([A2X], [a2x], [none]) - -dnl check for spell checking deps -AC_PATH_PROGS([ASPELL], [aspell], [none]) -AM_CONDITIONAL([HAVE_ASPELL], [test "x$ASPELL" != "xnone"]) - dnl AIX system AM_CONDITIONAL([SYSTEM_AIX], [test "xAIX" = "x`uname -s 2>/dev/null`"]) dnl processor type -AC_DEFINE_UNQUOTED(CPU_TYPE, $target_cpu, [Define processor type]) +AC_DEFINE_UNQUOTED(CPU_TYPE, ["$target_cpu"], [Define processor type]) -dnl expand ${sysconfdir} and write it out +dnl Can use valgrind for memory-leak testing, if present +AC_PATH_PROGS([VALGRIND], [valgrind], [none]) +dnl Even if the tool is installed, it may be not usable on build platform. +dnl QEMU may further complicate things, providing CPUs that formally match +dnl a supported family but crash in practice, or hopefully rejected early: +dnl valgrind: fatal error: unsupported CPU. +dnl Supported CPUs are: +dnl * x86 (practically any; Pentium-I or above), AMD Athlon or above) +dnl * AMD Athlon64/Opteron +dnl * ARM (armv7) +dnl * MIPS (mips32 and above; mips64 and above) +dnl * PowerPC (most; ppc405 and above) +dnl * System z (64bit only - s390x; z990 and above) +dnl Even if the tool does basically start, on some QEMU systems it crashes +dnl later (e.g. claims Signal 11 in tear-down after a successful test), so +dnl we support an explicit --without-valgrind (aka --with-valgrind=no) too. +AS_IF([test -n "${VALGRIND}"], [ + AC_MSG_CHECKING([whether valgrind is usable on current platform]) + AS_IF([( ${VALGRIND} --help >/dev/null 2>/dev/null )], + [AS_IF([( ${VALGRIND} /bin/sh -c true >/dev/null 2>/dev/null )], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + VALGRIND="none" + ])], + [AC_MSG_RESULT([no]) + VALGRIND="none" + ]) +]) +AC_MSG_CHECKING(whether to use valgrind for memory-leak testing) +AC_ARG_WITH(valgrind, + AS_HELP_STRING([--with-valgrind=PATH], [whether to use valgrind for memory-leak testing]), +[ + dnl ### echo "Caller said: '${withval}'... Discovered tool: '${VALGRIND}'... " + case "${withval}" in + yes) + if test "x$VALGRIND" = "xnone"; then + AC_MSG_RESULT(no) + AC_MSG_ERROR([valgrind requested but not found]) + fi + with_valgrind="yes" + ;; + auto) + with_valgrind="auto" + ;; + no) + with_valgrind="no" + ;; + *) + AC_PATH_PROGS([VALGRIND], ["${withval}"], [none]) + if test "x$VALGRIND" = "xnone"; then + AC_MSG_RESULT(no) + AC_MSG_ERROR([valgrind requested but not found]) + fi + with_valgrind="yes" + ;; + esac +], []) + +if test "x${with_valgrind}" = xauto; then + if test "x$VALGRIND" = "xnone"; then + with_valgrind="no" + else + with_valgrind="yes" + fi +fi + +if test "x${with_valgrind}" = xyes; then + AC_MSG_RESULT(using ${VALGRIND}) + AC_MSG_NOTICE([Do not forget to build with debug (e.g. pass '-g' in CFLAGS for GCC) for best results with valgrind tests]) +else + AC_MSG_RESULT(no) +fi +AM_CONDITIONAL([HAVE_VALGRIND], [test "x${VALGRIND}" != "xnone"]) +AM_CONDITIONAL([WITH_VALGRIND], [test "x${with_valgrind}" = "xyes"]) + +AC_MSG_CHECKING([whether to build cppunit tests using valgrind support]) +if test "x${with_valgrind}" = xyes && test "x${have_cppunit}" = xyes ; then + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) +fi + +dnl expand ${sysconfdir} and write it out - note that most packages +dnl override it to be /etc/nut, /etc/ups or similar, while the +dnl autotools default would be $prefix/etc conftemp="${sysconfdir}" eval conftemp=\"${conftemp}\" eval conftemp=\"${conftemp}\" @@ -1187,6 +2376,7 @@ conftemp="${datadir}" eval conftemp=\"${conftemp}\" eval conftemp=\"${conftemp}\" DATADIR=${conftemp} +NUT_DATADIR=${conftemp} AC_DEFINE_UNQUOTED(DATADIR, "${conftemp}", [Default path for data files]) dnl same for bindir @@ -1210,6 +2400,64 @@ eval conftemp=\"${conftemp}\" LIBDIR=${conftemp} AC_DEFINE_UNQUOTED(LIBDIR, "${conftemp}", [Default path for system libraries]) +dnl same for libexecdir +conftemp="${libexecdir}" +eval conftemp=\"${conftemp}\" +eval conftemp=\"${conftemp}\" +LIBEXECDIR=${conftemp} +AC_DEFINE_UNQUOTED(LIBEXECDIR, "${conftemp}", [Default path for system exec-libraries]) + + +dnl checks related to --with-snmp enabled on command-line + +dnl ${nut_with_snmp}: any value except "yes" or "no" is treated as "auto". +if test "${nut_with_snmp}" = "yes" -a "${nut_have_libnetsnmp}" != "yes"; then + AC_MSG_ERROR([Net-SNMP libraries not found, required for SNMP drivers]) +fi + +if test "${nut_with_snmp}" != "no"; then + nut_with_snmp="${nut_have_libnetsnmp}" +fi + +NUT_REPORT_FEATURE([build SNMP drivers], [${nut_with_snmp}], [], + [WITH_SNMP], [Define to enable SNMP support]) +AM_CONDITIONAL([HAVE_SNMP], [test "${nut_have_libsnmp}" = "yes"]) + + +if test -n "${host_alias}" ; then + AC_DEFINE_UNQUOTED(AUTOTOOLS_HOST_ALIAS, "${host_alias}", [host env spec we run on]) +else + if test -n "${host}" ; then + AC_DEFINE_UNQUOTED(AUTOTOOLS_HOST_ALIAS, "${host}", [host env spec we run on]) + fi +fi +if test -n "${build_alias}" ; then + AC_DEFINE_UNQUOTED(AUTOTOOLS_BUILD_ALIAS, "${build_alias}", [host env spec we built on]) +else + if test -n "${build}" ; then + AC_DEFINE_UNQUOTED(AUTOTOOLS_BUILD_ALIAS, "${build}", [host env spec we built on]) + fi +fi +if test -n "${target_alias}" ; then + AC_DEFINE_UNQUOTED(AUTOTOOLS_TARGET_ALIAS, "${target_alias}", [host env spec we built for]) +else + if test -n "${target}" ; then + AC_DEFINE_UNQUOTED(AUTOTOOLS_TARGET_ALIAS, "${target}", [host env spec we built for]) + fi +fi + +if test -n "${host_cpu}" -a -n "${host_os}" ; then + AC_DEFINE_UNQUOTED(AUTOTOOLS_HOST_SHORT_ALIAS, "${host_cpu}-${host_os}", [host OS short spec we run on]) +fi +if test -n "${build_cpu}" -a -n "${build_os}" ; then + AC_DEFINE_UNQUOTED(AUTOTOOLS_BUILD_SHORT_ALIAS, "${build_cpu}-${build_os}", [host OS short spec we built on]) +fi +if test -n "${target_cpu}" -a -n "${target_os}" ; then + AC_DEFINE_UNQUOTED(AUTOTOOLS_TARGET_SHORT_ALIAS, "${target_cpu}-${target_os}", [host OS short spec we built for]) +fi + +dnl ---------------------------------------------------------------------- + dnl Current date now=`TZ=UTC date +%Y-%m-%d` @@ -1219,6 +2467,7 @@ AC_SUBST(TREE_VERSION) AC_SUBST(NUT_NETVERSION) AC_SUBST(LIBSSL_CFLAGS) AC_SUBST(LIBSSL_LIBS) +AC_SUBST(LIBSSL_REQUIRES) AC_SUBST(LIBGD_CFLAGS) AC_SUBST(LIBGD_LDFLAGS) AC_SUBST(LIBNETSNMP_CFLAGS) @@ -1231,9 +2480,12 @@ AC_SUBST(LIBAVAHI_CFLAGS) AC_SUBST(LIBAVAHI_LIBS) AC_SUBST(LIBPOWERMAN_CFLAGS) AC_SUBST(LIBPOWERMAN_LIBS) +AC_SUBST(LIBMODBUS_CFLAGS) +AC_SUBST(LIBMODBUS_LIBS) AC_SUBST(LIBIPMI_CFLAGS) AC_SUBST(LIBIPMI_LIBS) AC_SUBST(DOC_BUILD_LIST) +AC_SUBST(DOC_CHECK_LIST) AC_SUBST(LIBWRAP_CFLAGS) AC_SUBST(LIBWRAP_LIBS) AC_SUBST(LIBLTDL_CFLAGS) @@ -1248,6 +2500,8 @@ AC_SUBST(STATEPATH) AC_SUBST(CONFPATH) AC_SUBST(BINDIR) AC_SUBST(LIBDIR) +AC_SUBST(NUT_DATADIR, [`eval echo "${DATADIR}"`]) +AC_SUBST(NUT_LIBEXECDIR, [`eval echo "${LIBEXECDIR}"`]) AC_SUBST(DRVPATH) AC_SUBST(SBINDIR) AC_SUBST(PORT) @@ -1261,11 +2515,347 @@ AC_SUBST(driverexecdir) AC_SUBST(htmldir) AC_SUBST(pkgconfigdir) AC_SUBST(systemdsystemunitdir) -AC_SUBST(systemdsystemshutdowndir) +AC_SUBST(systemdshutdowndir) +AC_SUBST(systemdtmpfilesdir) +AC_SUBST(auglensdir) AC_SUBST(hotplugdir) AC_SUBST(udevdir) -AC_OUTPUT([ +dnl On a related note to warning setup below, we limit the minimum C and C++ +dnl standard versions to ones we actively strive to support (C99 and C++11, +dnl GNU dialects tend to work on more systems if supported by compiler there). +dnl It is assumed that on very old systems whose compilers do not know these +dnl standards (only support ANSI/C89/C90 or older), as well as for builds +dnl that explicitly specify a CFLAGS="-std=..." (for GCC/CLANG toolkits), +dnl nothing should get added to CFLAGS/CXXFLAGS by this method: +NUT_COMPILER_FAMILY_FLAGS_DEFAULT_STANDARD + +dnl Filter through known variants first, so automatic choices can be made. +dnl Note that clang identifies as gcc-compatible so should be probed first. +dnl TODO: Flip this default to "hard" when we clear existing codebase. +dnl Note: the "gcc-legacy" option is intentionally undocumented, it acts as +dnl least-surprise default if caller did not specify any --enable-warnings. +dnl Note: Currently the "gcc-minimal" mode below adapts to builds with +dnl C89/C90/ANSI mode to be less noisy. Keep this in mind if changing the +dnl default "nut_warning_difficulty" and/or the case handling below. +dnl NOTE: Until X-Mas 2021, the default was "minimal" (now "medium") +nut_warning_difficulty="medium" +AC_MSG_CHECKING([whether to pre-set warnings (from '${nut_enable_warnings}')]) +AS_CASE(["${nut_enable_warnings}"], + [no|all|gcc-legacy|gcc-minimal|clang-minimal|gcc-medium|clang-medium|gcc-hard|clang-hard], [], + [clang], [nut_enable_warnings="${nut_enable_warnings}-${nut_warning_difficulty}"], + [gcc], [ + AS_CASE(["${CFLAGS}"], + [*89*|*90*|*ansi*], [nut_enable_warnings="${nut_enable_warnings}-minimal"], + [nut_enable_warnings="${nut_enable_warnings}-${nut_warning_difficulty}"] + )], + [yes|auto|""], [ + AS_IF([test "${CLANGCC}" = "yes"], [nut_enable_warnings="clang-${nut_warning_difficulty}"], + [AS_IF([test "${GCC}" = "yes"], [ + AS_CASE(["${CFLAGS}"], + [*89*|*90*|*ansi*], [nut_enable_warnings="gcc-minimal"], + [AS_CASE(["`$CC --version | grep -i gcc`"], + [*" "1.*|*" "2.*|3.*|*" "4.0*|*" "4.1*|*" "4.2*|*" "4.3*], [ + AC_MSG_WARN([Very old GCC in use, disabling warnings]) + dnl #AS_IF([test x"${nut_enable_Werror}" = xauto], [nut_enable_Werror="no"]) + nut_enable_Werror="no" + nut_enable_warnings="no"], + [*" "4.4*|*" "4.5*|*" "4.6*|*" "4.7*|*" "4.8*], [nut_enable_warnings="gcc-legacy"], + [nut_enable_warnings="gcc-${nut_warning_difficulty}"] + )] + )], [nut_enable_warnings="all"]) + ]) + ], + [hard|auto-hard|auto=hard], [ + AS_IF([test "${CLANGCC}" = "yes"], [nut_enable_warnings="clang-hard"], + [AS_IF([test "${GCC}" = "yes"], [nut_enable_warnings="gcc-hard"], [nut_enable_warnings="all"]) + ]) + ], + [medium|auto-medium|auto=medium], [ + AS_IF([test "${CLANGCC}" = "yes"], [nut_enable_warnings="clang-medium"], + [AS_IF([test "${GCC}" = "yes"], [nut_enable_warnings="gcc-medium"], [nut_enable_warnings="all"]) + ]) + ], + [minimal|auto-minimal|auto=minimal], [ + AS_IF([test "${CLANGCC}" = "yes"], [nut_enable_warnings="clang-minimal"], + [AS_IF([test "${GCC}" = "yes"], [nut_enable_warnings="gcc-minimal"], [nut_enable_warnings="all"]) + ]) + ], + [legacy], [AS_IF([test "${GCC}" = "yes"], [nut_enable_warnings="gcc-legacy"], [nut_enable_warnings="no"])], + [AC_MSG_WARN([Unsupported variant for --enable-warnings=${nut_enable_warnings}, ignored]) + nut_enable_warnings="no" + ] +) +AC_MSG_RESULT(["${nut_enable_warnings}"]) + +dnl # Nothing special for gcc - we tend to survive it with GNU standard >= 99 +dnl # and fail with strict C standard. Suggestions welcome for "gcc-hard" to +dnl # make a difference. +dnl # Note that "medium" and "hard" settings tend to trigger warnings also +dnl # from system headers, so we try to avoid them, using "-isystem path" +dnl # pre-set in our `m4/nut_compiler_family.m4` script: +dnl # https://stackoverflow.com/questions/36355232/disable-certain-warnings-for-system-headers +dnl # and "-Wno-system-headers" below. +dnl # Some of the compiler flags (including those added by pkg-config of some +dnl # third-party dependency packages) can upset older compiler releases which +dnl # did not yet support those. Flags like "-Wno-unknown-warning" for GCC or +dnl # "-Wno-unknown-warning-option" for CLANG should take care of that at least +dnl # for toolkit versions that support these - set in NUT_COMPILER_FAMILY_FLAGS +dnl # Majority of sanity checks are enabled by "-Wextra" on both GCC and CLANG +dnl # and "-Weverything" additionally on CLANG. They are impractically picky, +dnl # especially with fallout from system headers that we can not impact anyway +dnl # so the "difficulty level" pre-sets exclude certain warning classes from +dnl # that report. +dnl ### Special exclusion picks for clang-hard: +dnl # -Wno-unused-macros -- system headers define a lot of stuff we do not use, +dnl # gotta be fatal right? +dnl # -Wno-reserved-id-macro -- configure script tends to define _GNU_SOURCE_, +dnl # __EXTENSIONS__ etc. which are underscored and reserved for compilers +dnl # -Wno-padded -- NSPR and NSS headers get to issue lots of that +dnl # -Wno-c++98-compat-pedantic -Wno-c++98-compat -- our C++ code uses nullptr +dnl # as requested by newer linters, and C++98 does not. We require C++11 +dnl # or newer anyway, and skip building C++ library and test otherwise. +dnl ### Special exclusion picks for clang-medium (same as hard, plus...): +dnl # -Wno-float-conversion -Wno-double-promotion -Wno-implicit-float-conversion +dnl # -- reduce noise due to floating-point literals like "3.14" being a C +dnl # double type (a "3.14f" literal is a C float) cast implicitly into +dnl # float variables. Also variadic functions like printf() cast their +dnl # floating-point arguments into double (and small integer types into +dnl # "int") which then confuses pedantic checks of printf("%f", floatval). +dnl # -Wno-conversion -- similarly for error: implicit conversion loses +dnl # floating-point precision: 'double' to 'float' [-Werror,-Wconversion] +dnl # max_output = atof(sValue); +dnl # -Wno-cast-qual -- our code calls some library methods in ways which use +dnl # a "const char *" as a "char *" or vice-versa. Sometimes these method +dnl # signatures differ between dependency releases; sometimes they just +dnl # happened too hard to unravel cleanly and add more warnings. +dnl # This exclusion may be removed after common warnings are solved, +dnl # to allow progress on rectifying these cases next. +dnl # -Wno-incompatible-pointer-types-discards-qualifiers -- our code often +dnl # defines (char*) as the type for struct fields and method arguments, +dnl # but initializes/passes (char[]) variables or fixed strings. +dnl # This makes at least clang-3.4 quite upset and noisy (seems newer +dnl # versions care less about this situation). +dnl # -Wno-disabled-macro-expansion -- some system definitions of strncmp() +dnl # and other routines are in fact recursive macros. The -Weverything +dnl # mode of clang(-3.4) disables their handling, unless told otherwise. +AS_CASE(["${nut_enable_warnings}"], + [all], [ + CFLAGS="${CFLAGS} -Wall" + CXXFLAGS="${CXXFLAGS} -Wall" + ], + [clang-hard], [ + CFLAGS="${CFLAGS} -ferror-limit=0 -Wno-system-headers -Wall -Wextra -Weverything -Wno-disabled-macro-expansion -Wno-unused-macros -Wno-reserved-id-macro -Wno-padded -Wno-documentation -Wno-cast-qual -pedantic" + CXXFLAGS="${CXXFLAGS} -ferror-limit=0 -Wno-system-headers -Wall -Wextra -Weverything -Wno-disabled-macro-expansion -Wno-unused-macros -Wno-reserved-id-macro -Wno-padded -Wno-documentation -Wno-cast-qual -Wno-c++98-compat-pedantic -Wno-c++98-compat" + ], + [clang-medium], [ + CFLAGS="${CFLAGS} -ferror-limit=0 -Wno-system-headers -Wall -Wextra -Weverything -Wno-disabled-macro-expansion -Wno-unused-macros -Wno-reserved-id-macro -Wno-padded -Wno-documentation -Wno-cast-qual -pedantic -Wno-float-conversion -Wno-double-promotion -Wno-implicit-float-conversion -Wno-conversion -Wno-incompatible-pointer-types-discards-qualifiers" + CXXFLAGS="${CXXFLAGS} -ferror-limit=0 -Wno-system-headers -Wall -Wextra -Weverything -Wno-disabled-macro-expansion -Wno-unused-macros -Wno-reserved-id-macro -Wno-padded -Wno-documentation -Wno-cast-qual -Wno-c++98-compat-pedantic -Wno-c++98-compat" + ], + [clang-minimal], [ + CFLAGS="${CFLAGS} -ferror-limit=0 -Wall -Wextra -Wno-documentation" + CXXFLAGS="${CXXFLAGS} -ferror-limit=0 -Wall -Wextra -Wno-documentation" + ], + [gcc-legacy], [CFLAGS="${CFLAGS} -Wall -Wsign-compare"], + [gcc-minimal], [ + dnl Builds with C89 (and aliases) are quite noisy for C99+ syntax used + dnl in NUT. The minimal-warnings should not complain in these builds. + dnl To make matters worse, many modern OS and third-party library + dnl headers can not be used with "C90 + pedantic" mode of GCC, either. + CFLAGS="${CFLAGS} -Wall -Wsign-compare" + CXXFLAGS="${CXXFLAGS} -Wall -Wextra" + AS_CASE(["${CFLAGS}"], + [*89*|*90*|*ansi*], [], + [CFLAGS="${CFLAGS} -Wextra -pedantic"] + ) + ], + [gcc-medium|gcc-hard], [ + CFLAGS="${CFLAGS} -Wno-system-headers -Wall -Wextra -Wsign-compare" + CXXFLAGS="${CXXFLAGS} -Wno-system-headers -Wall -Wextra" + AS_CASE(["${CFLAGS}"], + [*89*|*90*|*ansi*], [], + [CFLAGS="${CFLAGS} -pedantic"] + ) + ] +) + +AC_MSG_CHECKING([whether to make warnings fatal]) +AS_CASE(["${nut_enable_Werror}"], + [yes|auto], [ + CFLAGS="${CFLAGS} -Werror" + CXXFLAGS="${CXXFLAGS} -Werror" + ], + [no], [ + CFLAGS="${CFLAGS} -Wno-error" + CXXFLAGS="${CXXFLAGS} -Wno-error" + ] +) +AC_MSG_RESULT(["${nut_enable_Werror}"]) + +dnl Some compilers (e.g. older clang-3.4) have issues with built-in methods +dnl that are implemented as macros in system headers -- but only for some +dnl sources like snmp-ups.c, nutscan-serial.c, scan_eaton_serial.c, serial.c, +dnl scan_avahi.c, scan_xml_http.c, scan_snmp.c... (Seems they all refer to +dnl -DNETSNMP_USE_INLINE among other options, and tends to happen more with +dnl OpenSSL-enabled builds). Check if we like them? +AC_CHECK_HEADER([string.h], + [AC_LANG_PUSH([C]) + CFLAGS_SAVED="${CFLAGS}" + CFLAGS_BUILTIN_STR="-fno-builtin-strchr -fno-builtin-strcmp -fno-builtin-strncmp" + CFLAGS="${CFLAGS} -Werror -Wunreachable-code ${LIBNETSNMP_CFLAGS} ${LIBLTDL_CFLAGS} ${LIBNEON_CFLAGS} ${LIBSSL_CFLAGS}" + AC_MSG_CHECKING([whether we should disable string built-ins]) + dnl AC_DEFINE([HAVE_STRING_H], [1], [Define to 1 if you have .]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], [char *s = "v1", c = '%'; +if (strcmp(s, "v1") != 0) return 1; +if (strchr(s, '1') == NULL) return 1; +if (strchr(s, c) != NULL) return 1 +/* no ";return 0;" here - autoconf adds one */ + ])], + [CFLAGS="${CFLAGS_SAVED}" + AC_MSG_RESULT([no, they are not a problem])], + [CFLAGS="${CFLAGS_BUILTIN_STR} ${CFLAGS}" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], [char *s = "v1", c = '%'; +if (strcmp(s, "v1") != 0) return 1; +if (strchr(s, '1') == NULL) return 1; +if (strchr(s, c) != NULL) return 1 +/* no ";return 0;" here - autoconf adds one */ + ])], + [CFLAGS="${CFLAGS_BUILTIN_STR} ${CFLAGS_SAVED}" + AC_MSG_RESULT([yes, this solves a problem])], + [CFLAGS="${CFLAGS_SAVED} -Werror -Wno-unreachable-code ${LIBNETSNMP_CFLAGS} ${LIBLTDL_CFLAGS} ${LIBNEON_CFLAGS} ${LIBSSL_CFLAGS}" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], [char *s = "mibs", c = '%'; +/* Macro version of strcmp() has problems with strings shorter than + * 3 or 4 bytes, so to avoid nailing "-Warray-bounds" as well, + * here we just test for longer strings - existing NUT sources were + * fixed for this situation already */ +if (strcmp(s, "mibs") != 0) return 1; +if (strchr(s, 'b') == NULL) return 1; +if (strchr(s, c) != NULL) return 1 +/* no ";return 0;" here - autoconf adds one */ + ])], + [dnl CFLAGS="${CFLAGS_SAVED} -Wno-unreachable-code" + dnl NOTE: Empirically, constrain to just LIBNETSNMP_CFLAGS + CFLAGS="${CFLAGS_SAVED}" + LIBLTDL_CFLAGS="${LIBLTDL_CFLAGS} -Wno-unreachable-code" + LIBNETSNMP_CFLAGS="${LIBNETSNMP_CFLAGS} -Wno-unreachable-code" + AC_MSG_RESULT([no, but -Wno-unreachable-code solves the problem for this compiler])], + [CFLAGS="${CFLAGS_SAVED}" + AC_MSG_RESULT([no, this does not solve the problem or is not supported]) + ]) + ]) + ] + ) + AC_LANG_POP([C])] +) + +dnl Similar to above, for s_addr = htonl((ntohl(ip->start.s_addr) + 1)); +dnl which causes "shadowed local variable" as (re-)defined in nested macros. +dnl Technically also needs to `#include ` for struct in_addr +dnl but that should be pulled by inet.h anyway +AC_CHECK_HEADER([arpa/inet.h], + [AC_LANG_PUSH([C]) + CFLAGS_SAVED="${CFLAGS}" + CFLAGS_BUILTIN_NTOHL="-fno-builtin-htonl -fno-builtin-ntohl" + CFLAGS="${CFLAGS} -Werror -Wunreachable-code -Wshadow ${LIBNETSNMP_CFLAGS} ${LIBLTDL_CFLAGS} ${LIBNEON_CFLAGS} ${LIBSSL_CFLAGS}" + AC_MSG_CHECKING([whether we should disable htonl/ntohl built-ins]) + dnl AC_DEFINE([HAVE_ARPA_INET_H], [1], [Define to 1 if you have .]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], [struct in_addr sin = {0}; +sin.s_addr = htonl((ntohl(sin.s_addr) + 1)) +/* no ";return 0;" here - autoconf adds one */ + ])], + [CFLAGS="${CFLAGS_SAVED}" + AC_MSG_RESULT([no, they are not a problem])], + [CFLAGS="${CFLAGS_BUILTIN_NTOHL} ${CFLAGS}" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], [struct in_addr sin = {0}; +sin.s_addr = htonl((ntohl(sin.s_addr) + 1)) +/* no ";return 0;" here - autoconf adds one */ + ])], + [CFLAGS="${CFLAGS_BUILTIN_NTOHL} ${CFLAGS_SAVED}" + AC_MSG_RESULT([yes, this solves a problem])], + [CFLAGS="${CFLAGS_SAVED} -Werror -Wno-shadow ${LIBNETSNMP_CFLAGS} ${LIBLTDL_CFLAGS} ${LIBNEON_CFLAGS} ${LIBSSL_CFLAGS}" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], [struct in_addr sin = {0}; +sin.s_addr = htonl((ntohl(sin.s_addr) + 1)) + ])], + [CFLAGS="${CFLAGS_SAVED}" + LIBLTDL_CFLAGS="${LIBLTDL_CFLAGS} -Wno-shadow" + LIBNETSNMP_CFLAGS="${LIBNETSNMP_CFLAGS} -Wno-shadow" + AC_MSG_RESULT([no, but -Wno-shadow solves the problem for this compiler])], + [CFLAGS="${CFLAGS_SAVED}" + AC_MSG_RESULT([no, this does not solve the problem or is not supported]) + ]) + ]) + ] + ) + AC_LANG_POP([C])] +) + +dnl Finally restore warnings settings that the caller might have provided in CFLAGS etc +NUT_POP_WARNINGS + +dnl Due to possibly repetitive content, generate unique settings +dnl relative to the top_builddir (distcheck and all): +AC_MSG_CHECKING([for top build dir for this configure run]) +TOP_BUILDDIR="" +AS_IF([test -n "${ac_abs_top_builddir}" && test -d "${ac_abs_top_builddir}"], + [TOP_BUILDDIR="${ac_abs_top_builddir}"], + [AS_IF([test -n "${ac_pwd}" && test -d "${ac_pwd}"], + [TOP_BUILDDIR="${ac_pwd}"], + [TOP_BUILDDIR="`dirname "$0"`" + TOP_BUILDDIR="`cd "$TOP_BUILDDIR" && pwd`" || AC_MSG_ERROR([Can not detect TOP_BUILDDIR])] + )] +) +AC_MSG_RESULT(["${TOP_BUILDDIR}"]) + +ABS_TOP_BUILDDIR="`cd "${TOP_BUILDDIR}" && pwd`" || AC_MSG_ERROR([Can not detect ABS_TOP_BUILDDIR]) +ABS_TOP_SRCDIR="`cd "${abs_srcdir}" && pwd`" || AC_MSG_ERROR([Can not detect ABS_TOP_SRCDIR]) +AM_CONDITIONAL([BUILDING_IN_TREE], [test "${ABS_TOP_BUILDDIR}" = "${ABS_TOP_SRCDIR}"]) + +AC_MSG_CHECKING([whether to customize ${TOP_BUILDDIR}/scripts/systemd/nut-common.tmpfiles.in for this system]) +AS_IF([test -n "$systemdtmpfilesdir"], + [mkdir -p "${TOP_BUILDDIR}"/scripts/systemd + cat > "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF +# State file (e.g. upsd to driver) and pidfile location for NUT: +d @STATEPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - +X @STATEPATH@/nut +EOF + AS_IF([test "$STATEPATH" != "$PIDPATH"], + [cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF +d @PIDPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - +X @PIDPATH@/nut +EOF]) + AS_IF([test -n "$ALTPIDPATH" && test "$STATEPATH" != "$ALTPIDPATH" && test "$PIDPATH" != "$ALTPIDPATH"], + [cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF +d @ALTPIDPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - +X @ALTPIDPATH@/nut +EOF]) + AS_IF([test -n "$ALTSTATEPATH" && test "$STATEPATH" != "$ALTSTATEPATH" && test "$ALTSTATEPATH" != "$ALTPIDPATH" && test "$PIDPATH" != "$ALTSTATEPATH"], + [cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF +d @ALTSTATEPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - +X @ALTSTATEPATH@/nut +EOF]) +]) +AC_MSG_RESULT([done]) + +AC_MSG_NOTICE([Generating "data" files from templates, see below for executable scripts]) +AC_CONFIG_FILES([ clients/Makefile common/Makefile conf/Makefile @@ -1276,6 +2866,7 @@ AC_OUTPUT([ data/Makefile data/driver.list docs/Makefile + docs/cables/Makefile docs/docinfo.xml docs/man/Makefile drivers/Makefile @@ -1283,12 +2874,12 @@ AC_OUTPUT([ lib/libupsclient-config lib/libupsclient.pc lib/libnutclient.pc + lib/libnutclientstub.pc lib/libnutscan.pc lib/Makefile scripts/Aix/nut-aix.spec scripts/augeas/Makefile scripts/augeas/nutnutconf.aug - scripts/augeas/nutupsconf.aug scripts/augeas/nutupsdconf.aug scripts/augeas/nutupsdusers.aug scripts/augeas/nutupsmonconf.aug @@ -1297,32 +2888,82 @@ AC_OUTPUT([ scripts/augeas/nutupssetconf.aug scripts/avahi/nut.service scripts/devd/Makefile - scripts/devd/nut-usb.conf scripts/hotplug/Makefile scripts/hotplug/libhidups scripts/HP-UX/nut.psf - scripts/HP-UX/postinstall scripts/python/Makefile + scripts/python/module/PyNUT.py + scripts/upsdrvsvcctl/Makefile scripts/systemd/Makefile - scripts/systemd/nut-driver.service + scripts/systemd/nut-common.tmpfiles + scripts/systemd/nut-driver@.service scripts/systemd/nut-monitor.service scripts/systemd/nut-server.service - scripts/systemd/nutshutdown + scripts/systemd/nut-driver-enumerator.service + scripts/systemd/nut-driver-enumerator.path + scripts/Solaris/nut-driver-enumerator.xml + scripts/Solaris/nut-driver.xml + scripts/Solaris/nut-monitor.xml + scripts/Solaris/nut-server.xml + scripts/Solaris/nut.xml scripts/Solaris/Makefile scripts/Solaris/pkginfo - scripts/Solaris/postinstall - scripts/Solaris/preremove - scripts/Solaris/nut scripts/udev/Makefile scripts/udev/nut-ipmipsu.rules - scripts/udev/nut-usbups.rules + scripts/ufw/Makefile scripts/ufw/nut.ufw.profile scripts/Makefile server/Makefile tools/Makefile tools/nut-scanner/Makefile tests/Makefile + tests/NIT/Makefile Makefile ]) +AC_MSG_NOTICE([Generating templated script files that should be marked executable]) +m4_foreach_w([SCRIPTFILE], [ + scripts/Aix/nut.init + scripts/HP-UX/postinstall + scripts/python/app/NUT-Monitor-py2gtk2 + scripts/python/app/NUT-Monitor-py3qt5 + scripts/augeas/gen-nutupsconf-aug.py + scripts/python/module/test_nutclient.py + scripts/upsdrvsvcctl/nut-driver-enumerator.sh + scripts/upsdrvsvcctl/upsdrvsvcctl + scripts/systemd/nutshutdown + scripts/Solaris/svc-nut-server + scripts/Solaris/svc-nut-monitor + scripts/Solaris/precheck.py + scripts/Solaris/preinstall + scripts/Solaris/postinstall + scripts/Solaris/preremove + scripts/Solaris/postremove + scripts/Solaris/preproto.pl + scripts/Solaris/nut + tools/gitlog2changelog.py + tools/nut-snmpinfo.py +], [ + dnl Autoconf substitutes the token above specified in plain text, + dnl e.g. the brace below is empty and bracket gives verbatim varname + dnl AC_MSG_NOTICE([Script: SCRIPTFILE brace:(${SCRIPTFILE}) bracket:([SCRIPTFILE])]) + AC_CONFIG_FILES(SCRIPTFILE, chmod +x "SCRIPTFILE") +]) + +AC_MSG_NOTICE([Generating templated script files whose templates might have been generated (or not) by autogen.sh calling our helper scripts]) +m4_foreach_w([SCRIPTFILE], [ + scripts/augeas/nutupsconf.aug + scripts/udev/nut-usbups.rules + scripts/devd/nut-usb.conf +], [ + AC_MSG_CHECKING([whether to generate SCRIPTFILE]) + AS_IF([test -s SCRIPTFILE.in && ! test -f SCRIPTFILE.in.AUTOGEN_WITHOUT], + [AC_MSG_RESULT(yes) + AC_CONFIG_FILES(SCRIPTFILE)], + [AC_MSG_RESULT(no)] + ) +]) + +AC_OUTPUT + NUT_PRINT_FEATURE_REPORT diff --git a/data/Makefile.am b/data/Makefile.am index 4b67782..9909818 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -5,3 +5,16 @@ SUBDIRS = html dist_data_DATA = cmdvartab nodist_data_DATA = driver.list EXTRA_DIST = evolution500.seq epdu-managed.dev + +# NOTE: Due to portability, we do not use a GNU percent-wildcard extension: +#%-spellchecked: % Makefile.am $(top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) +# $(MAKE) -s -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC_ONE="$<" SPELLCHECK_DIR="$(srcdir)" $@ + +cmdvartab-spellchecked: cmdvartab Makefile.am $(top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) + $(MAKE) -s -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC_ONE="$<" SPELLCHECK_DIR="$(srcdir)" $@ + +spellcheck spellcheck-interactive spellcheck-sortdict: + $(MAKE) -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC="cmdvartab" SPELLCHECK_DIR="$(srcdir)" $@ + +MAINTAINERCLEANFILES = Makefile.in .dirstamp +CLEANFILES = *.pdf *.html *-spellchecked diff --git a/data/Makefile.in b/data/Makefile.in index 0bd8feb..e2ae422 100644 --- a/data/Makefile.in +++ b/data/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.16.3 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -17,7 +17,17 @@ # Network UPS Tools: data VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -82,19 +92,24 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = data -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(srcdir)/driver.list.in $(dist_data_DATA) ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nut_arg_with.m4 \ $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ $(top_srcdir)/m4/nut_check_libavahi.m4 \ $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ $(top_srcdir)/m4/nut_check_libgd.m4 \ $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ $(top_srcdir)/m4/nut_check_libneon.m4 \ $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ $(top_srcdir)/m4/nut_check_libnss.m4 \ @@ -103,11 +118,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ $(top_srcdir)/m4/nut_check_libusb.m4 \ $(top_srcdir)/m4/nut_check_libwrap.m4 \ $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ $(top_srcdir)/m4/nut_type_socklen_t.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(dist_data_DATA) \ + $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = driver.list @@ -175,7 +197,7 @@ am__recursive_targets = \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - distdir + distdir distdir-am am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is @@ -196,6 +218,7 @@ am__define_uniq_tagged_files = \ ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) +am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/driver.list.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ @@ -229,6 +252,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -239,6 +263,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -252,6 +277,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -264,6 +290,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -281,6 +308,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -291,21 +320,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -325,6 +362,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -338,6 +378,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -355,6 +396,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -368,6 +410,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -393,12 +438,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -412,6 +459,8 @@ SUBDIRS = html dist_data_DATA = cmdvartab nodist_data_DATA = driver.list EXTRA_DIST = evolution500.seq epdu-managed.dev +MAINTAINERCLEANFILES = Makefile.in .dirstamp +CLEANFILES = *.pdf *.html *-spellchecked all: all-recursive .SUFFIXES: @@ -427,14 +476,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu data/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu data/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -595,7 +643,10 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -680,6 +731,7 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) @@ -688,6 +740,7 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am @@ -771,6 +824,18 @@ uninstall-am: uninstall-dist_dataDATA uninstall-nodist_dataDATA ps ps-am tags tags-am uninstall uninstall-am \ uninstall-dist_dataDATA uninstall-nodist_dataDATA +.PRECIOUS: Makefile + + +# NOTE: Due to portability, we do not use a GNU percent-wildcard extension: +#%-spellchecked: % Makefile.am $(top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) +# $(MAKE) -s -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC_ONE="$<" SPELLCHECK_DIR="$(srcdir)" $@ + +cmdvartab-spellchecked: cmdvartab Makefile.am $(top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) + $(MAKE) -s -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC_ONE="$<" SPELLCHECK_DIR="$(srcdir)" $@ + +spellcheck spellcheck-interactive spellcheck-sortdict: + $(MAKE) -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC="cmdvartab" SPELLCHECK_DIR="$(srcdir)" $@ # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/data/cmdvartab b/data/cmdvartab index 3d091f2..5f322c6 100644 --- a/data/cmdvartab +++ b/data/cmdvartab @@ -84,7 +84,7 @@ VARDESC input.load "Load on (ePDU) input (percent of full)" VARDESC input.realpower "Current sum value of all (ePDU) phases real power (W)" VARDESC input.power "Current sum value of all (ePDU) phases apparent power (VA)" VARDESC input.source "The current input power source" -VARDESC input.source.preferred "The prefered input power source" +VARDESC input.source.preferred "The preferred input power source" VARDESC output.voltage "Output voltage (V)" VARDESC output.voltage.nominal "Nominal output voltage (V)" @@ -94,6 +94,7 @@ VARDESC output.current "Output current (A)" VARDESC output.current.nominal "Nominal output current (A)" VARDESC battery.charge "Battery charge (percent of full)" +VARDESC battery.charge.approx "Rough approximation of battery charge" VARDESC battery.charge.low "Remaining battery level when UPS switches to LB (percent)" VARDESC battery.charge.restart "Minimum battery level for restart after power off (percent)" VARDESC battery.charge.warning "Battery level when UPS switches to Warning state (percent)" @@ -145,7 +146,7 @@ VARDESC ambient.present "Ambient sensor presence" VARDESC ambient.contacts.1.status "State of the dry contact sensor 1" VARDESC ambient.contacts.2.status "State of the dry contact sensor 2" -# FIXME: the outlet collection is indexed - solve with regexs? +# FIXME: the outlet collection is indexed - solve with regexps? # # VARDESC outlet.[[:digit:]]+.id "Outlet system identifier ()" @@ -177,6 +178,7 @@ VARDESC outlet.2.delay.start "Interval to wait before restarting this outlet (se VARDESC driver.name "Driver name" VARDESC driver.version "Driver version - NUT release" VARDESC driver.version.internal "Internal driver version" +VARDESC driver.version.usb "USB library version" VARDESC device.part "Device Part Number" diff --git a/data/driver.list.in b/data/driver.list.in index 50f23b8..a4e876c 100644 --- a/data/driver.list.in +++ b/data/driver.list.in @@ -16,8 +16,8 @@ # ======== # - device type: # "ups" for Uninterruptible Power Supply -# "pdu" for Power Distributions Unit -# "scd" for Solar Controlers Device +# "pdu" for Power Distribution Unit +# "scd" for Solar Controller Device # "ats" for Automatic Transfer Switch # # - support level: a number from "1" to "5" (stars) meaning: @@ -35,15 +35,25 @@ # Duplicate text in the last field will be cooked out during the conversion # to HTML with ROWSPAN magic. They must be an exact match for this to work. -"Ablerex" "ups" "2" "MS-RT" "" "blazer_ser" "Ablerex" "ups" "2" "625L" "USB" "blazer_usb" "Ablerex" "ups" "2" "Hope Office 400/600" "" "blazer_ser" +"Ablerex" "ups" "2" "MARS MS3000RT" "" "blazer_ser" +"Ablerex" "ups" "2" "MS-RT" "" "blazer_ser" +"Ablerex" "ups" "2" "MP series" "USB" "nutdrv_qx" +"Ablerex" "ups" "2" "ARES Plus series" "USB" "nutdrv_qx" +"Ablerex" "ups" "2" "MSII series" "USB" "nutdrv_qx" +"Ablerex" "ups" "2" "MSIII series" "USB" "nutdrv_qx" +"Ablerex" "ups" "2" "GRs series" "USB" "nutdrv_qx" +"Ablerex" "ups" "2" "GRs Plus series" "USB" "nutdrv_qx" "ActivePower" "ups" "2" "400VA" "" "blazer_ser" "ActivePower" "ups" "2" "1400VA" "" "blazer_ser" "ActivePower" "ups" "2" "2000VA" "" "blazer_ser" "Advice" "ups" "2" "TopGuard 2000" "" "blazer_ser" +"Advice" "ups" "2" "Top V Pro 6-10K" "USB" "blazer_usb" # https://www.advice.co.il/en/advice-products/ups-systems/ups-online-systems/one-phase-ups-5k-10k/%D7%90%D7%9C-%D7%A4%D7%A1%D7%A7-%D7%90%D7%95%D7%9F-%D7%9C%D7%99%D7%99%D7%9F-top-v-pro-6-10k-detail https://github.com/networkupstools/nut/issues/744 +"Advice" "ups" "2" "PRS850" "USB" "blazer_usb" +"Advice" "ups" "2" "PRV700 Pro" "USB" "blazer_usb" "AEC" "ups" "1" "MiniGuard UPS 700" "Megatec M2501 cable" "genericups upstype=21" @@ -51,6 +61,7 @@ "AEG Power Solutions" "ups" "3" "PROTECT NAS" "" "usbhid-ups" "AEG Power Solutions" "ups" "3" "PROTECT B" "" "usbhid-ups" +"APC" "ups" "3" "APC AP9584 Serial-to-USB kit" "USB" "usbhid-ups" # Allows USB connections to Serial-port APC devices, https://github.com/networkupstools/nut/pull/181 "APC" "ups" "2" "Back-UPS 1200BR (Microsol)" "" "solis" "APC" "ups" "2" "Back-UPS BZ2200BI-BR (Microsol)" "" "solis" "APC" "ups" "1" "Back-UPS Pro" "" "apcsmart" @@ -58,13 +69,16 @@ "APC" "ups" "1" "Smart-UPS" "" "apcsmart" "APC" "ups" "1" "Smart-UPS SMT/SMX/SURTD" "Microlink models with RJ45 socket - they *require* AP9620 SmartSlot expansion card and smart cable" "apcsmart" "APC" "ups" "2" "Back-UPS Pro USB" "USB" "usbhid-ups" -"APC" "ups" "2" "Back-UPS USB" "USB" "usbhid-ups" +"APC" "ups" "2" "Back-UPS (USB)" "USB" "usbhid-ups" +"APC" "ups" "2" "Back-UPS CS USB" "USB" "usbhid-ups" "APC" "ups" "2" "Back-UPS RS USB" "USB" "usbhid-ups" "APC" "ups" "2" "Back-UPS LS USB" "USB" "usbhid-ups" "APC" "ups" "2" "Back-UPS ES/CyberFort 350" "USB" "usbhid-ups" "APC" "ups" "2" "Back-UPS BF500" "USB" "usbhid-ups" "APC" "ups" "2" "BACK-UPS XS LCD" "USB" "usbhid-ups" -"APC" "ups" "2" "Smart-UPS USB" "USB" "usbhid-ups" +"APC" "ups" "2" "Back-UPS XS 1000M (Back-UPS Pro 1000, Model BX1000M)" "USB" "usbhid-ups" # https://github.com/networkupstools/nut/issues/139 +"APC" "ups" "2" "SMC2200BI-BR" "USB" "usbhid-ups" # https://github.com/networkupstools/nut/issues/557 +"APC" "ups" "2" "Smart-UPS (USB)" "USB" "usbhid-ups" "APC" "ups" "1" "Back-UPS" "940-0095A/C cables" "genericups upstype=1" "APC" "ups" "1" "Back-UPS" "940-0020B/C cables" "genericups upstype=2" "APC" "ups" "1" "Back-UPS" "940-0023A cable" "genericups upstype=9" @@ -77,7 +91,7 @@ "APC" "pdu" "1" "Masterswitch" "940-0020 cable" "genericups upstype=12" "APC" "pdu" "1" "AP9210" "8 outlets" "powerman-pdu (experimental)" "APC" "pdu" "1" "AP79xx" "8 to 24 outlets" "powerman-pdu (experimental)" -"APC" "pdu" "3" "(various)" "SNMP monitoring card" "snmp-ups (experimental)" +"APC" "pdu" "3" "(various APxxxx)" "SNMP monitoring card" "snmp-ups" "APC" "ats" "3" "ATS AP7724" "" "snmp-ups (experimental)" "Aphel" "pdu" "3" "various PDU" "" "snmp-ups (experimental)" @@ -88,6 +102,8 @@ "Appro" "pdu" "1" "SWPDU" "48 outlets" "powerman-pdu (experimental)" +"ARES" "ups" "2" "AR265i" "USB" "nutdrv_qx port=auto vendorid=0001 productid=0000 protocol=hunnox langid_fix=0x0409 novendor noscanlangid" # https://github.com/networkupstools/nut/pull/638 did not explicitly mention the driver parameters, but other reports in the discussion did + "ARTronic" "ups" "2" "ARTon Millenium 1/2/3/6/10 kVA" "Serial" "blazer_ser" "ARTronic" "ups" "2" "ARTon Millenium 3.1 10/15/20 kVA" "Serial" "blazer_ser" "ARTronic" "ups" "2" "ARTon Titanium 6/10 kVA" "Serial" "blazer_ser" @@ -98,6 +114,8 @@ "ARTronic" "ups" "2" "ARTon Platinium Combo 3.1 10/15/20 kVA" "USB" "blazer_usb" "ARTronic" "ups" "2" "ARTon Platinium RT 1/2/3/6/10 kVA" "USB" "blazer_usb" +"Armac" "ups" "2" "R/2000I/PSW" "(USB ID 0925:1234)" "nutdrv_qx" + "ASEM SPA" "ups" "5" "PB1300 UPS" "i2c" "asem" "Asium" "ups" "3" "P700" "USB" "blazer_usb" # http://www.asiumpower.com/Asium-ASIUM-P700-650VA-360W/dp/B009SMEQ10 @@ -118,6 +136,7 @@ "Atlantis Land" "ups" "2" "(various)" "USB" "nutdrv_qx" "Aviem Systems" "ups" "2" "Aviem Power RT 1000-3000VA" "" "blazer_ser" +"Aviem Systems" "ups" "2" "Aviem Pro 2000VA" "USB" "blazer_usb" # https://github.com/networkupstools/nut/issues/827 "Baytech" "pdu" "1" "RPC3" "8 outlets" "powerman-pdu (experimental)" "Baytech" "pdu" "1" "RPC3-20NC" "8 outlets" "powerman-pdu (experimental)" @@ -185,45 +204,63 @@ "COVER ENERGY SA" "ups" "2" "COVER PRM 1K/2K/3K/6K/10K EC" "" "blazer_usb" "COVER ENERGY SA" "ups" "2" "COVER PRM 6K/10K PR" "" "blazer_usb" +"CPC" "ups" "2" "RACK850VA" "USB" "nutdrv_qx port=auto vendorid=0001 productid=0000 product=MEC0003 protocol=hunnox langid_fix=0x0409 novendor noscanlangid" # https://github.com/networkupstools/nut/pull/638 caveats at https://github.com/networkupstools/nut/issues/537 + +"Crown" "ups" "2" "CMU-SP1200IEC" "USB" "nutdrv_qx port=auto vendorid=0001 productid=0000 protocol=hunnox langid_fix=0x0409 novendor noscanlangid" # https://github.com/networkupstools/nut/pull/638 caveats at https://github.com/networkupstools/nut/issues/1014 + +"Cyber Power Systems" "ups" "1" "550SL" "" "genericups upstype=7" +"Cyber Power Systems" "ups" "1" "725SL" "" "genericups upstype=7" +"Cyber Power Systems" "ups" "1" "CPS1100AVR" "" "powerpanel" +"Cyber Power Systems" "ups" "1" "CPS1200AVR" "" "powerpanel" +"Cyber Power Systems" "ups" "1" "CPS1250AVR" "" "powerpanel" +"Cyber Power Systems" "ups" "1" "CPS1500AVR" "" "powerpanel" +"Cyber Power Systems" "ups" "1" "CPS1500AVR-HO" "" "powerpanel" "Cyber Power Systems" "ups" "1" "CPS320AVR" "" "powerpanel" "Cyber Power Systems" "ups" "1" "CPS500AVR" "" "powerpanel" "Cyber Power Systems" "ups" "1" "CPS650AVR" "" "powerpanel" "Cyber Power Systems" "ups" "1" "CPS700AVR" "" "powerpanel" "Cyber Power Systems" "ups" "1" "CPS800AVR" "" "powerpanel" +"Cyber Power Systems" "ups" "1" "CPS825VA" "" "powerpanel" "Cyber Power Systems" "ups" "1" "CPS850AVR" "" "powerpanel" "Cyber Power Systems" "ups" "1" "CPS900AVR" "" "powerpanel" # http://www.cyberpowersystems.com/products/ups-systems/other-ups/CPS900AVR.html -"Cyber Power Systems" "ups" "1" "CPS1250AVR" "" "powerpanel" -"Cyber Power Systems" "ups" "1" "CPS1500AVR" "" "powerpanel" -"Cyber Power Systems" "ups" "1" "Power99" "" "genericups upstype=7" -"Cyber Power Systems" "ups" "1" "550SL" "" "genericups upstype=7" -"Cyber Power Systems" "ups" "1" "725SL" "" "genericups upstype=7" -"Cyber Power Systems" "ups" "1" "CPS825VA" "" "powerpanel" -"Cyber Power Systems" "ups" "1" "CPS1100AVR" "" "powerpanel" -"Cyber Power Systems" "ups" "1" "CPS1200AVR" "" "powerpanel" -"Cyber Power Systems" "ups" "1" "CPS1500AVR-HO" "" "powerpanel" "Cyber Power Systems" "ups" "1" "PR2200" "" "powerpanel" -"Cyber Power Systems" "ups" "2" "PR3000E" "" "powerpanel" -"Cyber Power Systems" "ups" "2" "OL3000RMXL2U" "" "powerpanel" +"Cyber Power Systems" "ups" "1" "Power99" "" "genericups upstype=7" +"Cyber Power Systems" "ups" "2" "AE550" "USB" "usbhid-ups" +"Cyber Power Systems" "ups" "3" "BL1250U" "USB" "usbhid-ups" # https://www.cyberpowersystems.com/product/ups/battery-backup/bl1250u/ https://github.com/networkupstools/nut/issues/1012 +"Cyber Power Systems" "ups" "2" "BR1000ELCD" "USB" "usbhid-ups" # https://www.cyberpower.com/eu/en/product/sku/BR1000ELCD https://github.com/networkupstools/nut/issues/552 +"Cyber Power Systems" "ups" "2" "CP1350AVRLCD" "USB" "usbhid-ups" +"Cyber Power Systems" "ups" "2" "CP1500AVRLCD" "USB" "usbhid-ups" +"Cyber Power Systems" "ups" "2" "CP850PFCLCD" "USB" "usbhid-ups" # https://github.com/networkupstools/nut/issues/605 +"Cyber Power Systems" "ups" "2" "CP1500PFCLCD" "USB" "usbhid-ups" # https://www.cyberpowersystems.com/product/ups/cp1500pfclcd/ https://github.com/networkupstools/nut/issues/520 +"Cyber Power Systems" "ups" "2" "CP900AVR" "USB" "usbhid-ups" "Cyber Power Systems" "ups" "2" "CPS685AVR" "USB" "usbhid-ups" "Cyber Power Systems" "ups" "2" "CPS800AVR" "USB" "usbhid-ups" -"Cyber Power Systems" "ups" "2" "AE550" "USB" "usbhid-ups" -"Cyber Power Systems" "ups" "3" "CP 1500C" "USB" "usbhid-ups" -"Cyber Power Systems" "ups" "3" "CP825AVR-G / LE825G" "USB" "usbhid-ups" # http://www.cyberpowersystems.com/products/ups-systems/retail-products/LE825G.html -"Cyber Power Systems" "ups" "3" "OR2200LCDRM2U" "USB" "usbhid-ups" -"Cyber Power Systems" "ups" "3" "OR700LCDRM1U" "USB" "usbhid-ups" -"Cyber Power Systems" "ups" "3" "PR6000LCDRTXL5U" "USB" "usbhid-ups" +"Cyber Power Systems" "ups" "2" "OL3000RMXL2U" "" "powerpanel" +"Cyber Power Systems" "ups" "2" "PR3000E" "" "powerpanel" +"Cyber Power Systems" "ups" "2" "Value 1500ELCD-RU" "USB" "usbhid-ups" "Cyber Power Systems" "ups" "2" "Value 400E" "USB" "usbhid-ups" "Cyber Power Systems" "ups" "2" "Value 600E" "USB" "usbhid-ups" "Cyber Power Systems" "ups" "2" "Value 800E" "USB" "usbhid-ups" -"Cyber Power Systems" "ups" "2" "Value 1500ELCD-RU" "USB" "usbhid-ups" -"Cyber Power Systems" "ups" "2" "CP900AVR" "USB" "usbhid-ups" -"Cyber Power Systems" "ups" "2" "CP1000AVRLCD" "USB" "usbhid-ups" -"Cyber Power Systems" "ups" "2" "CP1350AVRLCD" "USB" "usbhid-ups" -"Cyber Power Systems" "ups" "2" "CP1500AVRLCD" "USB" "usbhid-ups" -"Cyber Power Systems" "ups" "2" "CP1000PFCLCD" "USB" "usbhid-ups" +"Cyber Power Systems" "ups" "3" "CP 1500C" "USB" "usbhid-ups" +"Cyber Power Systems" "ups" "3" "CP1000PFCLCD" "USB" "usbhid-ups" +"Cyber Power Systems" "ups" "3" "CP1500EPFCLCD" "USB" "usbhid-ups" # http://www.cyberpower-eu.com/products/ups_systems/pfc-sinewave/cp1500epfclcd.htm +"Cyber Power Systems" "ups" "3" "CP825AVR-G / LE825G" "USB" "usbhid-ups" # http://www.cyberpowersystems.com/products/ups-systems/retail-products/LE825G.html +"Cyber Power Systems" "ups" "3" "EC350G" "USB" "usbhid-ups" # https://www.cyberpowersystems.com/products/ups/ecologic/ec350g +"Cyber Power Systems" "ups" "3" "EC750G" "USB" "usbhid-ups" # https://www.cyberpowersystems.com/products/ups/desktop/ec750g +"Cyber Power Systems" "ups" "3" "EC850LCD" "USB" "usbhid-ups" # https://www.cyberpowersystems.com/product/ups/ec850lcd/ https://github.com/networkupstools/nut/issues/622 +"Cyber Power Systems" "ups" "3" "OR1500ERM1U" "USB" "usbhid-ups" # https://github.com/networkupstools/nut/issues/1338 +"Cyber Power Systems" "ups" "3" "OR2200LCDRM2U" "USB" "usbhid-ups" +"Cyber Power Systems" "ups" "3" "OR700LCDRM1U" "USB" "usbhid-ups" +"Cyber Power Systems" "ups" "3" "OR500LCDRM1U" "USB" "usbhid-ups" # https://www.cyberpowersystems.com/product/ups/or500lcdrm1u/ https://github.com/networkupstools/nut/issues/578 +"Cyber Power Systems" "ups" "3" "RT650EI" "USB" "usbhid-ups" # http://www.cyberpowersystems.de/produkte/backup-usv-serien/rt-serie.html https://github.com/networkupstools/nut/issues/453 +"Cyber Power Systems" "ups" "3" "UT2200E" "USB" "usbhid-ups" # https://www.cyberpower.com/ww/en/product/sku/UT2200E https://github.com/networkupstools/nut/issues/556 +"Cyber Power Systems" "ups" "3" "PR1500RT2U" "" "usbhid-ups" # https://www.cyberpowersystems.com/product/ups/new-smart-app-sinewave/pr1500rt2u/ https://github.com/networkupstools/nut/issues/1191 +"Cyber Power Systems" "ups" "3" "PR6000LCDRTXL5U" "USB" "usbhid-ups" +"Cyber Power Systems" "ups" "3" "PR2200LCDRT2U" "" "snmp-ups" "Cyber Power Systems" "ups" "3" "RMCARD100" "" "snmp-ups" "Cyber Power Systems" "ups" "3" "RMCARD201" "" "snmp-ups" "Cyber Power Systems" "ups" "3" "RMCARD202" "" "snmp-ups" +"Cyber Power Systems" "ups" "3" "RMCARD205" "" "snmp-ups" "Cyber Power Systems" "ups" "3" "RMCARD301" "" "snmp-ups" "Cyclades" "pdu" "1" "PM8" "8 outlets" "powerman-pdu (experimental)" @@ -253,14 +290,24 @@ "Dell" "ups" "5" "Various (XML/HTTP mode)" "UPS Network Management Card" "netxml-ups (experimental)" "Delta" "ups" "1" "GES602N" "" "belkin" +"Delta" "ups" "4" "Delta UPS Amplon R Series" "USB port" "usbhid-ups" "Deltec" "ups" "1" "PowerRite Pro II" "" "genericups upstype=15" "Deltec" "ups" "4" "PRM 450/700/1000/1500" "" "upscode2" +"DEXP" "ups" "2" "MIX 850VA" "USB" "blazer_usb langid_fix=0x0409 runtimecal=240,100,720,50 default.battery.voltage.high=2.27 default.battery.voltage.low=1.72" # https://github.com/networkupstools/nut/issues/721 + "Digital Loggers" "pdu" "1" "LPC, EPCR2, DIN" "8 outlets" "powerman-pdu (experimental)" +"DigiTECH" "ups" "2" "Computer 650VA" "USB" "nutdrv_qx port=auto vendorid=0001 productid=0000 protocol=hunnox langid_fix=0x0409 novendor noscanlangid" # https://github.com/networkupstools/nut/pull/638 caveats at https://github.com/networkupstools/nut/issues/674 (may need longer pollinterval) + "Digitus" "ups" "1" "DN-170014" "USB" "richcomm_usb" # http://www.digitus.info/en/products/professional-network/security-and-surveillance/power-supply/uninterrruptable-power-supplies/ups-uninterruptible-power-systems-dn-170014/section/prof/ "Digitus" "ups" "2" "DN-170020" "" "blazer_ser" +"Digitus" "ups" "2" "DN-170040" "USB" "blazer_usb" # https://github.com/networkupstools/nut/issues/1251 +"Digitus" "ups" "2" "DN-170041" "USB" "blazer_usb" # https://github.com/networkupstools/nut/issues/1251 +"Digitus" "ups" "2" "DN-170040" "USB" "nutdrv_qx" # https://github.com/networkupstools/nut/issues/1251 +"Digitus" "ups" "2" "DN-170041" "USB" "nutdrv_qx" # https://github.com/networkupstools/nut/issues/1251 +"Digitus" "ups" "2" "DN-170076" "USB" "nutdrv_qx" # https://www.digitus.info/en/products/network-and-server-cabinets/power-supply/uninterruptible-power-supplies/dn-170076/ https://github.com/networkupstools/nut/issues/948 "Dynamix" "ups" "2" "UPS1700D" "" "blazer_ser" "Dynamix" "ups" "2" "UPS-650VA" "" "blazer_ser" @@ -274,6 +321,7 @@ "Eaton" "ups" "5" "Ellipse ECO 650/800/1200/1600 VA" "USB" "usbhid-ups" "Eaton" "ups" "5" "Ellipse ASR USBS 600/750/1000/1500 VA" "USB cable" "usbhid-ups" "Eaton" "ups" "5" "Ellipse MAX USBS 600/850/1100/1500 VA" "USB cable" "usbhid-ups" +"Eaton" "ups" "5" "Ellipse PRO 650 VA" "USB cable" "usbhid-ups" "Eaton" "ups" "5" "Evolution 650/850/1150/1550/2000 VA" "USB port" "usbhid-ups" "Eaton" "ups" "5" "Evolution S 1250/1750/2500/3000 VA" "USB port" "usbhid-ups" "Eaton" "ups" "5" "EX 700/1000/1500 VA" "USB port" "usbhid-ups" @@ -284,24 +332,32 @@ "Eaton" "ups" "5" "Nova AVR 625/1250" "USB" "usbhid-ups" "Eaton" "ups" "5" "5E650iUSB" "USB port" "usbhid-ups" "Eaton" "ups" "5" "5E1100iUSB" "USB port" "usbhid-ups" # http://powerquality.eaton.com/5E1100iUSB.aspx?CX&GUID=8D85FE66-3102-427C-8F33-B8D56BBDD4D3 +"Eaton" "ups" "4" "5E2200" "USB port" "nutdrv_qx" "Eaton" "ups" "5" "5S" "USB port" "usbhid-ups" "Eaton" "ups" "5" "5SC" "USB port" "usbhid-ups" "Eaton" "ups" "5" "5P" "USB port" "usbhid-ups" "Eaton" "ups" "5" "9SX" "USB port" "usbhid-ups" -"Eaton" "ups" "5" "Ellipse ASR USBS 600/750/1000/1500 VA" "Serial cable" "mge-shut or oldmge-shut" -"Eaton" "ups" "5" "Ellipse MAX USBS 600/850/1100/1500 VA" "Serial cable" "mge-shut or oldmge-shut" -"Eaton" "ups" "5" "Evolution 650/850/1150/1550/2000 VA" "Serial port" "mge-shut or oldmge-shut" -"Eaton" "ups" "5" "Evolution S 1250/1750/2500/3000 VA" "Serial port" "mge-shut or oldmge-shut" -"Eaton" "ups" "5" "EX 700/1000/1500 VA" "Serial port" "mge-shut or oldmge-shut" -"Eaton" "ups" "5" "EX 2200/3000/3000 XL VA" "Serial port" "mge-shut or oldmge-shut" -"Eaton" "ups" "5" "EX 1000 RT2U / 1500 RT2U" "Serial port" "mge-shut or oldmge-shut" -"Eaton" "ups" "5" "MX 5/8/10/15/20 kVA" "Serial port" "mge-shut or oldmge-shut" -"Eaton" "ups" "5" "5 PX" "Serial port" "mge-shut or oldmge-shut" -"Eaton" "ups" "5" "EX RT 1:1 7/11 kVA" "" "mge-shut or oldmge-shut" -"Eaton" "ups" "5" "EX RT 3:1 5/7/11 kVA" "" "mge-shut or oldmge-shut" -"Eaton" "ups" "5" "5SC" "Serial port" "mge-shut or oldmge-shut" -"Eaton" "ups" "5" "5P" "Serial port" "mge-shut or oldmge-shut" -"Eaton" "ups" "5" "9SX" "Serial port" "mge-shut or oldmge-shut" +"Eaton" "ups" "5" "9PX" "USB port" "usbhid-ups" +"Eaton" "ups" "5" "9PX Split Phase 6/8/10 kVA" "USB port" "usbhid-ups" +"Eaton" "ups" "5" "Ellipse ASR USBS 600/750/1000/1500 VA" "Serial cable" "mge-shut" +"Eaton" "ups" "5" "Ellipse MAX USBS 600/850/1100/1500 VA" "Serial cable" "mge-shut" +"Eaton" "ups" "5" "Evolution 650/850/1150/1550/2000 VA" "Serial port" "mge-shut" +"Eaton" "ups" "5" "Evolution S 1250/1750/2500/3000 VA" "Serial port" "mge-shut" +"Eaton" "ups" "5" "EX 700/1000/1500 VA" "Serial port" "mge-shut" +"Eaton" "ups" "5" "EX 2200/3000/3000 XL VA" "Serial port" "mge-shut" +"Eaton" "ups" "5" "EX 1000 RT2U / 1500 RT2U" "Serial port" "mge-shut" +"Eaton" "ups" "5" "MX 5/8/10/15/20 kVA" "Serial port" "mge-shut" +"Eaton" "ups" "5" "5 PX" "Serial port" "mge-shut" +"Eaton" "ups" "5" "EX RT 1:1 7/11 kVA" "" "mge-shut" +"Eaton" "ups" "5" "EX RT 3:1 5/7/11 kVA" "" "mge-shut" +"Eaton" "ups" "5" "5SC" "Serial port" "mge-shut" +"Eaton" "ups" "5" "5P" "Serial port" "mge-shut" +"Eaton" "ups" "5" "9SX" "Serial port" "mge-shut" +"Eaton" "ups" "5" "9PX" "Serial port" "mge-shut" +"Eaton" "ups" "5" "9PX 2000 RT" "USB port" "mge-shut" # https://github.com/networkupstools/nut/issues/540 +"Eaton" "ups" "5" "9PX Split Phase 6/8/10 kVA" "Serial port" "mge-shut" +"Eaton" "ups" "5" "9PX" "SNMP/Web card" "netxml-ups" +"Eaton" "ups" "5" "9PX Split Phase 6/8/10 kVA" "SNMP/Web card" "netxml-ups" "Eaton" "ups" "5" "EX RT (XML/HTTP)" "NMC Transverse card (ref 66074)" "netxml-ups (experimental)" "Eaton" "ups" "5" "EX RT (SNMP)" "NMC Transverse card (ref 66074)" "snmp-ups (experimental)" "Eaton" "ups" "5" "E Series NV UPS 400-2000 VA" "" "blazer_usb" @@ -328,14 +384,21 @@ "Eaton" "ups" "5" "ConnectUPS X / BD / E Slot" "Network port" "snmp-ups" "Eaton" "ups" "5" "Management Card Contact" "Config 3 - Cable 66033" "genericups upstype=7" "Eaton" "ats" "5" "Eaton ATS16" "" "snmp-ups" +"Eaton" "ats" "5" "Eaton ATS30" "" "snmp-ups" "Effekta" "ups" "2" "MI/MT/MH" "2502 cable" "blazer_ser" "Effekta" "ups" "2" "RM2000MH" "" "blazer_ser" "Electrys" "ups" "2" "UPS 2500" "" "nutdrv_qx or blazer_ser" +"Elsist" "ups" "2" "Nemo2.0 160" "USB" "blazer_usb" # http://www.naicon.com/company/wp-content/uploads/2017/05/Manual-NEMO2.0-Ver.02-Eng.pdf https://github.com/networkupstools/nut/issues/719 + +"Emerson" "pdu" "3" "PM3000 metered & switched" "" "snmp-ups" + "Energy Sistem" "ups" "2" "(various)" "" "blazer_ser" +"Energy Technologies" "ups" "2" "DPK1/1-3" "Serial" "blazer_ser" # https://www.tensy.ru/podderzhka/dokumentatsiya/ibp-serii-dpk/ https://github.com/networkupstools/nut/issues/762 + "ETA" "ups" "1" "mini+UPS" "WinNT/Upsoft cable" "genericups upstype=7" "ETA" "ups" "1" "mini+UPS PRO" "UPS Explorer cable" "etapro" @@ -351,6 +414,7 @@ "EVER" "ups" "2" "DUO II Pro series" "USB port" "blazer_usb" "EVER" "ups" "2" "POWERLINE RT 1-3kVA series" "USB port" "blazer_usb" "EVER" "ups" "2" "POWERLINE RT 6-10kVA series" "USB port" "blazer_usb" +"EVER" "ups" "4" "ECO Pro AVR CDS series" "USB port" "usbhid-ups" "Exide" "ups" "1" "NetUPS SE" "" "genericups upstype=15" "Exide" "ups" "4" "NetUPS SE 450/700/1000/1500" "" "upscode2" @@ -402,6 +466,9 @@ "Grafenthal" "ups" "2" "PR-3000-HS" "SNMP/Web Minislot card (ref 149G0006)" "snmp-ups" # http://grafenthal.de/produkte/usv/online/pr-hs-serie/pr-3000-hs/?L=3et8 +"Greencell" "ups" "2" "Micropower 600" "USB" "nutdrv_qx" # https://github.com/networkupstools/nut/issues/1080 +"Greencell" "ups" "2" "Micropower 600" "USB" "blazer_usb" # https://github.com/networkupstools/nut/issues/1080 + "Gtec" "ups" "2" "ZP120N-1K / ZP120N-1KS / ZP120N-2K / ZP120N-2KS / ZP120N-3K / ZP120N-3KS" "" "blazer_usb" "Gtec" "ups" "2" "ZP120N-6K / ZP120N-6KS / ZP120N-10K-11 / ZP120N-10KS-11" "" "blazer_usb" "Gtec" "ups" "2" "ZP120N-10K-31-00 / ZP120N-10K-31-07 / ZP120N-10K-31-09 / ZP120N-10K-31-99 / ZP120N-20K" "USB port" "blazer_usb" @@ -409,6 +476,8 @@ "Gtec" "ups" "2" "ZP120N-10K-31-00 / ZP120N-10K-31-07 / ZP120N-10K-31-09 / ZP120N-10K-31-99 / ZP120N-20K" "Serial port" "blazer_ser" "Gtec" "ups" "2" "AP160N-1K / AP160LCD-1K-KS / AP160N-2K / AP160LCD-2K-KS / AP160N-3K / AP160LCD-3K-KS / AP160N-6K-PDU / AP160N-10K-PDU" "Serial port" "blazer_ser" +"Guardian" "ups" "2" "LCD 1500 AP (IGA1500LCD)" "Serial" "nutdrv_qx" + "HP" "ups" "1" "PowerTrust 2997A" "HP 5061-2575 cable" "apcsmart" "HP" "ups" "3" "T750 G2" "Serial port" "bcmxcp" "HP" "ups" "3" "T1000 G3" "Serial port" "bcmxcp" @@ -417,8 +486,8 @@ "HP" "ups" "4" "R3000 XR" "" "bcmxcp" "HP" "ups" "4" "R5500 XR" "" "bcmxcp" "HP" "ups" "3" "T500 / T750" "older models, USB port" "bcmxcp_usb" -"HP" "ups" "3" "R/T3000" "Serial port" "mge-shut or oldmge-shut" -"HP" "ups" "3" "R5000 / R7000" "Serial port" "mge-shut or oldmge-shut" +"HP" "ups" "3" "R/T3000" "Serial port" "mge-shut" +"HP" "ups" "3" "R5000 / R7000" "Serial port" "mge-shut" "HP" "ups" "3" "T750 INTL" "" "usbhid-ups" "HP" "ups" "3" "T1000 INTL" "" "usbhid-ups" "HP" "ups" "3" "T1500 INTL" "" "usbhid-ups" @@ -432,8 +501,15 @@ "HP" "ups" "4" "Various (SNMP mode)" "HP UPS Management Module" "snmp-ups" "HP" "pdu" "1" "HP3488 Switch/Control Unit" "" "powerman-pdu (experimental)" -"Huawei" "ups" "4" "UPS5000-E" "" "snmp-ups" +"HPE" "pdu" "5" "Various (SNMP mode)" "" "snmp-ups" +"Huawei" "ups" "4" "UPS5000-E" "" "snmp-ups" +"Huawei" "ups" "3" "UPS2000-G and UPS2000-A series" "MODBUS (USB with Linux 5.12+, or Serial RS-232)" "huawei-ups2000" # https://github.com/networkupstools/nut/issues/1066 https://github.com/networkupstools/nut/pull/1198 https://github.com/networkupstools/nut/pull/954 https://github.com/networkupstools/nut/issues/1017 + +"Hunnox" "ups" "2" "HNX-850" "USB" "nutdrv_qx port=auto vendorid=0001 productid=0000 protocol=hunnox langid_fix=0x0409 novendor noscanlangid" # https://github.com/networkupstools/nut/pull/638 + +"IBM" "ups" "5" "Various" "USB port" "usbhid-ups" +"IBM" "ups" "5" "Various" "Serial port" "mge-shut" "IBM" "pdu" "1" "Blade Center Management Module" "15 outlets" "powerman-pdu (experimental)" "ICS" "pdu" "1" "8064 Ethernet Relay Interface" "16 outlets" "powerman-pdu (experimental)" @@ -461,10 +537,12 @@ "IPMI" "pdu" "1" "" "" "powerman-pdu (experimental)" +"Ippon" "ups" "2" "Back Basic 850 Euro" "USB" "blazer_usb (experimental)" # https://github.com/networkupstools/nut/issues/802 "Ippon" "ups" "2" "Back Power Pro 400/500/600/700/800" "" "blazer_ser" "Ippon" "ups" "2" "Back Power Pro 400/500/600/700/800" "USB" "blazer_usb (experimental)" "Ippon" "ups" "2" "Back Comfo Pro 600/800" "" "blazer_ser" "Ippon" "ups" "2" "Back Comfo Pro 600/800" "USB" "blazer_usb (experimental)" +"Ippon" "ups" "2" "Back Comfo Pro II 650/850/1050" "USB" "blazer_usb (experimental)" "Ippon" "ups" "2" "Smart Power Pro 1000/1400/2000" "" "blazer_ser" "Ippon" "ups" "2" "Smart Power Pro 1000/1400/2000" "USB" "blazer_usb (experimental)" "Ippon" "ups" "2" "Smart Winner 750/1000/1500/2000/3000" "" "blazer_ser" @@ -482,6 +560,8 @@ "Kanji" "ups" "1" "800 VA" "USB" "nutdrv_atcl_usb" "Kebo" "ups" "2" "1200D/D Series" "" "blazer_ser" +"Kebo" "ups" "2" "UPS-1000D (UPS-1000VA)" "USB" "blazer_usb" # https://github.com/networkupstools/nut/issues/981 +"Kebo" "ups" "2" "UPS-650VA" "USB" "megatec_usb" "KOLFF" "ups" "2" "BLACK NOVA 1K/2K/3K/6K/10K/20K TOWER" "" "blazer_usb" "KOLFF" "ups" "2" "BLACK NOVA 1K/2K/3K/6K/10K/20K XL TOWER" "" "blazer_usb" @@ -495,7 +575,43 @@ "LDLC" "ups" "2" "UPS-1200D" "" "blazer_usb langid_fix=0x4095" -"Legrand" "ups" "2" "Keor Multiplug" "" "nutdrv_qx" +"Legrand" "ups" "2" "Daker DK" "Serial" "nutdrv_qx" +"Legrand" "ups" "2" "Daker DK" "USB" "nutdrv_qx" +"Legrand" "ups" "2" "Daker DK Plus" "Serial" "nutdrv_qx" +"Legrand" "ups" "2" "Daker DK Plus" "USB" "nutdrv_qx" +"Legrand" "ups" "2" "Keor Line RT" "Serial" "nutdrv_qx" +"Legrand" "ups" "2" "Keor Line RT" "USB" "nutdrv_qx" +"Legrand" "ups" "2" "Keor LP" "Serial" "nutdrv_qx" +"Legrand" "ups" "2" "Keor Multiplug" "USB" "nutdrv_qx" +"Legrand" "ups" "2" "Keor S" "Serial" "nutdrv_qx" +"Legrand" "ups" "2" "Keor S" "USB" "nutdrv_qx" +"Legrand" "ups" "2" "Keor PDU" "USB" "usbhid-ups" +"Legrand" "ups" "2" "Keor SP" "USB" "usbhid-ups" +"Legrand" "ups" "2" "Keor SPX" "USB" "nutdrv_qx" +"Legrand" "ups" "4" "Megaline 1250" "Serial" "metasys" +"Legrand" "ups" "4" "Megaline 2500" "Serial" "metasys" +"Legrand" "ups" "4" "Megaline 3750" "Serial" "metasys" +"Legrand" "ups" "4" "Megaline 5000" "Serial" "metasys" +"Legrand" "ups" "4" "Megaline 5000 /2" "Serial" "metasys" +"Legrand" "ups" "4" "Megaline 6250 /2" "Serial" "metasys" +"Legrand" "ups" "4" "Megaline 7500 /2" "Serial" "metasys" +"Legrand" "ups" "4" "Megaline 8750 /2" "Serial" "metasys" +"Legrand" "ups" "4" "Megaline 10000 /2" "Serial" "metasys" +"Legrand" "ups" "2" "Niky" "Serial" "nutdrv_qx" +"Legrand" "ups" "2" "Niky" "USB" "nutdrv_qx" +"Legrand" "ups" "2" "Niky S" "Serial" "nutdrv_qx" +"Legrand" "ups" "2" "Niky S" "USB" "nutdrv_qx" +"Legrand" "ups" "4" "WHAD 800" "Serial" "metasys" +"Legrand" "ups" "4" "WHAD 1000" "Serial" "metasys" +"Legrand" "ups" "4" "WHAD 1250" "Serial" "metasys" +"Legrand" "ups" "4" "WHAD 1500" "Serial" "metasys" +"Legrand" "ups" "4" "WHAD 2000" "Serial" "metasys" +"Legrand" "ups" "4" "WHAD 2500" "Serial" "metasys" +"Legrand" "ups" "4" "WHAD CAB 1250" "Serial" "metasys" +"Legrand" "ups" "4" "WHAD CAB 2500" "Serial" "metasys" +"Legrand" "ups" "4" "WHAD HE 800" "Serial" "metasys" +"Legrand" "ups" "4" "WHAD HE 1000" "Serial" "metasys" +"Legrand" "ups" "4" "WHAD HE 1500" "Serial" "metasys" "Lestar" "ups" "2" "MD-800E" "" "blazer_ser" @@ -506,6 +622,8 @@ "Liebert" "ups" "1" "GXT2-3000RT230" "" "liebert-esp2 (experimental)" "Liebert" "ups" "2" "PowerSure Personal XT" "USB" "usbhid-ups" "Liebert" "ups" "2" "PowerSure PSA" "USB" "usbhid-ups" +"Liebert" "ups" "2" "PowerSure PSA 500" "USB" "usbhid-ups" +"Liebert" "ups" "2" "PowerSure PSA500MT3-230U" "USB" "usbhid-ups" # https://github.com/networkupstools/nut/issues/601 "Liebert" "ups" "2" "PowerSure PSI 1440" "USB" "usbhid-ups" # http://www.emersonnetworkpower.com/en-US/Products/ACPower/Pages/LiebertPowerSurePSILineInteractiveUPS10003000VA.aspx "LNXI" "pdu" "1" "Icebox" "10 outlets" "powerman-pdu (experimental)" @@ -520,48 +638,50 @@ "Mecer" "ups" "2" "ME-1000-WTU" "USB" "nutdrv_qx" # http://www.comx-computers.co.za/download/mecer/ME-1000-WTU.pdf "Mecer" "ups" "2" "ME-2000" "" "blazer_ser" -"Meta System" "ups" "1" "HF Line" "1..4 boards" "metasys" -"Meta System" "ups" "1" "HF Line \/2" "5..8 boards" "metasys" -"Meta System" "ups" "1" "HF Millennium 810" "" "metasys" -"Meta System" "ups" "1" "HF Millennium 820" "" "metasys" -"Meta System" "ups" "1" "HF TOP Line 910" "" "metasys" -"Meta System" "ups" "1" "HF TOP Line 920" "" "metasys" -"Meta System" "ups" "1" "HF TOP Line 930" "" "metasys" -"Meta System" "ups" "1" "HF TOP Line 940" "" "metasys" -"Meta System" "ups" "1" "HF TOP Line 950" "" "metasys" -"Meta System" "ups" "1" "HF TOP Line 960" "" "metasys" -"Meta System" "ups" "1" "HF TOP Line 970" "" "metasys" -"Meta System" "ups" "1" "HF TOP Line 980" "" "metasys" -"Meta System" "ups" "1" "ECO Network 750" "" "metasys" -"Meta System" "ups" "1" "ECO Network 1000" "" "metasys" -"Meta System" "ups" "1" "ECO Network 1050" "" "metasys" -"Meta System" "ups" "1" "ECO Network 1500" "" "metasys" -"Meta System" "ups" "1" "ECO Network 1800" "" "metasys" -"Meta System" "ups" "1" "ECO Network 2000" "" "metasys" -"Meta System" "ups" "1" "ECO Network 2100" "" "metasys" -"Meta System" "ups" "1" "ECO Network 2500" "" "metasys" -"Meta System" "ups" "1" "ECO Network 3000" "" "metasys" -"Meta System" "ups" "1" "ECO 305" "" "metasys" -"Meta System" "ups" "1" "ECO 308" "" "metasys" -"Meta System" "ups" "1" "ECO 311" "" "metasys" -"Meta System" "ups" "1" "ECO 511" "" "metasys" -"Meta System" "ups" "1" "ECO 516" "" "metasys" -"Meta System" "ups" "1" "ECO 519" "" "metasys" -"Meta System" "ups" "1" "ECO 522" "" "metasys" -"Meta System" "ups" "1" "ally HF 800" "" "metasys" -"Meta System" "ups" "1" "ally HF 1000" "" "metasys" -"Meta System" "ups" "1" "ally HF 1250" "" "metasys" -"Meta System" "ups" "1" "ally HF 1600" "" "metasys" -"Meta System" "ups" "1" "ally HF 2000" "" "metasys" -"Meta System" "ups" "1" "ally HF 2500" "" "metasys" -"Meta System" "ups" "1" "Megaline 1250" "" "metasys" -"Meta System" "ups" "1" "Megaline 2500" "" "metasys" -"Meta System" "ups" "1" "Megaline 3750" "" "metasys" -"Meta System" "ups" "1" "Megaline 5000" "" "metasys" -"Meta System" "ups" "1" "Megaline 6250" "" "metasys" -"Meta System" "ups" "1" "Megaline 7500" "" "metasys" -"Meta System" "ups" "1" "Megaline 8750" "" "metasys" -"Meta System" "ups" "1" "Megaline 10000" "" "metasys" +"Meta System" "ups" "4" "HF Line" "1..4 boards" "metasys" +"Meta System" "ups" "4" "HF Line /2" "5..8 boards" "metasys" +"Meta System" "ups" "4" "HF Millennium 810" "" "metasys" +"Meta System" "ups" "4" "HF Millennium 820" "" "metasys" +"Meta System" "ups" "4" "HF TOP Line 910" "" "metasys" +"Meta System" "ups" "4" "HF TOP Line 920" "" "metasys" +"Meta System" "ups" "4" "HF TOP Line 930" "" "metasys" +"Meta System" "ups" "4" "HF TOP Line 940" "" "metasys" +"Meta System" "ups" "4" "HF TOP Line 950" "" "metasys" +"Meta System" "ups" "4" "HF TOP Line 960" "" "metasys" +"Meta System" "ups" "4" "HF TOP Line 970" "" "metasys" +"Meta System" "ups" "4" "HF TOP Line 980" "" "metasys" +"Meta System" "ups" "4" "ECO Network 750" "" "metasys" +"Meta System" "ups" "4" "ECO Network 1000" "" "metasys" +"Meta System" "ups" "4" "ECO Network 1050" "" "metasys" +"Meta System" "ups" "4" "ECO Network 1500" "" "metasys" +"Meta System" "ups" "4" "ECO Network 1800" "" "metasys" +"Meta System" "ups" "4" "ECO Network 2000" "" "metasys" +"Meta System" "ups" "4" "ECO Network 2100" "" "metasys" +"Meta System" "ups" "4" "ECO Network 2500" "" "metasys" +"Meta System" "ups" "4" "ECO Network 3000" "" "metasys" +"Meta System" "ups" "4" "ECO 305" "" "metasys" +"Meta System" "ups" "4" "ECO 308" "" "metasys" +"Meta System" "ups" "4" "ECO 311" "" "metasys" +"Meta System" "ups" "4" "ECO 511" "" "metasys" +"Meta System" "ups" "4" "ECO 516" "" "metasys" +"Meta System" "ups" "4" "ECO 519" "" "metasys" +"Meta System" "ups" "4" "ECO 522" "" "metasys" +"Meta System" "ups" "4" "ally HF 800" "" "metasys" +"Meta System" "ups" "4" "ally HF 1000" "" "metasys" +"Meta System" "ups" "4" "ally HF 1250" "" "metasys" +"Meta System" "ups" "4" "ally HF 1600" "" "metasys" +"Meta System" "ups" "4" "ally HF 2000" "" "metasys" +"Meta System" "ups" "4" "ally HF 2500" "" "metasys" +"Meta System" "ups" "4" "Megaline 1250" "" "metasys" +"Meta System" "ups" "4" "Megaline 2500" "" "metasys" +"Meta System" "ups" "4" "Megaline 3750" "" "metasys" +"Meta System" "ups" "4" "Megaline 5000" "" "metasys" +"Meta System" "ups" "4" "Megaline 6250" "" "metasys" +"Meta System" "ups" "4" "Megaline 7500" "" "metasys" +"Meta System" "ups" "4" "Megaline 8750" "" "metasys" +"Meta System" "ups" "4" "Megaline 10000" "" "metasys" +"Meta System" "ups" "4" "DHEA 1000" "Serial" "metasys" +"Meta System" "ups" "4" "DHEA 1500" "Serial" "metasys" "MGE Office Protection Systems" "ups" "5" "Protection Center 500/675 VA" "USB" "usbhid-ups" "MGE Office Protection Systems" "ups" "5" "Protection Station 500/650/800 VA" "USB" "usbhid-ups" @@ -572,15 +692,15 @@ "MGE Office Protection Systems" "ups" "5" "Pulsar 700/1000/1500 VA" "USB port" "usbhid-ups" "MGE Office Protection Systems" "ups" "5" "Pulsar M 2200/3000 VA" "USB port" "usbhid-ups" "MGE Office Protection Systems" "ups" "5" "Pulsar MX 5/8/10/15/20 kVA" "USB port" "usbhid-ups" -"MGE Office Protection Systems" "ups" "5" "Ellipse ASR USBS 600/750/1000/1500 VA" "Serial cable" "mge-shut or oldmge-shut" -"MGE Office Protection Systems" "ups" "5" "Ellipse MAX USBS 600/850/1100/1500 VA" "Serial cable" "mge-shut or oldmge-shut" -"MGE Office Protection Systems" "ups" "5" "Evolution 650/850/1150/1550/2000 VA" "Serial port" "mge-shut or oldmge-shut" -"MGE Office Protection Systems" "ups" "5" "Evolution S 1250/1750/2500/3000 VA" "Serial port" "mge-shut or oldmge-shut" -"MGE Office Protection Systems" "ups" "5" "Pulsar 700/1000/1500 VA" "Serial port" "mge-shut or oldmge-shut" -"MGE Office Protection Systems" "ups" "5" "Pulsar M 2200/3000 VA" "Serial port" "mge-shut or oldmge-shut" -"MGE Office Protection Systems" "ups" "5" "Pulsar MX 5/8/10/15/20 kVA" "Serial port" "mge-shut or oldmge-shut" -"MGE Office Protection Systems" "ups" "5" "Comet EX RT 1:1 7/11 kVA" "" "mge-shut or oldmge-shut" -"MGE Office Protection Systems" "ups" "5" "Comet EX RT 3:1 5/7/11 kVA" "" "mge-shut or oldmge-shut" +"MGE Office Protection Systems" "ups" "5" "Ellipse ASR USBS 600/750/1000/1500 VA" "Serial cable" "mge-shut" +"MGE Office Protection Systems" "ups" "5" "Ellipse MAX USBS 600/850/1100/1500 VA" "Serial cable" "mge-shut" +"MGE Office Protection Systems" "ups" "5" "Evolution 650/850/1150/1550/2000 VA" "Serial port" "mge-shut" +"MGE Office Protection Systems" "ups" "5" "Evolution S 1250/1750/2500/3000 VA" "Serial port" "mge-shut" +"MGE Office Protection Systems" "ups" "5" "Pulsar 700/1000/1500 VA" "Serial port" "mge-shut" +"MGE Office Protection Systems" "ups" "5" "Pulsar M 2200/3000 VA" "Serial port" "mge-shut" +"MGE Office Protection Systems" "ups" "5" "Pulsar MX 5/8/10/15/20 kVA" "Serial port" "mge-shut" +"MGE Office Protection Systems" "ups" "5" "Comet EX RT 1:1 7/11 kVA" "" "mge-shut" +"MGE Office Protection Systems" "ups" "5" "Comet EX RT 3:1 5/7/11 kVA" "" "mge-shut" "MGE Office Protection Systems" "ups" "5" "Comet EX RT (XML/HTTP)" "NMC Transverse card (ref 66074)" "netxml-ups (experimental)" "MGE Office Protection Systems" "ups" "5" "Comet EX RT (SNMP)" "NMC Transverse card (ref 66074)" "snmp-ups (experimental)" "MGE Office Protection Systems" "ups" "5" "various models (XML/HTTP mode)" "NMC Minislot (Ref 66102)" "netxml-ups (experimental)" @@ -628,45 +748,45 @@ "MGE UPS SYSTEMS" "ups" "5" "Pulsar MX 4000 RT" "USB" "usbhid-ups" "MGE UPS SYSTEMS" "ups" "5" "Pulsar MX 5000 RT" "USB" "usbhid-ups" "MGE UPS SYSTEMS" "ups" "5" "Comet / Galaxy (USB)" "USB Card (ref 66067)" "usbhid-ups" -"MGE UPS SYSTEMS" "ups" "5" "NOVA AVR 600 Serial" "" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "NOVA AVR 1100 Serial" "" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Pulsar Ellipse USBS" "Serial cable" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Pulsar Ellipse S" "" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Pulsar Ellipse Premium USBS" "Serial cable" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Pulsar Ellipse Premium S" "" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Ellipse Office 600" "Serial cable" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Ellipse Office 750" "Serial cable" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Ellipse Office 1000" "Serial cable" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Ellipse Office 1500" "Serial cable" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Ellipse MAX 600" "Serial cable" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Ellipse MAX 850" "Serial cable" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Ellipse MAX 1100" "Serial cable" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Ellipse MAX 1500" "Serial cable" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Pulsar EXtreme C / EX RT" "" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Comet EX RT" "Serial port" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Comet EX RT 3:1" "Serial port" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Pulsar Esprit" "" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Evolution 650" "Serial port" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Evolution 850" "Serial port" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Evolution 1150" "Serial port" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Evolution S 1250" "Serial port" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Evolution 1550" "Serial port" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Evolution S 1750" "Serial port" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Evolution 2000" "Serial port" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Evolution S 2500" "Serial port" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Evolution S 3000" "Serial port" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Pulsar M 2200" "Serial port" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Pulsar M 3000" "Serial port" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Pulsar M 3000 XL" "Serial port" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Pulsar 700" "Serial port" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Pulsar 1000" "Serial port" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Pulsar 1500" "Serial port" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Pulsar 1000 RT2U" "Serial port" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Pulsar 1500 RT2U" "Serial port" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Pulsar MX 4000 RT" "Serial port" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Pulsar MX 5000 RT" "Serial port" "mge-shut or oldmge-shut" -"MGE UPS SYSTEMS" "ups" "5" "Pulsar Evolution" "Serial port" "mge-shut or oldmge-shut or mge-utalk" -"MGE UPS SYSTEMS" "ups" "5" "Pulsar EXtreme C" "" "mge-shut or oldmge-shut or mge-utalk" +"MGE UPS SYSTEMS" "ups" "5" "NOVA AVR 600 Serial" "" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "NOVA AVR 1100 Serial" "" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Pulsar Ellipse USBS" "Serial cable" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Pulsar Ellipse S" "" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Pulsar Ellipse Premium USBS" "Serial cable" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Pulsar Ellipse Premium S" "" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Ellipse Office 600" "Serial cable" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Ellipse Office 750" "Serial cable" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Ellipse Office 1000" "Serial cable" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Ellipse Office 1500" "Serial cable" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Ellipse MAX 600" "Serial cable" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Ellipse MAX 850" "Serial cable" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Ellipse MAX 1100" "Serial cable" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Ellipse MAX 1500" "Serial cable" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Pulsar EXtreme C / EX RT" "" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Comet EX RT" "Serial port" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Comet EX RT 3:1" "Serial port" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Pulsar Esprit" "" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Evolution 650" "Serial port" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Evolution 850" "Serial port" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Evolution 1150" "Serial port" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Evolution S 1250" "Serial port" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Evolution 1550" "Serial port" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Evolution S 1750" "Serial port" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Evolution 2000" "Serial port" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Evolution S 2500" "Serial port" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Evolution S 3000" "Serial port" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Pulsar M 2200" "Serial port" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Pulsar M 3000" "Serial port" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Pulsar M 3000 XL" "Serial port" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Pulsar 700" "Serial port" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Pulsar 1000" "Serial port" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Pulsar 1500" "Serial port" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Pulsar 1000 RT2U" "Serial port" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Pulsar 1500 RT2U" "Serial port" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Pulsar MX 4000 RT" "Serial port" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Pulsar MX 5000 RT" "Serial port" "mge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Pulsar Evolution" "Serial port" "mge-shut or mge-utalk" +"MGE UPS SYSTEMS" "ups" "5" "Pulsar EXtreme C" "" "mge-shut or mge-utalk" "MGE UPS SYSTEMS" "ups" "5" "Pulsar ES+" "" "mge-utalk" "MGE UPS SYSTEMS" "ups" "5" "Pulsar ESV+" "" "mge-utalk" "MGE UPS SYSTEMS" "ups" "5" "Pulsar SV" "" "mge-utalk" @@ -678,7 +798,7 @@ "MGE UPS SYSTEMS" "ups" "5" "Pulsar EXtreme" "" "mge-utalk" "MGE UPS SYSTEMS" "ups" "5" "Comet EXtreme" "" "mge-utalk" "MGE UPS SYSTEMS" "ups" "5" "Comet / Galaxy (Serial)" "Utalk Serial Card (ref 66060)" "mge-utalk" -"MGE UPS SYSTEMS" "ups" "5" "Comet / Galaxy (Serial)" "HID COM Serial Card (ref 66066)" "mge-shut or oldmge-shut" +"MGE UPS SYSTEMS" "ups" "5" "Comet / Galaxy (Serial)" "HID COM Serial Card (ref 66066)" "mge-shut" "MGE UPS SYSTEMS" "ups" "5" "Pulsar / Comet / Galaxy (SNMP)" "SNMP/Web Transverse card (ref 66074)" "snmp-ups (experimental)" "MGE UPS SYSTEMS" "ups" "5" "various models (XML/HTTP mode)" "NMC Minislot (Ref 66102)" "netxml-ups (experimental)" "MGE UPS SYSTEMS" "ups" "5" "various models (SNMP mode)" "NMC Minislot (Ref 66102)" "snmp-ups (experimental)" @@ -751,10 +871,14 @@ "Nitram" "ups" "1" "Elite 2002" "" "genericups upstype=16" "Nitram" "ups" "1" "Elite 2005" "" "powerpanel" +"nJoy" "ups" "2" "Keen 600" "USB" "blazer_ser port=/dev/ttyUSB0" # https://www.njoy.ro/UPS/keen-600 +"nJoy" "ups" "2" "Keen 600" "USB" "nutdrv_qx port=/dev/ttyUSB0" # https://www.njoy.ro/UPS/keen-600 +"nJoy" "ups" "3" "Aten PRO 3000" "SNMP" "snmp-ups" # At least basic status is served; https://www.njoy.global/product/aten-pro-3000 + "Novex" "ups" "1" "NUPS-650" "USB" "blazer_usb protocol=megatec" # http://komp.1k.by/periphery-ups/novex/Novex_NUPS_650-130052.html "Numeric" "ups" "2" "3000 SW" "" "blazer_ser" -"Numeric" "ups" "2" "Digital 800 plus" "USB" "blazer_usb" +"Numeric" "ups" "2" "Digital 800 plus" "USB" "nutdrv_qx or blazer_usb" "Oneac" "ups" "1" "ON400" "advanced interface" "oneac" "Oneac" "ups" "1" "ON600" "advanced interface" "oneac" @@ -778,16 +902,24 @@ "Online" "ups" "2" "Zinto A" "" "blazer_usb" "Online" "ups" "1" "Zinto D" "" "optiups" "Online" "ups" "2" "Yunto YQ450" "" "blazer_usb" +"Online" "ups" "2" "Xanto S700" "/dev/ttyUSB0" "nutdrv_qx" # https://github.com/networkupstools/nut/issues/1279 "OnLite" "ups" "2" "AQUA" "50" "blazer_ser" "Opti-UPS" "ups" "1" "PowerES" "420E" "optiups" "Opti-UPS" "ups" "1" "VS 575C" "type=OPTI" "powercom" +"Opti-UPS" "ups" "1" "Power Series" "PS1500E" "blazer_usb" "Orvaldi Power Protection" "ups" "2" "various" "not 400 or 600" "blazer_ser" "Orvaldi Power Protection" "ups" "2" "750 / 900SP" "" "blazer_usb" "Phasak" "ups" "2" "400VA / 600VA" "" "blazer_ser" +"Phasak" "ups" "2" "9465 or P6N" "USB" "nutdrv_qx" # https://github.com/networkupstools/nut/issues/1187 => Voltronic-QS-Hex protocol detected + +"PhoenixContact" "ups" "4" "QUINT-UPS/24DC" "2320461" "phoenixcontact_modbus" #https://www.phoenixcontact.com/online/portal/us?uri=pxc-oc-itemdetail:pid=2320461 + +"PiJuice" "ups" "5" "PiJuice HAT" "" "pijuice" # https://github.com/PiSupply/PiJuice/issues/124 +"PiJuice" "ups" "5" "PiJuice Zero pHAT" "" "pijuice" "Plexus" "ups" "2" "500VA" "USB" "blazer_usb" "Plexus" "ups" "2" "1000VA Pro" "USB" "blazer_usb" @@ -812,6 +944,14 @@ "Powercom" "ups" "5" "(various)" "USB (2009 models, product id: 00a?)" "usbhid-ups (experimental)" "Powercom" "ups" "5" "BNT-xxxAP" "USB (product id: 0004)" "usbhid-ups (experimental)" "Powercom" "ups" "1" "BNT-xxxAP" "USB (product id: 0001)" "usbhid-ups (experimental)" +"Powercom" "ups" "3" "RPT-600AP" "USB" "usbhid-ups" # http://pcmups.com.tw/eA/html/product/show.php?num=226&root=13&kind=105&page=1&keyword= https://github.com/networkupstools/nut/issues/633 +"Powercom" "ups" "3" "Raptor 2000" "USB" "usbhid-ups" # https://github.com/networkupstools/nut/issues/633 + +"Powercool" "ups" "1" "350VA to 1600VA" "USB" "nutdrv_atcl_usb" +"Powercool" "ups" "2" "650VA" "USB" "nutdrv_qx port=auto vendorid=0001 productid=0000 product=MEC0003 protocol=hunnox langid_fix=0x0409 novendor noscanlangid" # https://github.com/networkupstools/nut/pull/638 caveats at https://github.com/networkupstools/nut/issues/537 +"Powercool" "ups" "2" "650VA" "USB" "nutdrv_qx port=auto vendorid=0001 productid=0000 bus=001 product=MEC0003 protocol=hunnox langid_fix=0x0409 novendor norating noscanlangid" # https://github.com/networkupstools/nut/pull/638 caveats at https://github.com/networkupstools/nut/issues/537 +"Powercool" "ups" "2" "1500VA" "USB" "nutdrv_qx port=auto vendorid=0001 productid=0000 product=MEC0003 protocol=hunnox langid_fix=0x0409 novendor noscanlangid" # https://github.com/networkupstools/nut/pull/638 caveats at https://github.com/networkupstools/nut/issues/537 - e.g. battery percentage is not being returned +"Powercool" "ups" "2" "2000VA" "USB" "nutdrv_qx port=auto vendorid=0001 productid=0000 product=MEC0003 protocol=hunnox langid_fix=0x0409 novendor noscanlangid" # https://github.com/networkupstools/nut/pull/638 caveats at https://github.com/networkupstools/nut/issues/537 "POWEREX" "ups" "2" "VI 1000 LED" "" "blazer_usb" @@ -839,6 +979,18 @@ "PowerWalker" "ups" "2" "Line-Interactive VI 850 LCD" "" "blazer_usb" "PowerWalker" "ups" "2" "Online VFI 1000RT/1500RT/2000RT/3000RT/6000RT/10000RT LCD" "" "blazer_usb" "PowerWalker" "ups" "2" "Line-Interactive VI 1000RT/1500RT/2000RT/3000RT LCD" "" "blazer_usb" +"PowerWalker" "ups" "2" "VFI 1000 CG PF1" "" "nutdrv_qx" # https://powerwalker.com/?page=product&item=10122108&lang=en +"PowerWalker" "ups" "2" "VFI 2000 TGS" "USB" "usbhid-ups" # https://github.com/networkupstools/nut/issues/560 and https://github.com/networkupstools/nut/pull/564 +"PowerWalker" "ups" "2" "VI 650 SH" "USB" "usbhid-ups" # https://github.com/networkupstools/nut/issues/483 +"PowerWalker" "ups" "2" "VI 650/850 SHL" "USB" "usbhid-ups" # https://github.com/networkupstools/nut/issues/646 +"PowerWalker" "ups" "2" "VI 1200 SHL" "USB" "usbhid-ups" # https://github.com/networkupstools/nut/issues/1270 +"PowerWalker" "ups" "2" "VI 2200 SHL" "USB" "usbhid-ups" # https://github.com/networkupstools/nut/issues/756 +"PowerWalker" "ups" "2" "VI 1200 SH" "USB" "usbhid-ups" # https://github.com/networkupstools/nut/issues/646 +"PowerWalker" "ups" "2" "VI 2200 SH" "USB" "usbhid-ups" # https://github.com/networkupstools/nut/issues/646 +"PowerWalker" "ups" "2" "Basic VI 1000 SB" "USB" "usbhid-ups" # https://github.com/networkupstools/nut/issues/818 +"PowerWalker" "ups" "2" "PR1500LCDRT2U" "USB" "usbhid-ups" # https://github.com/networkupstools/nut/issues/818 +"PowerWalker" "ups" "2" "VI 3000 SCL" "USB" "blazer_usb" # https://github.com/networkupstools/nut/issues/971 +"PowerWalker" "ups" "2" "VI 750T/HID" "USB" "usbhid-ups" # https://powerwalker.com/?page=select&cat=VI_THID&lang=en https://github.com/networkupstools/nut/issues/774 "Powerware" "ups" "4" "3110" "" "genericups upstype=7" "Powerware" "ups" "4" "3115" "" "genericups upstype=11" @@ -868,6 +1020,7 @@ "Raritan" "pdu" "3" "Intelligent PDU - Dominion PX" "no report, but should be supported" "snmp-ups (experimental)" "Raritan" "pdu" "3" "Metered PDU - Raritan PM" "no report, but should be supported" "snmp-ups (experimental)" "Raritan" "pdu" "3" "Switched PDU - Raritan RPC" "no report, but should be supported" "snmp-ups (experimental)" +"Raritan" "pdu" "3" "Dominion PX2" "" "snmp-ups" "REDi" "ups" "2" "Blazer 400VA / 600VA / 800VA" "" "blazer_ser" @@ -877,8 +1030,8 @@ "Riello" "ups" "3" "Riello Sentinel SDL 6000-7" "Netman Plus 102 SNMP Card" "snmp-ups" "Riello" "ups" "3" "Riello Sentinel Dual SDH 1000-7" "Netman Plus 102 SNMP Card" "snmp-ups" -"Riello" "ups" "5" "IDG 400/600/800/1200/1600" "" "riello_usb" -"Riello" "ups" "5" "IPG 600/800" "" "riello_usb" +"Riello" "ups" "4" "IDG 400/600/800/1200/1600" "" "riello_usb" +"Riello" "ups" "4" "IPG 600/800" "" "riello_usb" "Riello" "ups" "5" "WPG 400/600/800" "" "riello_usb" "Riello" "ups" "5" "NPW 600/800/1000/1500/2000" "" "riello_usb" "Riello" "ups" "5" "NDG 800/1000/1500/2000" "" "riello_usb" @@ -918,10 +1071,37 @@ "Rucelf" "ups" "2" "Rucelf UPOII-3000-96-EL" "" "blazer_ser" # http://www.rucelf.ua/en/catalog/upoii-3000-96-el/ +"Salicru" "ups" "2" "SPS ONE 700VA" "USB" "blazer_usb" +"Salicru" "ups" "2" "SPS ONE 2000VA" "USB" "nutdrv_qx" # https://www.salicru.com/en/ups/sps-one.html https://github.com/networkupstools/nut/issues/554 +"Salicru" "ups" "2" "SPS 650/850 HOME" "usb" "usbhid-ups (experimental)" +"Salicru" "ups" "2" "SLC TWIN PRO2" "usb" "usbhid-ups (experimental)" # https://github.com/networkupstools/nut/issues/450 +"Salicru" "ups" "2" "SLC-1500-TWIN PRO3" "usb" "usbhid-ups (experimental)" # https://github.com/networkupstools/nut/issues/1142 +"Salicru" "ups" "2" "SLC TWINPRO3" "usb" "usbhid-ups (experimental)" +"Salicru" "ups" "2" "SLC TWIN RT3" "usb" "usbhid-ups (experimental)" + +"Santak" "ups" "2" "Castle C*K" "Serial" "blazer_ser" # https://github.com/networkupstools/nut/issues/1039 +"Santak" "ups" "2" "MT*-PRO" "Serial" "blazer_ser" # https://github.com/networkupstools/nut/issues/1039 + +"Siemens" "ups" "4" "SITOP UPS500" "serial" "nutdrv_siemens_sitop (experimental, untested)" +"Siemens" "ups" "4" "SITOP UPS500" "USB" "nutdrv_siemens_sitop (experimental)" + "SmartLabs" "pdu" "1" "2412S Power Line Modem" "for X10/Insteon" "powerman-pdu (experimental)" "SMS (Brazil)" "ups" "2" "Manager III" "" "blazer_ser" +"SNR" "ups" "2" "SNR-UPS-LID-600" "" "nutdrv_qx" +"SNR" "ups" "2" "SNR-UPS-LID-600-XPS" "" "nutdrv_qx" +"SNR" "ups" "2" "SNR-UPS-LID-600-LED-C13" "" "nutdrv_qx" +"SNR" "ups" "2" "SNR-UPS-LID-600-LED-C13-PRO" "" "nutdrv_qx" +"SNR" "ups" "2" "SNR-UPS-LID-800" "" "nutdrv_qx" +"SNR" "ups" "2" "SNR-UPS-LID-800-LED-С13" "" "nutdrv_qx" +"SNR" "ups" "2" "SNR-UPS-LID-1000-XPS" "" "nutdrv_qx" +"SNR" "ups" "2" "SNR-UPS-LID-1200" "" "nutdrv_qx" +"SNR" "ups" "2" "SNR-UPS-LID-1500" "" "nutdrv_qx" +"SNR" "ups" "2" "SNR-UPS-LID-2000" "" "nutdrv_qx" +"SNR" "ups" "2" "SNR-UPS-LID-2000-XPS" "" "nutdrv_qx" +"SNR" "ups" "2" "SNR-UPS-LID-3000-XPS" "" "nutdrv_qx" + "SOLA" "ups" "1" "305" "cable INT-0025C" "genericups upstype=7" "SOLA" "ups" "1" "325" "" "blazer_ser or bestups" "SOLA" "ups" "1" "520" "" "blazer_ser or bestups" @@ -962,11 +1142,13 @@ "Sweex" "ups" "2" "INTELLIGENT UPS 1500VA P220" "USB" "blazer_usb (USB ID 0665:5161)" # http://www.sweex.com/en/notebook-pc-accessoires/ups/PP220/ "Syndome" "ups" "2" "Era 500VA" "USB" "blazer_usb" +"Syndome" "ups" "2" "Atom LCD-1000" "USB" "usbhid-ups" # https://github.com/networkupstools/nut/issues/483 "Sysgration" "ups" "2" "UPGUARDS Pro650" "" "blazer_ser" "Tecnoware" "ups" "2" "Easy Power 1200" "" "blazer_ser" -"Tecnoware" "ups" "2" "UPS ERA LCD 0.65" "" "blazer_usb langid_fix=0x409" +"Tecnoware" "ups" "2" "UPS ERA LCD 0.65" "USB" "blazer_usb langid_fix=0x409" +"Tecnoware" "ups" "2" "UPS ERA PLUS 1100" "USB" "blazer_usb" # https://www.tecnoware.com/Prodotti/FGCERAPL1100/ups-era-plus-1100.aspx https://github.com/networkupstools/nut/issues/747 "Tripp Lite" "ups" "1" "(various)" "Lan 2.2 interface - black 73-0844 cable" "genericups upstype=5" "Tripp Lite" "ups" "2" "1500 LCD" "USB" "usbhid-ups" @@ -1068,7 +1250,8 @@ "Tripp Lite" "ups" "3" "SMX3000RT2UTAA" "USB (protocol 3015)" "usbhid-ups" # http://www.tripplite.com/en/products/model.cfm?txtModelID=4396 "Tripp Lite" "ups" "3" "SMX3000XLRT2U" "USB (protocol 3015)" "usbhid-ups" # http://www.tripplite.com/en/products/model.cfm?txtSeriesID=933&txtModelID=2694 "Tripp Lite" "ups" "3" "SMX3000XLRT2UA" "USB (protocol 3015)" "usbhid-ups" # http://www.tripplite.com/en/products/model.cfm?txtModelID=5658 -"Tripp Lite" "ups" "3" "SMX500RT1U" "USB (protocol 3005)" "usbhid-ups" # http://www.tripplite.com/en/products/model.cfm?txtModelID=2691 +"Tripp Lite" "ups" "3" "SMX500RT1U" "USB (older; product ID 0001, protocol 3005)" "tripplite_usb" # https://www.tripplite.com/support/product/part-number/SMX500RT1U https://github.com/networkupstools/nut/pull/584 +"Tripp Lite" "ups" "3" "SMX500RT1U" "USB (newer; protocol/product ID 3005)" "usbhid-ups" # https://www.tripplite.com/support/product/part-number/SMX500RT1U "Tripp Lite" "ups" "3" "SMX750SLT" "USB (protocol 3014)" "usbhid-ups" # http://www.tripplite.com/en/products/model.cfm?txtModelID=3021 "Tripp Lite" "ups" "3" "SU750RTXL2U" "USB (protocol 4001)" "usbhid-ups" # http://www.tripplite.com/en/products/model.cfm?txtModelID=3194 "Tripp Lite" "ups" "3" "SU750RTXLCD2U" "USB (protocol 4004)" "usbhid-ups" # http://www.tripplite.com/en/products/model.cfm?txtModelID=5070 @@ -1119,6 +1302,8 @@ "UPSonic" "ups" "2" "PrOffice 650" "USB" "blazer_usb" "UPSonic" "ups" "2" "DS-800" "USB" "blazer_usb" +"V7" "ups" "2" "UPS1RM2U1500-1E" "USB" "blazer_usb" # http://www.v7world.com/uk/ups-1500va-rack-mount-2u-eu.html https://github.com/networkupstools/nut/issues/716 + "Various" "ups" "4" "(various)" "SEC protocol" "gamatronic" "Various" "ups" "1" "(various)" "Generic RUPS model" "genericups upstype=4" "Various" "ups" "1" "(various)" "Generic RUPS 2000 (Megatec M2501 cable)" "genericups upstype=21" @@ -1149,6 +1334,8 @@ "Voltronic Power" "ups" "2" "Frigate TX 1KVA" "USB" "nutdrv_qx" "Voltronic Power" "ups" "2" "Galleon 1KVA" "Serial" "nutdrv_qx" "Voltronic Power" "ups" "2" "Galleon 1KVA" "USB" "nutdrv_qx" +"Voltronic Power" "ups" "2" "Galleon X9-RT LCD-1-3K" "USB" "blazer_usb" # https://github.com/networkupstools/nut/issues/1251 +"Voltronic Power" "ups" "2" "Galleon X9-RT LCD-1-3K" "USB" "nutdrv_qx" # https://github.com/networkupstools/nut/issues/1251 "Voltronic Power" "ups" "2" "Imperial 1KVA" "Serial" "nutdrv_qx" "Voltronic Power" "ups" "2" "Imperial 1KVA" "USB" "nutdrv_qx" "Voltronic Power" "ups" "2" "Prosine 800" "Serial" "nutdrv_qx" diff --git a/data/html/Makefile.am b/data/html/Makefile.am index 956e66b..4d0620a 100644 --- a/data/html/Makefile.am +++ b/data/html/Makefile.am @@ -1,7 +1,11 @@ -# Network UPS Tools: data/html +# Network UPS Tools: data/html # install these only if configured --with-cgi if WITH_CGI dist_html_DATA = index.html bottom.html nut-banner.png nodist_html_DATA = header.html endif EXTRA_DIST = README + +MAINTAINERCLEANFILES = Makefile.in .dirstamp +# Generated by configure script: +DISTCLEANFILES = header.html diff --git a/data/html/Makefile.in b/data/html/Makefile.in index f455c4a..30cdd21 100644 --- a/data/html/Makefile.in +++ b/data/html/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.16.3 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -15,7 +15,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -80,19 +90,24 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = data/html -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(srcdir)/header.html.in $(am__dist_html_DATA_DIST) README ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nut_arg_with.m4 \ $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ $(top_srcdir)/m4/nut_check_libavahi.m4 \ $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ $(top_srcdir)/m4/nut_check_libgd.m4 \ $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ $(top_srcdir)/m4/nut_check_libneon.m4 \ $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ $(top_srcdir)/m4/nut_check_libnss.m4 \ @@ -101,11 +116,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ $(top_srcdir)/m4/nut_check_libusb.m4 \ $(top_srcdir)/m4/nut_check_libwrap.m4 \ $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ $(top_srcdir)/m4/nut_type_socklen_t.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__dist_html_DATA_DIST) \ + $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = header.html @@ -160,6 +182,8 @@ am__uninstall_files_from_dir = { \ am__installdirs = "$(DESTDIR)$(htmldir)" "$(DESTDIR)$(htmldir)" DATA = $(dist_html_DATA) $(nodist_html_DATA) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/header.html.in \ + README DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) A2X = @A2X@ ACLOCAL = @ACLOCAL@ @@ -168,6 +192,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -178,6 +203,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -191,6 +217,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -203,6 +230,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -220,6 +248,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -230,21 +260,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -264,6 +302,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -277,6 +318,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -294,6 +336,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -307,6 +350,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -332,12 +378,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -348,11 +396,14 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ udevdir = @udevdir@ -# Network UPS Tools: data/html +# Network UPS Tools: data/html # install these only if configured --with-cgi @WITH_CGI_TRUE@dist_html_DATA = index.html bottom.html nut-banner.png @WITH_CGI_TRUE@nodist_html_DATA = header.html EXTRA_DIST = README +MAINTAINERCLEANFILES = Makefile.in .dirstamp +# Generated by configure script: +DISTCLEANFILES = header.html all: all-am .SUFFIXES: @@ -368,14 +419,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu data/html/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu data/html/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -443,7 +493,10 @@ ctags CTAGS: cscope cscopelist: -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -506,10 +559,12 @@ clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am @@ -592,6 +647,8 @@ uninstall-am: uninstall-dist_htmlDATA uninstall-nodist_htmlDATA tags-am uninstall uninstall-am uninstall-dist_htmlDATA \ uninstall-nodist_htmlDATA +.PRECIOUS: Makefile + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/data/html/header.html.in b/data/html/header.html.in index 6f7f1ff..6e222a5 100644 --- a/data/html/header.html.in +++ b/data/html/header.html.in @@ -1,7 +1,7 @@ -Network UPS Tools +Network UPS Tools diff --git a/depcomp b/depcomp index 4ebd5b3..6b39162 100755 --- a/depcomp +++ b/depcomp @@ -1,9 +1,9 @@ #! /bin/sh # depcomp - compile a program generating dependencies as side-effects -scriptversion=2013-05-30.07; # UTC +scriptversion=2018-03-07.03; # UTC -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999-2020 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ scriptversion=2013-05-30.07; # UTC # GNU General Public License for more details. # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -783,9 +783,9 @@ exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: diff --git a/docs/FAQ.txt b/docs/FAQ.txt index 81c93df..9c59f10 100644 --- a/docs/FAQ.txt +++ b/docs/FAQ.txt @@ -4,8 +4,8 @@ NUT Frequently Asked Questions endif::external_title[] == I just upgraded, and ... -You have read link:UPGRADING[UPGRADING] in the base directory of the distribution, -right? +You have read link:UPGRADING[UPGRADING] in the base directory of the +distribution, right? If not, go read it now, then come back to this file if your question wasn't answered in there. @@ -38,7 +38,7 @@ already been done in the old version. The drivers drop root privileges long before the serial port is opened. You'll need to change the permissions on that port so that -their new user id can access it. Normally this is "nobody", but it +their new user id can access it. Normally this is "nobody", but it may be changed at compile-time by using configure --with-user. Read the error message. If you have a permissions mismatch, then @@ -47,12 +47,12 @@ you'll see something like this: Network UPS Tools - APC Smart protocol driver 0.60 (1.1.7) This program is currently running as youruid (UID 1234) /dev/ttyS2 is owned by user root (UID 0), mode 0600 - Change the port name, or fix the permissions or ownership + Change the port name, or fix the permissions or ownership of /dev/ttyS2 and try again. Unable to open /dev/ttyS2: Permission denied Now is a good time to point out that using "nobody" is a bad idea, -since it's a hack for NFS access. You should create a new role +since it's a hack for NFS access. You should create a new role account (perhaps called "ups" or "nut"), and use that instead. Also, scroll down to the "security domains" question to see an @@ -88,16 +88,16 @@ Refer to the upsd(8) and upsd.conf(5) manpages for more information. == I get a 'not listening on...' error from upsd. -Verify your LISTEN directive. It should be one of the valid IP addresses for -the computer running upsd (or 0.0.0.0, which is INADDR_ANY), not an address for -a client. +Verify your LISTEN directive. It should be one of the valid IP addresses +for the computer running `upsd` (or `0.0.0.0`, which is `INADDR_ANY`), not +an address for a client. -The LISTEN directive lets you pick which interface upsd listens on. If you are -trying to limit the clients which can connect to upsd, you either need to use -tcp-wrappers or kernel firewall rules. +The LISTEN directive lets you pick which interface `upsd` listens on. +If you are trying to limit the clients which can connect to `upsd`, +you either need to use tcp-wrappers or kernel firewall rules. -This isn't a NUT-specific limitation - it applies equally to your web server or -mailer daemon. +This isn't a NUT-specific limitation -- it applies equally to your web server +or mailer daemon. == Which UPS should I buy? @@ -112,13 +112,13 @@ hardware for testing, results of their testing efforts, or protocol specifications. We try to publish this information on the NUT website, so you can take this into consideration when selecting an UPS brand. -== I have an APC Smart-UPS connected with a grey APC serial cable and it won't work. +== I have an APC Smart-UPS connected with a grey APC serial cable and it won't work. The Back-UPS type in the genericups driver works but then I don't get to use all the nifty features in there. Why doesn't the right driver work? The problem lies in your choice of cable. APC's grey cables -generally only do "dumb" signalling - very basic yes/no info about +generally only do "dumb" signalling -- very basic yes/no info about the battery and line status. While that is sufficient to detect a low battery condition while on battery, you miss out on all the goodies that you paid for. @@ -138,9 +138,10 @@ If your grey cable isn't the 940-0095B, the solution is to dump that cable and find one that supports APC's "smart" signalling. Typically these come with the UPS and are black. If your smart cable has wandered off, one can be built rather easily with some connectors and -cable - there's no fancy wiring or resistors. +cable -- there's no fancy wiring or resistors. -See this URL for a handy diagram: http://www.networkupstools.org/cables/940-0024C.jpg +See this URL for a handy diagram: +http://www.networkupstools.org/cables/940-0024C.jpg There is also a text version of that diagram in the docs/cables directory of the NUT source distribution. Either one should allow @@ -176,8 +177,8 @@ Besides, if upsmon were rolled into upsd, upsd would get even bigger than it is now. You'd have one less process, but the RAM consumption would be pretty close to now. -See the "Data Room" section in docs/config-notes.txt for more configuration -ideas and explanations. +See the "Data Room" section in link:docs/config-notes.txt[] for +more configuration ideas and explanations. *Answer 2* @@ -185,7 +186,7 @@ If this really bothers you, roll up your sleeves and use the sockdebug code to write a "upsmon" type program that sits on top of the state sockets. It won't work over the network, but it means you don't need upsd. It also means only one host can monitor the -UPS. +UPS. This is also a good option to consider if you can't use networked monitoring code for security or safety reasons. @@ -206,7 +207,7 @@ It is also coherent with the answer to the previous question. *Answer 1* New versions of the init man page taken from the sysvinit package -are saying that usage of SIGPWR is discouraged, since /dev/initctl +are saying that usage of SIGPWR is discouraged, since /dev/initctl control channel is the preferred way of communication. *Answer 2* @@ -253,16 +254,16 @@ directly affects how long you run on battery without knowing what's going on with the UPS. Note: some drivers occasionally need more time to update than the -default value of MAXAGE (in upsd.conf) allows. As a result, they +default value of MAXAGE (in upsd.conf) allows. As a result, they are temporarily marked stale even though everything is fine. This -can happen with MGE Ellipse equipment - see the mge-shut or usbhid-ups man +can happen with MGE Ellipse equipment -- see the mge-shut or usbhid-ups man pages. In such cases, you can raise the value of MAXAGE to avoid these warnings; try a value like 25 or 30. == Why do the client programs say 'Driver not connected' when I try to run them? This means that upsd can't connect to the driver for some reason. -Your ups.conf entry might be wrong, or the driver might not be +Your ups.conf entry might be wrong, or the driver might not be running. Maybe your state path is not configured properly. Check your syslog. upsd will complain regularly if it can't @@ -272,6 +273,12 @@ Note: if you jumped in with both feet and didn't follow the INSTALL.nut document, you probably started upsd by itself. You have to run 'upsdrvctl start' to start the drivers after configuring ups.conf. +On operating systems with a supported service management framework, +you might wrap your NUT drivers into individual services instances +with 'upsdrvsvcctl resync' and then manage those with commands like +'upsdrvsvcctl stop' and 'upsdrvsvcctl start' (note that on other +systems this tool may be not pre-installed via packaging). + == Why don't the pathnames in your documentation match the package I installed? Each distribution has conventions for where specific file types should be @@ -298,11 +305,14 @@ that point. You *want* the system to die without reaching the part where the kernel tells it to shut down. A possible script might look like this: +------ # other shutdown stuff here (mount -o remount,ro ...) + # `upsmon -K` if available on still mounted filesystems + # at this point is more portable than the `test` below if (test -f /etc/killpower) then - /usr/local/ups/sbin/upsdrvctl shutdown + /sbin/upsdrvctl shutdown sleep 600 # this should never return @@ -311,6 +321,7 @@ might look like this: fi halt -p +------ The other solution is to change your BIOS setting to "always power on" instead of "last state", assuming that's possible. @@ -323,8 +334,8 @@ things depending on what's supported: - Set a jumper on the motherboard that means "return after outage" - Set something in the BIOS that says "power up after power failure" -- Try using something (like a capacitor) across the power button - to "push" it for you - this might not work if it needs a delay +- Try using something (like a capacitor) across the power button + to "push" it for you -- this might not work if it needs a delay - Hack the cable between the power supply and the motherboard to fool it into powering up whenever line power is present - Teach a monkey to watch the machine and press the power button @@ -342,14 +353,15 @@ cat some magic characters at /dev/adb to enable "server mode". This would instruct the system to reboot while unattended. From Usenet post <6boftzxz51.fsf@ecc-office.sp.cs.cmu.edu>: - +------ # Send packet over the ADB bus to the PowerMac CUDA chip # telling it to reboot automatically when power is restored # after a power failure. cat /etc/local/autoboot.adb > /dev/adb - autoboot.adb contains these three bytes (in hex): 01 13 01 + # autoboot.adb contains these three bytes (in hex): 01 13 01 +------ Later PowerPC Macs with a PMU and the appropriate kernel driver can achieve the same effect with the following command: @@ -363,11 +375,11 @@ use of `setpci`, and are highly model-specific: - http://superuser.com/questions/212434/reboot-after-power-failure-for-mac-running-ubuntu - http://ubuntuforums.org/showthread.php?t=1209576 -Note: this question has been in the FAQ for several years now, and +Note: this question has been in the FAQ for several years now, and there's still no clean answer. Let me guess: everyone who runs a server on Mac hardware has a team of trained monkeys, and feeds them by growing bananas in the tropical environment formed by waste heat -from the equipment. +from the equipment. The rest of us are still waiting for the answer. Booting into the Mac OS to frob the "file server" panel is not an acceptable @@ -404,7 +416,7 @@ For my development system this yields the following /dev entries: - Switch to root, then start the drivers: - # /usr/local/ups/sbin/upsdrvctl -u nutdev start + # upsdrvctl -u nutdev start - The listing for /var/state/ups then looks like this: @@ -428,14 +440,14 @@ make the files owned by root.nut, with mode 0640. Once the config files are ready, start upsd: - # /usr/local/ups/sbin/upsd -u nutsrv + # upsd -u nutsrv Check your syslog to be sure everything's happy, then be sure to update your startup scripts so it uses this procedure on your next boot. If you like this, you'll probably also find the chroot process to -be useful and interesting. See security.txt for more details. +be useful and interesting. See link:security.txt[] for more details. == What's the point of that 'security domains' concept above? @@ -445,12 +457,12 @@ to that one user account. Direct access to the serial device is not possible, since that is owned by another user. There is also the possibility of running the drivers and upsd in a -chroot jail. See the chroot.txt provided in the source -distribution for an example implementation. +chroot jail. See the chroot option in link:security.txt[], `upsd` +and driver documentation. Why give would-be vandals any sort of help? -Put it this way - I *wrote* good chunks of this stuff, and I still +Put it this way -- I *wrote* good chunks of this stuff, and I still run the programs this way locally. You should definitely consider using this technique. @@ -458,8 +470,8 @@ using this technique. You probably don't want to do this, since it doesn't maximize your runtime on battery. Assuming you have a good reason for it (see -the next entry), then look at scheduling.txt or the upssched(8) man -page for some ideas. +the next entry), then look at link:scheduling.txt[] or the +linkman:upssched[8] man page for some ideas. ///////////////////////////////////////////////////////////////// TODO: figure out how to link to the upssched man page above. @@ -487,17 +499,17 @@ with no visible interruption in service. If you purposely shut down early, you guarantee an interruption in service by bringing down the box. -See upssched.txt for information on how you can shutdown early if +See link:upssched.txt[] for information on how you can shutdown early if this is what you really want to do. -== The CGI programs report 'access to that host is not authorized' - what's going on? +== The CGI programs report 'access to that host is not authorized' -- what's going on? Those programs need to see a host in your hosts.conf before they will attempt communications. This keeps people from feeding it random "host=" settings, which would annoy others with outgoing connection attempts from your system. -If your hosts.conf turns out to be configured correctly with +If your hosts.conf turns out to be configured correctly with MONITOR entries and all that, check the permissions. Your web server may be running the CGI programs as a user that can't read the file. @@ -505,7 +517,7 @@ the file. If you run your web server in a chroot jail, make sure the programs can still read hosts.conf. You may have to copy it into the jail for this to work. If you do that, make sure it's not writable by -any of the user accounts which run inside the jail. +any of the user accounts which run inside the jail. == upsd is running, so why can't I connect to it? @@ -526,7 +538,7 @@ Either find the pid of the background process and send it a SIGHUP, or just start it again with '-c reload'. If you send the signals yourself instead of using -c, be sure you -hit the right process. There are usually two upsmons, and you +hit the right process. There are usually two upsmon processes, and you should only send signals to one of them. To be safe, read the pid file. @@ -537,17 +549,42 @@ There are several driver to support USB models. - usbhid-ups supports various manufacturers complying to the HID Power Device Class (PDC) standard, - tripplite_usb supports various older Tripp-Lite units (with USB ProductID 0001) - bcmxcp_usb supports various Powerware units, -- nutdrv_qx and blazer_usb support various manufacturers that use the Megatec / Q1 protocol. +- blazer_usb supports various manufacturers that use the Megatec / Q1 protocol. +- nutdrv_qx supports various manufacturers that use the Megatec / Q* protocol + family. This is the driver slated to receive all further development in this + area, it was specially designed to support many more sub-drivers and has + added a lot over time, so please do try it first nowadays. -Refer to the 'driver-name' (8) manpage for more information. +Refer to the 'driver-name' (8) man page for more information. You can also consult the Hardware Compatibility List (HCL) and filter on USB: http://www.networkupstools.org/stable-hcl.html?connection=USB +== My USB UPS has a bogus Vendor ID 0x0001 and Product ID 0x0000, what driver supports it? + +Unfortunately, many devices are made without registering as a Vendor with +the corresponding standards body, and use generic USB chips for interfacing +with a computer (roughly similar to using a network interface card with a +random MAC address and PCI ID, and thus poorly identifiable device specifics +needed to automatically load some certain driver). Often they also lack a +unique serial number field, so monitoring several devices is problematic. + +One frequent case is with devices identifying as "Fry's Electronics" and/or +"MEC0003", if those data are served at all, or plain "0001/0000" in ID field. +In some cases they are accompanied by "UPSmart" software with a "MEGA(USB)" +connection option that works for Windows users. + +Your best bet is to search for community discussions of issues on NUT GitHub +at https://github.com/networkupstools/nut/issues?q=is%3Aissue and try options +there. Devices with these chips were known to connect with drivers for such +unrelated protocols as Megatec Q* (different sub-drivers, often `fabula` or +`hunnox`), ATCL, or USB-HID. + == My USB UPS is supported but doesn't work! -On Linux, udev rules are provided to set the correct permissions on device file. -This allows the NUT driver to communicate with the UPS, through this device file. +On Linux, udev rules are provided to set the correct permissions on device +file. This allows the NUT driver to communicate with the UPS, through this +device file. However, the driver may still fail to start and support the device, with a message like: @@ -567,7 +604,7 @@ Instead of unplugging, you might also be able to run `udevadm trigger There was a mistake in the naming of the NUT udev rules file which resulted in the rules being overridden by another udev configuration file. While this has been fixed in the Git master branch, your distribution may still be affected. -Details are available in the following Github issue: +Details are available in the following GitHub issue: https://github.com/networkupstools/nut/issues/140 == Why do you not use the Linux kernel HID driver when communicating with USB UPSes? @@ -596,6 +633,79 @@ There is a rudimentary locking mechanism in NUT, but there is a chance that the packages might not use the same directory as the NUT default, and the conflict will be reported by the kernel. +== Why does my (Eaton 5E) USB UPS on Linux connect but quickly disconnects soon? + +This issue was extensively investigated by NUT community members in +https://github.com/networkupstools/nut/issues/630 and resulted in a +chain of distribution bugs logged such as +https://bugzilla.redhat.com/show_bug.cgi?id=1715504 + +The gist of it is that some versions of Linux kernel used an "USB HID quirk" +for certain devices, see Linux kernel source `drivers/hid/hid-quirks.c` file, +including MGE/Eaton vendor ID (0x0463) based on an older device a contributor +had issues with. Firmware in newer devices no longer had the bug which needed +the "quirk" and misbehaved when it was enabled. While newer (and much older) +Linux kernels should not have the problem, with the quirk removed according +to https://lkml.org/lkml/2018/11/26/580 having the issue in the field really +depends on the combination of Linux kernel and device firmware that meet. + +Either way, it seems that problematic combinations preclude Linux from seeing +the device as a `hid-generic` first, to hand it over to a NUT driver. + +This quirk can be tuned with a kernel boot parameter (via GRUB etc.): + + usbhid.quirks=0x0463:0xffff:0x08 + +to re-enable the NOGET quirk. + +For context, according to https://bugzilla.redhat.com/show_bug.cgi?id=1875532 +the symptoms for the problem look like this: + + # Plug in the UPS and observe the dmesg logs, + # the following continuously appears: + [ 93.568082] usb 1-6: new full-speed USB device number 9 using xhci_hcd + [ 94.311469] usb 1-6: New USB device found, idVendor=0463, idProduct=ffff, bcdDevice= 0.01 + [ 94.311475] usb 1-6: New USB device strings: Mfr=1, Product=2, SerialNumber=0 + [ 94.311483] usb 1-6: Product: 5E + [ 94.311486] usb 1-6: Manufacturer: EATON + [ 96.269989] hid-generic 0003:0463:FFFF.000A: hiddev96,hidraw2: USB HID v1.10 Device [EATON 5E] on usb-0000:00:14.0-6/input0 + [ 107.369425] hid-generic 0003:0463:FFFF.000A: usb_submit_urb(ctrl) failed: -1 + [ 107.369469] hid-generic 0003:0463:FFFF.000A: timeout initializing reports + [ 112.828826] usb 1-6: USB disconnect, device number 9 + [ 113.284452] usb 1-6: new full-speed USB device number 10 using xhci_hcd + [ 114.027693] usb 1-6: New USB device found, idVendor=0463, idProduct=ffff, bcdDevice= 0.01 + [ 114.027698] usb 1-6: New USB device strings: Mfr=1, Product=2, SerialNumber=0 + [ 114.027701] usb 1-6: Product: 5E + [ 114.027704] usb 1-6: Manufacturer: EATON + [ 115.984222] hid-generic 0003:0463:FFFF.000B: hiddev96,hidraw2: USB HID v1.10 Device [EATON 5E] on usb-0000:00:14.0-6/input0 + [ 126.825756] hid-generic 0003:0463:FFFF.000B: usb_submit_urb(ctrl) failed: -1 + [ 126.825775] hid-generic 0003:0463:FFFF.000B: timeout initializing reports + [ 132.527809] usb 1-6: USB disconnect, device number 10 + +A similar report on the driver side may look like: + + usbhid-ups[4554]: libusb_get_report: Input/output error + upsd[4591]: Data for UPS [eaton] is stale - check driver + usbhid-ups[4554]: Can't claim USB device [0463:ffff]: No such file or directory + upsd[4591]: Can't connect to UPS [eaton] (usbhid-ups-eaton): No such file or directory + upsmon[5148]: Poll UPS [eaton@localhost] failed - Driver not connected + upsmon[5148]: Communications with UPS eaton@localhost lost + +Other similar looking issues may include improper setup of udev, upower +and similar frameworks to hand over the device from the OS to a driver +daemon; competition with other software probing USB devices (ModemManager +was mentioned in this context), including running several copies of the +NUT drivers trying to use same port (e.g. one started by services and +another manually as you tried to debug the problems). + +Software quirks aside, please do test with a different USB cable and/or port +on the computer. These were known to cause grief beyond what can be fixed +with a few key words ;) + +Finally, sometimes the issue is on the OS side (and/or USB chipset), to +the point that the USB driver can not be unloaded and re-attached until +you power cycle the system. + == Why doesn't my package work? Or a variation like... @@ -610,6 +720,79 @@ This means all packages have been built by a third party. If you have an issue that's related to packaging, you will need to seek help with whoever built it for you. +== My UPS is directly connected to an appliance with a limited version of NUT, how can I monitor the UPS from arbitrary clients? + +You can set up a separate general-purpose system as the NUT server for +your "arbitrary clients", using `dummy-ups` in "relay mode" as the driver. +This instance of `dummy-ups` would in turn be the NUT client allowed to +interact with the appliance and that way with the UPS connected there. + +NOTE: The original question related to a NAS with NUT provided in its +firmware OS, that only allowed one or few clients and not a whole +rack's worth of client IP addresses. + +== My networked UPS can't handle being monitored by dozens of NUT clients + +Network management cards on many UPSes are rather puny appliances, often +known to either limit the amount of clients who may connect, for security +or performance reasons, or otherwise to crash or respond very slowly when +overwhelmed. + +You may be better off reducing the amount of servers connected to the UPS +with the `snmp-ups`, `netxml-ups` or similar type of driver, and set up +other systems as clients of these NUT servers. + +Developers who are working on NUT, its drivers, or further projects and +appliances based on NUT, and who need to monitor their UPS from multiple +systems using the complete NUT stack on each system (e.g. during testing), +can benefit from dedicating a separate general-purpose system as the NUT +server using the real (networked) driver for the UPS, while using the +`dummy-ups` in "relay mode" as the driver connected to this dedicated +server on each tested system. + +== How can I setup NUT as a proxy (setup a server to forward/relay client data)? + +This can easily be achieved by using the `dummy-ups` driver. +The `port` field acts as the reference to the "other" UPS served +by another NUT server. + +Example with `dummy-ups` driver: + + [proxy] + driver = dummy-ups + port = upsname@ip-or-hostname[:port] + desc = "UPS proxy for UPS upsname on server ip-or-hostname" + +Also note that there is a `clone` driver with similar purpose, +which allows users to group clients to a particular outlet of +a device with a "real" driver running locally, and deal with +this output as if it was a normal UPS. + +Here the `port` field references the driver socket name that +the "real" UPS driver is using. See its manual page for more +details and caveats. + +Example with `clone` driver: + + [realups] + driver = usbhid-ups + port = auto + + [clone-outlet-1] + driver = clone + port = usbhid-ups-realups + load.on = outlet.1.load.on + load.off = outlet.1.load.off + load.status = outlet.1.status + [...] + +This allows to group load attached to a separately manageable +outlet (or group of outlets) on larger UPS and ePDUs, in order +to power those devices on/off together. This may be also useful +to delegate management of feeds to devices for purposes like +hosting or supporting hardware for smaller teams sharing a rack +in a larger company. + == Why are there two copies of upsmon running? It's not really two complete copies if your OS forks efficiently. @@ -635,7 +818,7 @@ incidentally what the official FreeBSD port of NUT does for all builds. == I have 'some problem' with 'some old version' ... Get the latest stable release, and see if it still happens. If it -goes away, it means someone else reported it and got it fixed a +goes away, it means someone else reported it and got it fixed a long time ago. You may want to search the mailing lists to see if someone else has @@ -645,20 +828,23 @@ into your distribution (potentially with unofficial packages). Some OS distributions contain old versions of NUT. If your hardware is newer than the NUT release, there is a good chance that support has not been added -yet. Please do not tell us you have the "latest version for Distro XYZ" - even +yet. Please do not tell us you have the "latest version for Distro XYZ" -- even if the developers are familiar with that distribution, it helps others if you quote the exact package version. NOTE: check the release date on the version you have. If it's more than about 6-12 months old, there's probably a newer stable tree -version out there. +version out there. As development happens actively, be sure to also +check if a custom build from Git (usually using the `master` branch +of NUT https://github.com/networkupstools/nut/ repository) has your +issue fixed by some kind soul already. == I built NUT from Git, and it complains about lots of missing files. What happened? If you are not actively developing a driver, can you use a snapshot instead? The NUT instance of Buildbot generates tar files of the latest NUT source -after each successful build, and these snapshots include a prebuilt version of -the `./configure` script. +after each successful build, and these snapshots include a pre-built version +of the `./configure` script. Otherwise, you will need recent versions of autoconf, automake, libtool, asciidoc, a2x and its dependencies for DocBook/dblatex. Rather than publish a @@ -673,7 +859,7 @@ and also SNMP and XML/HTTP (Eaton and MGE) communications. Since NUT is very extensible, support for a new communication bus can be added easily. - + Any time there is a gap in features, it's usually because the group of people who own that hardware and the group of people who write code don't overlap. The fix is to make them overlap - @@ -687,7 +873,12 @@ NUT. Changing the way a fundamental component works, such as USB support, means a lot of testing to ensure that your fix does not break other drivers. Sometimes patches are put on hold due to a feature freeze. If it -doesn't show up once the new version opens up, send it again. +doesn't show up once the new version opens up, please send it again. + +It may also be much more productive to submit changes as pull requests via +https://github.com/networkupstools/nut/pulls so they are automatically +processed by the NUT CI farm across numerous target platforms, and +various inconsistencies can be diagnosed and fixed early. == I'm not much of a programmer. How can I help? @@ -705,7 +896,7 @@ has already handled it successfully. == I replaced the battery in my APC Smart-UPS and now it thinks the battery is low all the time. How do you fix this? Or a variation like... - + == My APC UPS keeps reporting 'OL LB', even after it's been charging for many hours. What can I do about this? This happened to me, and some other people too. The combination of @@ -723,7 +914,7 @@ disconnect it from the computer so this software won't shut it down. The easiest way to do this is to first unplug your computer(s) from -it, and plug in a token load like a lamp. Also, move the UPS to a +it, and plug in a token load like a lamp. Also, move the UPS to a power strip that doesn't switch the ground line or an outlet that you can switch off at your panel. @@ -752,6 +943,8 @@ for you. There is a small chance that the mailing list spam filter ate your message. Check the list archives to see if your message appears there. +Also double-check that you have subscribed to the lists and completed +all the confirmation rituals of its engine. Convincing the other subscribers that you've actually read down this far might be useful. You might mention "queequeg" for better results. @@ -770,6 +963,10 @@ In addition, the mailing lists are publicly archived, and therefore easily searchable. Chances are, you aren't the only person who will ever have that question. +There are similar benefits to using the discussions on issue tracker at +https://github.com/networkupstools/nut/issues and if suitable, in the +currently open pull requests. + == If you want mailing list replies to go to the list, why don't you add a Reply-To: header? We are not going to rehash all of the arguments for and against this in a @@ -782,6 +979,10 @@ If you're not a programmer, you can still help others by making that protocol available. You might host the document somewhere and send the URL to one of the mailing lists. +Posting an issue with attachments on +https://github.com/networkupstools/nut/issues +can also be helpful. + == How can you answer questions to situations that nobody's encountered yet? Isn't this a frequently asked questions file? *Answer 1* @@ -793,9 +994,12 @@ It's a kind of Magic. It's both that and a frequently *anticipated* questions file, too. The idea is to write it up in here so that nobody asks the mailing -list when it finally does get released. +list when it finally does get released. == My UPS powers up immediately after a power failure instead of waiting for the batteries to recharge! +Or a variation like... + +== My UPS (an APC as it happens) lacks the field "battery.charge.restart" -- so how will it know when to restart? You can rig up a little hack to handle this issue in software. @@ -812,8 +1016,8 @@ where there's not enough battery capacity left for upsmon to do its thing. Exactly how long to wait is a function of your UPS hardware, and will require careful testing. -If this is too evil for you, buy another kind of UPS that will either wait for a -minimum amount of charge, a minimum amount of time, or both. +If this is too evil for you, buy another kind of UPS that will either wait for +a minimum amount of charge, a minimum amount of time, or both. == I'm facing a power race Or a variation like... @@ -838,12 +1042,17 @@ they won't be stuck in the halted state with the UPS running on line power. Implement this by modifying your shutdown script like this: +------ + # `upsmon -K` if available on still mounted filesystems + # at this point is more portable than the `test` below + if (test -f /etc/killpower) then - /usr/local/ups/sbin/upsdrvctl shutdown + /sbin/upsdrvctl shutdown sleep 120 # uh oh, we never got shut down! (power race?) reboot fi +------ diff --git a/docs/Makefile.am b/docs/Makefile.am index c587aa5..a593070 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -1,3 +1,10 @@ +MAINTAINERCLEANFILES = Makefile.in .dirstamp +EXTRA_DIST = + +# Is "egrep == grep -E" always valid? (maybe all a job for configure.ac) +EGREP = egrep +#EGREP = grep -E + IMAGE_FILES = images/asciidoc.png \ images/hostedby.png \ images/nut_layering.png \ @@ -12,9 +19,10 @@ IMAGE_FILES = images/asciidoc.png \ images/old-cgi.png # Only track here the local deps -SHARED_DEPS = nut-names.txt asciidoc.conf +SHARED_DEPS = nut-names.txt daisychain.txt asciidoc.conf asciidoc.txt USER_MANUAL_DEPS = acknowledgements.txt cables.txt config-notes.txt \ + config-prereqs.txt ci-farm-lxc-setup.txt \ configure.txt download.txt documentation.txt features.txt history.txt \ outlets.txt scheduling.txt security.txt support.txt user-manual.txt @@ -35,44 +43,107 @@ CABLES_IMAGES = images/cables/73-0724.png images/cables/940-0024C.jpg \ images/cables/mge-usb-rj45.jpg \ images/cables/SOLA-330.png -ALL_TXT_SRC = nut-names.txt $(USER_MANUAL_DEPS) $(DEVELOPER_GUIDE_DEPS) \ - $(CABLES_DEPS) FAQ.txt nut-qa.txt packager-guide.txt snmp.txt +ALL_TXT_SRC = nut-names.txt daisychain.txt \ + $(USER_MANUAL_DEPS) $(DEVELOPER_GUIDE_DEPS) \ + $(CABLES_DEPS) FAQ.txt nut-qa.txt packager-guide.txt snmp.txt \ + solaris-usb.txt NUT_SPELL_DICT = nut.dict -EXTRA_DIST = $(ALL_TXT_SRC) $(SHARED_DEPS) $(IMAGE_FILES) \ +EXTRA_DIST += $(ALL_TXT_SRC) $(SHARED_DEPS) $(IMAGE_FILES) \ $(CABLES_IMAGES) $(NUT_SPELL_DICT) \ - common.xsl xhtml.xsl chunked.xsl + common.xsl xhtml.xsl chunked.xsl asciidoc.txt ASCIIDOC_HTML_SINGLE = user-manual.html \ developer-guide.html \ packager-guide.html \ + solaris-usb.html \ + cables.html \ FAQ.html ASCIIDOC_HTML_CHUNKED = user-manual.chunked \ developer-guide.chunked \ packager-guide.chunked \ - FAQ.html + solaris-usb.chunked \ + cables.chunked \ + FAQ.chunked ASCIIDOC_PDF = user-manual.pdf \ developer-guide.pdf \ packager-guide.pdf \ - cables.pdf \ + solaris-usb.pdf \ + cables.pdf \ FAQ.pdf -SUBDIRS = man -SUFFIXES = .txt .html .pdf +SUBDIRS = man cables +SUFFIXES = .txt .html .pdf -spellchecked all: doc +# This list is defined by configure script choices and options: +check-local: @DOC_CHECK_LIST@ + +# This list is defined by configure script choices and options: doc: @DOC_BUILD_LIST@ +# This target can be called by developers to go around the configure +# script choices at their risk (e.g. missing tools are possible): +docs: pdf html-single html-chunked man-man html-man + +all-docs: docs + +check-docs: check-pdf check-html-single check-html-chunked check-man + pdf: $(ASCIIDOC_PDF) # also build the HTML manpages with these targets html-single: $(ASCIIDOC_HTML_SINGLE) html-chunked: $(ASCIIDOC_HTML_CHUNKED) +# the "for" loops might better use $^ but it might be not portable +check-pdf: $(ASCIIDOC_PDF) + @FAILED=""; LANG=C; LC_ALL=C; export LANG; export LC_ALL; \ + for F in $(ASCIIDOC_PDF) ; do \ + test -s "$$F" && { file "$$F" | $(EGREP) -i 'PDF document' > /dev/null ; } || FAILED="$$FAILED $$F" ; \ + done; if test -n "$$FAILED" ; then \ + echo "FAILED PDF sanity check for:$$FAILED" >&2 ; file $$FAILED >&2 ; exit 1; \ + fi; echo "PASSED PDF sanity check"; exit 0 + +check-html-single: $(ASCIIDOC_HTML_SINGLE) + @FAILED=""; LANG=C; LC_ALL=C; export LANG; export LC_ALL; \ + for F in $(ASCIIDOC_HTML_SINGLE) ; do \ + test -s "$$F" && { file "$$F" | $(EGREP) -i '(XML|HTML.*document)' > /dev/null ; } || FAILED="$$FAILED $$F" ; \ + done; if test -n "$$FAILED" ; then \ + echo "FAILED HTML-single sanity check for:$$FAILED" >&2 ; file $$FAILED >&2 ; exit 1; \ + fi; echo "PASSED HTML-single sanity check"; exit 0 + +check-html-chunked: $(ASCIIDOC_HTML_CHUNKED) + @FAILED=""; LANG=C; LC_ALL=C; export LANG; export LC_ALL; \ + for D in $(ASCIIDOC_HTML_CHUNKED); do \ + for F in "$$D"/*.html ; do \ + test -s "$$F" && { file "$$F" | $(EGREP) -i '(XML|HTML.*document)' > /dev/null ; } || FAILED="$$FAILED $$F" ; \ + done; \ + for F in "$$D"/*.css ; do \ + test -s "$$F" && { $(EGREP) -i 'CSS stylesheet' "$$F" > /dev/null ; } || FAILED="$$FAILED $$F" ; \ + done; \ + done; if test -n "$$FAILED" ; then \ + echo "FAILED HTML-chunked sanity check for:$$FAILED" >&2 ; file $$FAILED >&2 ; exit 1; \ + fi; echo "PASSED HTML-chunked sanity check"; exit 0 + +# Note: usually the results from man-page check will be reported twice: +# once as a SUBDIRS child makefile, and once via DOC_CHECK_LIST expansion +# Note: default `make all` in the man directory caters to drivers etc. +# chosen during configure script execution. The "all-man" and "all-html" +# rules build everything documented. +check-man all-man man-man all-html html-man: + cd $(top_builddir)/docs/man/ && $(MAKE) -f Makefile $@ + +man: + cd $(top_builddir)/docs/man/ && $(MAKE) -f Makefile all + +CLEANFILES = *.xml *.html *.pdf *-spellchecked docbook-xsl.css + +# Dirs to clean clean-local: - rm -rf *.pdf *.html *.chunked docbook-xsl.css *.bak + rm -rf *.chunked *.bak tmp ### TODO: automatic dependency generation # Add other directory deps (not for local EXTRA_DIST) and generated contents @@ -85,55 +156,258 @@ FULL_DEVELOPER_GUIDE_DEPS = $(DEVELOPER_GUIDE_DEPS) $(SHARED_DEPS) \ user-manual.html user-manual.chunked user-manual.pdf: $(FULL_USER_MANUAL_DEPS) developer-guide.html developer-guide.chunked developer-guide.pdf: $(FULL_DEVELOPER_GUIDE_DEPS) packager-guide.html packager-guide.chunked packager-guide.pdf: packager-guide.txt asciidoc.conf +solaris-usb.html solaris-usb.chunked solaris-usb.pdf: solaris-usb.txt asciidoc.conf # Note: without the "-v", asciidoc (circa 8.6.2) sometimes hangs when # generating the chunked HTML. In this case, export the environment # variable ASCIIDOC_VERBOSE to "-v", ie: # $ ASCIIDOC_VERBOSE=-v make -A2X_COMMON_OPTS = $(ASCIIDOC_VERBOSE) --attribute icons \ - --xsltproc-opts "--nonet" \ - --xsltproc-opts "--stringparam nut.localdate \"`TZ=UTC date +%Y-%m-%d`\"" \ - --xsltproc-opts "--stringparam nut.localtime \"`TZ=UTC date +%H:%M:%S`\"" \ - --xsltproc-opts "--stringparam nut.nutversion \"@PACKAGE_VERSION@\"" \ - --attribute iconsdir=$(srcdir)/images \ +A2X_COMMON_OPTS = $(ASCIIDOC_VERBOSE) \ + --attribute=icons \ + --xsltproc-opts="--nonet" \ + --xsltproc-opts="--stringparam nut.localdate \"`TZ=UTC date +%Y-%m-%d`\"" \ + --xsltproc-opts="--stringparam nut.localtime \"`TZ=UTC date +%H:%M:%S`\"" \ + --xsltproc-opts="--stringparam nut.nutversion \"@PACKAGE_VERSION@\"" \ + --attribute=iconsdir="$(srcdir)/images" \ --attribute=badges \ --attribute=external_title \ - --attribute tree_version=@TREE_VERSION@ \ - -a toc -a numbered --destination-dir=. + --attribute=tree_version="@TREE_VERSION@" \ + -a toc -a numbered --destination-dir=$${A2X_OUTDIR} +# NOTE: a2x newer than 8.6.8 says "--destination-dir" is only valid for HTML. +# As of version 8.6.9 it lies, and the argument is required for our distcheck +# (and does affect PDF builds, as found during work on collision-avoidance - +# true with at least asciidoc/a2x versions 9.0.0rc2). +# For more details see issues https://github.com/asciidoc/asciidoc/issues/44 +# and https://github.com/networkupstools/nut/pull/281 (in short, attempts +# to "fix" this warning broke NUT build). If this is to be retried later, see +# https://github.com/networkupstools/nut/pull/281/commits/fe17861c4ea12679b3ebfefa8a6d692d79d99f2d +# and do not forget to fix up docs/man/Makefile.am too ;) -.txt.html: common.xsl xhtml.xsl - $(A2X) $(A2X_COMMON_OPTS) --attribute=xhtml11_format --format=xhtml --xsl-file=$(srcdir)/xhtml.xsl $< +# NOTE: a2x tends to copy some files into its working area, preserving original +# permissions. If those files are read-only in origin (e.g. packaged stylesheet +# or our resources coming from EXTRA_DIST) the next a2x can not overwrite it. +# Also note that such hoarding of files has potential to break parallel builds +# (or cause them to produce undefined results if some bad timing happens). +# As a brutal workaround for the former problem, we chmod. For second one we +# might try magic with .SEQUENTIAL recipe hints, but that is gmake-dependent. -.txt.chunked: common.xsl chunked.xsl - $(A2X) $(A2X_COMMON_OPTS) --attribute=chunked_format --format=chunked --xsl-file=$(srcdir)/chunked.xsl $< +# Note that empirically it treats "destination-dir" as the source root for +# PDF generation (even though it claims the argument is ignored for non-HTML +# targets) so we have to provide the "images/" in this case. ONLY for PDF! -.txt.pdf: docinfo.xml - $(A2X) $(A2X_COMMON_OPTS) --attribute=pdf_format --format=pdf -a docinfo1 $< +# Note we only remove the original target (if present), if it is a directory - +# e.g. created by "html-chunked" targets. +DOCBUILD_BEGIN = { \ + if test -n "$${A2X_OUTDIR}" && test "$${A2X_OUTDIR}" != '.' ; then \ + rm -rf "./$${A2X_OUTDIR}" || true ; \ + test -d "$@" && rm -rf "$@" || true ; \ + mkdir -p "./$${A2X_OUTDIR}" || exit ; \ + case "$${A2X_OUTDIR}" in \ + tmp/pdf.*) ln -s ../../images "./$${A2X_OUTDIR}" ;; \ + esac; \ + else A2X_OUTDIR='.' ; fi; \ + if test -s "${builddir}/docbook-xsl.css" \ + && test -r "${builddir}/docbook-xsl.css" \ + && ! test -w "${builddir}/docbook-xsl.css" \ + ; then chmod u+w "${builddir}/docbook-xsl.css" ; fi ; \ + chmod -R u+w "./$${A2X_OUTDIR}" || true; \ +} + +# When moving "*" hope a2x did not make any "hidden" files +# like ".*" that would be required for resulting documents. +# Leave the "images/" dir there, though. +# Otherwise, we would have to `find` them all. +DOCBUILD_END = { \ + if test -n "$${A2X_OUTDIR}" && test "$${A2X_OUTDIR}" != '.' ; then \ + chmod -R u+w "./$${A2X_OUTDIR}" || true; \ + test -d "$@" && rm -rf "$@" || true ; \ + mv -f "./$${A2X_OUTDIR}/$(@F)" ./ || exit ; \ + mv -f "./$${A2X_OUTDIR}/"*.* ./ 2>/dev/null || true ; \ + rm -rf "./$${A2X_OUTDIR}" ; \ + fi ; \ +} + +# PORTABILITY NOTE: POSIX Make forbids the suffix rule definitions with +# prerequisites like done below, and GNU Make of some versions complains; +# https://www.gnu.org/software/make/manual/html_node/Error-Messages.html +# says the prerequisites were ignored while a suffix rule was created; +# eventually the POSIX stance would be taken to define a rule for a weird +# verbatim target file name with prerequisites: +# ../docs/Makefile:936: warning: ignoring prerequisites on suffix rule definition +# Changes from ".txt.pdf: docinfo.xml" to "*.pdf: docinfo.xml" = ".txt.pdf:" +# as done below may be pointless in the end (with regard to a portable way +# to trigger builds by a changed dependency), but at least predictable and +# not toxic. +*.html: common.xsl xhtml.xsl +.txt.html: + @A2X_OUTDIR="tmp/html-single.$(@F).$$$$" ; \ + echo " DOC-HTML Generating $@"; \ + $(DOCBUILD_BEGIN) ; RES=0; \ + $(A2X) $(A2X_COMMON_OPTS) --attribute=xhtml11_format --format=xhtml --xsl-file=$(srcdir)/xhtml.xsl $< || RES=$$? ; \ + $(DOCBUILD_END) ; exit $$RES + +*.chunked: common.xsl chunked.xsl +.txt.chunked: + @A2X_OUTDIR="tmp/html-chunked.$(@F).$$$$" ; \ + echo " DOC-HTML-CHUNKED Generating $@"; \ + $(DOCBUILD_BEGIN) ; RES=0; \ + $(A2X) $(A2X_COMMON_OPTS) --attribute=chunked_format --format=chunked --xsl-file=$(srcdir)/chunked.xsl $< || RES=$$? ; \ + $(DOCBUILD_END) ; exit $$RES + +# Note: non-HTML a2x modes may ignore the destination directory +*.pdf: docinfo.xml +.txt.pdf: + @A2X_OUTDIR="tmp/pdf.$(@F).$$$$" ; \ + echo " DOC-PDF Generating $@"; \ + $(DOCBUILD_BEGIN) ; RES=0; \ + $(A2X) $(A2X_COMMON_OPTS) --attribute=pdf_format --format=pdf -a docinfo1 $< || RES=$$? ; \ + $(DOCBUILD_END) ; exit $$RES if HAVE_ASPELL # Non-interactively spell check all documentation source files. # This is useful for Buildbot and automated QA processing # FIXME: how to present output (std{out,err}, single file or per target)? +# NOTE: ../ChangeLog is nowadays generated from commit messages, so +# its spelling (or errors in that) are not fixable and thus irrelevant. +# Similarly for the ../INSTALL file that is prepared by autoconf and not +# tracked as a source file by NUT Git repository. SPELLCHECK_SRC = $(ALL_TXT_SRC) ../README ../INSTALL.nut ../UPGRADING ../NEWS \ ../TODO ../scripts/ufw/README ../scripts/augeas/README ../lib/README \ - ../tools/nut-scanner/README + ../tools/nut-scanner/README \ + ../AUTHORS ../COPYING ../LICENSE-GPL2 ../LICENSE-GPL3 + +# Directory SPELLCHECK_SRC files are relative to. Overriden by other Makefiles. +SPELLCHECK_DIR = $(srcdir) + +# Note: de-facto our documentation is beyond ASCII (at least in names of +# international committers). The grep tests below look if the aspell output +# contained something other than the OK lines (tagged with asterisk) and +# aspell's version (tagged with @) and if it did - those lines must be the +# spellcheck complaints. Empty OUT is ok. +# We also must indent the input, because certain piped-in characters are +# interpreted as commands, and seems this feature can not be turned off. +# See also http://aspell.net/man-html/Through-A-Pipe.html +# TODO: Is "grep -a" or "grep -b" (treat input as ascii/bin) portable enough? +# Set SPELLCHECK_ERROR_FATAL=no if there are some unavoidable issues +# due to spellchecking, to temporarily not fail builds due to this. +# For Travis CI in particular, see ci_build.sh in NUT codebase root. +SPELLCHECK_ERROR_FATAL = yes +SPELLCHECK_ENV_DEBUG = no +ASPELL_NUT_COMMON_ARGS = -p $(abs_srcdir)/$(NUT_SPELL_DICT) +ASPELL_NUT_COMMON_ARGS += -d en --lang=en --ignore-accents +ASPELL_NUT_COMMON_ARGS += --encoding=utf-8 +ASPELL_ENV_LANG = en.UTF-8 +ASPELL_OUT_NOTERRORS = (^[ \t]*[\*\@]|^$$) + +# WARNING: The percent wildcard is a GNU extension; otherwise we need +# a ".txt.txt-spellchecked" type of rule and files like "README" all +# renamed to *.txt, or lots of rules for files without the extensions +# Other Makefiles have a relatively simple life, dealing with just a +# few texts and name/extension patterns in their directories. +#?#.txt.txt-spellchecked: Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) +#%-spellchecked: % Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) +#*-spellchecked */*-spellchecked: $(@:-spellchecked=) $(top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) +# NOTE: This portable rule RELIES on just one SPELLCHECK_SRC defined +# at a time, with an outer Makefile caller ensuring the looping: +$(SPELLCHECK_DIR)/$(SPELLCHECK_SRC_ONE)-spellchecked: $(SPELLCHECK_DIR)/$(SPELLCHECK_SRC_ONE) $(abs_top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) + @LANG=C; LC_ALL=C; export LANG; export LC_ALL; \ + rm -f "$@" || true ; \ + echo " ASPELL Spell checking on $(SPELLCHECK_DIR)/$(SPELLCHECK_SRC_ONE)"; \ + OUT="`(sed 's,^\(.*\)$$, \1,' | $(ASPELL) -a -t $(ASPELL_NUT_COMMON_ARGS) 2>&1) < "$(SPELLCHECK_DIR)/$(SPELLCHECK_SRC_ONE)"`" \ + && { if test -n "$$OUT" ; then OUT="`echo "$$OUT" | $(EGREP) -b -v '$(ASPELL_OUT_NOTERRORS)' `" ; fi; \ + test -z "$$OUT" ; } \ + || { RES=$$? ; \ + echo "FAILED : Aspell reported errors here:" >&2 \ + && echo "----- vvv" >&2 \ + && echo "$$OUT" >&2 \ + && echo "----- ^^^" >&2 ; \ + exit $$RES; } ; \ + touch "$@" spellcheck: - @for docsrc in $(SPELLCHECK_SRC); do \ - echo "Spell checking on $$docsrc"; \ - LANG=C $(ASPELL) -a -t -p $(NUT_SPELL_DICT) < $$docsrc | grep [^*]; \ - done -# Interactively spell check all documentation source files + @if test "$(SPELLCHECK_ENV_DEBUG)" != no ; then \ + echo "ASPELL DEBUG : information about the setup follows:"; \ + LANG=$(ASPELL_ENV_LANG); LC_ALL=$(ASPELL_ENV_LANG); export LANG; export LC_ALL; \ + $(ASPELL) --help || true; \ + dpkg -l |grep -i aspell || true ; \ + echo "ASPELL automatic execution line is : ( sed 's,^\(.*\)$$, \1,' < docfile.txt | $(ASPELL) -a -t $(ASPELL_NUT_COMMON_ARGS) | $(EGREP) -b -v '$(ASPELL_OUT_NOTERRORS)' )" ; \ + echo "ASPELL proceeding to spellchecking job..."; \ + else true; fi + @FAILED="" ; LANG=C; LC_ALL=C; export LANG; export LC_ALL; \ + for docsrc in $(SPELLCHECK_SRC); do \ + if test "$(SPELLCHECK_ENV_DEBUG)" != no ; then \ + echo "ASPELL MAKEFILE DEBUG: Will see from `pwd` if '$(SPELLCHECK_DIR)/$${docsrc}-spellchecked' is up to date" >&2; \ + else true ; fi ; \ + $(MAKE) -s -f "$(abs_top_builddir)/docs/Makefile" SPELLCHECK_SRC_ONE="$${docsrc}" SPELLCHECK_DIR="$(SPELLCHECK_DIR)" "$(SPELLCHECK_DIR)/$${docsrc}-spellchecked" \ + || FAILED="$$FAILED $(SPELLCHECK_DIR)/$$docsrc"; \ + done ; \ + if test -n "$$FAILED" ; then \ + echo "=====================================================================" ; \ + echo "FAILED automatic spellcheck for the following sources (relative to `pwd`): $$FAILED" ; \ + echo "=====================================================================" ; \ + echo "Please 'cd $(abs_top_builddir) && make spellcheck-interactive'"; \ + echo "to either fix document sources or update the dictionary of accepted"; \ + echo "words and spellings listed in the '$(NUT_SPELL_DICT)' file there."; \ + echo "Either way, please follow up by posting a pull request or a patch"; \ + echo "to integrate your fixes into the common NUT codebase."; \ + echo "=====================================================================" ; \ + test x"$(SPELLCHECK_ERROR_FATAL)" = xno || exit 1; \ + echo "NOTE: SPELLCHECK_ERROR_FATAL == no so this make does not break the build!"; \ + echo "=====================================================================" ; \ + fi >&2 ; exit 0 + +# Interactively spell check all documentation source files below (so a human +# can edit the documentation errors and/or add words to custom dictionary). +# Note that here we do not restrain reported issues, so this might catch more +# than the automated test above. +spellcheck-sortdict: $(abs_builddir)/$(NUT_SPELL_DICT).sorted + +# Note that the source file may be not overwritable (distcheck, cdrom, ...), +# so we'd ignore that failure. But the practical use-case is a developer's +# in-tree workspace, so we want the working copy of the dictionary fixed up +# for easy `git diff`ing if possible. +# Note also that "$( "$@" + @cp -f "$@" "$(abs_builddir)/$(NUT_SPELL_DICT)" + @if [ "$(abs_builddir)" != "$(abs_srcdir)" ] ; then \ + cp -f "$@" "$<" || true ; \ + cp -f "$(abs_builddir)/$(NUT_SPELL_DICT).bak-pre-sorting" "$(abs_srcdir)/" || true ; \ + fi + +DISTCLEANFILES = $(NUT_SPELL_DICT).bak-pre-sorting .$(NUT_SPELL_DICT).sorted $(NUT_SPELL_DICT).sorted + spellcheck-interactive: - @for docsrc in $(SPELLCHECK_SRC); do\ - echo "Spell checking on $$docsrc"; \ - LANG=C $(ASPELL) check -p $(NUT_SPELL_DICT) $$docsrc; \ - done + @FAILED="" ; for docsrc in $(SPELLCHECK_SRC); do \ + echo "Spell checking on $(SPELLCHECK_DIR)/$$docsrc"; \ + LANG=$(ASPELL_ENV_LANG) LC_ALL=$(ASPELL_ENV_LANG) $(ASPELL) check $(ASPELL_NUT_COMMON_ARGS) $(SPELLCHECK_DIR)/$$docsrc || \ + FAILED="$$FAILED $(SPELLCHECK_DIR)/$$docsrc"; \ + done ; \ + if test -n "$$FAILED" ; then \ + echo "FAILED interactive spellcheck for the following sources (relative to `pwd`): $$FAILED" >&2 ; \ + exit 1; \ + fi ; exit 0 + $(MAKE) spellcheck-sortdict + @echo "------------------------------------------------------------------------"; \ + echo "Custom dictionary file $(NUT_SPELL_DICT) may have been updated now."; \ + echo "Use 'git add -p docs/$(NUT_SPELL_DICT) && git checkout -- docs/$(NUT_SPELL_DICT) && make spellcheck-sortdict && git add -p docs/$(NUT_SPELL_DICT)'"; \ + echo "to review changes (please DO NOT REMOVE LINES that aspell chose to drop,"; \ + echo "because other systems might not know these words in their system dictionaries)"; \ + echo "------------------------------------------------------------------------" else !HAVE_ASPELL +# This rule woulf probably just fail; normally with no ASPELL there are no callers for it +*/*-spellchecked *-spellchecked: Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) + @echo " SKIP-ASPELL $@ : Documentation spell check not available since 'aspell' was not found." >&2 spellcheck: @echo "Documentation spell check not available since 'aspell' was not found." spellcheck-interactive: @echo "Documentation spell check not available since 'aspell' was not found." endif !HAVE_ASPELL -.PHONY: html html-single pdf +.PHONY: html html-chunked html-single pdf man diff --git a/docs/Makefile.in b/docs/Makefile.in index 1a28021..8b1a929 100644 --- a/docs/Makefile.in +++ b/docs/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.16.3 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,19 +89,24 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = docs -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(srcdir)/docinfo.xml.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nut_arg_with.m4 \ $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ $(top_srcdir)/m4/nut_check_libavahi.m4 \ $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ $(top_srcdir)/m4/nut_check_libgd.m4 \ $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ $(top_srcdir)/m4/nut_check_libneon.m4 \ $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ $(top_srcdir)/m4/nut_check_libnss.m4 \ @@ -100,11 +115,17 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ $(top_srcdir)/m4/nut_check_libusb.m4 \ $(top_srcdir)/m4/nut_check_libwrap.m4 \ $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ $(top_srcdir)/m4/nut_type_socklen_t.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = docinfo.xml @@ -143,7 +164,7 @@ am__recursive_targets = \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - distdir + distdir distdir-am am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is @@ -164,6 +185,7 @@ am__define_uniq_tagged_files = \ ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) +am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/docinfo.xml.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ @@ -197,6 +219,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -207,6 +230,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -220,6 +244,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -229,9 +254,12 @@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ -EGREP = @EGREP@ + +# Is "egrep == grep -E" always valid? (maybe all a job for configure.ac) +EGREP = egrep EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -249,6 +277,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -259,21 +289,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -293,6 +331,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -306,6 +347,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -323,6 +365,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -336,6 +379,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -361,12 +407,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -376,6 +424,11 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ udevdir = @udevdir@ +MAINTAINERCLEANFILES = Makefile.in .dirstamp +EXTRA_DIST = $(ALL_TXT_SRC) $(SHARED_DEPS) $(IMAGE_FILES) \ + $(CABLES_IMAGES) $(NUT_SPELL_DICT) common.xsl xhtml.xsl \ + chunked.xsl asciidoc.txt +#EGREP = grep -E IMAGE_FILES = images/asciidoc.png \ images/hostedby.png \ images/nut_layering.png \ @@ -391,8 +444,9 @@ IMAGE_FILES = images/asciidoc.png \ # Only track here the local deps -SHARED_DEPS = nut-names.txt asciidoc.conf +SHARED_DEPS = nut-names.txt daisychain.txt asciidoc.conf asciidoc.txt USER_MANUAL_DEPS = acknowledgements.txt cables.txt config-notes.txt \ + config-prereqs.txt ci-farm-lxc-setup.txt \ configure.txt download.txt documentation.txt features.txt history.txt \ outlets.txt scheduling.txt security.txt support.txt user-manual.txt @@ -413,32 +467,36 @@ CABLES_IMAGES = images/cables/73-0724.png images/cables/940-0024C.jpg \ images/cables/mge-usb-rj45.jpg \ images/cables/SOLA-330.png -ALL_TXT_SRC = nut-names.txt $(USER_MANUAL_DEPS) $(DEVELOPER_GUIDE_DEPS) \ - $(CABLES_DEPS) FAQ.txt nut-qa.txt packager-guide.txt snmp.txt +ALL_TXT_SRC = nut-names.txt daisychain.txt \ + $(USER_MANUAL_DEPS) $(DEVELOPER_GUIDE_DEPS) \ + $(CABLES_DEPS) FAQ.txt nut-qa.txt packager-guide.txt snmp.txt \ + solaris-usb.txt NUT_SPELL_DICT = nut.dict -EXTRA_DIST = $(ALL_TXT_SRC) $(SHARED_DEPS) $(IMAGE_FILES) \ - $(CABLES_IMAGES) $(NUT_SPELL_DICT) \ - common.xsl xhtml.xsl chunked.xsl - ASCIIDOC_HTML_SINGLE = user-manual.html \ developer-guide.html \ packager-guide.html \ + solaris-usb.html \ + cables.html \ FAQ.html ASCIIDOC_HTML_CHUNKED = user-manual.chunked \ developer-guide.chunked \ packager-guide.chunked \ - FAQ.html + solaris-usb.chunked \ + cables.chunked \ + FAQ.chunked ASCIIDOC_PDF = user-manual.pdf \ developer-guide.pdf \ packager-guide.pdf \ - cables.pdf \ + solaris-usb.pdf \ + cables.pdf \ FAQ.pdf -SUBDIRS = man -SUFFIXES = .txt .html .pdf +SUBDIRS = man cables +SUFFIXES = .txt .html .pdf -spellchecked +CLEANFILES = *.xml *.html *.pdf *-spellchecked docbook-xsl.css ### TODO: automatic dependency generation # Add other directory deps (not for local EXTRA_DIST) and generated contents @@ -454,29 +512,114 @@ FULL_DEVELOPER_GUIDE_DEPS = $(DEVELOPER_GUIDE_DEPS) $(SHARED_DEPS) \ # generating the chunked HTML. In this case, export the environment # variable ASCIIDOC_VERBOSE to "-v", ie: # $ ASCIIDOC_VERBOSE=-v make -A2X_COMMON_OPTS = $(ASCIIDOC_VERBOSE) --attribute icons \ - --xsltproc-opts "--nonet" \ - --xsltproc-opts "--stringparam nut.localdate \"`TZ=UTC date +%Y-%m-%d`\"" \ - --xsltproc-opts "--stringparam nut.localtime \"`TZ=UTC date +%H:%M:%S`\"" \ - --xsltproc-opts "--stringparam nut.nutversion \"@PACKAGE_VERSION@\"" \ - --attribute iconsdir=$(srcdir)/images \ +A2X_COMMON_OPTS = $(ASCIIDOC_VERBOSE) \ + --attribute=icons \ + --xsltproc-opts="--nonet" \ + --xsltproc-opts="--stringparam nut.localdate \"`TZ=UTC date +%Y-%m-%d`\"" \ + --xsltproc-opts="--stringparam nut.localtime \"`TZ=UTC date +%H:%M:%S`\"" \ + --xsltproc-opts="--stringparam nut.nutversion \"@PACKAGE_VERSION@\"" \ + --attribute=iconsdir="$(srcdir)/images" \ --attribute=badges \ --attribute=external_title \ - --attribute tree_version=@TREE_VERSION@ \ - -a toc -a numbered --destination-dir=. + --attribute=tree_version="@TREE_VERSION@" \ + -a toc -a numbered --destination-dir=$${A2X_OUTDIR} + +# NOTE: a2x newer than 8.6.8 says "--destination-dir" is only valid for HTML. +# As of version 8.6.9 it lies, and the argument is required for our distcheck +# (and does affect PDF builds, as found during work on collision-avoidance - +# true with at least asciidoc/a2x versions 9.0.0rc2). +# For more details see issues https://github.com/asciidoc/asciidoc/issues/44 +# and https://github.com/networkupstools/nut/pull/281 (in short, attempts +# to "fix" this warning broke NUT build). If this is to be retried later, see +# https://github.com/networkupstools/nut/pull/281/commits/fe17861c4ea12679b3ebfefa8a6d692d79d99f2d +# and do not forget to fix up docs/man/Makefile.am too ;) + +# NOTE: a2x tends to copy some files into its working area, preserving original +# permissions. If those files are read-only in origin (e.g. packaged stylesheet +# or our resources coming from EXTRA_DIST) the next a2x can not overwrite it. +# Also note that such hoarding of files has potential to break parallel builds +# (or cause them to produce undefined results if some bad timing happens). +# As a brutal workaround for the former problem, we chmod. For second one we +# might try magic with .SEQUENTIAL recipe hints, but that is gmake-dependent. + +# Note that empirically it treats "destination-dir" as the source root for +# PDF generation (even though it claims the argument is ignored for non-HTML +# targets) so we have to provide the "images/" in this case. ONLY for PDF! + +# Note we only remove the original target (if present), if it is a directory - +# e.g. created by "html-chunked" targets. +DOCBUILD_BEGIN = { \ + if test -n "$${A2X_OUTDIR}" && test "$${A2X_OUTDIR}" != '.' ; then \ + rm -rf "./$${A2X_OUTDIR}" || true ; \ + test -d "$@" && rm -rf "$@" || true ; \ + mkdir -p "./$${A2X_OUTDIR}" || exit ; \ + case "$${A2X_OUTDIR}" in \ + tmp/pdf.*) ln -s ../../images "./$${A2X_OUTDIR}" ;; \ + esac; \ + else A2X_OUTDIR='.' ; fi; \ + if test -s "${builddir}/docbook-xsl.css" \ + && test -r "${builddir}/docbook-xsl.css" \ + && ! test -w "${builddir}/docbook-xsl.css" \ + ; then chmod u+w "${builddir}/docbook-xsl.css" ; fi ; \ + chmod -R u+w "./$${A2X_OUTDIR}" || true; \ +} + + +# When moving "*" hope a2x did not make any "hidden" files +# like ".*" that would be required for resulting documents. +# Leave the "images/" dir there, though. +# Otherwise, we would have to `find` them all. +DOCBUILD_END = { \ + if test -n "$${A2X_OUTDIR}" && test "$${A2X_OUTDIR}" != '.' ; then \ + chmod -R u+w "./$${A2X_OUTDIR}" || true; \ + test -d "$@" && rm -rf "$@" || true ; \ + mv -f "./$${A2X_OUTDIR}/$(@F)" ./ || exit ; \ + mv -f "./$${A2X_OUTDIR}/"*.* ./ 2>/dev/null || true ; \ + rm -rf "./$${A2X_OUTDIR}" ; \ + fi ; \ +} # Non-interactively spell check all documentation source files. # This is useful for Buildbot and automated QA processing # FIXME: how to present output (std{out,err}, single file or per target)? +# NOTE: ../ChangeLog is nowadays generated from commit messages, so +# its spelling (or errors in that) are not fixable and thus irrelevant. +# Similarly for the ../INSTALL file that is prepared by autoconf and not +# tracked as a source file by NUT Git repository. @HAVE_ASPELL_TRUE@SPELLCHECK_SRC = $(ALL_TXT_SRC) ../README ../INSTALL.nut ../UPGRADING ../NEWS \ @HAVE_ASPELL_TRUE@ ../TODO ../scripts/ufw/README ../scripts/augeas/README ../lib/README \ -@HAVE_ASPELL_TRUE@ ../tools/nut-scanner/README +@HAVE_ASPELL_TRUE@ ../tools/nut-scanner/README \ +@HAVE_ASPELL_TRUE@ ../AUTHORS ../COPYING ../LICENSE-GPL2 ../LICENSE-GPL3 + +# Directory SPELLCHECK_SRC files are relative to. Overriden by other Makefiles. +@HAVE_ASPELL_TRUE@SPELLCHECK_DIR = $(srcdir) + +# Note: de-facto our documentation is beyond ASCII (at least in names of +# international committers). The grep tests below look if the aspell output +# contained something other than the OK lines (tagged with asterisk) and +# aspell's version (tagged with @) and if it did - those lines must be the +# spellcheck complaints. Empty OUT is ok. +# We also must indent the input, because certain piped-in characters are +# interpreted as commands, and seems this feature can not be turned off. +# See also http://aspell.net/man-html/Through-A-Pipe.html +# TODO: Is "grep -a" or "grep -b" (treat input as ascii/bin) portable enough? +# Set SPELLCHECK_ERROR_FATAL=no if there are some unavoidable issues +# due to spellchecking, to temporarily not fail builds due to this. +# For Travis CI in particular, see ci_build.sh in NUT codebase root. +@HAVE_ASPELL_TRUE@SPELLCHECK_ERROR_FATAL = yes +@HAVE_ASPELL_TRUE@SPELLCHECK_ENV_DEBUG = no +@HAVE_ASPELL_TRUE@ASPELL_NUT_COMMON_ARGS = -p \ +@HAVE_ASPELL_TRUE@ $(abs_srcdir)/$(NUT_SPELL_DICT) -d en \ +@HAVE_ASPELL_TRUE@ --lang=en --ignore-accents --encoding=utf-8 +@HAVE_ASPELL_TRUE@ASPELL_ENV_LANG = en.UTF-8 +@HAVE_ASPELL_TRUE@ASPELL_OUT_NOTERRORS = (^[ \t]*[\*\@]|^$$) +@HAVE_ASPELL_TRUE@DISTCLEANFILES = $(NUT_SPELL_DICT).bak-pre-sorting .$(NUT_SPELL_DICT).sorted $(NUT_SPELL_DICT).sorted all: all-recursive .SUFFIXES: -.SUFFIXES: .txt .html .pdf .chunked +.SUFFIXES: .txt .html .pdf -spellchecked .chunked $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ @@ -489,14 +632,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu docs/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu docs/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -615,7 +757,10 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -671,6 +816,7 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-local check: check-recursive all-am: Makefile installdirs: installdirs-recursive @@ -697,14 +843,17 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-recursive clean-am: clean-generic clean-libtool clean-local mostlyclean-am @@ -769,65 +918,240 @@ ps-am: uninstall-am: -.MAKE: $(am__recursive_targets) install-am install-strip +.MAKE: $(am__recursive_targets) check-am install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-am clean clean-generic clean-libtool clean-local \ - cscopelist-am ctags ctags-am distclean distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ - uninstall-am + check-am check-local clean clean-generic clean-libtool \ + clean-local cscopelist-am ctags ctags-am distclean \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am + +.PRECIOUS: Makefile all: doc +# This list is defined by configure script choices and options: +check-local: @DOC_CHECK_LIST@ + +# This list is defined by configure script choices and options: doc: @DOC_BUILD_LIST@ +# This target can be called by developers to go around the configure +# script choices at their risk (e.g. missing tools are possible): +docs: pdf html-single html-chunked man-man html-man + +all-docs: docs + +check-docs: check-pdf check-html-single check-html-chunked check-man + pdf: $(ASCIIDOC_PDF) # also build the HTML manpages with these targets html-single: $(ASCIIDOC_HTML_SINGLE) html-chunked: $(ASCIIDOC_HTML_CHUNKED) +# the "for" loops might better use $^ but it might be not portable +check-pdf: $(ASCIIDOC_PDF) + @FAILED=""; LANG=C; LC_ALL=C; export LANG; export LC_ALL; \ + for F in $(ASCIIDOC_PDF) ; do \ + test -s "$$F" && { file "$$F" | $(EGREP) -i 'PDF document' > /dev/null ; } || FAILED="$$FAILED $$F" ; \ + done; if test -n "$$FAILED" ; then \ + echo "FAILED PDF sanity check for:$$FAILED" >&2 ; file $$FAILED >&2 ; exit 1; \ + fi; echo "PASSED PDF sanity check"; exit 0 + +check-html-single: $(ASCIIDOC_HTML_SINGLE) + @FAILED=""; LANG=C; LC_ALL=C; export LANG; export LC_ALL; \ + for F in $(ASCIIDOC_HTML_SINGLE) ; do \ + test -s "$$F" && { file "$$F" | $(EGREP) -i '(XML|HTML.*document)' > /dev/null ; } || FAILED="$$FAILED $$F" ; \ + done; if test -n "$$FAILED" ; then \ + echo "FAILED HTML-single sanity check for:$$FAILED" >&2 ; file $$FAILED >&2 ; exit 1; \ + fi; echo "PASSED HTML-single sanity check"; exit 0 + +check-html-chunked: $(ASCIIDOC_HTML_CHUNKED) + @FAILED=""; LANG=C; LC_ALL=C; export LANG; export LC_ALL; \ + for D in $(ASCIIDOC_HTML_CHUNKED); do \ + for F in "$$D"/*.html ; do \ + test -s "$$F" && { file "$$F" | $(EGREP) -i '(XML|HTML.*document)' > /dev/null ; } || FAILED="$$FAILED $$F" ; \ + done; \ + for F in "$$D"/*.css ; do \ + test -s "$$F" && { $(EGREP) -i 'CSS stylesheet' "$$F" > /dev/null ; } || FAILED="$$FAILED $$F" ; \ + done; \ + done; if test -n "$$FAILED" ; then \ + echo "FAILED HTML-chunked sanity check for:$$FAILED" >&2 ; file $$FAILED >&2 ; exit 1; \ + fi; echo "PASSED HTML-chunked sanity check"; exit 0 + +# Note: usually the results from man-page check will be reported twice: +# once as a SUBDIRS child makefile, and once via DOC_CHECK_LIST expansion +# Note: default `make all` in the man directory caters to drivers etc. +# chosen during configure script execution. The "all-man" and "all-html" +# rules build everything documented. +check-man all-man man-man all-html html-man: + cd $(top_builddir)/docs/man/ && $(MAKE) -f Makefile $@ + +man: + cd $(top_builddir)/docs/man/ && $(MAKE) -f Makefile all + +# Dirs to clean clean-local: - rm -rf *.pdf *.html *.chunked docbook-xsl.css *.bak + rm -rf *.chunked *.bak tmp user-manual.html user-manual.chunked user-manual.pdf: $(FULL_USER_MANUAL_DEPS) developer-guide.html developer-guide.chunked developer-guide.pdf: $(FULL_DEVELOPER_GUIDE_DEPS) packager-guide.html packager-guide.chunked packager-guide.pdf: packager-guide.txt asciidoc.conf +solaris-usb.html solaris-usb.chunked solaris-usb.pdf: solaris-usb.txt asciidoc.conf -.txt.html: common.xsl xhtml.xsl - $(A2X) $(A2X_COMMON_OPTS) --attribute=xhtml11_format --format=xhtml --xsl-file=$(srcdir)/xhtml.xsl $< +# PORTABILITY NOTE: POSIX Make forbids the suffix rule definitions with +# prerequisites like done below, and GNU Make of some versions complains; +# https://www.gnu.org/software/make/manual/html_node/Error-Messages.html +# says the prerequisites were ignored while a suffix rule was created; +# eventually the POSIX stance would be taken to define a rule for a weird +# verbatim target file name with prerequisites: +# ../docs/Makefile:936: warning: ignoring prerequisites on suffix rule definition +# Changes from ".txt.pdf: docinfo.xml" to "*.pdf: docinfo.xml" = ".txt.pdf:" +# as done below may be pointless in the end (with regard to a portable way +# to trigger builds by a changed dependency), but at least predictable and +# not toxic. +*.html: common.xsl xhtml.xsl +.txt.html: + @A2X_OUTDIR="tmp/html-single.$(@F).$$$$" ; \ + echo " DOC-HTML Generating $@"; \ + $(DOCBUILD_BEGIN) ; RES=0; \ + $(A2X) $(A2X_COMMON_OPTS) --attribute=xhtml11_format --format=xhtml --xsl-file=$(srcdir)/xhtml.xsl $< || RES=$$? ; \ + $(DOCBUILD_END) ; exit $$RES -.txt.chunked: common.xsl chunked.xsl - $(A2X) $(A2X_COMMON_OPTS) --attribute=chunked_format --format=chunked --xsl-file=$(srcdir)/chunked.xsl $< +*.chunked: common.xsl chunked.xsl +.txt.chunked: + @A2X_OUTDIR="tmp/html-chunked.$(@F).$$$$" ; \ + echo " DOC-HTML-CHUNKED Generating $@"; \ + $(DOCBUILD_BEGIN) ; RES=0; \ + $(A2X) $(A2X_COMMON_OPTS) --attribute=chunked_format --format=chunked --xsl-file=$(srcdir)/chunked.xsl $< || RES=$$? ; \ + $(DOCBUILD_END) ; exit $$RES -.txt.pdf: docinfo.xml - $(A2X) $(A2X_COMMON_OPTS) --attribute=pdf_format --format=pdf -a docinfo1 $< +# Note: non-HTML a2x modes may ignore the destination directory +*.pdf: docinfo.xml +.txt.pdf: + @A2X_OUTDIR="tmp/pdf.$(@F).$$$$" ; \ + echo " DOC-PDF Generating $@"; \ + $(DOCBUILD_BEGIN) ; RES=0; \ + $(A2X) $(A2X_COMMON_OPTS) --attribute=pdf_format --format=pdf -a docinfo1 $< || RES=$$? ; \ + $(DOCBUILD_END) ; exit $$RES + +# WARNING: The percent wildcard is a GNU extension; otherwise we need +# a ".txt.txt-spellchecked" type of rule and files like "README" all +# renamed to *.txt, or lots of rules for files without the extensions +# Other Makefiles have a relatively simple life, dealing with just a +# few texts and name/extension patterns in their directories. +#?#.txt.txt-spellchecked: Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) +#%-spellchecked: % Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) +#*-spellchecked */*-spellchecked: $(@:-spellchecked=) $(top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) +# NOTE: This portable rule RELIES on just one SPELLCHECK_SRC defined +# at a time, with an outer Makefile caller ensuring the looping: +@HAVE_ASPELL_TRUE@$(SPELLCHECK_DIR)/$(SPELLCHECK_SRC_ONE)-spellchecked: $(SPELLCHECK_DIR)/$(SPELLCHECK_SRC_ONE) $(abs_top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) +@HAVE_ASPELL_TRUE@ @LANG=C; LC_ALL=C; export LANG; export LC_ALL; \ +@HAVE_ASPELL_TRUE@ rm -f "$@" || true ; \ +@HAVE_ASPELL_TRUE@ echo " ASPELL Spell checking on $(SPELLCHECK_DIR)/$(SPELLCHECK_SRC_ONE)"; \ +@HAVE_ASPELL_TRUE@ OUT="`(sed 's,^\(.*\)$$, \1,' | $(ASPELL) -a -t $(ASPELL_NUT_COMMON_ARGS) 2>&1) < "$(SPELLCHECK_DIR)/$(SPELLCHECK_SRC_ONE)"`" \ +@HAVE_ASPELL_TRUE@ && { if test -n "$$OUT" ; then OUT="`echo "$$OUT" | $(EGREP) -b -v '$(ASPELL_OUT_NOTERRORS)' `" ; fi; \ +@HAVE_ASPELL_TRUE@ test -z "$$OUT" ; } \ +@HAVE_ASPELL_TRUE@ || { RES=$$? ; \ +@HAVE_ASPELL_TRUE@ echo "FAILED : Aspell reported errors here:" >&2 \ +@HAVE_ASPELL_TRUE@ && echo "----- vvv" >&2 \ +@HAVE_ASPELL_TRUE@ && echo "$$OUT" >&2 \ +@HAVE_ASPELL_TRUE@ && echo "----- ^^^" >&2 ; \ +@HAVE_ASPELL_TRUE@ exit $$RES; } ; \ +@HAVE_ASPELL_TRUE@ touch "$@" @HAVE_ASPELL_TRUE@spellcheck: -@HAVE_ASPELL_TRUE@ @for docsrc in $(SPELLCHECK_SRC); do \ -@HAVE_ASPELL_TRUE@ echo "Spell checking on $$docsrc"; \ -@HAVE_ASPELL_TRUE@ LANG=C $(ASPELL) -a -t -p $(NUT_SPELL_DICT) < $$docsrc | grep [^*]; \ -@HAVE_ASPELL_TRUE@ done -# Interactively spell check all documentation source files +@HAVE_ASPELL_TRUE@ @if test "$(SPELLCHECK_ENV_DEBUG)" != no ; then \ +@HAVE_ASPELL_TRUE@ echo "ASPELL DEBUG : information about the setup follows:"; \ +@HAVE_ASPELL_TRUE@ LANG=$(ASPELL_ENV_LANG); LC_ALL=$(ASPELL_ENV_LANG); export LANG; export LC_ALL; \ +@HAVE_ASPELL_TRUE@ $(ASPELL) --help || true; \ +@HAVE_ASPELL_TRUE@ dpkg -l |grep -i aspell || true ; \ +@HAVE_ASPELL_TRUE@ echo "ASPELL automatic execution line is : ( sed 's,^\(.*\)$$, \1,' < docfile.txt | $(ASPELL) -a -t $(ASPELL_NUT_COMMON_ARGS) | $(EGREP) -b -v '$(ASPELL_OUT_NOTERRORS)' )" ; \ +@HAVE_ASPELL_TRUE@ echo "ASPELL proceeding to spellchecking job..."; \ +@HAVE_ASPELL_TRUE@ else true; fi +@HAVE_ASPELL_TRUE@ @FAILED="" ; LANG=C; LC_ALL=C; export LANG; export LC_ALL; \ +@HAVE_ASPELL_TRUE@ for docsrc in $(SPELLCHECK_SRC); do \ +@HAVE_ASPELL_TRUE@ if test "$(SPELLCHECK_ENV_DEBUG)" != no ; then \ +@HAVE_ASPELL_TRUE@ echo "ASPELL MAKEFILE DEBUG: Will see from `pwd` if '$(SPELLCHECK_DIR)/$${docsrc}-spellchecked' is up to date" >&2; \ +@HAVE_ASPELL_TRUE@ else true ; fi ; \ +@HAVE_ASPELL_TRUE@ $(MAKE) -s -f "$(abs_top_builddir)/docs/Makefile" SPELLCHECK_SRC_ONE="$${docsrc}" SPELLCHECK_DIR="$(SPELLCHECK_DIR)" "$(SPELLCHECK_DIR)/$${docsrc}-spellchecked" \ +@HAVE_ASPELL_TRUE@ || FAILED="$$FAILED $(SPELLCHECK_DIR)/$$docsrc"; \ +@HAVE_ASPELL_TRUE@ done ; \ +@HAVE_ASPELL_TRUE@ if test -n "$$FAILED" ; then \ +@HAVE_ASPELL_TRUE@ echo "=====================================================================" ; \ +@HAVE_ASPELL_TRUE@ echo "FAILED automatic spellcheck for the following sources (relative to `pwd`): $$FAILED" ; \ +@HAVE_ASPELL_TRUE@ echo "=====================================================================" ; \ +@HAVE_ASPELL_TRUE@ echo "Please 'cd $(abs_top_builddir) && make spellcheck-interactive'"; \ +@HAVE_ASPELL_TRUE@ echo "to either fix document sources or update the dictionary of accepted"; \ +@HAVE_ASPELL_TRUE@ echo "words and spellings listed in the '$(NUT_SPELL_DICT)' file there."; \ +@HAVE_ASPELL_TRUE@ echo "Either way, please follow up by posting a pull request or a patch"; \ +@HAVE_ASPELL_TRUE@ echo "to integrate your fixes into the common NUT codebase."; \ +@HAVE_ASPELL_TRUE@ echo "=====================================================================" ; \ +@HAVE_ASPELL_TRUE@ test x"$(SPELLCHECK_ERROR_FATAL)" = xno || exit 1; \ +@HAVE_ASPELL_TRUE@ echo "NOTE: SPELLCHECK_ERROR_FATAL == no so this make does not break the build!"; \ +@HAVE_ASPELL_TRUE@ echo "=====================================================================" ; \ +@HAVE_ASPELL_TRUE@ fi >&2 ; exit 0 + +# Interactively spell check all documentation source files below (so a human +# can edit the documentation errors and/or add words to custom dictionary). +# Note that here we do not restrain reported issues, so this might catch more +# than the automated test above. +@HAVE_ASPELL_TRUE@spellcheck-sortdict: $(abs_builddir)/$(NUT_SPELL_DICT).sorted + +# Note that the source file may be not overwritable (distcheck, cdrom, ...), +# so we'd ignore that failure. But the practical use-case is a developer's +# in-tree workspace, so we want the working copy of the dictionary fixed up +# for easy `git diff`ing if possible. +# Note also that "$( "$@" +@HAVE_ASPELL_TRUE@ @cp -f "$@" "$(abs_builddir)/$(NUT_SPELL_DICT)" +@HAVE_ASPELL_TRUE@ @if [ "$(abs_builddir)" != "$(abs_srcdir)" ] ; then \ +@HAVE_ASPELL_TRUE@ cp -f "$@" "$<" || true ; \ +@HAVE_ASPELL_TRUE@ cp -f "$(abs_builddir)/$(NUT_SPELL_DICT).bak-pre-sorting" "$(abs_srcdir)/" || true ; \ +@HAVE_ASPELL_TRUE@ fi + @HAVE_ASPELL_TRUE@spellcheck-interactive: -@HAVE_ASPELL_TRUE@ @for docsrc in $(SPELLCHECK_SRC); do\ -@HAVE_ASPELL_TRUE@ echo "Spell checking on $$docsrc"; \ -@HAVE_ASPELL_TRUE@ LANG=C $(ASPELL) check -p $(NUT_SPELL_DICT) $$docsrc; \ -@HAVE_ASPELL_TRUE@ done +@HAVE_ASPELL_TRUE@ @FAILED="" ; for docsrc in $(SPELLCHECK_SRC); do \ +@HAVE_ASPELL_TRUE@ echo "Spell checking on $(SPELLCHECK_DIR)/$$docsrc"; \ +@HAVE_ASPELL_TRUE@ LANG=$(ASPELL_ENV_LANG) LC_ALL=$(ASPELL_ENV_LANG) $(ASPELL) check $(ASPELL_NUT_COMMON_ARGS) $(SPELLCHECK_DIR)/$$docsrc || \ +@HAVE_ASPELL_TRUE@ FAILED="$$FAILED $(SPELLCHECK_DIR)/$$docsrc"; \ +@HAVE_ASPELL_TRUE@ done ; \ +@HAVE_ASPELL_TRUE@ if test -n "$$FAILED" ; then \ +@HAVE_ASPELL_TRUE@ echo "FAILED interactive spellcheck for the following sources (relative to `pwd`): $$FAILED" >&2 ; \ +@HAVE_ASPELL_TRUE@ exit 1; \ +@HAVE_ASPELL_TRUE@ fi ; exit 0 +@HAVE_ASPELL_TRUE@ $(MAKE) spellcheck-sortdict +@HAVE_ASPELL_TRUE@ @echo "------------------------------------------------------------------------"; \ +@HAVE_ASPELL_TRUE@ echo "Custom dictionary file $(NUT_SPELL_DICT) may have been updated now."; \ +@HAVE_ASPELL_TRUE@ echo "Use 'git add -p docs/$(NUT_SPELL_DICT) && git checkout -- docs/$(NUT_SPELL_DICT) && make spellcheck-sortdict && git add -p docs/$(NUT_SPELL_DICT)'"; \ +@HAVE_ASPELL_TRUE@ echo "to review changes (please DO NOT REMOVE LINES that aspell chose to drop,"; \ +@HAVE_ASPELL_TRUE@ echo "because other systems might not know these words in their system dictionaries)"; \ +@HAVE_ASPELL_TRUE@ echo "------------------------------------------------------------------------" +# This rule woulf probably just fail; normally with no ASPELL there are no callers for it +@HAVE_ASPELL_FALSE@*/*-spellchecked *-spellchecked: Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) +@HAVE_ASPELL_FALSE@ @echo " SKIP-ASPELL $@ : Documentation spell check not available since 'aspell' was not found." >&2 @HAVE_ASPELL_FALSE@spellcheck: @HAVE_ASPELL_FALSE@ @echo "Documentation spell check not available since 'aspell' was not found." @HAVE_ASPELL_FALSE@spellcheck-interactive: @HAVE_ASPELL_FALSE@ @echo "Documentation spell check not available since 'aspell' was not found." -.PHONY: html html-single pdf +.PHONY: html html-chunked html-single pdf man # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/docs/acknowledgements.txt b/docs/acknowledgements.txt index 33aa5d4..7597bb2 100644 --- a/docs/acknowledgements.txt +++ b/docs/acknowledgements.txt @@ -19,24 +19,24 @@ The NUT Team Active members ~~~~~~~~~~~~~~ -- Arnaud Quette: project leader (since 2005), Debian packager and jack of all trades +- Jim Klimov: project leader (since 2020), OpenIndiana and OmniOS packager, CI ops and infra +- Arnaud Quette: ex-project leader (from 2005 to 2020), Debian packager and jack of all trades - Charles Lepple: senior lieutenant -- Emilien Kia: senior developer - Daniele Pezzini: senior developer -- Václav Krpec: junior developer - Kjell Claesson: senior developer - Alexander Gordeev: junior developer - Michal Soltys: junior developer - David Goncalves: Python developer - Jean Perriault: web consultant - Eric S. Raymond: Documentation consultant +- Roger Price: Documentation specialist - Oden Eriksson: Mandriva packager -- Stanislav Brabec: Novell / Suse packager +- Stanislav Brabec: Novell / SUSE packager - Michal Hlavinka: Redhat packager - Antoine Colombier: trainee For an up to date list of NUT developers, refer to -link:https://github.com/orgs/networkupstools/members[GitHub]. +link:https://github.com/networkupstools/nut/graphs/contributors[GitHub]. Retired members ~~~~~~~~~~~~~~~ @@ -45,18 +45,20 @@ Retired members - Arjen de Korte: senior lieutenant - Peter Selinger: senior lieutenant - Carlos Rodrigues: author of the "megatec" drivers, removing the numerous -drivers for Megatec / Q1 protocol. These drivers have now been replaced by -blazer_ser and blazer_usb + drivers for Megatec / Q1 protocol. These drivers have now been replaced + by blazer_ser and blazer_usb - Niels Baggesen: ported and heavily extended upscode2 to NUT 2.0 driver model - Niklas Edmundsson: has worked on 3-phase support, and upscode2 updates - Martin Loyer: has worked a bit on mge-utalk - Jonathan Dion: MGE internship (summer 2006), who has worked on configuration - Doug Reynolds: has worked on CyberPower support (powerpanel driver) -- Jon Gough: has worked on porting the megatec driver to USB (megatec_usb) +- Jon Gough: has worked on porting the megatec driver to USB (megatec_usb) - Dominique Lallement: Consultant (chairman of the USB/HID PDC Forum) - Julius Malkiewicz: junior developer - Tomas Smetana: former Redhat packager (2007-2008) - Frederic Bohe: senior developer, Eaton contractor (2009-2013) +- Emilien Kia: senior developer +- Václav Krpec: junior developer Supporting manufacturers @@ -87,13 +89,20 @@ provide you with official support from Eaton, or a better level of device support in NUT.* ================================================================================ +* link:https://www.ametek.com/products/businessunits/powersystemsandinstruments/powervar[AMETEK +Powervar], through Andrew McCartney, has added support for all AMETEK Powervar +UPM models as usb-hid UPS. + * link:http://www.gamatronic.com[Gamatronic], through Nadav Moskovitch, has revived the 'sec' driver (as gamatronic), and expanded a bit genericups for its UPSs with alarm interface. +* link:https://ever.eu/[EVER Power Systems] added a USB HID subdriver for +EVER UPSes (Sinline RT Series, Sinline RT XL Series, ECO PRO AVR CDS Series). + * link:http://www.microdowell.com[Microdowell], through Elio Corbolante, has -created the 'microdowell' driver to support the Enterprise Nxx/Bxx serial devices. -They also proposes NUT as an alternative to its software for +created the 'microdowell' driver to support the Enterprise Nxx/Bxx serial +devices. The company also proposes NUT as an alternative to its software for link:http://www.microdowell.com/fra/download.html[Linux / Unix]. * link:http://pcmups.com.tw[Powercom], through Alexey Morozov, has provided @@ -111,6 +120,13 @@ list, and the rest of the information is available via the link:http://article.gmane.org/gmane.comp.monitoring.nut.user/8173[list archives]. +* link:https://nag.company/en[NAG], through Alexey Kazancev and Igor Ryabov, +has added support for SNR-UPS-LID-XXXX models as usb-hid UPS. + +* link:http://www.ablerex.com.tw/[Ablere Electronics Co., Ltd.] contributed +the ablerex subdriver for blazer_usb, handling Ablerex MP, ARES Plus, MSII +MSIII, GRs and GRs Plus models. + Appliances manufacturers ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -143,20 +159,21 @@ the libhid projects, ... through Arnaud Quette (who was also an MGE employee). All the MGE supporters have gone with Eaton (through MGE Office Protection Systems), which was temporarily the new NUT sponsor. -- Fenton Technologies contributed a PowerPal 660 to the project. Their open -stance and quick responses to technical inquiries were appreciated for +- Fenton Technologies contributed a PowerPal 660 to the project. Their open +stance and quick responses to technical inquiries were appreciated for making the development of the fentonups driver possible. -Fenton has since been acquired by link:http://www.metapo.com[Metapo]. +Fenton has since been acquired by link:http://www.metapo.com[Metapo]. -- Bo Kersey of link:http://www.vircio.com[VirCIO] provided a Best Power Fortress -750 to facilitate the bestups driver. +- Bo Kersey of link:http://www.vircio.com[VirCIO] provided a Best Power +Fortress 750 to facilitate the bestups driver. - Invensys Energy Systems provided the SOLA/Best "Phoenixtec" protocol document. SOLA has since been acquired by Eaton. - PowerKinetics technical support provided documentation on their MiniCOL protocol, which is archived in the NUT protocol library. -PowerKinetics was acquired by the link:http://www.jst.cc[JST Group] in June 2003. +PowerKinetics was acquired by the link:http://www.jst.cc[JST Group] +in June 2003. - link:http://www.cyberpowersystems.com[Cyber Power Systems] contributed a 700AVR model for testing and development of the cyberpower driver. @@ -166,7 +183,12 @@ and a UPStation GXT2 with the Web/SNMP card for development of the liebert driver and expansion of the existing snmp-ups driver. Liebert has since been acquired by link:http://www.emerson.com[Emerson]. -NOTE: If a company or individual isn't listed here, then we probably don't have -enough information about the situation. Developers are requested to report vendor -contributions to the NUT team so this list may reflect their help. -If we have left you out, send us some mail. +NOTE: If a company or individual isn't listed here, then we probably don't +have enough information about the situation. Developers are kindly requested +to report vendor contributions to the NUT team so this list may reflect their +help, as well as convey a sense of official support (at least, that drivers +were proposed according to the know-how coming from specs and knowledge about +hardware and firmware capabilities, and not acquired via reverse engineering +with a certain degree of unreliability and incompleteness). If we have left +you out, please send us some mail or post a pull request to update this +document in GitHub. diff --git a/docs/asciidoc.txt b/docs/asciidoc.txt new file mode 100644 index 0000000..1f7b391 --- /dev/null +++ b/docs/asciidoc.txt @@ -0,0 +1,19 @@ +Using AsciiDoc in NUT +===================== +Charles Lepple +:Author Initials: CFL + +Intro +----- + +See the https://asciidoc-py.github.io/userguide.html[AsciiDoc User Guide] +for more information. + +Works in Progress +----------------- + +- link:website/index.html[The NUT Website] +- link:user-manual.html[The NUT User Manual] +- link:developer-guide.html[The NUT Developer Guide] +- link:packager-guide.html[The NUT Packager Guide] +- link:man/index.html[Man pages] diff --git a/docs/cables.txt b/docs/cables.txt index afc2c29..df4ca78 100644 --- a/docs/cables.txt +++ b/docs/cables.txt @@ -37,20 +37,20 @@ OmniGuard F6C***-RKM *From "Daniel"* -A straight-through RS-232 cable (with pins 2-7 connected through) should work -with the following models: +A straight-through RS-232 cable (with pins 2-7 connected through) should +work with the following models: - F6C110-RKM-2U - F6C150-RKM-2U - F6C230-RKM-2U -- F6C320-RKM-3U +- F6C320-RKM-3U image::images/cables/belkin-f6cx-rkm-xu-cable.jpg[Belkin OmniGuard F6C***-RKM cable] Eaton ----- -Documents in this section are provided courtesy of Eaton. +Documents in this section are provided courtesy of Eaton. MGE Office Protection Systems ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -127,7 +127,7 @@ This cable can be used with the following models: T700, T1000, T1500, T1500j, T700h, T1000h, T1500h, R1500, R1500j, R1500h, T2000, T2000j, T2400h, T2400h-NA, R3000 / R3000j, R3000h, -R3000h-International, R3000h-NA, R6000h-NA, R6000i, R6000j. +R3000h-International, R3000h-NA, R6000h-NA, R6000i, R6000j. UPS PC 9 pin connector @@ -143,8 +143,8 @@ Contributed by Kjell Claesson and Arnaud Quette. Phoenixtec (Best Power) ----------------------- -Many Best Power units (including the Patriot Pro II) have a female DB-9 socket -with a non-standard pinout. +Many Best Power units (including the Patriot Pro II) have a female DB-9 +socket with a non-standard pinout. |==== |Signal | PC | UPS @@ -166,7 +166,7 @@ Tripp-Lite *From Tripp-Lite, via Bryan Kolodziej* -This cable (black 73-0844 cable) is used on various models, using the "Lan 2.2 interface" -and the genericups driver (upstype=5). +This cable (black 73-0844 cable) is used on various models, using the +"Lan 2.2 interface" and the genericups driver (upstype=5). image::images/cables/73-0724.png[73-0724 cable] diff --git a/docs/cables/Makefile.am b/docs/cables/Makefile.am new file mode 100644 index 0000000..8cdb1d3 --- /dev/null +++ b/docs/cables/Makefile.am @@ -0,0 +1,2 @@ +CLEANFILES = *-spellchecked +MAINTAINERCLEANFILES = Makefile.in .dirstamp diff --git a/docs/cables/Makefile.in b/docs/cables/Makefile.in new file mode 100644 index 0000000..bd4629b --- /dev/null +++ b/docs/cables/Makefile.in @@ -0,0 +1,566 @@ +# Makefile.in generated by automake 1.16.3 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2020 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = docs/cables +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/nut_arg_with.m4 \ + $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ + $(top_srcdir)/m4/nut_check_libavahi.m4 \ + $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ + $(top_srcdir)/m4/nut_check_libgd.m4 \ + $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ + $(top_srcdir)/m4/nut_check_libneon.m4 \ + $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ + $(top_srcdir)/m4/nut_check_libnss.m4 \ + $(top_srcdir)/m4/nut_check_libopenssl.m4 \ + $(top_srcdir)/m4/nut_check_libpowerman.m4 \ + $(top_srcdir)/m4/nut_check_libusb.m4 \ + $(top_srcdir)/m4/nut_check_libwrap.m4 \ + $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ + $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ + $(top_srcdir)/m4/nut_type_socklen_t.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +SOURCES = +DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +A2X = @A2X@ +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +ASCIIDOC = @ASCIIDOC@ +ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BINDIR = @BINDIR@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CONFPATH = @CONFPATH@ +CPP = @CPP@ +CPPCHECK = @CPPCHECK@ +CPPFLAGS = @CPPFLAGS@ +CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ +CPPUNIT_LIBS = @CPPUNIT_LIBS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DBLATEX = @DBLATEX@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ +DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ +DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ +DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ +DRVPATH = @DRVPATH@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBAVAHI_CFLAGS = @LIBAVAHI_CFLAGS@ +LIBAVAHI_LIBS = @LIBAVAHI_LIBS@ +LIBDIR = @LIBDIR@ +LIBGD_CFLAGS = @LIBGD_CFLAGS@ +LIBGD_LDFLAGS = @LIBGD_LDFLAGS@ +LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ +LIBIPMI_LIBS = @LIBIPMI_LIBS@ +LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ +LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ +LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ +LIBNEON_LIBS = @LIBNEON_LIBS@ +LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ +LIBNETSNMP_LIBS = @LIBNETSNMP_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBPOWERMAN_CFLAGS = @LIBPOWERMAN_CFLAGS@ +LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ +LIBS = @LIBS@ +LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ +LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ +LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ +LIBUSB_LIBS = @LIBUSB_LIBS@ +LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ +LIBWRAP_LIBS = @LIBWRAP_LIBS@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LN_S_R = @LN_S_R@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ +NUT_NETVERSION = @NUT_NETVERSION@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OS_NAME = @OS_NAME@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PIDPATH = @PIDPATH@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ +RANLIB = @RANLIB@ +RUN_AS_GROUP = @RUN_AS_GROUP@ +RUN_AS_USER = @RUN_AS_USER@ +SBINDIR = @SBINDIR@ +SED = @SED@ +SERLIBS = @SERLIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOURCE_HIGHLIGHT = @SOURCE_HIGHLIGHT@ +STATEPATH = @STATEPATH@ +STRIP = @STRIP@ +SUN_LIBUSB = @SUN_LIBUSB@ +TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ +VERSION = @VERSION@ +WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ +XMLLINT = @XMLLINT@ +XSLTPROC = @XSLTPROC@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +auglensdir = @auglensdir@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +cgiexecdir = @cgiexecdir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +devddir = @devddir@ +docdir = @docdir@ +driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +hotplugdir = @hotplugdir@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +now = @now@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgconfigdir = @pkgconfigdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +systemdshutdowndir = @systemdshutdowndir@ +systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +udevdir = @udevdir@ +CLEANFILES = *-spellchecked +MAINTAINERCLEANFILES = Makefile.in .dirstamp +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu docs/cables/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu docs/cables/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags TAGS: + +ctags CTAGS: + +cscope cscopelist: + + +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + cscopelist-am ctags-am distclean distclean-generic \ + distclean-libtool distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags-am uninstall uninstall-am + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/docs/cables/apc-rs500-serial.txt b/docs/cables/apc-rs500-serial.txt index ef89ed6..9a35a2a 100644 --- a/docs/cables/apc-rs500-serial.txt +++ b/docs/cables/apc-rs500-serial.txt @@ -1,7 +1,7 @@ Desc: APC UPS cable - for Back-UPS RS 500 File: apc-rs500-serial.txt Date: 14 July 2004 -Auth: Russell Kroll , Martin Edlman +Auth: Russell Kroll , Martin Edlman This document was constructed from a mail from Martin. He figured out the pinouts to make the Back-UPS RS 500 work with a normal serial port. diff --git a/docs/cables/ge-imv-victron.txt b/docs/cables/ge-imv-victron.txt index bffed19..6a84417 100644 --- a/docs/cables/ge-imv-victron.txt +++ b/docs/cables/ge-imv-victron.txt @@ -25,7 +25,7 @@ Data cable 2 for UPS: Driver: victronups (newvictronups) - + UPS PC 9 pin connector 2 --------- 3 3 --------- 2 @@ -39,13 +39,13 @@ UPS PC 9 pin connector Crack cable: for UPS Victron Lite (no IMV Victron Match Lite) - + Driver: genericsups UPS PC 9 pin connector 1 ---------- 4 DTR -7 ---------- 1 DCD ----------+ +7 ---------- 1 DCD ----------+ 9 ---------- 8 CTS -----+ | 5 ---------- 5 GND | | | | diff --git a/docs/cables/powerware.txt b/docs/cables/powerware.txt index 3aa127b..1db1a77 100644 --- a/docs/cables/powerware.txt +++ b/docs/cables/powerware.txt @@ -1,8 +1,8 @@ Desc: Powerware 3115 factory cable File: powerware.txt -Date: 22 July 2005 +Date: 22 July 2005 Auth: various - + 1) Powerware 3115 factory cable From Peter Åstrand diff --git a/docs/cables/repotec.txt b/docs/cables/repotec.txt index 6df107a..3d26a70 100644 --- a/docs/cables/repotec.txt +++ b/docs/cables/repotec.txt @@ -2,7 +2,7 @@ Desc: Repotec 800A (800VA) & 162A (1600VA) cable File: repotec.txt Date: 11 April 2001 Auth: Theodor Milkov - + PC UPS @@ -11,9 +11,9 @@ PC UPS R 5.6k | 7 (RTS) >----+ - + 3 (Tx) >--------------- 6 - + 4 (DTR) <----+---------- 5 | R 5.6k diff --git a/docs/cables/sms.txt b/docs/cables/sms.txt index 6d7ab73..54f3b81 100644 --- a/docs/cables/sms.txt +++ b/docs/cables/sms.txt @@ -1,4 +1,4 @@ -Desc: SMS UPS cables, for Upsilon compatible SMS UPS +Desc: SMS UPS cables, for Upsilon compatible SMS UPS File: sms.txt Date: 9 October 2001 Auth: Marcio Gomes @@ -11,6 +11,6 @@ FEMEA DB9 MACHO DB9 4/8 ---------- 5 5 ---------- 8 -- This cable is working with Manager III 1300 VA and 650 VA, SMS Ups's -- Jump in computer side pins 4/8 and conect to pin 1 in UPS side +- This cable is working with Manager III 1300 VA and 650 VA, SMS UPS's +- Jump in computer side pins 4/8 and connect to pin 1 in UPS side - Use NUT blazer_ser driver diff --git a/docs/ci-farm-lxc-setup.txt b/docs/ci-farm-lxc-setup.txt new file mode 100644 index 0000000..0e7fa7f --- /dev/null +++ b/docs/ci-farm-lxc-setup.txt @@ -0,0 +1,693 @@ +Setting up the multi-arch Linux LXC container farm for NUT CI +------------------------------------------------------------- + +Due to some historical reasons including earlier personal experience, +the Linux container setup implemented as described below was done with +persistent LXC containers wrapped by LIBVIRT for management. There was +no particular use-case for systems like Docker (and no firepower for a +Kubernetes cluster) in that the build environment intended for testing +non-regression against a certain release does not need to be regularly +updated -- its purpose is to be stale and represent what users still +running that system for whatever reason (e.g. embedded, IoT, corporate) +have in their environments. + +Common preparations +~~~~~~~~~~~~~~~~~~~ + +* Prepare LXC and LIBVIRT-LXC integration, including an "independent" + (aka "masqueraded) bridge for NAT, following https://wiki.debian.org/LXC + and https://wiki.debian.org/LXC/SimpleBridge +** For dnsmasq integration on the independent bridge (`lxcbr0` following + the documentation examples), be sure to mention: +*** `LXC_DHCP_CONFILE="/etc/lxc/dnsmasq.conf"` in `/etc/default/lxc-net` +*** `dhcp-hostsfile=/etc/lxc/dnsmasq-hosts.conf` in/as the content of + `/etc/lxc/dnsmasq.conf` +*** `touch /etc/lxc/dnsmasq-hosts.conf` which would list simple `name,IP` + pairs, one per line (so one per container) +*** `systemctl restart lxc-net` to apply config (is this needed after + setup of containers too, to apply new items before booting them?) + +* Install qemu with its `/usr/bin/qemu-*-static` and registration in + `/var/lib/binfmt` + +* Prepare an LVM partition (or preferably some other tech like ZFS) + as `/srv/libvirt` and create a `/srv/libvirt/rootfs` to hold the containers + +* Prepare `/home/abuild` on the host system (preferably in ZFS with + lightweight compression like lz4 -- and optionally, only if the amount + of available system RAM permits, with deduplication; otherwise avoid it); + account user and group ID numbers are `399` as on the rest of the CI farm + (historically, inherited from OBS workers) + +** It may help to generate an ssh key without a passphrase for `abuild` + that it would trust, to sub-login from CI agent sessions into the + container. Then again, it may be not required if CI logs into the + host by SSH using `authorized_keys` and an SSH Agent, and the inner + ssh client would forward that auth channel to the original agent. ++ +------ +abuild$ ssh-keygen +# accept defaults + +abuild$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys +abuild$ chmod 640 ~/.ssh/authorized_keys +------ + +* Edit the root (or whoever manages libvirt) `~/.profile` to default the + virsh provider with: ++ +------ +LIBVIRT_DEFAULT_URI=lxc:///system +export LIBVIRT_DEFAULT_URI +------ + +* If host root filesystem is small, relocate the LXC download cache to the + (larger) `/srv/libvirt` partition: ++ +------ +:; mkdir -p /srv/libvirt/cache-lxc +:; rm -rf /var/cache/lxc +:; ln -sfr /srv/libvirt/cache-lxc /var/cache/lxc +------ +** Maybe similarly relocate shared `/home/abuild` to reduce strain on rootfs? + + +Setup a container +~~~~~~~~~~~~~~~~~ + +Note that completeness of qemu CPU emulation varies, so not all distros +can be installed, e.g. "s390x" failed for both debian10 and debian11 to +set up the `openssh-server` package, or once even to run `/bin/true` (seems +to have installed an older release though, to match the outdated emulation?) + +While the `lxc-create` tool does not really specify the error cause and +deletes the directories after failure, it shows the pathname where it +writes the log (also deleted). Before re-trying the container creation, this +file can be watched with e.g. `tail -F /var/cache/lxc/.../debootstrap.log` + +[NOTE] +====== +You can find the list of LXC "template" definitions on your system +by looking at the contents of the `/usr/share/lxc/templates/` directory, +e.g. a script named `lxc-debian` for the "debian" template. You can see +further options for each "template" by invoking its help action, e.g.: +------ +:; lxc-create -t debian -h +------ +====== + +* Install containers like this: ++ +------ +:; lxc-create -P /srv/libvirt/rootfs \ + -n jenkins-debian11-mips64el -t debian -- \ + -r bullseye -a mips64el +------ +** to specify a particular mirror (not everyone hosts everything -- + so if you get something like + `"E: Invalid Release file, no entry for main/binary-mips/Packages"` + then see https://www.debian.org/mirror/list for details, and double-check + the chosen site to verify if the distro version of choice is hosted with + your arch of choice): ++ +------ +:; MIRROR="http://ftp.br.debian.org/debian/" \ + lxc-create -P /srv/libvirt/rootfs \ + -n jenkins-debian10-mips -t debian -- \ + -r buster -a mips +------ +** ...or for EOLed distros, use the archive, e.g.: ++ +------ +:; MIRROR="http://archive.debian.org/debian-archive/debian/" \ + lxc-create -P /srv/libvirt/rootfs \ + -n jenkins-debian8-s390x -t debian -- \ + -r jessie -a s390x +------ +** ...Alternatively, other distributions can be used (as supported by your + LXC scripts, typically in `/usr/share/debootstrap/scripts`), e.g. Ubuntu: ++ +------ +:; lxc-create -P /srv/libvirt/rootfs \ + -n jenkins-ubuntu1804-s390x -t ubuntu -- \ + -r bionic -a s390x +------ +** For distributions with a different packaging mechanism from that on the + LXC host system, you may need to install corresponding tools (e.g. `yum4`, + `rpm` and `dnf` on Debian hosts for installing CentOS and related guests). + You may also need to pepper with symlinks to taste (e.g. `yum => yum4`), + or find a `pacman` build to install Arch Linux or derivative, etc. + Otherwise, you risk seeing something like this: ++ +------ +root@debian:~# lxc-create -P /srv/libvirt/rootfs \ + -n jenkins-centos7-x86-64 -t centos -- \ + -R 7 -a x86_64 + +Host CPE ID from /etc/os-release: +'yum' command is missing +lxc-create: jenkins-centos7-x86-64: lxccontainer.c: + create_run_template: 1616 Failed to create container from template +lxc-create: jenkins-centos7-x86-64: tools/lxc_create.c: + main: 319 Failed to create container jenkins-centos7-x86-64 +------ ++ +Note also that with such "third-party" distributions you may face other + issues; for example, the CentOS helper did not generate some fields in + the `config` file that were needed for conversion into libvirt "domxml" + (as found by trial and error, and comparison to other `config` files): ++ +------ +lxc.uts.name = jenkins-centos7-x86-64 +lxc.arch = x86_64 +------ ++ +Also note the container/system naming without underscore in "x86_64" -- + the deployed system discards the character when assigning its hostname. + Using "amd64" is another reasonable choice here. + +* Add the "name,IP" line for this container to `/etc/lxc/dnsmasq-hosts.conf` + on the host, e.g.: ++ +------ +jenkins-debian11-mips,10.0.3.245 +------ ++ +NOTE: Don't forget to eventually `systemctl restart lxc-net` to apply the +new host reservation! + +* Convert a pure LXC container to be managed by LIBVIRT-LXC (and edit config + markup on the fly -- e.g. fix the LXC `dir:/` URL schema): ++ +------ +:; virsh -c lxc:///system domxml-from-native lxc-tools \ + /srv/libvirt/rootfs/jenkins-debian11-armhf/config \ + | sed -e 's,dir:/srv,/srv,' \ + > /tmp/x && virsh define /tmp/x +------ ++ +NOTE: You may want to tune the default generic 64MB RAM allocation, + so your launched QEMU containers are not OOM-killed as they exceeded + their memory `cgroup` limit. In practice they do not eat *that much* + resident memory, just want to have it addressable by VMM, I guess + (swap is not very used either), at least not until active builds + start (and then it depends on compiler appetite and `make` program + parallelism level you allow, e.g. by pre-exporting `MAXPARMAKES` + environment variable for `ci_build.sh`, and on the number of Jenkins + "executors" assigned to the build agent). ++ +** It may be needed to revert the generated "os/arch" to `x86_64` (and let + QEMU handle the rest) in the `/tmp/x` file, and re-try the definition: ++ +------ +:; virsh define /tmp/x +------ + +* Then execute `virsh edit jenkins-debian11-armhf` (and same for other + containers) to bind-mount the common `/home/abuild` location, adding + this tag to their "devices": ++ +------ + + + + +------ +** Note that generated XML might not conform to current LXC schema, so it + fails validation during save; this can be bypassed with `i` when it asks. + One such case was however with indeed invalid contents, the "dir:" schema + removed by example above. + + +Shepherd the herd +~~~~~~~~~~~~~~~~~ + +* Monitor deployed container rootfs'es with: ++ +------ +:; du -ks /srv/libvirt/rootfs/* +------ ++ +(should have non-trivial size for deployments without fatal infant errors) + +* Mass-edit/review libvirt configurations with: ++ +------ +:; virsh list --all | awk '{print $2}' \ + | grep jenkins | while read X ; do \ + virsh edit --skip-validate $X ; done +------ +** ...or avoid `--skip-validate` when markup is initially good :) + +* Mass-define network interfaces: ++ +------ +:; virsh list --all | awk '{print $2}' \ + | grep jenkins | while read X ; do \ + virsh dumpxml "$X" | grep "bridge='lxcbr0'" \ + || virsh attach-interface --domain "$X" --config \ + --type bridge --source lxcbr0 ; \ + done +------ + +* Verify that unique MAC addresses were defined (e.g. `00:16:3e:00:00:01` + tends to pop up often, while `52:54:00:xx:xx:xx` are assigned to other + containers); edit the domain definitions to randomize, if needed: ++ +------ +:; grep 'mac add' /etc/libvirt/lxc/*.xml | awk '{print $NF" "$1}' | sort +------ + +* Make sure at least one console device exists (end of file, under the + network interface definition tags), e.g.: ++ +------ + + + +------ + +* Populate with `abuild` account, as well as with the `bash` shell and + `sudo` ability, reporting of assigned IP addresses on the console, + and SSH server access complete with envvar passing from CI clients + by virtue of `ssh -o SendEnv='*' container-name`: ++ +------ +:; for ALTROOT in /srv/libvirt/rootfs/*/rootfs/ ; do \ + echo "=== $ALTROOT :" >&2; \ + grep eth0 "$ALTROOT/etc/issue" || ( printf '%s %s\n' \ + '\S{NAME} \S{VERSION_ID} \n \l@\b ;' \ + 'Current IP(s): \4{eth0} \4{eth1} \4{eth2} \4{eth3}' \ + >> "$ALTROOT/etc/issue" ) ; \ + grep eth0 "$ALTROOT/etc/issue.net" || ( printf '%s %s\n' \ + '\S{NAME} \S{VERSION_ID} \n \l@\b ;' \ + 'Current IP(s): \4{eth0} \4{eth1} \4{eth2} \4{eth3}' \ + >> "$ALTROOT/etc/issue.net" ) ; \ + groupadd -R "$ALTROOT" -g 399 abuild ; \ + useradd -R "$ALTROOT" -u 399 -g abuild -M -N -s /bin/bash abuild \ + || useradd -R "$ALTROOT" -u 399 -g 399 -M -N -s /bin/bash abuild \ + || { if ! grep -w abuild "$ALTROOT/etc/passwd" ; then \ + echo 'abuild:x:399:399::/home/abuild:/bin/bash' \ + >> "$ALTROOT/etc/passwd" ; \ + echo "USERADDed manually: passwd" >&2 ; \ + fi ; \ + if ! grep -w abuild "$ALTROOT/etc/shadow" ; then \ + echo 'abuild:!:18889:0:99999:7:::' >> "$ALTROOT/etc/shadow" ; \ + echo "USERADDed manually: shadow" >&2 ; \ + fi ; \ + } ; \ + if [ -s "$ALTROOT/etc/ssh/sshd_config" ]; then \ + grep 'AcceptEnv \*' "$ALTROOT/etc/ssh/sshd_config" || ( \ + ( echo "" ; \ + echo "# For CI: Allow passing any envvars:"; \ + echo 'AcceptEnv *' ) \ + >> "$ALTROOT/etc/ssh/sshd_config" \ + ) ; \ + fi ; \ + done +------ ++ +Note that for some reason, in some of those other-arch distros `useradd` +fails to find the group anyway; then we have to "manually" add them. + +* Let the host know and resolve the names/IPs of containers you assigned: ++ +------ +:; grep -v '#' /etc/lxc/dnsmasq-hosts.conf \ + | while IFS=, read N I ; do \ + getent hosts "$N" >&2 || echo "$I $N" ; \ + done >> /etc/hosts +------ + +Further setup of the containers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +See NUT `docs/config-prereqs.txt` about dependency package installation +for Debian-based Linux systems. + +It may be wise to not install e.g. documentation generation tools (or at +least not the full set for HTML/PDF generation) in each environment, in +order to conserve space and run-time stress. + +Still, if there are significant version outliers (such as using an older +distribution due to vCPU requirements), it can be installed fully just +to ensure non-regression -- e.g. that when adapting `Makefile` rule +definitions or compiler arguments to modern toolkits, we do not lose +the ability to build with older ones. + +For this, `chroot` from the host system can be used, e.g. to improve the +interactive usability for a population of Debian(-compatible) containers +(and to use its networking, while the operating environment in containers +may be not yet configured or still struggling to access the Internet): +------ +:; for ALTROOT in /srv/libvirt/rootfs/*/rootfs/ ; do \ + echo "=== $ALTROOT :" ; \ + chroot "$ALTROOT" apt-get install \ + sudo bash vim mc p7zip p7zip-full pigz pbzip2 git \ + ; done +------ + +Similarly for `yum`-managed systems (CentOS and relatives), though specific +package names can differ, and additional package repositories may need to +be enabled first (see link:config-prereqs.txt[config-prereqs.txt] for more +details such as recommended package names). + +Note that technically `(sudo) chroot ...` can also be used from the CI worker +account on the host system to build in the prepared filesystems without the +overhead of running containers as complete operating environments with any +standard services and several copies of Jenkins `agent.jar` in them. + +Also note that externally-driven set-up of some packages, including the +`ca-certificates` and the JDK/JRE, require that the `/proc` filesystem +is usable in the chroot environment. This can be achieved with e.g.: +------ +:; for ALTROOT in /srv/libvirt/rootfs/*/rootfs/ ; do \ + for D in proc ; do \ + echo "=== $ALTROOT/$D :" ; \ + mkdir -p "$ALTROOT/$D" ; \ + mount -o bind,rw "/$D" "$ALTROOT/$D" ; \ + done ; \ + done +------ + +TODO: Test and document a working NAT and firewall setup for this, to allow +SSH access to the containers via dedicated TCP ports exposed on the host. + + +Troubleshooting +~~~~~~~~~~~~~~~ + +* Q: Container won't start, its `virsh console` says something like: ++ +------ +Failed to create symlink /sys/fs/cgroup/net_cls: Operation not permitted +------ +A: According to https://bugzilla.redhat.com/show_bug.cgi?id=1770763 + (skip to the end for summary) this can happen when a newer Linux + host system with `cgroupsv2` capabilities runs an older guest distro + which only knows about `cgroupsv1`, such as when hosting a CentOS 7 + container on a Debian 11 server. +** One workaround is to ensure that the guest `systemd` does not try to + "join" host facilities, by setting an explicit empty list for that: ++ +------ +:; echo 'JoinControllers=' >> "$ALTROOT/etc/systemd/system.conf" +------ +** Another approach is to upgrade `systemd` related packages in the guest + container. This may require additional "backport" repositories or + similar means, possibly maintained not by distribution itself but by + other community members, and arguably would logically compromise the + idea of non-regression builds in the old environment "as is". + +* Q: Server was set up with ZFS as recommended, and lots of I/O hit the + disk even when application writes are negligible ++ +A: This was seen on some servers and generally derives from data layout + and how ZFS maintains the tree structure of blocks. A small application + write (such as a new log line) means a new empty data block allocation, + an old block release, and bubble up through the whole metadata tree to + complete the transaction (grouped as TXG to flush to disk). ++ +** One solution is to use discardable build workspaces in RAM-backed + storage like `/dev/shm` (`tmpfs`) on Linux, or `/tmp` (`swap`) on + illumos hosting systems, and only use persistent storage for the home + directory with `.ccache` and `.gitcache-dynamatrix` directories. +** Another solution is to reduce the frequency of TXG sync from modern + default of 5 sec to conservative 30-60 sec. Check how to set the + `zfs_txg_timeout` on your platform. + + +Connecting Jenkins to the containers +------------------------------------ + +To properly cooperate with the +https://github.com/networkupstools/jenkins-dynamatrix[jenkins-dynamatrix] +project driving regular NUT CI builds, each build environment should be +exposed as an individual agent with labels describing its capabilities. + +Agent Labels +~~~~~~~~~~~~ + +With the `jenkins-dynamatrix`, agent labels are used to calculate a large +"slow build" matrix to cover numerous scenarios for what can be tested +with the current population of the CI farm, across operating systems, +`make`, shell and compiler implementations and versions, and C/C++ language +revisions, to name a few common "axes" involved. + +Labels for QEMU +^^^^^^^^^^^^^^^ + +Emulated-CPU container builds are CPU-intensive, so for them we define as +few capabilities as possible: here CI is more interested in checking how +binaries behave on those CPUs, *not* in checking the quality of recipes +(distcheck, Make implementations, etc.), shell scripts or documentation, +which is more efficient to test on native platforms. + +Still, we are interested in results from different compiler suites, so +specify at least one version of each. + +NOTE: Currently the NUT `Jenkinsfile-dynamatrix` only looks at various +`COMPILER` variants for `qemu-nut-builder` use-cases, disregarding the +versions and just using one that the environment defaults to. + +The reduced set of labels for QEMU workers looks like: + +------ +qemu-nut-builder qemu-nut-builder:alldrv +NUT_BUILD_CAPS=drivers:all NUT_BUILD_CAPS=cppunit +OS_FAMILY=linux OS_DISTRO=debian11 GCCVER=10 CLANGVER=11 +COMPILER=GCC COMPILER=CLANG +ARCH64=ppc64le ARCH_BITS=64 +------ + +Labels for native builds +^^^^^^^^^^^^^^^^^^^^^^^^ + +For contrast, a "real" build agent's set of labels, depending on +presence or known lack of some capabilities, looks something like this: +------ +doc-builder nut-builder nut-builder:alldrv +NUT_BUILD_CAPS=docs:man NUT_BUILD_CAPS=docs:all +NUT_BUILD_CAPS=drivers:all NUT_BUILD_CAPS=cppunit=no +OS_FAMILY=bsd OS_DISTRO=freebsd12 GCCVER=10 CLANGVER=10 +COMPILER=GCC COMPILER=CLANG +ARCH64=amd64 ARCH_BITS=64 +SHELL_PROGS=sh SHELL_PROGS=dash SHELL_PROGS=zsh SHELL_PROGS=bash +SHELL_PROGS=csh SHELL_PROGS=tcsh SHELL_PROGS=busybox +MAKE=make MAKE=gmake +PYTHON=python2.7 PYTHON=python3.8 +------ + +Generic agent attributes +~~~~~~~~~~~~~~~~~~~~~~~~ + +* Name: e.g. `ci-debian-altroot--jenkins-debian10-arm64` (note the + pattern for "Conflicts With" detailed below) + +* Remote root directory: preferably unique per agent, to avoid surprises; + e.g.: `/home/abuild/jenkins-nut-altroots/jenkins-debian10-armel` +** Note it may help that the system home directory itself is shared between + co-located containers, so that the `.ccache` or `.gitcache-dynamatrix` + are available to all builders with identical contents +** If RAM permits, the Jenkins Agent working directory may be placed in + a temporary filesystem not backed by disk (e.g. `/dev/shm` on modern + Linux distributions); roughly estimate 300Mb per executor for NUT builds. + +* Usage: "Only build jobs with label expressions matching this node" + +* Node properties / Environment variables: + +** `PATH+LOCAL` => `/usr/lib/ccache` + +Where to run agent.jar +~~~~~~~~~~~~~~~~~~~~~~ + +Depending on circumstances of the container, there are several options +available to the NUT CI farm: + +* Java can run in the container, efficiently (native CPU, different distro) + => the container may be exposed as a standalone host for direct SSH access + (usually by NAT, exposing SSH on a dedicated port of the host; or by first + connecting the Jenkins controller with the host as an SSH Build Agent, and + then calling SSH to the container as a prefix for running the agent; or + by using Jenkins Swarm agents), so ultimately the build `agent.jar` JVM + would run in the container. + Filesystem for the `abuild` account may be or not be shared with the host. + +* Java can not run in the container (crashes on emulated CPU, or is too old + in the agent container's distro -- currently Jenkins requires JRE 8+, but + eventually will require 11+) => the agent would run on the host, and then + the host would `ssh` or `chroot` (networking not required, but bind-mount + of `/home/abuild` and maybe other paths from host would be needed) called + for executing `sh` steps in the container environment. Either way, home + directory of the `abuild` account is maintained on the host and shared with + the guest environment, user and group IDs should match. + +* Java is inefficient in the container (operations like un-stashing the source + succeed but take minutes instead of seconds) => either of the above + +Using Jenkins SSH Build Agents +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This is a typical use-case for tightly integrated build farms under common +management, where the Jenkins controller can log by SSH into systems which +act as its build agents. It injects and launches the `agent.jar` to execute +child processes for the builds, and maintains a tunnel to communicate. + +Methods below involving SSH assume that you have configured a password-less +key authentication from the host machine to the `abuild` account in each +guest build environment container. +This can be an `ssh-keygen` result posted into `authorized_keys`, or a +trusted key passed by a chain of ssh agents from a Jenkins Credential +for connection to the container-hoster into the container. +The private SSH key involved may be secured by a pass-phrase, as long as +your Jenkins Credential storage knows it too. +Note that for the approaches explored below, the containers are not +directly exposed for log-in from any external network. + +* For passing the agent through an SSH connection from host to container, + so that the `agent.jar` runs inside the container environment, configure: + +** Launch method: "Agents via SSH" + +** Host, Credentials, Port: as suitable for accessing the container-hoster ++ +NOTE: The container-hoster should have accessed the guest container from + the account used for intermediate access, e.g. `abuild`, so that its + `.ssh/known_hosts` file would trust the SSH server on the container. + +** Prefix Start Agent Command: content depends on the container name, + but generally looks like the example below to report some info about + the final target platform (and make sure `java` is usable) in the + agent's log. Note that it ends with un-closed quote and a space char: ++ +------ +ssh jenkins-debian10-amd64 '( java -version & uname -a ; getconf LONG_BIT; getconf WORD_BIT; wait ) && +------ + +** Suffix Start Agent Command: a single quote to close the text opened above: +------ +' +------ + + +* The other option is to run the `agent.jar` on the host, for all the + network and filesystem magic the agent does, and only execute shell + steps in the container. The solution relies on overridden `sh` step + implementation in the `jenkins-dynamatrix` shared library that uses a + magic `CI_WRAP_SH` environment variable to execute a pipe into the + container. Such pipes can be `ssh` or `chroot` with appropriate host + setup described above. ++ +NOTE: In case of ssh piping, remember that the container's + `/etc/ssh/sshd_config` should `AcceptEnv *` and the SSH + server should be restarted after such configuration change. + +** Launch method: "Agents via SSH" + +** Host, Credentials, Port: as suitable for accessing the container-hoster + +** Prefix Start Agent Command: content depends on the container name, + but generally looks like the example below to report some info about + the final target platform (and make sure it is accessible) in the + agent's log. Note that it ends with a space char, and that the command + here should not normally print anything into stderr/stdout (this tends + to confuse the Jenkins Remoting protocol): ++ +------ +echo PING > /dev/tcp/jenkins-debian11-ppc64el/22 && +------ + +** Suffix Start Agent Command: empty + +* Node properties / Environment variables: + +** `CI_WRAP_SH` => ++ +------ +ssh -o SendEnv='*' "jenkins-debian11-ppc64el" /bin/sh -xe +------ + +Using Jenkins Swarm Agents +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This approach allows remote systems to participate in the NUT CI farm by +dialing in and so defining an agent. A single contributing system may be +running a number of containers or virtual machines set up following the +instructions above, and each of those would be a separate build agent. + +Such systems should be "dedicated" to contribution in the sense that +they should be up and connected for days, and sometimes tasks would land. + +Configuration files maintained on the Swarm Agent system dictate which +labels or how many executors it would expose, etc. Credentials to access +the NUT CI farm Jenkins controller to register as an agent should be +arranged with the farm maintainers, and currently involve a GitHub account +with Jenkins role assignment for such access, and a token for authentication. + +The https://github.com/networkupstools/jenkins-swarm-nutci[jenkins-swarm-nutci] +repository contains example code from such setup with a back-up server +experiment for the NUT CI farm, including auto-start method scripts for +Linux systemd and upstart, illumos SMF, and OpenBSD rcctl. + +Sequentializing the stress +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Running one agent at a time +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Another aspect of farm management is that emulation is a slow and intensive +operation, so we can not run all agents and execute builds at the same time. + +The current solution relies on +https://github.com/jimklimov/conflict-aware-ondemand-retention-strategy-plugin +to allow co-located build agents to "conflict" with each other -- when one +picks up a job from the queue, it blocks neighbors from starting; when it +is done, another may start. + +Containers can be configured with "Availability => On demand", with shorter +cycle to switch over faster (the core code sleeps a minute between attempts): + +* In demand delay: `0`; + +* Idle delay: `0` (Jenkins may change it to `1`); + +* Conflicts with: `^ci-debian-altroot--.*$` assuming that is the pattern + for agent definitions in Jenkins -- not necessarily linked to hostnames. + +Also, the "executors" count should be reduced to the amount of compilers +in that system (usually 2) and so avoid extra stress of scheduling too many +emulated-CPU builds at once. + +Sequentializing the git cache access +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +As part of the `jenkins-dynamatrix` optional optimizations, the NUT CI +recipe invoked via `Jenkinsfile-dynamatrix` maintains persistent git +reference repositories that can be used to cache NUT codebase (including +the tested commits) and so considerably speed up workspace preparation +when running numerous build scenarios on the same agent. + +Such `.gitcache-dynamatrix` cache directories are located in the build +workspace location (unique for each agent), but on a system with numerous +containers these names can be symlinks pointing to a shared location. + +To avoid collisions with several executors updating the same cache with +new commits, critical access windows are sequentialized with the use of +https://github.com/jenkinsci/lockable-resources-plugin[Lockable Resources +plugin]. On the `jenkins-dynamatrix` side this is facilitated by labels: +------ +DYNAMATRIX_UNSTASH_PREFERENCE=scm-ws:nut-ci-src +DYNAMATRIX_REFREPO_WORKSPACE_LOCKNAME=gitcache-dynamatrix:SHARED_HYPERVISOR_NAME +------ + +* The `DYNAMATRIX_UNSTASH_PREFERENCE` tells the `jenkins-dynamatrix` library + code which checkout/unstash strategy to use on a particular build agent + (following values defined in the library; `scm-ws` means SCM caching + under the agent workspace location, `nut-ci-src` names the cache for + this project); +* The `DYNAMATRIX_REFREPO_WORKSPACE_LOCKNAME` specifies a semi-unique + string: it should be same for all co-located agents which use the same + shared cache location, e.g. guests on the same hypervisor; and it should + be different for unrelated cache locations, e.g. different hypervisors + and stand-alone machines. diff --git a/docs/config-notes.txt b/docs/config-notes.txt index 62983b5..a87ae50 100644 --- a/docs/config-notes.txt +++ b/docs/config-notes.txt @@ -13,8 +13,8 @@ NOTE: NUT does not currently provide proper graphical configuration tools. However, there is now support for linkdoc:developer-guide[Augeas,augeas_user], which will enable the easier creation of configuration tools. Moreover, linkman:nut-scanner[8] is available to discover supported devices -(USB, SNMP, Eaton XML/HTTP and IPMI) and NUT servers (using Avahi or the classic -connection method). +(USB, SNMP, Eaton XML/HTTP and IPMI) and NUT servers (using Avahi or the +classic connection method). Details about the configuration files ------------------------------------- @@ -104,7 +104,7 @@ quotes spanning multiple lines. Basic configuration ------------------- -This chapter describe the base configuration to establish communication with +This chapter describes the base configuration to establish communication with the device. This will be sufficient for PDU. But for UPS and SCD, you will also need to @@ -112,21 +112,35 @@ configure <>. image:images/simple.png[] +On operating systems with service management frameworks (such as Linux +systemd and Solaris/illumos SMF), the life-cycle of driver, data server +and monitoring client daemons is managed respectively by `nut-driver` +(multi-instance service), `nut-server` and `nut-monitor` services. +These are in turn wrapped by an "umbrella" service (or systemd "target") +conveniently called `nut` which allows to easily start or stop all those +of the bundled services, which are enabled on a particular deployment. + [[Driver_configuration]] Driver configuration ~~~~~~~~~~~~~~~~~~~~ -Create one section per UPS in /usr/local/ups/etc/ups.conf +Create one section per UPS in 'ups.conf' -To find out which driver to use, check the <>, -or data/driver.list. +NOTE: The default path for a source installation is `/usr/local/ups/etc`, +while packaged installation will vary. +For example, `/etc/nut` is used on Debian and derivatives, +while `/etc/ups` or `/etc/upsd` is used on RedHat and derivatives. + +To find out which driver to use, check the +<>, +or `data/driver.list(.in)` source file. Once you have picked a driver, create a section for your UPS in -ups.conf. You must supply values for "driver" and "port". +'ups.conf'. You must supply values at least for "driver" and "port". Some drivers may require other flags or settings. The "desc" value is optional, but is recommended to provide a better description of -what your UPS is supporting. +what useful load your UPS is feeding. A typical device without any extra settings looks like this: @@ -135,19 +149,29 @@ A typical device without any extra settings looks like this: port = /dev/ttyS1 desc = "Workstation" -NOTE: USB drivers (usbhid-ups, bcmxcp_usb, tripplite_usb, blazer_usb and -richcomm_usb) are special cases and ignore the 'port' value. +[NOTE] +====== +USB drivers (such as `usbhid-ups` for non-SHUT mode, `nutdrv_qx` for +non-serial mode, `bcmxcp_usb`, `tripplite_usb`, `blazer_usb`, `riello_usb` +and `richcomm_usb`) are special cases and ignore the 'port' value. + You must still set this value, but it does not matter what you set -it to; a common and good practice is to set 'port' to *auto*, but you can -put whatever you like. If you only own one UBS UPS, the driver will -find it automatically. If you own more than one, refer to the driver's -manual page for more information on matching a specific device. +it to; a common and good practice is to set 'port' to *auto*, but you +can put whatever you like. + +If you only own one USB UPS, the driver will find it automatically. + +If you own more than one, refer to the driver's manual page for more +information on matching a specific device. +====== References: linkman:ups.conf[5], linkman:nutupsdrv[8], linkman:bcmxcp_usb[8], linkman:blazer[8], +linkman:nutdrv_qx[8], linkman:richcomm_usb[8], +linkman:riello_usb[8], linkman:tripplite_usb[8], linkman:usbhid-ups[8] @@ -156,16 +180,17 @@ linkman:usbhid-ups[8] Starting the driver(s) ~~~~~~~~~~~~~~~~~~~~~~ -Start the driver(s) for your hardware: +Generally, you can just start the driver(s) for your hardware (all sections +defined in 'ups.conf') using the following command: - /usr/local/ups/sbin/upsdrvctl start + upsdrvctl start Make sure the driver doesn't report any errors. It should show a few details about the hardware and then enter the background. You should get back to the command prompt a few seconds later. For reference, a successful start of the `usbhid-ups` driver looks like this: - # /usr/local/ups/sbin/upsdrvctl start + # upsdrvctl start Network UPS Tools - Generic HID driver 0.34 (2.4.1) USB communication driver 0.31 Using subdriver: MGE HID 1.12 @@ -173,29 +198,96 @@ reference, a successful start of the `usbhid-ups` driver looks like this: If the driver doesn't start cleanly, make sure you have picked the right one for your hardware. You might need to try other drivers -by changing the "driver=" value in ups.conf. +by changing the "driver=" value in 'ups.conf'. Be sure to check the driver's man page to see if it needs any extra -settings in `ups.conf` to detect your hardware. +settings in 'ups.conf' to detect your hardware. If it says `can't bind /var/state/ups/...` or similar, then your state path probably isn't writable by the driver. Check the -<>. +<> vs. the +user account your driver starts as. -After making changes, try the <> step again. +After making changes, try the <> +step again. -References: man pages: linkman:nutupsdrv[8], linkman:upsdrvctl[8] +Driver(s) as a service +~~~~~~~~~~~~~~~~~~~~~~ + +On operating systems with init-scripts managing life-cycle of the operating +environment, the `upsdrvctl` program is also commonly used in those scripts. +It has a few downsides, such as that if the device was not accessible during +OS startup and the driver connection timed out, it would remain not-started +until an administrator (or some other script) "kicks" the driver to retry +startup. Also, startup of the `upsd` data server daemon and its clients +like `upsmon` is delayed until all the NUT drivers complete their startup +(or time out trying). + +This can be a big issue on systems which monitor multiple devices, such as +big servers with multiple power sources, or administrative workstations +which monitor a datacenter full of UPSes. + +For this reason, NUT starting with version 2.8.0 supports startup of its +drivers as independent instances of a `nut-driver` service under the Linux +systemd and Solaris/illumos SMF service-management frameworks (corresponding +files and scripts may be not pre-installed in packaging for other systems). + +Such service instances have their own and independent life-cycle, including +parallel driver start and stop processing, and retries of startup in case of +failure as implemented by the service framework in the OS. The Linux systemd +solution also includes a `nut-driver.target` as a checkpoint that all defined +drivers have indeed started up (as well as being a singular way to enable or +disable startup of drivers). + +In both cases, a service named `nut-driver-enumerator` is registered, and +when it is (re-)started it scans the currently defined device sections in +'ups.conf' and the currently defined instances of `nut-driver` service, +and brings them in sync (adding or removing service instances), and if +there were changes -- it restarts the corresponding drivers (via service +instances) as well as the data server which only reads the list of sections +at its startup. This helper service should be triggered whenever your system +(re-)starts the `nut-server` service, so that it runs against an up-to-date +list of NUT driver processes. + +A service-oriented solution also allows to consider that different drivers +have different dependencies -- such as that networked drivers should begin +startup after IP addresses have been assigned, while directly-connected +devices might need nothing beside a mounted filesystem (or an activated +USB stack service or device rule, in case of Linux). Likewise, systems +administrators can define further local dependencies between services and +their instances as needed on particular deployments. + +This solution also adds the `upsdrvsvcctl` script to manage NUT drivers as +system service instances, whose CLI mimics that of `upsdrvctl` program. +One addition is the `resync` argument to trigger `nut-driver-enumerator`, +another is a `list` argument to display current mappings of service +instances to NUT driver sections. Also, original tool's arguments such +as the `-u` (user to run the driver as) or `-D` (debug of the driver) +do not make sense in the service context -- the accounts to use and +other arguments to the driver process are part of service setup (and +an administrator can manage it there). + +Note that while this solution tries to register service instances with same +names as NUT configuration sections for the devices, this can not always be +possible due to constraints such as syntax supported by a particular service +management framework. In this case, the enumerator falls back to MD5 hashes +of such section names, and the `upsdrvsvcctl` script supports this to map +the user-friendly NUT configuration section names to actual service names +that it would manage. + +References: man pages: linkman:nutupsdrv[8], linkman:upsdrvctl[8], +linkman:upsdrvsvcctl[8] Data server configuration (upsd) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Configure upsd, which serves data from the drivers to the clients. +Configure `upsd`, which serves data from the drivers to the clients. -First, edit upsd.conf to allow access to your client systems. By -default, upsd will only listen to localhost port 3493/tcp. If you want +First, edit 'upsd.conf' to allow access to your client systems. By +default, `upsd` will only listen to `localhost` port 3493/tcp. If you want to connect to it from other machines, you must specify each interface you -want upsd to listen on for connections, optionally with a port number. +want `upsd` to listen on for connections, optionally with a port number. LISTEN 127.0.0.1 3493 LISTEN ::1 3493 @@ -203,15 +295,15 @@ want upsd to listen on for connections, optionally with a port number. NOTE: Refer to the NUT user manual <> for information on how to access and secure upsd clients connections. -Next, create upsd.users. For now, this can be an empty file. +Next, create 'upsd.users'. For now, this can be an empty file. You can come back and add more to it later when it's time to -configure upsmon or run one of the management tools. +configure `upsmon` or run one of the management tools. Do not make either file world-readable, since they both hold access control data and passwords. They just need to be readable by the user you created in the preparation process. -The suggested configuration is to chown it to root, chgrp it to the +The suggested configuration is to `chown` it to `root`, `chgrp` it to the group you created, then make it readable by the group. chown root:nut upsd.conf upsd.users @@ -227,26 +319,36 @@ Starting the data server Start the network data server: - /usr/local/ups/sbin/upsd + upsd Make sure it is able to connect to the driver(s) on your system. A successful run looks like this: - # /usr/local/ups/sbin/upsd + # upsd Network UPS Tools upsd 2.4.1 listening on 127.0.0.1 port 3493 listening on ::1 port 3493 Connected to UPS [eaton]: usbhid-ups-eaton -upsd prints dots while it waits for the driver to respond. Your +`upsd` prints dots while it waits for the driver to respond. Your system may print more or less depending on how many drivers you have and how fast they are. -NOTE: if upsd says that it can't connect to a UPS or that the data -is stale, then your ups.conf is not configured correctly, or you +NOTE: If `upsd` says that it can't connect to a UPS or that the data +is stale, then your 'ups.conf' is not configured correctly, or you have a driver that isn't working properly. You must fix this before going on to the next step. +NOTE: Normally `upsd` requires that at least one driver section is +defined in the 'ups.conf' file, and refuses to start otherwise. +If you intentionally do not have any driver sections defined (yet) +but still want the data server to run, respond and report zero devices +(e.g. on an automatically managed monitoring deployment), you can enable +the `ALLOW_NO_DEVICE true` option in the 'upsd.conf' file. + +On operating systems with service management frameworks, the data server +life-cycle is managed by `nut-server` service. + Reference: man page: linkman:upsd[8] Check the UPS data @@ -256,15 +358,16 @@ Status data ^^^^^^^^^^^ Make sure that the UPS is providing good status data. +You can use the `upsc` command-line client for this: - /usr/local/ups/bin/upsc myupsname@localhost ups.status + upsc myupsname@localhost ups.status You should see just one line in response: OL -OL means your system is running on line power. If it says something -else (like OB - on battery, or LB - low battery), your driver was +`OL` means your system is running on line power. If it says something +else (like `OB` -- on battery, or `LB` -- low battery), your driver was probably misconfigured during the <> step. If you reconfigure the driver, use `upsdrvctl stop` to stop it, then start it again as shown in the <> step. @@ -277,11 +380,11 @@ All data Look at all of the status data which is being monitored. - /usr/local/ups/bin/upsc myupsname@localhost + upsc myupsname@localhost What happens now depends on the kind of device and driver you have. -In the list, you should see ups.status with the same value you got -above. A sample run on a UPS (Eaton Ellipse MAX 1100) looks like this: +In the list, you should see `ups.status` with the same value you got +above. A sample run on an UPS (Eaton Ellipse MAX 1100) looks like this: battery.charge: 100 battery.charge.low: 20 @@ -337,8 +440,15 @@ Startup scripts NOTE: This step is not necessary if you installed from packages. -Edit your startup scripts, and make sure upsdrvctl and upsd are run every time -your system starts. +Edit your startup scripts, and make sure `upsdrvctl` and `upsd` are run +every time your system starts. In newer versions of NUT, you may have a +'nut.conf' file which sets the `MODE` variable for bundled init-scripts, +to facilitate enabling of certain features in the specific end-user +deployments. + +If you installed from source, check the `scripts` directory for reference +init-scripts, as well as systemd or SMF service methods and manifests. + [[UPS_shutdown]] Configuring automatic shutdowns for low battery events @@ -356,59 +466,95 @@ Shutdown design When your UPS batteries get low, the operating system needs to be brought down cleanly. Also, the UPS load should be turned off so that all devices -that are attached to it are forcibly rebooted. +that are attached to it are forcibly rebooted, and subsequently start in +the predictable order and state suitable for your data center. -Here are the steps that occur when a critical power event happens: +Here are the steps that occur when a critical power event happens, +for the simpler case of one UPS device feeding one or several systems: 1. The UPS goes on battery -2. The UPS reaches low battery (a "critical" UPS), that is to say - upsc displays: +2. The UPS reaches low battery (a "critical" UPS), that is to say, + `upsc` displays: + ups.status: OB LB + -The exact behavior depends on the specific device, and is related to: +The exact behavior depends on the specific device, and is related to +such settings and readings as: - - battery.charge and battery.charge.low - - battery.runtime and battery.runtime.low + - `battery.charge` and `battery.charge.low` + - `battery.runtime` and `battery.runtime.low` -3. The upsmon master notices and sets "FSD" - the "forced shutdown" - flag to tell all slave systems that it will soon power down the load. +3. The `upsmon` primary notices the "critical UPS" situation and sets + "FSD" -- the "forced shutdown" flag to tell all secondary systems + that it will soon power down the load. + -(If you have no slaves, skip to step 6) +[WARNING] +========= +By design, since we require power-cycling the load and don't +want some systems to be powered off while others remain running +if the "wall power" returns at the wrong moment as usual, the "FSD" +flag can not be removed from the data server unless its daemon is +restarted. If we do take the first step in critical mode, then we +intend to go all the way -- shut down all the servers gracefully, +and power down the UPS. -4. upsmon slave systems see "FSD" and: +Keep in mind that some UPS devices and corresponding drivers would +latch the "FSD" again even if "wall power" is available, but the +remaining battery charge is below a threshold configured as "safe" +in the device (usually if you manually power on the UPS after a long +power outage). This is by design of respective UPS vendors, since +in such situation they can not guarantee that if a new power outage +happens, their UPS would safely shut down your systems again. +So it is deemed better and safer to stay dark until batteries +become sufficiently charged. +========= ++ +(If you have no secondary systems, skip to step 6) - - generate a NOTIFY_SHUTDOWN event - - wait FINALDELAY seconds - typically 5 - - call their SHUTDOWNCMD - - disconnect from upsd +4. `upsmon` secondary systems see "FSD" and: -5. The upsmon master system waits up to HOSTSYNC seconds (typically 15) - for the slaves to disconnect from upsd. If any are connected after - this time, upsmon stops waiting and proceeds with the shutdown - process. + - generate a `NOTIFY_SHUTDOWN` event + - wait `FINALDELAY` seconds -- typically `5` + - call their `SHUTDOWNCMD` + - disconnect from `upsd` -6. The upsmon master: +5. The `upsmon` primary system waits up to `HOSTSYNC` seconds (typically `15`) + for the secondary systems to disconnect from `upsd`. If any are still + connected after this time, `upsmon` primary stops waiting and proceeds + with the shutdown process. - - generates a NOTIFY_SHUTDOWN event - - waits FINALDELAY seconds - typically 5 - - creates the POWERDOWNFLAG file - usually /etc/killpower - - calls the SHUTDOWNCMD +6. The `upsmon` primary: -7. On most systems, init takes over, kills your processes, syncs and + - generates a `NOTIFY_SHUTDOWN` event + - waits `FINALDELAY` seconds -- typically `5` + - creates the `POWERDOWNFLAG` file in its local filesystem -- + usually `/etc/killpower` + - calls the `SHUTDOWNCMD` + +7. On most systems, `init` takes over, kills your processes, syncs and unmounts some filesystems, and remounts some read-only. -8. init then runs your shutdown script. This checks for the - POWERDOWNFLAG, finds it, and tells the UPS driver(s) to power off - the load. +8. `init` then runs your shutdown script. This checks for the + `POWERDOWNFLAG`, finds it, and tells the UPS driver(s) to power off + the load by sending commands to the connected UPS device(s) they manage. -9. The system loses power. +9. All the systems lose power. 10. Time passes. The power returns, and the UPS switches back on. 11. All systems reboot and go back to work. +/////////////////////////////////// +https://github.com/networkupstools/nut/issues/1370 + +TODO: Check other docs and code to spell out expected behavior with +multiple UPS devices (when not all of them go critical or even on battery) +and servers with multiple inputs. + +Does the `upsmon` primary system power-cycle a "critical" UPS if that +is not the only one feeding it, so it is not shutting down now? +/////////////////////////////////// How you set it up ~~~~~~~~~~~~~~~~~ @@ -417,42 +563,48 @@ How you set it up NUT user creation ^^^^^^^^^^^^^^^^^ -Create a upsd user for upsmon to use while monitoring this UPS. +Create a `upsd` user for `upsmon` to use while monitoring this UPS. -Edit upsd.users and create a new section. upsmon will connect -to upsd and use this user name (in brackets) and password to -authenticate. This example is for a user called "monuser": +Edit 'upsd.users' and create a new section. The `upsmon` will connect +to `upsd` and use these user name (in brackets) and password to +authenticate (as specified in its configuration via `MONITOR` line). + +This example is for defining a user called "monuser": [monuser] password = mypass - upsmon master - # or upsmon slave + upsmon primary + # or upsmon secondary References: linkman:upsd[8], linkman:upsd.users[5] Reloading the data server ^^^^^^^^^^^^^^^^^^^^^^^^^ -Reload upsd. Depending on your configuration, you may be able to -do this without stopping upsd: +Reload `upsd`. Depending on your configuration, you may be able to +do this without stopping the `upsd` daemon process: - /usr/local/ups/sbin/upsd -c reload + upsd -c reload If that doesn't work (check the syslog), just restart it: - /usr/local/ups/sbin/upsd -c stop - /usr/local/ups/sbin/upsd + upsd -c stop + upsd -NOTE: if you want to make reloading work later, see the entry in the -link:FAQ.html[FAQ] about starting upsd as a different user. +For systems with integrated service management (Linux systemd, +illumos/Solaris SMF) their corresponding `reload` or `refresh` +service actions should handle this as well. + +NOTE: If you want to make reloading work later, see the entry in the +link:FAQ.html[FAQ] about starting `upsd` as a different user. Power Off flag file ^^^^^^^^^^^^^^^^^^^ -Set the POWERDOWNFLAG location for upsmon. +Set the `POWERDOWNFLAG` location for `upsmon`. -In upsmon.conf, add a POWERDOWNFLAG directive with a filename. -upsmon will create this file when the UPS needs to be powered off +In 'upsmon.conf', add a `POWERDOWNFLAG` directive with a filename. +The `upsmon` will create this file when the UPS needs to be powered off during a power failure when low battery is reached. We will test for the presence of this file in a later step. @@ -465,68 +617,79 @@ linkman:upsmon.conf[5] Securing upsmon.conf ^^^^^^^^^^^^^^^^^^^^ -The recommended setting is to have it owned by root:nut, then make it readable -by the group and not world. This file contains passwords that could be used by -an attacker to start a shutdown, so keep it secure. +The recommended setting is to have it owned by `root:nut`, then make it +readable by the group and not by the world. This file contains passwords +that could be used by an attacker to start a shutdown, so keep it secure. chown root:nut upsmon.conf chmod 0640 upsmon.conf -This step has been placed early in the process so you secure this file before -adding sensitive data in the next step. +This step has been placed early in the process so you secure this file +before adding sensitive data in the next step. Create a MONITOR directive for upsmon ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Edit upsmon.conf and create a MONITOR line with the UPS definition -(@), username and password from the <> -step, and the master or slave setting. +Edit 'upsmon.conf' and create a `MONITOR` line with the UPS definition +(@), username and password from the +<> step, and the +"primary" or "secondary" setting. -If it's the master (i.e., it's connected to this UPS directly): +If this system is the UPS manager (i.e. it's connected to this UPS directly +and can manage it using a suitable NUT driver), its `upsmon` is the primary: - MONITOR myupsname@mybox 1 monuser mypass master + MONITOR myupsname@mybox 1 monuser mypass primary -If it's just monitoring this UPS over the network, and some other system is the -master: +If it's just monitoring this UPS over the network, and some other +system is the primary, then this one is a secondary: - MONITOR myupsname@mybox 1 monuser mypass slave + MONITOR myupsname@mybox 1 monuser mypass secondary -The number "1" here is the power value. This should always be set to 1 unless -you have a very special (read: expensive) system with redundant power supplies. -In such cases, refer to the User Manual: +The number `1` here is the "power value". This should always be set +to 1, unless you have a very special (read: expensive) system with +redundant power supplies. In such cases, refer to the User Manual: - <>, - <>. +Note that the "power value" may also be 0 for a monitoring (administrative) +system which only observes the remote UPS status but is not impacted by its +power events, and so does not shut down when the UPS does. + References: linkman:upsmon[8], linkman:upsmon.conf[5] Define a SHUTDOWNCMD for upsmon ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Still in upsmon.conf, add a directive that tells upsmon how to shut down your -system. This example seems to work on most systems: +Still in 'upsmon.conf', add a directive that tells `upsmon` how to +shut down your system. This example seems to work on most systems: SHUTDOWNCMD "/sbin/shutdown -h +0" Notice the presence of "quotes" here to keep it together. -If your system has special needs, you may want to set this to a script which -does local shutdown tasks before calling init. +If your system has special needs (e.g. system-provided shutdown handler +is ungracefully time constrained), you may want to set this to a script +which does customized local shutdown tasks before calling `init` or +`shutdown` programs to handle the system side of this operation. Start upsmon ^^^^^^^^^^^^ - /usr/local/ups/sbin/upsmon + upsmon If it complains about something, then check your configuration. +On operating systems with service management frameworks, the monitoring client +life-cycle is managed by `nut-monitor` service. + Checking upsmon ^^^^^^^^^^^^^^^ -Look for messages in the syslog to indicate success. It should look something -like this: +Look for messages in the `syslog` to indicate success. +It should look something like this: May 29 01:11:27 mybox upsmon[102]: Startup successful May 29 01:11:28 mybox upsd[100]: Client monuser@192.168.50.1 @@ -543,10 +706,12 @@ NOTE: This step is not need if you installed from packages. Edit your startup scripts, and add a call to `upsmon`. -Make sure `upsmon` starts when your system comes up. Do it after `upsdrvctl` -and `upsd`, or it will complain about not being able to contact the server. +Make sure `upsmon` starts when your system comes up. +On systems with `upsmon` primary (also running the data server), +do it after `upsdrvctl` and `upsd`, or it will complain about not +being able to contact the server. -You may delete the POWERDOWNFLAG in the startup scripts, but it is not +You may delete the `POWERDOWNFLAG` in the startup scripts, but it is not necessary. `upsmon` will clear that file for you when it starts. NOTE: Init script examples are provide in the 'scripts' directory of @@ -560,16 +725,17 @@ NOTE: This step is not need if you installed from packages. Edit your shutdown scripts, and add `upsdrvctl shutdown`. -You should configure your system to power down the UPS after the filesystems are -remounted read-only. Have it look for the presence of the POWERDOWNFLAG (from -linkman:upsmon.conf[5]), using this as an example: +You should configure your system to power down the UPS after the +filesystems are remounted read-only. Have it look for the presence +of the `POWERDOWNFLAG` (from linkman:upsmon.conf[5]), using this +as an example: --------------------------------------------------------------------------------- +------------------------------------------------------------------------------ - if (test -f /etc/killpower) + if (/sbin/upsmon -K) then echo "Killing the power, bye!" - /usr/local/ups/bin/upsdrvctl shutdown + /sbin/upsdrvctl shutdown sleep 120 @@ -578,18 +744,25 @@ linkman:upsmon.conf[5]), using this as an example: # *** see also the section on power races in the FAQ! *** fi --------------------------------------------------------------------------------- +------------------------------------------------------------------------------ [WARNING] -================================================================================ -- Be careful that upsdrvctl command will probably power off your machine. +============================================================================== +- Be careful that `upsdrvctl shutdown` command will probably power off +your machine and others fed by the UPS(es) which it manages. Don't use it unless your system is ready to be halted by force. If you run RAID, read the <<_raid_warning,RAID warning>> below! -- Make sure the filesystem(s) containing upsdrvctl, ups.conf and your UPS -driver(s) are mounted (possibly in read-only mode) when the system gets to this -point. Otherwise it won't be able to figure out what to do. -================================================================================ +- Make sure the filesystem(s) containing `upsdrvctl`, `upsmon`, +the `POWERDOWNFLAG` file, 'ups.conf' and your UPS driver(s) are +mounted (possibly in read-only mode) when the system gets to +this point. Otherwise it won't be able to figure out what to do. + +- If for some reason you can not ensure `upsmon` program is executable +at this point, your script can `(test -f /etc/killpower)` in a somewhat +non-portable manner, instead of asking `upsmon -K` for the verdict +according to its current configuration. +============================================================================== [[Testing_shutdowns]] @@ -602,17 +775,17 @@ on your systems before leaving them unattended. A successful sequence is one where the OS halts before the battery runs out, and the system restarts when power returns. -The first step is to see how upsdrvctl will behave without actually turning off -power. To do so, use the '-t' argument: +The first step is to see how `upsdrvctl` will behave without actually +turning off the power. To do so, use the `-t` argument: - /usr/local/ups/bin/upsdrvctl -t shutdown + upsdrvctl -t shutdown It will display the sequence without actually calling the drivers. You can finally test a forced shutdown sequence (FSD) using: - /usr/local/ups/sbin/upsmon -c fsd + upsmon -c fsd This will execute a full shutdown sequence, as presented in <>, starting from the 3rd step. @@ -643,35 +816,38 @@ is turned off and waits for the power to return. Once the power is back, the system reboots, pulls the snapshot back in, and keeps going from there. If the user happened to be away when it happened, they may return and have no idea that their system actually -shut down completely in the middle. +shut down completely in the middle (although network connections will drop). -In order for this to work, you need to shutdown NUT (UPS driver, upsd -server and upsmon client) in the suspend script and start them again in -the resume script. Don't try to keep them running. The upsd server +In order for this to work, you need to shutdown NUT (UPS driver, `upsd` +server and `upsmon` client) in the `suspend` script and start them again in +the `resume` script. Don't try to keep them running. The `upsd` server will latch the FSD state (so it won't be usable after resuming) and so -will the upsmon client. Some drivers may work after resuming, but many -don't and some UPSs will require re-initialization, so it's best not -to keep this running either. +will the `upsmon` client. Some drivers may work after resuming, but many +don't and some UPS devices will require re-initialization, so it's best not +to keep them running either. -After stopping driver, server and client you'll have to send the UPS -the command to shutdown only if the POWERDOWNFLAG is present. Note -that most likely you'll have to allow for a grace period after sending -'upsdrvctl shutdown' since the system will still have to take a -snapshot of itself after that. Not all drivers support this, so before -going down this road, make sure that the one you're using does. +After stopping NUT driver, server and client you'll have to send the UPS +the command to shutdown only if the `POWERDOWNFLAG` is present. Note +that most likely you'll have to allow for a grace period after calling +`upsdrvctl shutdown` since the system will still have to take a +snapshot of itself after that. Not all drivers and devices support this, +so before going down this road, make sure that the one you're using does. + +- see if you can query or configure settings named like `load.off.delay`, + `ups.delay.shutdown`, `offdelay` and/or `shutdown_delay` RAID warning ~~~~~~~~~~~~ -If you run any sort of RAID equipment, make sure your arrays are either halted -(if possible) or switched to "read-only" mode. Otherwise you may suffer a long -resync once the system comes back up. +If you run any sort of RAID equipment, make sure your arrays are +either halted (if possible) or switched to "read-only" mode. +Otherwise you may suffer a long resync once the system comes back up. -The kernel may not ever run its final shutdown procedure, so you must take care -of all array shutdowns in userspace before upsdrvctl runs. +The kernel may not ever run its final shutdown procedure, so you must take +care of all array shutdowns in userspace before `upsdrvctl shutdown` runs. -If you use software RAID (md) on Linux, get mdadm and try using -'mdadm --readonly' to put your arrays in a safe state. This has to +If you use software RAID (md) on Linux, get `mdadm` and try using +`mdadm --readonly` to put your arrays in a safe state. This has to happen after your shutdown scripts have remounted the filesystems. On hardware RAID or other kernels, you have to do some detective work. It may @@ -693,8 +869,8 @@ be configured using some general descriptions. There are two main elements: -1. There's a UPS attached to a communication (serial, USB or network) port on -this system. +1. There's a UPS attached to a communication (serial, USB or network) port + on this system. 2. This system depends on a UPS for power. You can play "mix and match" with those two to arrive at these descriptions @@ -704,36 +880,37 @@ for individual hosts: - B: 2 but not 1 - C: 1 and 2 -A small to medium sized data room usually has one C and a bunch of Bs. -This means that there's a system (type C) hooked to the UPS which depends -on it for power. There are also some other systems in there (type B) +A small to medium sized data room usually has one 'C' and a bunch of 'Bs'. +This means that there's a system (type 'C') hooked to the UPS which depends +on it for power. There are also some other systems in there (type 'B') which depend on that same UPS for power, but aren't directly connected to -it. +it communications-wise. Larger data rooms or those with multiple UPSes may have several "clusters" -of the "single C, many Bs" depending on how it's all wired. +of the "single 'C', many 'Bs'" depending on how it's all wired. -Finally, there's a special case. Type A systems are connected to a UPS's -serial port, but don't depend on it for power. This usually happens when -a UPS is physically close to a box and can reach the serial port, but -the wiring is such that it doesn't actually feed it. +Finally, there's a special case. Type 'A' systems are connected to +an UPS's communication port, but don't depend on it for power. +This usually happens when an UPS is physically close to a box and can +reach the serial port, but the power wiring is such that it doesn't +actually feed that box. Once you identify a system's type, use this list to decide which of the programs need to be run for monitoring: -- A: driver and upsd -- B: upsmon (as slave) -- C: driver, upsd, and upsmon (as master) +- A: driver and `upsd` +- B: `upsmon` (in secondary mode) +- C: driver, `upsd`, and `upsmon` (in primary mode, as the UPS manager) + +image:images/advanced.png[] To further complicate things, you can have a system that is hooked to multiple UPSes, but only depends on one for power. This particular -situation makes it an "A" relative to one UPS, and a "C" relative to the -other. The software can handle this - you just have to tell it what to do. +situation makes it an `A` relative to one UPS, and a `C` relative to the +other. The software can handle this -- you just have to tell it what to do. NOTE: NUT can also serve as a data proxy to increase the number of clients, -or share the communication load between several upsd instances. - -image:images/advanced.png[] +or share the communication load between several `upsd` instances. If you are running large server-class systems that have more than one power feed, see the next section for information on how to handle it @@ -743,8 +920,8 @@ properly. Typical setups for big servers with UPS redundancy -------------------------------------------------- -By using multiple MONITOR statements in upsmon.conf, you can configure an -environment where a large machine with redundant power monitors multiple +By using multiple `MONITOR` statements in 'upsmon.conf', you can configure +an environment where a large machine with redundant power monitors multiple separate UPSes. image:images/bigbox.png[] @@ -752,35 +929,39 @@ image:images/bigbox.png[] Example configuration ~~~~~~~~~~~~~~~~~~~~~ -For the examples in this section, we will use a server with four power supplies -installed. +For the examples in this section, we will use a server with four power +supplies installed and locally running the full NUT stack, including +`upsmon` in primary mode -- as the UPS manager. -Two UPS, 'Alpha' and 'Beta', are each driving two of the power supplies. +Two UPSes, 'Alpha' and 'Beta', are each driving two of the power supplies +(by adding up, we know about the four power supplies of the current system). This means that either 'Alpha' *or* 'Beta' can totally shut down and the server will be able to keep running. -The upsmon.conf configuration that reflect this is the following: +The 'upsmon.conf' configuration which reflects this is the following: - MONITOR ups-alpha@myhost 2 monuser mypass master - MONITOR ups-beta@myhost 2 monuser mypass master + MONITOR ups-alpha@myhost 2 monuser mypass primary + MONITOR ups-beta@myhost 2 monuser mypass primary MINSUPPLIES 2 -With that configuration, upsmon will only shut down when both UPS reaches -a critical (on battery + low battery) condition, since 'Alpha' and 'Beta' -provide the same power value. +With such configuration, `upsmon` on this system will only shut down when +both UPS devices reach a critical (on battery + low battery) condition, +since 'Alpha' and 'Beta' each provide the same power value. As an added bonus, this means you can move a running server from one UPS -to another (for maintenance purpose for example) without bringing it down since -the minimum power will be provided at all times. +to another (for maintenance purpose for example) without bringing it down +since the minimum sufficient power will be provided at all times. -The MINSUPPLIES line tells upsmon that we need at least 2 power supplies +The `MINSUPPLIES` line tells `upsmon` that we need at least 2 power supplies to be receiving power from a good UPS (on line or on battery, just not -on battery and low battery). +on battery *and* low battery). -NOTE: we could have used a 'Power Value' of 1 for both UPS, and MINSUPPLIES -set to 1 too. These values are purely arbitrary, so you are free to use your -own rules. Here, we have linked these values to the number of power supplies -that each UPS is feeding (2). +NOTE: We could have used a 'Power Value' of `1` for both UPS, and have +`MINSUPPLIES` set to `1` too. These values are purely arbitrary, so +you are free to use your own rules. Here, we have linked these values +to the number of power supplies that each UPS is feeding (2) since this +maps better to physical topology and allows to throw a third or fourth +UPS into the mix without much configuration headache. Multiple UPS shutdowns ordering @@ -788,11 +969,11 @@ Multiple UPS shutdowns ordering If you have multiple UPSes connected to your system, chances are that you need to shut them down in a specific order. The goal is to shut down -everything but the one keeping upsmon alive at first, then you do that one -last. +everything but the one keeping `upsmon` alive at first, then you do that +one last. To set the order in which your UPSes receive the shutdown commands, define -the 'sdorder' value in your ups.conf. +the `sdorder` value in your 'ups.conf' device sections. [bigone] driver = usbhid-ups @@ -810,11 +991,11 @@ the 'sdorder' value in your ups.conf. sdorder = 0 The order runs from 0 to the highest number available. So, for this -configuration, the order of shutdowns would be 'misc', 'littleguy', and then -'bigone'. +configuration, the order of shutdowns would be 'misc', 'littleguy', +and then 'bigone'. -NOTE: If you have a UPS that shouldn't be shutdown when running 'upsdrvctl -shutdown', set the *sdorder* to *-1*. +NOTE: If you have a UPS that shouldn't be powered off when running +`upsdrvctl shutdown`, set its `sdorder` to `-1`. Other redundancy configurations diff --git a/docs/config-prereqs.txt b/docs/config-prereqs.txt new file mode 100644 index 0000000..45b1058 --- /dev/null +++ b/docs/config-prereqs.txt @@ -0,0 +1,848 @@ +ifdef::website[] +Prerequisites for building NUT on different OSes +================================================ +endif::website[] + +This chapter aims to list packages with the tools needed on a freshly minimally +deployed worker to build as many targets of NUT recipes as possible, mainly +the diverse driver and documentation types. + +NUT codebase generally should not depend on particular operating system or +kernel technology and version, and with the operating systems listed below +one can benefit from use of containers (jails, zones) to build and test +against numerous OS distributions on one physical or virtual machine, +e.g. to cover non-regression with older tool kits while taking advantage +of new releases. + +* For Linux systems, we have notes on link:ci-farm-lxc-setup.txt[Setting + up the multi-arch Linux LXC container farm for NUT CI] + +Some of the below are alternatives, e.g. compiler toolkits (gcc vs. clang) +or SSL implementations (OpenSSL vs Mozilla NSS) -- no problem installing +both, at a disk space cost. + +NOTE: Some NUT branches may need additional or different software versions +that are not yet included into `master` branch dependencies, e.g. the DMF +(Dynamic Mapping Files) sub-project needs LUA 5.1. + +More packages and/or system setup may be needed to actually run NUT with +all features enabled; chapters below concern just with building it. + +General call to Test the ability to configure and build +------------------------------------------------------- + +Check out from git, generate files and configure to tailor to your build +environment, and build some tests: + +------ +:; mkdir -p nut && cd nut && \ + git clone https://github.com/networkupstools/nut/ -b master . +:; ./autogen.sh && \ + ./configure --with-doc=all --with-all --with-cgi && \ + make all && make check && make spellcheck +------ + +You can toggle some `configure` options to check different dependency +variants, e.g. `--with-ssl=nss` vs. `--with-ssl=openssl` + +For reproducible runs of various pre-sets of configuration during +development, take a look at `ci_build.sh` script and different `BUILD_TYPE` +(and other) environment variable settings that it supports. A minimal run +with it is just to call the script, e.g.: + +------ +:; mkdir -p nut && cd nut && \ + git clone https://github.com/networkupstools/nut/ -b fightwarn . +:; ./ci_build.sh +------ + +[NOTE] +====== +To build older releases, such as "vanilla" NUT 2.7.4 and older, +you may need to address some nuances: + +* Ensure that `python` in `PATH` points to a python-2.x implementation + (`master` branch is fixed to work with python 2 and 3) + +* Ensure that `bash` is your user and maybe system shell (or ensure the + generated `configure` script gets interpreted by it) + +* Generally you may have better results with GNU Make newer than 3.81 + than with other make implementations; however, builds are regularly + tested by CI with Sun dmake and BSD make as well, so recipes should + not expect GNU-only syntax and constructs to work + +* Parallel builds should be okay in current development version and + since NUT 2.8.0 (is a bug to log and fix, if not), but they may be + failure-prone in 2.7.4 and earlier releases +====== + +For intensive rebuilds, `ccache` is recommended. + + +Build prerequisites to make NUT from scratch on various Operating Systems +------------------------------------------------------------------------- + +Debian 10/11 +~~~~~~~~~~~~ + +Being a popular baseline among Linux distributions, Debian is an +important build target. Related common operating systems include +Ubuntu and customized distros for Raspberry Pi, Proxmox, as well +as many others. + +The package list below should largely apply to those as well, +however note that some well-known package names tend to differ. +A few of those are noted below. + +[NOTE] +====== +While Debian distros I've seen (8 to 11) provide a "libusb-dev" +for libusb-0.1 headers, the binary library package name is specifically +versioned package by default of the current release (e.g. "libusb-0.1-4"), +while names of both the library and development packages for libusb-1.0 +must be determined with: +------ +:; apt-cache search 'libusb.*1\.0.* +------ +yielding e.g. "libusb-1.0-0-dev" (string name was seen with different +actual package source versions on both Debian 8 "Jessie" and +Debian 11 "Buster"). +====== + +Debian-like package installations commonly start with an update of +metadata about recently published package revisions: + +------ +:; apt-get update + +# NOTE: Older Debian-like distributions may lack a "libtool-bin" +:; apt-get install \ + ccache time \ + git python perl curl \ + make autoconf automake libltdl-dev libtool-bin libtool \ + valgrind \ + cppcheck \ + pkg-config \ + gcc g++ clang + +# NOTE: For python, you may eventually have to specify a variant like this +# (numbers depending on default or additional packages of your distro): +# :; apt-get install python2 python2.7 python-is-python2 +# and/or: +# :; apt-get install python3 python3.9 +# You can find a list of what is (pre-)installed with: +# :; dpkg -l | grep -Ei 'perl|python' + +# For spell-checking, highly recommended if you would propose pull requests: +:; apt-get install \ + aspell aspell-en + +# For other doc types (man-page, PDF, HTML) generation - massive packages (TEX, X11): +:; apt-get install \ + asciidoc source-highlight python3-pygments dblatex + +# For CGI graph generation - massive packages (X11): +:; apt-get install \ + libgd-dev + +# NOTE: Some older Debian-like distributions, could ship "libcrypto-dev" +# and/or "openssl-dev" instead of "libssl-dev" by its modern name +:; apt-get install \ + libcppunit-dev \ + libssl-dev libnss3-dev \ + augeas-tools libaugeas-dev augeas-lenses \ + libusb-dev libusb-1.0-0-dev \ + libi2c-dev \ + libmodbus-dev \ + libsnmp-dev \ + libpowerman0-dev \ + libfreeipmi-dev libipmimonitoring-dev \ + libavahi-common-dev libavahi-core-dev libavahi-client-dev +# For libneon, see below + +:; apt-get install \ + lua5.1-dev + +:; apt-get install \ + bash dash ksh busybox +------ + +Alternatives that can depend on your system's other packaging choices: +------ +:; apt-get install libneon27-dev +# ... or +:; apt-get install libneon27-gnutls-dev +------ + +Over time, Debian and Ubuntu had different packages and libraries providing +the actual methods for I2C; if your system lacks the `libi2c` (and so fails +to `./configure --with-all`), try adding the following packages: +------ +:; apt-get install build-essential git-core libi2c-dev i2c-tools lm-sensors +------ + +For cross-builds (note that not everything supports multilib approach, +limiting standard package installations to one or another implementation; +in that case local containers each with one ARCH may be a better choice, +with `qemu-user-static` playing a role to "natively" run the other-ARCH +complete environments): +------ +:; apt-get install \ + gcc-multilib g++-multilib \ + crossbuild-essential \ + gcc-10:armhf gcc-10-base:armhf \ + qemu-user-static +------ + +NOTE: For Jenkins agents, also need to `apt-get install openjdk-11-jdk-headless` +(technically, needs at least JRE 8+). You may have to ensure `/proc` is mounted +in the target chroot (or do this from the running container). + +CentOS 7 +~~~~~~~~ + +CentOS is another popular baseline among Linux distributions, being a free +derivative of the RedHat Linux, upon which many other distros are based as +well. These systems typically use the RPM package manager, using directly +`rpm` command, or `yum` or `dnf` front-ends depending on their generation. + +For CentOS 7 it seems that not all repositories are equally good; some of +the software below is only served by EPEL (Extra Packages for Enterprise +Linux), as detailed at: + +* https://docs.fedoraproject.org/en-US/epel/ +* https://www.redhat.com/en/blog/whats-epel-and-how-do-i-use-it +* https://pkgs.org/download/epel-release + +You may have to specify a mirror as the `baseurl` in a `/etc/yum.repos.d/...` +file (as the aged distributions become less served by mirrors), such as: + +* https://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/7/x86_64/ ++ +------ +# e.g. for CentOS7 currently: +:; yum install https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-14.noarch.rpm + +# And edit /etc/yum.repos.d/epel.repo to uncomment and set the baseurl=... +# lines, and comment away the mirrorlist= lines (if yum hiccups otherwise) +------ + +General developer system helpers mentioned in link:ci-farm-lxc-setup.txt[]: +------ +:; yum update + +:; yum install \ + sudo vim mc p7zip pigz pbzip2 +------ + +NOTE: Below we request to install generic `python` per system defaults. +You may request specifically `python2` or `python3` (or both): current +NUT should be compatible with both (2.7+ at least). + +NOTE: On CentOS, `libusb` means 0.1.x and `libusbx` means 1.x.x API version. + +NOTE: On CentOS, it seems that development against libi2c/smbus is not +supported. Neither the suitable devel packages were found, nor i2c-based +drivers in distro packaging of NUT. Resolution and doc PRs are welcome. + +------ +:; yum install \ + ccache time \ + file systemd-devel \ + git python perl curl \ + make autoconf automake libtool-ltdl-devel libtool \ + valgrind \ + cppcheck \ + pkgconfig \ + gcc gcc-c++ clang + +# NOTE: For python, you may eventually have to specify a variant like this +# (numbers depending on default or additional packages of your distro): +# :; yum install python-2.7.5 +# and/or: +# :; yum install python3 python3-3.6.8 +# You can find a list of what is (pre-)installed with: +# :; rpm -qa | grep -Ei 'perl|python' + +# For spell-checking, highly recommended if you would propose pull requests: +:; yum install \ + aspell aspell-en + +# For other doc types (man-page, PDF, HTML) generation - massive packages (TEX, X11): +:; yum install \ + asciidoc source-highlight python-pygments dblatex + +# For CGI graph generation - massive packages (X11): +:; yum install \ + gd-devel + +# NOTE: "libusbx" is the CentOS way of naming "libusb-1.0" +# vs. the older "libusb" as the package with "libusb-0.1" +:; yum install \ + cppunit-devel \ + openssl-devel nss-devel \ + augeas augeas-devel \ + libusb-devel libusbx-devel \ + i2c-tools \ + libmodbus-devel \ + net-snmp-devel \ + powerman-devel \ + freeipmi-devel \ + avahi-devel \ + neon-devel +#?# is python-augeas needed? exists at least... +#?# no (lib)i2c-devel ... +#?# no (lib)ipmimonitoring-devel ... would "freeipmi-ipmidetectd" cut it at least for run-time? + +# Some NUT code related to lua may be currently limited to lua-5.1 +# or possibly 5.2; the former is default in CentOS 7 releases... +:; yum install \ + lua-devel + +:; yum install \ + bash dash ksh +------ + +NOTE: `busybox` is not packaged for CentOS 7 release; a static binary can +be downloaded if needed. For more details, see +https://unix.stackexchange.com/questions/475584/cannot-install-busybox-on-centos + +CentOS packaging for 64-bit systems delivers the directory for dispatching +compiler symlinks as `/usr/lib64/ccache`. You can set it up same way as for +other described environments by adding a symlink `/usr/lib/ccache`: +------ +:; ln -s ../lib64/ccache/ "$ALTROOT"/usr/lib/ +------ + +NOTE: For Jenkins agents, also need to `yum install java-11-openjdk-headless` +(technically, needs at least JRE 8+). + +FreeBSD 12.2 +~~~~~~~~~~~~ + +Note that `PATH` for builds on BSD should include `/usr/local/...`: + +------ +:; PATH=/usr/local/libexec/ccache:/usr/local/bin:/usr/bin:$PATH +:; export PATH +------ + +NOTE: You may want to reference `ccache` even before all that, as detailed +below. + +------ +:; pkg install \ + git python perl5 curl \ + gmake autoconf automake autotools libltdl libtool \ + valgrind \ + cppcheck \ + pkgconf \ + gcc clang + +# NOTE: For python, you may eventually have to specify a variant like this +# (numbers depending on default or additional packages of your distro): +# :; pkg install python2 python27 +# and/or: +# :; pkg install python3 python37 +# You can find a list of what is (pre-)installed with: +# :; pkg info | grep -Ei 'perl|python' + +# For spell-checking, highly recommended if you would propose pull requests: +:; pkg install \ + aspell en-aspell + +# For other doc types (man-page, PDF, HTML) generation - massive packages (TEX, X11): +:; pkg install \ + asciidoc source-highlight textproc/py-pygments dblatex + +# For CGI graph generation - massive packages (X11): +:; pkg install \ + libgd + +:; pkg install \ + cppunit \ + openssl nss \ + augeas \ + libmodbus \ + neon \ + net-snmp \ + powerman \ + freeipmi \ + avahi + +:; pkg install \ + lua51 + +:; pkg install \ + bash dash busybox ksh93 +------ + +Recommended: +------ +:; pkg install ccache +:; ccache-update-links +------ + +For compatibility with common setups on other operating systems, can symlink +`/usr/local/libexec/ccache` as `/usr/lib/ccache` and possibly add dash-number +suffixed symlinks to compiler tools (e.g. `gcc-10` beside `gcc10` installed +by package). + +NOTE: For Jenkins agents, also need to `pkg install openjdk8` (or 11+) -- +and do note its further OS configuration suggestions for special filesystem +mounts. + +Due to BSD specific paths *when not using* an implementation of `pkg-config` +or `pkgconf` (so guessing of flags is left to administrator -- TBD in NUT +`m4` scripts), better use this routine to test the config/build: +---- +:; ./configure --with-doc=all --with-all --with-cgi \ + --without-avahi --without-powerman --without-modbus \ + ### CPPFLAGS="-I/usr/local/include -I/usr/include" \ + ### LDFLAGS="-L/usr/local/lib -L/usr/lib" +---- + +Note the lack of `pkg-config` also precludes `libcppunit` tests, although +they also tend to mis-compile/mis-link with GCC (while CLANG seems okay). + +OpenBSD 6.4 +~~~~~~~~~~~ + +Note that `PATH` for builds on BSD should include `/usr/local/...`: + +------ +:; PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH +:; export PATH +------ + +NOTE: You may want to reference `ccache` even before all that, as detailed +below. + +OpenBSD delivers many versions of numerous packages, you should specify +your pick interactively or as part of package name (e.g. `autoconf-2.69p2`). + +During builds, you may have to tell system dispatcher scripts which version +to use (which feels inconvenient, but on the up-side for CI -- this system +allows to test many versions of auto-tools in the same agent), e.g.: +------ +:; export AUTOCONF_VERSION=2.69 AUTOMAKE_VERSION=1.10 +------ + +To use the `ci_build.sh` don't forget `bash` which is not part of OpenBSD +base installation. It is not required for "legacy" builds arranged by just +`autogen.sh` and `configure` scripts. + +NOTE: The OpenBSD 6.4 `install64.iso` installation includes a set of packages +that seems to exceed whatever is available on network mirrors; for example, +the CD image included `clang` program while it is not available to `pkg_add`, +at least not via http://ftp.netbsd.hu/mirrors/openbsd/6.4/packages/amd64/ +mirror. The `gcc` version on CD image differed notably from that in the +networked repository (4.2.x vs 4.9.x) + +------ +:; pkg_add \ + git python curl \ + gmake autoconf automake libltdl libtool \ + valgrind \ + cppcheck \ + pkgconf \ + gcc clang + +# NOTE: For python, you may eventually have to specify a variant like this +# (numbers depending on default or additional packages of your distro): +# :; yum install python-2.7.15p0 +# and/or: +# :; yum install python-3.6.6p1 +# although you might succeed specifying shorter names and the packager +# will offer a list of matching variants. +# NOTE: "perl" is not currently a package, but seemingly part of base OS. +# You can find a list of what is (pre-)installed with: +# :; pkg_info | grep -Ei 'perl|python' + +# For spell-checking, highly recommended if you would propose pull requests: +:; pkg_add \ + aspell + +# For other doc types (man-page, PDF, HTML) generation - massive packages (TEX, X11): +:; pkg_add \ + asciidoc source-highlight py-pygments dblatex \ + docbook2x docbook-to-man + +# For CGI graph generation - massive packages (X11): +:; pkg_add \ + gd + +:; pkg_add \ + cppunit \ + openssl nss \ + augeas \ + libusb1 \ + neon \ + net-snmp \ + avahi + +# Select a LUA-5.1 (or possibly 5.2?) version +:; pkg_add \ + lua + +:; pkg_add \ + bash dash busybox ksh93 +------ + +[NOTE] +====== +With OpenBSD 6.4, building against freeipmi failed: its libtool +recipes referenced `-largp` which did not get installed in the system. +Maybe some more packages are needed explicitly? + +------ +:; pkg_add \ + freeipmi +------ +====== + +Recommended: +------ +:; pkg_add ccache +:; ( mkdir -p /usr/lib/ccache && cd /usr/lib/ccache && \ + for TOOL in cpp gcc g++ clang clang++ clang-cpp ; do \ + ln -s ../../local/bin/ccache "$TOOL" ; \ + done ; \ + ) +------ + +For compatibility with common setups on other operating systems, can add +dash-number suffixed symlinks to compiler tools (e.g. `gcc-4.2.1` beside +`gcc` installed by package) into `/usr/lib/ccache`. + +NOTE: For Jenkins agents, also need to `pkg_add jre` or `pkg_add jdk` +(pick version 1.8 or 8, or 11+). + +Due to BSD specific paths *when not using* an implementation of `pkg-config` +or `pkgconf` (so guessing of flags is left to administrator -- TBD in NUT +`m4` scripts), better use this routine to test the config/build: +------ +:; ./configure --with-doc=all --with-all --with-cgi \ + --without-avahi --without-powerman --without-modbus \ + ### CPPFLAGS="-I/usr/local/include -I/usr/include" + ### LDFLAGS="-L/usr/local/lib -L/usr/lib" +------ + +Note the lack of `pkg-config` also precludes `libcppunit` tests, although +they also tend to mis-compile/mis-link with GCC (while CLANG seems okay). + +NetBSD 9.2 +~~~~~~~~~~ + +Instructions below assume that `pkgin` tool (pkg-src component to +"install binary packages") is present on the system. Text below +was prepared with a VM where "everything" was installed from the +ISO image, including compilers and X11. It is possible that some +packages provided this way differ from those served by `pkgin`, +or on the contrary, that the list of suggested tool installation +below would not include something a bare-minimum system would +require to build NUT. + +Note that `PATH` for builds on NetBSD should include `local` and +`pkg`; the default after installation of the test system was: + +------ +:; PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/pkg/sbin:/usr/pkg/bin:/usr/X11R7/bin:/usr/local/sbin:/usr/local/bin" +:; export PATH +------ + +NOTE: You may want to reference `ccache` even before all that, +as detailed below: + +------ +:; PATH="/usr/lib/ccache:$PATH" +:; export PATH +------ + +To use the `ci_build.sh` don't forget `bash` which is not part of OpenBSD +base installation. It is not required for "legacy" builds arranged by just +`autogen.sh` and `configure` scripts. + +------ +:; pkgin install \ + git python27 python39 perl curl \ + make gmake autoconf automake libltdl libtool \ + cppcheck \ + pkgconf \ + gcc7 clang + +;; ( cd /usr/pkg/bin && ( ln -fs python2.7 python2 ; ln -fs python3.9 python3 ) ) +# You can find a list of what is (pre-)installed with: +# :; pkgin list | grep -Ei 'perl|python' + +# For spell-checking, highly recommended if you would propose pull requests: +:; pkgin install \ + aspell aspell-en + +# For man-page doc types, footprint on this platform is moderate: +:; pkgin install \ + asciidoc + +# For other doc types (PDF, HTML) generation - massive packages (TEX, X11): +:; pkgin install \ + source-highlight py39-pygments dblatex + +# For CGI graph generation - massive packages (X11): +:; pkgin install \ + gd openmp + +:; pkgin install \ + cppunit \ + openssl nss \ + augeas \ + libusb libusb1 \ + neon \ + net-snmp \ + avahi + +# Select a LUA-5.1 (or possibly 5.2?) version +:; pkgin install \ + lua51 + +:; pkgin install \ + bash dash ast-ksh oksh +------ + +[NOTE] +====== +(TBD) On NetBSD 9.2 this package complains that it requires +OS ABI 9.0, or that `CHECK_OSABI=no` is set in `pkg_install.conf`. +Such file was not found in the test system... + +------ +:; pkgin install \ + openipmi +------ +====== + +Recommended: For compatibility with common setups on other operating +systems, can add dash-number suffixed symlinks to compiler tools (e.g. +`gcc-7` beside the `gcc` installed by package) near the original +binaries and into `/usr/lib/ccache`: +------ +:; ( cd /usr/bin && for TOOL in cpp gcc g++ ; do \ + ln -s "$TOOL" "$TOOL-7" ; \ + done ) + +# Note that the one delivered binary is `clang-13` and many (unnumbered) +# symlinks to it. For NUT CI style of support for builds with many +# compilers, complete the known numbers: +:; ( cd /usr/pkg/bin && for TOOL in clang-cpp clang++ ; do \ + ln -s clang-13 "$TOOL-13" ; \ + done ) + +:; pkgin install ccache +:; ( mkdir -p /usr/lib/ccache && cd /usr/lib/ccache && \ + for TOOL in cpp gcc g++ clang ; do \ + for VER in "" "-7" ; do \ + ln -s ../../pkg/bin/ccache "$TOOL$VER" ; \ + done ; \ + done ; \ + for TOOL in clang clang++ clang-cpp ; do \ + for VER in "" "-13" ; do \ + ln -s ../../pkg/bin/ccache "$TOOL$VER" ; \ + done ; \ + done ; \ + ) +------ + +NOTE: For Jenkins agents, also need to `pkgin install openjdk11` (will be +in `JAVA_HOME=/usr/pkg/java/openjdk11`). + +OpenIndiana 2021.10 +~~~~~~~~~~~~~~~~~~~ + +Note that due to IPS and `pkg(5)`, a version of python is part of baseline +illumos-based OS; this may not be the case on some other illumos distributions +which do not use IPS however. Currently they use python 3.7 or newer. + +To build older NUT releases (2.7.4 and before), you may need to explicitly +`pkg install python-27`. + +Typical tooling would include: + +------ +:; pkg install \ + git curl wget \ + gnu-make autoconf automake libltdl libtool \ + valgrind \ + pkg-config \ + gnu-binutils developer/linker + +# NOTE: For python, some suitable version should be available since `pkg(5)` +# tool is written in it. Similarly, many system tools are written in perl +# so some version should be installed. You may specify additional variants +# like this (numbers depending on default or additional packages of your +# distro; recommended to group `pkg` calls with many packages at once to +# save processing time for calculating a build strategy): +# :; pkg install runtime/python-27 +# and/or: +# :; pkg install runtime/python-37 runtime/python-35 runtime/python-39 +# Similarly for perl variants, e.g.: +# :; pkg install runtime/perl-522 runtime/perl-524 runtime/perl-534 +# You can find a list of what is available in remote repositories with: +# :; pkg info -r | grep -Ei 'perl|python' + +# For spell-checking, highly recommended if you would propose pull requests: +:; pkg install \ + aspell text/aspell/en + +# For other doc types (man-page, PDF, HTML) generation - massive packages (TEX, X11): +:; pkg install \ + asciidoc libxslt \ + docbook/dtds docbook/dsssl docbook/xsl docbook docbook/sgml-common pygments-39 \ + graphviz expect graphviz-tcl + +# For CGI graph generation - massive packages (X11): +:; pkg install \ + gd + +:; pkg install \ + openssl library/mozilla-nss \ + library/augeas python/augeas \ + libusb-1 libusbugen system/library/usb/libusb system/header/header-usb driver/usb/ugen \ + libmodbus \ + neon \ + net-snmp \ + powerman \ + freeipmi \ + avahi + +:; pkg install \ + lua + +:; pkg install \ + dash bash shell/ksh93 + +### Maybe +:; pkg install \ + gnu-coreutils + +### Maybe - after it gets fixed for GCC builds/linkage +:; pkg install \ + cppunit +------ + +For extra compiler coverage, we can install a large selection of versions, +although to meet NUT CI farm expectations we also need to expose "numbered" +filenames, as automated below: +------ +:; pkg install \ + gcc-48 gcc-49 gcc-5 gcc-6 gcc-7 gcc-9 gcc-10 gcc-11 \ + clang-80 clang-90 \ + ccache + +# As of this writing, clang-13 refused to link (claiming issues with +# --fuse-ld which was never specified) on OI; maybe later it will: +:; pkg install \ + developer/clang-13 runtime/clang-13 + +# Get clang-cpp-X visible in standard PATH (for CI to reference the right one), +# and make sure other frontends are exposed with versions (not all OI distro +# releases have such symlinks packaged right), e.g.: +:; (cd /usr/bin && for X in 8 9 13 ; do for T in "" "++" "-cpp"; do \ + ln -fs "../clang/$X.0/bin/clang$T" "clang${T}-${X}" ; \ + done; done) + +# If /usr/lib/ccache/ symlinks to compilers do not appear after package +# installation, or if you had to add links like above, call the service: +:; svcadm restart ccache-update-symlinks +------ + +We can even include a `gcc-4.4.4-il` version (used to build the illumos OS +ecosystems, at least until recently, which is a viable example of an old +GCC baseline); but note that so far it conflicts with `libgd` builds at +`./configure --with-cgi` stage (its binaries require newer ecosystem): + +------ +:; pkg install \ + illumos-gcc@4.4.4 + +# Make it visible in standard PATH +:; (cd /usr/bin && for T in gcc g++ cpp ; do \ + ln -s ../../opt/gcc/4.4.4/bin/$T $T-4.4.4 ; \ + done) + +# If /usr/lib/ccache/ symlinks to these do not appear, call the service: +:; svcadm restart ccache-update-symlinks +------ + +OI currently also does not build `cppunit`-based tests well, at least +not with GCC (they segfault at run-time with `ostream` issues); a CLANG +build works for that however. + +It also lacks out-of-the-box Tex suite and `dblatex` in particular, which +`asciidoc` needs to build PDF documents. It may be possible to add these +from third-party repositories (e.g. SFE) and/or build from sources. + +No pre-packaged `cppcheck` was found, either. + +NOTE: For Jenkins agents, also need to `pkg install developer/java/openjdk8` +(or `pkg install runtime/java/openjdk11` for JRE 11 -- currently the OS does +not offer in-distro JDK version 11+). + +OmniOS CE (as of release 151036) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Being a minimal-footprint system, OmniOS CE provides very few packages out +of the box. There are additional repositories supported by the project, as +well as third-party repositories such as SFE. For some dependencies, it may +happen that you would need to roll and install your own builds in accordance +with that project's design goals. + +Note you may need not just the "Core" IPS package publisher, but also the +"Extra" one. See OmniOS CE web site for setup details. + +------ +:; pkg install \ + developer/build/autoconf developer/build/automake developer/build/libtool \ + build-essential ccache git developer/pkg-config \ + runtime/perl \ + asciidoc \ + libgd + +:; pkg install \ + net-snmp + +# NOTE: For python, some suitable version should be available since `pkg(5)` +# tool is written in it. You may specify an additional variant like this +# (numbers depending on default or additional packages of your distro): +# :; pkg install runtime/python-37 +# You can find a list of what is available in remote repositories with: +# :; pkg info -r | grep -Ei 'perl|python' +------ + +OmniOS lacks a pre-packaged libusb, however the binary build from contemporary +OpenIndiana can be used (copy the header files and the library+symlinks for +all architectures you would need). + +You may need to set up `ccache` with the same `/usr/lib/ccache` dir used +in other OS recipes. Assuming your Build Essentials pulled GCC 9 version, +and ccache is under `/opt/ooce` namespace, that would be like: +------ +:; mkdir -p /usr/lib/ccache +:; cd /usr/lib/ccache +:; ln -fs ../../../opt/ooce/bin/ccache gcc +:; ln -fs ../../../opt/ooce/bin/ccache g++ +:; ln -fs ../../../opt/ooce/bin/ccache gcpp +:; ln -fs ../../../opt/ooce/bin/ccache gcc-9 +:; ln -fs ../../../opt/ooce/bin/ccache g++-9 +:; ln -fs ../../../opt/ooce/bin/ccache gcpp-9 +------ + +Given that many of the dependencies can get installed into that namespace, +you may have to specify where `pkg-config` will look for them (note that +library and binary paths can be architecture bitness-dependent): +------ +:; ./configure PKG_CONFIG_PATH="/opt/ooce/lib/amd64/pkgconfig" --with-cgi +------ + +Note also that the minimal footprint nature of OmniOS CE precludes building +any large scope easily, so avoid docs and "all drivers" unless you provide +whatever they need to happen. diff --git a/docs/configure.txt b/docs/configure.txt index aff82c1..c681f74 100644 --- a/docs/configure.txt +++ b/docs/configure.txt @@ -3,96 +3,229 @@ Configure options ================= endif::website[] -There are a few options that can be given to configure to tweak compiles. -See also "./configure --help" for a current and complete listing. +There are a few options reviewed below that can be given to `configure` +script to tweak your compilations. See also `./configure --help` for a +current and complete listing for the current version of the codebase. Driver selection ---------------- +Serial drivers +~~~~~~~~~~~~~~ + --with-serial +USB drivers +~~~~~~~~~~~ + Build and install the serial drivers (default: yes) --with-usb Build and install the USB drivers (default: auto-detect) -Note that you need to install the libusb development package or files. + +Note that you need to install the libusb development package or files, +and that both libusb 0.1 and 1.0 are supported. In case both are +available, libusb 1.0 takes precedence, and will be used by default. +It is however possible to override this default choice by explicitly +calling `--with-usb=libusb-0.1` or `--with-usb=libusb-1.0`. +If you do specify the version to use (or `yes` for auto-detection), +this option would fail if requested (or any) libusb version was not +found. The default `auto` value would not fail in such case. + +SNMP drivers +~~~~~~~~~~~~ --with-snmp Build and install the SNMP drivers (default: auto-detect) + Note that you need to install libsnmp development package or files. + --with-net-snmp-config + +In addition to the `--with-snmp` option above, this one allows to provide +a custom program name (in `PATH`) or complete pathname to `net-snmp-config` +(may have copies named per architecture, e.g. `net-snmp-config-32` and +`net-snmp-config-64`). + +This may be needed on build systems which support multiple architectures, +or in cases where your distribution names this program differently. +With a default value of `yes` it would mean preference of this program, +compared to information from `pkg-config`, if both are available. + +XML drivers and features +~~~~~~~~~~~~~~~~~~~~~~~~ + --with-neon Build and install the XML drivers (default: auto-detect) + Note that you need to install neon development package or files. +LLNC CHAOS Powerman driver +~~~~~~~~~~~~~~~~~~~~~~~~~~ + --with-powerman Build and install Powerman PDU client driver (default: auto-detect) + This allows to interact with the Powerman daemon, and the numerous -Power Distribution Units (PDU) supported by the project. +Power Distribution Units (PDU) supported by the +https://github.com/chaos/powerman[powerman] project. + Note that you need to install powerman development package or files. +IPMI drivers +~~~~~~~~~~~~ + --with-ipmi --with-freeipmi Build and install IPMI PSU driver (default: auto-detect) -This allows to monitor numerous Power Supply Units (PSU) found -on servers. -Note that you need to install freeipmi (0.8.5 or higher) development package or -files. + +This allows to monitor numerous Power Supply Units (PSU) found on servers. + +Note that you need to install freeipmi (0.8.5 or higher, for nut-scanner; +and 1.0.1 or higher, for nut-ipmipsu) development package or files. + +I2C bus drivers +~~~~~~~~~~~~~~~ --with-linux_i2c Build and install i2c drivers (default: auto-detect) + Note that you need to install libi2c development package or files. +Modbus drivers +~~~~~~~~~~~~~~ + + --with-modbus + +Build and install modbus (Serial, TCP) drivers (default: auto-detect) + +Note that you need to install libmodbus development package or files. + +Manual selection of drivers +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + --with-drivers=,,... Specify exactly which driver or drivers to build and install (this works for serial, usb, and snmp drivers, and overrides the preceding three options). -As of the time of this writing (2010), there are 46 UPS drivers +As of the time of original writing (2010), there are 46 UPS drivers available. Most users will only need one, a few will need two or three, and very few people will need all of them. To save time during the compile and disk space later on, you can use this option to just build and install a subset of the drivers. -To select mge-shut and usbhid-ups, you'd do this: +For example, to select `mge-shut` and `usbhid-ups`, you'd do this: --with-drivers=apcsmart,usbhid-ups If you need to build more drivers later on, you will need to rerun -configure with a different list. To make it build all of the -drivers from scratch again, run 'make clean' before starting. +`configure` with a different list. To make it build all of the +drivers from scratch again, run `make clean` before starting. Optional features ----------------- +CGI client interface +~~~~~~~~~~~~~~~~~~~~ + --with-cgi (default: no) Build and install the optional CGI programs, HTML files, and sample CGI configuration files. This is not enabled by default, as they -are only useful on web servers. See data/html/README for additional +are only useful on web servers. See link:data/html/README[] for additional information on how to set up CGI programs. +Pretty documentation and man pages +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + --with-doc= (default: no) Build and install NUT documentation file(s). -The possible values are "html-single" for single page HTML, "html-chunked" -for multi pages HTML, "pdf" for a PDF file or "auto" to build all the -possible previous documentation formats. -Verbose output can be enabled using: ASCIIDOC_VERBOSE=-v make -This feature requires AsciiDoc 8.6.3 (http://www.methods.co.nz/asciidoc). +This feature requires AsciiDoc 8.6.3 or newer (see https://asciidoc.org). + +The possible documentation type values are: + +* `html-single` for single page HTML, +* `html-chunked` for multi-paged HTML, +* `pdf` for a PDF file, and +* `man` for the usual manpages. + +Other values understood for this option are listed below: + +* If the `--with-doc` argument is passed without a list, or specifies + just `=yes` or `=all`, it enables all supported formats with a `=yes` + to require them. + +* An (explicit!) `--with-doc=auto` argument tries to enable all supported + formats with an `=auto` but should not fail the build if something + can not be generated. + +* A `--with-doc=no` quietly skips generation of all types of documentation, + including manpages. + +* `--with-doc=skip` is used to configure some of the `make distcheck*` + scenarios to re-use man page files built and distributed by the main + build and not waste time on re-generation of those. + +Multiple documentation format values can be specified, separated with comma. +Each such value can be suffixed with `=yes` to require building of this one +documentation format (abort configuration if tools are missing), `=auto` to +detect and enable if we can build it on this system (and not abort if we +can not), and `=no` (or `=skip`) to explicitly skip generation of this +document format even if we do have the tools to build it. + +If a document format is mentioned in the list without a suffix, then it is +treated as a `=yes` requirement. + +Verbose output can be enabled using: `ASCIIDOC_VERBOSE=-v make` + +Example valid formats of this flag: + +* `--with-doc` without an argument, effectively same as `--with-doc=yes` +* `--with-doc=` is a valid empty list, effectively same as `--with-doc=no` +* `--with-doc=auto` +* `--with-doc=pdf,html-chunked` +* `--with-doc=man=no,pdf=auto,html-single` + +Development files +~~~~~~~~~~~~~~~~~ --with-dev (default: no) -Build and install the upsclient and nutclient library and header files. +Build and install the upsclient and nutclient library and header files, to +build further projects against NUT (such as wmNUT client and many others). + +Options for developers +~~~~~~~~~~~~~~~~~~~~~~ + + --enable-check-NIT (default: no) + +Add `make check-NIT` to default activity of `make check` to run the +NUT Integration Testing suite. This is potentially dangerous (e.g. due +to port conflicts when running many such tests in same environment), +so not active by default. + + --enable-maintainer-mode (default: no) + +Use maintainer mode to keep `Makefile.in` and `Makefile` in sync with +ever-changing `Makefile.am` content after Git updates or editing. + + --enable-cppcheck (default: no) + +Activate recipes for static analysis with `cppcheck` tools (if available). + +I want it all! +~~~~~~~~~~~~~~ --with-all (no default) @@ -100,84 +233,120 @@ Build and install all of the above (the serial, USB, SNMP, XML/HTTP and PowerMan drivers, the CGI programs and HTML files, and the upsclient library). +Networking transport security +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + --with-ssl (default: auto-detect) --with-nss (default: auto-detect) --with-openssl (default: auto-detect) Enable SSL support, using either Mozilla NSS or OpenSSL. + If both are present, and nothing was specified, OpenSSL support will -be preferred. Read docs/security.txt for instructions on SSL support. +be preferred. + +Read link:docs/security.txt[] for instructions on SSL support. + +NOTE: Currently the two implementations differ in supported features. + +Networking access security +~~~~~~~~~~~~~~~~~~~~~~~~~~ --with-wrap (default: auto-detect) -Enable libwrap (tcp-wrappers) support. Refer to upsd man page for -more information. +Enable libwrap (tcp-wrappers) support. + +Refer to linkman:upsd[8] man page for more information. + +Networking IPv6 +~~~~~~~~~~~~~~~ --with-ipv6 (default: auto-detect) Enable IPv6 support. +AVAHI/mDNS +~~~~~~~~~~ + --with-avahi (default: auto-detect) Build and install Avahi support, to publish NUT server availability using mDNS protocol. This requires Avahi development files for the -Core and Client parts. +Core and Client parts. + +LibLTDL +~~~~~~~ --with-libltdl (default: auto-detect) Enable libltdl (Libtool dlopen abstraction) support. -This is required to build nut-scanner. + +This is required to build `nut-scanner` which loads third-party libraries +dynamically, based on requested scanning options. This allows to build and +package the tool without requiring all possible dependencies to be installed +in each run-time environment. Other configuration options --------------------------- +NUT data server port +~~~~~~~~~~~~~~~~~~~~ + --with-port=PORT -Change the TCP port used by the network code. Default is 3493. +Change the TCP port used by the network code. Default is 3493 +as registered with IANA. -Ancient versions of upsd used port 3305. NUT 2.0 and up use a -substantially different network protocol and are not able to +Ancient versions of `upsd` used port 3305. NUT 2.0 and up use a +substantially different network protocol and are not able to communicate with anything older than the 1.4 series. If you have to monitor a mixed environment, use the last 1.4 version, as it contains compatibility code for both the old "REQ" and the new "GET" versions of the protocol. +Daemon user accounts +~~~~~~~~~~~~~~~~~~~~ + --with-user= --with-group= -Programs started as root will setuid() to for somewhat -safer operation. You can override this with -u in several -programs, including upsdrvctl (and all drivers by extension), upsd, -and upsmon. The "user" directive in ups.conf overrides this at run +Programs started as `root` will `setuid()` to `` for somewhat +safer operation. You can override this with `-u ` in several +programs, including `upsdrvctl` (and all drivers by extension), `upsd`, +and `upsmon`. The "user" directive in `ups.conf` overrides this at run time for the drivers. -NOTE: upsmon does not totally drop root because it may need to +NOTE: `upsmon` does not totally drop `root` because it may need to initiate a shutdown. There is always at least a stub process -remaining with root powers. The network code runs in another +remaining with `root` powers. The network code runs in another (separate) process as the new user. -The is used for the permissions of some files, +The `` is used for the permissions of some files, particularly the hotplugging rules for USB. The idea is that the device files for any UPS devices should be readable and writable by members of that group. -The default value for both the username and groupname is "nobody". +The default value for both the username and groupname is `nobody` +(or `nogroup` on systems that have it when `configure` script runs). This was done since it's slightly better than staying around as -root. Running things as nobody is not a good idea, since it's a +`root`. Running things as `nobody` is not a good idea, since it's a hack for NFS access. You should create at least one separate user for this software. -If you use one of the --with-user and --with-group options, then -you have to use the other one too. +If you use one of the `--with-user` and `--with-group` options, then +you have to use the other one too. -See the INSTALL.nut document and the FAQ for more on this topic. +See the link:INSTALL.nut[] document and the FAQ for more on this topic. + +Syslog facility +~~~~~~~~~~~~~~~ --with-logfacility=FACILITY Change the facility used when writing to the log file. Read the man -page for openlog to get some idea of what's available on your system. -Default is LOG_DAEMON. +page for `openlog` to get some idea of what's available on your system. +Default is `LOG_DAEMON`. Installation directories @@ -187,111 +356,165 @@ Installation directories This is a fairly standard option with GNU autoconf, and it sets the base path for most of the other install directories. The default -is /usr/local/ups, which puts everything but the state sockets in one -easy place. +is `/usr/local/ups`, which puts everything but the state sockets in one +easy place, and does not conflict with usual distribution packaging. If you like having things to be at more of a "system" level, setting -the prefix to /usr/local or even /usr might be better. +the prefix to `/usr/local` or even `/usr` might be better. --exec_prefix=PATH This sets the base path for architecture dependent files. By -default, it is the same as . +default, it is the same as ``. --sysconfdir=PATH Changes the location where NUT's configuration files are stored. -By default this path is /etc. Setting this to /etc or -/etc/ups might be useful. +By default this path is `/etc`. Setting this to `/etc/nut` or +`/etc/ups` might be useful. -The NUT_CONFPATH environment variable overrides this at run time. +The `NUT_CONFPATH` environment variable overrides this at run time. - --bindir=PATH --sbindir=PATH + --bindir=PATH Where executable files will be installed. Files that are normally -executed by root (upsd, upsmon, upssched) go to sbindir, all others -to bindir. The defaults are /bin and /sbin. +executed by root (`upsd`, `upsmon`, `upssched`) go to ``, +all others to ``. The defaults are `/sbin` and +`/bin` respectively. - --datadir=PATH - -Change the data directory, i.e., where architecture independent -read-only data is installed. By default this is /share, -i.e., /usr/local/ups/share. At the moment, this directory only -holds two files - the optional cmdvartab and driver.list. - - --mandir=PATH - -Sets the base directories for the man pages. The default is -/man, i.e., /usr/local/ups/man. - - --includedir=PATH - -Sets the path for include files to be installed when `--with-dev` is -selected. For example, upsclient.h is installed here. The default -is /include. - - --libdir=PATH - -Sets the installation path for libraries. This is just the -upsclient library for now. The default is /lib. +See also `--with-drvpath` below. --with-drvpath=PATH The UPS drivers will be installed to this path. By default they -install to "/bin", i.e., /usr/local/ups/bin. +install to `/bin`, i.e. `/usr/local/ups/bin`. -The "driverpath" global directive in the ups.conf file overrides this +You would want a location that remains mounted when most of the system +is prepared to turn off, so some distributions package NUT drivers into +`/lib/nut` or similar. See link:config-notes.txt[] detailing how to +set up system shutdown. + +The `driverpath` global directive in the `ups.conf` file overrides this at run time. + --datadir=PATH + +Change the data directory, i.e., where architecture independent +read-only data is installed. By default this is `/share`, +i.e. `/usr/local/ups/share`. At the moment, this directory only +holds two files -- the optional `cmdvartab` and `driver.list`. + + --mandir=PATH + +Sets the base directories for the man pages. The default is +`/man`, i.e. `/usr/local/ups/man`. + + --includedir=PATH + +Sets the path for include files to be installed when `--with-dev` is +selected. For example, `upsclient.h` is installed here. The default +is `/include`. + + --libdir=PATH + +Sets the installation path for libraries. Depending on the build +configuration, this can include the `libupsclient`, `libnutclient`, +`libnutclientsub`, `libnutscan` and their pkg-config metadata (see +`--with-pkgconfig-dir` option). The default is `/lib`. + + --with-pkgconfig-dir=PATH + +Where to install pkg-config `*.pc` files. This option only has an +effect if `--with-dev` is selected, and causes a pkg-config file to +be installed in the named location. The default is +`/pkgconfig`. + +Use `--without-pkgconfig-dir` to disable this feature altogether. + --with-cgipath=PATH The CGI programs will be installed to this path. By default, they -install to "/cgi-bin", which is usually /usr/local/ups/cgi-bin. +install to `/cgi-bin`, which is usually +`/usr/local/ups/cgi-bin`. -If you set the prefix to something like /usr, you should set the -cgipath to something else, because /usr/cgi-bin is pretty ugly and +NOTE: If you set the prefix to something like `/usr`, you should set the +`cgipath` to something else, because `/usr/cgi-bin` is pretty ugly and non-standard. The CGI programs are not built or installed by default. Use -"./configure --with-cgi" to request that they are built and +`./configure --with-cgi` to request that they are built and installed. --with-htmlpath=PATH HTML files will be installed to this path. By default, this is -"/html". Note that HTML files are only installed if ---with-cgi is selected. - - --with-pkgconfig-dir=PATH - -Where to install pkg-config *.pc files. This option only has an -effect if `--with-dev` is selected, and causes a pkg-config file to -be installed in the named location. The default is -/pkgconfig. - -Use --without-pkgconfig-dir to disable this feature altogether. +`/html`. Note that HTML files are only installed if +`--with-cgi` is selected. --with-hotplug-dir=PATH -Where to install Linux 2.4 hotplugging rules. The default is -/etc/hotplug, if that directory exists, and not to install it +Where to install Linux 2.4 hotplugging rules. The default is to use +`/etc/hotplug`, if that directory exists, and to not install it otherwise. Note that this installation directory is not a -subdirectory of by default. When installing NUT as a +subdirectory of `` by default. When installing NUT as a non-root user, you may have to override this option. -Use --without-hotplug-dir to disable this feature altogether. +Use `--without-hotplug-dir` to disable this feature altogether. --with-udev-dir=PATH Where to install Linux 2.6 hotplugging rules, for kernels that have -the "udev" mechanism. The default is /etc/udev, if that directory -exists, and not to install it otherwise. Note that this -installation directory is not a subdirectory of by +the "udev" mechanism. The default is to use `/etc/udev`, if that +directory exists, and to not install it otherwise. Note that this +installation directory is not a subdirectory of `` by default. When installing NUT as a non-root user, you may have to override this option. -Use --without-udev-dir to disable this feature altogether. +Use `--without-udev-dir` to disable this feature altogether. + + --with-systemdsystemunitdir=PATH + +Where to install Linux systemd unit definitions. Useless and harmless +on other OSes, including Linux distributions without systemd, just adding +a little noise to configure script output. + +Use `--with-systemdsystemunitdir=auto` (default) to detect the settings +using pkg-config if possible. + +Use `--with-systemdsystemunitdir(=yes)` to require detection of these +settings with pkg-config, or fail configuration if not possible. + +Use `--with-systemdsystemunitdir=no` to disable this feature altogether. + + --with-systemdshutdowndir=PATH + +Where to install Linux systemd unit definitions for shutdown handling. +Useless and harmless on other OSes, including Linux distributions +without systemd, just adding a little noise to configure script output. + +Use `--with-systemdshutdowndir` to detect the settings using pkg-config. + +Use `--with-systemdshutdowndir=no` to disable this feature altogether. + + --with-systemdtmpfilesdir=PATH + +Where to install Linux systemd configuration for tmpfiles handling (the +automatically created locations for PID, state and similar run-time files). +Useless and harmless on other OSes, including Linux distributions +without systemd, just adding a little noise to configure script output. + +Use `--with-systemdtmpfilesdir` to detect the settings using pkg-config. + +Use `--with-systemdtmpfilesdir=no` to disable this feature altogether. + + --with-augeas-lenses-dir=PATH + +Where to install Augeas configuration-management lenses. + +Only useful and valid if you use Augeas to parse and modify configuration +files. The default is to use `/usr/share/augeas/lenses`, if that directory +exists, and to not install it otherwise. Directories used by NUT at run-time @@ -300,53 +523,87 @@ Directories used by NUT at run-time --with-pidpath=PATH Changes the directory where pid files are stored. By default this is -/var/run. Certain programs like upsmon will leave files here. +`/var/run`. Certain programs like `upsmon` will leave files here. --with-altpidpath=PATH -Programs that normally don't have root powers, like the drivers and -upsd, write their pid files here. By default this is whatever the -statepath is, as those programs should be able to write there. +Programs that normally don't have `root` powers, like the drivers and +`upsd`, write their pid files here. By default this is whatever the +statepath (below) is, as those programs should be able to write there. + +The `NUT_ALTPIDPATH` environment variable overrides this at run time. --with-statepath=PATH -Change the default location of the state sockets created by the -drivers. +Change the default location of the state sockets created by the drivers +to interact with the data server `upsd`. Default is `/var/state/ups`. -The NUT_STATEPATH environment variable overrides this at run time. - -Default is /var/state/ups. +The `NUT_STATEPATH` environment variable overrides this at run time. Things the compiler might need to find -------------------------------------- +LibGD +~~~~~ + + --with-pkg-config + +This option allows to provide a custom program name (in `PATH`) or a +complete pathname to `pkg-config` which describes `CFLAGS`, `LIBS` and +possibly other build-time options in `*.pc` files, to use third-party +libraries. On build systems which support multiple architectures you +may also want to set `PKG_CONFIG_PATH` to match your current build. + --with-gd-includes="-I/foo/bar" -If you installed gd in some place where your C preprocessor can't -find the header files, use this switch to add additional -I flags. +If you installed `libgd` in some place where your C preprocessor can't +find the header files, use this switch to add additional `-I` flags. --with-gd-libs="-L/foo/bar -labcd -lxyz" -If your copy of gd isn't linking properly, use this to give the -proper -L and -l flags to make it work. See LIBS= in gd's Makefile. +If your copy of `libgd` isn't linking properly, use this to give the +proper `-L` and `-l` flags to make it work. See `LIBS=` in gd's `Makefile`. -NOTE: the --with-gd switches are not necessary if you have gd 2.0.8 -or higher installed properly. The gdlib-config script will be -detected and used by default in that situation. +NOTE: the `--with-gd` switches are not necessary if you have gd 2.0.8 +or higher installed properly. The `gdlib-config` script or pkg-config +manifest will be detected and used by default in that situation. + + --with-gdlib-config + +This option allows to provide a custom program name (in `PATH`) or +a complete pathname to `gdlib-config`. This may be needed on build +systems which support multiple architectures, or in cases where your +distribution names this program differently. + +LibUSB +~~~~~~ + + --with-libusb-config + +This option allows to provide a custom program name (in `PATH`) or +a complete pathname to `libusb-config` (usually delivered only for +libusb-0.1 version, but not for libusb-1.0). This may be needed on +build systems which support multiple architectures or provide several +versions of libusb, or in cases where your distribution names this +program differently. + +Various +~~~~~~~ --with-ssl-includes, --with-usb-includes, --with-snmp-includes, --with-neon-includes, --with-libltdl-includes, --with-powerman-includes="-I/foo/bar" If your system doesn't have pkg-config and support for any of the above -libraries isn't found (but you know it is installed), you must specify the -compiler flags that are needed. +libraries isn't found (but you know it is installed), you must specify +the compiler flags that are needed. --with-ssl-libs, --with-usb-libs, --with-snmp-libs, --with-neon-libs, --with-libltdl-libs --with-powerman-libs="-L/foo/bar -labcd -lxyz" -If system doesn't have pkg-config or it fails to provides hints for some of the -settings that are needed to set it up properly and the build in defaults are -not right, you can specify the right variables here. +If system doesn't have pkg-config or it fails to provides hints for +some of the settings that are needed to set it up properly and the +build in defaults are not right, you can specify the correct values +for your system here. diff --git a/docs/contact-closure.txt b/docs/contact-closure.txt index deba8b9..044039e 100644 --- a/docs/contact-closure.txt +++ b/docs/contact-closure.txt @@ -74,15 +74,19 @@ When editing the genericups.h, the values have the following meanings: Outgoing lines: -- line_norm = what to set to make the line "normal" - i.e. cable power +- line_norm = what to set to make the line "normal" -- i.e. cable power - line_sd = what to set to make the UPS shut down the load Incoming lines: -- line_ol = flag that appears for on line / on battery -- val_ol = value of that flag when the UPS is on battery -- line_bl = flag that appears for low battery / battery OK -- val_bl = value of that flag when the battery is low +- line_ol = flag that appears for on line / on battery +- val_ol = value of that flag when the UPS is on battery +- line_bl = flag that appears for low battery / battery OK +- val_bl = value of that flag when the battery is low +- line_rb = flag that appears for battery health +- val_rb = value of that flag when the battery needs a replacement +- line_bypass = flag that appears for battery bypass / battery protection active +- val_bypass = value of that flag when the battery is bypassed / missing This may seem a bit confusing to have two variables per value that we want to read, but here's how it works. If you set line_ol to @@ -91,7 +95,7 @@ with the value of the serial port whenever a poll occurs. If that flag exists, then the result of the and will be 0x80. If it does not exist, the result will be 0. -So, if line_ol = foo, then val_ol can only be foo or 0. +So, if line_ol = foo, then val_ol can only be foo or 0. As a general case, if 'line_ol == val_ol', then the value you're reading is active high. Otherwise, it's active low. Check out the guts of diff --git a/docs/daisychain.txt b/docs/daisychain.txt new file mode 100644 index 0000000..c67d287 --- /dev/null +++ b/docs/daisychain.txt @@ -0,0 +1,220 @@ +ifndef::external_title[] +[[daisychain]] +NUT daisychain support notes +============================ +endif::external_title[] + +NUT supports daisychained devices for any kind of device that proposes +it. This chapter introduces: + +* for developers: how to implement such mechanism, +* for users: how to manage and use daisychained devices in NUT in general, + and how to take advantage of the provided features. + +Introduction +------------ + +It's not unusual to see some daisy-chained PDUs or UPSs, connected together +in master-slave mode, to only consume 1 IP address for their communication +interface (generally, network card exposing SNMP data) and expose only one +point of communication to manage several devices, through the daisy-chain +master. + +This breaks the historical consideration of NUT that one driver provides +data for one unique device. However, there is an actual need, and a smart +approach was considered to fulfill this, while not breaking the standard +scope (for base compatibility). + + +Implementation notes +-------------------- + +General specification +~~~~~~~~~~~~~~~~~~~~~ + +The daisychain support uses the device collection to extend the historical +NUT scope (1 driver -- 1 device), and provides data from the additional +devices accessible through a single management interface. + +A new variable was introduced to provide the number of devices exposed: the +`device.count`, which: + +* defaults to 1 +* if higher than 1, enables daisychain support and access to data of each +individual device through `device.X.{...}` + +To ensure backward compatibility in NUT, the data of the various devices +are exposed the following way: + +* `device.0` is a special case, for the whole set of devices (the whole +daisychain). It is equivalent to `device` (without `.X` index) and root +collections. The idea is to be able to get visibility and control over the +whole daisychain from a single point. +* daisy-chained devices are available from `device.1` (master) to `device.N` +(slaves). + +That way, client applications that are unaware of the daisychain support, +will only see the whole daisychain, as it would normally seem, and not +nothing at all. + +Moreover, this solution is generic, and not specific to the ePDU use case +currently considered. It thus support both the current NUT scope, along with +other use cases (parallel / serial UPS setups), and potential evolution and +technology change (hybrid chain with UPS and PDU for example). + + +Devices status handling +^^^^^^^^^^^^^^^^^^^^^^^ + +To be clarified... + + +Devices alarms handling +^^^^^^^^^^^^^^^^^^^^^^^ + +Devices (master and slaves) alarms are published in `device.X.ups.alarm`, +which may evolve into `device.X.alarm`. If any of the devices has an alarm, +the main `ups.status` will publish an `ALARM` flag. This flag is be cleared +once all devices have no alarms anymore. + +NOTE: ups.alarm behavior is not yet defined (all devices alarms vs. list of +device(s) that have alarms vs. nothing?) + +Example +^^^^^^^ + +Here is an example excerpt of three PDUs, connected in daisychain mode, with +one master and two slaves: + + device.count: 3 + device.mfr: EATON + device.model: EATON daisychain PDU + device.1.mfr: EATON + device.1.model: EPDU MI 38U-A IN: L6-30P 24A 1P OUT: 36XC13:6XC19 + device.2.mfr: EATON + device.2.model: EPDU MI 38U-A IN: L6-30P 24A 1P OUT: 36XC13:6XC19 + device.3.mfr: EATON + device.3.model: EPDU MI 38U-A IN: L6-30P 24A 1P OUT: 36XC13:6XC19 + ... + device.3.ups.alarm: high current critical! + device.3.ups.status: ALARM + ... + input.voltage: ??? (proposal: range or list or average?) + device.1.input.voltage: 237.75 + device.2.input.voltage: 237.75 + device.3.input.voltage: 237.75 + ... + outlet.1.status: ?? (proposal: "on, off, off) + device.1.outlet.1.status: on + device.2.outlet.1.status: off + device.3.outlet.1.status: off + ... + ups.status: ALARM + + +Information for developers +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +NOTE: these details are dedicated to the `snmp-ups` driver! + +In order to enable daisychain support for a range of devices, developers +have to do two things: + +* Add a `device.count` entry in a mapping file (see `*-mib.c`) +* Modify mapping entries to include a format string for the daisychain index + +Optionally, if there is support for outlets and / or outlet-groups, there +is already a template formatting string. So you have to tag such templates +with multiple definitions, to point if the daisychain index is the first +or second formatting string. + +Base support +^^^^^^^^^^^^ + +In order to enable daisychain support on a mapping structure, the following +steps have to be done: + +* Add a "device.count" entry in the mapping file: snmp-ups will determine +if the daisychain support has to be enabled (if more than 1 device). +To achieve this, use one of the following type of declarations: ++ +a) point at an OID which provides the number of devices: + + { "device.count", 0, 1, ".1.3.6.1.4.1.13742.6.3.1.0", "1", + SU_FLAG_STATIC, NULL }, ++ +b) point at a template OID to guesstimate the number of devices, by walking +through this template, until it fails: ++ + { "device.count", 0, 1, ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.%i", "1", + SU_FLAG_STATIC, NULL, NULL }, + +* Modify all entries so that OIDs include the formatting string for the +daisychain index. For example, if you have the following entry: ++ + { "device.model", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.0", ... }, ++ +And if the last "0" of the the 4th field represents the index of the device +in the daisychain, then you would have to adapt it the following way: ++ + { "device.model", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.%i", ... }, + + +Templates with multiple definitions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If there already exist templates in the mapping structure, such as for +single outlets and outlet-groups, you also need to specify the position +of the daisychain device index in the OID strings for all entries in the +mapping table, to indicate where the daisychain insertion point is exactly. + +For example, using the following entry: + + { "outlet.%i.current", 0, 0.001, ".1.3.6.1.4.1.534.6.6.7.6.4.1.3.0.%i", + NULL, SU_OUTLET, NULL, NULL }, + +You would have to translate it to: + + { "outlet.%i.current", 0, 0.001, ".1.3.6.1.4.1.534.6.6.7.6.4.1.3.%i.%i", + NULL, SU_OUTLET | SU_TYPE_DAISY_1, NULL, NULL }, + +`SU_TYPE_DAISY_1` flag indicates that the daisychain index is the first +`%i` specifier in the OID template string. If it is the second one, use +`SU_TYPE_DAISY_2`. + + +Devices alarms handling +^^^^^^^^^^^^^^^^^^^^^^^ + +Two functions are available to handle alarms on daisychain devices in your +driver: + +* `device_alarm_init()`: clear the current alarm buffer +* `device_alarm_commit(const int device_number)`: commit the current alarm +buffer to "device..ups.alarm", and increase the count of +alarms. If the current alarms buffer is empty, the count of alarm is +decreased, and the variable "device..ups.alarm" is removed +from publication. Once the alarm count reaches "0", the main (device.0) +ups.status will also remove the "ALARM" flag. + +[NOTE] +====== +When implementing a new driver, the following functions have to be +called: + +* `alarm_init()` at the beginning of the main update loop, for the whole +daisychain. This will set the alarm count to "0", and reinitialize all +alarms, +* `device_alarm_init()` at the beginning of the per-device update loop. +This will only clear the alarms for the current device, +* `device_alarm_commit()` at the end of the per-device update loop. +This will flush the current alarms for the current device, +* also `device_alarm_init()` at the end of the per-device update loop. +This will clear the current alarms, and ensure that this buffer will not +be considered by other subsequent devices, +* `alarm_commit()` at the end of the main update loop, for the whole +daisychain. This will take care of publishing or not the "ALARM" flag +in the main ups.status (`device.0`, root collection). +====== diff --git a/docs/design.txt b/docs/design.txt index 4e39eca..9655f01 100644 --- a/docs/design.txt +++ b/docs/design.txt @@ -1,7 +1,7 @@ NUT design document =================== -This software is designed around a layered scheme with drivers, a +This software is designed around a layered scheme with drivers, a server and clients. These layers communicate with text-based protocols for easier maintenance and diagnostics. @@ -26,7 +26,7 @@ From the driver ~~~~~~~~~~~~~~~ The core of all DRIVERS maintains internal storage for every variable -that is known along with the auxiliary data for those variables. It +that is known along with the auxiliary data for those variables. It sends updates to this data to any process which connects to the Unix domain socket. @@ -39,7 +39,7 @@ The SERVER will connect to the socket of each DRIVER and will request a dump at that time. It retains this data in local storage for later use. It continues to listen on the socket for additional updates. -This protocol is documented in sock-protocol.txt. +This protocol is documented in link:sock-protocol.txt[]. From the server ~~~~~~~~~~~~~~~ @@ -50,28 +50,31 @@ immediately. When a request for data arrives from a CLIENT, the SERVER looks through the internal storage for that UPS and returns the requested data if it is available. -The format for requests from the CLIENT is documented in protocol.txt. +The format for requests from the CLIENT is documented in link:protocol.txt[]. Instant commands ---------------- -Instant commands is the term given to a set of actions that result in +"Instant commands" is the term given to a set of actions that result in something happening to the UPS. Some of the common ones are -test.battery.start to initiate a battery test and test.panel.start to +`test.battery.start` to initiate a battery test and `test.panel.start` to test the front panel of the UPS. They are passed to the SERVER from a CLIENT using an authenticated network connection. The SERVER first checks to make sure that the instant -command is valid for the DRIVER. If it's supported, a message is sent +command is valid for the DRIVER. If it's supported, a message is sent via a socket to the DRIVER containing the command and any auxiliary information. At this point, there is no confirmation to the SERVER of the command's execution. This is (still) planned for a future release. This has been delayed since returning a response involves some potentially interesting -timing issues. Remember that upsd services clients in a round-robin +timing issues. Remember that `upsd` services clients in a round-robin fashion, so all queries must be lightweight and speedy. +NOTE: FIXME: Wasn't "TRACKING" mechanism for "INSTCMD/SET VAR" introduced +to address just this? See https://github.com/networkupstools/nut/pull/659 + Setting variables ----------------- @@ -88,6 +91,9 @@ Like the instant commands, there is currently no acknowledgement of the command's completion from the DRIVER. This, too, is planned for a future release. +NOTE: FIXME: Wasn't "TRACKING" mechanism for "INSTCMD/SET VAR" introduced +to address just this? See https://github.com/networkupstools/nut/pull/659 + Example data path ----------------- @@ -97,24 +103,24 @@ delivering the alpha message to the admin. 1. EQUIPMENT reports on battery by setting flag in status register -2. DRIVER notices this flag and stores it in the ups.status variable as +2. DRIVER notices this flag and stores it in the `ups.status` variable as OB. This update gets pushed out to any listeners via the sockets. -3. SERVER upsd sees activity on the socket, reads it, parses it, and - commits the new data to its local version of the status variable. +3. SERVER `upsd` sees activity on the socket, reads it, parses it, and + commits the new data to its local version of the status variable. -4. CLIENT upsmon does a routine poll of SERVER for "ups.status" and - gets "OB". +4. CLIENT `upsmon` does a routine poll of SERVER for `ups.status` and + gets `OB`. -5. CLIENT upsmon then invokes its NOTIFYCMD which is upssched. +5. CLIENT `upsmon` then invokes its `NOTIFYCMD` which is `upssched`. -6. upssched starts up a daemon to handle a timer which will expire about +6. `upssched` starts up a daemon to handle a timer which will expire about 30 seconds into the future. 7. 30 seconds later, the timer expires since the UPS is still on battery, - and upssched calls the CMDSCRIPT upssched-cmd. + and so `upssched` calls the `CMDSCRIPT` which is `upssched-cmd`. -8. upssched-cmd parses the args and calls sendmail. +8. `upssched-cmd` parses the args and calls `sendmail`. 9. Avian carriers, smoke signals, SMTP, and some magic result in the message getting from the pager company's gateway to a transmitter @@ -122,66 +128,66 @@ delivering the alpha message to the admin. This scenario requires some configuration, obviously: -1. There's a UPS driver running. +1. There's an UPS driver running. (Whatever applies for the hardware) -2. upsd has a valid UPS entry in ups.conf for this UPS. +2. `upsd` has a valid UPS entry in 'ups.conf' for this UPS. [myups] driver = nutupsdrv port = /dev/ttySx -3. upsd has a valid user for upsmon in upsd.users. +3. `upsd` has a valid user for `upsmon` in 'upsd.users' file. [monuser] password = somepass - upsmon master + upsmon primary -4. upsmon is set to monitor this UPS in upsmon.conf. - - MONITOR myups@localhost 1 monuser somepass master +4. `upsmon` is set to monitor this UPS with this user in 'upsmon.conf' file. -5. upsmon is set to EXEC the NOTIFYCMD for the ONBATT condition in - upsmon.conf. + MONITOR myups@localhost 1 monuser somepass primary + +5. `upsmon` is set to `EXEC` the `NOTIFYCMD` for the `ONBATT` condition in + 'upsmon.conf' file. NOTIFYFLAG ONBATT EXEC -6. upsmon calls upssched as the NOTIFYCMD in upsmon.conf. +6. `upsmon` calls `upssched` as the `NOTIFYCMD` in 'upsmon.conf' file. NOTIFYCMD /path/to/upssched -7. upssched has a 30 second timer for ONBATT in upssched.conf. +7. `upssched` has a 30 second timer for `ONBATT` in 'upssched.conf' file. AT ONBATT * START-TIMER upsonbatt 30 -8. upssched calls upssched-cmd as the CMDSCRIPT in upssched.conf. +8. `upssched` calls `upssched-cmd` as the `CMDSCRIPT` in 'upssched.conf'. CMDSCRIPT /path/to/upssched-cmd -9. upssched-cmd knows what to do with "upsonbatt" as its first argument - (A quick case..esac construct, see the examples) +9. `upssched-cmd` knows what to do with `upsonbatt` keyword as its first + argument (a quick `case..esac` construct, see the examples) History ------- The oldest versions of this software (1998) had no separation between -the driver and the network server and only supported the latest APC +the driver and the network server, and only supported the latest APC Smart-UPS hardware as a result. The network protocol used brittle binary structs. This had numerous bad implications for compatibility and portability. After the driver and server were separated, data was shared through the state file concept. Status was written into a static array (the "info -array") by drivers, and that array was stored on disk. upsd would +array") by drivers, and that array was stored on disk. The `upsd` would periodically read that file into a local copy of that array. Shared memory mode was added a bit later, and that removed some of the lag from the status updates. Unfortunately, it didn't have any locking originally, and the possibility for corruption due to races existed. -mmap() support was added at some point after that, and became the -default. The drivers and upsd would mmap() the file into memory and +`mmap()` support was added at some point after that, and became the +default. The drivers and `upsd` would `mmap()` the file into memory and read or write from it. Locking was done using the state file as the token, so contention problems were avoided. This method was relatively quick, but it involved at least 3 copies of the data (driver, disk/mmap, @@ -194,12 +200,13 @@ connections and push updates asynchronously to any listeners. They also recognize a few commands. Drivers also dampen updates, and only push them out when something actually changes. -As a result, upsd no longer has to poll any files on the disk, and can -just select() all of its fds and wait for activity. When one of them is -active, it reads the fd and parses the results. Updates from the -hardware now get to upsd about as fast as they possibly can. +As a result, `upsd` no longer has to poll any files on the disk, and can +just `select()` all of its file descriptors (fds) and wait for activity. +When one of them is active, it reads the fd and parses the results. +Updates from the hardware now get to `upsd` about as fast as they possibly +can. -Drivers used to call setinfo() to change the local array, and then would -call writeinfo() to push the array onto the disk, or into the +Drivers used to call `setinfo()` to change the local array, and then would +call `writeinfo()` to push the array onto the disk, or into the mmap/shared memory space. This introduced a lag since many drivers poll quite a few variables during an update. diff --git a/docs/developer-guide.txt b/docs/developer-guide.txt index 7b0a823..5cd8f2c 100644 --- a/docs/developer-guide.txt +++ b/docs/developer-guide.txt @@ -73,18 +73,19 @@ This mode allows to simulate any kind of devices, even non existing ones. Using this method, you can either replay a real life sequence, <>, or directly interact -through upsrw or by editing the device file, to modify the variables values. +through `upsrw` or by editing the device file, to modify the variables' +values. Here is an example to setup a device simulation: - install NUT as usual, if not already done -- get a simulation file (.dev) or sequence (.seq), or generate one using the -<>. Sample files are provided in the 'data' -directory of the NUT source. You can also download these from the development -repository, such as the -link:http://anonscm.debian.org/viewvc/nut/trunk/data/evolution500.seq?revision=2778&view=co[evolution500.seq]. -- copy the simulation file to your sysconfig directory, like /etc/nut or -/etc/ups +- get a simulation file (`.dev`) or sequence (`.seq`), or generate one using + the <>. Sample files are provided in the + `data` directory of the NUT source. You can also download these from + the development repository, such as the + link:https://github.com/networkupstools/nut/raw/master/data/evolution500.seq[evolution500.seq]. +- copy the simulation file to your sysconfig directory, like `/etc/nut` + or `/etc/ups` - configure NUT for simulation (linkman:ups.conf[5]): + [dummy] @@ -92,7 +93,7 @@ link:http://anonscm.debian.org/viewvc/nut/trunk/data/evolution500.seq?revision=2 port = evolution500.dev desc = "dummy-ups in dummy mode" + -- now start NUT, at least dummy-ups and upsd: +- now start NUT, at least `dummy-ups` and `upsd`: + $ upsdrvctl start dummy $ upsd @@ -102,15 +103,15 @@ link:http://anonscm.debian.org/viewvc/nut/trunk/data/evolution500.seq?revision=2 $ upsc dummy ... + -- you can also use upsrw to modify the data: +- you can also use `upsrw` to modify the data in memory: + $ upsrw -s ups.status="OB LB" -u user -p password dummy + -- or directly edit /etc/nut/evolution500.seq. In this case, modification will -only apply according to the TIMER events and the current position in the -sequence. +- or directly edit your copy of `/etc/nut/evolution500.seq`. + In this case, modification will only apply according to the `TIMER` + events and the current position in the sequence. -For more information, refer to linkman:dummy-ups[8] manual page. +For more information, refer to linkman:dummy-ups[8] manual page. [[dev-recording]] @@ -118,11 +119,11 @@ For more information, refer to linkman:dummy-ups[8] manual page. Device recording ---------------- -To complete dummy-ups, NUT provides a device recorder script called -'nut-recorder.sh' and located in the 'tools/' directory of the +To complete `dummy-ups`, NUT provides a device recorder script called +`nut-recorder.sh` and located in the 'tools/' directory of the NUT source tree. -This script uses 'upsc' to record device information, and stores +This script uses `upsc` to record device information, and stores these in a differential fashion every 5 seconds (by default). Its usage is the following: @@ -134,8 +135,8 @@ For example, to record information from the device 'myups' every 10 seconds: nut-recorder.sh myups@localhost myups.seq 10 During the recording, you will want to generate power events, such as power -failure and restoration. These will be tracked in the simulation files, and be -eventually be replayed by the <> driver. +failure and restoration. These will be tracked in the simulation files, and +be eventually be replayed by the <> driver. NUT core development and maintenance @@ -159,8 +160,14 @@ Appendix A: NUT command and variable naming scheme include::nut-names.txt[] +[[daisychain]] +Appendix B: NUT daisychain support notes +======================================== + +include::daisychain.txt[] + [[lib-info]] -Appendix B: NUT libraries complementary information +Appendix C: NUT libraries complementary information =================================================== include::../lib/README[] diff --git a/docs/developers.txt b/docs/developers.txt index 9d52065..11f8daa 100644 --- a/docs/developers.txt +++ b/docs/developers.txt @@ -4,70 +4,71 @@ Information for developers This document is intended to explain some of the more useful things within the tree, and provide a standard for working on the code. -General stuff - common subdirectory ------------------------------------ +General stuff -- common subdirectory +------------------------------------ String handling ~~~~~~~~~~~~~~~ -Use snprintf(). It's even provided with a compatibility module if the +Use `snprintf()`. It's even provided with a compatibility module if the target system doesn't have it natively. -If you use snprintf() to load some value into a buffer, make sure you +If you use `snprintf()` to load some value into a buffer, make sure you provide the format string. Don't use user-provided format strings, since that's an easy way to open yourself up to an exploit. -Don't use strcat(). We have a neat wrapper for snprintf() called snprintfcat() -that allows you to append to char * with a format string and all the usual -string length checking of snprintf(). +Don't use `strcat()`. We have a neat wrapper for `snprintf()` called +`snprintfcat()` that allows you to append to `char *` with a format +string and all the usual string length checking of `snprintf()` routine. Error reporting ~~~~~~~~~~~~~~~ -Don't call syslog() directly. Use upslog_with_errno() and upslogx(). +Don't call `syslog()` directly. Use `upslog_with_errno()` and `upslogx()`. They may write to the syslog, stderr, or both as appropriate. This means you don't have to worry about whether you're running in the background or not. -upslog_with_errno prints your message plus the string expansion of -errno. upslogx just prints the message. +The `upslog_with_errno()` routine prints your message plus the string +expansion of `errno`. The `upslogx()` just prints the message. -fatal_with_errno and fatalx work the same way, but they -exit(EXIT_FAILURE) afterwards. Don't call exit() directly. +`fatal_with_errno()` and `fatalx()` work the same way, but they +also `exit(EXIT_FAILURE)` afterwards. Don't call `exit()` directly. Debugging information ~~~~~~~~~~~~~~~~~~~~~ -upsdebug_with_errno(), upsdebugx(), upsdebug_hex() and upsdebug_ascii() -use the global `nut_debug_level` so you don't have to mess around with -printf()s yourself. Use them. +The `upsdebug_with_errno()`, `upsdebugx()`, `upsdebug_hex()` and +`upsdebug_ascii()` routines use the global `nut_debug_level`, so you +don't have to mess around with `printf()`'s and `if`'s yourself. +Use them. Memory allocation ~~~~~~~~~~~~~~~~~ -xmalloc, xcalloc, xrealloc and xstrdup all check the results of the base -calls before continuing, so you don't have to. Don't use the raw calls -directly. +`xmalloc()`, `xcalloc()`, `xrealloc()` and `xstrdup()` all check the +results of the base calls before continuing, so you don't have to. +Don't use the raw calls directly. Config file parsing ~~~~~~~~~~~~~~~~~~~ -The configuration parser, called parseconf, is now up to its fourth +The configuration parser, called `parseconf`, is now up to its fourth major version. It has multiple entry points, and can handle many different jobs. It's usually used for parsing files, but it can also take input a line at a time or even a character at a time. -You must initialize a context buffer with pconf_init before using any -other parseconf function. pconf_encode is the only exception, since it -operates on a buffer you supply and is an auxiliary function. +You must initialize a context buffer with `pconf_init()` before using any +other `parseconf` function. `pconf_encode()` is the only exception, since +it operates on a buffer you supply and is an auxiliary function. Escaping special characters and quoting multiple-word elements is all handled by the state machine. Using the same code for all config files avoids code duplication. NOTE: this does not apply to drivers. Driver authors should use the -upsdrv_makevartable() scheme to pick up values from ups.conf. Drivers -should not have their own config files. +`upsdrv_makevartable()` scheme to pick up values from 'ups.conf' file. +Drivers should not have their own config files. Drivers may have their own data files, such as lists of hardware, mapping tables, or similar. The difference between a data file and a @@ -78,13 +79,13 @@ hardware support to a driver without recompiling. vs. ~~~~~~~~~~~~~~~~~~~~~~~~~ -This is already handled by autoconf, so just include "timehead.h" and you -will get the right headers on every system. +This is already handled by autoconf, so just `#include "timehead.h"` and +you will get the right headers on every system. -Device drivers - main.c ------------------------ +Device drivers -- main.c +------------------------ -The device drivers use main.c as their core. +The device drivers use `main.c` as their core. To write a new driver, you create a file with a series of support functions that will be called by main. These all have names that start @@ -92,7 +93,7 @@ with `upsdrv_`, and they will be called at different times by main depending on what needs to happen. See the <> for information on writing -drivers, and also refer to the skeletal driver in skel.c. +drivers, and also refer to the skeletal driver in `skel.c`. Portability ----------- @@ -108,9 +109,9 @@ There are still older systems out there that don't do C++ style comments. -------------------------------------- Newer versions of gcc allow you to declare a variable inside a function -somewhat like the way C++ operates, like this: +after code, somewhat like the way C++ operates, like this: --------------------------------------------------------------------------------- +------------------------------------------------------------------------------- function do_stuff(void) { check_something(); @@ -119,18 +120,322 @@ function do_stuff(void) a = do_something_else(); } --------------------------------------------------------------------------------- +------------------------------------------------------------------------------- While this will compile and run on these newer versions, it will fail miserably for anyone on an older system. That means you must not use -it. gcc only warns about this with -pedantic. +it. `gcc` only warns about this with `-pedantic` flag. + +Another feature that does not work on some compilers (e.g. conforming +to "ANSI C"/C89/C90 standard) is initial variable declaration inside a +'for loop' block, like this: +-------------------------------------------------------------------------------- +function do_stuff(void) +{ + /* This should declare "int i;" first, then use it in "for" loop: */ + for (int i = 0; i < INT_MAX; ++i) { ... } + + /* Additional loops cause also an error about re-declaring a variable: */ + for (int i = 10; i < 15; ++i) { ... } +} +-------------------------------------------------------------------------------- + +TIP: At this point NUT is expected to work correctly when built with a +C99 (or rather GNU99 on many systems) or newer standard. + +The NUT codebase may build in a mode without warnings made fatal on C89 +(GNU89), but the emitted warnings indicate that those binaries may crash. +By the end of 2021, NUT codebase has been revised to pass GNU and strict-C +mode builds with C89 standard with the GCC toolkit (and on systems that do +have the newer features in libraries, just hide them in standard headers); +however CLANG toolkit is more restrictive about the C99+ syntax used. +If somebody in the community requires to build and run NUT on systems +that old, pull requests to fix the offending coding issues are welcome. + +Note also that the NUT codebase currently relies on certain features, +such as the printf format modifiers for `(s)size_t`, use of `long long`, +some nuances about structure/array initializers, variadic macros for +debugging, etc. that a pedantic C90 mode compilation warns is not part +of the standard but a GNU extension (and part of C99 and newer standard +revisions). Many of the "offences" against the older standard actually +come from system and third-party header files. + +That said, the NUT CI farm does run non-regression builds with GNU C89 +and strict C89 standard revisions and minimal passing warnings level, +to ensure that codebase is and remains at least basically compliant. + +Continuous Integration and Automated Builds +------------------------------------------- + +To ease and automate the build scenarios which were deemed important for +quality assurance and non-regression checks of NUT, several solutions +were introduced over time. + +ci_build.sh +^^^^^^^^^^^ + +This script was originally introduced (following ZeroMQ/ZProject example) +to automate CI builds, by automating certain scenarios driven by exported +environment variables to set particular `configure` options and `make` +some targets (chosen by the `BUILD_TYPE` envvar). It can also be used +locally to avoid much typing to re-run those scenarios during development. + +Developers can directly use the scripts involved in CI builds to fix +existing code on their workstations or to ensure support for new +compilers and C standard revisions, e.g. save a local file like this +to call the common script with pre-sets: + + $ cat _fightwarn-gcc10-gnu17.sh + #!/bin/sh + + BUILD_TYPE=default-all-errors \ + CFLAGS="-Wall -Wextra -Werror -pedantic -std=gnu17" \ + CXXFLAGS="-Wall -Wextra -Werror -std=gnu++17" \ + CC=gcc-10 CXX=g++-10 \ + ./ci_build.sh + +...and then execute it to prepare a workspace, after which you can go +fixing bugs file-by-file running a `make` after each save to confirm +your solutions and uncover the next issue to address :-) + +Helpfully, the NUT CI farm build logs report the configuration used for +each executed stage, so if some build combination fails -- you can just +scroll to the end of that section and copy-paste the way to reproduce +an issue locally (on an OS similar to that build case). + +Note that while spelling out sets of warnings can help in a quest to +fix certain bugs during development (if only by removing noise from +classes of warnings not relevant to the issue one is working on), there +is a reasonable set of warnings which NUT codebase actively tries to +be clean about (and checks in CI), detailed in the next section. + +For the `ci_build.sh` usage like above, one can instead pass the setting +via `BUILD_WARNOPT=...`, and require that all emitted warnings are fatal +for their build, e.g.: + + $ cat _fightwarn-clang9-gnu11.sh + #!/bin/sh + + BUILD_TYPE=default-all-errors \ + BUILD_WARNOPT=hard BUILD_WARNFATAL=yes \ + CFLAGS="-std=gnu11" \ + CXXFLAGS="-std=gnu++11" \ + CC=clang-9 CXX=clang++-9 CPP=clang-cpp \ + ./ci_build.sh + +Finally, for refactoring effort geared particularly for fighting the +warnings which exist in current codebase, the script contains some +presets (which would evolve along with codebase quality improvements) +as `BUILD_TYPE=fightwarn-gcc`, `BUILD_TYPE=fightwarn-clang` or plain +`BUILD_TYPE=fightwarn`: + + BUILD_TYPE=fightwarn-clang ./ci_build.sh + +As a rule of thumb, new contributions must not emit any warnings when +built in GNU99 mode with a `minimal` "difficulty" level of warnings. +Technically they must survive the part of test matrix across the several +platforms tested by NUT CI and marked in project settings as required +to pass, to be accepted for a pull request merge. + +Developers aiming to post successful pull requests to improve NUT can +pass the `--enable-warnings` option to the `configure` script in local +builds to see how that behaves and ensure that at least in some set-up +their contribution is viable. Note that different compiler versions and +vendors (gcc/clang/...), building against different OS and third-party +dependencies, with different CPU architectures and different language +specification revisions, might all complain about different issues -- +and catching this in as diverse range of set-ups as possible is why we +have CI tests. + +It can be beneficial for serial developers to set up a local BuildBot, +Travis or a Jenkins instance with a matrix test job, to test their local +git repository branches with whatever systems they have available. + +* https://github.com/networkupstools/nut/issues/823 + +While `autoconf` tries its best to provide portable shell code, sometimes +there are builds of system shell that just fail under stress. If you are +seeing random failures of `./configure` script in different spots with +the same inputs, try telling `./ci_build.sh` to loop configuring until +success (instead of quickly failing), and/or tell `./configure` to use +another shell at least for the system call-outs, with options like these: + + SHELL=/bin/bash CONFIG_SHELL=/bin/bash CI_SHELL_IS_FLAKY=true \ + ./ci_build.sh + +Jenkins CI +^^^^^^^^^^ + +Since mid-2021, the NUT CI farm is implemented by several virtual servers +courteously provided by http://fosshost.org + +These run various operating systems as build agents, and a Jenkins instance +to orchestrate the builds of NUT branches and pull requests on those agents. + +This is driven by `Jenkinsfile-dynamatrix` and a Jenkins Shared Library called +link:https://github.com/networkupstools/jenkins-dynamatrix[jenkins-dynamatrix] +which prepares a matrix of builds across as many operating systems, +bitnesses/architectures, compilers, make programs and C/C++ revisions +as it can -- based on the population of currently available build agents +and capabilities which they expose as agent labels. + +This hopefully means that people interested in NUT can contribute to the +build farm (and ensure NUT is and remains compatible with their platform) +by running a Jenkins Swarm agent with certain labels, which would dial +into https://ci.networkupstools.org/ controller. Please contact the NUT +maintainer if you want to participate in this manner. + +The `Jenkinsfile-dynamatrix` recipe allows NUT CI farm to run different sets +of build scenarios based on various conditions, such as the name of branch +being built (or PR'ed against), changed files (e.g. C/C++ sources vs. just +docs), and some build combinations may be not required to succeed. + +For example, the main development branch and pull requests against it must +cleanly pass all specified builds and tests on various platforms with the +default level of warnings specified in the `configure` script. These are +balanced to not run too many build scenarios overall, but just a quick and +sufficiently representative set. + +As another example, there is special handling for "fightwarn" pattern in +the branch names to run many more builds with varying warning levels and +more variants of intermediate language revisions, and so expose concerns +deliberately missed by default warnings levels in "master" branch builds +(the bar moves over time, as some classes of warnings become extinct from +our codebase). + +Further special handling for branches named like `fightwarn.*89.*` regex +enables more intensive warning levels for a GNU89 build specifically (which +are otherwise disabled as noisy yet not useful for supported C99+ builds), +and is intended to help develop fixes for support of this older language +revision, if anyone would dare. + +Many of those unsuccessful build stages are precisely the focus of the +"fightwarn" effort, and are currently marked as "may fail", so they end +up as "UNSTABLE" (seen as orange bubbles in the Jenkins BlueOcean UI, or +orange cells in the tabular list of stages in the legacy UI), rather than +as "FAILURE" (red bubbles) for build scenarios that were not expected to +fail and usually represent higher-priority problems that would block a PR. + +Developers whose PR builds (or attempts to fix warnings) did not succeed in +some cell of such build matrix, can look at the individual logs of that cell. +Beside indication from the compiler about the failure, the end of log text +includes the command which was executed by CI worker and can be reproduced +locally by the developer, e.g.: +---- +22:26:01 FINISHED with exit-code 2 cmd: ( +22:26:01 [ -x ./ci_build.sh ] || exit +22:26:01 +22:26:01 eval BUILD_TYPE="default-alldrv" BUILD_WARNOPT="hard" \ + BUILD_WARNFATAL="yes" MAKE="make" CC=gcc-10 CXX=g++-10 \ + CPP=cpp-10 CFLAGS='-std=gnu99 -m64' CXXFLAGS='-std=gnu++11 -m64' \ + LDFLAGS='-m64' ./ci_build.sh +22:26:01 ) +---- +or for autotools-driven scenarios (which prep, configure, build and test +in separate stages -- so for reproducing a failed build you should also +look at its configuration step separately): +---- +22:28:18 FINISHED with exit-code 0 cmd: ( [ -x configure ] || exit; \ + eval CC=clang-9 CXX=clang++-9 CPP=clang-cpp-9 CFLAGS='-std=c11 -m64' \ + CXXFLAGS='-std=c++11 -m64' LDFLAGS='-m64' time ./configure ) +---- + +To re-run such scenario locally, you can copy the line from `eval` (but +without the `eval` keyword itself) up to and including the executed script +or tool, into your shell. Depending on locally available compilers, you +may have to tweak the `CC`, `CXX` and `CPP` arguments; note that a `CPP` +may be specified as `/path/to/CC -E` for GCC and CLANG based toolkits +at least, if they lack a standalone preprocessor program (e.g. IntelCC). + +NOTE: While NUT recipes do not currently recognize a separate `CXXCPP`, +it would follow similar semantics. + +Some further details about the NUT CI farm workers are available in +link:config-prereqs.txt[config-prereqs.txt] and +link:ci-farm-lxc-setup.txt[ci-farm-lxc-setup.txt] documents. + +Travis CI +^^^^^^^^^ + +See the `.travis.yml` file in project sources for a detailed list of third +party dependencies and a large matrix of `CFLAGS` and compiler versions +last known to work or to not (yet) work on operating systems available +to that CI solution. + +[NOTE] +====== +The cloud Travis CI offering became effectively defunct for +open-source projects in mid-2021, so the `.travis.yml` file in NUT +codebase is not actively maintained. + +Local private deployments of Travis CI are possible, so if anybody does +use it and has updated markup to share, they are welcome to post PRs. +====== + +The NUT project on GitHub has integration with Travis CI to test a large +set of compiler and option combinations, covering different versions of +gcc and clang, C standards, and requiring to pass builds at least in a +mode without warnings (and checking the other cases where any warnings +are made fatal). + +Pre-set warning options +~~~~~~~~~~~~~~~~~~~~~~~ + +The options chosen into pre-sets that can be selected by `configure` +script options are ones we use for different layers of CI tests. + +Values to note include: + +* `--enable-Werror(=yes/no)` -- make warnings fatal; + +* `--enable-warnings(=.../no)` -- enable certain warning presets: + +** `gcc-hard`, `clang-hard`, `gcc-medium`, `clang-medium`, `gcc-minimal`, + `clang-minimal`, `all` -- actual definitions that are compiler-dependent + (the latter just adds `-Wall` which may be relatively portable); + +** `hard`, `medium` or `minimal` -- if current compiler is detected as + CLANG or GCC, apply corresponding setting from above (or `all` otherwise); + +** `gcc` or `clang` -- apply the set of options (regardless of detected + compiler) with default "difficulty" hard-coded in `configure` script, + to tweak as our codebase becomes cleaner; + +** `yes`/`auto` (also takes effect if `--enable-warnings` is requested + without an `=ARG` part) -- if current compiler is detected as CLANG + or GCC, apply corresponding setting with default "difficulty" from + above (or `all` otherwise). + +Note that for backwards-compatibility reasons and to help filter out +introduction of blatant errors, builds with compilers that claim GCC +compatibility can enable a few easy warning presets by default. This +can be avoided with an explicit argument to `--disable-warnings` (or +`--enable-warnings=no`). + +All levels of warnings pre-sets for GCC in particular do not enforce +the `-pedantic` mode for builds with C89/C90/ANSI standard revision +(as guesstimated by `CFLAGS` content), because nowadays it complains +more about the system and third-party library headers, than about NUT +codebase quality (and "our offenses" are mostly something not worth +fixing in this era, such as the use of `__func__` in debug commands). +If there still are practical use-cases that require builds of NUT on +pre-C99 compiler toolkits, pull requests are of course welcome -- but +the maintainer team does not intend to spend much time on that. + +Hopefully this warnings pre-set mechanism is extensible enough if we +would need to add more compilers and/or "difficulty levels" in the +future. + +Finally, note that such pre-set warnings can be mixed with options +passed through `CFLAGS` or `CXXFLAGS` values to your local `configure` +run, but it is up to your compiler how it interprets the resulting mix. Coding style ------------ This is how we do things: --------------------------------------------------------------------------------- +------------------------------------------------------------------------------- int open_subspace(char *ship, int privacy) { if (!privacy) @@ -141,22 +446,22 @@ int open_subspace(char *ship, int privacy) return secure_channel(ship); } --------------------------------------------------------------------------------- +------------------------------------------------------------------------------- The basic idea is that we try to group things into functions, and then find ways to drop out of them when we can't go any further. There's another way to program this involving a big else chunk and a bunch of braces, and it can be hard to follow. You can read this from top to bottom and have a pretty good idea of what's going on without having to -track too much { } nesting and indenting. +track too much `{ }` nesting and indenting. -We don't really care for pretentiousVariableNamingSchemes, but you can +We don't really care for `pretentiousVariableNamingSchemes`, but you can probably get away with it in your own driver that we will never have to touch. If your function or variable names start pushing important code off the right margin of the screen, expect them to meet the byte chainsaw sooner or later. -All types defined with typedef should end in "_t", because this is +All types defined with typedef should end in `_t`, because this is easier to read, and it enables tools (such as indent and emacs) to display the source code correctly. @@ -174,16 +479,41 @@ non-tab character has appeared on the line must be done by spaces in order for it to remain at the same alignment when someone views tabs at a different widths. -If you write something that uses spaces, you may get away with it in a -driver that's relatively secluded. However, if we have to work on that -code, expect it to get reformatted according to the above. +One common example for this is multi-line if condition: + +-------------------------------------------------------------------------------- + if (something && + something_else) { +-------------------------------------------------------------------------------- + +which may be written without mixing tabs and spaces to indent, as: + +-------------------------------------------------------------------------------- + if (something + && something_else + ) { +-------------------------------------------------------------------------------- + +Another example is tables of definitions that are better aligned with +(non-leading) spaces at least between names and values not too many +characters wide; it still helps to align the columns with spaces at +offsets divisible by 4 or 8 (consistently for the whole table): + +-------------------------------------------------------------------------------- +#define SHORT_MACRO 1 /* flag comment */ +#define SOMETHING_WITH_A_VERY_LONG_NAME 255 /* flag comment */ +-------------------------------------------------------------------------------- + +If you write something that uses leading spaces, you may get away with +it in a driver that's relatively secluded. However, if we have to work +on that code, expect it to get reformatted according to the above. Patches to existing code that don't conform to the coding style being used in that file will probably be dropped. If it's something we really need, it will be grudgingly reformatted before being included. When in doubt, have a look at Linus's take on this topic in the Linux -kernel - Documentation/CodingStyle. He's done a far better job of +kernel -- Documentation/CodingStyle. He's done a far better job of explaining this. Line breaks @@ -191,26 +521,52 @@ Line breaks It is better to have lines that are longer than 80 characters than to wrap lines in random places. This makes it easier to work with tools -such as "grep", and it also lets each developer choose their own +such as `grep`, and it also lets each developer choose their own window size and tab setting without being stuck to one particular choice. Of course, this does not mean that lines should be made unnecessarily long when there is a better alternative (see the note on -pretentiousVariableNamingSchemes above). Certainly there should not +`pretentiousVariableNamingSchemes` above). Certainly there should not be more than one statement per line. Please do not use --------------------------------------------------------------------------------- +------------------------------------------------------------------------------- if (condition) break; --------------------------------------------------------------------------------- +------------------------------------------------------------------------------- but use the following: --------------------------------------------------------------------------------- +------------------------------------------------------------------------------- if (condition) { break; } --------------------------------------------------------------------------------- +------------------------------------------------------------------------------- + +Un-used variables and function arguments +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Whenever a function needs to satisfy a particular API, it can end up +taking arguments that are not used in practice (think a too-trivial +signal handler). While some compilers offer the facility of decorations +like `__attribute__(unused)`, this proved not to be a portable solution. +Also the abilities of newer C++ standard revisions are of no help to +the vast range of existing systems that run NUT today and expect to be +able to do so tomorrow (hence the required C99+ support noted above). + +In NUT codebase we prefer to mark un-used variables explicitly in the +body of the function (or an `#ifdef` branch of its code) using the +`NUT_UNUSED_VARIABLE(varname)` as a routine call inside a function +body, referring to the macro defined in `common.h`. + +To display in a rough example: + +------------------------------------------------------------------------------- + static void signal_X_handler(int signal_X) { + NUT_UNUSED_VARIABLE(signal_X); + /* We have explicitly got nothing to do if we catch signal X */ + return; + } +------------------------------------------------------------------------------- Miscellaneous coding style tools -------------------------------- @@ -230,10 +586,10 @@ possible to set a tab stop to be 3 spaces, rather than the usual 8. (Note that in the saved file, one indentation level will still correspond to one tab stop; the difference is only how the file is rendered on screen). It is even possible to set this on a -per-directory basis, by putting something like this into your .emacs +per-directory basis, by putting something like this into your `.emacs` file: --------------------------------------------------------------------------------- +------------------------------------------------------------------------------- ;; NUT style (defun nut-c-mode () @@ -248,29 +604,64 @@ file: (setq auto-mode-alist (cons '(".*/nut/.*\\.[ch]$". nut-c-mode) auto-mode-alist)) --------------------------------------------------------------------------------- +------------------------------------------------------------------------------- Finishing touches ~~~~~~~~~~~~~~~~~ -We like code that uses const and static liberally. If you don't need to -expose a function or global variable to the outside world, static is +We like code that uses `const` and `static` liberally. If you don't need +to expose a function or global variable to the outside world, `static` is your friend. If nobody should edit the contents of some buffer that's -behind a pointer, const keeps them honest. +behind a pointer, `const` keeps them honest. -We always compile with -Wall, so things like const and static help you +We always compile with `-Wall`, so things like `const` and `static` help you find implementation flaws. Functions that attempt to modify a constant or access something outside their scope will throw a warning or even fail to compile in some cases. This is what we want. +Switch case fall-through +~~~~~~~~~~~~~~~~~~~~~~~~ + +While C standards allow to write `switch` statements to "fall through" +from handling one case into another, modern compilers frown upon that +practice and spew warnings which complicate detecting real bugs in the +code (and also looking back at some of the cases written decades ago, +it is not trivial to state whether the fall-through was intentional or +really is a bug). + +Compilers which detect such problem usually offer ways to decorate the +code with comments or attributes to keep it quiet it in cases where the +jump is intentional; also C++17 introduces special keywords for that in +the standard. NUT aiming to be portable and independent of compilers as +much as possible, prefers the arguably clearer and standards-based way +of using `goto` into the next intended operation, even though it is a +couple of lines away, e.g.: + + int uppercase = 0; + switch (char_opt) { + case 'U': + uppercase = 1; + goto fallthrough_case_u_option; + case 'u': + fallthrough_case_u_option: + process_u_option(uppercase); + break; + } + +In trivial cases, like falling through to `default` which just returns, +it may be clearer and more maintainable (adding other option cases in +the future) to just `return same_result` in the code block that would +fall through otherwise and avoid `goto` statements altogether. + Spaghetti ~~~~~~~~~ -If you use a goto, expect us to drop it when our head stops spinning. -It gives us flashbacks to the very old code we wrote. +If you use a `goto` that jumps over long distances (see "Switch case +fall-through" section above), expect us to drop it when our head stops +spinning. It gives us flashbacks to the very old code we wrote. We've tried to clean up our act, and you should make the effort -as well. +as well. We're not making a blanket statement about gotos, since everything probably has at least one good use. There are a few cases where a goto @@ -285,18 +676,18 @@ There are parts of the source tree that do not yet conform to these specs. Part of this is due to the fact that the coding style has been evolving slightly over the course of the project. Some of the code you see in these directories is 5 years old, and things have gotten cleaner -since then. Don't worry - it'll get cleaned up the next time something +since then. Don't worry -- it'll get cleaned up the next time something in the vicinity gets a visit. Memory leak checking ~~~~~~~~~~~~~~~~~~~~ We can't say enough good things about valgrind. If you do anything with -dynamic memory in your code, you need to use this. Just compile with -g -and start the program inside valgrind. Run it through the suspected -area and then exit cleanly. valgrind will tell you if you've done -anything dodgy like freeing regions twice, reading uninitialized memory, -or if you've leaked memory anywhere. +dynamic memory in your code, you need to use this. Just compile with +`gcc -g` and start the program inside `valgrind`. Run it through the +suspected area and then exit cleanly. valgrind will tell you if you've +done anything dodgy like freeing regions twice, reading uninitialized +memory, or if you've leaked memory anywhere. For more information, refer to the link:http://valgrind.kde.org[Valgrind] project. @@ -310,19 +701,24 @@ and many people have put a lot of time and energy to improve it. Submitting patches ------------------ -Small patches that arrive in unified format (diff -u) as plain text attachments -with no HTML and a brief summary at the top are the easiest to handle. +Current preference for suggesting changes is to open a pull request on +GitHub for the https://github.com/networkupstools/nut/ project. -If a patch is sent to the nut-upsdev mailing list, it stands a better chance of -being seen immediately. However, it is likely to be dropped if any issues -cannot be resolved quickly. If your code might not work for others, or if it is -a large change, your best bet is to submit a pull request or create an +For some cases, small patches that arrive by mailing list in unified +format (`diff -u`) as plain text attachments with no HTML and a brief +summary at the top are easy to handle, but sadly also easy to overlook. + +If a patch is sent to the nut-upsdev mailing list, it stands a better +chance of being seen immediately. However, it is likely to be dropped +if any issues cannot be resolved quickly. If your code might not work +for others, or if it is a large change, your best bet is to submit a +pull request or create an link:https://github.com/networkupstools/nut/issues[issue on GitHub]. -The issue tracker allows us to track the patches over a longer period of time, -and it is less likely that a patch will fall through the cracks. Posting a -reminder to the developers (via the nut-upsdev list) about a patch on GitHub is -fair game. +The issue tracker allows us to track the patches over a longer period +of time, and it is less likely that a patch will fall through the cracks. +Posting a reminder to the developers (via the nut-upsdev list) about a +patch on GitHub is fair game. Patch cohesion -------------- @@ -338,7 +734,7 @@ evaluated separately, assuming the core developers care enough to do that instead of just dropping it. If you have to make big changes in lots of places, send multiple -patches - one per item. +patches -- one per item. The finishing touches: manual pages and device entry in HCL ----------------------------------------------------------- @@ -353,39 +749,57 @@ skeletal man page that will probably miss many of the finer points of the driver and hardware. The same remark goes for device entries: if you add support for new models, -remember to also complete the hardware compatibility list, present -in data/driver.list.in. This will be used to generate both textual, static -HTML and dynamic searchable HTML for the website. +please remember to also complete the hardware compatibility list, present +in link:data/driver.list.in[]. This will be used to generate both textual, +static HTML and dynamic searchable HTML for the website. + +Finally, don't forget about fame and glory: if you added or substantially +updated a driver, your copyright belongs in the heading comment (along +with existing ones). For vendor backed (or sponsored) contributions we +welcome an entry in the link:docs/acknowledgements.txt[] file as well, +to track and know the industry players who help make NUT better and more +useful. + +It is nice to update the link:NEWS[] file for significant development +to be seen as part of next release, as well as to update the +link:UPGRADING[] file for potentially breaking changes and similar +heads-up notes for third-party teams (distribution packagers, clients +and bindings, etc.) Source code management ---------------------- -We currently use a Git repository hosted at GitHub (with a mirror at Alioth) to track -changes to the NUT source code. This allows you to clone the repository (or -fork, in GitHub parlance), make changes, and post them online for review prior -to integration. +We currently use a Git repository hosted at GitHub to track changes to +the NUT source code. This allows you to clone the repository (or fork, +in GitHub parlance), make changes, and post them online for peer review +prior to integration. -To obtain permission to commit directly to the master NUT repository, you must -be prepared to spend a fair amount of time contributing to the NUT codebase. -Most developers will be well served by committing to their own Git repository, -and having the NUT team merge their changes. +To obtain permission to commit directly to the common upstream NUT repository, +you must be prepared to spend a fair amount of time contributing to the +NUT codebase. Most developers will be well served by committing to their +own forked Git repository (preferably in a uniquely named branch for each +new contribution), and having the NUT team merge their changes using pull +requests. -Git offers a little more flexibility than the +svn update+ command. You may -fetch other developers' changes into your repository, but hold off on -actually combining them with your branch until you have compared the two -branches (for instance, with `gitk --all`). Git also allows you to accumulate -more than one commit worth of changes before pushing to another repository. -This allows development to continue without a constant network connection. +Git offers a little more flexibility than the +svn update+ command. +You may fetch other developers' changes into your repository, but hold +off on actually combining them with your branch until you have compared +the two branches (for instance, with `gitk --all`). Git also allows you +to accumulate more than one commit worth of changes before pushing to +another repository. This allows development to continue without a constant +network connection. -For a quick change to a file in the Git working copy, you can use `git diff` to -generate a patch to send to the nut-upsdev mailing list. If you have more -extensive changes, you can use `git format-patch` on a complete commit or -branch, and send the resulting series of patches to the list. +For a quick change to a file in the Git working copy, you can use +`git diff` to generate a patch to send to the nut-upsdev mailing list. +If you have more extensive changes, you can use `git format-patch` on +a complete commit or branch, and send the resulting series of patches +to the list. -If you use GitHub's web-based editor to make changes, it tends to create lots -of small commits, one per change per file. Unless there is reason to keep the -intermediate history, we will probably collapse the entire branch into one -commit with `git rebase -i` before merging. +If you use GitHub's web-based editor to make changes, it tends to create +lots of small commits, one per change per file. Unless there is reason to +keep the intermediate history, we will probably collapse (or "squash" in +Git parlance) the entire branch into one commit with a `git rebase -i` +before merging. The link:https://git.wiki.kernel.org/index.php/GitSvnCrashCourse[GitSvnCrashCourse] wiki page has some useful information for long-time users of Subversion. @@ -401,46 +815,38 @@ or git clone https://github.com/networkupstools/nut.git -if it is necessary to get around a pesky firewall that blocks the native Git -protocol. +if it is necessary to get around a pesky firewall that blocks the native +Git protocol. For a quicker checkout (when you don't need the entire repository history), you can limit the depth of the clone: git clone --depth 1 git://github.com/networkupstools/nut.git -In case the GitHub repository is temporarily unavailable for any reason, we -also plan to push to Alioth's -link:https://alioth.debian.org/scm/?group_id=30602[Git server] as well. You can -add a remote reference to your local repository: - - cd path/to/nut - git remote add -f alioth git://anonscm.debian.org/nut/nut.git - Mercurial (hg) access ~~~~~~~~~~~~~~~~~~~~~ -There are those who prefer the simplicity and self-consistency of the Mercurial -SCM client over the hodgepodge of unique commands which make up Git. Rather -than debate the merits of each system, we will gently guide you towards the -link:http://hg-git.github.com/[hg-git project] which would theoretically be a -transparent bridge between the central Git repository, and your local Mercurial -working copy. +There are those who prefer the simplicity and self-consistency of the +Mercurial SCM client over the hodgepodge of unique commands which make +up Git. Rather than debate the merits of each system, we will gently +guide you towards the link:http://hg-git.github.com/[hg-git project] +which would theoretically be a transparent bridge between the central +Git repository, and your local Mercurial working copy. -Other tools for hg/git interoperability are sure to exist. We would welcome any -feedback about this process on the nut-upsdev mailing list. +Other tools for hg/git interoperability are sure to exist. We would +welcome any feedback about this process on the nut-upsdev mailing list. Subversion (SVN) access ~~~~~~~~~~~~~~~~~~~~~~~ If you prefer to check out the NUT source code using an SVN client, GitHub has a link:https://github.com/blog/966-improved-subversion-client-support[SVN -interface to Git repositories] hosted on their servers. You can fork a copy of -the NUT repository and commit to your fork with SVN. +interface to Git repositories] hosted on their servers. You can fork a copy +of the NUT repository and commit to your fork with SVN. -Be aware that the examples in the GitHub blog post might result in a checkout -that includes all of the current branches, as well as the trunk. You are most -likely interested in a command line similar to the following: +Be aware that the examples in the GitHub blog post might result in a +checkout that includes all of the current branches, as well as the trunk. +You are most likely interested in a command line similar to the following: svn co https://github.com/networkupstools/nut/trunk nut-trunk-svn @@ -451,12 +857,13 @@ The NUT repository generally only holds files which are not generated from other files. This prevents spurious differences from being recorded in the repository history. -If you add a driver, it is recommended that you add the driver executable name -to the .gitignore file in that directory. Similarly, files generated from *.in -and *.am sources should be ignored as well. We try to include a number of -generated files in the tarball releases with `make dist` hooks in order to -minimize the number of dependencies for end users, but the assumption is that -a developer can install the packages needed to regenerate those files. +If you add a driver, it is recommended that you add the driver executable +name to the `.gitignore` file in that directory. Similarly, files generated +from `*.in` and `*.am` source templates should be ignored as well. +We try to include a number of generated files in the tarball releases with +`make dist` hooks in order to minimize the number of dependencies for end +users, but the assumption is that a developer can install the packages +needed to regenerate those files. Commit message formatting ------------------------- @@ -464,11 +871,11 @@ Commit message formatting From the `git commit` man page: [quote] -Though not required, it’s a good idea to begin the commit message with a single -short (less than 50 character) line summarizing the change, followed by a blank -line and then a more thorough description. The text up to the first blank line -in a commit message is treated as the commit title, and that title is used -throughout git. +Though not required, it's a good idea to begin the commit message with a +single short (less than 50 character) line summarizing the change, followed +by a blank line and then a more thorough description. The text up to the +first blank line in a commit message is treated as the commit title, and +that title is used throughout git. If your commit is just a change to one component, such as the HCL, upsd or a specific driver, prefix your commit message in a way that matches similar @@ -490,16 +897,24 @@ and should *not* be used as a guide for future commits. Repository etiquette and quality assurance ------------------------------------------ -Please keep the Git master branch in working condition at all times. The -master branch may be used to generate daily tarballs, and should not contain -broken code. If you need to commit incremental changes that leave the system -in a broken state, please do so in a separate branch and merge the changes -back into master once they are complete. +For developers who have commit access to the common upstream NUT repository: +Please keep the Git "master" branch in working condition at all times. +The "master" branch may be used to generate daily tarballs, it provides the +baseline for new contributions, and occasionally is tagged for a new release. +It should not contain broken code. If you need to commit incremental changes +that leave the system in a broken state, please do so in a separate branch +and merge the changes back into "master" once they are complete. + +To help keep the codebase ever-green, we run a number of CI tests and builds +in various conditions, including older compilers, different C/C++ standard +revisions, and an assortment of operating systems; a section below elaborates +on this in more detail. You are encouraged to use `git rebase -i` on your private Git branches to separate your changes into <<_patch_cohesion,logical changes>>. -From there, you can generate patches for the issue tracker, or the nut-upsdev list. +From there, you can generate patches for the issue tracker, or the nut-upsdev +mailing list. Note that once you rebase a branch, anyone else who has a copy of this branch will need to rebase on top of your rebased branch. Obviously, this hinders @@ -516,7 +931,7 @@ stash pop+ to apply your saved changes. Here is an example workflow: --------------------------------------------------------------------------------- +------------------------------------------------------------------------------ git clone -o central git://github.com/networkupstools/nut.git cd nut @@ -543,7 +958,7 @@ Here is an example workflow: # Publish your branch to your GitHub repository: git push username my-new-feature --------------------------------------------------------------------------------- +------------------------------------------------------------------------------ If you are new to Git, but are familiar with SVN, the link:http://git-scm.com/course/svn.html[following link] may be of use. @@ -552,12 +967,13 @@ link:http://git-scm.com/course/svn.html[following link] may be of use. Building the Code ----------------- -For a developer, the NUT build process starts with `./autogen.sh`. This script -generates the `./configure` script that end users typically invoke to build -NUT. If you are making a number of changes to the NUT source tree, configuring -with the `--enable-maintainer-mode` flag will ensure that after you change -`Makefile.am`, the `Makefile.in` and `Makefile` get regenerated. At a -minimum, you will need: +For a developer, the NUT build process starts with `./autogen.sh`. + +This script generates the `./configure` script that end users typically +invoke to build NUT. If you are making a number of changes to the NUT +source tree, configuring with the `--enable-maintainer-mode` flag will +ensure that after you change a `Makefile.am`, nearby `Makefile.in` and +`Makefile` get regenerated. At a minimum, you will need at least: * autoconf * automake @@ -565,32 +981,52 @@ minimum, you will need: * Python * Perl -After running `./autogen.sh`, you can pass your local configuration options to -`./configure` and run `make` from the top-level directory. To avoid the need -for root privileges when testing new NUT code, you may wish to use -`--prefix=$HOME/local/nut --with-statepath=/tmp`. You can also keep -compilation times down by only building the driver you are currently working -on: `--with-drivers=driver1,dummy-ups`. +[NOTE] +====== +See the link:config-prereqs.txt[] for better detailed package lists for +different operating systems. -Before pushing your commits upstream, please run +make distcheck-light+. This -checks that the Makefiles are not broken, that all the -relevant files are distributed, and that there are no compilation or -installation errors. Note that this requires all of the dependencies necessary -to build the documentation, including asciidoc, a2x, xsltproc, dblatex and any -additional XSL stylesheets. - -Running +make distcheck-light+ is especially important if you have added or -removed files, or updated configure.in or some Makefile.am. Remember: simply -adding a file to Git does not mean it will be distributed. To distribute a -file, you must update the corresponding Makefile.am. - -There is also +make distcheck+, which runs an even stricter set of -tests than +make distcheck-light+, but will not work unless you have all the -optional libraries and features installed. +See `ci_build.sh` for automating many practical scenarios, for easier +iterations. +====== Even if you do not use your distribution's packages of NUT, installing the distribution's list of build dependencies for NUT can reduce the amount of -trial-and-error when installing dependencies. For instance, in Debian, you can -run `apt-get build-dep nut` to install all of the auto* tools as well as any -development libraries and headers. +trial-and-error when installing dependencies. For instance, in Debian, you +can run `apt-get build-dep nut` to install all of the auto* tools as well +as any development libraries and headers. +After running `./autogen.sh`, you can pass your local configuration +options to `./configure` and run `make` from the top-level directory. +To avoid the need for root privileges when testing new NUT code, you +may wish to use `--prefix=$HOME/local/nut --with-statepath=/tmp`. +You can also keep compilation times down by only building the driver +which you are currently working on: `--with-drivers=driver1,dummy-ups`. + +Before pushing your commits upstream, please run `make distcheck-light`. +This checks that the Makefiles are not broken, that all the relevant files +are distributed, and that there are no compilation or installation errors. +Note that unless you specifically pass `--with-doc=skip` to `configure`, +this requires all of the dependencies necessary to build the documentation +to be locally installed on your system, including `asciidoc`, `a2x`, +`xsltproc`, `dblatex` and any additional XSL stylesheets. + +Running `make distcheck-light` is especially important if you have added or +removed files, or updated `configure.ac` or some `Makefile.am` file. +Remember: simply adding a file to Git does not mean it will be distributed. +To distribute a file, you must update the corresponding `Makefile.am` with +`EXTRA_DIST` entry and possibly other recipe handling. + +There is also `make distcheck`, which runs an even stricter set of +tests than `make distcheck-light`, but will not work unless you have all +of the optional third-party libraries and features installed. + +Finally note, that since 2017 the GitHub upstream project is monitored +by Travis CI (in addition to earlier multi-platform buildbots which +occasionally do not work), replaced since 2021 by a dedicated NUT CI farm. +This means that if your posted improvements are based on current NUT +"master" branch, the resulting pull request should get tested for a number of +scenarios automatically. If your code adds a substantial feature, consider +extending the `Jenkinsfile-dynamatrix` and/or `ci_build.sh` scripts in the +workspace root to add another `BUILD_TYPE` to the matrix of tests run in +parallel. diff --git a/docs/documentation.txt b/docs/documentation.txt index ab3bd2c..c588e12 100644 --- a/docs/documentation.txt +++ b/docs/documentation.txt @@ -13,6 +13,7 @@ ifdef::website[] - Cables information (link:cables.html[online]) (link:docs/cables.pdf[PDF]) - link:docs/man/index.html#User_man[User manual pages] - link:ddl/index.html#_supported_devices[Devices Dumps Library (DDL)]: Provides information on how devices are supported +- link:docs/solaris-usb.html[Notes on NUT monitoring of USB devices in Solaris and related operating systems] endif::website[] ifndef::website[] - link:../FAQ.html[FAQ - Frequently Asked Questions] @@ -20,6 +21,7 @@ ifndef::website[] - <> - link:../man/index.html#User_man[User manual pages] - link:http://www.networkupstools.org/ddl/index.html#_supported_devices[Devices Dumps Library (DDL)]: Provides information on how devices are supported +- link:../solaris-usb.html[Notes on NUT monitoring of USB devices in Solaris and related operating systems] endif::website[] Developer Documentation @@ -42,6 +44,36 @@ ifndef::website[] - link:http://www.networkupstools.org/ddl/index.html[Devices Dumps Library (DDL)]: Provides simulation data to the linkman:dummy-ups[8] driver endif::website[] +Data dumps for the DDL +---------------------- + +Note: both developers contributing a driver and users using an existing driver +for device not previously documented as supported by it, are welcome to report +new data for the Devices Dumps Library (DDL) mentioned above. Best of all such +"data dump" reports can be prepared by the +ifdef::website[] +link:https://raw.githubusercontent.com/networkupstools/nut/master/tools/nut-ddl-dump.sh[`tools/nut-ddl-dump.sh`] +endif::website[] +ifndef::website[] +`./tools/nut-ddl-dump.sh` +endif::website[] +script from the main NUT codebase, and reported on the NUT mailing list or +via link:https://github.com/networkupstools/nut/issues[NUT issues on GitHub] +or as a pull request against the +link:https://github.com/networkupstools/nut-ddl[NUT Devices Dumps Library] +following the naming and other rules described in the DDL documentation page. + +Data dumps collected by the tools above, or by `upsc` client, or by drivers +in exploratory data-dumping mode (with `-d 1` argument), can be compared by +ifdef::website[] +link:https://raw.githubusercontent.com/networkupstools/nut/master/tools/nut-dumpdiff.sh[`tools/nut-dumpdiff.sh`] +endif::website[] +ifndef::website[] +`./tools/nut-dumpdiff.sh` +endif::website[] +script from the main NUT codebase, which strips away lines with only numeric +values (aiming to minimize the risk of losing meaningful changes like counters). + Offsite Links ------------- @@ -59,10 +91,10 @@ These are general information about UPS, PDU, ATS, PSU and SCD: These are writeups by users of the software. - link:http://rogerprice.org/NUT.html[NUT Setup with openSUSE] '(Roger Price)' -- link:http://www.dimat.unina2.it/LCS/MonitoraggioUpsNutUbuntu10-eng.htm[Deploying NUT on an Ubuntu 10.04 cluster] '(Stefano Angelone)' +- link:http://www.dimat.unina2.it/LCS/MonitoraggioUpsNutUbuntu10-eng.htm[Deploying NUT on an Ubuntu 10.04 cluster] '(Stefano Angelone)' - link:http://blog.shadypixel.com/monitoring-a-ups-with-nut-on-debian-or-ubuntu-linux[Monitoring a UPS with nut on Debian or Ubuntu Linux] '(Avery Fay)' - link:http://linux.developpez.com/cours/upsusb/[Installation et gestion d'un UPS USB en réseau sous linux] '(Olivier Van Hoof, french)' -- link:http://trac.networkupstools.org/projects/nut/wiki/NutOnMacOSX[Network UPS Tools (NUT) on Mac OS X (10.4.10)] '(Andy Poush)' +- link:https://github.com/networkupstools/nut/wiki/NUT-on-Mac-OS-X[Network UPS Tools (NUT) on Mac OS X (10.4.10)] '(Andy Poush)' - link:http://www.llondel.org/ups.shtml[Interfacing a Contact-Closure UPS to Mac OS X and Linux] '(David Hough)' - link:http://fedoranews.org/contributors/kazutoshi_morioka/nut/[How to use UPS with nut on RedHat / Fedora Core] '(Kazutoshi Morioka)' - link:http://people.freebsd.org/~thierry/nut_FreeBSD_HowTo.txt[FreeBSD installation procedure] '(Thierry Thomas, from FreeBSD)' @@ -71,6 +103,11 @@ These are writeups by users of the software. - link:http://deschis.blogspot.com/2006/07/cum-se-configureaz-un-ups-apollo-seria.html[Cum se configurează un UPS Apollo seria 1000F pe Linux] '(deschis, Romanian)' - link:http://buffalo.nas-central.org/wiki/Install_a_UPS_%28nut%29[Install a UPS (nut) on a Buffalo NAS] '(various authors)' - link:http://blog.pointbre.com/2903/nutnetwork-ups-tool-korean-guidebook.html[NUT Korean GuideBook] '(PointBre)' +- link:https://www.jamesridgway.co.uk/monitoring-eaton-5sc-ups-scripts-and-integration-network-tools-home-assistant/amp/[USB UPS, notifications, and Home Assistant] '(James Ridgway)' + +Video articles are also available: + +- link:https://www.youtube.com/watch?v=vyBP7wpN72c[Network UPS Tools (NUT Server) Ultimate Guide] '(Techno Tim)' News articles and Press releases -------------------------------- diff --git a/docs/download.txt b/docs/download.txt index e43ce48..c6d2a63 100644 --- a/docs/download.txt +++ b/docs/download.txt @@ -10,7 +10,7 @@ Source code ================================================================================ You should always use PGP/GPG to verify the signatures before using any source code. -You can use the +You can use the ifdef::website[] link:docs/user-manual.chunked/ar01s09.html#verifySourceSig[following procedure] endif::website[] @@ -51,7 +51,7 @@ following script in the directory you just checked out: $ ./autogen.sh -Then refer to the +Then refer to the ifdef::website[] link:docs/user-manual.chunked/index.html[NUT user manual] endif::website[] @@ -59,7 +59,7 @@ ifndef::website[] linkdoc:user-manual[NUT user manual] endif::website[] for more information. - + ////////////////////////// NOTE: Users that need the latest developments to support new devices *must* use Git or <>. @@ -68,12 +68,10 @@ use Git or <>. Browse code ^^^^^^^^^^^ -You can also browse the code at -link:https://github.com/networkupstools/nut[GitHub], or at the -link:http://alioth.debian.org/scm/?group_id=30602[Alioth mirror]. The code was -originally kept in Subversion, and the old -link:http://trac.networkupstools.org/projects/nut[Trac site] will be kept -around for a bit so as not to break the URLs in the mailing list archives. +You can browse the "vanilla NUT" code at the +link:https://github.com/networkupstools/nut/[Main GitHub repository for NUT sources], +and some possibly modified copies as part of packaging recipe +sources of operating system distributions, as listed below. [[Snapshots]] Snapshots @@ -81,13 +79,23 @@ Snapshots GitHub has several download links for repository snapshots (for particular tags or branches), but you will need a number of tools such as autoconf, automake -and libtool to use these snapshots. +and libtool to use these snapshots to generate the `configure` script and some +other files. + +After you `configure` the source workspace, a `make dist-hash` recipe would +create the snapshot tarballs which do not require the auto* tools, and their +checksum files, such as those available on the NUT website and attached to +link:https://github.com/networkupstools/nut/releases[GitHub Releases page]. + +///////// +TODO: #1400 to replace this with a NUT CI farm service to publish the tarballs If our Buildbot instance is behaving, you can download a snapshot which does not require auto* tools from this link:http://buildbot.networkupstools.org/snapshots[builder]. Look for the latest *[tarball]* link towards the top of the page, and be sure to check the 'Build ##' link to verify the branch name. +///////// Older versions ~~~~~~~~~~~~~~ @@ -100,43 +108,70 @@ Binary packages NOTE: The only official releases from this project are source code. -NUT is already available in the following systems: +NUT is already available in the following operating systems (and +link:https://github.com/networkupstools/nut/wiki/Links-to-distribution-packaging-recipes-and-repository-sections[likely more]): -- Linux: -link:https://aur.archlinux.org/packages/network-ups-tools[Arch Linux], -link:http://packages.debian.org/nut[Debian], -link:http://packages.gentoo.org/package/sys-power/nut[Gentoo Linux], -Mandriva, -link:https://apps.fedoraproject.org/packages/nut[Red Hat / Fedora], -link:http://software.opensuse.org/package/nut[Novell Suse / openSUSE], -link:https://forum.openwrt.org/viewtopic.php?id=26269[OpenWrt], -link:http://packages.ubuntu.com/nut[Ubuntu], -link:https://github.com/voidlinux/xbps-packages/blob/master/srcpkgs/network-ups-tools/template[Void Linux]. +- link:https://repology.org/project/nut/versions[Repology report on NUT] + lists 745 entries about NUT, as of this writing + +- Linux: + + * link:https://github.com/42ity/nut/tree/FTY/obs[42ITy.org packaging recipes for Debian-based releases] + * link:https://salsa.debian.org/debian/nut/[Debian Salsa recipes] + and link:http://packages.debian.org/nut[Debian packages] + * link:http://packages.ubuntu.com/nut[Ubuntu packages] + * link:https://src.fedoraproject.org/rpms/nut/tree/rawhide[Fedora Rawhide recipes] + and link:https://src.fedoraproject.org/rpms/nut[Red Hat / Fedora packages] + * link:https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=network-ups-tools-git[Arch Linux recipe] + and link:https://aur.archlinux.org/packages/network-ups-tools-git[Arch Linux package info] + * link:https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-power/nut[Gentoo Linux recipe] + and link:http://packages.gentoo.org/package/sys-power/nut[Gentoo Linux package info] + * link:https://build.opensuse.org/package/show/openSUSE%3AFactory/nut[Novell SUSE / openSUSE official package base recipe] + and link:https://build.opensuse.org/package/show/hardware/nut[Novell SUSE / openSUSE official package development recipe], + and link:http://software.opensuse.org/package/nut[Novell SUSE / openSUSE official package overview] + * link:https://build.opensuse.org/search?search_text=nut[Numerous other recipes on Open Build System (not only by SUSE)] + * link:https://github.com/openwrt/packages/tree/master/net/nut[OpenWRT recipes] + * link:http://sotirov-bg.net/slackpack/search.cgi?q=nut[Slackware package overview] + * link:https://github.com/void-linux/void-packages/tree/master/srcpkgs/network-ups-tools[Void Linux recipes] - BSD systems: -link:http://www.FreeBSD.org/cgi/ports.cgi?query=^nut-&stype=name[FreeBSD], -link:http://pkgsrc.se/sysutils/ups-nut[NetBSD], -link:http://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/sysutils/nut/[OpenBSD], -link:http://doc.freenas.org/9.3/freenas_services.html#ups[FreeNAS]. + + * link:https://cgit.freebsd.org/ports/tree/sysutils/nut-devel[FreeBSD package recipe (devel)], + link:https://cgit.freebsd.org/ports/tree/sysutils/nut[FreeBSD package recipe] + and link:http://www.FreeBSD.org/cgi/ports.cgi?query=^nut-&stype=name[FreeBSD package overview] + * link:cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/sysutils/ups-nut/[NetBSD recipe] and link:http://pkgsrc.se/sysutils/ups-nut[NetBSD package overview] + * link:http://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/sysutils/nut/[OpenBSD recipe] + * link:https://github.com/freenas/iocage-ports/tree/master/sysutils/nut[FreeNAS iocage-ports recipe], + link:http://doc.freenas.org/9.3/freenas_services.html#ups[FreeNAS 9.3 docs on UPS integration] + and link:https://www.ixsystems.com/documentation/freenas/11.3-U5/services.html#ups[FreeNAS 11.3-U5 docs on UPS integration] - Mac OS X: -link:http://pdb.finkproject.org/pdb/package.php/nut[Fink], -link:http://trac.macports.org/browser/trunk/dports/sysutils/nut/Portfile[MacPorts] + + * link:https://github.com/fink/fink-distributions/blob/master/10.9-libcxx/stable/main/finkinfo/net/nut.info[Fink recipe] + and link:http://pdb.finkproject.org/pdb/package.php/nut[Fink package overview] + * link:http://trac.macports.org/browser/trunk/dports/sysutils/nut/Portfile[MacPorts recipe] + +- illumos/Solaris: + + * link:https://github.com/OpenIndiana/oi-userland/tree/oi/hipster/components/sysutils/nut[OpenIndiana oi-userland recipe] + and link:https://pkg.openindiana.org/hipster/en/search.shtml?token=nut&action=Search[OpenIndiana latest rolling builds] - Windows (complete port, Beta): -link:http://www.networkupstools.org/package/windows/NUT-Installer-2.6.5-6.msi[Windows MSI installer 2.6.5-6] + + * link:http://www.networkupstools.org/package/windows/NUT-Installer-2.6.5-6.msi[Windows MSI installer 2.6.5-6] Java packages ------------- -The jNut package has been split into its own link:https://github.com/networkupstools/jNut[GitHub repository]. +- The jNut package has been split into its own + link:https://github.com/networkupstools/jNut[GitHub repository]. - NUT Java support (client side, Beta) -link:http://www.networkupstools.org/package/java/jNut-0.2-SNAPSHOT.tar.gz[jNUT 0.2-SNAPSHOT] + link:http://www.networkupstools.org/package/java/jNut-0.2-SNAPSHOT.tar.gz[jNUT 0.2-SNAPSHOT] - NUT Java Web support (client side using REST, Beta) -link:http://www.networkupstools.org/package/java/jNutWebAPI-0.2-SNAPSHOT-src.tar.gz[jNutWebAPI 0.2-SNAPSHOT (sources)] + link:http://www.networkupstools.org/package/java/jNutWebAPI-0.2-SNAPSHOT-src.tar.gz[jNutWebAPI 0.2-SNAPSHOT (sources)] Virtualization packages ----------------------- @@ -144,7 +179,7 @@ Virtualization packages VMware ~~~~~~ -- NUT client 2.7.2 for ESXi 5.x (offsite, René Garcia) +- NUT client 2.7.4 for ESXi 5.0, 5.1, 5.5 and 6.0 (offsite, René Garcia) * link:http://rene.margar.fr/2012/05/client-nut-pour-esxi-5-0/[blog entry (French)] - * link:http://rene.margar.fr/downloads/NutClient-ESXi500-1.3.0.tar.gz[VIB package (v1.3.0)] + * link:http://rene.margar.fr/downloads/NutClient-ESXi500-1.4.0.tar.gz[VIB package (v1.4.0)] diff --git a/docs/features.txt b/docs/features.txt index eef38b6..631bdbc 100644 --- a/docs/features.txt +++ b/docs/features.txt @@ -19,7 +19,7 @@ Multiple manufacturer and device support ---------------------------------------- - Monitors many UPS, PDU, ATS, PSU and SCD models from more than 140 -manufacturers with a unified interface +manufacturers with a unified interface (link:stable-hcl.html[Hardware Compatibility List]). - Various communication types and many protocols are supported with the same @@ -31,11 +31,12 @@ common interface: Multiple architecture support ----------------------------- -- Cross-platform - different flavors of Unix can be managed together with a +- Cross-platform -- different flavors of Unix can be managed together with a common set of tools, even crossing architectures. -- This software has been reported to run on Linux distributions, the BSDs, Apple's -OS X, Solaris, IRIX, HP/UX, Tru64 Unix, and AIX. +- This software has been reported to run on Linux distributions, the BSDs, +Apple's OS X, commercial Solaris and open-source illumos distros, IRIX, +HP/UX, Tru64 Unix, and AIX. - Windows users may be able to build it directly with Cygwin. There is also a port of the client-side monitoring to Windows called WinNUT. @@ -60,8 +61,8 @@ WARNING: Be sure to plug your network's physical hardware (switches, hubs, routers, bridges, ...) into the UPS! -Redundancy support - Hot swap/high availability power supplies --------------------------------------------------------------- +Redundancy support -- Hot swap/high availability power supplies +--------------------------------------------------------------- - upsmon can handle high-end servers which receive power from multiple UPSes simultaneously. @@ -70,14 +71,18 @@ simultaneously. source UPSes becomes critical (on battery and low battery). - You can lose a UPS completely as long as you still have at least the minimum -number of sources available. The minimum value is configurable. +number of sources available. The minimum value is configurable. Security and access control --------------------------- - Manager functions are granted with per-user granularity. The admin can have -full powers, while the admin's helper can only do specific non-destructive tasks -such as a battery test. +full powers, while the admin's helper can only do specific non-destructive +tasks such as a battery test (beware that with a worn-out battery whose +replacement is a few years overdue, a "capacity/remaining runtime" test can +still be destructive by powering off the load abruptly -- and also such a +test can cause hosts to hide into graceful shutdowns when the battery state +does get critical as part of the test). - The drivers, server, and monitoring client (upsmon) can all run as separate user IDs if this is desired for privilege separation. @@ -91,8 +96,8 @@ shutdown command. In any other case, the privileged process exits. This was inspired by the auth mechanism in Solar Designer's excellent popa3d. - The drivers and network server may be run in a chroot jail for further -security benefits. This is supported directly since version 1.4 and beyond with -the 'chroot=' configuration directive. +security benefits. This is supported directly since version 1.4 and beyond +with the 'chroot=' configuration directive. - IP-based access control relies on the local firewall and link:http://en.wikipedia.org/wiki/TCP_Wrapper[TCP Wrapper]. @@ -106,9 +111,9 @@ Web-based monitoring - Comes stock with CGI-based web interface tools for UPS monitoring and management, including graphical status displays. -- Custom status web pages may be generated with the CGI programs, since they use -templates to create the pages. This allows you to have status pages which fit -the look and feel of the rest of your site. +- Custom status web pages may be generated with the CGI programs, since they +use templates to create the pages. This allows you to have status pages which +fit the look and feel of the rest of your site. Free software ------------- @@ -116,39 +121,48 @@ Free software - That's free beer and free speech. Licensed under the GNU General Public License version 2 or later. -- Know your systems - all source code is available for inspection, so there are -no mysteries or secrets in your critical monitoring tools. +- Know your systems -- all source code is available for inspection, so there are +no mysteries or secrets in your critical monitoring tools. UPS management and control -------------------------- -- Writable variables may be edited on higher end equipment for local customization +- Writable variables may be edited on higher end equipment for local +customization -- Status monitoring can generate notifications (email/pager/SMS/...) on alert conditions +- Status monitoring can generate notifications (email/pager/SMS/...) on alert +conditions -- Alert notices may be dampened to only trigger after a condition persists. This -avoids the usual pager meltdown when something happens and no delay is used. +- Alert notices may be dampened to only trigger after a condition persists. +This avoids the usual pager meltdown when something happens and no delay +is used. - Maintenance actions such as battery runtime calibration are available where supported by the UPS hardware. -- Power statistics can be logged in custom formats for later retrieval and analysis +- Power statistics can be logged in custom formats for later retrieval and +analysis -- All drivers are started and stopped with one common program. Starting one is -as easy as starting ten: 'upsdrvctl start'. +- All drivers are started and stopped with one common program. Starting one +is as easy as starting ten: `upsdrvctl start`. + +- For operating systems with a supported service management framework, you can +manage the NUT drivers wrapped into independent service instances using the +'upsdrvsvcctl' instead, and gain the benefits of automated restart as well as +possibility to define further dependencies between your OS components. - Shutdowns and other procedures may be tested without stressing actual UPS -hardware by simulating status values with the dummy-ups pseudo-driver. Anything -which can happen in a driver can be replicated with dummy-ups. +hardware by simulating status values with the dummy-ups pseudo-driver. +Anything that can happen in a driver can be replicated with dummy-ups. Monitoring diagrams ------------------- -These are the most common situations for monitoring UPS hardware. Other ways are -possible, but they are mostly variants on these four. +These are the most common situations for monitoring UPS hardware. Other ways +are possible, but they are mostly variations of these four. -NOTE: these examples show serial communications for simplicity, but USB or SNMP -or any other monitoring is also possible. +NOTE: these examples show serial communications for simplicity, but USB or +SNMP or any other monitoring is also possible. "Simple" configuration ~~~~~~~~~~~~~~~~~~~~~~ @@ -157,8 +171,8 @@ image:images/simple.png[] One UPS, one computer. This is also known as "Standalone" configuration. -This is the configuration that most users will use. You need at least a driver, -upsd, and upsmon running. +This is the configuration that most users will use. You need at least a +driver, `upsd`, and `upsmon` running. "Advanced" configuration ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -166,60 +180,77 @@ upsd, and upsmon running. image:images/advanced.png[] One UPS, multiple computers. Only one of them can actually talk to the UPS -directly. That's where the network comes in. The Master system runs the driver, -upsd, and upsmon in master mode. The Slave systems only run upsmon in slave mode. +directly. That's where the network comes in: -This is useful when you have a very large UPS that's capable of running multiple -systems simultaneously. There is no longer the need to buy a bunch of individual -UPSes or "sharing" hardware, since this software will handle the sharing for you. +- The Primary system runs the relevant driver, `upsd`, and `upsmon` in +"primary" mode. -//////////////////////////////////////////////////////////////////////////////// +- The Secondary systems only run `upsmon` in "secondary" mode which all +connect to `upsd` on Primary. + +This is useful when you have a very large UPS that's capable of running +multiple systems simultaneously. There is no longer the need to buy a bunch +of individual UPSes or "sharing" hardware, since this software will handle +the sharing for you. + +////////////////////////////////////////////////////////////////////////////// *FIXME* remainder === One UPS, many clients === -- Multiple systems may monitor a single UPS using only their network connections - no special "UPS sharing" hardware is required. +- Multiple systems may monitor a single UPS using only their network +connections -- no special "UPS sharing" hardware is required. -- "Slave and master" monitoring design synchronizes shutdowns so that slaves can bring down their operating systems cleanly before the master switches off the power. +- "Secondaries and a primary" monitoring design synchronizes shutdowns so that +secondary systems can bring down their operating systems cleanly before +the primary tells the UPS to switch off the power. === Many UPSes, many clients === -- Each upsd process can serve status data for multiple UPSes to many clients. +- Each `upsd` process can serve status data for multiple UPSes to many clients. +Multiple NUT drivers need to be configured and running locally on the system +with `upsd` then, and have appropriate media connections to the power devices. -- Each upsmon process can monitor multiple UPSes for status data. +- Each `upsmon` process can monitor multiple UPSes, possibly from multiple +`upsd` hosts, for status data. -//////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// "Big Box" configuration ~~~~~~~~~~~~~~~~~~~~~~~ image:images/bigbox.png[] -Some systems have multiple power supplies and cords. You typically find this on -high-end servers that allow hot-swap and other fun features. In this case, you -run multiple drivers (one per UPS), a single upsd, and a single upsmon (as -master for both UPS 1 and UPS 2) +Some systems have multiple power supplies and cords. You typically find +this on high-end servers that allow hot-swap and other fun features. +In this case, you run multiple drivers (one per UPS), a single `upsd`, +and a single `upsmon` (as a primary for both UPS 1 and UPS 2) -This software understands that some of these servers can also run with some of -the supplies gone. For this reason, every UPS is assigned a "power value" - the -quantity of power supplies that it feeds on a system. -The total available "power value" is compared to the minimum that is required -for that hardware. For example, if you have 3 power supplies and 3 UPSes, but -only 2 supplies must be running at any given moment, the minimum would be 2. -This means that you can safely lose any one UPS and the software will handle it -properly by remaining online. +This software understands that some of these servers can also run with +some of the supplies gone. For this reason, every UPS is assigned a +"power value" -- the quantity of power supplies that it feeds on this +system. + +The total available "power value" is compared to the minimum that is +required for that hardware. For example, if you have 3 power supplies +and 3 UPSes, but only 2 supplies must be running at any given moment, +the minimum would be 2. + +This means that you can safely lose any one UPS and the software will +handle it properly by remaining online and not causing a shut down. "Bizarre" configuration ~~~~~~~~~~~~~~~~~~~~~~~ image:images/bizarre.png[] -You can even have a UPS that has the serial port connected to a system that it's -not feeding. Sometimes a PC will be close to a UPS that needs to be monitored, -so it's drafted to supply a serial port for the purpose. This PC may in fact be -getting power from some other UPS. This is not a problem. +You can even have a UPS that has the serial port connected to a system that +it's not feeding. Sometimes a PC will be close to a UPS that needs to be +monitored, so it's drafted to supply a serial port for the purpose. +This PC may in fact be getting its own power from some other UPS. This is +not a problem for the set-up. -The first system ("mixed") is a Master for UPS 1, but is only monitoring UPS 2. -The other systems are Slaves of UPS 2. +The first system ("mixed") is a Primary for UPS 1, but is only monitoring +UPS 2. The other systems are Secondaries of UPS 2. Image credits ------------- diff --git a/docs/hid-subdrivers.txt b/docs/hid-subdrivers.txt index 42a7cab..edf2b84 100644 --- a/docs/hid-subdrivers.txt +++ b/docs/hid-subdrivers.txt @@ -9,9 +9,9 @@ different classes (audio, imaging, mass storage etc). Almost all UPS devices belong to the "HID" class, which means "Human Interface Device", and also includes things like keyboards and mice. What HID devices have in common is a particular (and very flexible) interface -for reading and writing information (such as x/y coordinates and -button states, in case of a mouse, or voltages and status information, -in case of a UPS). +for reading and writing information (such as X/Y coordinates and +button states, in the case of a mouse, or voltages and status information, +in the case of a UPS). The NUT "usbhid-ups" driver is a meta-driver that handles all HID UPS devices. It consists of a core driver that handles most of the work of @@ -20,13 +20,14 @@ specific UPS manufacturers (MGE, APC, and Belkin are currently supported). Adding support for a new HID UPS device is easy, because it requires only the creation of a new sub-driver. -There are a few USB UPS devices that are not HID devices. These +There are a few USB UPS devices that are not true HID devices. These devices typically implement some version of the manufacturer's serial protocol over USB (which is a really dumb idea, by the way). An -example is the Tripplite USB. Such devices are *not* supported by the -usbhid-ups driver, and are not covered in this document. If you need to -add support for such a device, read new-drivers.txt and see the -tripplite_usb driver for inspiration. +example is the original Tripplite USB interface (USB idProduct = 0001). Its HID +descriptor is only 52 bytes long (compared to several hundred bytes for a true +PDC HID UPS). Such devices are *not* supported by the usbhid-ups driver, and +are not covered in this document. If you need to add support for such a device, +read new-drivers.txt and see the "tripplite_usb" driver for inspiration. HID Usage Tree ~~~~~~~~~~~~~~ @@ -115,7 +116,7 @@ example Belkin defines `00860040` = ConfigVoltage (which is incidentally a violation of the USB PDC specification, as `00860040` is reserved for future use). -Thus, subdrivers generally need to provide: +Thus, subdrivers generally need to provide: - manufacturer-specific usage definitions, - a mapping of HID variables to NUT variables. @@ -126,26 +127,58 @@ shutdown.restart), and conversions of manufacturer specific data formats. +Usage macros in drivers/hidtypes.h +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The `drivers/hidtypes.h` header provides a number of macro names +for entries in the standard usage tables for Power Device +`USAGE_POW_` and Battery System `USAGE_BAT_` +data pages. + +If NUT codebase would ever need to refresh those macros, here is +some background information (based on NUT issue #1189 and PR #1290): + +These data were parsed from (a very slightly updated version of) +https://github.com/abend0c1/hidrdd/blob/master/rd.conf file, which +incorporates the complete USB-IF usage definitions for Power Device +and Battery System pages (among many others), so we didn't have to +extract the names and values from the USB-IF standards documents +(did check it all by eye though). + +The file was processed with the following chain of commands: + +------ +:; grep -e '^0084' -e '^0085' rd.conf \ + | sed 's/,.*$//;s/ *$//' \ + | sed 's/ /_/g;s/_/ /' \ + | tr '[:lower:]' '[:upper:]' \ + | sed 's/\(0085.... \)/\1USAGE_BAT_/;s/\(0084.... \)/\1USAGE_POW_/;s/\([A-Z_]*\)_PAGE/PAGE_\1/' \ + | awk '{print "#define "$2" 0x"$1}' +------ + + Writing a subdriver ~~~~~~~~~~~~~~~~~~~ In preparation for writing a subdriver for a device that is currently unsupported, run usbhid-ups with the following command line: - drivers/usbhid-ups -DD -u root -x explore -x vendorid=XXXX auto + drivers/usbhid-ups -DD -u root -x explore -x vendorid=XXXX -x port=auto -s ups -(substitute your device's 4-digit VendorID instead of "XXXX"). -This will produce a bunch of debugging information, including a number -of lines starting with "Path:" that describe the device's usage tree. -This information forms the initial basis for a new subdriver. +(substitute your device's 4-digit VendorID instead of "XXXX"). +This will produce a bunch of debugging information, including a number +of lines starting with "Path:" that describe the device's usage tree. +This information forms the initial basis for a new subdriver. -You should save this information to a file, e.g. - drivers/usbhid-ups -DD -u root -x explore -x vendorid=XXXX auto >& /tmp/info +You should save this information to a file, e.g.: + + drivers/usbhid-ups -DD -u root -x explore -x vendorid=XXXX \ + -x port=auto -s ups 2>&1 | tee /tmp/info You can create an initial "stub" subdriver for your device by using script scripts/subdriver/gen-usbhid-subdriver.sh. Note: this only creates -a "stub" and needs to be futher customized to be useful (see -CUSTOMIZATION below). +a "stub" and needs to be further customized to be useful (see +"Customization" below). Use the script as follows: @@ -160,14 +193,18 @@ and digits, and use natural capitalization such as "Belkin" (not information. You should put the generated files into the drivers/ subdirectory, and -update usbhid-ups.c by adding the appropriate #include line and by -updating the definition of subdriver_list in usbhid-ups.c. You must -also add the subdriver to USBHID_UPS_SUBDRIVERS in drivers/Makefile.am -and call "autoreconf" and/or "./configure" from the top level NUT directory. -You can then recompile usbhid-ups, and start experimenting with the new +update `usbhid-ups.c` by adding the appropriate `#include` line and by +updating the definition of `subdriver_list` in `usbhid-ups.c`. You must +also add the subdriver to USBHID_UPS_SUBDRIVERS in `drivers/Makefile.am` +and call `autoreconf` and/or `./configure` from the top-level NUT directory. +You can then recompile `usbhid-ups`, and start experimenting with the new subdriver. -CUSTOMIZATION: The initially generated subdriver code is only a stub, + +Customization +~~~~~~~~~~~~~ + +The initially generated subdriver code is only a stub, and will not implement any useful functionality (in particular, it will be unable to shut down the UPS). In the beginning, it simply attempts to monitor some UPS variables. To make this driver useful, @@ -175,7 +212,7 @@ you must examine the NUT variables of the form "unmapped.*" in the hid_info_t data structure, and map them to actual NUT variables and instant commands. There are currently no step-by-step instructions for how to do this. Please look at the files to see how the currently implemented -subdrivers are written.: +subdrivers are written: - apc-hid.c/h - belkin-hid.c/h @@ -188,10 +225,29 @@ subdrivers are written.: - tripplite-hid.c/h +Fixing report descriptors +~~~~~~~~~~~~~~~~~~~~~~~~~ + +It is a fact of life that fellow developers make mistakes, and firmware +authors do too. In some cases there are inconsistencies about bytes seen +on the wire vs. their logical values, such value range and signedness if +interpreting them according to standard. + +NUT drivers now include a way to detect and fix up known issues in such +flawed USB report descriptors, side-stepping the standard similarly where +deemed needed. A pointer to such hook method is part of the `subdriver_t` +structure detailing each `usbhid-ups` subdriver nuances, defaulting to +a `fix_report_desc()` trivial implementation. + +For some practical examples, see e.g. `apc_fix_report_desc()` method in the +`drivers/apc-hid.c` file, and `cps_fix_report_desc()` in `drivers/cps-hid.c` +file. + + Shutting down the UPS ~~~~~~~~~~~~~~~~~~~~~ -It is desireable to support shutting down the UPS. Usually (for +It is desirable to support shutting down the UPS. Usually (for devices that follow the HID Power Device Class specification), this requires sending the UPS two commands. One for shutting down the UPS (with an 'offdelay') and one for restarting it (with an 'ondelay'), diff --git a/docs/history.txt b/docs/history.txt index e31c933..4db0a35 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -8,7 +8,7 @@ This page is an attempt to document how everything came together. The Network UPS Tools team would like to warmly thank Russell Kroll. Russell initially started this project, maintaining and improving it for -over 8 years (1996 - mid 2005). +over 8 years (1996 -- mid 2005). Prototypes and experiments -------------------------- @@ -144,49 +144,75 @@ September 1999: new name, new URL Several visitors to the web page and subscribers to the mailing lists provided suggestions to rename the project. The old name no longer accurately described -it, and it was perilously close to APC's "Smart-UPS" trademark. Rather than risk -problems in the future, the name was changed. Kern Sibbald provided the winner: -Network UPS Tools, which captures the essence of the project and makes for great -short tarball filenames: nut-x.y.z.tar.gz. +it, and it was perilously close to APC's "Smart-UPS" trademark. Rather than +risk problems in the future, the name was changed. Kern Sibbald provided the +winner: Network UPS Tools, which captures the essence of the project and makes +for great short tarball filenames: nut-x.y.z.tar.gz. -The new name was first applied to 0.42.0, released October 31, 1999. This is -also when the web pages moved from the old `http://www.exploits.org/~rkroll/smartupstools/` -URL to the replacement at `http://www.exploits.org/nut/` to coincide with the -name change. +The new name was first applied to 0.42.0, released October 31, 1999. +This is also when the web pages moved from the old +`http://www.exploits.org/~rkroll/smartupstools/` URL to the replacement +at `http://www.exploits.org/nut/` to coincide with the name change. More drivers were written and the hardware support continued to grow. upsmon -picked up the concepts of "master" and "slave", and could now handle -environments where multiple systems get power from a single UPS. Manager mode -was added to allow changing the value of read/write variables in certain UPS -models. +picked up the concepts of what is now known as "primary" and "secondary", +and could now handle environments where multiple systems get power from a +single UPS. + +Manager mode was added to allow changing the value of read/write variables +in certain UPS models. June 2001: common driver core ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Up to this point, all of the drivers compiled into freestanding programs, each providing their own implementation of main(). This meant they all had to check -the incoming arguments and act uniformly. Unfortunately, not all of the programs -behaved the same way, and it was hard to document and use consistently. It also -meant that startup scripts had to be edited depending on what kind of hardware -was attached. +the incoming arguments and act uniformly. Unfortunately, not all of the +programs behaved the same way, and it was hard to document and use consistently. +It also meant that startup scripts had to be edited depending on what kind of +hardware was attached. -Starting in 0.45.0, released June 11, 2001, there was a new common core for all drivers called main.c. It provided the main function and called back to the upsdrv_* functions provided by the hardware-specific part of the drivers. This allowed driver authors to focus on the UPS hardware without worrying about the housekeeping stuff that needs to happen. +Starting in 0.45.0, released June 11, 2001, there was a new common core for +all drivers called `main.c`. It provided the main function and called back to +the `upsdrv_*` functions provided by the hardware-specific part of the drivers. +This allowed driver authors to focus on the UPS hardware without worrying about +the housekeeping stuff that needs to happen. -This new design provided an obvious way to configure drivers from one file, and ups.conf was born. This eventually spawned upsdrvctl, and now all drivers based on this common core could be started or stopped with one command. Startup scripts now could contain "upsdrvctl start", and it didn't matter what kind of hardware or how many UPSes you had on one system. +This new design provided an obvious way to configure drivers from one file, and +so `ups.conf` was born. This eventually spawned upsdrvctl, and now all drivers +based on this common core could be started or stopped with one command. Startup +scripts now could contain "upsdrvctl start", and it didn't matter what kind of +hardware or how many UPSes you had on one system. -Interestingly, at the end of this month, Arnaud Quette entered the UPS world, as a subcontractor of the now defunct MGE UPS SYSTEMS. -This marks the start of a future successful collaboration. +Interestingly, at the end of this month, Arnaud Quette entered the UPS world, +as a subcontractor of the now defunct MGE UPS SYSTEMS. This marked the start of +a future successful collaboration. May 2002: casting off old drivers, IANA port, towards 1.0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -During the 0.45.x series, both the old standalone drivers and the ones which had been converted to the common core were released together. Before the release of 0.50.0 on May 24, 2002, all of the old drivers were removed. While this shrank the list of supported hardware, it set the precedent for removing code which isn't receiving regular maintenance. The assumption is that the code will be brought back up to date by someone if they actually need it. Otherwise, it's just dead weight in the tree. +During the 0.45.x series, both the old standalone drivers and the ones which +had been converted to the common core were released together. Before the +release of 0.50.0 on May 24, 2002, all of the old drivers were removed. +While this shrank the list of supported hardware, it set the precedent for +removing code which isn't receiving regular maintenance. The assumption is +that the code will be brought back up to date by someone if they actually +need it. Otherwise, it's just dead weight in the tree. -This change meant that all drivers could be controlled with upsdrvctl and ups.conf, allowing the documentation to be greatly simplified. There was no longer any reason to say "do this, unless you have this driver, then do this". +This change meant that all remaining drivers could be controlled with the +`upsdrvctl` and `ups.conf`, allowing the documentation to be greatly +simplified. There was no longer any reason to say "do this, unless you +have this driver, then do this". -IANA granted an official port number to the project, and the network code switched to port 3493. It had previously been on 3305 which is assigned to odette-ftp. 3305 was probably picked in 1997 because it was the fifth project to spawn from some common UDP server code. +IANA granted an official port number to the project, and the network code +switched to port 3493. It had previously been on 3305 which is assigned to +`odette-ftp`. 3305 was probably picked in 1997 because it was the fifth +project to spawn from some common UDP server code. -After 0.50.1, the 0.99 tree was created to provide a tree which would receive nothing but bug fixes in preparation for the release of 1.0. As it turned out, very few things required fixing, and there were only three releases in this tree. +After 0.50.1, the 0.99 tree was created to provide a tree which would receive +nothing but bug fixes in preparation for the release of 1.0. As it turned out, +very few things required fixing, and there were only three releases in this +tree. Leaving 0.x territory --------------------- @@ -194,51 +220,119 @@ Leaving 0.x territory August 2002: first stable tree: NUT 1.0.0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -After nearly 5 years of having a 0.x version number, 1.0.0 was released on August 19, 2002. This milestone meant that all of the base features that you would expect to find were intact: good hardware support, a network server with security controls, and system shutdowns that worked. +After nearly 5 years of having a 0.x version number, 1.0.0 was released on +August 19, 2002. This milestone meant that all of the base features that +you would expect to find were intact: good hardware support, a network +server with security controls, and system shutdowns that worked. -The design was showing signs of wear from the rapid expansion, but this was intentionally ignored for the moment. The focus was on getting a good version out that would provide a reasonable base while the design issues could be addressed in the future, and I'm confident that we succeeded. +The design was showing signs of wear from the rapid expansion, but this was +intentionally ignored for the moment. The focus was on getting a good version +out that would provide a reasonable base while the design issues could be +addressed in the future, and I'm confident that we succeeded. November 2002: second stable tree: NUT 1.2.0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -One day after the release of 1.0.0, 1.1.0 started the new development tree. During that development cycle, the CGI programs were rewritten to use templates instead of hard-coded HTML, thus bringing back the flexibility of the original unreleased prototype from 5 years before. multimon was removed from the tree, as the new upsstats could do both jobs by loading different templates. +One day after the release of 1.0.0, 1.1.0 started the new development tree. +During that development cycle, the CGI programs were rewritten to use template +files instead of hard-coded HTML, thus bringing back the flexibility of the +original unreleased prototype from 5 years before. The `multimon` was removed +from the tree, as the new `upsstats` could do both jobs by loading different +templates. -A new client library called upsclient was created, and it replaced upsfetch. This new library only supported TCP connections, and used an opaque context struct to keep state for each connection. As a result, client programs could now do things that used multiple connections without any conflicts. This was done primarily to allow OpenSSL support, but there were other benefits from the redesign. +A new client library called upsclient was created, and it replaced upsfetch. +This new library only supported TCP connections, and used an opaque context +struct to keep state for each connection. As a result, client programs could +now do things that used multiple connections without any conflicts. This was +done primarily to allow OpenSSL support, but there were other benefits from +the redesign. -upsd and the clients could now use OpenSSL for basic authentication and encryption, but this was not included by default. This was provided as a bonus feature for those users who cared to read about it and enable the option, as the initial setup was complex. +upsd and the clients could now use OpenSSL for basic authentication and +encryption, but this was not included by default. This was provided as +a bonus feature for those users who cared to read about it and enable +the option, as the initial setup was complex. -After the 1.1 tree was frozen and deemed complete, it became the second stable tree with the release of 1.2.0 on November 5, 2002. +After the 1.1 tree was frozen and deemed complete, it became the second +stable tree with the release of 1.2.0 on November 5, 2002. April 2003: new naming scheme, better driver glue, and an overhauled protocol ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Following an extended period with no development tree, 1.3.0 got things moving again on April 13, 2003. The focus of this tree was to rewrite the driver-server communication layer and replace the static naming scheme for variables and commands. +Following an extended period with no development tree, 1.3.0 got things +moving again on April 13, 2003. The focus of this tree was to rewrite +the driver-server communication layer and replace the static naming +scheme for variables and commands. -Up to this point, all variables had names like STATUS, UTILITY, and OUTVOLT. They had been created as drivers were added to the tree, and there was little consistency. For example, it probably should have been INVOLT and OUTVOLT, but there was no OUTVOLT originally, so UTILITY was all we had. This same pattern repeated with ACFREQ - is it incoming or outgoing? - and many more. +Up to this point, all variables had names like STATUS, UTILITY, and OUTVOLT. +They had been created as drivers were added to the tree, and there was little +consistency. For example, it probably should have been INVOLT and OUTVOLT, +but there was no OUTVOLT originally, so UTILITY was all we had. This same +pattern repeated with ACFREQ -- is it incoming or outgoing? -- and many more. -To solve this problem, all variables and commands were renamed to a hierarchical scheme that had obvious grouping. STATUS became ups.status. UTILITY turned into input.voltage, and OUTVOLT is output.voltage. ACFREQ is input.frequency, and the new output.frequency is also now supported. Every other variable or command was renamed in this fashion. +To solve this problem, all variables and commands were renamed to a +hierarchical scheme that had obvious grouping. STATUS became ups.status. +UTILITY turned into input.voltage, and OUTVOLT is output.voltage. +ACFREQ is input.frequency, and the new output.frequency is also now +supported. Every other variable or command was renamed in this fashion. -These variables had been shared between the drivers and upsd as values. That is, for each name like STATUS, there was a #define somewhere in the tree with an INFO_ prefix that gave it a number. INFO_STATUS was 0x0006, INFO_UTILITY was 0x0004, and so on, with each name having a matching number. This number was stored in an int within a structure which was part of the array that was either written to disk or shared memory. +These variables had been shared between the drivers and upsd as values. +That is, for each name like STATUS, there was a #define somewhere in the +tree with an INFO_ prefix that gave it a number. INFO_STATUS was 0x0006, +INFO_UTILITY was 0x0004, and so on, with each name having a matching number. +This number was stored in an int within a structure which was part of the +array that was either written to disk or shared memory. -That structure had several restrictions on expansion and was dropped as the data sharing method between the drivers and the server. It was replaced by a new system of text-based messages over Unix domain sockets. Drivers now accepted a short list of commands from upsd, and would push out updates asynchronously. upsd no longer had to poll the state files or shared memory. It could just select all of the driver and client fds and act on events. +That structure had several restrictions on expansion and was dropped as the +data sharing method between the drivers and the server. It was replaced by +a new system of text-based messages over Unix domain sockets. Drivers now +accepted a short list of commands from upsd, and would push out updates +asynchronously. upsd no longer had to poll the state files or shared memory. +It could just select all of the driver and client fds and act on events. -At the same time, the network protocol on port 3493 was overhauled to take advantage of the new naming scheme. The existing "REQ STATUS@su700", "ANS STATUS@su700 OL" scheme was showing signs of age, and it really only supported the UPS name (@su700) as an afterthought. The new protocol would now use commands like GET and LIST, leading to exchanges like "GET VAR su700 ups.status" and "VAR su700 ups.status OL". The responses contain enough data to stand alone, so clients can now handle them asynchronously. +At the same time, the network protocol on port 3493 was overhauled to take +advantage of the new naming scheme. The existing "REQ STATUS@su700", +"ANS STATUS@su700 OL" scheme was showing signs of age, and it really +only supported the UPS name (@su700) as an afterthought. The new protocol +would now use commands like GET and LIST, leading to exchanges like +"GET VAR su700 ups.status" and "VAR su700 ups.status OL". These responses +contain enough data to stand alone, so clients can now handle them +asynchronously. July 2003: third stable tree: NUT 1.4.0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -On July 25, 2003, 1.4.0 was released. It contained support for both the old "REQ" style protocol (with names like STATUS), and the new "GET" style protocol (with names like ups.status). This tree is provided to bridge the gap between all of the old releases and the upcoming 2.0. +On July 25, 2003, 1.4.0 was released. It contained support for both the +old "REQ" style protocol (with names like STATUS), and the new "GET" style +protocol (with names like ups.status). This tree is provided to bridge the +gap between all of the old releases and the upcoming 2.0. -2.0 will be released without support for the old REQ/STATUS protocol. The hope is that client authors and those who have implemented their own monitoring software will use the 1.4 cycle to change to the new protocol. The 1.4 releases contain a lot of compatibility code to make sure both work at the same time. +2.0 will be released without support for the old REQ/STATUS protocol. +The hope is that client authors and those who have implemented their own +monitoring software will use the 1.4 cycle to change to the new protocol. +The 1.4 releases contain a lot of compatibility code to make sure both +work at the same time. July 2003: pushing towards 2.0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -1.5.0 forked from 1.4.0 and was released on July 29, 2003. The first changes were to throw out anything which was providing compatibility with the older versions of the software. This means that 1.5 and the eventual 2.0 will not talk to anything older than 1.4. +1.5.0 forked from 1.4.0 and was released on July 29, 2003. The first changes +were to throw out anything which was providing compatibility with the older +versions of the software. This means that 1.5 and the eventual 2.0 will not +talk to anything older than 1.4. -This tree continues to evolve with new serial routines for the drivers which are intended to replace the aging upscommon code which dates back to the early 0.x releases. The original routines would call alarm and read in a tight loop while fetching characters. The new functions are much cleaner, and wait for data with select. This makes for much cleaner code and easier strace/ktrace logs, since the number of syscalls has been greatly reduced. +This tree continues to evolve with new serial routines for the drivers which +are intended to replace the aging upscommon code which dates back to the early +0.x releases. The original routines would call alarm and read in a tight loop +while fetching characters. The new functions are much cleaner, and wait for +data with select. This makes for much cleaner code and easier strace/ktrace +logs, since the number of syscalls has been greatly reduced. -There has also been a push to make sure the data from the UPS is well-formed and is actually usable before sending updates out to upsd. This started during 1.3 as drivers were adapted to use the dstate functions and the new variable/command names. Some drivers which were not converted to the new naming scheme or didn't do sanity checks on the incoming UPS data from the serial port were dropped from the tree. +There has also been a push to make sure the data from the UPS is well-formed +and is actually usable before sending updates out to upsd. This started +during 1.3 as drivers were adapted to use the dstate functions and the +new variable/command names. Some drivers which were not converted to the +new naming scheme or didn't do sanity checks on the incoming UPS data from +the serial port were dropped from the tree. This tree was released as 2.0.0. @@ -248,11 +342,23 @@ networkupstools.org November 2003: a new URL ~~~~~~~~~~~~~~~~~~~~~~~~ -The bandwidth demands of a project like this have slowly been forcing me to offload certain parts to other servers. The download links have pointed offsite for many months, and other large things like certain UPS protocols have followed. As the traffic grows, it's clear that having the project attached to exploits.org is not going to work. +The bandwidth demands of a project like this have slowly been forcing me to +offload certain parts to other servers. The download links have pointed +offsite for many months, and other large things like certain UPS protocols +have followed. As the traffic grows, it's clear that having the project +attached to exploits.org is not going to work. -The solution was to register a new domain and set up mirrors. There are two initial web servers, with more on the way. The main project URL has changed from `http://www.exploits.org/nut/` to http://www.networkupstools.org. The actual content is hosted on various mirrors which are updated regularly with rsync, so the days of dribbling bits through my DSL should be over. +The solution was to register a new domain and set up mirrors. There are two +initial web servers, with more on the way. The main project URL has changed +from `http://www.exploits.org/nut/` to http://www.networkupstools.org. +The actual content is hosted on various mirrors which are updated regularly +with rsync, so the days of dribbling bits through my DSL should be over. -This is also when all of the web pages were redesigned to have a simpler look with fewer links on the left side. The old web pages used to have 30 or more links on the top page, and most of them vanished when you dropped down one level. The links are now constant on the entire site, and the old links now live in their own groups in separate directories. +This is also when all of the web pages were redesigned to have a simpler +look with fewer links on the left side. The old web pages used to have 30 +or more links on the top page, and most of them vanished when you dropped +down one level. The links are now constant on the entire site, and the old +links now live in their own groups in separate directories. Second major version -------------------- @@ -279,7 +385,7 @@ At that time, the development process was still centralized. There was no revision control system (like the current Subversion repository), nor trackers to interact with NUT development. Russell was receiving all the patches and requests, and doing all the work on -his own, including releases. +his own, including releases. Russell was more and more thinking about giving the project leadership to Arnaud Quette, which finally happened with the 2.0.1 release in February 2005. @@ -287,10 +393,11 @@ Arnaud Quette, which finally happened with the 2.0.1 release in February 2005. This marked a new era for NUT... First, Arnaud aimed at opening up the development by creating a project on the -http://www.debian.org/[Debian] http://alioth.debian.org/projects/nut/[Alioth Forge]. +http://www.debian.org/[Debian] +http://alioth.debian.org/projects/nut/[Alioth Forge]. This allowed to build the team of hackers that Russell dreamed about. It also allows to ensure NUT's continuation, whatever happens to -the leader. And that would most of all boost the projects contributions. +the leader. And that would most of all boost the projects contributions. //////////////////////////////////////////////////////////////////////// diff --git a/docs/images/advanced.png b/docs/images/advanced.png index 8f1df804eaabab8db0b23ffde371a40b66673fcc..a8291af04af051c9e5727d7c318096f37e44a7fc 100644 GIT binary patch literal 49233 zcmV*fKv2JlP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGh)&Kwv)&Y=jd7J|FeBVB!hgMBt=KX`t#v$LZ;Y3JMbX5P$L5{ZQL78Z-;Sg7yensfBy zZ$pj8@vo4+8R@~02&5VESLAO-{wSpX02v5*4RR~;8=y^?Fk#|j!K&-tVkqP^EvYaW zGFMB=iI6yC31lMVIS6qd!~wY-@xzS3u^1w7vxr^B{dPfBl1cO0;OKVH}48aHS&V0& ze_>-d92%<#h8a51>_$Gux!ua7=c(M}IYakcCK3vZFA$J`F41UIk(ixiX19x-l98si z*;z)ix7BLX z$)<~R)Kf&QCDQbs$|TRFme_SA?aG^?LREb?Y|- zckJ9b{3~aF$(-$R2*D(-EXFg>Eqt%j>pj9C56LT(X>(5mQP59{N+1-HAgrGNERRqq z2nz(F`lv#%j^gmC;&7^^TcWv0`~Oh2EIuG&=< z-&s|4#F?irSf+hzCJqH8iRu(-H5dg`gCwA&r_XgCz!>GSzpnwp#L z`tp~)_?WsG6MX^@*Bc$}ZFBhuDDv{;%k=rDsA0euezR^h3WKxKHH5!)nnqa?;9jpy z)?t+Es>8@L>f&>#NHY?aSR^Dd5NkXVlsL#0C)M-Ci>Wyp3Z4_%hBgZ{2oD@3P8+lp zf;>A;IFWWJ4Z%4V~1r$`Z`P}fRw z^YR9sa>~gQCrz5%gf`=EYHD%@{6XA>`0RE^JBYnKVYRkKL!nl*$(FV@Yx9K{e2Hk+adAm$@!&xN@m7L602jf6AGNi$MK*8VB0F~MP;XqmT}ehUycxSs z^9@V_OHFHf;J^VgbLLDr=ICR@<#OT~BjLrRqoYG=>S_}$%}vjpdBz!^)9=m10md`W zKEJrNwe74+cfTi-CruK+-zSee z@`(65wfJqT1$?K*51>eAbk=pv3rkD;Np4;)4ANMlqrH7CEZO7#@cXM9St1)@x$3H` zY_n${*-%_sQewedX%NUImAKeB%5)q*a(i2=bo%^|PJxRdUT>##csr2aF753dV#V7k zKQB-6^Yf*!pg{5=MTJFDSeP#*B_&b}NxBjwvlQZL>u85N5|;Y9+FL*Wxic@;@6W^m z#B&Q@c&?$o{&dwi&}1TZx6EGf1&s*Mg7!={U3ooQPu=K@@~Wd#=lndeysSPs9Lc{4BAC<`tAHEig3>-8_HgDP_JMrTFB%rI^+R`dB zX3UhYeC;dJP~RxeKKHEpd;?4yqIokohx-oV+Qzy%nSInzGIZE*X>4qeP%!kwjW_=7 zOZuf*2g}pXJbPbhS@}1#A>*Ej%c44Jwd38>&^%72q4jIoC}@495>-#cMGLL1tu?xJ z%a*|xUU0tI8G3;6?DH?&590bd-F>!^u+=U{e(wM9yJV0Q&ZSy028r}kE|okouT9h4 z)R82a9?I?M+N4goHV7R^ScMU^9z5f@ct&$!+~mPM)Y6)4>I}<<4we!*dBbCJn7v(@ zKP9ClQeWR7+qQ01=RPh%@K)%(l=tf=XMXPU5)MbCv7r%`S0}iM?SaIV+O0zJV%G}J z;XFrN<8X&ZjUEdRXrnkC&h2;Ib!XPjK(RWVuH!X=`S{?M?1cpu4slNPCqrIdzP+@x z^auLkJ_CP?IS;b;XlCnFFAy{m28N>DsI`gGbW+&Usr}yC`3$Y+tMjUyah)#R)|*~O zvTnVOq_44706^z`|&+a?$$BNtInV}!{8o2ID zkex_&LO%(ashv5vz5Y}p5At`&t?EdGi+bLmC3gqv{4v!2T6XHY5H4eNKw!m}__2Q# zAKo0>D!0qXQ6tqC-haRV88T$3y!ZYGdWnw*xSQ^1O(kB52?awlXegntt!f-B&B zf5-&=kjG_^5s)0nG(B$$WLPiH7en}&Mw$yJGCcv352=8tw;aG_ey-Azstn(PoWGd_ zj>ki0LR>tLEIw@WkS>7!3q*}*;n)V54oP+ZBh70IA;TcU_3YlkB8_Z7n#C2DNGOsd z0Jbx&;ir&=%F~W_v$~Syn3th-K@pXgW>u-YbZuB{X?3de89MD;%C&}0t3%hwGeCE8 zn=h=aERI~*pJ*Y$>gsA4IFKtccL6u3;(q!VXF~X) z*Wy9oDivRbsFhi9KYWX@XO&;_2M|sU{|1Ch@ca+*Ci32d<^qUZYI-{K-p+I6^C<|y z^g=Bu&qJPoa3zebC`-~i9P&2^?}cXiI>E6kUyK5y#dPBqah_Uwnc5XC*%~MUr)-+@D?tk5l0d$HYsk3*UhO zP*u|6;xwfFVR4b56ySzxeTuyAF7h%YEe|&y!F>gAf33ctL~Jfe*c>V>1V5f%tFTw# za#FOUQb#=h2qBs9*?kGZRX)~3Dj}~!XaF1!`6dO=%1CHFb6gmdb>c+o>Tmqr7 zaW;e=+#3*r3y5+h18I_{0salSkkJsX_5WK`$rWaacTx5f=qd<_vbSin zSgb*#6F3$NgS?Q&35@^@Qb^J2oPKPaPnP3%uWO@@q@-M%T1QG<+O@`c=IL4&bsl+I zIZD^HX*yX)iq@~`4(<4x=`I@J(idG8S40g~ePZaJ&A}`DR_bq18aJgKDVR{Is7h`5Fi8!EL8 z_4-i?@TF_*w9l{^!lj}I@BsQd5L!rV*pwQ4nS69=A%+WAujd6Jbt*^HqKL-pbx-G+ zZ;(d5t_{@ax(!02G(eK#kH|M0A0n;_%N9Y4i~RxB5Cg0~^9!Wg$a`WF<7e>LaH)Ix z%sm3GNQcd82^ukYd>DM4-n53UHGEC;+eph(qL=NCJfQg%rd?}DO1)iq>DMZ)&Zp>< z^Y~xWDo>Zx`jm8Ci^Fcw8I7wBdIM2>6Pn8wlkonsxO8n07wZp)I4?7#BoxwSCnyPO zx;+q*NgZ2c`-ktz;z#e7MUOuyxgB+etGF-3MQ`N$5WX-Ckfi8QFrW@uT_+FFErXB*)1RP2Z4qN2w@xV)8t)Sy|`L2rXyANv)bh`0(0@};=2NGdBU zrL(hB>g(!c!-kD=%+d6A`VVZDFy(X-_Q4rsNV24RsQS)y&<&l2 zJoeq)26+~B8X+Uye&*f)H>ks6u|?QGNnRX1^R~5WM1Vh8BZL&Pz%_~hQu9?_h8TIM zL(A*ZP?}E7PnP5Nr0YG_OPx`7%KaKT^WJ(w0DpTranV)OtJBkzrWAeZss z2qA@2mb9r$UDDrem40!rM5{JQ)zUYl=EHZyk%+)mRF1_yEyaUptP|Hi%peiSxzzD;g|(CXk@)nZpc^NuYR2^EHl&0mS*P-f8`K)B!d#pF* zT3ti+hzKmMFe}m#v)DA!qQw;sgSbAv#f9Hfi2=SG)cqs{cdPCbY255?c@Uo-T~F|O zcGjcLy{A|JcyItEu9Z-9O%VCpHL^BpfY<^AVHiG|g5wDy&b(*}sB(=LS9olo=vqnPN+uFp7 zXPl$%vyMDcJ@=g8tx6c>d8GZH%xjD~WMfsWw6wNM0`2Sg(Sv2xviD@r;K5hl`tO^Q zqt)4lPi%3S`1ImOKm0!XKBC&oL~|D-99cwzO$rK7gA4RLSOO|9MXPcd8e&|7|C4!1 zNvQ*GV?EEfHbtj>R)(l+wX~tTs{?AU;OL!!Xwu@+UaSO3h{6{#g)euCT1A5COr0XM zl5`$YZXy5Pw9a_k=x%wCP4RrOO_?jd`SB0rjz3=|xBubS@Wb>bYq2QHCRj?`TH44W2}=>s9!QGhl&1A_hE~=TU~|~j-_J0Muv#ui@04eU zJS7lNO9uu0K`HPzO8mn`^4C9JEm!^W7joq9ClEc{n zZQ=mqq}7lA=B>pq=khn_iXF~b3uNe#^QFJXD*14qG`EY>f?$cHYP9oImrZGw#rZwC zY(3VInxCola%puTzw5KQ%4F7stbIoRZSTsw?Jt1}0n~BCQAf(V@4Ty1k7j-CNh6_^ zP0{tWwbI_+CS%7>kZ}_xC{k2?XDFabY5%h@i!06lgCMdM%NZS`;qci<%F++slhLPm z?)OY-+@~2CpHgs8ivtMDuRV5gva|1yB(Ak>VR^2I@oy#$G>%{Qw7j*D1DqPR&HO)E zTEy@k5x30(0<%lM9GmoW+oTLqj^kpdRq`Cx45H|sSh^#io=9f*a;fB`Yu2rQ#vbd? z^~XWk_N6j^OV`Q`M;~*HeDFTUM({MNXSz!xp%G3`S|u$~U9}6u)h-h!O_q_PwOFh! z;!=h5@>+&E!v8JJ&9Z3&2h24be#8;76!$XzTXAvp-#TG=AEu5XivwtD4- zT|RlIE+A`K!?-3Y%|W=JAQrZLaEPYy53)3kJZd9f=?vFWi7J<(lR{@!*ZQ$mu1kMh z#PJg5ccEUc&;(!RySa$aySa$EPKsXE09{8C;%VW!=+%eEF%z2lAI98fKg&Z}m@&Q~YFb z!fMO0a}6x3z)%whG*=%*HpC)!${d)8bQrvt9yjG41!z@WjnN3J@NVsYsSbp`%6<|uC2 zyjjgtB;h%oE}1lC3S7r!GX9&1%NzrI*|7T%!-GzRa7TQCjD4&b4w2=!>+XA3JoDre z)A)8LTBn~bZw%%vkAn|`+-PXfHBiqRHAF2Y9>=qV`=)i3Naz!naqbgvmV&FHQcnMn zAx#>NnR~3PS+hocE^eaNS}8rfdDBMm;yFKj_7PHA-cLo#C(Ek@{z7Q}ozyn9DTqV1 z;5xrQpb?$jCgaA9msKFqAw!4e-*WT6x&pjD zDAtf)Yx#$OurDi&msv0p7eB-oj!7pcMML~yBQ9&NhxwN zv`$i~+PDV1)s<%d6-kyPxd#dO{Yo2Pz-pAgkrh65mf_lC7jt$D=SUL6P2$ROz}Tu~ zV=@}4C4d(>-s;&b39C~gYN=#Rz#jWVQcCM$Tw~Os_N3H_$q;RTVRtg~2hv9kc|E&U ztlW(|JAofVgGpRj4y)Z>O&7%=u6V$U$0OYW$u{9gYba&3mBg|yB-LG65)=Dul$cR#r;_1Q9~hFuoHK$=*mx z<@cbC5C}D31rs-wpn4RLSs;+U$SGY#E+S~LSa74+4U@PI4RFChE_Y)ra@c2ZI2}#g z0orJ!@y<38E}MdMwhDMd!qVkFlSuYPQpVJt-89QUXh9hx?dc??#cOq!$9+sw!Fo6d zVX<0qquC9UxDGxTqrx@ie+}WnZhwIE8SrLrcez{%MOqYJyI4bLFd6+m*(PC&D@j}& z-BU!=OOi?x{hS&N%pfi`3YsLV^gK0}F=N*(o7IlrD9SoM{%$m%5tzhvaKWXR88GBb zbi53OMx!mu+-HczV;wG+J8lF##=-${hRlAhs09`m+%kSA+)|983nUuC94mSqhW54jwp@`6rTyB;sw4<8@kuhg!{P+s1$T3hiy}?Jl<)2A6JeLEt!| z@$T+EWs}5gU42~92rMoY7`hjdN|Dsgd*vSDg}|UvLJNP`v-mSc6bYN18`Xli*aes6 zFp2BnflD>t{069?X!!x9E!NITOxE7p-B|s5G*bb zmm;M-kyIv;>DuVm(p<$1i%WMKGs!G76oOzM7hOeE*ysEI9cnO%>)?Q+hsQ~@K@whl zC#Npr;%+N_3N$RVhZN$9XZNTgB@XMC{Zjlsv~}luM^eJTNC>TFc@DKSN4)hBJjL1rnqqMsbmFolA}XFKnHX zR4L@tElEK#HASN>jd<9LsR*i@5k*4+84>da7{?XoOGR5;FRRgO;)+BfQdd_eJ9q7p zojZ5R_U${Qa{G4KwyjdOZrdhXwr-Wpo43fOO`B!orcG*_vi0jX$h!6GmF&WG-MvM! z5S%R9KjHsS62X+seY=Q@yZ3N66$%$k`x&Gha=-vfAZ(BpT_alz#MMo|Pc{j6`Z2x} zuH>L5KkG!)BT4l@Y+})x8K?VznNmn9!$s8H#(=+jUSi~Y6!(S~P4~=}McC`IHam9g zkdHq4NLpLl!1h{9i&~NfU!a!mIj`$j%frXXkRe0l3tu=(hC*lIvNqfW`vXaYEV0^a zEE4NlHr(3(ajg+n+IeV{O|v`amOt;-Z)G@6vt^ll=ZGL`cZbGxauwG z_u=CzJ#EHJIcdQHt>205f|>iExt`Wzk31}+Mvsy46DCLt+EN0~xfK=^3b2T#H6^=X z7;ydhyu4h=&o2;<$F15$S$Th1@!@jG%g=xAzI*TCo`_k6E8aMfOTms~x<}#y^~-5@L>?wSJj7P5qd>j4?OUItX#QDX3d(JLP8oLab$zrha2W@x~bbGw5Zsz znMqtEC(gtA+~>}eQ%^Z{H{y!>R>)Dqxa;?42nC-LDf_7;A~h1P<9@DiN%jVdOKbyv z1=1@P+4(h*DEE=w|9I%FQ{^|m>)M;dbK-YoO~G{iC_9l~_o4KAM=ftI<0np%^UgnC z^>Y!5m=gS-k?vj3bW-ygAvIwcf)omZw z)~#D*=~82JJ_%FJBu0B)EtlpL1GC26@Ht!sfIb3j2RaL`fY@ z*Wri}cE#0zHKMB;c$mCVnVBg;y&!AQI z!3Q7cM_q^~9Qa|l<$RyXhxk}-Q%xO^-l)ESwCnc33iw0AOUgzLuy4%23e(&Rt8xmHP6G{GeC73do?lZe2zEV1Zx=#6vd``Q#^-p?OO|TG1Jo)YVPs?p#G; z%H+xNjc!9#|~ z_b$3va`W<%&u^wX*sa!|{o2|ZdHuCl;VMqx*7?%Z(k{E^e@Fau58E0g*4iS8wi>ZD zSBa~oS{yN0cvdT{I~&@dU0g1=Oqn`e{QgeaxPF5a6c$~6-@SL=pl&XUuvb^HwUvfP z&mcK**gPJ^j{}LT$*9y?TIENOhxFc1-_W3^KGPse!|#)K#Oe-;)f0lmARzbMziUhW zi3VxC205UlML3;~8n>s*RZIkTpC|WOhXodm!`CG4j%x9A>=0LbwSI;cmu@-r*1|Hh zUY^T9E6^JOk+~dJ>Hp%tWXNl`%lLIK$jp|Na;(QECyp5`r_7%x3(h!GPB`f#Ir6Au zWYUzWGHiH-)Kpc;rVSglda`^MYoc4?A~Ed=Jg()S)U=i z2VqD98G?S?L57kFyy8i{2Ca{a)>E%Y zE0g4?b>gzYqv3!R+fQj}sf-;vL52<;F2$u~Vzt?&rKMSxE&V{=dgFC@|J`?G<%$nw z!@6~9YqR?Ly3}^b%~7)&-4fT{z%_%^W&*Udl!XPYTUhECX_eO-;>unqlQ$8qR|f{H z#s7ylGj|>o4m~Dcu?G^lxw#GQ9HZkGzpww$f1z6=0de{o#O>8Aq+CTvA4$=!ccgUF z3(|kZ{W9dOe<(822^4uaZswUu|b-fo74{1j1lAL`reEN z9VT(hFqm^|M-Xri;a`;-}by&lOSo z1aM#4b8|e&7Q^M6EeGkPV~hC2<*OG@XSL*bcSv6AX34K#DaE_qlCn+D%YYU4%Fx$u zkl`;~B|~5OgA87zSx5swNd4ZrLrRxEC`D@)N?zrA;%e9`Hm)rOoP6r3a_yh4mx+@n z$$bw$ET^4uhFtc`U&_e~7RdY)j+bfEXQ)1`j`j|z-qqzMvY&VUi6<%Y>WziPbH*{l zg9w9+NL-vk#N+hPAm=>3= zP4q34nY#mJ_dP#iM|3FO?!^VlV)PM<9lB@#S)8%GuR^efqE$p)=GI` zrwsINl0nTYWk~fKG7N-N@!@}D{=nX z`#Z}TWR*Hkk(<6Y7Y>orhqxri?UKVQ21rP{LNYRt4O{Q;5#5GETzTbH;`8}>42S4C z-g92pv6g2X^Q~iqL-Z>zm!JOhr=Rt3h)nz#@(+eVaLHzibBI{`Uxq9zcPAbX>GDvlbO-@Qo_*?asY5^)!c%N7@VJR){jV6<|qfp(G3Ruq7>*j_J*wkBm! z^))yOT3ie(9|9su!19m6;*Z%K&XB`l_uCx~FP`5QmP$!kIS8tVu3U%HVe51_T%C4@y#W@? z#)6{4rMbDen?j*bbxlpp&P#v%!(RKik3ade6VKxh@jRXfi)jLMI*D~dR)(hRjj#;t z+_^(muUaWHXB`fgGu$n4;h9%;R}P#e{(hrn*yh*ZR_|_D@!F@Ke$pha?uhHRzxgeQ zt5fx5%|2qb{$q6!QrGdG^SX|;JmZ+eZHsa#yfyc+|{v_fWsf{Fx ztb}lzvV+nqe%*D~x8Hf&tp)nw0Rtx#7Zrn)Kuo2jC5htFGFnPehtm-R5y4<`=CdQ5 zeWXK&4paT7TuzD0C~e4ms+8^y0DAvL=nWkI>IcV`CaIHS^a=s# zxAqo>2iWiuEm0O%k>us&sY(C3m2$uu?AN|>cJ!NH|LQI0efwL}VevWfx!-lUT_1p9 zz-9VKVK*J`y@7EJJLgrO7LJX+EeaPR*c*)1Q}IRgyoP5Yq3HD1`Lp&|NQ6KW^w%j z0&^<~c4quYOCB8j``@?S@zDMEeXqKzO3z6L+%esKD}n1)8ZRj+je>8YcDp^`a5(&U zR=oI~>p_5PQ0_yA-BIcH`{};z_}Nc?+^coO&OP_MKMff=^cP&K4O*?;#$}Z%D=XE4 zm6es-j)ukcu3o&)@b6pi_!`LN55AhDl;#O4Hp!5pp$58qFM!7wBsXi}1!moHmETpK`KbB;Yu8XKF$>dKMev=b!^ zVhZJzNzhXy{%9Nm0@HO6?ZMJoBd+#(DXzn{o=#>RYq5uL4TaiKr%`tE)rR5i#B31aNrrfy zgf+4!;%aYitDib;I{PQM#&u8bQav8NWn!TumIi&k*UmWOjQzI2*zLF9UKohT_}1p8 zV|>2OBf_EJM4Qzz-0St__3z)$!te|}|MVmV4jL$Qy_bFXp>(1>Ra8{SrcGPKI%t$6 zPCZ|Ip@?)gR7g{ zuf%ovWtS(3>$rKxDYD5VE`x;jl-G5vtCD1m1Tg%)DJFa zMciVkNF*#HYOAZKzWU1IuaU5NBCcJ#cFHkux9DQ^8VRYzgZ&4)HF3whdGqvT8upHx zZn|kuARM34-qt)P;1A4%MKvxM2n~eA;~6%5C`f6rS~uQev&y6i6NJ;=xHrRyk)y;5 zkAw>ia2iZgI;mit#PZx8nRd{bs#*r!HMf1d+gD5 z>ViGsqKkeq)a|xS&&hF*FDS@wudi>a-neny8w(dM{LHS^wO8U|T$Q&2#N~3yy!rD| zNNE2NSChV+4c8~S;)*Lw;`$8Y>Z`A|9(~+#Gb{)RS z1g3>Up^?z#e!tIAQd}zICr*&EvNFl_cx36)rD}EHapT9y*s)_lOd<7h4~5~K!pdT( zhdak3RLp?UEU(a>q8$CI>e~|c?+pfIw>|Re7_~tji zePMA)@zt>I`fq~!nVXX*b75R?^p(@@0)Bs}!`r#5x@y-Ce)OXsy`*3EnZRC&>t{dx znd-;lmpuRY`6(o{|A?!hUYqVR7!ToZe)AiXxIRO8<&{?si(72J#S?WrT6Bq?y+_pJ zd0>P&Etj&=k|c5E!CKj|eY-R@x3GT)L{_Lq-}VMRM{TWbnw10MD=03!AlH-U?DTdV z5e$YVhl0W3ZjZYN)({LHZg63f8PlgqK0c2G_3pdxs*%*W$Ig?YqI|(MYBmXjVjUnW z#vyLpxIu;w9|ocw#wkT=K#TX7lbfRmjU$HOCmGPMzgW<|THD%$OWfpxWQvOm@tily z>eZ{mk#O|6jqBFmvU%g$Jx=8rJYvMr!-tQ!3HNL%C@hp=!-lH+A-U74%gfJ`98Zo~ zUYhr@V#TTr+qP}_+An_b3&se3>akbi`sq(DO%m7fC!UZ(Li>rh@FUmPX=|wS;rz{S ze`^xgX9WMd|NgHH8aViWNNS6-e+;mXh+qTc^UxD`j&uA1L5M#9GVuv4C24Q(P%|^Q z+;RfX9p@}^+2am)5hW$1GIiQv;&Hj z#1SKgtG?g5dUzZ78+p&eM^vbO;0+r#BwAZq*4Ee5-t@tHZ+E+#(SX52IjdqS2Laru z+XL&4adX@;YsQQjY8DEK*NwlGqy8k)y1M!V-11AVy6SiT)@u3mVz0#YlOO*$Nn9tM zbW#cl?H}Uems(e=EfYLs$WS%K$Rw`M2EPCO?_V=-{s~ubs?Pp^dUo(!FocHB4L4^E z1OuuMw!O7oyuMCF0Df3QPPY@*TAAQ^mYV7+*|=e&j2Jmm=Fgue1N!$@QR^SBSfQfw zxjD$dL4%~Ny$zOGJBYxgqV!#`lo;$u%ZQ)Jm@0O#bAM6RJ7K~EMTFH=)#BkA@UYgn zDhkVN*|G&>k}Jm?b)?uGcGaK7O<-A1{{j7_6ZhzCYgKWN{XsHZ{=5=p_{@(QHB$B6 zZCJlS8X6m`3iI=SGiJ=l`_4Z5>?Cu~n|u6Mqwxs$OjAK%Bu-kStdAr03{U#(TDb7}OaK1&zxVlcvi*rv;_9}SQ;iC8y&!#7`+-2Re*Nug;tgJ(O&S?Br&L{6`D=i!fNHJV4T35MwIUt=JsjjJk3%F5W{eaL~)XRJ1s8Mp18=l%EJ zmz674N_jb#b1H-P5Ry*Z=Rgos9$d>0-g{Rbc<@1a=iT>|OFM7?t)N_KgezRYeyCCg zWZPxamaS4#Q!5p)=EjU3rPkuAg>^S|>SP&NF?`6o@4j>QqQ$Sa{q^rR{u+d%eB&i= zzWR{M?VJOG+stDIiIbe@w$gp2HTYW?0oPyuXGOFmOn(1#TVZMb5#O~j)96!=ZY{1K z{oseneC3aJ%7RnXTTio=@Fh5$YQ%({j{IS0nzPS}zBaWNUt%y2P}lGW%EcR~sksT) zNA)^1i;FQS#L!{Gn!DRt%0lO z#dA1l;6NP5m9)p1QM5uXFXFNfu2q4mZ7Gdt?1$Ha6gTvaZP*wE0>`rw22_o~0~ zP{m$d#UEaBNs_ouJ?*qK;+n~&Iq(B4UA9b4KIIfyzI3V7*43(s(koW1QVR?&TJ*9s zH8sh%&N&A^$Ts|F{pG*^y#v>2bG=AhRXe%qji`s>s;jRyiR-fk%XQcP?HeAq{bvP* zg@=`umRi|?jBK^8`i>ntRcAb1CkLz;x;kv|haEOWh7KJHa?6Ef^(ri%O)>zabn1dr zKy;#ZfToo)W5#su<_veRT8%c2fYmY@9m5J*xyCBw5_#SjrL8NI6;N{R9Dq#)?NPrAgVSH zMyu)*)B3{PAhWpYz~{MjYuBmHc;?SKe75Si=O931eIx$*gqjJGo0}tR*RGebV@4^G zrX|(@OHLyvov5Jc;%Ow+re>g!q-Yri13|Ibtr4fw)t=+Y{iw|C_|DU>zpgcyEJhk} zz3}48)%X$zr4rZoFSBvw zzV-GS62O1iSAY4-U%E;a z=nI&{wNJSE>PMYLMK$B<8(WVH2K-0DN|+Q0hlj-yv7(lyW-DK8bW!HaITj6h09?cz zSm2F#dF_(<^NxkfR<9atG#Y^wv{|`JJDOPRHMg?QKOP1E8g3S zFTSWgzqy$tW>w@wqRNK_>4jU#{-_T8-HN0d>J?#e!2-C7QHR6nb?184x^r`%3IzhU zy!-CEeYSM>rv+)9^Wku4kum&ifQLPG&U2K4Z_W`gkqe6o)elDSp?l)VCuH#}i`D22 zAGEW+@CB)>uT$nP-+BgEt5JXEXXDKmsjI8INk24k2;uXe|NLR+p8K83HESLZE?)fV zNAXzrUvSaBF=x)v(>{OJ=S$A{<~OZ$)A+*6fg5CnKUKMHo2=ikN$gHH$Z3Wwe)TnZ z^UXI=#v?-p50(WBPSyHKVewe-Wbk>K46?D=?a~T&iF5pR?W&eS5DEiR4?ldSs+%!T z>o#mu{YT~H<^ zvs6mU`^n%TaCdX_q!lmfmGDfSc=SMtE!{MdH#pPFy7&E?4n=gK1r6SX>ufaDlR%_yC^y`Ol|W zTuhG`IRfTzzUpJBuC7vfGx5fJ@4fd`+9=0$yBT20a$B};*6X0z9g@neTht9yfB>(# z_F83eg<#s(*Voi8|R=FfFcL;fPtY{|llxFCkXdaF06bC|Ff8Telu=)#1_~FEhqk)zsFimmZ%tj?xw67s!MO<5V~RiQ=O* zYi0g%$4O01jdJA}p3v#-WUwZlsR61Fi{T5q@a$P|F9Sd__4N(vB{_clMCDSlgMaPX zwK8(V2=%=3ez#RtN?BRCdRelcsR-6k1|*vOQ0NH(d&)pfk*ysl#{ zFO|5qZQjJs$AdFcuKnX5rKYYX(bn4b#ObFk__8|DmoSN|R~S8F#4r2zA9x+DoDfKg zje5#qQ)TMZsc?((mF2?V;*Fa&!Qz<>vIt96)h-z{c!+BFw94ODvP24ti{uCp85*?O zM0gDdhSB9!AS(7lF_wzY2;DswEVE;dK0@`kvMYipE-6;4lWc=EN2_fh$joVXs!_Qh zuH#4_iIkx0XF!Dqz~W-)1qT4$dFMSDI&6p{MNTK8+sf#8x`rgF0$6TFzmy`+jt=GG zlBC+{?!m29Bo$O7m4Le!@Z{v|$jS9Ab`=%<>!oL&QDF-v_78R=E`syQX3U&*TR}m7 z`8{{vb9$%OYh&NR>?4kh@h!-eN~vi~bJr4Hr*rMxd-ngG{W|>qJHGhEFFdPmrmtZVSFbT<#Kg0xK1Rb`NtnG zqsNXCk6W95$lo;<)posEx@@T;t|Mn3t~$uu(fAX%rUh;kM-s zao)6e@#4?Kw3QZds53V=Pmva_AzEZ4DUM9Nbx<5n_r4w6-Q7d*V8PwpZCP9w zcXtRHVDS*#f@>g1aF^ij?iL^rJip2F`PN%+6@P8PGSkz2y62qxz7A{hy$=U{>D+XO zzA*EK*Lt!h{d{4Vp@OCdhoi1x?}bamI;C1Q*|&IWIZ&*OBWFOZf-#FL7E0&5x;BoxtK zEls%MD(iqZEz@z?v6l) zN3H_4T=)L|*xP(Jzy}x(R!QWU|n0i6*6li;%4H$U2+~(x5KYf@?GzDY?$+%T)k<`$=`?ZdT zg;i#sl!KWA6|#9Q&M1|fud;9?e%;F?W9dQpcXxZV0UlH&Kg*Nmya@Ug-*2!0zD)lS zB#lV*3|URTA%QiK!N8>ArA3*_2`6vqbxQA|p`0JRDW{#zSCzG*Wz53EZ+y{1%o%^J zL$heQ!pJc)LoV4OZ$5=kh5eSBVl{!+!Cc17ge_PdJ%)2lUH)`)cC-r;2P;)jUCX~| zPq12XSt~1T#pzcbmK$19X2)InI&PRM(^oxWXK!bD`n{UV_u8_l z5T>;EmjJjch+@VyQ|zz4%m?&$R;J8-#7hQhKEh6bAVgum=i2;`zq->SIgDZdT>Ztt z*1-eM!sQRhO}Mo(r}YA9Y;5$xZ!bv>bEQVnANJx;mO9w1h}_KKhP(X6?Ad?NZ81^s_~|~`*M0x6NMT*=@H=agfPMPr|2PTJ7ZzCl%`tO38mIJ4 z?83{CK=R}!^sjfZiMSs^1mQw3O*Wy2$ewhz82X`tC4K%M8n8B0$@p8i3qb^#jLUo0 zl$PAks>nTwPWT75y?|jgnyM&WVli+2npKo_oA)s+cyC<;X+PBvU*!Q}l_2jaXn_k( ztA@0?V?LMFD1N3eBpFpCpMek+!SZl|Sw=Iv>?g4}Y`knz>h^_eEEb&PeClWIWb-a< zcXzI%Op5CdKiDqZestunt;JJjoC@fv{>?H8xSHNLuknk9-5i2_*JjT>C91deS$AHK zW;4vCz6UMo@B8akM3HJvT_>9zprmBo^#K5-9SOsti_}FIOR}$bzvdC@ zB`F$0_DDFJpPy&(hMM|>oxJCmkssZ5sbFx>&cg?bu;pvfF-3ykg_KkQaqQg7J8bX! z!JeOS-I4=eAR(Nf1TAuEPo;hd_j1d%ZYCDe|98y2> zfF0@Idg}iy?CWMsiyLTj^edK$oS;~zKZuE)5nLwtlh;1>#V9u0gJo2{xo3U1T?9@y zi*4Jj4VJo0QBCz?CqSu3EHCh7+41psQdpdM?OPK2iu^DOG-FDaZul^INC3JGMS?b? z_=5dz>5Kn{^2pI4(FRh@Y>Ky$N>+X5s^)l4I3h`lHr0+mVFK8K zlt1(DB`JcR>KN((NX#Q?-Pg`)#y_a3ITegp$m(4;=!tKVS06({DVCV=AkDpQLPn}1{lXex$DC3lc+&N0l0 zY{V;ZMe0(iQJ-9Kzju}}5$<>d&;w5`non0>N^H2ru(&AldVEu|K_372|ER_B(T%oJ z^C;xGz3fRMUh3jpeuijo~mC3*4`wwAy!-2WSK2z~im^)mwHQV0T?3>H9I1%+Q zi429T*=np~Zb#S^DlF2A*1$`+?Rn%qWtN6#>DzrmoB6=H(lmF$Xng~|%&SBl(Q{A+JZEtLLSNH#KzR{l{i@|*v`%wCj6!<1Vk;_YIHD9xD zo!=UHKqBgY*V_9=<(?8CZW?64EIxW(OZ74P`$(JP@rqe&79t zzvQ56|7OJ==U8685H3+pC^zv#+(7R;`!03>YD5`5VE(H94&T<^@l^P){~-e%pdR`p zCD5MFNUr#7>Xe=o!^%)|NZ9GavNEGrIBknVBnCrsY=cfu27*;n9Hvcw4>EyYl%7T| z;!oJ-Pq2BHz$hHM!wK$#&~t)u2CQ&$hg^AZQGRG7V3B2LZ+j%`raCr(s#Tz}@?V!I+dzE-o!CdF@};9Ifo0X#ws4Q4%0DNZ;Wu{+O1(mluVttGiFE zneRGo(>p}Z2~ypcjG{9`fe*t)N7NC-Q7g--#&8uRM~TAQad~^@CB)$LZFNUi_^a(L zC$<&2qnLGl7>}!Rvb1r;&^`1$>mYRA`ut72-vF~C|6**S6Jmjz!e_*QT#nr6S@Yjg z0n~C`n}>fE=jR^)9mSYt>34GM&;7R}|4vQ~sV%vIuOH)q#733Gd(vZK&`TwRtv=D} z&O>$feP912nmjc!3Oqe-JSr=Pj5#$Ma^pDrcgh*ozV(I_NEX4OJ^e7(hjbgtge#6* zuMH$IkjQN#d}i1HvY^%tj6`g#szgML4-Y(6IL`P2U!{E44D7By-~@PtMv+3VViSVr31PAj%kH_)sZhgcl>j04o_In{QSi zBkrP{a`ZXj2;x~aT3k#(v(uhCc{<-Ttmka$vT}-I#C`C9(652iL@{)CtrUeS`%5Jri+U14I zi)GvjRDTg4!^gzX554*u6@|DBFXh$pj26C6D46HvtQV&%uxHzZ9p|ftqqqL1-wz4r zwf2tgJI2pgWneE=%4RQZF>;a#FpgM=0UkRDx2- zVQ`r~-c&7V2(+1O~+h+;i` zRsrLf9e3XIq^aZn=Y>m&O;LdF;Jf{r@86q70X5Xi;r>{<&bD@PG&Q6@)y*O5ERtA0 zZQ;Oo^PxsLQ`jJ&Q`PsVCu*)6zAJ#VkeYqFn+~Y2rdQMTidK`}D6xg+m{v9(1=g@@&ObDXEhkOSqt&|g+wO02i)_^;Mu?4oQ z<6OgMn7_oq)IM3pp1Qy*szW5mn>?NrIOD}i_Zsbm;GK~3#xlcBC8p_S-0**VuidJ> zoFn`xz!SqxS5W7-;IFQ)DZZI`c?DV%Qsq3g7>uktO8O;z<|$?Kn7adSbz43OU}mNM zIOh^xq~VTT=c*4O6R?lYHz*VRVXGVl)3rpgRK~Q=3&rhCF{b1CTb5h`EM!3#O~;+wt-?%`9*8dZkY& z0�V+|X{nOZKqsgj>=&IRw2Ljg0apRoC};FDX6GwK}=cZ}yaW{auG4g{R#Re`sB~$5j$0=A=u

qx1Gr2 z?LiKgO?h+t95pZR449Iu==NWK3;JZoPROI{>Vd=VpD>^;+NP|?k_LiLJv%#p%HQm0 zxX(P~wNXhyk*e1%GTJB+N z4#88}42J~gZ=>5?)WAnWt-6y1!b>^GTB?Mm!t{+`x0*AdY7(crTJlZsi~qy){GyWi zlr6Sis&1BAC8rSZLPrQ^Id9eklB@_u(H#hnT~`{p;VA+zC{6xRR%%Up{=gr7VO|lv*%I2G7b7Te1+kW~n70Z=q)r6kl;9zTiM)2(K{~DbQ-!soF zisD+1BOVPi@o_KElcfcTE#4Uhw9XfyTL-fd2XW2pPn$1W(V4evS~k_U&AFMI#+#=%Hv#tV-87oml9||PXgj*(tskiOTj=W?CnrZ`ZNBLp6>+Em z|Cx>3>jXej7p*%_C(fF6`YX5E|3W^i91m_&grvm0LDet|uA=?DgY*|`V`hz`uy&qm z`W)f5lMvng-#2Yr!7l-N#(IIW%c=IWCsRDHi;bhRGLxqm`iU@it|TyJc2lrbvlIfi z(wZmWNW}BN0ntZ!r*M8y-UpS4 z)l#klw}#_uX2Z&k1AD8__&9(KGCa_3O8- zN8^4EgOvbJ>PNg=UxjXKaGaiT_0`zQLLCpHhA~b!dl}<+g{CiwrDVLDtS=h}L(Z2B z4LQ(yMRt&=LBcV94lNZDCz>2VlM8Y(Q8j~%IDLuoI)(xXC~dk4=Ifui(s_pa(}IUA z;{5&6AkOpd#ujBu4pzcST6U>3&I|Uhp{F|Yk3|g)0`weu4|}iU#;vX@mEhJY19rHA z7c-e}&-RX$Yd>10a+kML79||03eOJiq8palad?7c-jPU4#Xpu`1?zQcsOHQ9d&?fl zqBv9azRg0YfTx_M0tP3~1!!KXa5blxx&?CnBu^Cl)|Ez$hK3D9 z`!7rZgF`bce@5>rBlVam5*~No^l_)5lAHO|>?4~a`e^b>2d52wXovG?d4l1380kgQSOvzSB@6Jo_ulMzHxSxsbGNO}x30_@{P^iE{KY8Iqu6(q z0u+GlYfNX6TU_V1DfAhA2lk6+P8yI*9W(m|T3y<%GyrSVOT&_`lEW5~^0OwtC;A=E za1eDbuW8EoRf?K9l2h8OfCOHOWw7OSSCM=?EHG%r8&@j5)3sVvay?0lS%IO6U06zVb+Kv>U-a1sQvkNr&XxsnguCq%zKfQfCRH zO0lK_lU8ZkJa5c!bc-5enTHaK4s7UehGrkOb>BI-$Z;otM)0d=-7HGJ;JX^MMJpMmw+c-^cDH=cW7bckWv?U~VAyO2+nK6DW%woGpp7-M;xLvKzBV+GYxqqjQJ-iG%|VD`e%^QQQ1 zWcl@gD{}q@8ljum(4xFE(-hMgMb@h#%dl}55j}vY;s3;Yo!2SJN(txMx?2${iMyT8 z-zSD@{|hE(e_bJ{_uHqgk>B z{I{+Y!q22!TsUA3l)sAgOUv^mbux>AVJ`31FyqjkOALvwT6}sNTiTqbmT7V9^}0;> zai`6z{3JBjA%j23YH0OKpEUZ>xyHyf=p8=9D@%Znzv>eLTTOU4Cp1rq_DgiL=+}J@ zoJC!uKPc@v8(z(Z-&)WmQqKRO9b8n{cb}qrtt|SVHstO2^fZb7ffr1zKr<+ccoWCU zlQ&Plu7}?MvnT{v<$r@Ppn|Q}`(v0^W1YJ(!>%ont>!Y@UzL%RXhn+1RRGtaef`gi zWt_{8AV900Kzub9MJjtDS0fZ( zl?(>#K`$c&0n=f6cCw7`W_=^(+cO_zyQml?Qa<}hX|CgB$r^sC98!;CPhMG@@|KpZBad@$J1?$d(>JDDF^2C&Z*tC* z?U6S3C+tfZ8sTJdi$0hT@-nF~6BOK(+hKC`hjB7scOlD(2`RkXV(eHfEglo`+J-~1 znIq}7GEe8&;G50Z^blp~fX=p%=4Nt%j^^JDj~s)q9UW4+K4&=P#GIOg@l+fes(JL{ z(Yiux?^CByPZy(k<`$LwS1-`ARkK8;7HSOGT0dU=iOemS7FjN?YIaJJ@n?Rph|F%>;;}-xl~xsj3_3M6H4Yd3AAA7?k5SQG$zIU4 zB=t}XEGa}9FE1ehLvI3DrB}?_iyO6d16sh3DqivrBL*E6@yE<}B%?uLQ8RC^?uh(U z00X>sd}E;}b#=Vo#cLF|Rgrb)aMg4bRiozV1X&IDQ}pK=EF%CSrI*f}oN@WA<% zJZ67N%2>Jf$!GiFp|tSmK}0tI^ua&sV|lk7H3k9nwKl=WXk7LO9uE`VlWAi?Ugggx zi(OCzz_SYI{G}cS`8wH$$lV*IdnIJ-(DmwwTA#MiZ z%3-H9l`NdDp;fh-ll`)9NqnG<5BAX$B;q@=xf8lDayxhi^dthurEO}@2~}*LYpARk zQSCC69)5UN{^r+L*cA9H>4+na7M%lM%twYxHX?oexwFI|vZl5&#U|HJb1;Dnkcq}8 zEqvE)N?6*0d6{n#H7Nxd=IW-cB#U837&)c!i*i_d$`4=QC>iD`=ke<Mwz+f;mQp8A?x%Ul0<|7nFpt)$TVA5^_Q8P-N!}X;bgq#`FLq z)>b*Lk%_uXF4ugQQ%CQ1&)LntLCWvTZXf&-UcOW@34uz!5j zui>t`!xWR}jE5B=9biYJ>h}9*cj}s}ioCdf9bO+q^h>`OL3jEyCMdL0y!RsDYV~H| za2PLdoZ+?XdqpJ!VR8}W-_~r8GtTSn1}jZ<{ojdC7adQUp6&(_0Dr?3ZjS$}ieA05 zxcxC{y7A(v}lYKSr9{hzJfvcEUygH#@8(oCWHJ z;WI&HDOhesBU311n{5L+c3C{)9QlVXSWaS8=o#6>{gcfRdtSFIBRigI`*#|5f+^L7 zl~uzzPT$a;zScEP+3!Zxm63MG?X8~3=!sDkP?CDY?E3iWV*tT5@9^qB%R3e}#-QeN z@M9<~Ta!b7XvBbBrS}g3Pfajr@z zW*{AtO!&EaYfE`WS2|_{Azl)K^kdrrdW%*{qlXgf4Y^EDvO0V5tXZ0w^Ck;jy2x9t zij9<_LSC-md^uH-=l23uJ;!b<5S!upn}m$xZD3Jo3%8KBm4CG9 zm3IVvLTV|8PK5{Z8#1DsOksq&?~6^)k5e#*+uPfX$O*Wyu>y3Bk5KAA3Jn}r5&_(C zpLQXJW~*;|i?ykRM$QV$Uk@$2WB-mo`Cgg(Ogcf4odNOak!jpM|8M};kPggeV(Ow6 z+FJAmMH;rRKj_$GY(Z0HOTXi-mutc5+VALOKP3mfJXLDQr&rfhBztcLDQ)=OU>Mx> zJT>^uGcPxqg`X`MGsVY4(pwe4Z6BtaxBB}vWkA_PWqqLER_$pNjs3(%UBPl6{)DWp ztvzbTokAJec>)ZFD{+!*b?J(Au{HacnN}XYraA`5BC>WFMzTJ{q5E$ul044va_#M( zT22*q4TmuNO)WY#$w+aosd06>Yl8Hs0QDnIoPV8v^+>Dz`_A~@`NnR7l?;gy z+FgpV-tA2Lr+Mk2N|&i-wXYh?#`ih0@*FQ3bj6FW<+3nJ86vbF?THjF683lOmKhd4 z6Q+DO?SWh`k~wSdc`OG083~(J%TVI@p$tq%X@Qf^7M8z{IAilqPRJ}z4{Cfbz)`0W zDXN4>9?YDa>vWLm>N%8H(>1~#{r9TNW-#1Xb!hZ`sG+psnmXwJFhA!q=i=06(k|6tFKh&@~!pE`7L``y#71!BSU&f7VkxFA4#T0dOmRxNf@b+f+XDg#}pm0+`jGUbEk9JBbCx`d|9j zdCU%C=wNL;by;F{IKK|yjxgb5AVlCZ(jf3iUN^^ie28o0lW%X*rQe#bJu=)Q!k6ci zFK;Q1z~x|KizCFxmv;PMICboCzqR7IAV%UqWv@HOqa zbXRs*?{Bm8+T>={gw;-_P3{c)DA&INTqh%Yq#!v(Wrt!F!zN*zl8TSb&xO29e&Uw9 zmD2$4byt5y<^CQiGqVC~rZjvd14w3Sci>pmlXVkll|ohS$L#Sns5;&5M<0qNbKs_R z)A{d*Kpn$ohw8R#Z@u3ulWQ%IZ=Sa&^M_%|?6I*l+mw~3yOSW#J-JZc<|Qh8$)kFlmE=?KSg;>y`w{=A+08w8JS zRJ1tD`(I|U{lJJ?4JG7gwmOdew6E>Blj^8=NqC|RII^F1`JHU~&c}xz-|J2qlo|-r zNAiDWc*$oM6fHJ3T%7gU?+Y8Z&Ef64Y9hDNdiueHKr0sI-y*IUk?k-fDBGkrr4k<` zFiD+Sww-UAH-6V9cC0YV{X`X49Khf2OdB-AkO3ASofj0hiY{+#|44kqsP4Q7KC9yIZarr=U$DW6!+ycz_rj*&6K1@ zQ6lWyio52mQ^66zn|`ZoSet*l2hI{l;Poz8!}hg? zMH#$2GSUW3nPdo-lz8 zzBgSTiM?L^xjY$oLT_FV8d3nP&Iquf0zKj`c~PKdr*&Ggh3YiA1VP!A)uyFs?VW2s zp;Vb6g*D75ip^#n5uC=~0XQwiG+hApSi`Qu-X+lRpJ82174-A%ziAvU1&+c8BBt2} zV173_Jvt($z>E|Y@NG4NYEEr?c(rBMVDfxDcgpa$^6d&@DXh0`YVI?<9d{0BQtb-p z$|vggWQ{&m>A08ZIrn}(JW_x6?5=M%g!CL5AmX36)Zm-quvTZBAZlI1(`?I5{Ez~%POcXcfYc&#mk)dudL!HKpC;Q`D8-)1a|55J!&V=CQF1%lfTzW7rG{?;&5 zP*BjAvt}8D10y3M8x(0oJ~ik0?8M9kUaJF-=X{nf>4+n|XG)=NFn0dSFBe7}$2;)>793h#zf1a!(B@3>+ zegvA90s_wWE+K9u%f*j>I5K*|5yvKSgsdK733kqpps}&2%Z-qfCB($!dnTf2pmowj zn-Q)F5FT*0GTDMFhkml(WPj5ZH5PP`{^?zJb5l#J14SJ#l4!oV$ zg^oa5=0Ty61~e#R(I*uZ<+UA;qeSxhA~=gRMne0a1>EPwyG8R+2$!i0vq+r)pX4|H zrnkJvv2g~8n22z*E1=Z_c-YtSx(eCt7GZMCRRwV=*Wj}Z+PA7--qq_%i-MX!kr-re zb1I6~3%^e{ubhMEJNq#8yyF};JEg*0TB_1syFNmS;*DU@qozqbnQSvH)C^Dk5F5$=1zN7@CQ`&yFMC zW>t0QS2*~Agge)|y#(<-F=k?9Rm>>KzL%ij`pHGe_9#XQqgoPx9U8f6*?;+yF=Ld* zX)!qLf{p)F>gMJ)e`f`>)>?B?#TwNL)Z3U)9hn@@cmtMAkS$aV^&dky2WSk4fZN5{ zy>)FdBRzfNzE6pLCO!8Yq4TQR*$4#Eyvurhc}#OyX^{wgb-hWD>hRUn)n%q$wDted zY(124lJ|T+M8rMyzzrC?xXf@Dg9Zv2l&lSQ?1JT;Y*#BW&jtr&%WGB`?D(>F3IW4* z7_!&JQi0c?8ULHot7104B{==>C9MX`5H+ns%@QMTqD^vf4gCXUlm)|v#&+6W&}M!A=G0PuM|eKJ2SPW@|iL50kD zxz6dF@(%$qPr&^&0Rf%!@Z?xCJ|STlKVM`ne%RU#+O_NDgB>2`s|Z-kVSY3X=t8sp zI6lVF^~}9({^dVOI@v|rY49Ni$%iw{NXlaaDzpGr#}AG#6}jSWnpsNlaLjcnW4%)% z_V&(t^%`KO%*DfAX4gLRliywy5XsrEYFZ1^qiHPr!*q%2p4z$>@Jt6Wv&WkB-3s&c zKPxKifc7uo!32`(?_Han?xk(5JIUrc95Im71xM;aa{xM=jLQ0vmmx`AAAGM2vd4iM znCN8t8r+1#(WWU(QTn^n;%jS3)eNyVaOqsV|h#fnIlDFteNzjAw;_7v>9WeeV ztp=gvBD%UV+OymADa?3i-IzJXXT7J4NTX}wZK`u{u#0D_VeTQW9M9t0rW6Jm6v&n5 zgj7H?x`XML05@{^mX_Dd4{`pN$Bate*6){VAG_FSfeZ%FQ>=V#`0?=(acy&6Mn=ZF zJ6@SxU(9)<{hN5MTK-4{^?Oi}hYDnSS~Ex3H#s}-F2icArG6%Ka_4JDd3)L*GXtV~_B4r@zZvG*Tt7>8ND98E(fY=-rkfl_ySe?(`b< zvspEnSnx95i3_M1dB@^Kr30GU;Ii~D%O7PY6RuEphkC-Uhi}kK)L%qg;B>n5g+|pf zxnyvr{h*&`&r{7@B$lTty>v#ldcwDQ1+=3C^b+1NGi$@o9p5mc#pB8ABR%x(1 zN=VSin-{tnco$GMgRFWH7O&`9GL=3StFT1d2c-3K**iLFS&mIoUnNIm8GcFgT%eL3 zdqV56bAUiJa$e~bu;YJIy{85gfW>6u6~Qo}d3WbDZu-2$Z>8zIen2{Z(OTUCc+CIP>IS!84Zcz|-BK-6 z+yyy2)3bXi&dSg&*Com9YRqTGN2#d@Izb#mb+p(#Jw0dU=87MKR?JkU&&l4K=Ksv* zh4W0UxUJvtJ9QK|y~)$M(#-x#1h0TW{9Zn3Bl7lie(&sRcd$HZ=zO)Ar5Vy6jS7`R zV@)I^;cS3i$TSJeo!w72hY}#YS$a?_1R7bvpx~DYq_Il%0;^0JHHk>cC9&U6Cw(E0 zh@R7_m!E{or%YQ^l`Lig(|()^dGzU$4Z(FA zM>?mjQTs3uhE+D1j!iBo_?}YtdFN0ptAKgIbr7 zrs2950~3@!jwS38oEh{`iu<2OHdl2!;hEP-rg_+D=P-CWWuLtTM@u{ zrUWcW?OjHaX}kPekEJ;#>dd6k7hkI@+7`c4(~jR6DQcn$@pDa$jfzHrIm%h0MxN4q zy$CA}R+T5=q}+C?wDs|1e9V;tSc|SK6ZMHP#XUjgDgd8%swZ4$6E7xZ@9^}uqPtcl zey`y6#q0;{jhYH0F2@sXlFq@hdJuA0k((hq`1<9sLN<)r8I z_9<(LX%imJ5%6tP;E5q-xITF$BsfK(EvCzA&Yk65_uQV_I&1B%FR3S@2?B{^Qpfr$jD_3gX1 zO!ziW#KS3P=jQkqFK?&_&=DD<`UtpH3;S&eQ?#OzJNIQGdb8=blkKwn0gXo49!+MOT3a!j7p%c|mu~N2}~FjP?IUAn#4sC>)at z1mcuSgbZ)}QL+bxI=iPX_S)Xwo(-%}P*tUT@G~boQdr-Bm5ohhR8a7wtVrSmAdx!O zs|>9%Y1UO#dK&qZIh!UUnc=h_tK&8^!dS6XoPIzEk=bRJ3(Rq$SgbN;ffHv2kV#rO zXW)xL7_>6{i?T@~Y<;qdO^1P4f{O6xI;N=Y8!^KV6%S%ZO`MQVyw=10xObGA(%q+3mpUlU>G%xE(?ZXVW=aY;@jhhm`VL)0K0aiyjD=qHg&rEL9 z9*+uD*My6DZvTPneNC)W%e%AX(Q9+DpC^f;nmJo%{hNqNtQ=kH7&qLXOaWrcDC!r! zOMYx4a(3+~Ql=sT=|$JypQkI_v)HMOl)M(ONcq)U!GLoY3Iw8ErsfI)`G+#94_2|X z4TMk~f{Smk@WY+VgMRVk0*bc-N%u#i4U>@G2-i`z{W6ATWDAqIFTD11^7LXE7e*C7 z4kJ8=p7x_DjXJIMHP4#0=s#YfFPQv1c54bPUg(txB9HJylCM~VDO(2WNx<%-SL@PW z)ptoQYR7;~I8ScObtynyAa96iFA*=)-?47YAf7bVl1q1PUcv z6Mu+*$W|SnZu=VPr|%Zej2}XS{tQNp*6kLlDkF}3LK~Yf5;9w_4_<+VU4flpQm>)B z%(4W$(LXA(lmH6BF91WO8w?jSWc@8Xd+T6&9!`QFtjsp%>e4JYm6j>B=xNk{fA}pc zQ*tU1eG?A-?WeK*&WC{vlb??wIAZMo88|w6k798$Zpq$naiDvu{}3wDP>W=d9jh#E zQ9r8_Cw6b5OrNOA{FeNp0nA{%`0OiX=gzA((k7vkXgUVQ#dt)@bfCSdq5-5{dvR_w zI*Cr(7S1ADw;DuadtX8I6UE-)B{F_=w4g-xy2zi;_Ln%XOmvL_Z*&5k=cjiz0N=tc z>c?^uDX&-_*$=_3iT(Y9Fw4zID?a4CU7d9NY9X(|Z*&`Vh5QY2y|hOskaYZEB6^vO z**JTFeWX27Z^0Z<{TxGKf!vSm&4(t`0ok0RAA=Dm^cwC^~-D zo%KT{X-Ux!9fMY>Td8{Y9QqNqPOuAKB7ea5CDRyIH4X$PSR(du$eWHyQZZ4PohkNdc5Jqg05=qSlEWJiw|ZBI=#uD zh{@MOr8wi28qu|W7{Dd~#OKPzka>i@(bvJL?Y@MQ#o&w_Dyhms26y|G6?@hbw>XyLE7T_zZlW zxppH+=@%{SvzgTG?-Qj3vC*>~e1rQz5TUMPG={+?PRr?go3<#f_%c^U^^~#39>r>K z9U04SvnOy!#ctRJM#Lbg(zT#AU#p`fmF@7-hqN*`_FUdn?mH3RD=5XLllO#%XnQ9H zT4i^YnHP)a+X*VO$fN3-+LY=!M!-}irfU=b0iTbI1ftPklBn3dCqG|GtuL>MVyRd_gjIU^PsAabfma4!5{{F^*xT(grvx zQL(thL45_rA;dTF3lbCJhV%LlZ(#ERG3V3+7Meg4|C$y5J1P&s4xd)_7VaQLVo+U3 z?CQN}W^?d44x(oY1h%14kB^OO5iT558>S%)T3J>AKG3lPwz`S8qurt59(svdULPu2 z1JDC)9cu-2d$85s4Kr3&V##1>(nMIp)6Ez9v?aaO&T@{-kPWBOz}cmy|Iz5~;NK zGgMo`j;2&9ci`BQ|1UxDLjVDX%XQ?m#4o0_nvj0= zD{ehIIR)BkaY%$gkNL%54;Addfmg1>tx#w2mXrP>ev{}MMmm*VLG)|k2ulx?Jt6Fi znobN!mNWR&l2hfv-8;WSY7Y2y#{Z&KAZC#>-$>v zMzzhIzKKG}>z$tSSUMYXcZ#@$`bE(+qs;ges?(~KM>b2L9i2jxV)vz*vCX$t3#aBR zm>hd?&BPzziB)mU4p8BPI>IYEh=;Gh@zq$&D~UQkIJOThi86}k&)ym=O=bu3cF>Er zguE%Eg#0__eAZaz9Y4I|Ji0)k8P#Dp?C_TRcCq+IGzh5hOzVj)LTri~8{{Gu{vJ8u zf~We!hEm>t8Nb^YPOrHmq9{x@&k1RK#)`WLs80 z>QX{FD=2T~V(4YKE|!8hWyI;Ga|HBV z%NN$__aHSb8hUys_GiKfdq)xEZ6etWD8`dWqqBBtv^~Ylrp#kdvBIauI%COPINwd_ zN7Z5laO0@0*$b{@#+5TPk=lXokL1#yJM_^zU#idl3$&+raJm_*#~z)0K-khA^l>Gz zh$Mv;H;OVvQsu92yK=7y7u{s1WUNYP(hI?%OTAIxJPF{g;-$;K3Gr5?LVe?_98qW` zH5MJ0d9^Hzs|jxaYgWV-xt4h6FEBc*vqt6`A6XTu9K{;){^AoM*{OvQx93h9+%X=F zSSXZySxgsh+lC5*MnN>8Avp3v>%TPQ9h$gtpNN2fvo=6jb2tFbRBc?cx5RWMf)f&& z%G}V|H+|URn&?Msh)Q-iGk-_#LR7Jl`)-$)H$pzNDO7VQV1rfTq_WT_7(HG&tmwdkHz3gZREmH;ya@gwj-5%?ekGv*_ zd&JLvm@ri^R#Ej|sj&x-|7J#$3Cy)1TKqmIeKoMq0GFs?PFB{R$kpA}{rv$Bj(Nq* z_w~;ItpvcnH%yn-atBc|#RKet#NCoF-*biEbsv7Cd$oXD%qw90X9x#=3mPgrS%>5( zc_0BuOyOWIZRM!QZZsyrB7xoibC4oYp^KOj!z$2Yxp76%`6_JrFh>*xDr_ww3J`D^ zPnsJG0ItxaTU7bU5cH62Op;<7?mT{kk;e7GBtF942Cd($MG3yx3*1VR)}7z8qlR^$ zERB1i{}}0JrE|0bDPWP_{*xc}f0dxcR$2LwR=)*3Hsl-;qxw<66Wn z5D>n=hbs|De&6~mQQYr_EX9}`{=Q2r0)Fr_zU=yC$UEx4m+I&~R?CSl0jLp#G;}8> z;m_o~)Vgq3ThH&-#BAD;paQx2=bHl`K1lhiuN>%Q2k$=1ddS)iiB=|Fk| zx2@Qvo&aRAz8L?{ux4GK;d~8sfNrI}T}b5r8)g@Y8Fg-0@i&bguka5r5n7oog77gR z(>H&^UD(Z;A}&bS*j2l>Ju7J%Q~8}W4Al6oTi#T&{J+NDDlCqmZM%iwL4teG!7aGE zJHg!o!QGwU4ub{{7Hn{L4;I`#cyM?7JMX){>;LvX+H*A59L!XAPgQqSJ?mZ#NQ`I% zoXU=4KDu7*IWzvAag>L@2p0yL!&340g{FhpRf=u4sE6J}JK<$xf9zwE2meK*{SQm| zCkX4iMgTTqu$t32EZ7$pKVt=Zltk1S8A)w{v}e12d^2q;KkWG{S~FR`r-nxQXkn7sb{x2F)0 zL1Aj-O63HI#S99%n6cv=6RDMJT*LhrZiOQ3n9^_>g1O6B+MEz*b&~C-f0C%>{s+7E z7h|t+-iu43as2;8UXA~;-PA&EpNgN+b%6NuJZX}vo&Ei{ehRh^%HQTpYeL9Zsh6Yo zgN_(JH-GfukJBU1zVKZAa1swduZ}##P`-+aib7ozXI;R?>-P_8r1>npXlS^t+f*)f zF$!jMPJ&(MMQ{CB7ghb+H3Fx-;T*a6S;MyIk2O>nJ;G$%k=p&3lB1FN7yXVXLh}9R zi~}lcL0hZwjDUfWkvx)iy2g^@Flx|LsYcuHK0#^6<42r(vV*AL7*}~i&(|jIBz!uM zl>YVyIPur#V#SC4#RmD4Vkn?h{Qnz#^@g8)D+R#UgN`hAs-V*#sMsyX-kPtBw zfO}7kjK!*)X{`R#T?>auBXo%w-! zzPJdO9S!a8Mi=J=@gHWpSh2zp6{4euRHKj50Tz4Z;Dl$o+85NM^7ErlzJw?`E3vf6 zxkMf%*>~elkfEp-wH{*?v7W$?VDh=4q@5&D?Wo_F=dFKyFYr6@IS`|)+|Wn^TT`Su zF*StX?REyv6RfR}$8~-jT=YC(6&v(J+x$LojaWIr)KZFTHkc&i!@J}_maBs#OEw@J zl`~YN&CO`c&0S=-mBsN~UBivubEfln0_sYDk8tW(Utf2JI4?M6Iqna~Y%6Po6h$DX zv+DBFWk|q}PjMnK3pyw-P`g>TBwv<>r0a%1#?0D$CL@Hl3ZujfzLAs-d50-YqC`6y z3yaVgEDu&O#X^Q~Vem6@hmTRXH|xkHxPL>+o>apAk;Pjk@iP{`5D`+@NnTT4W_?Of zoc-ANIDH#9;djbdsX9^wZV_tBOWE1kLle5_$D&ru73$ywSHl9%^wn?1lbF#`;*MY# zbYaBi8SA=+UQD}q8qC$%d`{eGF8=KC`MR!a$*`Yhod2lTRLq5$38Aj$iiR85f(bgH zKuCus7b)m3MSkJ@Fs0&M{;H6{%F)EM3}j)!T`&A+Tc3me(eCJsw2Y`fwEmYWf!BMi zH|-WvxCKXLObk%$_v>u|nWi7eguzr^r!5<)rE0}MNabDd2LW3D01*h8QaRl0d-+6; zXwchS)vSu9CbMJ_)rf(;omJ)gFh*&kx8e;a%2>#^r9pGCp09OqJhc|h9>?3FZIiJ3 zGp=l?O%s#!EaF5D-n`B*@u=CFMr;lfZiOEKY|&yi8`6|%Q%Y`HBNx|44darn3O-9_ zePE7I3-da*;<(t9w%PfHK$58E(4mOS;twY=)tmjZrJgN~`c-J>C}D{Fri zG{wDOQ$yoWc~u8>gPU8e%RaM}y%mlT8JS_O(K3I>G<>4%U8B67UK>YKqnw(2GzS;A zteabG`+cw2QoBjVVdm9?pZN1@s@`>3-M@8qcFahwxxY8BC5ZaWiQyxC!eL67fqe6l zyXFz#G=V1m$Ukq)*`PA)sj7iD0xyEQDb%G>KJt5`2`nUWU!-!+ixO#3eca|K;#ikH zDn_RzGwnF>pExb%s(Hv-RuMlSQxse~<)g(zGai>nj9QB4%51mp8*+~&pYc%@kAXOa(3$W;X| zTta)$m~N5t_T}56hL~$vsFb~YwhHeekmw;BN$JI8{~`8vk)6=avpn=?QThF=AFMR* z0SVjJu>)7x&nB!9W$GhOH%YHB2t#BEi$J`s`F#YK&H6V!fuMUkASn0@k4B;(FArFf z@v|7XqB-qmqHTedpru$TNyOFx9CrNy64?+dE-^)m#0b6#>aw_*D#e*H;u$(X9B;?w zaK|_6C4T0f`+IbfF6b=}3o|ydK8&Ka1;##ug2nxDyD*NHkpobTPE{wpVo~Y@q^TV` zw)B@qM;GMJG8b32^`E%Q;!6x-=tR#25uWD`5YCnl|Azq%9Gx9P+bnd0ZlYb9bTXVt z-$}@ey&85l2zukp{w+?B($vHkyXy1t@u@FcH|ZpFDZsPpFr@~XIF*)M$f(==wLLF$IzSZ)hC&fjc_?EhDUJZ# zylR!K0K3V0Ce`A!|uGA^1n0XEf_ajE4?8|gm8DD zNh0zreB_hWXDp;N{l@>3vGRL}iPK5$xEE>`)VNP%4;*T#4k9!s*0+p044x$c{B!xq zGrRyY+Ao=!!_xyS!+vkC#jD6poDK^HlF`alZ2z!6+~9um8tpzQX^!H4*ZPJ+?q~IP z-JDit`Qz-_`D$#+>y>=x0clDd$_2Jk9|g%Hx&*US11s}QoCa=Z zO7fxMGcQR95__gZnRg3Pubf&PSLbxjT-%C_;tU>FC=xA86ZaI$iyE8@n*UhSYkk(+ zVYT_!07`U3*G1d;2xpur{Kb-Ip(-Urx}e%wsm@wYbwhZaV<~sKT7XE;(d4pHJXoNv zptml_G7QJ0%uWoa$WZe4PYXN50HbV0{R9Giavx+PqG2UjyIv~K2KidubxLYy3aBm6_~vj3@4h(+t>7@7UdSbNFT zv*f9u6jg`BvX!U2gZm8khD#d7|JPQh6KYYn+*B8t$l8*%$- zE`CX&8cCOu)k;}7Ofrg;~WX+*@7u!U5&W0YnEdJ=cNFbqv?~~XrD?huprq7!e*!LLG8V6j$_8fww}QPLucGv{yrgN3aHrU5 zy1OT*g!*O~!&a(BEoU~4Q8Vi-cBln?9ku#p9)!d#$3+bQZPhlD;@d##jSd4HUu}kB zYUa_0?ZP|W6+r-CZwU>#9aKsG9=ZGMZj_#fY{7StQP{UlwDUqY`x)x76^F_B?kAd; zRhp4zV@Tnz4>sgK!NF44bgA)qsFyP27>ex5Grt;2y)rD#Ma46efF)Y?dgis+yu&bG z;(kUl=GzCl%P0>WeL7GB5ibE>(vYiNATq(_*^;7T-GSHr-j5eDCKy7i1E43?TSp!P zyO{t&s4b#@yfHl=T|3yy)hgNs{%Nc*-x#*rK-eWvJI2riv4g2;7&1TO963wn9^KGt z8ZjW^--#Si@+w+pktYhS&0}Jm>ny1c-NF zp_A2)d9ckiQT4+;g;QzhO+$+yBSVJxrKW+1Vddqh+6w<}50hbwjau7kYo);}vZ)VB z;oY-RZu|RpzQsbcq+DTUsEAJTJ`(QTOy+`PWW#Ze3eQs^Axm9_SSp09pSSDMzY-}~ z3$kbkF$Yx=&waA}WIsDDqTnH}BnVC(nMeq+rvo3e4G+uAjBHPf9lMwz!pfFoEu-Cm zYYej@?9l1T{=-bai>3d;mp4VWNNWpz>G}(`Hqz**Pxy}2Jkst?%1mBbo2!>iZ-p>% z&QVzF+r5zO`(fuHHf_665!>0{M)A&i{1mk_c+foqg{(io`tr0t5A6_^SRVzudBg7+ zna`eO(d)jEB{vLAX^zp4fM|+*5>7`F53N{h&Z2HuopXqs9p@03o%)bYK}@Mme5;9R zxh!5@UaPWN9V)%n!{p4O$yu4RkR!-{t~N)qI~P|XE>S4e@q)s4afxPg0vHK#vLdLV zVbVxCd1Wwm$bNG&`zRQlt?G>j6Tz#bC{-gu21O^*9?6=U;z){USDOWo)hvUV0x4?$ zxa=Z}h29ivno->;(yet*c*d+RV9>r+| z5JzBdRrJ13O|_@hQ&=;aBs62-p9MPDtO56u!;EuBK0!#_&~RO;O)973sC{0w|*gg8qxTI`*8s zk;uGBIDU-heRk!<@`K}O{(1^)hpzQ|CF&Q^S_J@O2J(Zf6>G#qDd3^$RF{!ui>wP6 zpCB^&nqT156V(z+T0tql-}PK$7|s_&j9L$TNM8Hb)U9_zn~^dN{X`CUvLWf*L2uVM zTNj>fE4yJPd01K&fOXvQ^VYdkt#OolRYCWw0Tg&)g(5Qge`6E_js`R<~-d3LbWpxzr#gpiKS@v3q&CRhL?8hr(?}xb} z4>MI&WGK*z)i9(TWaLst6L=unyYyRKIgjsIngZye*M3Z2_{{XMcz{9fsDYh2I zmV)cX_c~cq&4P`1qKJ^BO4BmXQ?u%SkYW@8DgqrlAQMJkQc}C^&g0>wO-~=CNTr|3 z6!V{V@#FpbPB>F&D;*I-`YU4{{r!MD0aAc?wZL=A8_vJ@Ri~@Uzu%XakWrQ-2Mj3K zZeNQ#L^V-FsMut!xuMhH*rc$L<_9*AsI@d5;N`#f7m>T!74)kl<9!ZYRDtCebLANGUJzBR$?$?Vm+XWOKD9@a;PE z*<%IN5lZKHd2OURC~(0eb`!7wsr#c7LRtAwVr{e~aw4;=xJ4nwOzuR$ybQa?#xAf!VN@@n7MUVcyD;SVO zw&8YW1BDi%RE+%9Enpg(qg0ipujrDeVGsDFP73o&Uy_W7sd9!4PFFQm=RPzYs&VWI z`L#oVKf!uvH-Ve1&4bHVKgRQ+%M@4{-87)MXr#GTKuvAu^{f?q{EP?ja@jUzsFib^ z!%)52R`kC0AK1uwe12T9@AL}vr%h$|rzSe-yDm7EIEbT~4!EhK7j(JBaQ2i_s!)VFW7qi}e+3D5kEG2!q-3R5l@$8XlhBGZ@ zAnnhZiMdOdHgrI;*7U*ofP0vHx7h5YjLShZj@>{KhB9qZNEoYD9cX2;VZM6%$*^G} zZqDZOHple)3SnbF9Zc*k7T%B+jpUz-QRn719v(!F6Fiq4U4nb>(l#JId?8awBkk<$ zLPbM^@IbO_It>S!y?uKA@ar8=h3*oQ^-{z##JlnMlbF{h)%WcQZ^T^qCGr`N;w57N z*RW7jKz4K{VgnxdAq$g(W-z+6|)OvQm_@VhNcBWY0YmTX&2WOQg zi^c}o;;-~lWYF@i>g(wmy`cY=!~-DGi&~Qn+t>XGA}bUD{R$&&vr5d#sVuKbvdH~^ zF|FSwAR^zJ}eeLtATy_@PL;>bVLJTL|uUKG{3nA!FIGbT)35{&kj z)cjYw9ty;?tKLT^fZs1Z;P+-?Pssja)o?~_fd-!*c%xeGvEzm`g+%acjK1SA)z&vo z$>{LHStcD(50A>qN+mE4`oNG+FCJIv@^Oj^%z z0vA+}t@xnXe6kTsl|2FfmMq6reVtC*bU-`(vJEKgJJr|pQ-NrqC-`Hl4s@fYjV+Q7 zVi^h8HOC|e#>44W3Ap^*RpwiPy{1-qM~Sfe^j~?K#X_KU#qQGfZp!kutky&>xR1aX$5{n%qP*{6&8JR{iBT(1S;(VxF&Q zrGhkX3ck);!#FgAq*a90`F*$t4TFJ)yk^**S0SgiD;^uU9(QHZ327%Kr-KlS9m^`y zW_VT7>f5tS*z3M2LBN@^*`Au#(5luO;~>jhl|rM(NF+@zg<@>1w;(V_>z`{fenypM z))H&>`~k{GRhQL9oAbmaNSd75R0hZiwgUR(>4DxrV;jmyc)rhlzQ zUf?8U%YLaeH#DVih$aIBij8qqU1qSdTAKc+ zh}%v?MQo+oe*z4Mj&@g1^}??a5wtIvMjsPMhW#}#>m(O=vC zrPJXQ_?0HeJ_CfvGY_iEgh&xgTUdJNAv-pqfeCzsA_|I+8lH;;ae@1O&ml-7CmB3e zQLgUpKuka$kpFA=k3~r54(NRU+Wyo9ES6#t2)LGHxvYDr-}iMU;tE&gbth~68`Kb1y?KfT z>npY)jD%C8Hw35&CSRx1?RbIb$4vRu5_hwkosm?vN^r}R50p2epASC{_goF zv98XDoa%2f9p-9W{?s(@EB>(2T`P+9fq$o9gbi+lO^g3`AkOCKPhe89gQ9CYQ>625mG9tr<18iRI}-YW47yg)|8q2d&JuF_^-fbl97?t2C$Qwv z5D0gvfqDI3HG$Wi8Jx4uoB3bGBmoLcJ#w?TP7SVn^4A6S-DoF{#h#|nPTC2n5sSv; zOCmCw%{I6Jnc5v=6l5TIy^oOMPJ{X+@F{>FsLF^1B_}6S%Z-Z4d3oV7f8KU(F}7-% zb>>tm6eNkKAaO4#2CFHz5=|c>&1q=VIuAIf^Vx-EsIPG9FfV4MYOj-Eu z*^4Xzc^iBmqb+bKLz(9XVmRz*$opShY^3Fp6%`Xxa5LZXN)hi@@aD!twm!E*q3_G7 z7S$aUGg>Wwj@KUDNj_uPKki)L&D6gARN0j2DW|4zY=P_ptJ5dPlZJ(d)7I_V%I^`u zu;b8-L7@_PMe3UC%5t02EiM8e$X6OfBwST~NUEKElMjxJ6&+$BA+yokLZ`QTxuIg! z#SoTq&d2y){@7^JXz@}Mm44(E>y6pj{2oJx8Vu%pn{`z9C`A~lCVrgUoMqnS(bBR$ z4>F~Tua!I9`D3u7!Y|iJ|HgJV6_K=a%uUQ;+_{QtwjFG0G~CLz(}@$0^;?H89R)D& z;zqzRmP|cj6yyWOOp8Ys~*FeLq}Kbpg^wze*;b#7C)Utt5p z&{Z!gRrX!m>j;bl!Wy3Oq4?_gLf72-V^sjv!p^c5paR%R#H>ha zE94NpL&bFSSv5(-T;oP$q!`s~22$lmMz!*KG#~t4v#XPneSCp&@x|&qA+HOc56J8! z;8PD1!NbN5tfx0$X_Q+sY`KZBsceyoUgGI)zUsOgkC*C8`(_!34Ex*yZ{Z>F{DlTW*=*5#aTJR^$0>tn>{g_XWK&Q8W?1TOO#i;jIG_Aefg_C;z zp=onJo^)yLc7*QpW1ypxO-vl!MdBxR?^@fu=FN`7)rQf#yu3^e?w$`!E>n{&3W}qX2HIGoq2`)J{1oaw~~_1&E5U<`PV{ct5R+)1$44rM`5b!HXBe1@$;HV-J1qbNocsqoQIQ8MShf zoSnjNw${qYw!gStSW_cw+v0_p<mh z^gU7I$ZBtdy8T*e#6bQ6qqq4Kw87rr|1_VNjpuIl$~~w$>{deGv5xPjQs%Ev=v#CG zn~T0g9cXD=0+fs*(KNr!1DCzyE6Xn)p4U^-cBrU!1!CkI$*GO=0N8BI2bo|6h!G2SZv?r*A^hG@*O@>W*D0R8g=VBgg=A^PMWPYek(KSPh&1TP}Qr{0(DM>iE1_}F*+7(3Rj;`T9OGDB|W#6D3>`3QC@tU!=*}T_-K)SjXKcNcD+VUrA%!V;NvOB?fN>$79-~gCnG`sb79rxo!@;q(*G9ul60_0yOTsE_&HNCBhkof4;xBf5j zuS9mvRk4@((ad}l#3&Oi^mGJc6alSzUvG2tq0V0Kc6lB)mHHslZoaTOkk9o z+lyfqU?Pno3OG{sQxJE|`V@0IVzO0$1u?YDcew}zze2jHXQ~cAwy%#*MkD76ZZ@vi z`{+%m-rse-84yQF(YV)p$KSfUlVH4urD@4h_wR^WFUFDkJBd1}2(x zVRH$3A@pUCBOO7j9v~$iX=QcqSRxY3OZcb3t1YjnNSdy#Wx%|UFeLk%OYk0cP>Ny` znnXFStsbI2Mhc2n%I1;;$~Sg{KL|m|cF+Jsc3idx@oFa~XAj}&kDcAU(gRUkc`-oE zMCbYe0hRD~Hrt$3r9OYoye3-2__ot)Wk+4pXT5@ z|BWa9Cau?}f)r9sD~}C9c(e+hpZTW!q?cDNOmJ`yY`&gwua&BFuq{b{WDTG7Ujb;vT&5x?Teuzq+T z84ljNX_(`zg*iPqH|aAwUaTP-FX=8y(dKx6RH_Y@`0}N|8QMxwFY0FThG;|IkCprO z0r!A}_)Kh%BTPO)fS`omxLbrk&^!6}cUCp27~^i{HPy67`*y=B4h{|~Ltm#&hpP6= z5tuGmPtt!Hj3=Cpwm(7T`yaXAJYb9?k3Zng*io?BJ(yw2L4oGx*WrUM&S%GBPR*W~)bI42Uwbe$zZ{@VO zeDKIZlkSbtRMCr{3+$Frs=o!|w#p%ykFDNWQab1wU9T_3b93EuYlVmDE*#uXq~lRreQsotOd{nDUgX8iVTgnqTgrnr{P%AodDk%)Ub*4CxX#bM|I<#o_J&5wb% z)d!#vvq|EqazryVSm0Xo^_PM`QfbM|$4eG(xeD2Qk~$tI_i@YTO!*|?bA=<0tU4~bq>~lKP^n6p`w0|SApvQdraRGjlzl=V{FfgD_8nQsNeUS!@Y_O) zZV6QeZAxy3@%W$fQY(O`1_MAuUvlYw3Q4@YbOwalDmJEWe_a0P29f!(xh|d;?lyr7 zRn^KPY(|oY6Stk@cW({0ociV@(lyG3661v)WyVPG+3nk75QcBWJ1Xq#O6tT%KGVo5 z=ol!Dl^H?W+fn-aI9n;Kt!K_n#BpRhpD!s6HUdPXsA~!A@uez(U%xGEM2bIV;wm}rmX{t1Ck?Tg%Itw`Y)m& zz{!2bx-^$1-D+K7*#Zw+mL z+VK%Ha2GE>q?Mn2b79rf(@V)5!O=k$&4&w>q(^12yQ%VbdN5h$hHL^)8%#~Qc3MH* zN&_1_D7b~eJ1Ox`g())J;8ZG_lBVE@6edILR`Z2 zDKaJtf6-1tzk;Hkn^GB2)_gBhle6<8beF-;(lK%=+GxwE(P$iuDO3J~!ld)U<-(2% z4Yzs#mxeP_`w_=&y9mW#9TL;;c6`4MyY(jmWH30E*+g$jC;*$9GRI8BZI>(xgAhGx zj&PyV|BgK#wVmKD8R2qd!hEnx-2J#Dxinl6i}VmVG|1Y{Q#aJ4(CWfVom5rgwDZZH zfYrKQA&29$%rr3T0adH;fL=x(Wq}S}d{R+scf@5rH8r-2NGBU*)f!fR$ulie``gJU znSTWuFJ3K}P$WyAvv<>xtLt^1$QlWp10`=;ICJnyzxr$Y!Vhh%k2KilMxtO!g^_S= zc4^6Jvmjom)ewMR|J85b64`gX+!9xDf2t`e+HDs3^oc0eg@SNgC2d9rD!(>{P*4uO z@A1dYKM$#=i1yX~$6`n^4ufU{X)5|~c%j54KrM_4Y14CsEB;i>q$WvI<1@*d3%r+c zj1hCNv`oIh`o&NVOm9|hN3wyaB3C*y1Rq+IyK-F3G)ctCOUIH1H@Ih z`-?4K()#mR2@sJZnLiHaH^ZiyI)Uj)gH}ey?OP!XLeDAynMM8rkCLEM4a@MydwQ%q zykQ7DXd)gS_}6*2?}JtkCQ(prilf>>In#9t4jgingk*V1Ff&N@eQRE)sBQ*PO6L1f z=FMvUUiC zMH>?>ccRsewL|jPYiGaHfY=rfug%VoUg05>wd?4PR|yv*m4CE9J>vt3#k|sA>3D6gv`r;Oy+LTvfLo9vzwUrpT&K zyG`KMIlMvhCq^J{K0^0bRGif7=ov7T+vbvExQ%BW{np@Jx_z{nS6}(QG@L{O8aZ&r z+9i|^3GNB(KiJU$=WDkXJ(ReKx3#q*{q+bH8~;p0xK5GhZ90}QvVVf=_pE&1ySp7! z^LJj-g^f*Gs2IMssUI5$PY*e& zdA0`zVT`k`5^NmHp|l9bw`2d}Jecvr@X>(ZV~KY?Qr_*LXq^QwvHN+9d(ELdqEKyPSHm%Q=)oYAxGc3wyq9B)FRHjyfd71GlrBUKLm=Ixz5hVoc@X= zz3mhG_4jvuhSYF0t_-J|?*!Sr%kUHN4fWbh^{$r^4DAYnF6V!sj}GS+y6gtxy26`3 z;$lPltO`oRO$kWRFOj6kuTp4T&ss$$GuDcbc}mS|%JUFbMutu2>UP+3&JaB`%lzjo zu-2JAPOm!E42Y}3aNW9$L3F;(L(;t?^>&%v^h~sy>?>d^dQ*E`-4cIJnjAJdaO1H5 z%)}rd*t@U6+AB0Pm4bsVKSoJAC;x;9EqYVY;E-WsF;QRO=ZlN-Qzx&aqO_sFm5NGI zQ{k3_1OI&{0hA@5^I|(qxrMK6q+1`KdC{B=R05< zcJd+uYmEere}cr`-rM%+_GEq8Oo$nw)A6C%7<(UQJtaM<#mv^;R>niQ>LV2cQ>N+2 z$jI?u4c$)~_NKX|Nh=!UY3KEf1;OEH>Ao#y%_{vtTtz9hIqbfkVUTKEwKvU<)p}x|7svjZ7QNq}Mlipu zM#GN1>fFv^ZT$+H9fazB)G}P@=`3N)&?9ux?MA=GSy~u__UJNlOmXbzu67+`soLX;w}LgN>h5yI{8mmxl-8_C~|acL-tl_ z5z@3eMKOYe%n^k=r^Vl{I^wJ0`V8~p5-J~v7g@e7+k{482>b6x5NTqw@;1Vr@Gt99 zsaBQ`(i%ngrw|S{a!HhFEudZxJKLa!Q?|MJn@`FIB!(@{yDPVQLhv~M z&Z;c!Zze`rQj*HJU7VfTzhw-DCUwR=#kTfX!VK20P^PLHI#x%|a`L0Lx4z-}E!>Um zCe%YrAli7zup3Q7p|PmASm~SV@2EuF83#Bxjq~vW^b2$1g@k6IE#-#N<~1$pdxml9 zLpAoD1P`P{aJ?i_%p)x;4zb?#RLTfWlEupdNQZxawqHHp(Aa{#?ULJ9m#ZO zO$p1HBl@eEieJ*%uf}KWtyjuq`7&)Lj@Wd<=O^TlOh2`(5)Ia4XR9=BzOhk~IW&WpZY=aq~AgM(?8BG78WzTWX`Y@Hc3ZT6pPL*08QRUq-yA z0J{Ks8NIEKTX+(fCU4}If}PYsy4j=kk}&U$ntk=TqORVbjuPwsT z&Q9MvymV&Zi-AwP+JXO_KIPg}p$7|lM*t=kV%&ys!mVm2<0WA_-8jmY62N+2G}|{Z zwiVPKH-^n*(P&jw`A_@bvj)GWl3Keotq&?R?GsTHmQh%;mU0vKC4sR7y4mgx$d6*h`>Ggluv~MzBi@tz9hHpH2?-H zTHY{rcYk8M#Tt^GK06+0EPcD$?d5G&!dT0mLj~O9XeUgfi3q|a$`+imu#`Ad_azD@ z+!~vNYprIe7f7FB#ohuU-kVC-pYOYPwym3&JVv%zLf1vhGPqsi93@1Uj-HNcj|Jqc#Z-^aj zAn0l-<;EkJF}3c!T;JH3<57hjsXm0%AeHsE(h;Pdj)@|qZD8Ox^u%+Jw?QX7Yw{@k zRAps*{aNM(uf9Jc?j?px-p%*+X<|l*Jukn;$5Xk_^uCfEKPKxhpE0-#$b6~e` zuscxU&d+|PUm^smCL(HLG@qdAgo(l}V{?J3pgi-!6 z3n%ox{M_m6_u%R5!S>Eq`$O`o4|g?Epl}q9NfzgL4!>|Z)0Sn?8?X^Pp+u)c?;qr} z52P?K5`CKS@=)tjVV4;W(aFFnCk3o1nD-zTT{^PaLR&v((RrN@uBG z&1kw+8j2^Nm)0cNPePrr@Tn)SBZ-;hEfizKsQI(y7%gp}^5H=eOu%?r+y@gq_bZf{ z{5*6tJpLOr6%Q8)RnHHZM|UKo7OiIIS%k#7PHDe|=w@3`geql3%GXfIeT;aqYjhe2 z-D7oklv|v^Ln|q|sGK*xXgw?ANBIla%tmdmXg4%XY|bd`&oc-zVGWZO*yeBQ`iw$~ zxd@sd*<+5mM>bhe(*5n=*LYv*xOb^>85Vck)n^wZRUgt=*0m09J~#Hskn#6dp>sk$ zO2i6nX(G3OY2fwoV{EGOwEG(JLlo0m;8!S)6eWobrDU*87iL$O2l4zy?cL3$?%wTL z+w}ESb0YTee*kY3nEn6& literal 45511 zcmXt91yEbx)5QrM+}*XfTZ0E^AwYp*#i6*ndvP!BP^7rKQyhxByF+pN^83$xnR%1R z%YAS5+S%Q+=SHY}lEXkHL4|>V!BCKwhQPqUazHO(021`hFXXNX=of+$NI@L{{dfaR z!lA!W?B%tcpzRm_yI?^~8Sc=V#LhBW&T4jM&TfW|rZ8@9ZXA}jR!+u-_NE+mj^-KX zq9iadR4@wCAJyG6PdnT)$u&LR-^F>Hyq3H!DjR=kmbb|_Q)^m(t&Zkme*yVV>HHdw z^zQP;<>aGt@b~YLq>_Ze&4_V`Vz+J~BzDu*YfETcSQ$-n^7R{AU2F5vU>jb3J#0u% z<1wGeWWMK_yvaNeja312sR5`tVAp>qd1f@dx_*m>9KQpoZ4n4y2smL@bCZ@?gSBA2 zDJ)>mVQnGc+lhxlr=NXf`uV6{I6@Qm*8~w-6FqD^io5Gtp zF|}3yYYOATW16Fn0{u{T@nzP4Dn+R2EbOqh{Mjp zzr%WK1034vJA}pzG3x+wV5+tNf8cg`w^X-Pz{cF^MqbjBl#3Lz#x?qbCj2`}1*~T> zj0HQynrMpOM?Fi9Y06(%Bm7PET0GU4-2h3Y>WWm?n+ zxs_RpBOs`H3)3#-Ia_L>lide5%sG>cKH^fxt<-$VYUw}-U>uty2AHlG#}V)~9oPt` zHp8n1h$oEGh=ctL;`GlqXo2|ZgSF!z1mr`^>G*Z(9I25(QbB25@4G{2j0Y%VTNYgA zR_OyO;5iWp1^mZoj-b+50p2VNx+v5zRi=s`3VG`J>MUI9Bsh&W1t+bX&U!N#@O_+| z&RNSYeVkJmTVY8`dok^=Qo5?;BD2H( zeAWDE08@yK$j{;k%k;&Vpd=i{(sce+7Y(PFW$3a&K&6I354NA;g#|dLP6g+Yf&`pn z0b<*vP3PwyQd#Z%u1ib!;YmOD_NDdV{iLm2LYEncpWr+~$H0WtSSKX`5Yic@g6-*v zrKDz7DVvIqcxW1@5d`obTTVd!8y77uf+!tZagjit;vmA2!Q z4bN1-OWfEY&9}+lUDn<=qy`cKD?50-WDes-Ohoh!bL?7UON0gy?D#3BYGvw784N{^ zA>bmV7Tr5*b$n}`ZKeoEx)@rALTMJ{Bl*InO0tlC9Trl0eDFxT1U)t+&@omOOhblT zD9wai2uEg*$Am1!Zn>-jgxY@dYMnQu6CHXBlmq<}bsa6~|Ef0Vg z^ky&EP6X|-8lbP=<@I)fG=slu_xZ|Q6dxU7V#?*WEmIce=}MEt{vsx7MAG*MMA8n9 zcuXd;LIh@V6`Ua*O~{sf1O)T1DqW(&vqqJt>EI=Cqc#^7KI%ZvTfp19XWvQH^T2RB zaUHNYX(D{rcuBq}4yHBc1D-5e@TFW&JgQDW0bV0nojR%ex+Ijl0BT>#HFWEf9t8+AjA+bM)AyY_w)Mm(<$23)MsQO7>TyWgNzB0 z_rTx7>OPJ=F9gnda=3vqk*U=d(=>PIYePLj$Tbz*F|_f2dmJ(q=ILX0qO{#o+1baf z*W1(BKdj{=!@bGMfeUF5%1`tnVZG=1-jGv-yLq@$>d)6Wj2n}idG?N8X7fL@xJ7$*xmJm|J9 zdjvl`7W{N@g#nYKGB5z~t1ILyZ#8uvAKG{eX~CF++O#pu(#%w!H>ZVr@}Z_J8N{8Z zld6SDk&D2#gi>`#_*I<;q|}q6JvZQHQX)smGu%5*zB7(7XEc6vZ+O4f%jQ`+l~d?{tg&X%^$> z_>}YSQ$c=>D)v#@O6*!RPDq?hrrY?8L;zFmHK5Xl{ zS-bGr_qp(y%v9b&4278J4i9J$+L(Tlm*!adg$*K-qWF%^9Q~sFp{A6}CMuzkfo}SU zj-Rg#L+zu2Pe{VT%U91Y88IDdAM}ZQ z{WeW;6~4;B72!R4$9&_IB2$msh^E$@ zUzXER*VfiVpAKEGLqyls#6+)l6SY!YX3tQl0ihtd7d~uIyFS1H@CS|BmpypVdp1ij z1_;t+4R${V#I|Sw9DX|KFDtXeNf}FqyO@cTh4Y418i`viD+xcBbEg`eS{;F zqZ1byXqDu^EHQ;$)-@t(40fy|IO^j~D__z@z{i4GjV@&L9QTz4l2iaBsbG*HO*|l8 zK1qI2Pqsic|B9%_JyT1M{K}n7c_w0D`@!4SSu>+_Y_lS|TQeY|{S3dmOZkg7;7WDV zYREB-&z;bgsGJai%0D=kmvB)blU` z@Egbzz2wdhp5t!})cwopXGqlj+|<(0-Zg4Assd`!r9h*2 zx7HH>$@xr?t?>=AIX~)tGivGXXRt4Rvl0Ls`3>KFs=Ne^dIB3HJw&F%7_7w>tmQ~| zkMS`_vRMMcT*ESt@O`5nXG*Zt3U23Vn&fy+Fh9L@ErPD`$|eeEir=VC#`H6(DE}}@ zUXY-d-if(}o%B@@sHw3HYNkBEKG5Ea9#L$Hg~V8U?H&nY9_3N9By)rO&jbO~#mUXz zFTvFPE)9sFa1T)UBnq`JRq!HRuol1@p;;PmrGK$Qi4SU@$Owx9ZU?RBY>3>sfx?@- zF3z~A``Munpix&=2~8>n1G{iQnGRzDHAr$K^JaL$!on7omc$wi!MW<$!$X_R+uw8H zyj7VSNZsM}O}<>PIszZEfZJTu(l`&St3Xi+q;o>hD%L9C6d#ny6ZEt=*c5!$*s$|1C|Ar2YDOVkKKumEBG8;7YA{vCF?=p!;VY#ns`Png{>2{%065+IY4@YE-9B#bfL;GANmlz0l`xmwo4>ntLV%+V z#wWL4HhPhyYY&wESX(h=o!IiQ8n^b$wsgB*Nf57?U0>xeW133v04T}_7e;wTHaaB} zrqKVq%tnz}Llw+S9gOwBU778NWD7Xzx{Fb57I@;%{gu>;Ac$a{z4bP1p947tuOh!B ze9yDTi15Q|#}cFzSTq7^l018@a(+BuDLRLFL-$r@Zunii<_3fPjsDVglhW!XlHv=v z1IJ>Bek6^CJ@`u{NdWm!e`6-|T&F4mFRTYyTb};7q>=GzP2y7XAkMz@A1%y164fz+ z2AtFoUovZ5jQ~Ylqk6Zl3Y=szIU_{o#V>9IH~LTD^%uXc{x*qwyT$SHxW69(4s^JE z?}$v?%eLO^)f5k$m83(&-M+bN&kye;?ilvWmyDZh&3P+!$dxdiB}uJ_57d__>8|e@ z%(o@!PP{O&WFHO8gN>h(*tFZj58N(HG}!n(!yshkJ@0@TLM`TCi!WdoFaEso?h=2P zsUvJ{!t-%EWY6|m?y0keMDyKjrG|}v%ZNlySI(ZJyd0`uu={<&g;rB7C~b*ObOOvf z&RFnvXvYUT#1*KeOPcgFN*P5ClHwp{F3L&da-rRPCWO~Qa96D;b9E7C@ryW|nSb2b4emM(%dN7ZTmCOy@%#K6Cd6n%#QPMAF|5){VL78WhgI zX++(BAHd$c^}FnsOZscF+l!_{-&b-0vc!J;*dh6OdJ7vH`kcv`nYHmsy|$(6zi2U< z?`A)8VB7rVf`RW5UInf!Mc2(nmkS}lcO>1I=Uji)i!14if9lUzus33J7r%|~ln-z6 zl2~Bh(Y&!Wo!`mNQ*9A11*=oAx!HEg!cM-YKfv2J0=G}P-TXHeOcc|XCrxk`8?*31 zO=T0kp_Pe>SQzC#-*Iq=H72C*iiacQl@|w<=o)KG1hVqt(tv*ightLv^=odajJ`z*RHXp3Bm5YL#h_Fj$w4p}W7$&?}$g%Ba z37^cnzm<^(>H-~Ca5+ooM4hTw6e-1_tu7qe77ljzkOS@>`lfhU)qK4UsmK}d5^)oq zx<3QzOlG!zO3+))R}40?Jv}3b4;bs#?}2#Fem-1=L%R$`VB~c)-W}onwX?HMOo2;7 zRIT4h!n?#Bd(oLSTt(!zzoN;3nEpNt{AH@xCMqra?RE<@x><3 zS8ddGCFVJf;AT|Kf1TLwgLOSVu$p58#uFa#nr|PvFFN?UA{4#n-o(Uap1*LU)}>c! z$I!xtOgUe-unltsbEPc{i~z-{Rh4P9=T1qf%Z{KhFMBtjfC$Op7Izn6OQ_NK9 z#Flz7Xd(8^ocqfSr?XFzuoiv;9#v>jWjc3m++?iqx&wWsCGDiAE4^yn>z8({-{zrE zJm1m;YZO&qpi=wp`&{<;bcKB=D$Y6xZ~=w;JKlhm)DM=^uLqBwJPQRm5-VPPCC~`i zBrUe3%ftIrz@};6erYmmAa#lrpQ>)E+PyaM?QN8n^6$NIxlmq?bn4f=52n9PdYRJ8 z`rWF4*Fv6U;5Cz~8t?s^Itz-=al3JiW4db0IvPLE6Wpsv)Led9^j z!Vwmhdc_;ObvQ_uHOeqT{j07b*)k}!Ot4%HUl!EoT;+V5m1C{F;$Iw1Us*bBMO-gT zjkJTNn%)iRyW82}j;#r;FI#yWKK^8Xib5GuZp0zn&o(Icb{CYK;pZDE#-_(qT``hW z$jb~%9-o)3YNNzaqx|{j_pufRwa+C%8X{$aYz|zf0AXB5oQ6>@m$EtZK277Od)`E@ zgfIAB8kwQd2iNcV8}e+YQeO!qUZ?#uNhilPYd`6XVK1tX9Bs?CxrOZcLXiN$fUV%uwr z{p3=JrfnqAP`$U-wUxK*LwlnN#Z78Y46uQZ+=EMB`u#eFuCht^!3 zQS*aE{4Wna=-0YvMT^l#l;kURTXo7tY0th_teQMaW$aW_(qtS4`p?5k?B`e z%UICO`@iV8;vwG|a0)e@SGYTGsQI-P5uxkxwF?o!EyEKA?aoL4eyeesLc|0R<@ji{A~{yPb* zrUo35_+ogslKRX>gIPFv7ns$gsCf5U5Sky!V&|Yn{Cc3J4KDP6G92mymPH)YtKnEt zz*Kcqna5W<>9K}^tWvMwxKpXWmEOW7=|y=#SKU10c+`YCQ@6 zP9#mEN_Lcc1b5VoopF87@ix(9`!X1%N2tI1a9ncHc8%6u;$SyD^hsemy)PoDII_MN zMQP^sqeb#|&HHsMF4-Oqo*J49MT|jCGH|g`j7^ofNSAcMWS2LzkU^KFDSPsuRZ87S za-L*oh~%&+sc`1VF!}Gr&5j@rH9}o@ec1!tIi5JYpj%9{nNX6+6el{EUI6@qiLg5j zTP?FOE*)#A5qlkw4f!ruKOQCj9nMIt*_C^ZQWq{crAv&pY8;q?ex7V1ie;6bkYJDW~_+{o|l-wzb{&iL3v&;oKhOodP+*x zbNmd~nQk^ZsI%375G8APg&m_S+hS_cfpsy>qUe6A2jNyJQan+ZIgYUd z!uWZ#qFxD^k{Zs0Jc*q!NeS5(^9X9bgV9W_GDX`&+kc(OhGb{zmtIW`pvM%ra#znFON)=e>n zMwX6MfmGB*K&~!@Sa11>t;v@>OQ(L9S`kiUeZ&`nORp7kn4!!eyJ8iHDO`ZRBbgjP zl7QPHnftH6&hB^#y%IJNwG*=(B5r0(A;a>4AWoM7X-ennx4`eK_aB*?P=*{hSqp+b z9Hs|2TL%N>a-#Qnd&nHJbfxX31fMnTK1siTCA~x#OCvD3qOgz31zpRqa!CUnm(plC zprc^2!_!Tp;YpD82=94{3Z(mNf~+(%h6D#YbQO+9WkJX+a)rATt%jMxpD&(~BEy8& zyZ`6UcP(XSvIRALrz|CN?!6K%vd_BdW}AXC!9bpjb$gQkV3=Yao>EF1T{7TLK@+V#^}AW!xA0d+mQeYu=1rOE&S#p~dSB#hR{r!Po^c;wQ5Kt8NbgWAV%)+3l2<8|Y z@u_7r^z}jyR-2Ghef5dRd23$v`!k8@ENswXLAc^_U3PQfREI|Z+zhW?)qVQ6KsoN7 zuRkmO)svfxox(U-_kV?xYaF(oVCEeyUuCI0(ey*-%$?4@PK`Fq7Ix30A_vr8#A-GF z?5MGm1p70YJ9G;yqLzTCRvzD4>6O?$m!#$kE{bsKI1Y_T;!i)9NMM^Up*K^~O)=%- z6%00ASvR?lKSJqClrDcq3q>?Qls^KZgjs&KrJw~)g1uoaAOnmld+EEKwEedXn;<(q z*vT!k*>kTv;liUe*NLg923anmURA_gk-?!h3;m+fNNb2>n1vwbSG`@|^XxZPm z0b3b({9w$TE8&yh_`p%0LF_mSRNiP4MYSiOR`JU*v}r!Qu8Fc&Y|C}BjwN(vSy_D6 zy;_mUY7(XDl%!zE85iEI;(gq7eipKrggGWd+ivM#NoEBqB9qrp7v9+gT+A>b@8+y% z()mO%Juwl{_Aq14?hD#PA2++FmsiUxR#RIg{<+;%ctTHh%+I7|U)P)Q)1|u9)OM4b zW*-PM+i00W-L9_~!g(KddJF?^aNN)Rhj<-kdOzQ76oOS>kt)x<^1-vu2qGUO%kqrd z>ebMD&?FC;%5jt1>{e|x(!O!3B1}mGRHkm0ykeOv4)820NMA*OLqb0{Be5a(Sc=jq zHqbJFLJ`EjgyhT4F_snS#Gk+Mv}x5vL3;zjxar+B&O8QLimjUean_F1a^AcYX zUJ|}>N-wFYa+-HAz%9$0S*_FpLBLC7`$AHPc3J6gnXBd3x!5KmhSs|j9-&naq9K40 zVg^^nf(mLsbLb9U180b2U?3izO+*|&;oJ2E0I_e*wRqgfr_~s=?fG<6TG!mBCRNnr z{62jA-isf*cZu+qd0F+x5QSG%-K4medW(7|*{_4xT~G|RIB>N67VcNf&T^}t2cY9z z$&^A?!))Jx1+E-89Vtm*jb!VMG>gVRE;W-m*Q3J81=6kaokA^&1*V$nsI%agZTS@^ zR?D)JBd?HoILGXK(@7|fG>}q7{n6N4Ll^VA+9pE7p?ZYA0u0N-fL-3deejm*Z;S(I zy^))97%_S^8Vv5An|HMz2}*(pe$r4*szjot|Kw6H?U@#zb+lJWF5((RTdCA?WSO$z zbv5>3hsa^Gwn(zP>6U2pg1oAWf)v#Kam#@Bv%%$uS)A69jo7hO{?^8+=>$7C1dDjL z+J|{UUL)!I`3t`fc&HsBV!M_Hd)ieIQMCfgDIqr6S}A-ywPn=o%=9UG^c(>@f?6@V z_U42Gx&*9iVLZIyU^gT5`WeB+fXNzQdZ^*ygEvxuWL$Kr{@~^}zXnAooCWC+DJiv# zRA_OnSE)3PkDo(3OY|#y>UZz{7_P&kGqK}|u5cB&N?2P-G~3<|R-{~3^Op{S8rGf# z1bZw-syC1=C`K$_ap&RWv|!BW;Fc#}LP&DDBdzrS(sCcApy*>x3iu zlt8*_NP;(aI*od?4lR9ce-)jDl)jFP$_cm_%dI^U5>xcJSpM23>^`X(1U9M068IIt zS#QEK<{M9IovJVif^=)0pS-8|+5+{5^F&O89f5yAO<)VNb^5YxDp_9`gGS_npV`$I zE48``!?iI#>vbbW={fW)1ohb}pPoFoYlI7v7Go5nf`Z^hyLMVE{rtN7$+KhxStdQ0 z@nZzuzq_kX*I8kd{{ZLpqla7F8S(koddcE{9~KDUM7aFWeU3XFFHiTE6g@1g$@FUW zJ=f|BO5a!>#hLP#|JMR2pygTf4uR@^943o;G6$&=^=lsX{rQ)#DT{lRK(9zdMrJg= z%(r_+c2&eYq2&YX=j$z^!_oTFn|g9w;_=A-Rgww@U_F}6r7aW_L@V~YKckw1*T#L_ zs71FJa#u{|d5*ti?aEMy2#tE`)qL?91uAr)ey_cvcaEESaF8@T2pK~wge{22$Q*ym z3E0!HDI5N<9dR6$#Epv*77AZ3_=pY?W;*Nlb9OHGH{732I>Sk@p;2nG{ux&*M${r+ zPfPUbJy5PcP?V}S@!9X%xbr4w;~>M}9jnr7ht&PB2N{4UHI}jPr&3R3*sRvs#RY@% z;O4RUWh50BfWXP_K_qIvSHMNgY&DHx;2)8g5TMD;6a)Oms3@Y_<$n3Ye|;8>nQ zr7Q-;w6Yk6gL?no{j;TYrhxI}qfk^I4pr_c2_Fd(!6j^=FU$qmsjuGkTI}TmYgxgW7JS48aGTL6L=uK~8UkppVe?F_L^;Z=#_W z6Y_80=X-kSjvy{rBW6b>DUj#=*sf(OpWto(zP#G*?b;-jhtVPH6mtwxfs`w&JbSDU z?@8X=SoJOzpH*Wcf{PhKCb|s=7(w+YX5iS;dZ-|SH8li83&A51(|j(k-Z^~*3rLC~5n&M@7udeC=^Uro3X!Nw0S_&JkIB;p1W2RFBt z>5U>3k*`A8@~6DYbsf4KSc5xPSn|vp$AS|qLk{(ZSZ<@jwbLNGjekMf=daVe0mcjK ztg)?lPyo+&mCz9Z>v|xqKA(0D%SYzC+{fgEK!+Hd16;2RU~vEk5pr$cWmoumMcx<*32?{Dbr5O>#nt=r9EUr2R_*rt?5$JghF{Sh z5*b`v4hnWAmx$@42ibkkSz~6~wVv41?0|P1{}O+@%%}`zTlPPt zxn;PM^E<_h5^gbEY2vGWd=0d5)3e~; zUd`jCdY?Zos3kVi_p`+c>>7f$6Tlen9V)*X#T22{s(c@I3l~jIyY6R0oV87a?#ss* zAu@YtMw_OTpfr~VE>bVcTL;r6G;Z;*i05=|-alWrnmM0@cCyARiJ#v;-xEd-R0g~S zG{(N1A+uh%4{f~M^vXnvH&|?eApgxqpat(&QjdR#r2F2Z85m=?WYfWX8;vJ@){bV zLE^}O?;Vxphlxn}N#@!&?I=DiW-a|Lg!Um{-d*h_IyYb_#L~!r$kKG_Roid1i7c-$ zu2M!wi{7%!l;!CcLvCGZ(&{n#m>#`5^EWOgk6PD_AG{~&)k+z?L#rCJ*j$}mT`696 z8O1%@_qDTu8K)~7cbYg40rx{qc2Da%N;5Ai(B;zvDOD=$QI04BmwE`{5B1h71p|XY z)GzDbVEvuRz{Mf;N)uXjp)q}7!)A3({R1Zb1G6}q=H`ST07vVC5ryw%kHd3O(q*Gx zZml2k5wh<`AD`C;Vf_`J2HZ@uhaXMe#P*b&N6q&Uz4-%*;vQ$D>+Zh%iTYoe@Zelr zP*ym-WpXx{o?Zho4T-#a!l2HQ(s#p09A0^*S_v0B>YFSr`a^G0FZ0Njr{fk9 z_ZHpblxT{W2Wuz1m!++3o(j|0lQc2s?`SI{#~gvGfVVf;yYr>UV$z*(1+c>An-0^R z+sx`}lxg(irsw+Y`EdmuhyCyg>&(3H$L3?cs*&FEiT16HE(-l7Lt~cIQJ2meayyY} zgZraEIgZN8RgZ%#?5>R*b?{soNIlrnjC^Rg{b{bs_oLq;rTd1LZ)Ao?W(L$jRdFic zBo;xA@*P{q<}n0#om#9R9H~RhbP2W>kb#L~{*Ip*0MnrbhRYOD(x^nXCI zQ<}_khOb~;T>jR|C6I;oH_dro-^;KSyXUv7))+z&2L1^}z83*vYdbm<;mOD0@Y3Zw zs4D5xeNlXV$B;s!3jRDDDV%(GaSZ@YMH z&nvyqb6qm!p%8lA7w8h|G8u_Z``0Z~WMt{oqN}gRq4AY%6rEkaHaz7K%|f0Y*gE*s zU{zxiW}fX4YC5VJH)>Wx9wz2>_wC`u+M`sYsk7mCvIQHMen#;?Ij7fP0-KMQnDDC% zVET7bE9I=F?^T9QNwm!U+r6K)D(9~pTukJJ{+$}7&!7E<&etY4+@8;xCVyz@B`WGV zdJeT3_hgp2KmAXzqVIWBlo5R*(;)DN+pb38eg(DQ>;-JUa3$|Ayh2#7%=Kd z1<%)+t$l?uw&B4b>y6H=*XR2JOA?nWq9O=l*T!VF&+|uSl8kiwBq?5kVimSJ`z;V^ z2u+Hy8ndQWhbIPfEC||M&kIYNnm*vgcvG|-i{w0xk(!GR9sRcRd45hP-MvL4j|VfpRSQasAH* zzV3YXdzwju9KJX2ZI9}Qsxy}z(S&BD4jOOe%cwJ6EaX3B_n#bVHTjBNxvxb%ZT?qt z=lyN-yS||jX?wW!cERsW@nF|!>1K3qBoy4zPDg~wuwC<$ffu8XaI^Mif|ek%#^>3U z!uP?jb_pHU52%M*$V0sUL96=-gY@$874O>P?qXv!fj&~Z-kuA8hAwrKhnG`c5Ql*X zU4=^-DJ;~&)|v(fm4|n?_}3w2Y;tEecU+&2K3cBss15kB0w|Y*8VX-lMF_rC-2Pz3U9Y{h^-YuZZrLQ z9)saNW_#RebF^=YvfxL;|3>~ph^o$(7;T<40G+lazfG7hOmb-pMJ=B}7P29;_qQ*+ zhH(|2?U(jGKyy`6Eb)K9+fpQcYh5f!b2ot^NQ5NSpITEzWx6Q#0fMRa+<9D zwgsB6&>t^W&VUB)(gmu4JutuQ+z^OE1w9k%G88bzXD?#Nab zA>4>am{%o~mCL&P6NFXSb$ZPjHH*N($s^`t*ChhMYN3*z2>tK$dVsMuU4jCK zPGc1G&-1nmanKe(hoc>)&wOg$H7?-oqxFhePksoxS?%s$DFi9%^z?M5WY+&AQ9}-b z&!=@E#g?S5XR9tVy+w*ECq^~zP2cCPbK0+>?Z^l|erS6zeYaLTF>f@DY~KrAIEV5v zSreDt@K}y_OXgRh0`2jGgB~VMLQ#+i3pScYYmcKQ@wcm38yk!8U)(du%d z3bw!KzyhMT;lyoF<`&f9)nkULO|3LI|sj*IM}yUOu*Zwf-@$tLGJ%UYi@}!;%>5Y5ek~^6S8ly-@}F|913~ zr>Dht+rbi2br#dR)0NoDBR0KO1Z4oY2tnjdkLiA zk&Am=6uCpnL&}8-wj2|mWut*77X!+}Lr-}xr~CN-AiU!RM9DKbRJ=0k^8;Agfv z6<+aC+^FfHgq~`}tkud#qiLehyqVcmX`1-Lf{rY)Hn%$WE1ctPt_h!E#lyqXZx`!6qOY@RCQgVc z9}Hx7N+XFpGX;7)!d$5$(h&JRhf z$&qA3X$OKa_C{RWHAG=6A`c6G9RXUrU>_;5C8d=0_4Vr`&{umrUtLlG+x}X%Mu|5; zLIXz>zxB?n%5#qO+e$a6vhMTDqF`*>d21q6PW$#`V`se43D3*Ne-%XOja9<%XW4$G zWU?a@{<1XI_a89s>00ycwTf5oy-@vF2{GN7tagdb#^yJfsC#&JHpO)aoVXq%5$d#W za~99!>Yp^yNjj2f`};MwImgoPx7LfgURoT_qKvIrh&)8d>vQ+&?GOOkkx1ad)-FaUlyHqa#3u?H~g-53eIofu|%tJ-F;l1_forFAfwz>tf^ofns^H*I-Cd^>D-d0g<7RH z4Z!Ui?gL5tCMR$)Dy{vi25xMy8rhKHN~2At+j({)B!v9{xt(9AIeZQQZ++gGzDU>TQK5?>0No|59IH#EKs3JR*w ztqDZq5RCPg=)OCPRb$aSJUgRJopjntiEKVK)x2CRi2duC8-07Skf_A)vnw}b;*Mkc zN-!@sN1FTNXdogUn0|Q~lUq>mPkzXarR8^;G6k{{A^((GM196FK@1i^~8d)()ciL=PSpOY&5e!u9YI=XFxeA`iidE z`2s#Z-nL$H#P;#&uxOPPPTYDVZ?mwq%-3aB(@Zt7=ah2OB)r+@Q!&WNZD~Q#TWGoO ze4cg*f^H*uCL*fM`$Vhuot+)wRs6hp2lMW9y{}u65)ke4e6Omh zIRxDy7S`Vx5?vL_&bncrJiY!D&m@8A(fg`>#QivkP|oDXtR9q$)Su>|{zWu3*$tJb zSi41$`SxxZAsozA>L8vqT@cw<#sk5du9x4oH*J-jf z9T-VQ=wNH#RDMj8-e$qO{^I6#FJRzrmDR_!-B9IomNsniYKIoGo#5C)H*cpkIg-q( zK)2n$;{qLP-`jG7nd#||f_Na@zXArb4eNCIpSZ{>|gyW;NzOQgW$&vCU5c=0+#o^80tX&HL&3<-zN{(J7Z8Nlt%S zeAJJ%z7#2E_LozJ^Of4lbRoQZkXR*_fWt&iC4#7yA%@d`ap>(cSo0aV{4_a^*%0g-t02Z*d+)d`Ye8R;Fjgq z6H=wXkccq{;tLV!hn9}wMyTV#ju#y(OsQ-BiT4|R@4r0P^wwV9?we}9^}xN=yRbqf z)CG6Y4YAayES~c|A13jVcQyYalKFP&uAz>IDD)}cOA}Tcc z;{M30-!r07xuM38wf}hFR_i`&1od+qqVL|qZLQ(beT$H*O|g~mp>3j2D_gx*6Rt_o zrl5v$&HvWt@m%?|bJj#9MYhkK_Wq=u+12&{0z546M^6B3dPYXIQldOBSdfg~fQg$| zuzzzC*s<2ZrqdZUo-wf{X~kOPm}XQeZDmCo(JBnr157Wj5pT>63d6*~kh^^LIZPkS z))Vn~YcW4Mb}Y#2H*zq#5*%k|ulU+Q(j_4;o=TngX=Y)iZ#_%o=;VSvV_3zNp84qJ z5j9U`SCTuqy>5Nsp`q=fv+agXVsHj-&|Lh6_~1a|J%<%xHA}wu*w7Ps_VxKLc677O z=lRaz7L!uEzbD8BH|A4J*0mZNfx0KtYx#n{&m2l@i+EU?;kR77SVJNqTsaQ_Isn6o6 zB@MSQUU#Q^cPqA13ocNq1ZpPqBmp$G4=6s_t<#2LyR3S?}I67^L%#eQtfbHw%M4u2o zVM7fO{TpB3&|vtLpD@#n1L~~wTTRix089$ol2>~XtNBX9tNZ}~0$7+#*gdX}-&RtH zALAB-O}jD4s1ziexFdN2+nWbKgQAGzBR4c7JaQ%(t)1o#l2J@Szvm+g4<&<%^%jyR zFIdBRx9&`Q`g{W7-ZP-+Cw5jmmpK9~iMJY>-sv_~4ESPq63e!6SC+V#p$0u#_kNsQ zer{0je&rFZtZY&%gx>cJ>O^#1mx_Y>49SM5b3S}qx~oQgfW~a9Y`fZZW*G7E{kP&5 zhg3j7g8Xca-G(?z%0O#_)ikew(6JPjn6#4$_xJB)sW43AbcRqv;QcCAnJplue%Mr3fhF-%A_a*_wV%H=f28G? zDLy@7@f>3GkXBIqlvKRMzZJii9ZE{Ufcq7dMAOBerVsyoG|ziS7dTV1tuf^gijrE) z#?!4tRzxlY&^Lal`@kP5r5|Mbq(HMrD8q2|jG;6mJ;RHxOiK}aouGX1ABy(IGeLw` z9frtx$Eo%{99OEuO8_xI3FINq}Z*WR^sStugHMUiXyWR>W4c z+RQMLg~T9U~43Oi^%8Q4R0kXe^D)Fd(39_pFGp$E=W z$t`Icr7h+6^jvLEg3^fYS*$WyE)xt!S4_ze(?z+mlJdxZQ$VSpS7>*vS7c`pLbvLI z^1d0cXuO*+;k*n(dA`m^x{a?e!NBqEssKtj0l0VMhf1K)Z^#HXsL($ITx#C_gz}AI z3dy>EoTvdc4qVy+3MZa1kryXdW5u)*UVC;%l;Cy;5{u* zq_?nC=SG=c94}vdczkN|9`I_tSRF7pC~G|mVjh^tnl#o)82!){ti&J%t&}v{`DMPn ziL>A@+=$|#;@qfrXtl>!2!dL4Y0l!+84|DLzx(TQL^|tsN%e7NLd!=)m@?V7a)APq zRu&IcI?yw6g{B(msL+EXa1u!S%tc6|%zv)rPuQD-=TWt~`MO)0Q8drtIgsxz-|O!8 zuN?IDUf-WH+s4ET=4wrsQpiPO?yZA^VNl|xK=2qzNkx)*A--FR0UvDgypQgR*ljE= zEfwGmA8YFCReJx{hV+LDK4U6m_GhpS*P5KA`?Re*zB-r}*08N`$FqyHUMyJY-%sdG zWP0&Ejopae3r)fzH{&$t&7b&-8z>CT+N@D8}tAUSeKv|;==UH z-!*iXg}`lE#)s3cLBh&~Ei7hK_zUE>+`BgiDp+d`Fb3Nqehx!`J)$V1Cz9v8t!P3=D@SN7RYqacP;EpF9cti>>sT$R?T^n=WF5K@y8r zN4o#71wfY(vGt&!bEfDg{7K&Z0eV;+aUG!@!+`g=<(pi9#zQY(QBrLP5I;AYSNq$( z-)ebB)qEr0j(N%~Pam$+zn#G4Hv`1%fu_Y@SxrnFMp=^0aM?U!uRa&c&9<*3eY}-A z(=9lYH$I$J4E5~d3#g3+f9uD<#|!p<@($}ejBlG5GXFti9rgS50m;{bwm zNK2Pf7Iyn$>ed7-m-frb86~Z z$vcSPk1yE%By)Gna`uo?%XEU=8_4U(69{$Rk7NrzX+L&#e?Nk?Sfv ze$%{9Q^t8ZV!5W<7Xyj5-$(s0YzgBR(I+%PV+}?UMHe(V^MyP8pdFlL`2&?fOwS81 zrI$UvH}~WSuHCNR-|R0xbMNR@LoL3v%T1lmB0>DvJtW+u!D$9- ztbBTJZ_md(vvV0w)I4`QrQ-g0{T9L29||K|yT3}161*s-bUjf|4zl<~^7x#>d9W)j zP-#y?Q7Xn7uil?T8GpWG;KUifpGTU+AnEC_*y`gZ?`g9f(*hGWvvu63(^(_x1;!S%dx~Q`BxMnn7;fx9UUFMuA6%y#;loFtpNOL zP1h1j>|d>oVPicW@xA?H-z4;kIg?JK{7De?k-yTvF(3bWd+WA5sE>|5j>DZ#Cc(n8 z{8Itv(3Z6?N1s`8|7=w;mJj9s2Vh=Z9eRZwB$z#vB<@MOa_IH}?pea6OKv~) z!NWCF@8Si7X2qW=bO1M!4}1)&s@wIRVyqfiop`KgxU74mir4gSDHX3ZUGMgBSpS9r z{O-8Hm6=qLfkN>FIa~9Ux@w79v0WQbl_aaAtbO{5v5#iPTl8^ifgiyjvz+L+(Ssrt zZj$P-Ft5U01zlI!xI&Hq*#oj=i)Hf$>W1J)=%IM+#diL|_d+Mm+77+i_wK*E-x(_( zedrc0v|^9C^V-eB45{0u)F@y1fpU{CHuk6c?+fkKV>|HM-x~B@l^w>cDm(29_3Bb| zP{|(}+}p>nh!isFGOpaWT_L_p>889`J+r;WBR@6yQLIrO(0EM~5*6nav0QGg(A}ad zbUW80wfD(~PyvUuhxx-X*Y)JXnn7lc8>;1+gZ^E5#aNr&cERhfNclnC%w`OE%`T5m zFY@i4kJBtzlbFEJ&`@&n_XVq~3_0q$7d6UxLrA;jduk9q)Dzf2)g-@mJ#6#>Cp5a_TqRm{oSwa_sDdUpMN99R0=^KcXU#@?JP=b z4N8#<Dp5$oiVWbihc17Mk=S zI@hMv^3Bl`_`u9)Xa6_$VaG`zx`5x1Mqk0h!I9X<0k8Z2`@?T}mOVko&z8i=26U2T5;}|v*=SA^S@XA;_v(1J(_%a55uah3o)Bg2 z5fmhIOdWd5O@)Rg2L9-eKc59Ep8$7_EDPRHqVsIHUi@dpDAe5G6U4c(9v=U~2Us;| z>wk8^-++i}=Z0iQ7ZFV9MO*QL!n}IN!ppfH`Qyij+nvV!X7m-@aJ~}vND@JuXDlwP zQ5YsUX@=!Pc}L&ahj5hX`Z*#zSo^Y$48H4IfMIxt@>d!3(12T)i;9RquQ!?Rp4vXW zMMvwR2zM8-N`neiqw+H@M(?uL&K;qkzebjz`jm%Z0d%1BtJ8*1o^wg;C25LNqQHUx zDdw%MCjGUwddGoqr{_-j`dCaYj|hRqAH~E>ZLIR7Jfw0 z^Vnaf!D-QwH*@JO8o4A9lyN7DR>ne7&6!vygOrWim}XHtrl=yv`^nJ5Rl-4)OqQsE z7PS*#k`ZOQAd!@ag18I<2a~{X=;_(-fUV6|`Dcx&CnYBePcYH7Gdm|7b0&PuH**Ai z%qww=k}SwItE?95{w(=jqvV$eTrBdsbi3nlBAp?{pGyS7o#l%H@xvWSE(8st3KmF3dk@uNq#zun%9dfdmLic@IL5XR$2oR;>pce-Fvcb!Nv z=&tZat%Yw$7*tTDJEd3HK80kK8}X*`Qo@k^r!qftCN4GaI*zV`hmQ|n)Vls3e~=-o z;*!^dWT|1qaG8T^uP9Xbk&`C13~>>R&xd^Tt)7&Z)tl7vLlsN9C!Yh ze3eRp&t5ov-VRgea8Z5nUC?g(^Zh&w%$|lXwJ=2fEw^D~Vi^U~@=Sz+q7%&u&LqJL z-q=~pv8Q-Q{pO0!kUx`8mjmiE8oYKiYYuNtJOk0DQ*ES&KAz+;->3&OQPQI!5UQ@WFZvvB5`?zTkDpfgB|7#= z!G?mjio$WjU%wiqqoq??zaP3381Z+z{=XNRCi}u8+=~27W zLYkAwxD-^meZU0%%UAo}f(4al2 zQDPzKN&bGRPmf1(5KbHv3tA!R>Rgd1NcvbwAn(kurrf1(sC4V{QrvOmzc~S&8m`{a zOE#1gTailVVPseK!X>HCNK_QJZ{sGbC68OIMImI^Tz-ZG$&*BUgv2?K5k~3Vz8;9* zd0_IYbbq8+S4QPB`#veUR7TBn>!53P#HodJwGvmp9cnxu94d&2JsA47$>Ws`4Uuu< z(lMzr@H;7r>Dv$rLaRi6qJ(=oD#4wCnL<~QoKIL_nzV3{5Q#w*$Yl6F5^twp89!?S6MP^o0VUlgIzub(C>R?irR3TQ5fc_EGOOvz%GB%QwSNIqeAJ;LAR+O;%s;C|da ztOfY8Uu-lZ(YpZa>NN?_LqrADl-a+bCWE(U_W_LPy|}{@QJ1QKcXecM(#?782z2S1 ztMS>~DKRp5G|E3w)cx_dFo3u-(l5Ny%L&Q5mp{DwtXbja@a57W)dIisfsHPweZvE4 z(*<^ZdYB69N8%_?7kU9E%dp&CA)B!u(29c1;aUwtc_W2iM~ImE>`oNCu8rkNn)2cT?$$FE74vWiwRY)|3;1Mf73}ctN?FJWpP4ZE`$Ec(mP9PWT1h&> zbtuTaR>6)@UrN@l=lN2^xRK7dKp}dR!?hbA6-n~W`hnUAM0wr7k#w*xU*ai!z4@rV zsmn3-Xbbu&_jdsoM6Z*cIQ5ur%tx%D!UXr3{*Ou3TZ2i3E;c`0PmH(S5~6xeSaYaM zU?e!mcXkKgp0_$1W*Rp&E36powk*oonLZfA>E|z!c5L6GP!!FK5?efj@HeJnZtF%v zL(YO2pQ-$u>79hzQUiep!5an4r)Uu#1P^3 zZ~X*aB+Jr{6!vJFCRxYwCL2bu%VzZH3Whu)cJ+ zmV0_uf86{DB>-lD2g3sCj1!jm)Z;K`W8LMtF{=2~mWX4YD;>Mq{DS8NpMV}vEX!8# zAysBivYKO#xLZojPS#(hu>*5Z9=S6%6?g=|j>;7#q7%;(@`G0C5z8iqX|^7RoYcrO zavbCCNjR*W<1f)ETO9SJF6y0ee(QWN^KX|BD?>F>1v zg#`1+w^Kb>@7vB!T8k-qIb&AdVHhM!>XJu9Ley#AHM7R;yvq`drF$346}K7TUZt=! zgnnA)Ry!uIcQ>+%TU_8NEC3>GzFD4*b>hrx+t!eXvUt3-WttQWo-wNG?66x3%`A}g zBoy_^k?ZIa`P)OfA6Ix)N-Mq@bfhwIV@@gBX@nQy60AJ)%ApAH!N!H+mKaR+pFE#+ z|1gC&eRniVr65M3GR{MM&rE52rX1Ga5~($_@21@>1AjZ5t6wF9=&kDS7TFTjfOspZ zAx|71Q?h{t%K2vcOMFF(3d`HG9x6sXJdGr^A<5I)deRF{`|Ba8Yceq(tK&4wnQ8sg zc7X@MgvWtNe%1_QGIpLYIK^Ln<3sOHHD-J`tinz`8*}0o0un-)Q|MeI>e{`c-Zm0% zN_VnKx9sPgBd~Y;jwH?3{dGXvV$dFblSVdjl(3207PQ@0Rv(GZfaSMWPGoDRH|Dk9 z7Ss1HvgGI}=9j6D$vknHD^pO9dr8x<+%A94K1F5Mo2r6Ya8!ThHUH;LTZJxn;nDoF zmjy!_<`JN9>pPSYE8mgYsIzoYNW)(qSK}$@;wfK~7(XGGfludEf9T3mD*5eA`8buV ze5Zk-TCze(v^f#)W7_Z_!^3>N8ngF|HZJcKCZwwv~5BnSQEQ*Z;oN1~QD^<6$#< zq4Kj!T$0}^_VpOU`Yn1qB`_rAJ&OmgKcyYKL0ME^1P#1v*(k^Ao__dKHIJh%7($3w3(`JKkePFHA4(w>!Djz$#vDynG9)wLVAOD@pj~qclnN8p*=J^e=s8-<&Mx z$Ie)W{hFcY&5IVlFI?|=&fhP=sfw9gYb(%CDNlVHYc^;?9{mi<)sZ+xpKyz0rozob zEXg>}&6J*%)2ymFv(%9$+N0flEZ)m-m{L@m{U4RVg%i~?*Z7bfmOq<*!5Ya4N_YE& z#ybqf-jVBjKQGhqsZ$tZCj#76-?!eq@fmZupyGkQO`17aXcTq)(p-^VAwTY(gh!f_ zrmoGF!h!|GAt8H8&%568%UjIIw34hSO^t)jYA}frsDeq7`!}V7vKXoN-@{w7Q&LEo z0#7^yfqsd9#M;joboC&u+J-M;pMh3M z{I0aC;CA&j&iNax&8TTh>`{)FWA%93$F!V@jtSp9UEU2*R0&k^6a}GGIL7R>hV(;` z{a&)Lnno8tw`U>z`s(33%{=gLRPhW_-m$Om6GQo_fY9-0@VPADhfh~6>pcTyYE z8Jyy9|$(Ju?T18CW>?>BC0#vqo)QqOgE3n-cTvM&5I&A+tcFV zz$EF%;x|$bxM4z5xAt9{SA_!ZnRYzCF8i-~R=&-oYgBP%Hmtws;&J_L+1ub6d9PR0 zPT5JYHmBngqy7A8jBtofCd!|{*L?W79mU`qYq6@*A1Qr!+&o*j@v3i84h8# z!_CAo4~sR&6~?+gq}|VlrlvSVwz@-{_m&T!ig8=vm~)NV4QBlxX9RL<9A=O^RMZz# zIWGdgnET7x>gst?RPTltyE711!oF6dd1$EEz_r?;@2|3@artuJ(pEgGFR`zUR%jmQ z3dO#rcZY=VoSlbP*4q1rDJo5yD_efy8uuQIoL22!IT(!|KJ3-bpwoC*iew!8TI=ev zP>>ll!(&#BT9p7L-CB!8wc65Gj5K`OyitmmuLvZ?A|%E7hI=q^!mAy#qQkACanyQT zy7mINxXZfmK)v|teg@5bXQ8lj3?BQFEDYsUTbvhI-8bELzT#50(WAvH4&HW3{#)q} zGmUT;huLNCyW`jn1aYT$7u55 z3wo6V`FlGuS=%Xk1sZhuw%d!?8(KE1ghX*O7^>YJ5@km@kw=D3yfv?07XL-lA)O&W zGSMPS5s_?Vqn5H)`{Et4#u9OHA(7kYQp8hPVpL__8-+aF>?J;am)RK^RMd^^I&+&E zjOn!^Sv5)6;h-{F>kQDqypS|M^+=e}psY08F&60fAfX1yCI1q1kW@Q^`Ycd{6lK0BAG8vL}T@&JxZ-alY*?D z$O1THEOHcuw4Sf43LlX-XjC1q0gqTQ5vhT1-;1YE*`-5#)uEixj^lmJI#yOQg$%P#hb=RqtF7a>JMM;jlu3=% z-1U3BW<v1WTIC2oHXTi8KAf*n)UMXYXN)w_k9jEAm~{2340QR8>Xn_v zPhAyUMriUAnP)v{7@n@j$Gb4ipcy(w~*fO<^H2N~IQr zX5`)H;dhb?`5p}1^oh#mPCZy8P(v3TLD-}qd0j%*q)H}Jt8Og-#bs9KdB(Pm?PonYMHkvwtp!=e6Z-c7E5 z5-ARHRjgz#ukL6~~H{jH%VWNYd8wt%fO&mf|Y{ zAz6ZrwfoV9gg|0CHZ~^O^kw4bgpP7 zlKMlT)__4~+RNcU_wFPaHPxRRo_o$L!E^p+{+NjRlnHSvSj+gV(2byy$*+*uVpjqj zV~F)_&{2%mRrJXwt99OpRW}DRRuV5hvVX?y&X~ynW-L)m7`5Xr^SutNWyj@0s(Pg( zer3`qa*7t+6j(D#oYi}f{^a)-Nq zZUNfwmtLoH4~5T0aTmxG`FAJ3{OgP`+zPpi1&l}qkzNr#e_EC&LQt#-bWT&s8c*uV z<9?Tx=3LEgH#9c>I8^SL_38LPZ})&g#FHhNru0zD*?DKJTY=S*W_y2M{-`!N*rek) zfB(8I-MsSF&(N3}`0awmG(S~tH3M&?MDY@`sq<2M>0T$=K{_BPkd+xXUp;HR4QF2U zaO1TjV*dI=oxC!f8>>x3iUn2 zGhB-trBc)}dnZzIFtMsp&@bi&4Sg!quB)39PwVEj{(H)-W>~+{@&9T8_@P?Pf<~{Z z{(ehz^XtX;Z21{b2~AX9d!UK@5^t3g^_F({iS}8H(hB#FOo6MYH7TV_Sja(D*J)`= z{m(I#%g)=HrNDEY=iJ@YofmLw!^&B;;q>8=5xA$d913Z!;`+l7JPs*(MMh#goQMAD zKqAM62|nCJy2XV4(t+Op;ZW;fSJZr4CMBPd9?yD2juL2+>a8_AYHz*QzPuKCiR(3T z<~sDK>#+2pTyvm!f!fFu;SuPNjfKXb0}_`3!?Ah-qga#oZOdHm6c*Pwz@v>eEIu2&%pP9q<0%`8|Sz=CHvuy<}Cb zTxLA;c^(Xhc1omQHC zcRw0bP#f@Wyc(%H+1q<*RAnY6i|uioG1go?rmwqab-F!65sw8!0t6#i-5gcHR|B#@ z0P*QtEv|AKZko1JcAE4E4Vs)>vO0q8&wAGro_V^r=jUC4!!lLAK%ALN$R1><&s!@; zmIyz-yiPeh{NC1ilwOnPdLH}~G=!Jm9A2y?({Fj-Mk$gD9qLizs62{oFz#Bz&|tZ zrmCr9SE)+CHT1_~NA(8am3R=gS4oUO_XBA9764P`xrm3J9IO=G9e*Y6JP$1MDjw(V z3rgKAK%Q7E5T4BZTKw9&*wq@_A-O-_5_rDRvnCYg9OjSpd2n!$mQE(ZRr()5)!;;F zZf@SU>VXa5El=LWH3<$f+$2bVA3C5moIKxk{*uFv!FGJ zIc-w(+L-njO=}VfowVRD4Yq>y?`q5|;rE$1DDXVS8iY8rT|PLOg4YX;qbSn**7UjH zhZ1sFu(h?-9TsC5O(cY<#<$Z(eB}`V^-?e>(#D-tnlUML%in zB3091I8DPA5R-806fJR0IIPsHYSo{q*5QpihZd_P;1seGgj%xPCHly9Wxl2xcfQqt zD_Snyi&JKpB1lo^`s|t;-Wx*;EK{`4=>&g%Wv!+OOg&8RT~!SGg0rfaxlbM=diZ68hNfn(Kr988`=B=dkl8P6nIvq;+KjA zwckB_u6BKcF4mau>O+GBLzBJ0Vz(p5K}H-FoVTNDs$0%BLVt9+%tw4FlOZ1T0hYQ8 zjUUYn0V>zxQUDXw1gcD!puS)xZj=)LzKIS1JsjM_>N$fuUj)~KXttJEdN$e zR>*2Yr~JahsLEn&eVt?8g=$K4%cPM&dul?IaHR1NM%^n)OUF=BQqGBG3q_v6p`6qIPz@wj3M2UaLq0Fp& zQr;bNu+h}_s~JJB&0S~ko1~;9l^2J}kHo}+4{!DZ5#C?_I@ffZsUkhPD$@!(>41^{ z;2Mz5x-3}j%nJPUo}!;?K2!uS-n6O1(`_BBowLOlp}AZf1$Y1!elt|!G!mLnB)+6ciG-KFu|B3 z3hgn->LI4mYbBRob=lg~t{eUVebD|M+O@I18Z zk8Mr+sL!X+V;NuPTD_0jKUTf<7w;E0V@_jiZZl`548l<7AJ95SA zj(`Fa-v0z)&f;!=V}2fNE@;44>rz&%_(wj#;ZeVT+ktV4^J5tFI*^Idi`SU3=9TSF z`O2!Qs+yIR#gaSpZp;=!nZR$^88IT*l?HBsctL{=$U6C&mKCw)g2Ac4f)CItkq6n> zDO?mH^G$Bd)UH3j0cv=2f1f*ZtnQWTBWl+l-E(sk<)vK18)OAXG>iZ>g7p7ArJh(= zP!l0lgJdQpZHS7A0nfa?@SFQ4Qyn=5Y(xE-f1Z2Wr2YCO#}s<)ade4J|H!qZ+!hOH zEZ-z27pGafc&BN!Xi4Q4!CTVD)AK)V{^_fA)#~M-O|Jjckq&L?=_QtpFMaIh##~%n z+-Lm&xVq2_{#55pkIyQ-w1-#25@Foy(26q zrz1*b<>DEkEc4h)lTTJQ21I8jS9#U@l3F(^Rzj@ajg>I-!V~bfhlSvdN#zrSOBxR+VAUzU%{Yp z*I&b)6`VMSh#7P9FO6S3{N6K21)@KAddcZP9E6t#V+@c$11bZs5>ssHTBRoS zuNa>-?Y}qS0UiwB?CMTV8EmYB2(*!HcNgrText#iS9@(&;Z3tkmZ7_+nI?_F`Yo^! zM}DSfvDtSk0U$Si}@*y~HM8h8#Yx?QrSI}f-ZGFuNx8AA%5+@TQ zv0~?dk?H9YSm0MFqgT~7{qd9r!<=M86vmb}Y~I>Ob1%ByLj}B=y9xo(Y-rq-$>}Cd)wNN2j6O%vx zp+MQ*(L*N`^s_a9BFDRwDK38T@Aj3mSt`+@r`2h3{nqQAlA?~n;^L2a)8AJ$5DwPX z^5<%Cje&Vz3WBH&Z@-vOpd_H4OfvdYii*Mb4&V!MkR~6m>+4San$!?awc7l~qPy>( zV^P?G78>s`f36#Eu-CO&Py41^KRpUgRA)faOsNJktmtcmpM$}Hf^fT zHQ^uM$TZiH%6+V!=q)}1zMhr;pa=*ORaJ@BwSC{d30DaSfVxMp;}0~Fifv{)|~WsUHh((UTZxyG4Z*oTQ){1XCsD zEm4fpjSt1d`VS6p02~W%Xvy9f$y}2plJ?!R-hYS?mQ3fe$pM<`6fMq{=Qr3#VktQc z%=UM`?6Ya;K@x&C@Ozs#DHZ8S(Iv{w|Ej&tEp-gqJ(CXcTzyx82BO_)A@b)z&WPE< zkFG)lO1g4}ccIbE{`j}HC_G2KluViZY3F&z{sU1_Wqv9pysw?X_l0}8oM*kghHNvB zmtPZ$NQnd1yk=vOJSA&Kwm z038_V>%-L7cLV@oa;YN)zW+ZOP26o>3l&cZ3)$k7X>((SrW)|)V%#VGK*7Ji`QA%~ zd&NESYY}TJuo63#QCuNOS}Tey2{yg2flI{9^n9u`5rF3aAq5kqqa)a+-qdAbbvYd4 z4FR!kTOcE!(Q`WN6o)r1T)lJOgaglI`uqAKg`l@CbJetXwjaK4KHOzwT*8e~v~0gg zDjbzY6YKsbnDu`sE^^dGxVTwjw827`Sod<#4167ZecFLM4{${Yvh$BEtl5LT(RIpz z|KMZ_F}c_g?Z-cml;A5YDXAh;(CuTs*X~6fXG5kv^<8u*ie7L%uB^bO_peV0H@9iq zD}h!kcaYP#3;o`Kw_5+wwMpL3G}UI(@yCya^0W~!hkA;HFBJs}`SPu7Y|{4jW?(^w z{R9lO@2w5Ny-FRy9UNp&fJH-2H7F^yEZyV}9VmJy%F{GuI#7_1!{fp1tSr#?diT#y z?A^@bB2a{vq^*0J)@Aee0{#8XI=Pn4n^XjcmhdEL8yvf%)NS*?3=_pk? zv~C@x48s9})vQOU3=JvKoUV`4`qWjFiETGQy>XliJKEVEVEPUAm&v%dOn*UE*1TFaH89k(!*>;JEZ( z>eJ+U&}QXZ{-USRVSBOpU2t)t#%#7W4n*pGHQmBWfJDQMLP4tiR?_eN z`MZVqW>*jU;=v9qNPu+`PB$V2ZN}#eyO7oTgo?uz`>(7_LPIJU$w{M_2MIb-9N#p zi@Vv$$+_fC8?y7&{{bV!zceLW)#$PqZ?)NcD=%A0%9f)3Ie5VcIOW7~ z-?;4EUEUI#%+|iyU1)qA;rgtpHt<|lD=B%Z(}lLcGX*+G5LN2}I)y0?1jt%<#u#Op z=+d3Ecuuat!OflHpW*4|6xQLGwC(CJQdg1Q~nxKd`Qs^>vC%ir;7w-P(2WMn9{%X>P2Jh(If&_?V z4oC`6Y$fY)+yy-ZG3sKEinpY|TEnky&Wm9Rh)p^Zmy$MqH)1O(;vU)A83J(mZ>XEU zVJYg7HoPicn)uGGNV3F!9?FENxV+aGF~KQ0c_k)1%l-xXIdsvKiOQ-!q@|dWl-VqQ zTuzz$3LaHqDd5y%H#3?T2Hx?zzlJ(p^9P+Rgd1v<>*j4C0t7K%e_{ph!kTrRfxC(2 zrN8fB9d_Cr42kbXHo#UG7PJM2y&B@YJvptFC_s50Ot6Y-7q^sW7Zs~*NzV0VROOo1 zen@p{h^P4MwjWYqlnypd(TBAjzJ&mayJ_G z{rhO42R{5%pi4btZTdv3w?tT$V}Q88zHG8n9lSEsR_k6QdrG;3=wD?CvYTi}y1NiL zPH#Nc=rAE3xSX8xmDw`sb82@q;fl0?L=tNuy?cAua+p8S48k_gpA1XQUrz=X2NlA(%E{=V)CRF6aS=RiBM3`s|9lc3?N z>V_`KSMOW2{SqEM|MX{@jV$i%lQRG1@T(!}BjDsUCge^Xr^invAtR@1X(=x&D+~6; zM;9-W*&|t)l2f(db6@=NhtdkoQV^(bwsmiam^ZqA*$>%GmP|Q<6rq>vriWZ~m&h}n z{eI{TzMKw^O~@@MY(#3v#!$l8gybPOtcqgcevBcbJ7bEmJ_@>H=olAt2b9aihuqZF zs|lLolfw=%)k(Z=>i=cK zIu0UEoe8Hd(kc1c+|4r&4?T!ZPe7%=xwB*M=}C6Los`H;2Cy&?W;8^y6>*+wu8+EV zAK(NQ{!$W8y+M7_KOX$QhT>r?oc2`fY!=aBf~ zuJ|g7B=p{TcqEA;I;6X&>B~of{OHs9Y6E9i+FsvNh9GK^_f;zrQ9?F8_zm~{@GjW1 z1c@XsVS+DNL0EtO_yBf3uu@bMrSb#!WB) z2?1a}?@d=}rE0G|W$=%;YiMGAqs(?1IsT9-PfqPZ*q!^fJr_HKX07dlJUj?z4nq{< z5g(i@iiF##ECq?jx`!@^W`T8rkwLPm*3h`Eh30l|4?~Wy9oNrsw;ouJ4%npt#Oe9t z&8_{)Px}^EJ8Ci5`wz6ePHl~0fJ>;UN*|j*dQA}L*-x&E(7FWvZWDqV6uCD~=V+a& zvVG4la=-Wu&zmsC|L8VA+?Wi3Gga==kt@Qm+esuorqNZnhDy6*E};j~hAdmm%74K-T#D9Aphf zi=~dUs@E78^5Zs>ht@?39UAtG5IA0xV!E=3zXU_vUXpUpqa~1S?5S%PP#hZN3?VL*{SdAr=$V*Z(`uEisP~hl0B3p^9Fu0f3dF# z&V?}Q7kf#Uv4d7|jT-fP#u`JN=z(b(I4*H7JrM2<5*=W5!?`wyo&PN2~H z1cGg+;i=p*E35Ka+KNzb4R0-7Xe=>cq%RI@pB*d?-F;>L#MslcUeI47i1xPER~qr; zAAKd!HHYtw!`gGvv$jI~IYVJ>u5e6&j;4pY%-!`0b!a|Z!wYu_YI9PAIW!A0CSKmqfN0_z8U}rxe=U#s5x+}Ddokdzc<0+-S_Q~y zEQvLKNK0-g+HLWxpOksMx>Okd{p}0mWee8G(ln`i*THK#@M&ZEUm*c!LmK6H2ZyE$ z(GDc#cU>LlNvS)Z_HULDj#Kup8lU_ycbws`G<)YtFgG9|x~7LtgVO?8=Zaqcm8+Ap z-!K2pJ@qY29lcb7gOwG{nwzB6;}H$Lv1$K10aLSdfgf@mc}Fr`^5dg>E~!Sd8ho{= zo5}X^Z2f}c(d_x;&ZYfJxg|9m56RD#kOnujtB&`W)d0*>QFaYGaa$W~9p~%{Oj?lV z`^U2_vnfG*bez{Lc`(X#Re-b>6BFkB4+kW1|4xcytN{L-8Yr64(5M;zO}YQ)4+DgqEc;jm}tuvLuZYZZHI}F4u((&lVU1 zEiEJ?9zMy)+!FkkqXfK>|4@@Szg2zc@VUlT|5KK9On8==P1w-6q9mZj+`YBE*i&NZ z6IDBAXQ{yDX}3GMOJ|r8I5ORjadnGe-CpL8IAjru4k~(BQNy^(M%^@uZ?<#9OXvqa zrqyx4`TYxwJnh^szZO7w3QaPZd+4&iP%G5F9T1Fpks-Yb#}!Mmgq83KLM`Jrf~w z)!*IS-QEklol?TlCGSzfF}~O#TE<~zh;$dz=5tmY!F_B25lbRjQxyI{(W@BC3IRx! zArwj}i{P72G9TUWgab?9)qkV%-QIyHiy3sjtxBMdx*BOYB&E?CEm7p1@(C|ArwajmEt+2xZq-G0;NaZjEk0o6FvmJ2TQu2c4z`zyH=R_?yRj=+fdGp}UHd&G4oZh3>`kat6PIs=qx2}!YBNVJhKDXXd{?4L=IT%NRaj!e z!3Jg?hwnvm`Yj(3zBb^k{R`Fxf^xs()Epz> zR19mB1CV@g(3e)x_2T`m@Ls{r17PI`X+7!70C@8^;1xGqD1}x*%MCsn4O8$LG9dep zIiLZ4P&U~uA$ZIQ2h^WOmlYoKu0Tj(Sjm4flxErg7CLJI{>`N2a!k_TQzR3a=78?q zEz&*h%|F875{08u9I3>rxFXEz{0hISQ^)+91BsX&o|y!Lc=2}!ZZHk800yp^3!%#N zWGI2EN8Nq6eftz_R7j0z*h^!lF~?HzbZ3w^aK1wo-EeM{$!wDTRFWIT=zw_pkIpzR z^SB)Y&_hAg9x~7y3b2nDev{?_7ht0k(TUUHF@{%%7dd9Nc9S$@3gS4TYf_uEM#G)k zeas(9&w5YGx05JF{`Pvfbk^ugbAff6Lzkhgpf5_b10*7$P9x*_(u3(_8>!q^y&D=T ze$~$aYYR8v91+3KsZQ2JjA+2?x|>lg#TmAVOMk0#r6A9JL1wTV z*T}q`F5^NIPM0AJ@odPfaMdSY;6mh^h+7n|m^qD$bEz2c>M6b-75=DpZ2iAl028j% zb2kdw_F1VC>wxL%53^?%!1VD!yMQ)*<*jK~E&rv7 zfwV^MANd=w>l>WJkC51GI&2mvkA@09$)~T%N9Mc&&#ajJ$kILp&x;HU4vfFj2$Vr^ zK9n0*B9_+zy9FR{1IKPjE))oCu0_K*^V)y5`z@=(e47?+N!I0ahE+cb(S8Lq-n5zk zp&6vuU?6$_LYIoskv-eaaEv5bA9vy;xU7C|I?t7-)J@teL7Vq8WmBb_=>`|Vp^9}{^ z)UTr2-bLw%R((KEoDe=?^LS|fsmH?X&(&f@qi2;#p|S~H8x$iV}fR?dk{3TalJaO^XnkVx0oS!|L6I=U*CIULE)Og zTY%aS)vnQi6yrs4QS=8DxL0hY?adoJ&7mSGw5lCjIUB3f&Y!i;ofRKlM3|zVdVRyh zQezt(`WVN4f}1e%Djy4P{K_H6&BMPMNSeuCh-2ZgM&32Pa(P1MLNh-$Mf~T*`#a3Z zTGQ_oRW0!!{ATl8WB-w70A|<08LPgJ@>yibr0vxZ&u7~c4b+)|U7CV5@;g3xY;li| zcp9P7pBj1cBw<7;_j7YQRzQV`+7u@AlFfFy!c;5tgUQk?5zdORh)DP5*N%IiIebq}LZ{+;Sv+C?M_=kl@<7AwFjN zKP{bgSQOpEh6$DKZkJB!2Ej#YNokP~>F!2CNhuK&X^909SOh_2kx)uNy1Rr0mhR>| zyuZ)?ye^TQnX_lknR)K#&L-$go$wl3@?zjee9^P#Fr(lh5+|JfNS>e|fd3}yciS`b zN*t6jSYc_Tf?NJxQXlctTe8h)YZ8!cZ#p+4&K(g`j@64On$Py3V59+z35rSOzJI^& zL--pkK(%F~B(^DrhiQuifbt?MK<{&!#AJl@gTb=jKR@f)m`X0-<@5|}yrQ{f!2bD% zp(JxEFE3`b~ z(nbf^4vkqM9V^c>{NmjhwykuYF_+oClDTPh5qi#4I+TWGQ^Q=ujNHR9o!dd?$=Epx zRMgQ{tannEsWRMrdtIrt$O`U}NyDed9q4kZXTO0f5Tio2H?X%sZ7kq`K%f6??;`mw z$)6$inXuKL${YmP8-o;`?e=+IX{+q|$^Y59LE<>d;<8WsTUfXY%Fgeca;4l7TB9(I z&_gv6pknJOaGx|%iRR^xU#p1}6N40+3KALp&A7Y4HQQJ}(^N`59a6oh!}2+dL(|0U zb6jV{(dLnD!<|{-?@hZ1jOh@ z$R>{P$q;BSb{xw9w~={{PaH+x_zQ-ag&hdcH7Y)tO7xCBBqll?DXS?&3RfNR-%s+Ci%bX zH@vi`{~QKavsw^0h`y`6&fDksQk)-M{Oqcs`)|O}d*p?q_(-Xs;R{TXIdtc37Y99`rpm)_rrVyAZo$(~v!W<*Z#wEdn*wdPd?XrV6mb6Um@(Px-@NckQk0wU*W)Mdf&2 zu8K9nF=bLLkb~r-*O$eP+BSWBJf#fgnHU@)@qa~HX~~F40}%13`X2~ZO8nv7yuWK$ zAtUi0ZifXlwj6<;Fq|JE_gg=V(?O+t^S!Vb6pv!rp{U)9|B@RiW0{ia_Hxt?N}d_* zM$65?wQPs{%p`GU^91AwU_}O$^r<>TO#R+u(A^AK1@U@oJo4Kug1QQkd5PIYo*97I z1hz7^-`jymMP@NL@)9qqtM;0e8f(f=&QqGkDbbq(hGA`M?tJMbNredeUgu1|#mjyW z?zm;y=(&i7vwa?6Ekf~TD_h~?k#IZD-i+pzW@-4RC(cU4sDLk01S>i^?m;Exr0f({sS)~DKUr{tlq>g<&9m=?SJ>9R-Fff5nyfQNC%7(nzHrjB9sE0 zGB#RWXf>%ylK7~!&{-yF`F^B_owTj`ZL)jM^OHJNp5ml@>_BAx(f-+Hq_u4QSE_f_ z5Cm0~hQZ%|XPX^&W7sq|tfgG1A>{FW@*^?BPoFXC!Njz1p0E%;H2gtt{`e!^#~856 zm$&{Oz_v)gK$D`(Av#~4c-OIFM>gc4?7J>Ik$evm3F3>Yw7P%Thq-nVCT0@qY|<$o zgNtolH=ywKsWys^Ql(J41id1IOh->g-$k%>qHe&}AjLi6lWvhUhN zktRt>2hivv0mtSQCC$+RXSj!S-^$i2vZJaoeQQ2`H1!b{M)_l?*eK?+wQ<>>r`tD= znbVsN?W&rta4Kn9-b_uq+&9B;X6f?y7v0(-^PED}?MFgw@}@M7@y4BNN_MBs`3w>E z0KFe>St~!oaOV7p&#}Wve;+MNhm)>FctFIhp>mr}RINh0W;e_^>e39qio_g)8l#`K zx{MNCpxvxX3!{LcMwW7E{<7#HaS8bqLdZ!e`HL7 z+GJmk{-sHd+Ak~X4RLe6^_WuzoEHJU#86D@pp)-6rKgC`EDaZgG*eOOAl?~M zkGJShxAsePCMkEwuQ%Xrknd=j33&51=#cOl#}YK$SKg z7x)f`CFtX0-W7%WLg|}fyz@ArXV&BL_puk9Y_`}0z5YdyV>M&^B>q7;?<*%;?rT*p zKK*_;hF4y)**ig^W<=-pJ|$b;6wY7fQxgmyt@(S8xg`DqR!&C*MoU4RvOFcmp-)>; z5&q@9$YBgt;E+;~*J`yz*GTFFB2SQ4Y>|f4;LV_B67Z~4_e^V*8Wb7udd^>wEJ+!{ zR(Nym_Geih#uYwGtDs#S;1;M5sO=NJbI9MFD19T<@^Il-viV6%*ofr4-{Lv7$pI}2 zqZS0p6hhp8sfx#r(FMZXmEFPiz7(~G!5bNeVJay5ht=UPGag+xHH6X*_^ZbaMerui3Dr^11zZ)y303 z(QE4sS*QJ#QiebA;@~ib%;1k-qhjJBTQMk;A2(l~CC^<=$9p_`K#R2~qhJ$G^6J=; zY>w7>CZAWdY$A4zDs~r+ffJFOb1;V|OdY54nSf^0+iu2Oj9VCd45cHW@fQTcB^L>`gS6cr@B10!n`pIpAH#DVCtUR zM7DS`F-~{jN$a<7h>aP~+WO3brMf?aD#mguIj4Wgu0uED5iOcaVonvAeWD?UmNEL% zCL#b#tkZL+oYD8VLixZl^cIq%dhYMqcvrDrNuPK?Pk|_ie1We88&#-ZYyX4nG@)hB!;+>*99$mKv2Alu>=53OgH$xJpRU{+nF&KRA#&RpZHnAJ!BMk+t|_ z&D57SPr^_kzTg!1+K1xL!v7uSd}_(RN#{Vjm9q z$8P!MDl9c_|BqdYjnQh&>88+r7HqD5V|(z9U9ITX(mOc8G{xWyFEU5uId<|%MEigEo*DiC z?L2whIHdeNMn6WLd|pn9o?YSK+GF}6ep}KZWk=KrDu0qgQ#Lso^-RrTl%~jutTFo+ zccL|Qw6NFfwG~l{@n>`A5_3KWS!cgd3Y|H5&GE7~$2$SQ3)OC|5JCvr0ytjaVhXaz zwC(N|je>+~;1$Dsq#G>-Vrjh%29uT+WYa7%bjXY@#~U}ed}di;u;x6gX0Rg?wG5}F+&)ujp=J_FghpuN%qFlR>%X;m82EA@TaixxUjoH-4E*g21pJLS@ z2FmX8*Tq68kzNBuTMf?dO1AMVXbAcBIv?>j%ShDGq6LJIbz{6=%@9JETBv>fOWvRNJx zs6a}1hxpCb>&r9e^aH;6?N7UcVIpuLEA0ObcWwsEH1snw(_z_11OyA(3zG-4be*2n zgKBMskV%QiUY;Ho-Z(3o*Z^Bih_J^%BQMe%TK10=PG}lR>7^9=S3S}{G~UlCQw8L| zN_{eYWVA%y>m{M~b5Cxvg|t#NB-}fyp&yImsPJzI6{#`)?dP?6Iq43)QQ3d8$1mgT zxY|D3{o@V$*l+SBo?)60THIx8?kdMh2>m;RFrE5l0_qmym3s{tp^=i10$I#^;nOsQ zqQIp_vuECpr`I03WFY+h^`g;WHmj*LPL%MUWW{545m~JLOOlRbWgabk@61&nQP4qd zfrPgwsuU)<(c1P@;}<*HifbK4Li6Q&jLQRHJfm6tsEfIqrjvxw<>~peaD$E4Ln-OO zL*nxNg{Bov1uYF}`!xq_yd2I~)B%X>hhk*mPPMQh*{-@In);xMe-Wr-iY%>~@UW}# zu%@rC-=aWfof>BzN1xdAeC+)Dyj9A+cj)%j4%5X%=XFT8rTXb&f4|gr$Y~`KF`TA7 zZ14@RXj7o97Q&eL$#Lqlt?5%f%5Ho}Qe^Am?CnRKI{4WHZ5p`vw$tEift@^mJzS@m zknrQe*|OPCZI2KjGkSpv1JdnP{(2g-Ghd;cejU@J93H912$ag%K&XZP=Bpg~7)6#Mr5)i1VsR;mQPMe+F zldzSWK^7izpPuucnHeLE|u-ayA@0(N0r6sftiGiIEDfJEN6Hg-G8%r(S#j> zv%qq_ry+?%Tm{4R&d!}`>9hEDAF^zq95css?L)nqUGtEUKN09Pgp=q6JQXTz2um~BxYxR z_WRB@sXQ^oEgI=-((9Bv+iAW$AX)Ag>N5|!i840+(#K-NyOPxn-=~WYo;9R|W?6ai zw19N>Fd!wK)85N0j(8`9(3qq6te51A7PJj;h~3-UgPSi_setVAs|J%bklX-lsE z3IzTYY*8KwIs0AVq*z~=G!?uyd(iOD{`8j0a{9T_>(0NoDrs>rsBreN$!-g|D|r38 zU%;$uBaoHDwPZ^04mzAA6jjwZL^kbqEGCes$75bvo!0S#hCE}YD^;m(E(k6C4fgQx z*Yq)l0>N&5|9tH)-$n(5!54QPV_w%xQjq&I=g}`U64H$Kn1EK&y)kty?OdW1Y`)7i z2o;}$;ibOg<3V-{+Uk3HbZV0`Nh!)mJ{FUGtgoMmePN-Si@NTuKX;+I1>ZCmlagn) ztKRw^_hUc;T1$^5>%?xhuu0_iOG(=}=tFB%?~{E}_rVzw*n;CQ2ic^D+w01iaMe-3niReSLQfNy%Z&z3x^S)sG9yF3 z=%&BH8t49T4-+!oD|ZTbjygWL&P>Qb?*T8_VV6#*2rD#SqvveseZ9-^hFAU1-tT2) zpoRXM_4L$~FZwAk=XD==$R`8a0a#Q9pEM~3Ux>VE$AYOJH=nX1i#)g7z1IdH zL+hMh&LHR8m*)JHtoq1R{CuiMOmBDHEib0z^9&FEd^;V8d3fm5@M3;qWM*b|W=bx% ze--CV`(^LchGiz`Q?l zbyqGKD3FX0a_}at5}x#)dCwjH=A+kH?oDT^iL$`3)?ZwPXpol7ZI-d*{)sf@arct< zw|$td0Zi{Q4KnpE(?(NM=>X$7-Am5YF;K@2Ko z^R9=+WNa>JS?UL(^UojLGULkC>aA&MpWXXgz1YgbA~y)@v+CxbAR)dg?{I##a}#wl zJ2!W{_@1vJ6^DemNRQWZoud*0a!hX82dB$Ae>6EoLpCS&6wYfcFBYIidySt+53~vh za6bx?$R7@j>N&6|dkT;~+`?;FTjRcZ**NiC3CW{uZ%hMVx5w7Pw*$vc?ln4);@ezy zl2dK>#2T%RkN^*nV z+_I9m`QEcclS<48^wZ`e}e)+Qce;Y?b;A9IL@^>!=&Pl-ikm9OBo1(0`P>AzEQlf1Wv7Hh$^I zN=5-Jv>>cpQ}g{Tj1y>4+Lk@RN;}#L)FNISZ=q*Tmhvqx3rTMJln&099{Bm;Qn}@1~b$?%)OryOM$N(%e4dwOYWVYOZ#2Y&XyTfS+(9X>xb7> zlJxtk!$Z(c0RbO@R{;>Q6W@Iaa1&DopL|&nDYhM)Ya&d0;Sdmu=+jQq1Kb;^Mvc-- z5ucr%NNSC^x}alXkT>N?yFUJPvGa1oH=B+nBoNgdruP-BYFSfojsCni+ovkGY)%4A z`LD#Ck?QR4B3mIY)4=i|DkfI2-FVV)gG!R!mO9~R>1PA;5I=Xb*R(53bJ>4_c82of}wl`67 zPBHkIY<)l8$P`i)a9ib^!fG1 zmhZDs8KW#{q4QhY*Z?6~k6m~=EiLVz$kwXnBo&#P)sxU26c=-vS=iN4otn-|eI7U_ zAd8mb?tn4Z>1k5uCQvtb&ivhdUge?X{jA=%T{d*g%&XJ$*V{~am;Wqpx?Y9w&|v&` zY5+YHb3G-LFuw&pLhuoNi1FVS2#8-MDCL|QkmtC1>cRV6OW5*xfXzpczwYRKnNJR7 zn;m-0n^ADmCJbIt#%VD~k|jo+0gYk=ye|U;K`{ZlzIyaM9S~0i%pcs0x7y3_By!~h1lNTJ6cj}=Y^J|g z0QFH&Qto|n2{P!{;1lNK%}FJhoYi+4lGS@dL^XA_!ns{Ql;+^<+Fp_92@)*rzD$6L z1%3~(GYkt;0OJzKydXfg82Ulr**3r?R=nd({^__iY<(vS&vHXLrlPwAd3XekVR0T( znsO;%13;Sin42=*r_!`tpzdcB6%*edTW=fhr=h!RBxU|Hdts~xc$b!hx1qLAAxjkg zwZzGc!4~63eXBm1s~@N{os}ZU1K3#Lvh0Bcfe@_+>l3^H8x$Bzt_mzUcpJOMoh;9Hw7aeyr< zHJG_j4clGpq2D?19XB5@c06Z-bxWd=RlL;6S$mHGTc*v;2)?V*U=lO3h7Qk9b z)ce8D_%yIiq)q@fA->H1bjjqzL~~0-TICl5-YoNRbGqvCe*?R3fissWhbaeyeS?x1 zA>@gk%S7XB@J@tz0}zfHblZZ`6L4l;WODY)9f=`Jzgc$@vqIvbrO+^U!CS2mD9g&v zw~}z1!i5RTiL?#oE^qz};VONc4I3?P4#O~~0cqpmMr4);wOTz8(n#bh? zp4_;#vOP|{S<+yN)ljd1SVquB!h z_;rhE$}-~R5UMWeJbtlAG8=YtrP0(Ea(he276!I7`pQg2vYW?T| zF##YZi%EMoHYR~+xDGP%^CeB}prxZ*TKJVdS?|pS$UJaSaRICq4E&Y0oqbGd{UBPt zyZNml;7VuqF*oB28=FY4dgyph`E>C5jNx1(TSY-ROPN_jf%p&~?707Qn*7xN- zUz{=1g8{U-bC!^nCv|%71untb-%HoNa0_!i^TVS~HadDDk6ApVH<)t76fx>I}lyTo+Gk zoruz1r@LFa9x;w{0Qu$N1RgNORR8+ZF38ZpgJAOn^5!)6lPBc;V$Zpdy zGF|^}dU^3`gP1@OIC%bM9nCt2Rk#LD1E*+NB>L9Z+cW0sGK+lw;R7|lzACJp0EgJ) ztS^TW|L*zu1=#|n~%jKe_MSS#g8FwlzX!7(~I%fhnUa*bVX(v&?~W=s(my}q>t`VoMDFKSuJ1mX<) z(1?~&8t&Y#Z-Fjx8>>{T4tuB_|>P>O0T)3 zLw>~gf~z?@66r|GC?CXFDklLzb z^#cY`k0Dw#gWssaXz&gQc(SGleRuWV|92m3RiuLsae;;u+zlw8^P>mt-C^e$y*7XB zt`^SLcDb#W3n>o*iw*~f^rOplA&l{igfTDX<2qXXLwADb87#_oY~>wR)weYvo`K+1J-oxsd1{g8ji(?}0J5ad-G`Ss<2R<0)%vE1S!V4^OGhJ7B%H zbZ3dSB};CfY<3sSrF5D6e%Bng=rG{CluKQ*?yENn^hDspz37xAaaCC*_^7?+lXJIG6bDeEc^o&K9E!GoE?ndmFeW}^MSEeg z9Mmr)+XqQEe&k^u=V&^S6kp5$7&kc`R{3NbR$^Q*kAk&+?d4}?fUZJu3!YdO>1k<| zZ*Fsv$LaA>13cXZfb4U_t!oq98H0P7YCJyX#&&;rfi%aOPez6Xzq25(>0~b0(rojB zNhq~t2|qx&e9JUgU5+Zy!SEy#VIZT$nF;}=5ny#4H|lIun5Mu)qbQNJ5^=F@-3n*8 zW&h&9eYdt-R7U~)T@u{1Z!ZtnsBBI9lP0QM2Be|(3c=&;H$8$Sg@v!Hss=O5#+7vX zg?XvM#?U7G7CmB>D{4`{!4Og4eBXQiVPt}P*?Kwcjk03CbEZgzt~fc-iHdaL?rh()7i7^R0^TV>uZK!SBV))pWVZgY?ARk@PPm50TMndBY= zX=OA6qOdtEyihf{+JDC)I_7FOh4i;h!)N(f4bD{BVrAjHEOIFp78dIemjtiUJEzMK zt>J36!9R*pCtd=fPMvSE{TO=1usfnmI; zLZuXwf2AgJ*X^L8U?(fy%exN)($?GJA5j4-rHLdRUyh%c$KYAG!A6D)V$R<|V7p-^ zVMu}^*-*OA7|jt1&&~xg=${?tt{oI5Z z0v}5z89^eS@f=Nh`*W?Tk}l&*@e#A^oc%uE7Dp5HoWFiwhKy4w1nUFlo55vD4GurI zdGH-=6Vmjm=U2tKx3<0xrc1Vjgi|F4pV|Hp9geJtYF~y@1N=|aLj6O*m$Vn(=sKYud2E_1tr6BlGbpS2R9$13ao4m8LhWm5D+BqX{Qm2l{on2SqF zVnXKfx-`d+@QmG+RRIM??#`Mb+FF&%240kjEL+=rqhp-L++ej00I=du@X6h|>CZNH zcL!*~UXjZXD5jFKBGPzqAs-gwhan3=3nlOMZcR|k3dF}RKk4us2|(Jk!pqWv)NnmX z9e&dk@$TM)`z`oKlA@i*zhwQgb3F@jJ-fe)Iz{ewDl+VHhKw6x`kQeJf4yCwM=Gfj zH|vbouw;JN%Ut1;5hi?neT}&vMJ`ZL5&FVWECMY}QHm3TgL4&9`d4aF^WL~G*OVxs zQgrL03vW&+n8UA(Yt63zg5sek7H!D^h(J zM!0TtiO`9n<}ps4B@z4{gkd5}Mv%vM);{_r#knUQVY>gy)7Z!TO2}=-U2ymIp#Uk2 z$Nyq~#eD~jzDjX4MOTK5mOaw9>G<}qnoj%py`+{?^4x}ygI-n=tdfr`EinKkti=! z6?;`FR+(h$Nm>m1QsKwE8T8onV5djwi1s!IuI0y^(^U1)P}Y{jtHVbUL?ocGZ}prk z^vm%ebN4PA^_(UT4F%WrnpS6t`-Ne_Aq%R5DwO0d;a&}=;nf>4I3VG1VLOg==ljT$@wD`&raA{e7oA%-3i(I*L z1PNGS_hxi^vYQDM=#E&z=R5jwE{wKjSTH4Xr<1FNZja4l(VH&x9e3@D(E?3`ppf+T z*S;O>i@j8B0PQM=Xl$UID}w>FYpzIgE!B|~N$R<9XMiWtL8c_n4ii@dg^l$fBs=;j zeYcau4KtKP4NC{maldPin!hw&H~RINx3HbQXAOPb#eb^Qf*B$#<}}R^Lt_5*|9>;a z{41<5HSn*(mXZZr_$AgBl9hkbH~&j~%20FllXQvW6UAwgUN@*05(uS=dvyQR&I>oJ zpc4C0%h)@3p8+H#1;r%@p!;FO<7&3KMzP`mUxSnm2TqTJ&J c<<%P;Vg3b4u@Cv%7~qe(vi4&H^!cm*0}87@ivR!s diff --git a/docs/images/bizarre.png b/docs/images/bizarre.png index 0c56884a3db07712ac4dab21a134663b5eb44342..47e45e2700716fc91d3ef7cf53054b68e3062003 100644 GIT binary patch literal 52703 zcmV*oKu5ocP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGh)&Kwv)&Y=jd7J|F(b z9M$>%cK6oKJ?=>v-L3Eb zf4?^~d$W6Y$&uuekey%h-S_6rn>VvF^M3PvPi^sdTy_VW%{CC~?~n_Tz5(0EA$$?S zKS208geOCykOs&@i2nldc?jPMIUF)qk6#OI!GZ+~dj-3$cL$QtSrE6{66p&$O$#d0 zDusLi$$@+b(#nGV8)O{hKFDZYTd-ik!d|1Z#I-xDfi?AS=s!b9Zi65-5E2?m@8^(T zK`dCXU}3M(S>kHXpESpv1}kd;G_5Y`m5{$c-hW z6S41QgzFH#7&-yOKMXY%ax>%v2raHsq+Ocw+n*H9>q7 zJSTpv>Y?kP8)LCpOFR~DiN>NW(P*?K6bv;tG&Te(D=Hgr{KF0WP+73B-_R-IB0xlV zx#c&IUXbMs7n%es7etV4{$5^nC zK&Oez!l8%P-+cRvNH{c=Z-9Ca)PMdlNX(=Y`wYFSG|6#{jm5xb(UAE4K?w#aArPk%X1Cixgc8FCF=B^M+w68)dL+`2%`QQ^ z-O-G&4{x<1Mx+NZ+A5KTQcsI97LPT9sQr+pKp^0U#n=S+VKu5NweaUWxY7!^Y%gz+eOrr7S~;B13G4!;$Dm%}q^L zpZATkNqiO#B3Q(g#(3?GHFR^n;usCI|wt4B0E!h?N~jnDGZBD7A;<~>ckU{8_BD- zaPYt)t~ADLufMsVxuto$A{J~nH2UDq#bAm=Bo-lQ#09RJ*fU_gz+!RO9k5_DOD0kI zrIU_&i>S4L(!1K%CQUp0sOe&o#9$IJLTt3Ea2<+x6wx582q-zM2uUXS8SH7l61vX>6#U&R0N@mp4bo9dnYv*ixj_ zu0~?;impj;szM0+Q#9jud2EVKq-)K?h%@q{4o5(kp^&N{qmG9C5(l})!y!e8c+u25 ziI+`mHdu_vM_G%o5HpmuW*1imw(lT`Fl0x$X|Xw^ z(dMu>#v}2Dm@Qt9tFN_%!?lrUwB~!?{Z2iO$1k^Fh9a*2{qKKM@(T*zE+{O@>(#Rd zzDjTj@UU%ouyu8{vToga*|KGe^7;97C4rHM+7BCFUvpT~J$iJP2@@vBv?HgfFQXzq zqycfsj`E#SQ(gV`nP;4SihgYtx)`s%_Qv~lb#=#S78lCAJ5!E0;q)Z(Fq1|b{T0&f z^4L_p+jKgqA#5hVHph12T|Vsi{exe(GtIDZkiJ&bW`7UBXfFv^a)P4p|n9N{ZuNZpN#K}{t3kwVLY&N^}1i6@r%eZm0xEku~q`BEI z%`MHi@jmhSniT2ye2sX(jpEF(OICKaj&jnUCF7UY$*+baEVjLmcn73&fB~R};TqRns9|06%VLptTR}X=|R7!<@}{_eHvO z?;#u4Yai~t0ST%eBsgaLc=_(Pzb#c&)%b9{iu3CU0A33t7^QhK2xFTK78N^p$`Mnh zNWZ@QrLwY|T}ocL>&}0itsR+uu)X@)>(3Mx6`$|G!`u~du~L*3wcKtShURu646Pr_ z*F$qLTZyV8;-ZDtP+uS2v~fe9AOHAAJGD!+&{cT-jklhxsHpfJ3kl0i$d(~f&N?5@ zC6!pTf}cbV=KZ=(+OKr$vF&Q}vCw7$N=>(`W7}v`x&X94ZkG_=LoeLHEWD#xV67~K zvsGA=^}dj-gb*jLeqKgrG?2}uu&5A3Q6(EdUV8)94c6nsUsPNoXP$kQghFAdsjZQg zrWP0l@J?_8v^qbO72Qiw)id}})X_*pbr%^ne1xo7vzqmJn;&`Pp#ggKX$QO0>6)Pt z%$|c^g@%R(JPhr@?+swFIr0k%F4s3Z1zdkIgujDBlMV{tTHKJakj{<=O#+VV3*qR4 zE(6MCE&m#Begw}C`UO47RUIWtaa6{lATQohM~(9TfW9B)borRiPf zYdTify!jpwLuM=@FqPQpFNK}2u_ZFHR z1wsvnmDj?ulI6{klF}0C)~&nr?A=Rx_vs^j`VNqO0|&{#!9!&5&|xxk#0VLF*kRHO z`}l#csjh}+<7A(;v>r{s=US)*_Y6B=!p@yHUji^^`DI$TXz^YV7z(R+yk3rR>=cmx z5-8R`JPX;0ZBA@>FrYtV7KD|xodT}?bO>kDAZ~zk=~O_ljVoE4jQYq>IMAlxC&)u- zU5v0fF0rrmSp3(tk%zvmrDNEn&0>x-j!nq}{}I=EjyA`3kT0$L5PoY7T*I}EL1}_n z7QhbfGZ2Y8R63Fu>!#SsxYxk>3A2fyT0-4!C2ki4+T(FSJmQ9UyX=-Yg zty{LrfB^&4O)e=Zk>0&~%k0^6^b~srxSOo#+%0&6pzelTi{H^5nzK-xfcQ*k?mr3g zYX~Pk=^6u(-lORv@<)a;?Cd2uH=4wpF?mt->i<7nL{SlB_Bfm#kYYHY1%b9pp1(Sg^-Jm!_ajuHkI}CyRLko5d_Q;Jfuzg3F zbnnjJ+X_CE5WWt);rjtcK=_4tiW@lR{~*UgT5ugCjmIJE^}GbzoN{M42;X1kcO!(yy^c-3zl?K0{sv*$*{9em;-dMA``ZTmD(oj1X05sk z+#nchnneO|8lBtl0#H8!;n#=YeuHRsVm}|)ClI5ev!ngyxy1MjQ}5kJNc#uq&mgJu zj(s2UckJgEZzyClgar2%q$h;r$KSwX=OY~_U^Kw_{YhRl`AJ?Q@f(e==4bjj>5_is zxz2EGJ$#OU(O42gfe7KNt`%|;fI$i@NXZ0X#2e|f{RUAmPS*)B9lOgsjCjUrT8r0p zQogOnCh0^T&?$MehX$|%-9-bDB#SG&PwKdEX$pLCaNpJSD2u9ExMrEEExfl_**657oR^Q z!|T?_>MuT#m!Eh@UVidn$!ypT>o~&l)mh?VKMq>=tUJwN1i)?-yhZd3_#U4GSpp&6 zhr9@x0pVnz+&&t@H758mXZ#lY1}>gMuZCnsf+Jo>JgqzaT)vO=3YH;mpU=U!SHzW* zog*bBMY3VT2Gy5q2VBRsYgWs&X~ys9THuDTjrvB&y?Bu8pznwL74a;{{|C7q@n1l* zQ|rGVdy5SaPOSGl>-0Q0&mPI?SO^J?`}*Pf`SB&8kw7^EGGTnY3Eog1b3W3tN@t&9uZW8n zJb187JYs?xfXmAHqmG)UT0-_0aFcI?Vm%h!u%6gf1O?6EL#&ki9i$(&Io6Ex;Tt{k zS@}(Km|z}vLUy?ydC>Y{izi8umJ`ijk|ZC#QIEi{8($QD>A1fc$I(>ggXTV73x{#= zq23N*XWMBIzF2oa=-Pe=G0w>sVx6 zb8~}U@H-|ET!V^JTE*$wARrSFrILpsDsPpCv7LOZv2C0yiI7w}?YPu@DWpfGO~*iW zh%g8$gfs>eanTB;#T5$e6>*WEC0pJ zx+R9c>c64YL26HV#3ie@S4eFmTzHV)iT#UY>HOK!vsbU1@4NRNehBv%xGq{(iM~tR zrZ&fQ1U+q-?4-r)U+lHTW#Q|KU;O;CAYRji#YL?;p<*A(x+aOR$>LFQCT-r2(vF}C z8#*b!q_~tkaBPw`?@!4?<((AQaUM{+MTm^3BLYK1SzP)Dmmv92_(7)d<4#etNbEwh zD+RSiLoi_y78kBiX|tH(aPh07+2S2BMeexjQhD}oH_GF`ze4>c1)FWJ>y2=pB!c30 zYFtOq({|?8b_p!vN^?ZQ5gRLp)eImgsF83mso?Y7)HLICZ5G5OX(h?z(V7ReN~iDF z1^@N^t#PgS8EH+&n(|2Gok(vIJ+3n_m%%8ANs*RLUL>qtky9#3nMF;P0|C>hylG|e zT=Xp1Z;rEEP(q=g5{}mm>fz#0o!C~+l3Q>5o&4&G%jLIMT_tWcg}=&epI3N)op4aP ziks`2wmzFbkzE)pbTN)!{`@tcz5i||pA~y+go{b>EarUNZ4vS=aOW;9HkG)3mk z{Za;>;(pe9SPd)C4|T8uHy7ubd)tin6H{m(l*F~7J|wT_kI}BsLYLy$RjSFX z3LD0sC-V!mQ6U+4ekERqbc2+7GZ3~*u{%QwJ$A_jsd4s#R-#BI7BhJyG~9!gH@=S+%`?hV0xJDc{N(K!c zg7;)0lDl(y)xX#qBZaTwg4Ah4L_DyBI&)eAos zhGaxrt2kKjceX@iaZOO(-QFz!UFVZKm)FUS^K0bl*;Vq#MKyBwiaL2>U8B6ZrCC1S z(IN|xc3neQ%3Gr13*$qCl5ehWN@(Ptv~5nO_N9m^4#}Z4Qt3Dk?%gxQjC-O!teR`4 z+`d$o(4-SHsG2pT)m7BM$qSWxi@X&v8iI>fzbQppU~w6sF_8FKPTrBU0{dpN@7P`3 zI4CWyZM6-npDLQlg=8&sF-}_f(qG?s>3Mw?3Y%1oJ3~I}-tKU=Jpx|=ufs0h44b&{ zesHEyC*o+$Ik1gQH4U>p&UZ#lou`f=P;Qg0C~l*Gx2sL*4C`!9k-2k?oU-h3MH0N0 zBafOcix)3WSV8S-71TrRq}jM(y)-s7$hh$nq(`sba23On;pD&%q|p+o|2(IvUxO=2 zi+0PF&C=xasq(~%{gI<@UTgPq6OMd>WHrBV0sR(FUr$D@xw zvGAqmpC6~n4p2AdWcj2IM{gW>@R~?$e3$H;hFQh&{n9KfWz9ionb7{=8_hpT?*-gd zo8+_w59nKP6{pXT70Z|7Nj@dpC(8NiTrKqG-jSJ<{X?hY3(DH?&4CY4 zJ-%9+YXq?e{bYiJLP$uos6vsb1mJeIK$^o*X$nPEnEkH8_}DRxwibeRj5&`z5xR;T zTy5MF=BZplLppK|P1;Cj9K)<>2r!P_9{5q$_Aw2`sl*^No|m0pn;LzJviS)2m<#5mL7%Vkwi|rA*rM^x&|HTt7_BwY9**$iN7Uz95s(+)e0=G zv?DGZct9E~;!1NkGn{2?ElXGz&5bC$ZLN@WlDI8H0-OaEVb;%*M3TtK&>fIeqGKxK zbd5|vJX(+YWP(bzw9G<_%M9kvZWOS%5(PM2VG&oFBP%<53uh-Vh%4G+5m(&ikRVJ^ zH76G>E)dICA*qBmr3DXZ4OVtrf|!g|eAZR2u()uc=?#mx4i0b@2~N7k znIergru_mGyc)H}B?~De*3>ArNEk*r%0`+B{jjjK*87o6c12PKIkl&aW4MA3E9co7 zugHo2lE_LEGnsK^ATyY!8iHiE8}q`YEiB?X@Zj_~obi-%A94PCPHnT_5R1hcTy8gv z3!S+9ATFz(OF|A4nS(5x1|jW&oI27J=0norXGtTbln$sV!dA`HMQ3QSF&|i57IEp? z!hr!h*Kr;%N38y3ywUjLYg6U!H-NZ&Znr0%D5OEZxWgnaTuT~D#MWBx$3-ffTw!My zQJ zBwR&`ixXx-r?W&Aaq)gc)PfmFuA(mOk(An(qFJ{^GE$ZExaS%<>DHAZthR1rYF7xt zt~#Jbn1@ANy0)-?!TZjo%j~hnH*FGa6kCQ`(TUi*wcfuXe)6M>n;rHHlm|0$wO{X( zP7*e`id@u!bHjIrq^MIX?@3k!EhZwBq}oV3Es6v?pmK#Dm|VME4E9imMO+64oL7EQ zJX{7Bk!xW9t;DroEiS@lldvkJI(cPq-9G4amZ&4Sj!O|!CrB#M(r8Kp*G}DMc0gr| zrAAKF?N`vNi5+E~DO$vysxmYC}$jm`KXdDvhr7;nr#&VJ4}h`YzpVY-wq0Z4s;^(^j!o zb5o@?I!#`wOUrJTq(;}tdM2PmdnzmOJ&KDC9-JIVp+Iwk<4GP zK<3SxFLUP3lR0zdK<3Iyr00_T7Sv$T!g%v+iHD4#S3oOqan+xfb$JOwlH>AFT?V_u z9x<#7&dlkETErDKxr!mUitV|EW^zhsNU9dQiMSL=X|to43Ct{hfBO>zDpwI77kp{b zp15{7tqmg7nu#Q(=H?dMY^~La!cpp4xZ}9iZ7q)5r6nbD?z!j4kRd~0_97l}X*8`3 zmm&L9V$BlWd8>`ufW7;*Vsq-#VzmX=Q5*;95*Ohg|GaC{J^%bif*f6^TrR7;!}YE7 zM8WpYrF0>e&lDLue!QG;%BiZ}Nl_5Wg+@inT20c4eY$4Fd|h3gJpatoGH}pf8F|pPxO?xrPpy^MN2T*h|4zJ2AFzxrjn#8p?bbNy?U%N_Z=C zW$c)-T>DbW%gg1XS+k^jkDh80!Q8yOr$Jo%wZGrNfKCzDfBy3yS+i!X9D$qJNw@hSdYUo9A%$MTzr`PdL4J%vGR>`ztM)cV$F+WYG1DBdI%x!e37Ed zBp%!(u}ZF^$!gl&z@90N?$^Ud$Pw8B9*=g-gqP2JezM%~doBX5!E?+7vZ7$3zLlQH zsaPPTpFgU?!$yvjA6@cO)v{;?>!j3drF?HqTD`-jxbli}dF|zwWXRB=GHCEnsjIJ( zCVxo!_UxwK`IeSuHAQn6R#-S3gm>eYD0}W_I3)}naAk?JdaFzrIZReAUk)oQ@1ZB2 zc#I7^X$3QJwOhxKw!nrX zVde6fH9zWY;u1r5I2$lN-XN=*fm38bG*9L^VMTQtFUy9XB1PwVtaS`7*_gtAcabl9i751&HKdRqD+OjH#0^Gy1 zr1$+t#Y5X+ZKbS6u7>$&EsJK@yraZkdFzMZ| zztq;$N%ULSi63@DOE@mgC?_ouO*g@lX-3(iTN?GZh&|9C{g%EV#ntQO*yB%>FTeO4 zu44WzPd@SJjq2jk2)lI^|M8E1N?BQ1hs4DP#YHQ@O$p*s&AQl!ze(F6JcL~l*9iFh z7hZ6|pL7E=#q-^ za<%OlGgDR!`i2UpE3#@rN7I&A}#JOFW)I2fApaY z9X4Dolu=vTAe$ziFaCyli8fT>`In2mx=h?P+ax2{qSc+jgK@c?;&QqrGt(=Fj~OSG za5>knTSwx$8pQQCb#ZBg-MWem4ZB_>myS*pUkKG<5fZ@zq7_CR!B<1g9;t8d4y>q5 z1JGAE4e}y{eIT|#l#d(_S5PIvo_C5tT3qn3OG%4xxm`QFnVI?)z}X?v2sRK<1}qzo zZ-;mrwn}FG2JzHv)c3-3rrQ@`{S(|ivpd+1TbLA2jpGs73Yc8QB_ z-!7r7EbWU!QDKmjvbZP=lgyOcxEt*5T!#);LTJVefY9>#03s4eCN7(^r`U2hJ(sXE z&o3D0YUJeRZZYalh}a=QT((#Qgj6SC;aN3kp>qFwO?Su1BAK{IPsF`*T^eaDl8^xk5IqU#}LEWtR#QG@m|=(diDT zW{{*pd? zu2_rjp#GrPBO!4%*T6y|A;CgYgtScZw|yZ+>)w`bOP-S6pWi9{-u?p!=?~KD-8-b` z`+t?5v+j~^pFJSQ23N??9bd|seO)rWca9uCX`Ebk#m{Bj_;K=!D}OB){_uzTnKaNE zWi?8Nq-DgL$jZATDiULe4l*Q&+3J8_op5?T$L0wnaRN#nKUbL|mGy7)iK_ zG3u}uR@(?Ojs$0+U1UH8fg!*Wt=5e#Yl_(1syo$kNJ=e!*8x^@V`f%nf~jIH^&p4+ zKOD{;ZWecQg?M2hW%;&BcKtfZty}^^`do_Ez9HQgJt4h6`8x>d_tN*Bn_wZ4kYFKw zbf=Vl`hXP8`=8`5dqc7}%ocaWdT|6=8{bYp>rA=xo_l2Un9*|2efP<6$DbfSz3g&1 zYWfTrJ8qm5l@tkI*G=m;%8KR7^rJM=I{CEIg$s&wNLndmMNKh07kVXxnYh{$R>*HH z87b>${8Y+{hN@#aK-ybe?N-j;c;ijVbnUQJF|obtxYlhg&e-O|Gb-oVlm5ypuS}Po z^9F`M*2Y7dBvzsGlRZluJ$?_Z2!y}=a}~cI@apStj(PiyHx|76)|-hQu-i`kql7&B zU}`W}8;&3dDbg$sdt4mxu-KzPv4>j39`uQ$xlU|NwUXhh6h~tP$cw8`?R!j`JVgc# z86>a0@`_A7a+=JUJzMbJODGVOT{-mG~aJ8A()%B;@Ah z4Se#6$2RGkX@lKX&RghmsGBb)H_@JdHc5-YhavlovbSX9L^yTcj(&i5~r zA;X8ukA8ZoeCG!j$i zjW^!=3 zoT_uE_K;c$sdanTajn~0oUzTX4u?1prKP2E^;K7;8*x1V`AMw$A&Cc8h@;!JYOEsg zBM2?7{f^si`&08H4?bY(6LDbRhFg{oQYru;6%-UoaVgw4gh^H)rCR9v3}*%_r`LPE z-o?cwC5uC$P+3Dm!`2`F@S?BWP2jl~UOE+S;ICm(O@n3S{VJrjJHj%sb<1X1wseV1 zKv@a|V9A;Y%Wwtp&Z~TP6b+HuqW&^)%WTOEwr$--`uHoayp)!n(r$_C_rLqS8j3^z ze$wPg`h#jEq}J_S$F**2amF@@t63lF)2&-Kx%%p>(~Y<|!TizD^4rAb9WC~}GZ^<7 zWCo;jrC}fAjywL+@X&qt=IWbW0=L&Ig|w9NK}~=@K z2joS<>eIWA^X4tGY176Dx83^3g?e`T9RK~_Ge^T6ygCpJ%nSyC+3k@P z3C(c*I*ZMlH_3`+OXY}3lM{1onP-(?d8n_WvAuiP?e^HqFTdD!G=3Ujw{=|X^=?R4 zVSk+CAcktPvw22{J@;hZ0QMXC8RUT745!oC*|zw0!G2&pd-akLhmDe>jy^hm<~iqv zFZ|(;0zbO+XAPHL@$;QOzw)Z}m;L+~v%hn}1&@8}yWjoAx!*khq{&l{99>e{t?0Vz zev^OA)mQddwsh(JH8s^JoHjK}g4gR&`LZ=mM+cQY`v%|p&bL0k@PhB1@zbCDC?`87 zds1dr=8LfM8d$$&)Mb5D(jwTmk>KxWt>0=DPE@!nu)faY(Y<(^ZU6h`2O-+ExURqM z`h>+b^~kCE*QV8y(k2z$ETLck4>Tf~Sy_5^t=N%~BXM873@gb~b!Dj*7kzr7d-v}0 zo8SB<-7Kz4A)IsG0Q+p+tOXAY?!W)R|9kf7|6RRhQ`^R>EIePjZ2qzL z-n|7{dPC>t=Bf!SH*VZSi)$Jzt}pcD`wjO!@X#m_*Y$xw;3R*GzmR0}Rj^_GI$6DH zrA(PRP3racKG9kT)zsLiNR8w~lEO|!kn9WD7|RfwuUgIHRaI3bb+xs@mtJ}yQ5Ts` z*sZI0-F4TA&*xLbHEr6oHpI1Y<3=uPC1b{pl`p^eLR`kzKnKaE@!}gLuzrP(;H6wX0Xjkw;CJni|a|WZ7bw2!tZi;>wh!j4WyKFml9y#l?PBTCqo-`!y4Cmm^UrpvOMkFpx5V|^Yk!*{uA`o?c@CP7>?j-JtmxF|GrnVx-7R6P|Wv8W}hYM{BSlh4C>z9oqL5xAAQv0^96?m0xjce>*|jT2K}S)UJrs*T8L}2_v+b0O1pJaWuPFxP<@oQ zZ{McYVrXjeNv}S=WzFif;^;k8;wSw`e6>~5T)9(%RXZeHvs0vQr#PExBsb<4x5FMo z`QqH(9F+e$EZ#po`|Q(cJrCDziR+rHuSpQs(KC-$WRpr<1_|vdu60|BGqy=wHPzb0 zcqFdtufN_Rt~A11Z@rak_jm?m#B2lNc1TS6@7%F%^oJjOFq4GU5piwZx<#hJ-Qtul zUja?{$o@UkO~>cw=l3ZpDyj1Mnk(P|&HDS_ z|1ulI`PEwxz6RJWaj{>OuMxxrQ+MVuGfgD4?})3qQtLI&mZ%$UxWOW>LlCoO&B_J= z%&^C8Gh!lx>>>kDKnK8LD%6uCFn7)zS-WPnBCK7wiZW>M5b4{uuYOeL0Bb1t_M5LC z|KNiUvdc*Vci;U`?|3|PSaognbbm|Bc({AR@DBE@tE>04G&e~foagYv50~!Ux=U78 zrp%f1rL0}IK?V%$FQvuB5{bs8JIae6u3a<|QuAmPBc3xr(9`gE+<4#P>b-7i_Nkuu zMMXtw#)q=)WdWPRaew#HqCZ}K`Q@GNaQwaR{opU9rKOh@mlS8MU$#8fSRP(^IGvG1D9;?VkBb|LmT$~h*=+&#Y z{O)(Zvxw^u!UrFGd`#RHXDjIxNb*GO9e}g1?%c6M)e+_8=1C8@T_i4AF59+k!~O>K z?qp|Yt5)h=fd)sw?^m-gY}&9bEo8>;B$H(k|i6U>S}6a!^VxU0DCD*kMAZ|;NeQs8cAfsGpU#Lu);F4 zyl@#uiQQq7y1E8fVa*6x>eZ`Ralbtr z3IFqr*Is!GANMx>wR-pN`*=JSo5-d7JzkKf%PFOBO$QDfC`U{@LIw{SEIGM3;=ym@ z2Y}T*)zvlf=9_Q*`NkW6|64tquPt^>7h4(2@pUEW5^#u- zMO=ple)z*5{^96jj=haPDCPMRoF>Vu$rV67FaXfF;;p<@NNZKS|kGn zxqrWYD7<;HL$4I)hjHdH$4GHep(3a)Tec|DqubW6e?O_Msg(whk2Avwg6fHLp-{l5 z4Fw&W( z(9MFOCBZ<8R8>~Vn$>G$?wq;u(T5+&+i$-kpMLtOY=isd%y39ueXR@}JV4Gq^Gvz; z;)^9GJ68@n>@c`t#ZpjIB$KC1ku%Reo72F^;w4LE-MaPC2OrAA4jU<<2;8>jCJ>WH z&Hj*?m5sQVRM%9=+I1UMHy>JIBssdRtTJJL#3f4>%e=Ysq#zH(2a;qb?5c`#rAbWl z=gpOe{_~K0{>2w+?L@90O41}j(v8c*wQ%N%?PWV;2MDpav{*)r7$RA?jt%QKsPu*T z`C0Sl&bfZ}>^U`m|Hs`A{Oe!;>cM;U$tNFu=ytn?*c}ee9ulVo$%zPQWbnS#H~8eP zyY7~2esi5HSg;WHUYp3!4htdDk>}03OFo~ zb#=AM-Rsl058R+hs?yu*amhPxzbB`icACWEQCYTZxvDQE8L_2t<;s=H3K=$N-NVhBH>(zIT2}>y+9&~5XEfry?ANcq zvTRtzQ3>m%48&PgSs@|3@1sVImcIS^s6|^BEm)vjK3)qe;c1!W>)j&wJ0f9L;5)>N zaz#swuH3x&^Kc*Hs^NiUgq9%7Ob+f7%B8A&Z)x$b{N44xIZVIB3P&AvR8B@l#`U<3 zr`hd}K{?r3nRJIK?19hU$ord*JUG$?7TC^bo_VULe)!iCyLA5|%Lsho z?z{Kj>I+~H*Y>SkFG8d*eEgekzS$zKLkxHP?Qi2e8LnG%agre_vLtSOLPzm*Y-25oBPO`nr1Av9nyQ z3{J9u-w>@lr4l=u*TRr7>R_GWyAV0eyksU_+c3` zY^WSI;xLe19$Y`x-Bv0WkZxtKUcJ<00_)eWQ-jMnBZ}6oW2<`C`MYy+^FdS~bS||I zi<1UHBV4?Ox;iO`t62vl0OzatUKZqJN_ zqkfR&ik24NrO!V5tY$5IO_5AoZ@=Tu%ggteiR<#8U8WHinETYzI!9cbQ|pmOACobo z$KcCZF3XoKlb>GtGg$@`ef65vcwifpudj#;4|eMojksuT-+aq0NyJrIS@F^tr=5DP zN?_q@gFEkhs9P}DIHta#?r2yK<6$ukg{##QE|aGcAF{!)cKX6PqD4Uq!|8O(vBw;( z*4|vac&U1?STB>8SD;q6fz>7pXptcABgT(cq~gPSQeIK1>P9P3u(?Xqu;Ih;?%Jfb zwnjFC04Izet17RVFV9QMgXF|IEm|X-5OBxN9Uz?HC;>KgEm2rKz2G(Y;C8WYigSH+ zFDX?$-&G?3NU5&2R_5b+*cXdwSs~63FRz>RNCAI927*A@nmBjvLh0SBhjLHXuV1U` z%;>Vx;^b_roK%p%wV@ua9>|jxVQp=-BI9^G7IQgWEncr@v)hyNZcTmFb<3A8-}TIn zX@Df+dh6|Xx8R2MH51ommtLxfix2tK(@#$#uCZgrsyeW_@bgasaeevaY&H0kQ`5|y zJ6}BvzHF?tq+7{pYo<;)Ql5VLDfI<0h-=Gct>u?y_$`0@V}iJ7LT}x&`P%cpdEQ@C z0t*KfZoc_udtqUZ0gcVI6YFbz)7g7G7z_*oaTMcqa&FTtX$}KB=9rnVI(iD5@2je6 zWbN8D%8je7t-~9n&6coq=@La$$5{|^+Di$f1XUXCv zQVch2=&&KmGTV#~Agw2-%dP6ujGpUD7cZ6|2<3@xCU8?HGXc_W-X8qF$Tr1Z!G+<0B@X?1K;zPUX8;u|;e%R|kvTR)7#b&r%eviky73Z4e&Ca^}?YH0N zicl6(kW@Jz2>PF+m171Uys^|+Dr#`UhYT44-~Mn_$HmqQf`s$I2k(Qt=BgHsOs_}2 z^{sEIJ~E&@F)vldm)6KXwE+NMya2v{+De=j4l0~+$|=Wf*s#g>!3S@z|Kiin|CgEN zx@_Xa2}hlN+G#z$dEPgiKfL%NIsEWZYH~;t4c~)#^X9@jUnp*n%vf0K8#ixJt$nPJ zXPwg7XPu?e215Z=z&Bxk-~N5n`8b(nBU~rCRz;kd0#?wZNfV_TKCWeOH`$$m%Y5a- zon&XvO`A8u#j018;)4baQkCI$xOOf6pzPRQCS^OyRQ=PSf&GI>o z)2&-~RiCwC-CB9?&9~$Qe6(MD?pgWZ-M8aQ7A*+W*Vb&v%*=XpVDDa&R;^!WU$$~Z z*1U!DM|}L*r$4hut8=iCq~3h%?ahTnMg0tm>(ZZGqB;c9;yUB(vyv<>hD%GksY=lD zojX+}D&vL>87wPTu2x|qU4CA^^yt}3J?M&xoq8TI^|EYQzg}GcU4mP0yG>bKtemW> zsJ!m1v(C6f?X+-EVdA(65BBQQ=f@7GO9BDEjGu4>ETu83&XTScE6hLn_!Ct>MC*lx zmmf5^IWhrh3*aJER936!Pj`uh|C3oCOAf+gM<1>}a-7y>;lhPTKVG?HCCXiMs`{~o z3l>OGaj}dTK1^~zG#fU;YR5ZUP=I{P%khp?gFFT*!s0;wMaZWg-miXr`YLjwJI9K5 zwq&vr-32SHfB*hs$ETF_U2E5_6;58rPb(+?V@Fh;myHCR8;sp7w2E_RSZaJ5z&9ZK)LPq+hyzaZBbui z!=3ngb3S$p2O$RcA9!g|N%1|s`}DPQU_A+oBsFs6VbZ;Oi6R1;(<@i4hDAOK)_9|A zhov)MK!3GjP8dWs7gmzX?Uk7`r>h>SB$Tb&w!unrYiS1!l-!&g<-V<1y-I8#nW>W} zBioqzFtRf#NsqIWtXj2F^`ROJ>xvcV+qQ3omDYl5>84uh*wsPJZw0UpjIDyye6Kmn z>IWZw1h=z5xvs1<=W0AG5A1-d+&qvI>!q?YvtYIPbytslqv~<~N)T3^s*~dH0J(y3?{Fu~84loOlr z(K(IIhJu+SL{9W>}I zSY0P~>(NuWQhbNTA2C5rKlL=cQKCqKi$bvDBgui_WO_TwcEW`mp@_x>cXP+ioggu{ za_yEbS*GT5XXj9kwPQx}=Fa8Z^fLPJ(JD_)q0Fubh80Dqmg;CkxR^#xc9yyppRWNH z)MjIzdR3{<>wqPs6O>kQ?m}M8jg4CC9xKmDQZ-f3thV5cGB%t%-DOl9P1iQ;V8J!G zYj6n!cMA>)E`z%>XmEFThv4oucyNc{ZiBnKeRJK|HgNRZ?&aPc#=INM zr_OKZW_95JM9Uuv!zRQ0abGA{^H1Ml+vNOJ(ET#dk3w#)porNt`(46z*4&w;#IkE_ zT~J>$)%VX|$EK!E)Rf~?eyUcQHJXwv%FyPPGW0Jq`@xF+1G_(DyP1-Mhm`P37@CO) ziA)eHnVR3HueF*SgO8Ve9uI#dBqmmvVVJtV8QtSqS*7O)dX%ytWmF73my(QbMK5a*h8cmU%bt{u8J zd9EAYF!fW&2l^9>SXT?h>$l#EyDHUx!(q>f4F-k%}_YGC8Wcc47zU@@RMD3k~u@%4#3(@E@D? zHeCU|mU^Gj=G2iV93LPFajiU8AJk9vAgp7L zqJ3y|LKsvb%XZswHl%>9XJpi2`cWZ3i;ZLk35z@7jiqYoKNt#2`DysXKORn4zY#$5wPh z$nI4PHW<7Z$Eu!cI9nym%h+JFv)swslC-2M{MA(ppW7}#UI2_RGBu@EHA?l{9R z$z6uz7LfhRQm{@aqFPVgH6_TP23X-$SWgM{}4|35vA)gYrxN?A_)|N8)Ao|rDx}~XY*oPqmv;Bbi6*C@W0i0eh ztau_WgcUnEGe*GM`J;Akju0LrF~Es%r1wtTyE7Sb87LBY);%l?-zN9}zDL{BKzRE1 zqjqfZ&nO-p8W$VFhx4K9)MDkmnGKWIVdtquV9)h9J+nPKa%eX`F2%XZbZTpL(!wj&%QBfYmsBd(J6xl? zzx|dK_tur8#)gt{uaK3M6+Y!K_^ULekdanrwN7}@OC#su#q|=Y!aTDgXc4d6rMN`4 zXpNZ~>>cB>x;UZJ0yJL8h(5_4Q?F*q7POxPl6l{5!@wJrj^`m@!0>yyB1!ZAKzBuq z6FwQc=Vt=fL)NyikSHqV@~U@>$cpGsU0wa*E~8WPW_?4ou!av1WctGM^L zomK_%HDsgEEUeg}ic>^kvej;XhgXWJ9=+SsEk1PMDWT{Z+_$xVs~Em9 zq#LY|7i>Uq4LZ-C^j#yrPUs}^HRx-DDOYf8*bCY%yDf)5sfV_ruz(o41{kFGFAI<> z_a{D$)W6nT$S^A~a?v3z?%VH=)i7gtH6yAZl3x!*{~MhXm<3xk%O0*R3{o^y$`uk3 zwES=2W%!5&J}lxB>62(dzh&c`oiDtkb%GAV)7+xYn;|}$0~V$J4$qlypCds`nvc(Z z=Om14sH*-FQKn&oqCBXmb?w{SS%STOT((ui_T;l7c8#T^ekL4Pr3;+lu^hs2#H;~n z=H4WTmS<`mWCs7c4rC6W8p~}Kd;F)P$yv33Qecd=Gq^smeaXb!_tJN|?O^f8U&s`- z`Mgxu%0FouM=c7@D1v)H|Gz5?9S6rae*xQ?RXkA2qsW~IQ`JT-qK~|NiiTqEcWaEl zh0XOD3A09FA`kWN22$R@0Mr_B=x|$&@gH8&X`5`!HS;;!I_2D_7*TEY+Y9dhyOPMh zLDbACC^Jh{nIYf9{b$<|7RBd8tf)3R$fyTyYTr+UaPqd%<2J2(-r)Z?4unt=y%CqQ zc?B5S!Y^NJl1(<5)enh&W3Qfy)#*>ugP~{j(DODc{4N7AT=j?$+zGC+cIk&ND6F#S z4jag8L_swL>PX1AOsCM~a5QEHncgk;{0@4#r1GDD#E)4)b0=p=&I@30ROtRUC0fy? zsX!c0b5Wi=qExwOnjq?-krBNB2Q(VR3lCv%u{Z=;GDP>gcKSEm%1js?)9?8g&;QFmAoEMugcbFLRqF*-Pe!yWR}AD`W`La&jE~=+j^6KK-Hx z@@0d^{XpalSri15QNMqLe1Sf5=s(47FW(LeIHmiBp$7|#kkBakx3m$rj+tD=bNIZL zb9+vxpK}mQ{iAHaMKutm;_`gaA3wPX!RRhjd>dCXN<>#zcPH8x)T5nzNFD$w2=PGf zo0`t6g^ZtUY;*E#gh%+=Zwd?H-XRO%Id#t$`Ju91AN%$HlO2RVI5=FF!wkO&4ucp4|WjGY-}6sdwsQm<=YGe6WVl8KSqFh5-I z_NoyhZ;&aQaOgE2M^)Qwc($~_wv!m96x{Si-LmYoZ}$Se zVSVm-R@SiC{+ovi6nq*UFKctN?`ZV~Pza8f1=j(me`IhTl81+iy zBnqf0G4O^f-yGy^X+t@6l>yW{wDNHTv*uxoCp~hql#w#V#s#Nzo0v5<*1wM$Rg~U8 zvyS)X{C6WmS|KOxE$uS?0Dl0Ey%db59Lf%g!tZAE>&&y|F?W1RSxyf)bo$S zKo)uPi;JNeHGt`x2u2nq`5F7|ifu-W#Ua$YI}T~><8E5HK@vBl)&kUDG$%awiN?+o zw#2j5Tt#xb{*V2P1|5DO=b| zS-IwWzB2Debb_)R%=P{zZs_Ee$W$ArW>;E2oAWo9qmt?oRb!z4XhD^@B!n6 zh1RDWU$)L~*esj6ZAnQm4Ts#R59UdINYYu&NfvbKot(55aec2K?W)>Mj*^0|O;Yl6 zHgHQcNjON1cUks6DrUr-3gs2nyLs@WapX*D*yI@H=dKlwFt}@Aa&G&%@6I~fTK;C>`ki2ABLk&hT}~xlyyn$gPUNdC_Nl>(|)@rl<;T z1lhSZnM3#54E(RCDhww=Ca(8&>_<41gsB?Lylt#4E%zS*)wlBAOhFg4sffnQ%gmOT zuhQIGJFk1EtXn=QGVYSWOIs0bTcd3NyAg-h+Os6kI>qTGX5=b1RH8{>Uai;DfQ?q0 z$v41l=^Xc*ClQgi+o4tojr37=+tpd#z(s1bPV?|ze;68WS}Bj)L;6n7ha_GnUW(%! zm<2Koq9Y8tHDXXF>NS%IZS$8|Suz8MuPBp`E0$X;zMr15yPh&T^gRn9PE%bXk~H)e)*vBs(&!1`bQFc{o>y{44gfjdXF=Yem#MO`XBEzB}(>3(+wrgjLed)$1DXyv8kU%Ga;RU z3)+$0?%gbZJ!<_~K1c&`)nm^`Zea2;z{QU0nblC&2R7v`VqLK{^h!R+K{uOy#%er7 z*G^&efIsjjKq_(#u?Py`;8zSW=f)2sglW89IJR`WKH-_Z1F;aX-=~ro8*-Bo@tRk# zKo0WmAO|=jJB|x7(dqz{K!>9neepCqo?G!abn?MgA1GeL{G2b}53UYea-g>FE^Ncg zP2FdZ=$KeQ%;CK?cwP!E2~uJe-t>irl<3ib#%rs7OC!F8EGa9!@VBVhCM}Fm>StH} zq2mmFGdF>9YP851JcJQ0eGxA1;6gt9?rvh<=-gdYs*VFbu1bqts|_+ z5VYHz$)2b*yHAb!0=QK;&GzuHr451M&L<1H9=GSrozM5ludiNv>Rb!+<&CbH>zaB@ z%n&{X2L-&^-$D!Lh4Fp59YKX6%Q8S^?^3``bTZ&l_nm)N5rH}Pj&3Q--v#m`8euW} z1u=-DX=eODRdCZEGG4hD=VWkCL_r3REX;J>!2%HTC>&57K9(^1q5cB2tG0b$MUb)P zYL3ivx1|+}@pFJuP@GJI$s6lw!%`%Yz}naT{aq(E#DSN=7zamjaMq@m zxQ>3pp_Pjhu84vd2Dq(jMoH2*F3n~GXWBW}Mb6@)EHeLmY*#jWrf!#yys};m!ZOs> zsSK#=N#5;jTt2fDTpiWJ)PRHw3p?s%H)neAV9?io^XU2&@-b)8LS}@>?!BQn>q`SI zvMYul35iFH2gbt|iZRT6a4KM}kF8~OwHrUdDyC$kMk7827x!TP08D`d!hL_d5Vz~` znMC0y%&00{{4aa{nU`Sa>oC@E=+e~FGpYlm$UxICWP2d0D3LNab7D`KW4+8AL_OI` zE0U8;2aOoXNR0Ls$N5#taFO%9k;1Rg8Koo)Gj(Y(13syE;wntxRHH39DS?_^f7Yc8 zlyqX`B}@7l4F&sJOhU|U0->UYyC_%$IGFu30x9e=CEN9M9hmpMvGo(1o%2cT zDvp07u*2)M8A5ay?YTBsvv6y2rheE7 zb8Qw_mnvMc5fC8z zXE)45axAXMlJjI6QvhVqS}X*whtBwX)P3o8Nf>p)J~^`4rZF{T*P;O?rpxspf#k>o z1!_0x4nwwlWwS()R=&M1Yx4=Bd-I12tc;`rrSp5kja9CHx>q=lT(wUwI#*WbC18Bw zwN%$Q$w44ZHvB+IN;^=^VVk|^ZFwdz;&sQDv9q@6;fF!6FS z_ZZGmLr{qrjM0PvPp7=R%j_=4*pJ70-WOf)q=%_L-NZpTJA4+Cl^*=yr}O%vV7Vj? z)b%!a3eU*oIG*cWtR1U#r!UH5{shist=E`%$WH`?&|+fwnHJ;S`Uub9s4BWKQ-~^HGU z+=6am^MSf;4wEZ?iHf(L;{T-w+G)8yt*bBitu@Xd@%lgt||^?PeqnHaSekos`xoAji1aQ?J{Lnu%D*Ofwhp%hYpD z%CscFO7&(2*{W}S8FWV|HZ^@G6~|1Sn2d=*sd)d*9Npy_2Aw~YCvXHLhsQCWVbImN zW{c_hkN}9uyKlK20|)EAW;<77{~EF~6mLm|S8cZ#l;R$Sagi`MWOyKW2-20fm#oN- z=YO%ha;xt)VjKPipXA5#u8#OvM6Sx(xj2z9^nT+9xGx|ZneToL=3(T*?>GI8Xc_J; z27rhD{U}FKBeL|34a&ye&kJSyW&BJwtXw!?10fH`n7A9Re(cR7O-0rBQ<;A$>D)hL ziqnLiOCyAv@=$6IO)3D?cGExRJucc!Pk3e2C+yzaq(zE7j2m7U3{p9;s)%N`6gmg< z$?!csodBw9sGy1Jq!Uk6P1g?`=iMsH>`zg)fdZP7O}`adl<1zng>YTV?;1i}GS2KI zH%fgKQijRGiI*>nW1w9DJ~48_)Hr&m6OgJK0tV~}=pGJe$*J>?4|w%5S(id!^-PM_ z8v?>Sz%3bL)@#vm-0GCr?sc-j(RD`?2fI+fK=xD$X(9bQL?o_K{iRvvhE|q#3y30& zr!om*B4*b=VGR!@_#pQk&9&_WOu5S{&w?{cGA-=K9Zw?l-l|6w?qXXfW6;&=L_bb4 zis}46BpR(+vDb=#9Qa^d+<{W)JvK_LMLW2~f?(sBAaf%>GCWhDOuil$v!Ulrl^dn| z(^E_*$#tKxPT#-hIxm9|Mx(|#Hk%DD^rvm{x3|iP$($V;~-Q{^80?ne^iaxxT>RM9t1KJD+xbIoXu_=sVfu?HkDYHSIl{C zbbovz;P45^u#RfzOvvK-62jNOfY+gCH(-J(eKHIT9lNFI9N2S_lT(T8c$vAWcRsf{ zns0w#y?A@*juHyC^e?Q7cr~W*#zYEULv=y5`mF5peJL|@@9TCx1uAlv)}{VzI1e@# z&f;+feRPrxUtM>n0C^ashaF!Va9sCqu=Q2|^3Fk5aQpn(5;Kb_luY%`FgWh_<2QSy zC9uUpWuTQ3V+b^8!l}+t2pgsR$j=BkoNxFFVOOFZ7YCu)zas(4X-t|Yu~xj~X|E6Ibcq)0Iw6i4`D605 z?QE*!ZE*|E&DG{ynbhbhYuCR`^ND~N7(x=4LbadBXKQsZ7w&;5Btl{#qTeGK`;u^d z=Y7SkffEx7_0Hd3#H`bJ-0R0PIpA?MavLCnxn6TPZRsDlp%$d|wp><{C6JA0k!OAN zPaNIe^JCr3vjSD1T4850u{C()3t*S$jGR3*$%DOc$vTzNEd<-+lwl(g3J;ljCTFa; zG2KLYxVXxC@qUR5HqEhGHD6Y6G3U?kF|YL2dmK}ogpOhomn2A2lm^w8uFW$`oH?-& zt`Z2S5a}@`MG7&J&`4)w0n&LiLu6;&vNhk|)z#ESLtIX)hb=ORzgZ?g@)n{1fTWPE zL2Cpq*54ue;n-j-5EH?-c_%8wE(dw8?;)nHMf!THGfc77wsGC8Rf(B+bHk`k<$Fqz z)_YyasMp3x~`YCgtf%4J}+WA%ha>URDWS-9nr}qSQ6z)F;s1#T2v8Y&R z&|NC&V8gWpzdqknML^UN=PkJIpXL6j*q)NgjhmK@N_Lu zBGo@g3|;&_ta9RgJ+uGS-CQSfd}TXz83#&Bl_Uwrg+dEHVRZ&OK6?VQ>|Ux!NTN5g zf`WIrD>)9EzQ{sXI!2oh*F$eTr{`i)O+fs@|7P_INxUjnUQ3xLQ12XD-S zB}Uc4pIOGC>$!{pt#Kib7Yd&8MR(TZ9p-;qvFWO4#(O(phO+n(vS}og?xX zTAU6qQ>(17Gz)$r-|mnhzfT<0!Ad?+EBDXDr)@opw^bf}pHs&8B&{fK6XiA!XLL&$ zNof&~V(eJeg2f+*Kv9-XxkR4~_WRDsSyAQ^HNwjbo-x4GSm{$Af;PiQWkvw!dpctv zorqImPA*}n!R4+3q6#`2J*mEB>S~EcbmU`7w&@2KuE@#N=T}Ibj36{9@({)bBvD3W z@%+go!|YQ~Wsc2LUlg2v!iIgk@H}re3$2ao@-tQ&=rzSih4uQMuL2@rA&~9^(Nf3P zh$$mhAwN(cOY)p@RXNlw_rANeIk3NIWUSwCi%@|SWP0dKEC36SKFVqsbhNL&pL$Je zSQh(UQ0e4dSX%h)uxBh(I+s9c3@^Ba6f2C(1i zSSBQt&*BLV(zyd6qr?aa-M)b$H- zD8**68HL`;KcVVa)5Z4ZOfugpFG2pT%7_f}Gx@cwcse)}Y}a+mHlAG$M-=~6 ziS_SE|n|j1Lkwz;ILsaQW?##l@(jSh|P`k!$)5+Ju3zVgjAhNa46D? zU=r9HG3{Ft9gHGCOZ90I$|RuZ31(Y!Gc$9|>YFfmCh$yC@LTK-#b&%kU_aqTzs?BG z=v-~w-D^WP1_~?@fYhE5*b{su0Yle8f3A`tvvh7nQ~fh78viT-LhaFfe>l>1LKg*~ z?Bp;yg1ckdB>cvC@{AeM@M_?97hM7B8IVvB3=B)A7dlMcGv3u#ctaZ+TnwOa^7)6Gru`70^wtnuCq7NL=Ov9w`z2#dI zBdnpD#Vi+9ceM`i$vOaHJr1cRpV1{MWO9uSMiZI7g`n2^ym@G~+htekwyQ(BoT)0* zt5T9H)JGz47)_q8aq69y*|pjrE2F+E4P0zc+R(q>22K4spsvsVWC1Vp;I>^_VU!h{ zdlN92kn|h&*7uas4Y};zWvO|LELBH#XQ`lK>&betQu;qTZ3FW;hjvs|8*{jl|2-rI zO+_v>?nbGzE0-rC`H*FQ_;<%UJb|AZsz~0h%xgfvNi!y1YL1}iFt2$o70l<`P|29z zg)$A6wxF;R*>EYq^fkW?*0efF!$B@%b5=TvW9!Ed{*wOV*vDJb`Bf;{70mk8WF4W>LpO86@9`8A?+8S!C8j*-t%h-O_JiHj-7KM!lEMYh05vR6t|c zwGGq^JO*aO*FvJEE~|C)RnaF`g$e^ z)%_I`ZA$fBb1zwQ;cjOtqIv9F2X4L~&L~?nf$V}Wp?;~0<^(!uHL$=4X;S#Gp)Aq` z;{1IKD{PR6Rv(a7ZMvkd7&Vchw;uZ!r<#pXNI{Re_5;(RsWt(Y3@CVN|DWF^uu%{C z?rZ@RygxLqH`0p-rQCL_hC?b0Oc+n&RnZa) zGIViSc($^zh{MbA#MK)VAz=3cL8flVaR6&m3ymveHnLBX*;aG3qA9F849i8; z$(`LQJp&=LsJ;QEVlym2Tg`60^Uez&7voi`Y6Pi+z>b74WIKcWU|7r2Bcy~aK1vp$ z$L`msDXUd^K;6D1d(%Z?N0&IfYmM~9kfBzxbmg;8_>0CNzjJ9d#_^d#K=x960wlie{BwS5F{M!{dTXUOzgr3(Zp-*yH^MoMz?)Y3}g zls&cS!>lCxU2R>W1s+akA!$AXP8cf}h3Ih5qkcuLTdQtDaytE8Qxg`#=R*B%pM+ff zKY&pZQ-10gXJowb)P!G(^n%~2%$qDX)d2PKRpBe&92#Vl5uq%B82~KxsIRPc-*&Vx zTNy76ApsAiO}_qL4t11OAYV(J8A`Cjl!br#Ks*)K0w+*kvr2H4#-T2H7FMTl9!p-M zU;YjBc%_zzbX-k=XMOiu06a08R9VS1GCH~ckG`mN7%te!IzEl3Khz!LJBlj0d)UxU z0>>1OE=&8Zax3^+&U7%UU^jrwOMmiZu+?$2tVB9j=nYaHAzMgS;<8^UBL~bC!>>~tlk_&lNi}W>iTw!Ic@}u%kC*=8Obh6@I51mpN(HcRO|iwN zEH@Oswz=INddCczWxquVZ#bHxd#ea=_>was(H`j>g|B5t7Mk4mF$h3R{HLQSmM`d) z6nDUd&F!Fl&$0UHoWb|&i0tcU#+u={JaN;ltvqFY4ccT>A^PE4a$O0v61Gi@nNUNy zpdBtm-Zd--_krAanu$rKkySP&i1QbH zX`2KSZzK#SY?PVWkbWcohu?0|7s3aQ&aY=*G%Q<`Tdy^`g=(uJh|KSY^a}_MNC*s$w=^zLC*J)zsBj9^DMG?=eGqv$MP*Wvl3iav+#Q0OkC?smP9y&j(Xz8jnU z^!>VFc`$NqCspClMp@!mmgIB)2MIkW@?mz21&=js?6}}LOCy1BCfO(b#)_IM#Bv0(^}1LVWMIRZ-cp< zo!aF)gH9euu6g8nX+^<1x)hgAb@l5DFYnZ=>4I|@R>}xeS;Y?v>KoNH>0}B0 zsP$n$apO~S%1xN_er77Jd@xGiVvtdq8RqrVBMlwNP>9LOC!2{b zu4l@xw&>OtVZDnzte*-;Ri^eJSK%7$IhjtmUpmYJsl%6EdT5)^hQr+}JfzlefMXWm zSmx$N`RHAw)z3~@-_iVk#Ae7wunVb} zC18GIU=jN8Pi{z0&_5hqB+)Wy2yWzwvDQC=qApr({HJ2uwSBDPF`p<5es(9&E;59s zPoMF8kp1er-52|}A0yRz^sW5+G7HUc9t<5P#psR!mCoxdS_By{?!?WATs+stli@_P z^EF9j_k`)w-4crF-xMZ!Ziso0l4f^@3yR0mzU`R&^%GUr1QfP?ou6MAJIM8B;CCyv zCxNs!Rd-`)KBxgysU?Ghl{J5o!#zDE?@XX zg)Sj?RoRzD40|vyHT`v31y9(x;LJ0X>KiXni2}Ja!iV6+u5FXY+fWm9TOlgbzVvp8 zTaoiJ$Bfgx;LJtfYT>31x9r8kMV#KnhopzkBRWC-BRv5KY&x>crZc7Bg!5#mNLdjh zJ=P(-9p2c?P%qA?+x6*1wD)Mo;Fx5O-}LR-r95^a9}d}MFJiAAYIU{6HnDtEb{lCa zq+RB(gY*d}PPm{G4)ZDV8srR&yA#laN=$=^emny2vvAyaWGczk3I+03( zMI7PBH80OnNq_o_%EVJ{Y^oQ>TsDUDm_bC-v6*0{7@;l6mGt z5M##kgH}-JxdcV?GDyDkRoz{+p=FGrp6nxmJ_Duu>PQP&~j(c6`N(PlfhT&|ma^2Ws*BJRwG%tP#d zu#^zFE9YlM-to7%qPp0JWCbGJ7TKj4 zZhUFLqOW#m;HE%$Z18<{?i^xbdKGIu=8(h@uvMnWQ-kOBdTT16vCLNKY z`tS!_ui56?XYBgH@$vEgzL?Ng@R}UBzGu|o^D#{YDarFUMOw_S1;!?RSOQh zx;yRGg?>l&avSlzYJ=rsuUGLOJ7bf+1LN!5Btx^`EJDdb}LBW&sx?d*1W8 zSzs1lrC_03i~Ap4Fc?qFo2G48cgyMfWKU>X$iI`8@8EjV7@SOV>OdljmT$Gf{?Ln` zG`<~){+8dNo2VVg2Y;s6dm1a^0g1Q0w8+*JH_fz|#osc%XnwAAm-#&I`}4DxbNekE zg^TY27roDklJX_QX4-&vlbbC0h_7s&if|k71aEYRupf`A(mZuRhb}`d=cu1(pvfzy z)bJH;4mSS>|0e2Wn!C-7VZqQd>&IRV<$=%1s^c;%#23@QR(X04#v2PS$zd=aiq;tV z@AMiZ-1%-P=^PPG46Hvr|?Z%-sD4BZ2kl=?M~qCT3<}i1@3GVs2vcn5}5uFm_hmvTBo= zm+E{mZA>a{*gkcz`o3wbf}Eo}q~}T??WTan@c8n}b@pyK|Yr|6JyM;&weo|F#$V;jP;?vDZ&-dv#pF zdIDd9H%{_%mF7QBLodUNnk5w?f|bAj=QOnzNpjgPL6Fpj=ZxPC^=TT6mvHng<`Lhy zhqq?LIBBHWfs%!Fq80k58=dX1``q0!+~8*vcILJl+&c3qw*74nC`VElc<7c*AF0_s z^tIe;@&_`WU;3h=P}1SbbmY|Z3@qx#P)#zgps$95gdL@0>v~fOkc`s!P`h%-gY&9e z*V}}k*^JwU_mqmp;^m3O_iGqXV4sM|{bU@Di+P>tjhR-LO}Km-j|?iz`aRnDDN@tCg+=AT;#=mTD9=(*D~pA@@6On}aFK8#c)%*95_*<1K|SpX52 zP0~*~I%7!PoV7cRS&^G)M7t+c&v#n^3(zgr=KY)nIk~Fbc%pxR6=fQt#kAgYFBTI4 zfn7-)V1?WW=FH^U`>(GAXfn=o%bTE`Dc>^R!wt{m<(8T}>2O^$5$Q@4NE=iHE)Jfg z0I7Xg3f4V$`+7BB_hv4ln-$MJJ@|OJp@gylvOFFcjLtOaOHq(|JxbBh=GQzk{)^@G zl#$7b9NLQq|LWf-mKR5rTv;l^rVp3(YCmvo$_~87h7=r*kH-5Y7aK%b(c1&p?P5D$ zuOr)ST?Me~bii%*E1O@#PD+oYj?k-;L0$?%UKCbIP4g(J^`OQicbdPCpWR{}t*r_* z^okdDGsOT9K#0LMmQ--BrCWg?%!e$79LY*9*E10J#&=@L@P0Mb&h_y!>3jcD9-Of7 zy{Zs8LHUrmh&cH;&-gond^{;eX$!*MrH);z|&FC+UowFo^@7e z_7=(7^%w(5JOfrs-0Y9mOJZ+B%*Jv=0Yoh}8ICW^EzVEU&_)w0F84}8Pp7nb2A2u@ zDf`p4N$g$6o!@FLcRtT^ThAm>!P!;dmbHfkZEnt-6W>sC$F=|Numkd~E30XVf+IR^ zXOOe_IL~Tz!1*Wp)^lOjgVP)<7Ywp=G3WK~?11Y5Fw3f(Gbwn^@Htfzwkp zRb~56^BQ-2n!hc70Q%$O2;!8;_1VB8;B6_g?%jfi&Gw72Dd83ZI8`c|by)_ws6LlS zTx{GQ5F49`Mk;db$j-4W|#)3~!eclhkmlFnbuQw^UAJm#A zBX`ti2J3B2^{#geoLMEsKW@Gg$Dmwo%U!sc$$Z+7p)1J@a*QmZY0xBWh#WW=k56#` zh)K^nok_75oEjf3bcWijceI{E`kLre(+de8dWVL-OH&443J3e7z&`#L#4|=PlAKG? z!czh=0>HNq6`~o%MY6OVwnF6koW=jFpZdLL;~3uO`QK|Bc<*H3`cH&TDNz5Cy==k?`L_N5hx za5o2|zoe#u+BIkho@lUy_OKBB8^=|azK0rv?X40l&d|aaAy!=;pd%V5;eau9di};^ zVl){Qt>mT>0suVtB|iB7C)hw>N7ep4*Y>?M<5wbs}g_c7nqovjXg)7 zNVcITT!In{%dARZE8Jv3)zBtz3D?}x>H_#v4m|mEk*G$IHO)hN;pRD>uD*)p?*INn zwNCWk_(TCiq`q0Md|mAcmzL>H>gpbaRkH93QSLK3%LyHO(g<_`a-eE-rGoMwcC28mp@Rs#}IJ*$RcpnsxwNC!vBVnq9)yJyZM#0MuStx z1=68|`e%Rbie^Bv*D|o#X8mg>w{6OE$n$S+UEA-FQ*ZPCsr7ke*}5&+d)}v)EFPuS z$pIXC;MN=J9ep)aR9xis?0nw0C<4c*;w?xjC*eRP7kD^06K%T*a%injE&shSp66MM z>O`rkca(TUttL`DQ68^>n1D;@H#GaG8QfQ^cu_I?0Nwp%_H~)UCnRe(Af0DvhTnhySRG~Qj zpK*P)Fp1YFLrNbPcjB1{l&#DGt$%d4nTt6hE6KvW@( z=T`_C2_*qqNrqlA6xnT;_e-fE?+qT)PneP$r<)?FsdJD}%W>|~+HT@GIX`V>0|}4s zj}YYU5yoZSW#!N}idS4L4*vPcY<{IXx*&M$B21)GRIaxw5PDbgh-64bu4UtLwTv z1w;X~*^c$$LHWl}|3d9=Im>D&LeCwvSI-}3E*bawB8MiO1qM$h5;{5rmb<(wRu*Le z6!fdb6Z=be`hSS*+eRQ13GBnh$JUv62+Gk6BF0g~6$#SkfYCNXVY&tSE8W7PJ}q2m z@=%B;4lIaE{LLc~hWk@NH=EdVeA-H{62j-pK#quNb0;7`>zH!4qGzkF?9;okOO;Du z(fMrsRmJ1sG`eFAYw$%&?U(3@R73=l8qF(2_!&Ttv=;ezCl_rYl)Ok^0on$kTcDVLv0a%U+$K`YUxZL`@;|uPe?6LhGQ3DI>vd>$WxW-7 zeSSzdUu|nTF@0-mQbtxL6tXFm&lS=|BlE_u%=PdRSbxNSh?Ca@68B8k*b5VL>!h&g zQ@lOT?m3rwFy8Au1f*qTW@6Ku2HMn!mwc;quOvv#>me1j|IgcGHz_7n8T$~>&SQgFJDyz;psuuK+Vfe`~>LzPw zh)F7ekDDo_1-$4SqhCn8VZXKyCBh_=dzrq_*GO``IMV92%N~DnwUCfSq1 zp+xElkavr8VQ&P>umP<9AwJMYK~Fwd?A7C3Kbhx_ydxoTn`-R(=ApC0|x2BlF#Wj zy|EZPhlQ_)so1R-nABS4E6mYpUL~A<7+_Iqpk5bvT?(*(T>3)MRZ+PzbJa&TOwXO{+KaLz&ATt5dd4)lF+5ElgHv-uP< z40Bj@x=@A&_qspcYCJGXay&8!oy>kz3?zG@7`S-^OJx|w z*G`7wEIPM)IA4VH3IjrVkuKINO3EWj{p6ZHsn6=zcQH@BUTC?$2dC~vb8jY<NraZv1=w2d)V?`<0%aK7~G! zw&Gc(%_Pe|sk&%&FW!I$$*45Z2IPz5@Wjp`=;1?phsF_;5!n9na6+5Bhx3@=m|*&= zLY~ZZiS7tJ^)gvQ4@#yZ5-SN}IPfUFE&+|_1r2bJs(9K$^~ZCnw7)pj*I#++f(PvP zw=B^C%DxTgWOr_RIlgZ?q+VO1TJ&3>4JM-A@ z%AAQs(&kis_q&{YaKhN(4v`B$_~l3mC-MdvxRP!@0}X9x=>qV+Vv9{7~C?G@wwc(pHMohp=3*=;?@?a^oyJ44@=t8=H)IK}FK zh1pHfu~(P_Zd-rRZuzCKMS z6Y-f~AdJ&js8|2Js8WfBTWzt9R?fYdd&9wenY^9;$wBfyNvyj6&p}qkBWQq(}BzrEVoVRpR)GX<9z0`+)pAHw}dVKrBG+P{3X;K%o zICjboE6fi8_Ht^o((LcW>WBuTs4Z2^)H$*(!P>~~IDy|kI)NpG29$6?M zj3i$CI>+)=u3x?Gjrh6gqHN=zDV=e^f?&B@)(@Pa2aVxakr3!qee_rcc}!S4(;AK> zcPBIF@H^bRSDPX1L(@v#kAs!l;$2vnm)CH^GF*Vp?Opf#ZM>_zq)b?HyAuRf^mo~} zfFP)g2~G5A5(G{F^h zU(B?A(L7zwuZyglyFc~djScp2`J&)@2UD zENVDa9Fty_)(5Od4Nv2q=oF&RW{(pCyO3sXDJZe--znD{Q(@Re!e`2M$10tjld`6V zW!@@i5vVPs$~qe*-3h&lw#H;I=m!8tc76+2p)HVx;n`?%_o2P)Q}<0;#WcgvCxDOn z4O@Ih0NiL52i-)Rtr!o($%OlAMuJscCbKKo+J?EPE6hv}Au!}kpCkC=)d~K1rt#Z% z!|!#SCA;O|IG$&~ax)Ci_&dKSYxlX^wD8?2P5yLLHbFL@tvcjJOR=;>->N#LLUU;w zKO}O|t3=~Q=e~|D&(?jCIxizUHSKt@=7yujdOA<56ksTJ?CtHnwr>WL5@)nC$3O+b zl7S+7b~`Bvhy-Rvmz~UDF_%eDt1&e4&udW6`*KOoJuDDa0#|j1!>HYt%9!f1Gqlx@ zlbBUum&yC7i`Zj6v4RzAz57&fEM;|Q?56E%zZ~&aEh0`87yB2UPDA3@rC22*$=%dZX=i<)}Ei z#U3G^ojnq9d20PE} zvJmdkkJnyHJ7k0CQ)=<9H*LIgk3Ajd-RWuOsCU>Tm^v$c6gA4G6J`Cc>m4e;^6RtT zAf2N_{oThw>P=G1@^`n{pA-^|gvD$kVo(P91-=5&cl|yDMMsgKkJ5w1b@C0^^vwEo zsvhXMs1$A?d^SI;z|H#d(J`rm14frr)cS`pcr2R2gQbd@$g5*CmD;sxEV`basB1%~ z4StWPhf!{gcLE)vOhygZp}Gb7IQ`_e`K}DC!OJkSl!bK?`8AA>B9nQ-a7)@nC1Air z*64Z#a;@s1V7G-yW#s20eT?VsiB_lj@VS-{H!G^>w@+}9P%4!5N=*IL`#j|Cmnv;b z-7p|@!@+g&Kn!_A<6~zPeH|3>d$hC+ELx_UtNo`<^^8R(;(&KjFL6C+`PwtLVn(~) zY`--A!&Fk-!3gS}HI9oMZUI}x-R@u~?GAYlM_y~#fhx5?I-pTeRehAjFu+^s1n)qy z26YJmDlN@snFhDR?XVbe{hu6(PUc*&j1|P*aJre*BjGjVy`OWcqfZ|DkI6EV;C}^= z53^PIL3UA7r^x85XN6Qa#O-pJl5f+P+t>#SqpqCfn_P_cP4(=OQc1sGIudbmsN~rg};!OqLY>P zdpYcE9Fo+b9x&CZ(lNMl`CXls@Kx-$EWh3`M*amj!Q=6#mJL{;eTdI}!Cx$MQ`6^e zD$*(AGYa67m?Nu<&89uySINfpHJkfkGt+BNC7Uc~mA3h0Ydzx_pxJg3z(^}ZpOHT1 zCKhN8di&+NI`U%zO5`I&iPixf4Qx&t?TKi*RwTGSj!JjkS2jZP&qsSpMiR?*zO+S-Tx$$ zWQ^`Se7rs`jf^;71FCXNL3r!2T{*HOFnW}RmETkS5tsaNjK%FCZGIocSZX4mSz1%f zaIN?Np(?VPsWv^{l#y0H!BN?!lxsevw8S%(H2*rAQ=})EB#|);DRMSshhXCk8KNj0 zX+d_ofBD~?hM1N6f{l6RMah2!*Zoa7#(KiIs~=|;&hf?649GdwW8UupG-&^Qfwz_8 zA6)+;TX5Ak8GMEYt(?#g6Z^&@6LRUcnZiQR2LP})nXvDzYOY)_xWU69GYht)sfmb* zC;|Y%D_GXvrUsz~VfFZTo##kq9cmxDd@)(aFshBodJ4?zKclUGY(RqiX+jDmNI_L-0 z{xv0?L6wxCG_|)t()SbRHT+%>eHv$mKBu{v)dHo6*FyLK6%>Wdh4470FSiG zb~D5v7LhdLV3^`wV#}#3SU%3#Y6q(1+r%DtLD1N#>)+1I%m~d|H^_VDl3$xI&k8X! zf%oGDPJusGw%+B|N&;`TVQi<#5JdQ>NJsi<@&u+_XqVVMVrbhC?VQ`sR;q0YK0MR? zHu%07rkt3gT1YkIRV%WxW->#QvTlbbt%PRb+dZ+#kNLsp_7^tz_w!I7px=kWWo? zz55Qb7}rEq(~8mc(G(M1ZqpKelmX4rW9C;eNiAwH^u86zg9{=iDEMY@d4)6D*E!UKkGVzX6AAhu^%<-Ux32xdQli2 z4{1LOZm47Q39M`lpEi#Qna4X^1ls9>I`0PICBJUfD;<2N$ot1_gwhAhdG?bYq{5q+ zhJRcN0`HLXqjS2({xqwR6=$}GL-9?3W}A_3xa zqQq2Hmyd;zT`S(GO@3$-cDNDHxwB-LZ$sCP?hbVAkWL`|Hq09FJ@%e$+dt|L96C!^ z?@ycakUG>8xa9!G+hnMXTz&N|)<7rRl|p?vxt4wDwSc+B0LTr zdMCyq&*>E3;kQ_fP1pXniPLOf{y@+k(Folqw#80n|AXJ~jRZ=FVnshU zpu#)9fXi5$s)dKxM@q*RWt#utdP2~^-Vfris`riL#3h`;tFU##uzmiT2qvp<`3b%< ze?cSzzcc++BkqH}GbGtAsT^`W|BXN;CzR~*3w0p05WPf+X*r1PDg(h(ME3Vg>_G-- zn+E z@FxxrtPTNaeK)fV^UrXkV~A_?UuUV0Q|t~`)J|IOi%h2 zmEa!~7UzC7B9BDyk6r{`h>vhv4?p>*6WAgsPu>1Q~9q!%h)&6YF#@nBBm+~UW1c*s)6^nb7>I6M%cT{H>$8)g#J z#q`b@1p`a*_{)0QEvd+kNdQZOXr6zmlIi81=}}LdMe9ScW?D|h`ah7Z<}cO zs3NsLCLAcDuMOjRn(P03M=Ysu@-ebyyBbzG+dOcGW;)^v+}A1zk{rPavUWdUR59uD zL3_xBD?|`OT@dF9$S_eG3mHFihUUufk~;~6vJm0X?Rkmo+eYg;6CZyA`B2g7Ys7y0 zz=J;wQJf${aE)h0Jy7$|1&xdUWd6}~=^txuBW)PS=DT9=h85*3Px9g9kq8^k;}!oB zh=R|BuE$yv+pYpQPrq4 zZ+3+(yiKhWDA4DNe3P`vHJLLij>0nRiP6W6Oe98JO{GjXQf`GQ_Jw|1mpot0j<}_* zq?`iZEu)9WTAaHhD3(zsr(r(!`jmM1(1nkAD&pZ5yDZ<-H~&Vq5%|zLXXl*+h?F4) zVgRNsMr4dw5-3It4E$N{vaF0A&#!1A7}W$nK)t3w+4+|bf_-OAuAG>Ls?6uriMw|9 zALJ?ond}XwR{E{buVMUnd#mvhf+`~O^ca>PX)rDmai~}!Zv_jg&!)Zx;}d~wE6ZD5 zOZi)ze-Ex#BK^HoiG^`51q;9*`f~aoS_-$z^WUcetS`ZTqZVLjk^J|+eM_kS?m4qR zwN0Y_{Oq`Z3k2R*k&8-Yq5kzgjpI$ITO|Q#GAhsv7chlcGDwKV^g99Ak2Y8*l=J;> zQ-oE=+c&fKe>UzRT^MlOo1iHItr%#DF4K^--1Cf06F+9u{reZOnCS!i^73+9=mi?D zF5`plvbk=IWf6r^)bS1PFCUU!*Q^!Q@5L{_0UD0YP2Oeza#e{Urzc&}zVVImbCft- zJ!@!nQb-UeCjU2 zfv&xZTI4psNgNMd--_fvx#f%BnfNdf77E{h?bPq1Ie=i6!gk9}-1h>Z>_6+TRAH=t zdr%_@M&UZ>sR$fgj&$Z^9`>+bs)ino8P9GvIivRgdqPol<^5uX2^$+21DUc6L)8Fb z{jVPbPyO_djt#sJ7;%fbEGl$FIXW0toJTSF=q8XRK|HbxTh(xR-A9$`)43gJcL>|u zGKqdO3zHxYjUK>%mY9o<9X7*^>#K>C-r?qMzVQ#(+}BXyzhLozguO?!_k>3h*e=xN zVo<}@F8=nTp01DXJ3{sOx5XX(IjZyHKldqq`#W;j%B2dfSFXiHP+gy!6PERMk7OX# z@4`zcTK9LJOrI%&ECr+vQMON?57`m5@>B}{P}7Hbg3Fn8ftA)aaRgkqy~d|f!mHuh z*jQXvrwXtyoQ{`TYyD;iC=ol2?#`FJ3Q-%JfAsi}*&^c$lE;1F!YsG9ON(SwkWfy5 zIr(VY!e30EMjofu!PR40figs{R_=r#8LYmC1PYsG#ko;ZH#$#_Uh(;P#Dv~ zFs@*E^fYBF8VU^y*;&poEQ@r^#Y;PsgS|bxcmlx^g?**gx`R5fG=-AkppJ3C6_T;} zj%L4O@`Mn9@AU#QW<+5axHkFzb~TU^cRW`Su877^;*nj|50h^OY?m=N@ZJ|-%45;b?;mn+kOCQ<;0rQtJ?0r%1TO; zQPC}b2&D`^@^2S4sxEsp%p#CQ!7COeW+_uf-zF%{?wfn$N^yiMpZvP1&lOJhT)(fb zo9K%)0sG#otuyhPiUnC%AJkEEz5p7?niZ&cHPjM4vHqQMDMsL+-0@YBhDxG_vVh#! znCFP_>qEM$9EoSgvJHJ7hs8G-B7{1GWqg>!=oC-JMAQC=N`da7p>Qt+h4H)B%LBnY z^~_R)sxfaQM9+?I1je5y34PesU7~B=g2s%@ie6=|N1oWzedb%sjli_ zd~X}zH{+I3$!?*!tC}j2R9eNJ*nW%>xdbs0X7gpQU+E-yFR>qq(^B3gO_B9tEK%B- z^w9c_P+Y8sOZltXpjGZ$t(wpE5w$S+ zy6U z%?GyY1@zZsq`fn0G>P7sv}3am6POkoj0O{O71_FdQGZCOqo3kyVUDu(#`mVV8smw1djkg2# zt>GzG{x1{w1ib#iu_U5KG6^KCK%881{mu}DQ%>~3?bbJ0M*hp+-%^{GRezCn4ap!x z1c&LzA0hw-L!yN&#;;l_5t8IuUHVAf;)wKF7Yw;4~yTI2*K zTDj4lJ}s0SH%aDPWLVUxlTyuN#)G8YR2LWEikQ%~VPr0jo;xDhqQe%q5g1cyh}T;? zL)EDJ!(kWLf}TSByJ5B@8b}QytBX#CaZwfMikhPv22-EMmoK!N-6gWb^jTVoE>KxW z(prF0x>Id%TWXfVTUw%5DrgBl@I(A6jj4|frIDTxLrp4ElRNzi6TNrSkgYA&VoFpX z<_f6vAd#wsk7~wU&|8e&-rm|xmmx$g?mNgq00fp18k#=}kb)YkI*FteskD+`}7 za2l-IVc71J`UVs~U^(3UryU|Ydn9xS6zH?~o*mU|G(0z!OH3?_E}0{}nwu!^Koktc z+`T1vHQX%Z5A{|GbcKl`;+hQchwjxe(K?3{7c2F0`T)eDJ>!baTtNf$q=ufp$f^}& z9?BJigc)_Fp@UJ9r2ajB<$TdSA~>e>_HUDnlzu=}dQ;@M#7du4bW`)wkJA9}`|90ho@!1TQsOh!?WsfTU!(v-*bIUymF(O-#*BHNKjWaWN@9 zu=|17eiQUItkNcjplCTf2Q!#4Ona$({1Q|$G5wof@KGi4&%oTk0exTNHk;xHzeKclNpBde>@!&&(B@O|oz3*jBw>i$-(R?OA#J9+9GbW9sFV?izSRKaTsyw zH9`vK1AXS25fQ*5x9PvrzTK2THJ44Dsh7EZ<3pZlXOm2mL(> zL1hg@u(n%$&BHRha=FMlGYuGoaX{TfMC=LYYt5*WC~5e`gB#%;8{&7FHvp~XW9coC zz@9F%VYKpzbxw&v0=F%-zCJjtWYU}HKwiE!hF*COhzCc12!MSX>ZPd3kcWWtS@x%82#I3 zGiF$R>b*Mpv`D}JnDjF5rYA`$i4&TbHTrmZC?zmd48I-gW)s|W3Xb>-?vQ{9#o$NtR75vGjNLn=vWj#$5qCJ?|^szSntv8(`t}xouk~;;<%@h4f z6RCXILVfse7ptEn@9v*rzm91+oCdC}ly>2qCSrvRSS%7ZRYxjJhxYp-OK=!y$s8Bz z_3^zP+-}SYZE?}R4B^OUnGY@K;--gj4FdE>^7sZk9#D+HJEV{gxgR2=^=!57J*tx< zFg_K{&1MWlY6$S7VJj$Q?aCMG3F#8=V|DObNhUAy^1y&zUJIjC|^uCi(SP>!!$TfOS5wceoxhMV%|F45_dO+ zaDBwU0eTb$NC_|mCNXR-thKbX%L=I+W)K^(7`C}NOnOyjtk@Ib{vm7Z|sFN{77sHgfV!s~mV9kobU=c`vt9 z=Cho$>~2#&i^+6sQq*MAvOb+!dGEhEB`v)^^Ku&|p#GbqtQ0eVET>)H^NcQ;8F1`o z3--A_ekJsFaQybYwNo!`DZGdV9YgyqbtHqhE{(X+Jku*e^|n3&NFhB7&Rt!=@cIdJ zg{q@zdBU6gJME7nXw#T$5}u(1W}Kb?MLA4ivCaCX`s#|1IaFpJZR`B^h~w_s6G?&c zlI_0@f|xF)SE^E*i$W<83WNiUC}d~vzG$Ib4u^4H#;{iGmgZ}Y#9i6%cBS52&X&;p z{ocpQcqGx#NzD{Tu1iB_aheDqowUHwWXh}45*3G3+wAT{4V-cm35(xjg`l0Z1%t&P zX= zh9H{v-)7OH<=+gH?GJE(WNhK5X5>ZM7k9W0BL@@(s1t;xC(;Vf!enR!Ts)+dPa!FV zlf(G9=~%0NBp_^nIx%KI z(NM_FG%lv=#`ym7Lb;owUdN=j^Nqr(9%N;XtP`*Pd9lUnuQMD13mHGL|DkWRv=2@9L`j%E@CG#LnZ;5!>lFc2qeqJK+Hi9QZq}c z7W0{_FUfwZjs%m)e|$sN0PzI1@E00lbxk~oA?k;s06j^l=2)6sd-nHVcB$me`P&Yu z$jO0KSy|bdNK|13f-0M|`U95aai+-vxNM6Dst)3!iiBC*hm7nUk~hEP(ea!#e0S$D zl+N zrm%r9*TkVdZRzewcNOP+Pg!-jP%E1`_NKCVI}v9*4FrZ}%Nca#&*rdKdpFA`p8t=r zkdQC_F(e1}FY~U*h`*$^=dEXpE3#Usd)=(JW z|BR4NRE68Mpefhf67eLqB*F6yqYqvQE0$K8-ENz7-t-y@g6d}z&S3*htykr?n)Ew_}cqn4X5qOm<;xWR+* zBjs^cgoZ>&7C*Ml5`JkW&8`jYKGXm>gudUXK|;3<;6-wn7${eU;Pq(;wV`K}KjfDJ zv6J3mxj=iMM$m|uAD4Mh3?c9ec zLNo=_aHWsER$API5)N+2x_A9CZ3Br!_(k99dGN@K=kn$mM+p00MXG7R|k>4_$WSd zvJUO{QBWo}e`aZ|T-F$@#r`MTfJ?Fc!Q;2H(NHn{??C}UHmRW$ZjRsea0BBwRfc~p zHKBy5xF0$rj@82W)@VG4+}PJ!;|)}h&bNzZnBHxw7)VYVJz>?i!Nq8tKk>2eeW^eQD;WexXgMP`YU^_lb$)|OF%^QJI#zQiPKhgqcUA_`^1+lb) z+7gY*C!B}j4?f;oZPu1OJwY4}10Y)m8%=ZaTxGo5N-4z>+owH;CM6}ubR}Y5(_kip z2B}M*_N5!4?rl@y2UWOVd#uE#^Psvkg{p_Q z!mhl|yHVdBZ@ltzDGa8=sDG55FSmMKha~SUuAVKmN`Yyg6}2tn=38g6KCD_Rj0Rh4 zdR=GKyB=j)(+r`WMHiJhdS(-DyvI^d?I~(+m&xz zJpdpMX0bctE=&6({%l1yz1!|^`M4Ge88|ZjLHQZYx3{&~oXABHFA;Z3k$}WDro_*_ zBWq>I87HK$Ad6`H^cF+|q7h^?aCLK|PDsjU_4f8o%1&nmGGzh9+_zc2T>M44QW! z`M0YR2}8lWoElw^>z~FgMLRURF5=uQ{uGFF*v*6JSr{}2mgbk4+zzIa(~bT0J_bA? z{N0^Xp@NA?7+%R?XYRh1_^=C3!sTU(sT6j|8THrxMn*~IEBc$?Ugq0;KU;dwXyPdA z?543MC9!gSa`^pc>vC?qR#jmy*=rd|M6Qv;*f^p-Zs;W%usXBZDCBVdfnFYQ z46UZ8^S&Uv9o~El`~ga7K}N9f8qD9q=%$s`2Yb)%PNiD?_IJxm!5TtN-&05jjhdWC ztWVdNeNz$$jI$aiuN2phDpbaGIVG(lNGEC0{h1f)wd0Fv&!$uT_Eyp5`kus{hjhw) z-TEN4$SCyPnp?SIpXb|`W*Hgs{= zvV(zy%nk2HCG;h>Ls650`Nc)~&H3>Gydi(uK%c`tO3wxMrUCJj!xbkP0cSYxGr4|!#0qOLg)|jY^ zi=(~-ws7Cs0x$Wuq{}+7!uz&k6QMTitbOk52BvOkf!SVEAys~zX+bsN>xpVx7j;@1 zl0tQ#2-Uk6*|5?nsth5ig-RBwMUvG<{!Eyu$Pr45!aflvPmh+E_s0oT$1mf>OLI%3 zBdsqKJ0cw_B~@S4;%oHCXxr`gcEzb(f#BouPy{R>7t}+ahQ~mk6;=VrjoM_34M<{U z=~zbWDvsDA9Pzgmxb*qH+PR_VhqN^ClN{A_+2qCo=4fz-F@&f^i{qFVZ7Q1{FG;<`GJ*2&Vs;^;#&kR6=fxEC`mn*1Q(M?VNHx|y{I1@=6Xp0QWl zs0ZR15?&kjK;{EJXp}YkJ%I(RMYm86?}pDoHro2<^TrcODX0%}l9on5ai1~mG9|f7 z=$GwHvI{TGlNt2wrz8vqOxXf8;z{mphYDP4N&c4P(YAszP?nzv0h{xiNE*cB5|0rZ zfAJu&>(9Lk>bg#Ws`#VUSf9G+XxB{M0{{wo$wp7dH2)Z4YsfHR$msR*@UUKcm6e|U zc^^wfC{3L`%LpjJdIEEcv@%v22+7jECZ7X#Bi-PI3o z^rjo8Qpg%bRSE8g7y0D9NAS(q-RU1E43`pD6vrtARTPWoOg1NNRbpG4OGk`X0>&n# zaAZ=Ne=hfYuuu7yrx{t-BiqvP5+x#jq$!#~0#ezuTwcEOyDpdYQw!4Sc+|21TXwO;y@r9|xBab(3tRAVlrOV zPY=l|LPH4#|73UXL)^$%hqA2|s%`@qByJ#g735LGD|N<4Eyw`5+#uQ5`y!0h%I{B* zwg)7UJX_`Ao78$mP=S5m-4uo$rcMz7sw?uDffPm(%D~PWxt|6{sbMKIAPEMY#rcg* zU(x%Zf5@JfzpdS)BmvKrYd3cRBfIn(78_4(m@zg~jqamnF70b!onVTP3f#BoVY2Z;IKCJxtz9ZT*$}60>rC z1-C6gJTS=e&K3!%$B>s(o@u8Baqj%e;9~|pI0XG5T&YC;e;WSki@`*RLP~=S zuF?mgIY|9l^3W?zG4TZL&L`N6%pz~Wf;j1&S7lKFcwYNSdxC@sy7uE9mi zOY8920tS$PG_Ib;2WK>VH~RDuq^Oiwz5nxIz@I*JKDQF36 zEvzP1^}ygOkFDM1D2+kQ)3wghNEp_`C^u z6!Pt>;49tjiLKcJmtP=i;z2UoeUBj9(=f}dxIQ}@ z>>yr+BMNeVj1o=fq>Y8}=J}~VR2|qSA(!~=rKYbGHeLgPA#kt`7y`m)kMKnvT*030 z;lxJs)QzI+|8ygFI4#D4AN|7N#^*qL89_d&UVAGppzD^Sd5E zucDAu%&F4H#&K5|7xPG6WTr8510@TpT)uC%6U5=^5PlgOXD#vLrTI7Xr$U5K*t1Sq zf}E|Q--ipnJOy~5tv{ZB@pH=$bkj_P*ihr(;?^nC%PWj#XW~p16z{ro_v-_|ok{1N zG=P8E;C~K=de2q@Ms1WWll}j*sb7_#V14SmS^Udz#nPAj>Srg$N8Cn^j+}e;$@Wm@ zt2}jeEn*9}2Hd4cqnt&d#LO(0hTA*HM@S^FREjM{>ic&O4=sLw<2^jkMq(SgdN|>O zr-w)kILyx*-gnWy=Uw(x22%p>wXGUe)cyT~?EFG}Wz-RUzi+VJ2BqXovZObDtX-z5 zUFs-;7FnqAVYArV*et*F$FSN6P9Z>n$occ%3mwzVejt6nhbHoxI0GJ~w&yg1{okV< z#Au?IHVGzlu6|^jqNSrt^Y$vBm}RJGXO(`N1dS5EI-y@2g2Ff%OFV{>;Zy2e`eF%Z ze|aB26b%?B)Gp!1K8GK)MAN7KUD)>pyxvW?jHfYqAMBusI@j$@k`)K{1$&udfXeIG zjxMZVIdhs)a+FxoD>tm%9R67Oq+{dYFr!BFTgIWpt+KZNdGuXd4QL$ztkr73xKT(? zSa(1JoYf{SRG1w+=*a$!#cge@@I?#Lt0;V$);ATY93CrNfKpHeJ=y`8G(gO?hr zo(n0e^nmqe1;=omBNG1EU3!RwKK0p(i!)2QgKMRDhGq4VM!^UkfzPUObaoeeg?LJ?kDeMuuHYw` zV-_~8?aGfIDGP<yr%+?SIw8yk*@ ziE`pK*X`!@H9H`i-{;rgGrzm8gI20>_b*xZr{&v?rK5Z;c@P(?lE`us(5!)RI(MmY zA{6Syzu?huKFFLsjeO@1D#S<+=MQ1^zgRpat2&;N2ETv*UPVhstDC{c@Z-y;ZNw!ngLP`({5f9Y|_lM#x_Fue1Lgu75@xI$7 zrL-PQW1f7(X3hG8I|Mp&%ftfCV%ml-#n;!j(d5($68SHLBlJ`o^qAPC^$3xl3S>** ze5tr*S$#g|%YRq;gQj5C!%9ytmrO!(`pAsCiek{(<>if+oCn9XJDVQu&9H1pi{t8jtc{KcdAN!^fH>iZ8zlhuz%U5C7JPFQppQ zmLi^kGuekA!aO2QR_`h)nYEzU#r%s*S7YNA7Vet#j4d4z;g)MVTMwyyW~X^)P8YO% z0E|)bON~>e`wggPoss9YEaRpS(rfZZ64Lf(SznUP{q+;CuwRBqMRmH$(pXTtlXV{<#AV z_3NGEQjE}_>$z^>PiDZXw(2AYihcF59***kLWmkV+FQswJnRWIsvW*V0$jHqtZUu} zI!4hs{(2IWEGUid&=;Nx@M{*1El^(i`Q`>E7$iPLJb&tEskr6$B=~>&bonf{O6P0Hf&hp$1RPpbifQ&-X75?iQ&_$CVk^Dgw;7Zt7;P z4O0#r3hRlKc0PNvvmAPDcEuJ&g7Zz>z&(UmusDDpot<5&Xt>Uu`XcwasB+r|SEDf_ z8|&robMp3;H#N^91q~%$*n*sKzQXM6EEPGs_{z#k(c`>r?QipsQ{!^47eL(kOZ;DS z-d|tbT)|(=G<?FQ;ZTQCX3=Iz|n5lnVzA&2b+v%%ko}8r3&RP+9o&2;hD96Yu z_^)%nnkgtLCE2<@sO63r%VbRvQNbx6_uas^{gHAt<9P6h)!zUx3o>bSqP(DwBDE@m zshdMv?HB}vgz9c)A0&fVzT{an8jvqIGJC& zL3|T%-`LsNvaI#~irpQwoGyEkksXF^%ABS#XV?1dXIisVVv@%}xxkuhpMO2yF&k?C zJ^c-N9Sn6H6mv=@d-u94l~E>SR9q20Bi9D0(3e0yNF>&MmECKx7&W6SL=JjLeuhIE zzgaS(G%70$58p9+>&-4G!pf^sPJwo?K76BHNdjY%^6(%agvEe#W~;4TqRv;^-mbaE zfOZ!j#V&7c9f6Drb&1!)#7Yul%j78821}}gcQq}%9^BC)b>Lj{(yn8Xi-(4Wg}tW5 z=@}U{Vy1X_c!F)<43d)7y8(OBuLqKD*Zb@Umz!a2QFfAy7m7Q%&@Z&fQH*GM;x&T} zo~J14s;ULp1k=Ttoghu z^bjO!HV=^(TD^P4*4Q!ASGu3r<;Vrqo-u_iSJw28GYhh6ov+k6R5TIMGhH-Oy!!Rh3o`9He-Y@cwyGRBG zYa6Q=nPJ$jxlBwDtW?GrK}Agsl9eqz`KiIE1Fn}hQx%~^ZmLgi>OKxqF8xs`Aq-IhCcx@ z;lKqnYbb*xz{f{D<9iq4Zc0iH72xvZAjwFos94S<83}L zYvsOrnPY*48?y@M-%z-Bz|9=0jA@bXL_3k={5T*6yXS)RKSEPunKNUpZesJ!jL;Q$ zG)JKVRy4l82HEl-nPJK=Hr9oOEA9nhhN$WF@7*biH|(SoExZcbobbs-TUkL zmbbf$-t`dfBcY3J22Pc6w^2UiME4uohwg*y47xiXA%t({--gP|<#I7d+8*5#CX7|d zm96s#a|Mx`x15VcqxTk^yT4!Vzl1Qn^y^`1*R)Hxy1HpTZb?R@1RH#Jej7Q+;31n( z;SI%4p~0v_hRBEP&U#cR4E9u1q{Vy=zMyJlt6N`Msx{N#R}IO@_P4-i`8`sXlA2Zl z)sr1Ya0!OaI~1$x=P(DKJHXb@R1-(cZtn)>(h3%)aV&tykMZ^JmG6?i#b|y(V#E#n zF`;hIp%UM}KsAGLK}LfftFE~=yGInnK;g}~d>*{*w&Q~-bkF-H-Rc`*?^Ta(y zZTM#i%;EZ>9oIda%6X>3+}vEdMRjH0_sxad;(D2xNfD0_o1>$6i4T@^voXp{Bf2Vc z7d!F`5XCYpke6cXrj4b7TO&nY!=*Ro`=!JnxAq`+54n3bo zlRh{LUb(p~{HEHmlf5_zLt?}hUzmTYb$#?AO>KG8@b&AqTiFCY7b(FzxtqJ7B3R8j zQYsuS!Z@Q!?v{RwmQzq3^?Jv&!^-^={lSbYV!U246x#glbpx_l(r%?bqyD;}>s`gwnx z3qD3Zno;k#hlRDXNhzL~|EtVxnijJLW$yY!9y6AA&uu|2*?71olfUfP~UuOw75P%uN_o+&+b6+;zefYC%Aw}c@=_{0} zwnkh0;7|;mWj<2qwJ(Ojv1bdUGq=u`nauuePysjS{vNF~+3)eL@`--v`|_6LePGa+ z3XB@^vbo`&PJ#rF=W?#l@zC=;+Y(i9z>q!oJj` z!lETxG z^lgotn)sCtU>B}uwfg5V1kx{TcXqBMhX3hQ)$MY_{U<&rnlQ_;3oP@J9 ztvU0)QRSeKechl)m+x?V?olrx3nB0lRt;hdJLIZ z8MS&naTz)`^(`fP>!%WI-zh`gm_C`F#GHLZaJ027j+R6T0$h#aN#y((nl3q}^MTfE zkGW3NQ4vR{%}aLkh$0~&TW!|_Cpz--<>g-WY>8MFgf#T+zEt$-6mm2j(Z2_6qBFU& znOR~c8$=h)0?d|bM1^XdN=&u?y+R^M*!sVCva%_J zye&;!mES8b8(g)JMy^8uhbH3jxh{pIL`(%;FhlfN(NBv|M*LElKV_k1V|^E8$~Q)u zZp1;FZ?9mWUzW3CWm5eD!i&NOgxLzrG`8&B71c6e+0hJ`TLhB1Z*9{nUq>Gv9?))* zOx*rWd@mh3SKJpaPR^_BSaEhw>GYV3l7G%&3{b3;B*(=A&HSu^W3^+0^99Ailo}r{ zUA};ayok$=08YZ!3VwZK)?zZ2JW1kycDItTF#?m;@^*>%Yxb*Lm$LYHRB6pvSvAMR zB0dEhuFPaAz_)gYPDK}g=Av)+KLNK0NcW~6jDnsH^uCCK6_lkwg#OTPVQe?R~*-`>m zkf{|Uuq|7*z#TNhy<{m&hxGLHsQWS?Pm+ozbJFFbvSV>`baapI-jI7xkrZ7^A|}Qd zG{>68EH+z{#cX~tH9h^oXPI19!7u)ATOgYjCv50}-ehTRN{ht=ZR$FaSn(1=UJdqRbyB3)7fAg_Yr)U-5l zgG5-@$E@0$K z{aB=KFPehDlnJ&m7*BwtLT0nsYqeTVsH}6n>A}sf@90n;egFXy`Fm`>g8rEuZaD*d z#wD&fV(@F&zrjc>c`z1Y)3y9ItQ7VI*nh+Bfsw$Th4C{dY&Gt^0QWkI{Rc=sk^RSD z3`#x(BLQ-sgAiQ%lcf1ASRCwW*uAh9aqR(YFDW$Q((s;9m{(Yt5O3d>Ti{G%b~?*# z=*q2Jd4*hm{k3rKx@Uss94%zBCc(PFIJl1toHOH`6Z&!1gs7_*R#PL&-J=W0(MUpX z(1%PW(}cxh>jY7~aye$5gGBDa<|nWu^idy2F=+dD>{EdqhHi5pJW!YPZk0c~P9nHfLNaL71J+nF~lv(a}8; z)sTBg#>Pfix2K@f>zQ8Rhr4&$Vza&$Yl{2%hau}6gh7&EF#ZRy|AdiH9Iz{4r(nN? z(Usc+`x%VC*j?z)3vn&aO~?LC*ssAp$%aHl#YK0Mg!Ke09Yzvj?%4yd)3ASlQ9*J2 zN(LbBfPEgu>9@H8dlQU`?GfBR4cqqx8gXg3Xee?Pe#_x-{3Orm)UyzpljOxGBnjtn z_cD=_1T_MpijoxT_Rt=MPOk$=nI|pQ*dAt`o2=&l*tv7(%aM;ibO7lv&P2sSrL_{DRHs3MhD(XR zh5dp%AOJh;Iv7V6XMp3yuo*X;z_9^#1FSsK#I`ipT3At}iEWjz4A_mZnN@YMPcXri zsS-0lTPcj^E{rrq?{PJZ_o<3Bvz-a91arH-8{VBoP;qIdnP%^=0bJ>uxl`Qd42n!z z;{olyNIP@3qHWQ0S)RiHIulk|B6JIkDG$-}Xy1vP%RhA4xn(XGM+He>yq;~`dLrjW zQ!JuJVxuDDNF$G#_}avCBj+=9qbRb^QOW%1XR~3N;?kgDZh$q3C&Rlc&x%AqvY^}c zJQNKx;hD)^7_ok|F$LmpVE=^9{9|mt4r8v@H(+bg#&Hq$aefvBV_0ne4XhG&E9~(| zTL~(8z5<@*%&|o z%%S=h*jHgpbXx->5ilW?B|J( z8|Z$u#&iDbyQJH zhtQy5jsPUV@}3>&lUpLkDcB$6eiUetkjO0#gh5}PmMm@`w%8Z_e4pka;xot|;4*U%>ygj?n| z@V+Fqop@gk5-6aJs_ie(#)9oxgGO8$G|VBO;}@V$GDtq>fp?uzWKp249BrH)XBHvy Yf042_CW<{907*qoM6N<$f~=d`B>(^b literal 48365 zcmXt91yCGav&C6_k>Kv`?kw)G!Gi?%;O@bLh2X9W!8N$M1h)XeJ-9o({r;*qRa;v# zH8t1z_C2TjbhL(=JO(N;Dhvz^hN6ND7zPHG9r_ajAVHt7Crx~Y{vo)56tw`*%O7A7 z1-(acR?v5YzQ6R}4;I9jnIvn9Ket990y zC@~BSC5)nsl$Lk)NvBURt!&2qdvwRYlk$J$@@@qD-P}vd6-PZ+-P} z`FWf13Hvy6x3-tZ(yix$EWy&Mt|oBLU8b7oOM0k~?_^hd+i~^S?-B3!k@A24&i>_+ z?}wdn+*s(y$XQtEEDGcuL^I^dGeQIj!+^>m9B@Hp$x0|x#wZ;|Ot<`00}LUz!3f}< z<`gg%D%Ez6b?{uU{P^A!#f^nqdOzvDGth=dlpV8!9FQ#G1*@BSzXb2tBPI#&Tmz(r z^M}<#^M}{_xISr$34PnNUl8=_@KGs16>!Pu%vOs|IKcp*jU9yZArDfHVk)x2at zTRpFmtsM-wB&;R%M*oBEPad_cY%H~T{D8p!-#eI*;Th%Mj;{C()-xrmOWue!^MaRP z4wxW@o4+0`7SLb#E<)<79R6#M6cddnrN#Gh^wGpMcC-vdzSn3X|>(ms2wj1#Ucd#yQUH(L=!R(_DqI2 z5;9x1E%`3_G!)d)D^^Xw9jTAZm835VLp1>D84iBzY3LbF2K$8p^Lm4(B?Pt}9($03 zb+>RA4^qJQq@%r4TNf8utLHDoAR`8d1334}BM337&e2B~MG7U14WU|65I_|!S*Vd) zO3R2Gg0KZs4O6Cp2|)3l^-w+XsRlE{7bBP<#1#Wq@(XN30f~2_HJgeY=Sl+Sf7HZH zMh=qtM`zRnx6e_BPw6MN!Ukfa?J+sTUiRZfDBQ`OMG+Yx{t=*%^6z>RO$Gu<=0j;A zeb+rH{NbQzaG6Y*1w5+J(u@aLKPM-KbVh0!`kYpYsdt1av#Jd_qxu|gSr0C#B@#Ih|4M@R>!bVi28i3)1iDg#b6WiM>PDW(1Y|>-JM|wi8Uv_A6 z-jP`6yqEUIHjQtw;tC9Sc4}VswB3_JDOVAn`>}+cP*&yUkY(5`JP;o;GeJ;d@F_O)j`^GD%u8nCKdr-XDWAc2}Go(P#zI*cmUOtq~r!X;YKt zRpKRvg?yjwXHQ`i!UVS|sBg8fqlTBqsxO?RjlW(pp|42-2&j5+;Z(1I55<;*!V#tb zX@Rh_^JDR?l;}E@)L+koW|xlYqL1^!pBG#nT=zLK_M`0irA?KmDsVnB=k%tK=ek}R zhD#QpU`$L;hf6NGH`ddBpKHI7YA=Yb)x6MpX4gXMEs}dvGLk$EJ zCJSYZ5USg0b5~IHM?V*6OrwT_(1L}wg+nyxs_X{6Bv>d z-Bz!s}g?O;@6snVEaqx}EIy=@G2>-~8r| zZbqgrrrDf2?p8h}989E#*NUmfD~hY>*Y^s*6db3A0Q*o)!#_|Vf|(3!>a`URtHBCR zeL5k>OooW{^<+!c&o<^@aBwZs9 z4+MqH8bU>_yP_GJW6Ly?z?E|CijSb5{!S()BkaqW4BEzr#o^VElnQXJMiDt}_ztZR zQ{=`KffG5T3;v-pLPP1YpW^M}uZ;OzPMqq*<>R$5bQ7uq!b-Tfe^@-^FGX z#ngb<{Q7j)E-xo%tY0TTDw*z4HE1?MgbAT|xc@-EnJ$ zM;90~NJvDqmDc^Ta6qxzXe(hZ!<(3HC$Y3(X1FB9G$^wE$gXDMM!f8hO7VK0z=)4# zlNkX_q&hJ&!T6m=osA`!H~ZN$9ilkOXe@ZoJ)*qxHBFWi&H zL1)n6s$O3G9v9^0<8xbYWvevl&YeF5v>JvOip%q7Q6-K3P%9m^n2n7s=E8_m;8l{A zhOdi2GOHu3)63SY3@Is*BhJda*iEO^iE$Q;U0-*3toibM+iViFaJ(K+`K8ApqU1Q- zAbQ+`G^kuvGo@|lRkK}t@AXP&!6Boz>gMR$JSVX9NO?hM3D3MD*L+)Wj5cx_kO5re zb04!3hA=A0I=TFg^qfnY0(+lfhXvoot3@CoOL(^2uXq^A$;-7IpS9aK+FCg~N3Dm5 z+qJqm6o%B(?^INJmdU(FV3@779@PJ|uN&Dz8&`(R3WQW(c^Pu(5L)N{IzztnrVgxy z_b@7gKvEWULZ%TiFRblf0z!ZW6J75^7ttEY+A1cU*`AycQoJh{cTPdiBJUSxUfmV< z3P!u6CBa~(_u;Jqyp~+Ccu{7A&7=t#oD2oLTL45nTKicp?pMyVeE8;&f;%%#);Gb| zrlzl7XKTYLi_v&h^N)cuh?=Uvnb&SIqO1ub5*Yc%DOS{P;i3_?P!;1%b z!%bwV>?UgBS;HT3j&vLXXPdEnbA#AsH|TLtariSaE&{Wuj7RIaNZal0ynV?vo&IwBy%Z zow-OPgp>gdN~1x>ubTP2^EOz-hahQ!X=2WNkReDTqtV$gy82jt)A;%Ko-k&sAuL3c zx&V;qJRp&OMWO{42AWSr>9ye=aUFt=^%XsRN`q@q~AP@!jNquwD=j*^v1~v1a z9xB;oy2>q2T?JjQiHc$^xy;1%-xGti_pel$-n>iiSt@>y_~p{3C~XO1f`Z+}5O{vH ztfRd^I|F{a-hkz(@X7}kl6jLyk=+gUp>A#@NJ@M(D=~HaXBIRCD=fS+oPt7CYm{c* zm~2B97?tymsG;<#!E}oX(J}^HqHI1tFzTFz&FF>AymUR!CJ$;2UD;(v^`wtf_<}MIJFbt<~G&g@-so}`G#@WpCft}4Lu?+N&Ku0aB+tFK7!kFtOQG^#Gju!kPgjUE(1*6knF zB1cleTnjIR`P7Td?;W5D1==3J;H(tzIqVzB`zibzfj(8HF=Spo7^CM$=={p7v@0@s=&G*jZdY8_^fT0GgQCVh zU58u=o!7WchJu**zD<8K7x!Xs+L`}FL>4Q9IjkYkl`#5awWTX#+S&-G!s%xXcKHz1 zo;RMo43}5-z#b_!iEdT7;3U&x1&w3MI5)XNRNl}m8pn=N-V<-o^;Dkp#HTZ5L(p!C z*al%2awXKxTfvlJdhq_GhWENXBt(8x>#%}*S8kUk)k~WaeleGM8yhe|eOSOJzb%qc zlj!&Q&d|CGZIi*Ey0~|Q<(Fmxq1i%i^}i(E^ce6)qK~BQK}t;OH!=rNe2XC zI5RktI12=V5?L;j;uwdrq!>-)Vcw~tH-oHG>=jj^v(tCo(O4Z_m~5<2Fdbq@ugsX6 zZY)Nk>q(1#tD-8Y@@Mf*tSHca#OvGhcMs7pA#)?a)ndi&Ao$(8Z=SAKq z;hWo|*5mcy!^+51NKCMpQW*!TMDxJ&B?{)Iz#j0drYDHJ2Kh~%N!v#)fe`bU#5Rh5 zdS&JJWR8e_i`hf4?>I8?CK{tnkg8`eS^RC1}~Unqj{An!kGH^5LV0H9hop7Vqkmy(FC zDSXpl`gN<&L1?(7YMW_%n=61G>dvjmnfjBZ^FhXiQSL5-_}_4GWf@&l8A?M}fw3y_ zsurUHmNG?qUiEav8So0AXqd9jr@G0s$MM1+=h6_Fa;}w}@mrv8m*|Y5@cyV2Hr;Dq zUxCT=1R{+4f_%aMQp~q0F|7DP@Rss0p25sr3Q7Kl4|3>T60IH*aH|{=NUMayN1;lE zW!RDj1(y76y1GKjt1y9m(E(gqLgq`P3D2cm{?z=~8&7L+kGAj@R4nA{t%oQlq%S*hnMGJ5JBF#P{o$Gw+1KN?|}A zdUi-MOPDuDmoM^#{idjYpXP&sq=a~e7)Il^vThL83-$wiZLx}t-{r#Z(qQt<(7g@B z*hG`Z#(#lS1G*O&w*-^!9X!3*`WB9aNMvMWfYU$NI&8_{Pec?-ZQw3~KcB9B@ZMu2 znSN1h#1+nVeYHJixbX?{d3I2J-Oubgt6`#mJ*#-kMrLlR%+2KQE^{NpG{;&izE&Z8 zkL42N6kJ(ZWM;u3U^HAUtGVNn`bH#=ha2_9z;8|}>Su14_USVv&MI%j(@{Pi-Wu_a zC~-Zt%Ofq9qaT;1S$Q*?SHba<#dbN)qQ#9c{itw+ZfV$>8EvvLehTRM># z@OJA%4g;owp@AXVu)|8BH>(!{>W3ft5JR{iqg-cKEgw#$vKYJgRss`|e1|2m?erK- zu9!;!3V)NMNQpN^?QJls;cB(hR3;bf#DIqSt2n0JP9|$zT#D-2u!@Z4r+BixLLPj+ zevT|`p@n5?{}}D?w43sQy@d>)8dFZhRW10O((F;|nqyk*xbIWN4{!HDdPn!Qr*glF zwa>2$8pRgVX{z-xmt17av<4W5|G4JN;xVs!FMRRUb}q5oaK~Bw4RE86c*@96l_}<@ zcVY7PORhfVp)YIm*dy-0iB?vMzLJcpH_*FF)wKZ>009QcF@O9e@*W@ETIfio*z4|M zf2FL)xAZ;_hT;Bb;r9J`jFGVae&n5C&c6v>Jv~`(MWaFpkqpjl(zZZSZVdMzW?N$j zvqirx$JA6kw+wQY?j-j5D>XlY5}?96-wjl#qIS{DrMGslsspLbeV?bLuF&N3=x1Q3 zLTD>k`pu~GguC~S7zg+5k#sQ8;#X(MytBB%iN%28YuI)oy?_ z;47K!S1Etuyz)>E3SrlXCjxi%FwI+o`#ma6zUis3;(uSpr#%9)&ll$}rn1LXFMNT4 zBn`hVN(ekXI1KQh{W!wtN&C`u_~kr|wpxf(gt0(78m;HMc?p^>lkYWqrw;*RoP8;p zR4APdCtqQS-28MD;n&(S>{&ig1m(|XsizXYc?uP?3L1}zd5w3_R?0clOuo95Z%Zkb z$MfoRc3VnRqjJRuVDH^7;12zmI;eQgEQy;S%OY<;r`n9^;ogL2pmiDS=+g;n`QJM9 zfX})Wk0$RWP|%xs146lr!Lg}$MUbN)NstB|xAHYjTxMU|zWYRiO1XVLQ%K2UQ;uDJ zSo9B)Ig)=2D;vg)-*oV{kZpfXCLc#|x&0`2Q`w{JzmZn@$Um)a!2-dXP4cdeIbeb^ z-prB$+rY}8=9eFuvOA$Y(`eme1Q^>7>`FBpL4g|>BfRDvTSN=WnyfFK+5EoVc5wdu>^Aesge z{Pn9}HGz-$?ARRG{?`#0X>agdUfr8ADJ}cXC;2FjT1&j7!}pd8O5vd*;$$?8J=(zx zSe}R2;S9V%LTVYBunD3#+_4KkkhWBHu@P_-^+hEx+N z95v_27Hjt&T!xaR_p}LZXYO5y@;MOF4;E6aD<->ACa`H{+h}Bl9JkoCNraXrXXd^)Qy6$x~OJq-bkpZTYMgr z#k<;wWBN_kb3j8)x%7AEl&u;zy97}=%Z`&~Muz#yXV0=sRG!qKOI9pO{X}P9` zwG7xJN|h<-hm=jBl0j~%UBE|sc^D-XYIf!NJ@_x1_QNV4 zIMK}ofrK>d99eQLm`Wm*gh?EBj6JpRObQ20kU>E_!>KLYA(9%}ao5$#J)>Yw>0vtn1Fa#K)x8@j@?8B;cuPin@jo`? zt74fYJ_NH&I*GRzYEGXrtgibma}fYlwqi;Hy4!$_a=Nz*h}TKSyPnKOQH{acoI-G z-C~cQ=$Sf)3Oo!X*!h+}!1*I<9r;oYNG0`l&2z~c4kMq#PHIlVYFUMvm^Etsi!U2M zq(o5D-p2Xt?S_*!KfK!F-Y=PUl~1dkHa#Zisd~SY^~f}GL7>0nvRQvR+Y&|gfv_$9 z#*kMv4?29YVErik&39ytQHqZ)NciRh9x8O~FjQeQ<1t>?aBFT>VlF;?JuDmWtL&zP zNcF5jWOm+JsGZtoz6(l*JIMp}E9p~9CWqCwT?3F$Pl-k-@6^!XJxkUEwoN z(7d8*Y|Hxff;PolF82UCIxM66Gu77gNp4l23F}I+D^|hDnmNRL;P%Vruf2fq^VM6n z7utGx#LVi}Urydelh|pMnjcPos2iTC;2V6Df10(6s&LrI#7n3^3I}z4Y5j8e78X(q zjas)ULGVO8Pd3X+bE(tDcYJ;*Et)g2EGLw*lRTfKDIU!%u8i?5y%4eJR0`@Wc~fus zZ=QM!?ZvJ08_RPVu=pJ_G`12y@O)+qBwVGzRGm}aiM{@U{d>8MbTYE^Xve`Y!c@iB zW}+A4x{y>E%|CjSw<^@?k?BK>UWuapCz4BV^l?-TMtn|pvMH=)o;izJ4t*6x!|LO! zTPOd}#l^+331RBP+*|$kL-Ue|lU3#E7-k?tE zSQDJ>xv&&*z10WJ~ zbB}c~Qk392bY!i;ihp!`ywml3&OmDWGuAe~rKJ4f{L>fHsoc)SrY5!WBrupUbx8F% z{xxN(0uVxvaLcI9G?-fT>G4QCXpE%Vr@#2gyVi*;_n&y|vG66ZjW8^l*`vr6OTF6b ziN5A~rq9L~PJ{CyuUojXHg_(ckAKT+^EWH%KV>3gp*X_eQ{jOfm*1(WF2js9q*YqJ zJ5Attjs~NR4r&Ai-NIxu8{Ymob%}o5E2gVQ(ntT?jSUa1_>a_SER-HGs{*32MW67h z0Q=LF(BN#K1kXs>16bZ@d!^ozWlH>+w8VDNk#@|9BJbxA2XWPpG_XSYqK@l%=e^5v z1&0XEl8c$N-tzT48FkGLx_zMrIGkSo!mspYlq! zsxTt^9ksWa7X&b;=oz_6nndEIN7+p?7h^}uJwHXWv%u&ok;>2dPO>oOCwk%K9-FqK zF5T9~&?z;AvRZMX`rr)W#pHI8DSM}vXcNtnx-78#ZTH$}jC)}O8T%Z+A85aQK;2`K zC|yI}&T(9?x5ROQC|6C@pJ1h_&+HBY(EiX@BF5Yznh@$1aNlpoy}7>3^nvXCi@IwD z*9W#u);xKUmx89ex`+TsH8uEu8rH+U&e}zf57v=o2lM1sik{~e(?KeQ^TEb%G-9&% z)ns_!qLF#ZbsLJ6X;|Wj`x(8l=O!MbVbpXzt6*or0o$6c?2xyvvG23PFA>?Fe<~Z6 z&EF`xexO|Y7BGIT$}uLbqb*xgE=-Qz-`~$+@t1@DPftou>1EmzAfG6Txio0D*Wd+p zngliwkyLvYt`<&5ospEBh4D8#?zan3cahMoU0`mE24?S;(Sq-=hqDpEu#1(7&cY5f zVn>9VDmK;6&4(}XAR!np%}Gj6iixW~tF${ms0WKS?8%h!4KGI4pfvX^&6Oa>sw-o0s;TW`^dMc3fJney$#?d{6rAw4P&^Vcay% z11e&6*b(?3H&&!YV9Y7X!o!je2lh5j?lJC#8B*y!y^)v_)nfAJ|mRb zb9qipB4<4pKHGQ2)`A;Drs!JlmoFcd*aHkf*UMh9+(-ZO_Km70wD5kwmNh7oNng9^ z0|vs-wk;E+)-h`<(PH^v{JuJG?9!ckex6lC`QmHTxbBCw%QK*5yH3?WIM8iCn*ym8 zodat<-JOQ|fErF2HW%^jRS#q6y2D)%r@Bqb_feC#Im#>6+|^bMb8fPbi9l5`jJ06d zrxA?b$@wiq*~|ioYwp$Nu0WNt`l zZ43phHm{Sy=9P_%(FTp>AIJfhY2~b7#MTl#ll@1Ko{+o`dnM}J4%FTr zhe&*O3nCxp^2mGGQ={l`25?>WC$i+Fsnwo4d@4l_3{}Sa>RBr#VcIRG6#B~VJN#0d z1v7PScQOG?bV3l9%TLt@CX@CDYt79`kL#*CW;Kl?hmCaQSko^EkSp z_(%`z7p3Mxgu^c2EoVJ$eDTa+Yju(vMQ@xrHEa$3k`hi)WTVvS6H)`N&{TD5Zp8r` z3143rx&+5*wSGJdDwTfJm_aZYt70@EFXQqHcrv zg5=Q}h8Rt-x&p>;qm>a-si=>8gObP_Y9~JIUO#FH;*c{i51@92VPGi>9ezPso22^2 zG(v}cMAeZfu7LGbxJ4$QxZ8HF(Z<1nc4l7T<40W83AXyOvQZ3#(5C8RS(eY182zN! z(_{doJcsi`@82%j@JCv{8>{bERW#6KX1u-FUVw&DtFaQ%cW`{#Pt4v3zBRL>f491h zhHyu|xM}ooZ@wextHV?GyZX&~u2A3>y-35hx%jDD-~dyzrgjnS%_e_QyDv+u;oC1p zWy4oW_r{@P=Di@~;Wx*prsfWx-Tkb0OHz2m_lr}-;WCufq7dkW71kvVmCzHDWZBr- zL(0lf<{GCx#B4Jcf0`20^u%j0-dHHxA15_AQYb*cejBfo%~K<)o8?QL`_?^EFo93k z@6W^`4^gEZ*G9t_WaV1{^gmZx+%fiA=9LUSAT^xgU{9GJPj&YX-g8(TS|DX@K8^-Rw?S3U)V=_{aZCl2PWPIZd<- zP27ZPc`HPg9w%KmL=lQy{*L}6_+DnGI zL?G?(&5*#$GFcB9jKsrM0*5EreUWUKy7lOysT{5(ZL}(!ZJmrej} zY{%>A`NPTAa5RZ7=U%wJ0$_m#GzF%Gf!43tG}^T{vGfZ20N>-~^!TBZ~Z`of4Zo}_T*uqq~%_3<$GY*b2!IuQ^( zB!?3h$IJIzoDAhUs{O1PCHkDIEavG?!6ihiW_1y&i8eQn;IerhPR`l`_;bJWM8mp( z-}FiAk9Y4*G?tNDPX5QMrNZ&oWoC8W`cx)1!dkdW+S+(Y(aHtR4(-BHp9zrw65$!A z!o_0n3_JthQdo#cNiAqIve&T5$A79DKByJ1<3%imgutrwe_m@t^M2?>uAs7I`3}Yj zSbZ;O*%9I<2~_$hL@Lk596-S)vVs!t1cUg3zIYGcOghyI!>ae^7OSRvALF<_@4A&i?%?+SLh8_wq*;5d+D~ z4;ROF{H*J;W^#e`uX*tTZH_G&>V%E6!#@05>MHAg4+!!QT|Y?*?T#D%2GyP%sULK0 ze>hD&=2v7Qp3(mMu{_^rDC&TV*|PfJ8%wpIUD%WEQnx+B1$(el;IYUx*-~qP7Hemh z7W3q_8)qsbp0XeWM~5=llsLWZou@($gdsbc=f~&Sm;r9g=)l`GO31Ew(cpiiHok(n zgbpS3h#~c_GWE>JzIE=UC`8<^vHEl{?1`VEdY#MhkYFT2-4*@gnPaPL` zc9KEx;-cw=MMRdngDAocbAMUq$`*1-1--)**1?-!+M$k0DYZ9mV%||k_(jLx%%+pk z?|%RsW-^4O_D}I$WbM}8adfvIdo_q>t0I1ElUB*P$8a`^J`h5_&CWwj={ktAzuRi= zesxqqLrNpe)hpz!lks6aJ6&!@(&IF0*RtcKhKP*va*>aLol`ZkAqYX1!rXpS0YMLD zf;Itn9oLgtiJhm%ChxvQMe|H$Tl1~0{#F468V1_TDfs(tt?4^$W`kpUm4>aPA=D20-9qtbJq)4=1Rjc$8Bt% zwWxA|Uu)iO2qd}!=*|7l{WhM>>0T4ssuMIukzcxF-Ku^>CHe-6_fBcdOxg*as31vMSRORaA0X9~rUX%p0$- zt%#XZ6N!tz!=z5+Oc1@|oO0TLiWl(Egbd3L4^KW%<-RH`(PJmfO#^92F_T6uY`@s` zUE_g$Z*K3og5Ka3D}{1$L_DV#z4IB}U$e*@C-MT{pEo4TH#(a;_8jw^?Ct$F`l@9U z$yU8In1!<4uM`K&xNt57myEosp4QIKh?g5mpNEcXy5CqLU5kuW(pO-Akv?wOn5L2( zn9Q~uQer$YxLku86F->QY$PdfL&!TI5tm!?6fg5wj0n!$rT}sb%Vc| z74%#v{5Z>LCnO|AcX$8YzWp)iJt4?=WKX@B%rC=ywQ9?Gz{b{*iZ~jGA}_de!zV+H z&Hv@^08N6Zijxxui%vCd+EmhHi6Sqb%go?)v<$Ug$>dO6LV>8F{DG)DO_*c*&CRXp zq411C*k{Ipx7TM|N81viX_Y!Xv-4cBus+jCzvc0-@kTGxI|&k(y;woJMd}oPn(sfU zi#EBeh@zq4v->}Ol~sPL))?X8=I(22SejX1lw&2QSp?GH!~roQWv#8{=f;wB{2%XD z&mW%IKJj-S7g4+(#um2_;2M8-d8^el&(4FK0Xg*j4^ls^cmK4%Oe;$(^dY9jLBWY0 zXsIvQqO}_#klVg|Xc30sK@~xDdW9OS-^cfv@UJZDiDolmDZ*;BK>1O_xCmc+)%V7%Q zafvua1cO?B@=Z>Gk>}G`-x^J&8(gBP_NVd|4f$xim9`Z1F}Dvsr#YYw!a*I=uFW@S zGMYcD_m+0hpS+)2zrzMQhJd5Q`dvKtPgf2i8ou)rk@fWKUm5;1>#1BZhxPgto5qla z#hk&OP0q3##uD4vmD$+jKs)m}&ZENKf(z%`tKA@ceSSWMX18|z;J@qicpvoMryS8ya=_ajIJq--i<5Ng|Ltl+PoKcYidDT%U%qfqB8Y10$!%({(&HG$ z`>L!|6E&6X6I5E4d@ADgeaaFg;ww6a(7;aIpXy-+*Yw00bjPZR;yGJ<4t>x;hnnz# zN4?vyXRhx*MPg#J?AAMXP=TlC+27I6L3w%g9C-(=2f3E3O>EizW6U~vuBg`s6ErDG ziKJ@K;~Xkml9}_kqd4qsax_>mh?1jei65UN6Vabvkfq8?`0IDxnYXgKcz5YgePc9^ zClI&^PjR?byVd1q@;Ihj?M(U@pgxuc-6&M!1MAb%JvPk!L2n0Xw&#btP%I#&y99y) zu{Jqs?Dr_(b`r;j{@3L4!h?kbqK)ZI28aq|7OFE$Qc3_bN$n+&_@(=YfO@N}CV6LFs=~3RRw5?FzlT@b&eT8S$YYFzb7FI0f8NfwxZDsAl zg$5U=mzR4L8FB{B*4k~O0Q;{*fcn)L=7XRyf1Rl3GKVYqQ()_WIXr zBj8W`cv)$6K~+%_G&)gyljgVY=5y!nl{8VTn7l@f@5wgc;eb9ziwCHMf@SA%;)CDx&Q#Qgu;-vMNc02XXnqs-48L{o6*C0yV^B@d>ao>OGB;lv5JNq8Gb^@ z`IRfI?{gv7)$0#I87)ak*mt+fl?HZEj$ zej(e^NN+#y$~wsPiwD;!a1s`4jLfahNf#G{y!A@qL<^!3cwYW(n4&gH3r9PcgW42y zhA%~Bg_E`I8+;06jZP^q8^Z zc$CPS)B9n8eKLkciDtwl4`wYm8znGmF8tvt^n{zJA_M zqYQ*ZJ8;JBi2fA(cD$A>28e`Y2b7PU9-nHJ({pXSL$Pzxae(%E)Z!QQyOv?iCZvp`?rT}Oe z#3WYOEUnLeS?RQUD8*l2mebSIj{R>ek248x zXQbqJF#?t+iUrmC#t|co>k4@^^sW zJ1c7?bQ-kCm$=~Ss z9euM?Sag8^y-K}0xZzu9SGFvEl;-+>OWn6Z_(m5)Kojx=lL$u$aAksk94 zFLhB+g{`@PIp3BnG(oww%Xz$1!;r`ELxEQ(?WU!AT(d`(yYaXB=feNbgIPU(`+xvX5B7EN z3q*ruk+lEBGM>t2e!t!ctyAgJD71cuy$XjTBRggN)RwLwsPZl;0aXXr>CqC$ftivsVtAa$o#RyU#OAH`nG zc0sDptr_xgSXnjjxm&iD@);<^VEtzxBkzZNDUP=RD0qd2(Cp!Z`yY6kC$dp}*#!;d|PqT3$YwXF*FbDh+;R#>eZh zvh?Jcc#&l_I}Gxwd<%zrzQ3>aJk2b*9^!DYP9 z_Y|K;>mkrQ0x@?6X(&8AItGJ~)2lD_7A2I|4(y-+iPzfi>m675S5{VSz9`lDKcd3* z!ayBOs^ykX?OR70G`9_Ag6pMpbaVtz0gytogVufix}68yoNOp_3-v+Ix0@SMNhVoF zQhM@)xxcf0KP<1Dt7GRhpl8hF?MgT3(}<-mtA5i>RjUI#5H-9*LD2AmIivj2A4So} z+gKlBVP-5VsrV9%y~jP3K)F?sh&s$}n|mB4s$SOAwD@+q+Popo`RAR&DPa6l6Zuj* zSEOy7`F*uhrC$Aw`#A5$s!$MB?m?a9wN++TRx|@KXB8ztug**ey0@TVVQ4-Iid^{Y z)pnrp?RZi=OOkUWo=jx9&W&I^jjiYxBqi9=bXE38s5CDfPV9ceVZ>OOsnxuW}GHz>cKRR27 zmX85JfWAb|x_a7QUwVB(Tbz#$5%V_R=0^a2o~LHsHc>M(*wD-_BPZK93KD#OqQXsd z>QE}h-`hyPAm@(mtYxH29M{wIey+YT%kjYW&!$Uzr#aUnd#=zbP`5SxjypcxuNO4C z_%ZyM)!H9j95>!X#gKjVJD>2Nby?8TuiSNG=&Elyr%P&a|Z8M9srPCB8U1K2E9!UL~26-^l|C zV3)QT3?Ada|Dw&k&#WkYI$nGJ6T#_>MO*D(F;8xN=L*tY%Dc5eCg(+WbF}v(Dbva< z&Gp7n<r6C2+As~oHctJ96pm=aKOZ4Mv<-XeV_2UQbmJO8WiSMWJ)u})3i5s|*TN!4MC9xhzR+!Z zLkW>t@+id6+^$0y*R7-_PoN2t6BbkQ<&~X!3veJ0$lP`Q;cgcOu0sHQCTt@BAaEzz z^e-+pHLYf@8gxI+<-NJf9Zkf;v%|9^FET=Mu|XYhg3YYqgCRkE36`EL7c85WJs*0+ zH~D&WgS}w*FJM0-Uf@%HT7TDt%;SQhvO**nA%Q0AK|lX?p*&Du2!NuFg9YH4VI>e2 zVS-TfdgheMYRLBdV4<=hA}25ZxR%pxefpnt z;B^@aC*h=Gf-PO&9uIKQ5x?hdXIKj~_>5br3ER?ze1=)_)Q3{$wRX?iz1E5Un9t2E zX@0w(fQZ-0?&a{y;CS1YX`nqNzH+VIZP|dCOY+rNd^QxjG-O%J%PV4HB`QIj$Ef-} z)-K>eB&(^2S7#QGsH7QAm{~QBjg2tGwXq< z$m}6Hd;=hJfwEuK(>%T!(DM%a1?K6E!tb1neptIC;9V_z(zKACF}9vne^N7*&A}Ys z{3`})2R(ajPyOf5A>kOTgx9bnJ}5(lye2#T=*r5$2-OI0>QJ}HCQaPx0 zpS+jXp1Ps6tz=c-SmOJ*rIjPRu;6ijEqZ|Rz(=39X`R1@^_Q#?Ye)GLj29{uJ3?1{ zUfUCzB>wlF$k0=U_{mdsxwsZPL5l(1?6}vGgxYs&6U#2!?@Evns|L~czYX&X5WQBr z4|~C)1_qy;NlAvA(j{tgY-k7mQ=#-Bq8*+s_g5RWAD*08czdVIQv~2aGnkN%^8&oH zbQuP_whQmu{?nb&>&MoO`bRyDQ4`Q}#H@7BY?o-t} z4_ss@c)`L{GXImM|Ar+Fsp^6B94CXjKY%LXs|RavTXmT{vVhw-J!mVIQjbw-wSF{>2V40Zg8*(lRK@1m-=$>0`yu*)>VbKY;86buq*aZs>r^1Ig`zddEtVZ zXlBSvp#nUOv<@?WLABj~j;?hLMSfK=Rb(73#bgF@D#SwdA(VP4#S&A4^{QRW&)uH` z!@cxXJ?IfNFy!ogyz)Kl@Nk`MhF_IMV;UQTyisYSP1-)WnrW$ z5uosr7+dNe@?OgmfME*=49k^#YowxUGWlYj-(Fr zdpeJi&l&`_zc>GNlibJU5j-fX>B^A2A2q)S=lK%Ap-SGYJCfQw%mLfqYwiK}MQ+8@2tVdC$68CEhvc70lBKrqz zH0H|c@y|G2Zhn6*$9{{=!N|umJS<(vblVsQs~c=IJH4xXCxl^G{S7TMm{VU%ebNV3 zGJYNrGE)(Xy$+-DjuI{A>WneM5FbSR(a=%!&_e{nrbkN(gOREY$wvnnM?>+Y%H|DD z>j(>$2_k!5Qv~~*SK9h023D84=Z#4|k;tvE`71I%XB(&sR^L|gppcr0_-`rjz*hzJ zk8(l5%@~a*KlG_=`W{Gaes9wC#L#ij^hj>~z4vEac;#rzZbgwSN$(Q8w(lA@)F%Y# zVYCoQcD`~ZtFMcqZdc@mky_ALusG{SoQbM;vR?3V6$O@EVEC(U?g_sEmN;0S&zBND zFOSO~Q5S*d&kO7BOQ?2!k!P;cMRsOxYjD6>?>9y8lkMXTe5G~!13bhyW!uS4Zx++Z z1DU3NYw!LcLEQ#s9qXUihVgTTlYO}Je-FwF`#b_}td3FDFxlEGhi))D4^c%254|r7 z@Pf<;cc?#ajHr?aUd#dC3jPrttrc`1b!2DBi5M!orl!&t2guB6sXf{~6mXL+1Q{aS z-N_lX@Xr7b=4F6ZY#>?t;je$cp@Gai<`OPbrD4|;f|qa#m+vJz$O3f($>J7%+X5r_ z8cTwcs$L4?V;1$Yd@hAmB(eu+NH8s({`X88dAkAMfLG6S`yKi`VzTnRzvA2bgn?A? zab1Fc)|clLVfr*71=im_PS>`mvqVdNOzP#dPkvXeSdy<^$^>CkWJZG?5k~i#Ogd+d zc(2`znHtd5hAjq@I**zFLbQtJxEG5Oa1j_50Tn@!CK;q4ynB@o^RDYH90rTVF0c}( z3kOzp-i272*^+K|VS$1e*X?4T^}tj1b-9C={HGfe&fd{r#3vRGF^MPj)iVe%9@C3J3 zj~mw|YC403h_XnsEK8)RE`GH6&<-v{Jt0VQKO@Y6m^dsj?+7G_j#GXVW}HhV5=L1| z*6d$SS#E3kgwYKH-~1oQq`4^XfHY%bf)69)LmoI0l^z0q4S?)<4!P@l-nHJHu%r(A zKQzzl)x9=~<&qZlGC8k0bz>|68K$QbO_oJ+%<$C1jBHX$$~d>v!}2>ZEM@{lg+io_ zO@+|6-;i|%di9dYZSeKoaIU^0r;s5Kk!EVQT@nO`kzCphpK=hQNdZ6WzTIR7Z)Mwe zpGQDU=HBWmtP~XTE*X(-`~+3XVupgB5*31_-@juLE2*?c1I(Y|^V(na8TaM#kW)TV z6&xjhhXmQ)`va2%BQk|BOz^KVwsBYEy}LLtrQ2_?&8T;Ip?bTXCX;yUjXRQjvX;SM zL`M(EdA_!^)N|U*Sf8I2|F7@T4=K;)Bo#Xx-5{*m@w6S)nYwI zFEOcA@ie?!Bs(U4rZ=ZwJq8qzuEdxVvX6mCGi`Ii*3WfMzoGT9ly&__izIjv7U4@> z4}a!x0SQeZxHIQ1c>8Ui3A}fvJtc(TEJ)ijgcMcO zw-gZM^@udj3nF>?@lrCP2GS-3E*459OP64z=1VG+8lV#P?nsqKLSp%(MS;%U7=rtI zhLyW_?l(8Fpa=ydK0(209!pFjXw%QUPU9$`vY^uLA^hRuiv%_d{HB7bB` zzgJ*Mrpr=E`b4JyN#dKC=PiaH91Knp6_8fx=3SKyZhOKR1SIr(zejSq^RCuR1vn)-th z{bwj=iFY=VJU;G@0{F5csQ_1W3J%iY`cXj*mPTAn;JwwnnpHr_M>;cHjC8tuWAzK6 zDjl#B9Y~1$V>*FJepF#!g{q82ku`CiniVGhmPnparu(h%Te4y?8J1VBG2qY*!iLR5 z;mgzdgBCJTI){+4+YpTGS4W>Mc8=a;Ox&{_+5Xrk=+L~`d?dl=ROnD0X1yt|8du^Q z7pxic!fh=4So~q0yBkNEDF{b91gMj3s_3zt7q*xGTmu&ple<<*6p4;$p^m#dQy`63 zIa825vV(1DGI>Bt1$4z|p&WeZ6zK3Y`bIX`Q}D+6+b6^7<@%F2zq4Rzr0+jaZ5F8MNwgFwZ;N%_pZEd8RPxD|uz_G#d=M ziz_Ks&>@6YTF31-OYi~t(ahnm-V#r$IV)l>Ru)JxYD~{jC3Js?qD`vgff|olM)<5M zpyANf)vbV&@K^{g-3(AuT+F_frRNxTRvStU)cl}EkbgO-6wAoXfcuSqQ7em#O>3gR zv5mD~dG@T(S8F?MB3zxCpThi5o;D_iJm%O3Hw$&RUQDHI^QSz-i6S+e(r4eX&Gl;Z z%*4h-kvCWYswdE0;s2mC;*{o2R6%c+@x0-^-d$}!0Z$sZ^vAlb^iN=zz+oIuu{q|| zuE$Rmna0=0@l>Fef1UI85bZDWFWf(|TkUtSqAn6>{PpE{ZF=+>0qtBbJRyO+IHx|! z={`VGeH!#%!ba2^vA=H9GW!P`lbYuWO^E!4<-o#^h&|4Cmx?88w4&7|c}L$SUByGr z`FV&ead95ZcrhXoO6O*z-Kir-*NZWy!cn1+(kC&i_U)(g>rEEy4B4p}c~Vm2&D5?* zH6isX;k}IqS%LcFh2E^cIWo+ENEEl%WD_I&>8rPT;-JM3yO#pCueCon6VSW3kgd0a zweblA@!t$!^!j(IgQYkv{SvqotT~m_uc~5&O7mKk_~lV(o9+32gk+BrFgL@s zcbyXjyunZcy61g#M=`JoF@E-5J4ak?8C`B9ojMI!Uwzqt>B=i};hz%vBDfpwbS^Bm zDrM!gdR#ELqgxvdgT9hJ1mmMLQIGpa5MBs>XA&(T3}#Ri>WL>uGn6V2YuWHWrGn?t zcd-MPxy3yIQj|^h$w`4|{^}<*{912aWxrXT+1k#*#LVfZ9!Gyi2X)@hs{IZkAM5SP z=SCm_Wo=9G7Kcj1lv3VJIul48B7}Djd;SG7qZ)!u_0E7j=J5AvM|_^mcSbnGaWykV-Vw}Y5(3_%fsFyrsa&b7j*U_{T$ z;I;djF>^*vH5KjgKzs<>W!; zTLoBzoNQ4+Yrind$*L#Rc7|5&#%X8#1 zDxH;@J)g2tA_6HVxdUp2WmV#)em6!oLht(h3Yv`yeK20a?%ms!++>? z(}+}uA*LkF_jvQG?v@GxF=Sx(c2mwM#B`%p*RvtzF_59U>7$|ll0&dPM{`|4%>_R; zs~_4xz&)HR7yLfe3mhRrSVC0yR2vlmcbo0^O6M9kEjutLh8RoQaE6$`z3ASn^7XD` z`~uB(Eygg-RR#iZ2k1A*I(UqHKYTNUdqo!_YDY96mxqnLuTPBMN^(N-qkKz!_eSMp z=`^YeKQG3)|5si1MQxJNXePP0?j*ntv;0;WTwg>NZ#~;K2+#K?_9z$k7pYvFO{rfo z^(O>;^7ye9nZ5)ty^hQA(_t=6@S@thb38JDhvDcX=1$+_%2P{I6Z-UHsC{DJt4XuV znLMPZ01UGFc5sg5ez{c{QD)ldZ69w<(I%N_1ZcBp5q5 zFCvkti@}d%8yp+LkeTB1Xm2)=4^PutCj_6KTl`AEkLc%YeiuK7(%{d(Z(J#s90g1V zyUqEBtID(A4-$(8S_V8Z;NSXCsHrKo;@rD#jKe+=-A^rB1~Qgacrsywu1k#O=CA1D zOk=$#u`GUTZ^!-m#*z^if%*G3_B2P)DpRGC+t82- zT%D_K^ZDg$d^9#yfxFZnxO=)+C3L@pIJe4d#IT?npGvm?y-Ek(?{6A)x*z|N>0#ws zcj;7jR`>i?!}?ehiu)54`G!64@DBcGM}v7FRY-Z-Gx_BQ5ON;U-R76rGMCXU{JmBt ztBg6uke}Jt^c?-rdS_*Z7`Rejf)X3WNc&xz9FgBW0tvq{XU@!|UZllyj|V>-mcHls zoX|+Omhc`rl+14r%RD$3SE*%Izb>#~)xTKIU)}CZfEDzGQW3@u3}_W|C}!6H^;z3zo|t&S75szWzy2cdIZj;nC?Kk;LBuw~Ng& zi;Z^uH16RJ46xnp?RRA1u#3h}d#DUSv@p#01yB3wHmlrwL)=iguO` zDwoQ`cHJA3vD&gKjVMr4^rhqKc?nt9`H#_9+m)H&bVRylA-h zgeW4}Xe+v-(Tu?mZj{BB1>ItCeQ`OVjoB&jGN09XMG`{LsQ_1pVq0!5?`Ok&*-}!^ z>C(2PLi&z4PmT@Bj8<(H1*@;(K{ZGWWl%-wDz0Ow^p`+hq6=Iqp^i3jD+qFU5sYNY&@?7T+sxDXP$O`h7Fa4v$Jl`tGj#qydI_^H0vV!7 zH9=HHenSE+0tx}U-3J^2--9V#ML_o9j2R%>#j*zYPj!^JWOg?tnM_qr8X!|GL zn`UE83tHPAt?pxK8pDCZ=F=~QXf(MxOyrpnm^Qz2B9{ag)g&nvDdO_ls(q=2vU^fY zcQLREOknz}>}#c{IX=sL=%j=}m!h)l&mh#YF>T{2A~fx{Hi9x~*I);wQ*1itOBl|KcT_F~KyviMnZCEM}at z0T2<4#lIt}DXo16JHJ>;p1ho?`dMhxai}%c^A1Xuy_YFrMzP9|wY9nY{o8K(h8vQg zKN`Y?_10DZtwM#9O%&!O?G7;2fPA_w7g(-?4pPe5W zJ@&1Kes~urDvWtIdc}8noYmLD!p)TPbLLOry{rnhU)~&X3R9yCvCa^xcUOBWj~Wty zM!OK|e9PU3 zH=aj!Xvtx(98&zi>p>8S=F^qVte`AoM-Uzn6>B>qBsti^?A@Q z6O3pi?>)sWESKm?Ct96UgJk_-1-ACqo_R!O`5qcaV9Wk<)PMQt5 z-I55m0e6*59%&;hRxm(`6u!(B7XG4<9O+MLY;1&vgE^?NGr~SA&@nwzA(UzMaD56n z?^nAiN5p!;RP_T=At_Sxwd!?ld7^TR2LZ5bs>aHx-`x-=Lf#m$O?k5-;GU!?V8KPS zawwqOLb1kD9c6WmIs{q28k5XBF;Ipq9lk7YeoXUkmV+dRjh`9gL{9pKQ-5&giEVoL zk7&Z&_4})R6qI!6*B9JjL5TixFCw6Bcm3Lc7<@d<-r%1znjr!fKLzFHLmAG&;d=uc zT-?p@=VDmPlp3pYS*oEMzXVr>%4&d&A23jwC-?4-vIX^_CcKo!I0CT6Ruc!y`Kr3& zsE*b(Q4+v%@NdVF*He7Z`pM9o_1KjHOW(KHVDt%CSSJHfX^b?$n1=IE{`7P8f%KRN zIz%%IOBp4>MNgiMuVjDv~ekGO`U-wtc>w9wU9DzVlO7kTqDNLq%N$6|Tty@|@3&KV!MJ&Dq{KlD& z47%Ga_FD_df$pX)a^glxYY*@xbSkl+rGHh`Q{UG~3lUpC1xOi7ef-n(ujR!>)>a^? zp@Rt97SkTOEz+b$i#s@Abuhw8!1%E0w3Ev_-#7iUL|2{;liIAj6jO!y@qiOzT2Q{F z=Ml_h=*fme4H*gRPWZf)7>fRlIh;s=V%Rv-$%)Su+{jSmC_${CTz4%tUct}OgI~Hu zN2E!BRdr%Tx#k{48y06 z$%KG8?IJkqF)^%6Yv-Q}IjHEMpOeRxpvp^j^2$sN;sxuhyvqiI+B=w@?ylT@$p&P- zfsxWeVb+3DKU$o^w9Xxv-p)zXrF%rIcM-XkIY;j}tpnXha^poO#FJRJ=V>ZAYRJ{bOU~@cpD! zYe&}27p%#Pq>aJIA+s@1dhlrF(#32^09W^!ncrF#r<4x*)j$IW6Qrle{QdOUY`f2L zz`|AjfCeJ1NTMm3g0v!7ufJGq<>6$#e!|dB4Yf0eV zDyuimFVEccuzNN!p(FXI8bBF z4riVyz#n;z;GF!N{&{Fw4gqBK{aoo3tJn2K6Rn2WV75Hp{wt8u6xGk=M@ng9;f-s% zI&i~HC9U&Fj?zGC){aoBz?r}9xp_Hz3jpjW)>dMc>c1H2Q|x2=^kO9fvCBV)A22Bv2k>7ke4uP1~KhWeV(=h`s0`pnJHR z4^=hE=&0}%;XiHLa{!cpJ4v^4qY366cLx8Ivlb@uvHeM4T>kCl_KjP4x4!jhuABUM zfQvY<7P$^{+`Ro{BZ(_7y>jTr9HNH?su3kuiL!|-i!sjFkK?`iVC(ZM1>00|D+7vy z89ES~)EHE0Q-T~S)nm$CxcyU+0dNiFLZOtrX4Q^o68Ny=SIGR$Wj{(paOZge zior$=JV5P{`6f^DPrmf>voH);-EN^W5C9xJsrCC`=Dw~P@f9eNeTM8YHk2_VuUUNv zA-uOA%PtV8RkM1ocd~5#ga)>=IGn>W&9$E$rFT;MA`&I~C1pB1JKL;#6V`lm1oQIW6BKEmpX ze6HWiF1Rq9Pu5zW0vJ)?WmrN;WxdNu<(v_jlh0R+^3*pg!exhjmq>>leqUPu?%15P70N z&PPsPdBe4%MnzAn(ixL92G+s9-X@5Vgl(XTAKww$-u}S*NlK5l8)>YYGnw2M<`q3M z=h3tlr0~Itckt7qc(JJhuL8Cw_~N;#W0QhTo-!v(W90W{&Km zv9$8iJ7E=>j9dL+y?z<}3!-BZk}iy1=l2T7@=?_!#T$xI(83LtC}=bWnBo6x0Sf=I zxE1%vke$6JRE1Gnqw>3tJ~|cue%6l?)BzO~cPa%xorQLZ!fmVEqp^cSA0{;VF z+}bq81)G0O%bR$oVB0LfIAFp8R9f{R@+0~&Yi;2CvU75*GPS~=WO?@7rB;NkxjkzUz#<#~>=5=1o2N-z`9iWeM3RDm*T$SKdiZP0cs-mh=Y zcIfTgs)*>6{Y9*8?9fhq`%#NjeB|ZGhfDIugMK)vTiJrF6u4_U0}0^&%Z->y)lFy& zan#e!?oSE#3m2UUUTY`go>1;$PQ;9P2(!k;437+XFKzNUv6#(xatmU&sK=a8V&TrM zBP6}0&ZVMNPJGaRiT>~e4+Ik+PBnIiRg{rl5>>tTE$}$)Fu6J0{?LLbC!rQW(%4uB zR@?8-xoG1b8(jBQPy(gpkyhCY77^aREX&5b>KkggQFz3ZTm0rxWR{E8N8bF4lwQ>N zK+BoSCu3&J8>vOnvxOpdkTAYiIYgLZZv54pZ5WX1h4?;Ek|wXD?P!&6Vn+`1DQA$9 zSsn`;c7t`^<(6itg~omHw>Ll9CNId(InXR+C5?`ADBCjowLAzvS~u~Bt-1Cc)~NeL zCT_FF2Tn__sBYqicc3P}>*sqD;SxRw}~f>k<*MQHMD9817tX~3m58s^v(C4!fEU530-pOkWZ*BDRr&B<8+VFfWy@|nk{Kocw~jc4aQ9H!?~{Dh!+j6r+!?< z$^hEivAl|gc-D%R#63e|qmwd2RUpq?IK@0B@G;GnMt$XLh~YCu623zI!0g5tZ%s6Lj-qhI#`ibEVrNpR zn>f@s#*WhhN;N7`8yP%r;EKWN-%H?g)kpSlUo6q9{kpyW)%)Vx>C?;EXZ5OsroF}4 z*};JmT68Qdnh@&rPg7HKeXLL)0%}>U-r$7U9+m}`2@$?kPH%x(yT7pIF6k7kP@@NW z?dp@YWu2Czgae0S2503uKveSo{PK|%^GevPFr_ED-(G%wNQ1o>G`gB8rl0_VwAfyg zL~2T%Mfy(-G48}Y^x&S#>W~(mFosD;^ll0qXef^$Y!X#!Kb`X0j;c$vS*0T0@tzjY z>HPSSN!JY27uuXh4sk-uA09V zOodslub~z~xZIz3rGX*~VeErn%MjoHY;S)F<*)nfa^EdYn?z>ku z!sv7zHi1(NYnIczNc4tc`9>t4$zD9XIAUlbn%mfcf+ zKv@k&*fx81I;qPvWyYQR6}}~F4Ojnmy}evjrtO(>U%A=v`c_os`m!&#o^uoTeHvSP zLsKM{RGTIBV5KTry(Azp(Mn9B3eKyR7@vnNYnlr>@xiIXF10ZQmZ_MC{l#Wt8m1k_ z&sz-fYOJB1{|UnRGJKD8v2hn@s&Pr#!KHk7bW~DSQ4DPh1SSC>^Z_$~UqB5|j_xDW zpUy^;qa6oGRpO_fYim9n?R)I=Z3i;k2V@5R%9Quy=S}OYzN!Fd_KG{yC)}--Aa2iw zm!|A6_d56^;#oqGwMHtPhM#jxg!(_f3o4)8)9<^O4q4TlG(E@9B{=~l_IiM-fIJH$ zJtF%>d_QbsONnC_DBY-D#@&JGuH#fq?ESNkr5YwC7Pxx(VYf2qp;vfZ@VWGyQgm~$ z{{rJF$KP2u3;2@8cZV2f%*@Yz)?WYMD$dm8^+njZ|%N+o}xs`S?6BVlfPa$g9w&nbIwO1A_K2KIL`FSeYCL2M50;=S<&F zkn!E}y4Ojg^@~UQ)9M?K$J(<7;1x58`i5@H=pf42imJrOwxx?<3{2}hH;N_z4*2w(^%}0@xGfbjY8rP z>N9o5MN9H?9-ib;8p5i_oRcZ;3`GlIIhZ?KJ>&E+8(>57_=9a)$Gditgh6FDg^$S$4{S5<(IPs~>L zb}be#m#rG3KX5w@q$yl#9PkzYH*c-c!{(H(PCq9ijY*~)F zU+#_ezA)sMYRLfUSp^vdX=cVhzBPjgS{4R=_zwe>Vc zb7Z@l0j2q3QBxCX&VKcWQH-R}#%Fc+-knrG#QTv8(qMI)!N4U9slWTLPiItWin_UA z8?_*>XScQ#Y?f$z638?GR(Q_W8jI1-zp`FB3|rp_HwXiOasAa!W#2nv9~KeK84d;V z`cPZEIBCG!10E(El*UCaeTI?M=N&6si+AXo)QfZ>h+}0INmQ4J7pRS&nQ)!4^op?X zR@n2BZ6C9i8dgthO_3K85?KKLHB1xXU z{U7rMeOhLjKJ(@oaNc}9Jv;N>@H7fee7=uji5`I7Ay|bs9rpNXwth4aw%z9 zsve>kG-IKN43TbAE3AWr@{Ws99C+fR$}BA{5tEaeEZ5tY|2^ixt%CRUZ52v@9~+yrm8I<_`C=Vl|IoRU&CVMaeVAwy7z)-&A#cTCDn1>Z!i*Gv-PTwq`|0lGPbN zW`wAZj-sK*hbl(MfGX9Pn~;0D08M-bf&Y(<*XzKsaSI-u6d55OwUZGwCqySi(zDj5 zwWm`m(tYo%x_JXpr%F7>mV@2z%sZu^zM!0n(@uV zXwFVPzHEO#JXURJu3r7(bZdBLp0VCM1aKJu*2keQ>44V&&_aXePsIUmqP)e2*yl%C zPK(9GG;BDu?}cT)8t&cw$);S+gC ziIK=C(Z28Gfzd%%XG8Su_4UN$B=@#66J&pB)_pNJUaawP$+p55W~1+y!(1T!j?2S! z!se!uB4jE(&Ym+?n${J)n@gbe95!ydatoZS*SHJXt*?6*)lcQ0+4kzkr(EgxQqZ%l zpdxH8Y(AW4mmJBsRa;m8nI(B(&-Dj%I8)fQ(muM=_vy2u^F^}~6M>S+aLVYTJj3+r z%))h~>g!4WY1SaHEA@!JZLMN8jAykMK{?n-52pch^q0))7I8vVHN#XtPdf4k@X5j< z5$!F8$q1}k}&)L3%Hm7>*z-A!>V3?o*J7v6FxBj-+5~Tywy^+ zu1Cd^kAgY()ki{TqfWn}noL#~W|;)T+PEm;17@z}2CV?-^(&YEJKcH*^YK%T-P#cv zToluN2KGPp()rGWY-y?ke4fvdj0-L1yzV6;OG~;6bQ#(z@x3zNq>yIgJ-f++c;awXJ!-UN02H>!k4ikzDO1GQ2GHk?{C@ zM+umyK8lF!*4QobY+b;YXeLUFsjw0D^I=S`%sel>Jl$dWUj15s>;vAedH<`eoPR)P zjiB;kk8mImkRJ!A6B^puavZ6EwtH!LZ%YUhFer{hoDF2k(O1 zc6fHw|C8|v;hH~On$OJ6>Tfo21b27q`7I8g>%{|ZS~z!i<{|T6eSL_ip*$7?1x=9j zz9QMKyws|TMN6RXk(t4h7;Yr|rWIJ+`<6PyXt5d+LW@&xx2Cw>XZf|(i6+4*?Rv%Y z`sQ}SGqK5aFYyz@!Qo+7UAHvII5Cp0)z=p=TkY15@3dTv$Db{>K4l3eye`T2XW5t_ffQf4pSle;eOx%80~yI%C#0>pqGlh43@%FfRI zxKw8=`MAURwqElFpd9vgfJxjd$@*qW{F74_FKe{fVIl7~?%s}f-OS(@t1^ar^1i*g zZ2(9`luvjkC$667olhjh`+I*JeaXhf@5CxvE*0CZPJUgKmeQ7GIKR?IB2hJRS|%&8 z>DOn<6D+pqF!}g196a>;oN4sR)YmrK`Nl+8yi+%25yJ1e;PWy~QOrsCv`-w-*g?`f3QYJWqcTLs z$-`ndGa8NRQ#{3?JFH*SIFk2Ij!fy2cEHK36WDgk^|8KB-Z~zGy|uNq>TD_dM@PlB zcMek}_$l^zM*4>5m*Zu2y3&;M z+|w`lsI$ZC3`A2$OZ19E%_dbLdkTEY6Z7l+t#_~4l4AErP_NmtA2($cm$o7{ev7qN zK>LTp&d$IbIBlv|JPB?iYNr6_OAmUC8Xp{h_uwh^a-FoFAuAwR}hOCCoZ(kJfm z78hv~Bo+WDU^8zf&lp*EYwP9e9hdtyHmCucG_W7X>ac}5?8mUgDCSv{hCvIgU(pa> z+3NQi@s;Qi!^8H^PAr|Qe%c8{C#tdROuA*wmZ=uB{z*PruAk&9PUa`djJIEYekN+C zCX6;+#*EvpzTJuzcE16*V8z9jl26`VLQmzq){c&*%k?LK)jkCK_~5jc4}^{ppKBeI z@Ck7|>H7Az+G!I6pd5&xU%LUH-!DPO{Pv1?B~E=gK3ogHTYS9U5Dz#3>+P32J33%Q z>m5xm66rHNchg7g9Sbx$5=Qp`R1WY>m~wYV#{y6kdyyf^yE)ZCpu7PMRk4pi`>gJ6 zDU;z{Wg-t?)xWYDP79KTT~uND@59}RKkmbchG1hH&FSBI(zhP54VPYtNfyWeA7ZIo z!*5w{zg)8z!*9CT1z zI?yyf=+6TY2|MtrVoxhIO!$(o7xC$Wj+DSzYxBD2?h+tMGYn&1roN(*ohm<6k0}(uu_sp^%c2T3K1;wzX0AJ2RyY0~4HBT^(I(^#AtpBzgw_fDA)H(pOESp$GUa!lu=KMgfzgSb(>@0%$Bpz)-n5a7XaV>>po zv}D}N^5%#pUD(SV&&ux{lQAbQg zjMCCr4#`)%)y>U~n(w0+;r5J%w#EQa<93|r1YcIKQcCrYLENR~rAWra74PxZLUm>U zJXcm04fsr_Cl&^R9JSSE_#px3vwJzr*}ib~&)c=>m~`Bg=tnk@0v&GQl(m4^D;<`^HCJ;H zaDL%{#Gce?*kQV>%S8*pR5P{QdA591^8kfoVt{Ke+ZEW$1Dl(@T!ba7fr{U0%ave3 z_7w&OM$3V+<5nONWrw?X$d_b99WCKpl}1^P)H)9jci)$RbsLO+=HnZ9ez>yE<_&ifktxyHnwc#FJahzAR$%Yb zrc~hOHE3S*&qcT}5&u#qzl!+po!d0GKP4cQ4N(47&&4Aqt)#>{s;n&i9)VBaQYgv% zY|R0E+RQ^p3&9!*l zbtQK5F9{tJb82-J;{(qQo~G@xUP^_0-hoKdr?5{JA-<~sf8zoJ9RmaCf1ofwi_uNQ z;5%^#IJvt!x|2`Jpv|RCdK_)SIpcrgdbilatmlO5lLTWXs8To$pOZ~*5QGT1vi%MR zkH$pLg38D;NaY~Vs0^Xx(#EnHyyg0c{=^mcd3~J}Dr&F!vp%A4l*Ggv#gY%q_O8oK z+o=uQ6NdEm09NA5-m?q&FObArMb3RszolGydMdI*%Yg-)ju?-a&qt0_U0se;l?Hq7 z&u<-Su1sc!7e9gkP(-!cA`eI7IV?c^^1eOJbIi@DBhv4gILF@TzgTtdrvUbG=P}Pc z=f`x*Y7bSxzkk2GE}Ez2*B#JlpeXj@g60?gdT>HqaAa~6VeBT za(ws?gSF9&`QrNm0Ao^zIa(t@rDG|d1feC6)f0K`)pK8b>W$$E7tHKY-$Q+xW*8av@ zEoG;&paf=;w53y$MsNY0oV%-K={E%Or{IGh-vI!T&gM(-SqTNb^~()xQ>M zlIz04pV2*#gv(3-2-%aBJ_E=?W#t#(zSsJ0J@GHEvo>mwsb^ERF<^)*?HRJf5i>Y!0lq!Y3{3~^Wot%@iCQAcUZr* zqir!q)>dZCc%JvV0RRPq?m4f+-Qh*|epWQuM~o(NuQWgU0`SR{7?L)xdB>^oQESR< z0mJWi9{*RLZ@RmH(!C2vs>%o?U0__N00u}}L$*9{kGpMyxS;Jsik%8|(@svbtO;n!meGE-nIWF~(3(=lE`}wcW}+Ip9&( z6d5hm&`u&Dp#jXG-s66c-rhjnI-mF_*gE4o9qCDA-&Q;yAHVP3srT7Kx3ga%BYTh1 zfPu&Ug69D!mv`ZjBATl4QYdaWq?e>j^=Y@|0qs>J`x9_=(W$p1VO9D15y-DjS^>KC z9(|8BndKFMF`*Z}kRrUu5YN}9J)IUalp^Da*}7kSMZ$DR&V^vHo1UbFxNdqPLunz> zUUzbXh1&GpB8J=3RV6t&q)8q0;p+dOM3IcRdOtQ1kl}v`IMSpmCd$(-wpaW*J@u^} zw=eip7pue9H9c-un3tCgWcSIJJJHh%I7orRfSC{#IEs=!Y?AJrk#{Gk0wDHJ zzqX(6RlIy2J6Q$r3dJju8Ox0OnEqWg+#RpqjXhY%iIK+s$F8vJ-vLN1xqr+t^PFOA z4gC54-W`7wM6XUqSCy#B+F?z3O03^D5)}Y!y8x<92{_jN)$*$JyOTHHotPfY*}J*1 znZ33&?PsV+Nl|zM|C=331}o76dy`Tsd$AhZXEp%E?kyN89dyMZ6i*+WiXGcmRn7xE zXBtD9swl>}Woan36>?0#r&LbeA)u|NZdf?d!NGy?*_tn4v{PWoQgH?J-`LUp%>S-{ zJ(K%PeBxg9q*%RqTKpJ5r|0jK?#D z^X@3*`0#iO==)&u8sy2QTOCqAM~J@KQO$<$cf9qQO_{=>D_f!obQeh+#Q!B|zq{f( zPD74b1z6vKa4==Za>3rlq3en+`zW_ij*s-?ygLwc1;6+PmNrDczWRk=16TH`Ksxs| z1OVum|IbzUe@0pKO4la=#3!VI7)REU#0VWZd%5-Sm`!}5F#XS4 zNE8Z8&GEmfx$v6#*`2mL$TKfCI@6+dS{G+4w&`?K+l4>@|BJP?EfCs-g@*xwv1Q}N z^HuuvQV>PmfAqV9WMIj(0uLCX*UokM{mZ!l9?b-#ckewakq&tMI z$UH&FbOjC!8G)m71|jyxB`wSu>DKdSdoE3Tye;g>SF`9(*WeKL6emtgEf7a=9Tz z@21WfP8>BOAra|0wahVga|^K(k!sQd0k$S*FSpt+J;r}wW_**B6hxx{VO0l7OOi^z?U&z6}Gjqc97A4Pmsr- zzxw^93?K{|eBT*X(@F;3wBYs^j3^7IgA^s8>xG{CY%+j%0pLV&jN&XQy#xD9gJ!UK z$b4GeuJ-84^n}sI%b2F7rq?$&z(mG@P#s96GDYzu(9X8DgiF5<%xC#mBV4_Rj&ygn zw|I=%Co4B#!K2BN?B(k{jvne#_2W1_Wp2)pwCG`0*WdSuWb)7e8K=7<^v%LZ6Zs;i zV_i{L>8)DB`$Q>VM}3GY`_z^KE6@oc6S$nTK5PVbBJt_}ZLIr~WyjI4v7BAl)RbWM zKGcEuAF5yIo=Zs&z-f^$?)N;{Neu?uE&QN?xS-_Sr!2aTpS;f*)?i7F=->JQ?H;c9 zk6!gRep4zOFq{E%nVz5T2d<6Kqx@1E_GPibLw;KYx+M7n<%pTKKtGp7bkhP;vl^1} zZ)16-*4fq>p*mu1e<5`@7QFbcQ-9jq-2X9AdE`BK1H22{^EV5}p0n?-FBt^i-%S7# z?03jCUtq$|Eqlz)hs7(9vcc+KLa>J~M3w)*WS6uO!7V|+e{GLGR_cxYe=Pt-$GhjT zLsc{yhh+8L5bQqzED$lBzjH3n99pX#cvmz<*vQ%)DAj-4$G_FJ?71T$A)U?h`O0W0 zp>1z(ulUZd7V>^IaK4!(E>eM*7+aI3wjY~I7kqYkfCX9`gj0I`9D}N4kp5EpnOWn2 zQM#q7DZuCco)RFn#DH;?rx|2#=W_htMM}d0xKNkENAJ7)s*OQ*O- z)x{{!FdFJt9l}6{%_q0Zk3_cz6oQU0ZLE+Mqz}lGU+@y}oscFl(}4cD^30OD-W5dc zr`boUFJMm{cU|E>F_gK9%p zcC{n=ymx1~&b|R={asjqWZ&7zQvvf{i5ZB zLw;~=KGPJ}h>cjn0u`p*DOPCr_+I&yeuq*3=e%Bb4y<8c!|yN%I1YOY2D_I?_*}nN z(f$Pnd;7fouK7N8L)Q-X_k2&B>fg5C6zhn3I?HeC0bWwGrl}R;z3^QGPE*IHXHT1@ zJK|+-Qg469pbj|k{eyc~VwdOL&$od{3_T3^s7dk+`^Se2>7M}M26L*SAFd_C@N3{Z zV1GEcaK3C>F{9Oz>6~z9&6Xzz$`|bza$V8vN6*t8@iudx@g<9HIE?V`+xc0KU^fJq zchw)&7$CLa8TxF2BI04@RTe8^97q4apTgsI_-)v1Bx&5HYr}4$ z3eo>J$fsFx)-Pnu7jclRtlIjzJQfxJH75N&l7xquFzO$`?KLg9zB{E!9sH>huQ8xH zRzd{IJqpW`X9({~7?^VsdLHe~cISXRr(uiKw?gag+C!)uVF7jx zz8V6wf`S+G`2;-e2lsaNb_W4Bz#-GTBI^Wm%BRlWK9Rp#6?G8R&cp7(IVP!p14UG9 z{!P46x5g0-`q#1euLFq=iyIZ=u8x)X6q$H$sfI;A;Q&L1gKpLbZN2H|dZ2o7R zuZIsV)*2V{JUi}v@4fHebshT)Qr*>x{B1kI!1lk6e+=!n>giU7xf$#P3DJPR^Qipk zkcXMbkHu@9`#iA`q@>qt`a+&Og@h=E6qhx3#;?NWg1_D!{QcDU(1l9#%PaZ@jU9HW za5&yh^aK@FR9@l`kwolZ5q7o@&5PKy<1bNN?^2oY5#icnVD90B_FBE_agY=`<9zh! zksY^G%mD-{Y&(Bu2<>-LJH9y}lMzYhba>zlBJYVaEV2$CJpjT(tcMC?0 zEMeb#!k3bWuu{hcVf{(&az~<(TnGMoZ6y9UCiDt`Z6DiG@#%rxE7@0UXdbClE_>t! z9#9$h+0<UuBJ9^X(sAejoj-R*-IEHm2fn-S z)YAl|?(6SChc!jU;eINMTv#2nVeq7AiOy~P3&R82zVU>6+%Bj2$2Wuun#k=K2|jyr zJIMcilYft&O2t6#tap9{q%5lTA1 zph2UlqRxMOrG8zW#ULpx^Qvcl)T&1gwh2NYElL=gV2_BCPZLd_I)5jcAeniEYxO>A zC@d%Q|lvAId$K%n&v z_2RU7ua%uxab0u2oRkapaq4Q##CR@u;>e_s#9{Ce^}{zl$@O_?HhlLP0?7aWLzLP3QM)wc z{T2_4)@x3>*OCzKZL*gFzk)|>Wi{_ZP6l#P=~^!{jH#a_{rgNXiAIIbuVFl-7pW!r zK2vKe<@YPw(iM^b6D7k#(ORH*01PX1~W5 zkP2RCs!2pqcz<{AsJz=Ofp}i}uQ^~+`U2xxS!Q42(PMQwIK%?e9Y@+vrO!RJvSjwx z1mboaFSMdHsY>}U5}$LGHEtaO4c62lHYQLamz0EfK4yAH_Z+`Cj$SSjzmG0X>)RV- ztIe!Oyl#~dTjsaYw-|V~5~suJ2H3}Rs9T?2wUF`^X$R6ALng8%JIb6-$_{v1Ra3sc z(26dn!AMmePfcSd0onAXR;*U5N++zY2+(KI4%wg_7l8!7A)I!ylghwvaYYqc+Pak$ zaI$zg8+w}ag$1L{@vwkYmPq#}{^4)&lU@l*y;gRA(n~0105AJ3`8&Kijr)1zvsA4l z6zRO}&5|@Afe_c8x7fJBKzsMT6MsdeX96?QiGZP$*JM0Lw;+kxjK`%4`zOJ*%Azd= zdUWB`d!=pA+nF4@AKXv11C>R$dd=Sn{W1JXU&5~NA7(j zy9&Y$!GmZrJRkSjW)^Sw>vglvck6E|@FP|DXn`LXZ&6XsdK`(8fg09DIi*;cnI*k2 z81jwq##PF-qn7lv4zaF~%Afx#Ez2FGv~}w|2jT{6fYyFk?S0O8@TGSCO{BoeidxT~ zhar(dIMUn_OfXD3(obpZE=D$+-jWx;9oXgXPlI3was*z>3zH|ZrDqhg11F3M7>pJ0 zSF#uMg{-XbXgFK=DK*|}}c*g(5EAg|v`%z1p!hgwI!Z>obFZ4Uz7IP|d%2)jBO zwuXE34L)@Wwv9KV$PNEBl{RbgBwuS#Ct^!VtNYxm?(hCT1c(oYvpqWt8@T|uL<7gbwA8? zde%Tod`!_X9slILOGSzIp0J}*;wR7w{>7opoTsb@OdAUfViHQQh^n=69chxd8ScL8zP!935z_wO@O_f89r)9f zceV+ah~AKhUI?n8E$ghc%BUUnSAjqTIJ(n_+;&Vo(H?XEV=+Qr%eT37>IFg5=kd@* zC6BWd=^79uN)`{nd%CGBHE}TDpgfw=OX2qKASSPWb zH0-+CtbHwl3ooK0jwq{Og=0w-TnMp19wD%6T%K2(Hski;Xjbao18Lsti$(GCFqmZRJVl_o0<=!zXN)A{++P91r*I?rZHqS!V?+LD&`p=~R~tB%oG@?b9hu4^y`4=6SgVx;vt;vhOu zJ1^ zvn);Iy{?m7>PCP6rM~SLYMLX)Y)gY+BG_SyU-g-anIx5Eibbl6u^?5cQ@$?5dv8gT zHVWW-iV{149V&q|dD{^z9)Ie)>s(!9uS}kV@jnjNxFIkcY69}#Qk?HBvLVnomJn^b zml5vIUF8@rih~HLoVW*lIGWwK<$Q1+3CH16@19Y+$_^V=*Yt5T8*+RZzF17zet+@k z`mJov=b|43S{|F$*%^saAwPP3|7cr!OxG{tKaRv#U~F?xQ^|j$_(k|n=R&;}Cr~_z zD_d)&$ws8BUzLqnK3+5GXN?nN#Q)i_?J|-#O(^_*e?#HuqmYJ#gUjgXe$IS-wxNu= zsD?y(#2Z;9yfxK;6@nsL58(A%{!>?mwK22tCpL3J)qFD1`|<0yF>v^L8)sV~MlZ={ zK>{gqdB~8Lsj8CupFOIjhGN54Q>dq&dhz@At}Au@2+kxH!ixMd;})$CjZE1em(~kZ z;##eUxJOe%XNdGk*AJ`j9D*)W5Q;As*W@ZAwG*D>LEBA__0VURlkw>vh753HHI&u- zmbX1{+YMC&Clq{rJXqnmjsxz*`iWKs&hj4DwoP+_QsLm=B(Z`QL;*t#MQRITxNN7D z8c8JJ_>O4!$R_<5Bqd+iQ%1ID9B*N_VahY;z)72zJ;<`QO~UC0 z!Ap6V3Y4?{pA)!Ju{44fO#_Uwvx+A1u$1rK5> zNi#Rp#e^02^!14~DTRn-dNnm}B2XhG{xe7pgQAHs#~gjS*(#I2Se~gtai04RbJmAI zidgOcb=X&w=v&c2UO7a?3$Wv{jSSCz0H!@z2Iod;^@7) z9hI9-(J8l2eakKM+9E%DwWC5Yvxv2EoX*1(L(~@Yhq`dWz>W2XV6j1_NRaiQlCnev zL*25YwVPWQHJ)eM`CTVvkiN9(Cc^zW&gv`QFqiaSlWqG-@tQwPhKPeltJEijcb_@N zxdObXVjLLW+)bL#@;)^TQji~PNs@US)mx%p!Pe#e2;^fNYUt?b+*PyHzQ`Fg1wf8X z?2CMd3rAP^c0^pY^-y;Y@Mpfdov5i1Ch_B@?j=dx#n<{qE`MuFTF#J3ly2$7H4P)p zO#AgaS`pRh@ldMsbi0C?H|}WW1+#_6>ckZ_NcKJpUV>B$dcTb!@!vA+gap}Ya{3>J zP<#v(DgHJqfRbh7lu*AHu#>X-U)-`NZFez9f67>P3@Csi<6MwL1xh?7Hdk z)#%x&Txo|f|8$J26|`wI$OT|#$Q#;&07*KNcq*t&qZt$kuq)8ez^Ur;3n50mY&FpI zvITV&{g~Z1F>w6Je#|F($)8AHHq4EB<0c6X<<`_Vw8X`22M}fLuNo^2k(N6smqD^~ zMaQc#E9CoI8B1Zke0*QIA|a9NuaCG*TXf2WH$pR5$T@^@NI#J`vp+7%meSFWaeNa~ zhClPfLKj~P4XP?hR50VHI=Xd6?NH}|Ly+U@LoITfIemCAaU1llVl$zhB8I@`?f0JuBdrspkmET)VtW=;@HCHf=bwh2T zI68d=H#TWp?XVK@pR6LmsWva8`FeiO6|PkJ27$a2v!~GRs;W!9h_MrU7!Aa-FeMnv z9g}|bc}HIdzmA&`~e)IXqvmHwlQ`B@{_U*e95 z8&s>ou{sy(ByZjl9IyY-`4t2ux~hG!YcF5fMx0-<(T(}E{&B*ZS;WB(V%b$YTxABz zV9a74Q?_jlt%#ECR?0trx;A$PR1kkw2SibJ9hYW>oXJW(G|28SfvGNR`gwxV7cS4P zm=vi#4`<>5TE#RiwU#({=ag*4ImQCkP(1lv)m=QpZstY@aZhd(a&1Qy_GowhU7R$D z17}EW4$kI}PdPYsI0|12zcV)RB7uc@Txco9(i0QQR`PY9GIMZwl-NG{@QpWKS(gt0 zPz079VUi&8{Nas~j~Xj*_B?H{`RxxgzVY+-FQuWo!U&YZI76Angr5lkU5Px{$`gls z4F1|+{cmhb;+_VJ8LxDep^48#HurEKme0#79bEM%d0LaUniyM9d_>gN{iBzLEwqNA zaYkat0lGM|K3>rdO0zYX`p{&fu?-omlK@IPs-%zqNr4PS07rB@CskqeztIy>V%;Nc zhLV4%|9HyIu3fDfjl?*ZP+#eiP%TPAUb+=V@_>Um(j@kXm7&oM8#nYu0*U<(%O?Ru z2;>%EYFiQJ@0FAkzrwT+3IF#EP24b(CYM5o1sTL*os8qv*31vTgcR3nbF1@I`nnihoxATYb4_BgnE z;3GcgNK@>)UXU0SQoB9plvp$`QY+E-56wlgroxnYFf+m8k1GX1mPo7`f@=WmKKby* z`Zh|#!2U3KCxly$e!P>vz5mh+)n-s-AHmrvOIzTVHoVK%WK&2vC{yGAu`ewjcKwsZ znLY0D_ZM*1LOuV`^{Xj)Vhe8S$NjORBY`vokj(L)VOMJBJiF+36uaxCVS-0xABhnG zjV*UK(g%KbN3;?LYKi4Lg7Ic8OR!!W-RJ)nM88630rN;EyB&!{0cMN$8$bm!Erni3?KG_dOyvE$$Yvb)9>a?4XkQ$C4}N5o(INuA7rAJF_d~t;zk)pf zz~8mzAv&7Vq~>Hu^(8-DDg(2iRuO#8aFTPue`a^j4y6j7Ua+qosQ0Ctq2AEAQg8(! z*NmB?s_YhCQbuGx-geIp+=WTi;Z@Vjhg~Pw+&t-L4vaS8K zIS_p%%2KVoC$k*}QAnb5)6&)Z4by{x|M>6`ig%A%>YDDz1G&P`+-b{|IMO23X3y^) zGeu|Kz5Lp@QT6Lkf=62|dGf|JvK5}1GJZ#NX?&jdAt+03F1Rs3#(~nu13Qy=FVe}N z5ncfg{4L|OW$QDoJPXz{4VjveWPz$GL9wI%)J$6v(iZPxuMt-lu*(8Fam7`Vp0Wie z%8Ot+6Cb@LFQU%OFw~3G1(D3@P_?I(0&fYWGn%i3jHixlA;uMokzK?ksHH1i+iA-q zyhTtu#|UBGax9h=pS$WoZSRh@0o}?XFsiNQtXiX`2rA+p$Hl$(w5)G}SL|emeypm< z0iJEdP{v9f1|TqZHbXi&&zr+KUL|LWF;1o z1m?ScfaHOC>LkacB5s`}73*c`cG0VK=-#w}Dc-Etk!Y+b_87wx1d_h=!M$Rcaz#Pe z2^(njxu}aP2FYVY1?T;{cot=nQe#Y8XaoZnLgeb@Lg%?&w<)S2nuE0O!q0=Z>P14) zCEf27^p;M10=e$_KhsDcN@#Dxh48yts4ec^{)cx}+c-GvVn))z(5Xq#`HVmuucH^r zy&_UWRO=#e>;RSVTlUfXBTFKcMNp{{x}UW1UWF0zuCE0llAZ%oWxpwS} zgUc{BY$>#`@V%^urtH@#f7N1ZIUq)QXt2MnQ}D=*G;m0+aYOr^%lp>Fqj~|Fu4Y0> z#ZH=6Mg6}N&bdOp;{IC6ee1rvTI^j@@T;UDZX!k6Uo+-$UzV@U@#{4Tr-(_U+K;w) zo0^OdU{sFI5qU_vxZ##-K@YzW3Q5d~fe711_w z6sLaw-#nSiNBiI@?QkR9NAYkE9asB$qAoNq8eg@0M<>r2Dt3~lJ?jyOm|`l zv+BJx%vSNYoWr-L1Y=Ys78gR<#>OmTsKi^h5xEvmdila|*6qH}wvxAy2JL+Q6gmGk zrVIZjd!05XnNnNFg_RgfwId^a>VuDm?@QelDvU+n&o0+3vLmO=rm`sG9uqoWlH9^b zeZ08<{;4yoK#pE!LI31gnW7*SxCF&FotFyUz|xUj+b#FIU?H&76nOiv(f`nh0+vLq zqP5Xevan%MJ^*F(UiYni?RPR98y~VE!&z&s(4!gUeB-StN;$w;Y$W?riL@qd@LB$M zQ4eQu+U4$SH)hG_v#V0qVlpeKFl=M`G;-EgBkXUJiQ zCb3SVy&_jtbdWI+qkpCn!24BV%)G8o_m2q$4`n5l?^yJ4e5#=cL%!_~c@Div(pzL3*u?ow zWD{a|IToiX)o>N1(QH_4^sH5q3ueeM~SE-EZ&Stegv<0JKENzc4lT~ zaL>nSzBMG*FYNc*rJ(a=lWVv>xSLhxCEX~B=i0(pxu)R?K8k;~B=I$GIn`@9)5q5` zTB>V+4+Fc3)97?b&=9Fs#fpUp@?YPzp6RG2!6ix`w`*(2*}$ z>stZo&=1ePomOeqvEj`O)6?Tjuldc)6E5?M$6Wps@&3QpYSKn*&h}T{ZTmZ~oDnbP z1-}`h4Wf#bx6>!9j7A4Oi-SVjHA6loE63Syqc&BY4z`AksJUdnc;p)LY*kHT1)1OA znw@-jezQKaXn1!~Eff|p(D*~(v%=Aaabr&hBtIFFkM{z_L}Eo?qs^6*A~x_R%d`+~ zw0`OLBkasW6W*%uwTua3JXPTeHM9XXC|kf!Eea-yxDS+4qfg(8Na)76b#9XW?LH9a z-sPnYT)74%l%f|u-U9EVRF$$Hyoslj{GhBQuBf1b4ayVAA_kvk%dnx=t}fH(sM%1h zYXQM3`=yN`snwe8ub|U`n~Bz^g6U+yp+Z95YS4>w&-ODuWLD~>g9m0`b5pQ5*Cy|kfg$le5#lpHeRpDC0&^U*$iFEbS?i#gdjv=h8F-N55IY?1cnZdGObW_R4R3$h#fJ@wag(te4__$Te8 z8E5z!_Ci|qg7GqY!mx3Rg*VViA#`I3;ltz$TkE*y${N;Y{#QV~UQX{Wgem_-2Ww(YE^-aIV! z`mgGwA$k6#wG_t{=gdRTgBlJ#`cT=BxxeEPQ(E=52v&IDx3{YBvIz~ZWnjx_@9gMF znUkIC&gkd_H=6M&uAmIW-4RgrTKxL;u(gL06rvimIg-ZoCm!%qjHwL?vx)OFx9RW**4qdv>U=)bmmW!$@Fp83K{(L#BW zgtNUBN12W8pb_o_56@3iGZ@oRZC~p4L)l z3**wz@lofc2fx1BKZQw^TzTA=EC{yT8Zp{w)_@OntsP z?!LPgiIpn6$V`WyW@y#56#Y_ZPQrgIt4Yv1-d1bu=<`d?dVp8k4^pfpI|E6Oi_xQta<XHC3DG0*95CNsP0 zR3O_+DRn7inMwnrO`Fxzd_E3c8ZSUBdN5AbRG*mmH7JCf`7pZqjG7vlR%IP|M`z6N zQ&42PJ5!qKRw^kvEV{8KQ}s{?#ZXDec=5ffRH%eI>O$ng-|47_u3bx9PxP?_u8iA( zI*N~E04o?{R@V(Wlu4%Vq=CuceV~clc{KlAXH-;AO$V9}JVXfNWw+gB9q8t8ob`A& zHuA5Rwwr?g71L6GbUApa(N=D3LU@l%KegKZ9?!lxDYw|9Pu@1+_%V7ffV16iAN@%V zSL;VI=lM4qZGcqr70!HKs=>ifYOU@@i%64UAfTF+)+EXJuX(DWBgdIjo`c59-@l*z zphHAJT>R=|Tp9M*0@5UKOcZ5UhSiCl3uSO))W{Li09=;HU6_es%xn~n3qTOWcsuit1@cKm`Hjr3VGNLFOO zc$#|mOAL6y0Jp)BflL#XAY=9>m#K+~2xK6r$8znswAHF49?A40QfHianp!CR&fdwX z&(j&M8-Mgquu$XKkdM1E=Z2L7Ft8hlA~P-dGvC1C^ZI_Zly#xlbYwxQ=VcVK4T*3{ zV9^@)tFEYb8aox#qEaJOp^A3P`%$lg|En-VqOJ(_Qdh|AG>m` zN^G=G5Y99r zyh4~f!1YoUwGXGxdzWyg#&{?$on4Wc5YTa!6Rd5ntAhNkCV6207qGLH;}*P&7k1IN zt=kj=${Nbk#zX#M=P!CsM1=_%D`uohD(%jOH9N!g2FT!+u|N=)^V;r&&>0tf{K5@N$FpdhY&?eCmTLSNESd zHzC9cF3J=ysO5Pk2XOjc(C{r=+4_@HQ_{Q?0Q5*5-2zfEqW^yMNlRP~Cv&yzH!a$d z3^XJ@l%v7iLXgH1t+u0W$k|U`xFG*(m`Tfi3I!riEMiMWry5m`U{U*Ob5g?N;Mpn~ zC6xzS2RJGJuV@gUTqc3Lr1U8e1_p*DkD*Thtom#@fCZeasi~=X`S~Um7vo(F|7&gr zu9X!!A<8waty$92?|%5aZEE5t9&nRnF8vL<)${NN^g}GM(`*d`A*R=1&m*N$ZkL)G zUS7uC1KQOu7_{qAT)~gB3#Wem1SXdZJirkw8~8z^yqTEL{Qf=yLH?}l%Y{L(@p_df_)F-B=wk7Kt)upgY5_z_(w!t4BV0TU)jTxJ6E z`f`bUuoty=bOan!%CPOQZNrk!_VS|m?XJ43;OWXm??WLbY}1PNy6QYbX`q%-8)lT9 zV_5GDtMh;J-l6~w>Leom8T(vzVv@X~FMYSs^4lvwPEP)rIPZ6Zz=U8#IQ^4ohjl^H zJPfWDZ)~6wA$tCYlWNu$0E~c+ac$q91x5I_>qo4`R#pi~Nt4UdvR2Xz2;}FWao3qz z^JJU(e`lvtQ&Vr@Z2!(r!Rn+eybwD;NJSwm!%JxKFpZj;CuSDnHUxp2W`l^|hcWBc zy>BDK+t>h2ET$B0_dBqh^=d~k4_;hYXth6KZfkF=qb8e8Wh6Ypg#HI7VcTTO&@Juk zOs_lg$P2clL?A)kuY92fU5ZNm<@$3b*(r&u!t>i*{k`#vxJ;8HE%mQl{&~%q8kR?b zN1!P=WD$Jw6ymef^`-(|cT>Wkp6_n|1-i)r?>|;b01&dO| za)3>1QC*$KdU;`C1Tdf7*Y1ur<&Ul9MN9n=>=b&In&kE-r%k#{j?q(1LLT zgr=q=FT9C(tUV8Vpl$6LABIU^NHa%U{Ajnsiz})xDu3rb_q*rITd)I2$>XZF{o3Ee z(d4!=c6j)Lnp)YQ)AuP%05l1J#qe5%+9x`?LC=`|as0`|#il zJIU^?Ppg)pJ{xIjYcQb3ly}+&Bfh-N4f++B!F2#&#G`(qMSB+)ixDO=Z~*52dt&Gr zC8d?O^+#p%L#YfO&SD+5qyCL#qIi}$_q%||K7uB(Q{rKrI0IfKb8`uZL9;7$lTDr5 zz4*5Q!W;o}sY)#n4XLJhfuXb9ls9mm$C_ly8BQIueOQXpm7?zM#52zSz0QVq?^SLT zAt}l%G%EF2e`5nMkNdM<_}Lk*k&)4%Xfj~<3R$tF-{HO#<{!L7jswLX5S{e$0&H3O z`a)x1DJt&)t+jYp+ZO|@_$T3N665vB~863exy`RPo z#=#&?)Mt+PccIsGB7WkkLjW0W4i#Je^eM78H2kL0Mcw1>5)fiETM-zc;0)*Y2^wJQ zk4oG$1M=j%NO{N0coJ~%UW)T86&gH=Ek_2z2r*A7ZU3E>WLz94p8uL_|FLqEr2v*h zFF6SG*Zm#dU2GA&w%*0=)3)#kZ(mHbG!!^`gX3O|zhU8?ttxEOJ$$ofeF58fz&F@> zk- zEwh=)T)H4bO+xOgDARDhwLK<67}XGS&glCQ+u<@EoJ1;m9)7htjVI7j1ak8|`7g3q zxxctWMdod%GsgL5I|moe;Pxq8$ZL~C|IXCO7|G%p(4BHj!WBfGX%hT0R)%Wml=XMR z&3dLlowXuHO^pkPA#-QHQ(5D_MJJNcJ%PaHu6Bx@mp(rzHsMkUh7-R5Zr!5eR!C_) zdg8><94>l7Ow>2jBECQ7=Z68E0Crf#aJDR!j8Ezks>VU=$eC&;VyvSdea43M)|iFv zF=Fk$z!Sr;)Asp9Ozf+}IU@B3s-r@O?SXJuSWuF-V$f2$3Jj`T;2&uh2HJ1^R+^#L zt9{;nKHQ?Be~e>pL(-I(zGrK&5GoQj&gqnD9m%q#LUV?}r!vf@M6ma52>rgb!w7fY z<5yo}!cJ%XmI+lhg)kp>2t3;eQ53~!xtg8p_N43v^WNL9}6 zAt50g2WDz;Xw-(FXoD9EoPN%GEo!bwRX9~rmya;EU*_)PcEDUy6r5FtL6g_CSc{Vf zD8_}Hi@jjrzf|S!t&Bl_~n4}V(v_Omu z!$;egt}e5ZNZ@#B6I5;1fHi)?N)mtb*DrZ;dU_OXJ3qOs>d(?8RiQ?V4EKZJ!MNBp z2fH4^8bs4F2Q9XY9olEFr{TIfHEeCJDh8T8zaa%>gvr-6(^ygTAPFd~t+ zIKO7%KV)o24fW;QVxy|6_Y3olCeoU)Oyz2W);CqPfkL)l|D~!p2{uJ-Uq$_+`PG&l z&+o=elUNUy0H9T;txSZ{?ko0iCWV|qSdH%Kg2nYMp16uAK{>F`)L`{CAnkH7R#3O3 z0IVa`tk1CZB$#~D>zb&5`~@M1BJuLkiFKR|H}Dbr?Rg2KPqz*BPIG297LhA($hL~^ z%~B9-8;yw!eZkFrvkwFYBx<*=KaD>0fK;_f*ZK)aplJ;k=41B-b*gmrYRpC-%zc3~ z0VGPQ1)*GN0{E4&yyYOlus$>(I6$?y)w=Cl7j_?Nb_;jX)QJL!l=fnCgYCYs6tw%t zZqoiD>^C+jUd*s(R1&13r$~Hl$o~$Px~RK5zpG39Y=80Hh9GO4lxW^Zg)J3EqKY^v z&P;}!Bl&Z1dc0v({F~d5Z5m4oqND27XUpm&*QYN3eNKJEch?C|{NnZHv*gwP7$P+y z1lF1xu1nKA7e&q5WtD`u&1Xf-9_S2QetHrs-dl3Y%a^w1wJ6r zU|qDIfsd8!8WJNzKL9F6fz$(7iRnz2O?TSNNq93yj}B*Qyg7}(?dev<3>1Oab?v&e z#p&xmF#%gnA^$@AC1d>~;N$05IT z=e=^C<8^a%b-JFV1tNWRCPLP0<56v>EhsJ2{!E9|uuTUyE0#zD>>E9$dGEGbpQ0zH zV4L*OG$aV2t#cG^v14qsnE8IhCIA?7fHF`)yM2mpo7@??13so^heeqv8kI&6SpdB+ zgPksChda@*%$u!2;;esyK<{k>2amd_wl@FBqgyo-?m$$D0ldc|0HCrz_q)Lmz%sX; zL0@erONIuAH$92=yL5C5;1YP0|9Bzd9v#pF*IKWiv`}1dAG*>duRue@4$*rawMB%bX^AsMUa+i^!Zw#1 zPZy7r3Hg4Sg%SHJ@6Y8wTEXBPJW$L+q4}T{y5TL6u=_9)dlg`xPHT{12R*BI-~`ot z8rZ)3Gxtr2_#QGqTMmoj?HwEnwJI%*b*0J_>9b@|kmDkm?FU_%M|GNj!Mfdje(}le zIEo77l!(8sMMr{qrAl4=Zf@s4p!Hx_?E*501F<2{si~`*U1q4nyb%&j-YHi3>^^Yg zw)vcEX-ddp3=LNS=J!Ye=7#Eu3Otr^x?>N|!`;@fmB|i0f@kXqE^rU!d%_;!tzyr~ zA5n%f9--}s1}pzHyde#!eS#h??=*CWWsY-?*-iFkJKTc~_Xh3IVfAS06eUUS0W=#p zTicgrZ`13zT)n$(c5IuOocr;0ZtmImpCv`M`JTOWb|C}Np1(#vf?vM|HA;`e9Vq;@ zfHvJ2T;>CiuG9Ub@>^7}WrYh}P+U$tGv`l6G27&e1SR?uiWr&Rb5Zq%vG`X2bKxlE zz=jGRKF@u$D%+FJ$G+U;!x*je6?19gETqCZMwt z9l5h8fL{A~RKmq9sp8CKZNxb0y)ooSHF&m`#Q&u`ev1_3=$Sk8aJ(Ov)gGGHw1)y7|hu z9;f+{qUzLroztafX?r_RV^?6L1ZQYkb+7nyEI^WfCl(Z(LP1$>z@d^W&H7kcphkzy z2izZvS<8H{T>+98e$Q8jj9!$aiA3Qapx>dj(9B`o)TL=*L4RQeQ(oX7YOjWUG_L$Z z6{_NldFTKu1#HpF!{(l<2WVoCTx~x( zXg_5{ScaA_78D0o%4cJ2pk$cW6b5lGNmJWDwHV^y1&7tSo-+uO({N-P7rdJ^ybP%( zNJ#UvevAwq+CLJGrw9vkD?HfL0aq*cZU?w#&RBhdNnv5j7SS@3#H3{+`mW!;8sOV- z@Xq{sm#(Fq#=)#KzhIA_VqoyYfbE+^LD|dHL`70(mAZlynL&S!JU>rM3J;NujzDpr zy`R^=&X*c4ea1S+z0_D`8zx%nOKL)-hvGKR2U*(OJ}!T{on3+5NYH~0o;SRZ^?^nz zefUpnG6`+4>A#lH_L45W8CLBl`j7zO#96OVJFXv--F3V2_ah(nYO1v}AP9VJ1_zQC zkfjWr)Sp}q3X@#{TZnXTok>i^*K6fsLP>|5 zzy$i+j_^R>$=q8B%%a%lLov?p*N=lA`>r)dj4=9qoM#Q?J0<32HS_XdCrVS!yptj_g68%2@4pm{P){|GcR+fZ+~g$yG6<>HZ~hP5Q*wv^ diff --git a/docs/macros.txt b/docs/macros.txt index efd9dd7..b32da5b 100644 --- a/docs/macros.txt +++ b/docs/macros.txt @@ -44,11 +44,11 @@ directory. - NUT_CHECK_OS Check for the exact system name and type. - This was only used in the past to determine the packaging rule to be used - through the OS_NAME variable, but may be useful for other purposes in the - future. + This was only used in the past to determine the packaging rule to be + used through the OS_NAME variable, but may be useful for other purposes + in the future. -- NUT_REPORT_FEATURE(FEATURE, VALUE, VARIABLE, DESCRIPTION) +- NUT_REPORT_FEATURE(FEATURE, VALUE, VARIABLE, DESCRIPTION) Schedule a line for the end-of-configuration feature summary. The FEATURE is a descriptive string such that the sentence "Checking @@ -62,7 +62,7 @@ directory. - NUT_REPORT(FEATURE, VALUE) Schedule a line for the end-of-configuration feature summary, without - printing anything to the terminal immediately. + printing anything to the terminal immediately. - NUT_PRINT_FEATURE_REPORT diff --git a/docs/man/Makefile.am b/docs/man/Makefile.am index e793657..0d693a3 100644 --- a/docs/man/Makefile.am +++ b/docs/man/Makefile.am @@ -4,13 +4,21 @@ # Notes: # - sources (.txt) and groff formats are both distributed, # - only sources are versioned ; groff files are generated at worst -# during 'make dist' +# during 'make dist' (while preparing a release tarball) # - HTML files are built upon request, if AsciiDoc is available, # - groff update will only happen if AsciiDoc is available too, # - all this can probably (and hopefully) be improved, but I've not # found a way to do pattern replacement on the fly for target deps! # FIXME: investigate an autogen.sh hook # - Ref: http://www.gnu.org/software/hello/manual/automake/Man-pages.html +# - WITH_MANS can be enabled if either we are building man-pages, or if +# the --with-doc=man=auto detected an inability to build the man-pages +# but enabled the DOC_INSTALL_DISTED_MANS toggle so we deliver disted +# files from source tree + +# Is "egrep == grep -E" always valid? (maybe all a job for configure.ac) +EGREP = egrep +#EGREP = grep -E # Base configuration and client manpages, always installed SRC_CONF_PAGES = \ @@ -21,6 +29,7 @@ SRC_CONF_PAGES = \ upsmon.conf.txt \ upssched.conf.txt +if WITH_MANS MAN_CONF_PAGES = \ nut.conf.5 \ ups.conf.5 \ @@ -28,6 +37,7 @@ MAN_CONF_PAGES = \ upsd.users.5 \ upsmon.conf.5 \ upssched.conf.5 +endif man5_MANS = $(MAN_CONF_PAGES) @@ -39,36 +49,50 @@ HTML_CONF_MANS = \ upsmon.conf.html \ upssched.conf.html +# NOTE: Currently SRC_DRIVERTOOL_PAGES are a separate list to generate +# a linkman-drivertool-names.txt file, but historically remain part of +# MAN/HTML_CLIENT_PAGES in the bigger picture. +SRC_DRIVERTOOL_PAGES = \ + nut-driver-enumerator.txt \ + upsdrvctl.txt \ + upsdrvsvcctl.txt + SRC_CLIENT_PAGES = \ + $(SRC_DRIVERTOOL_PAGES) \ nutupsdrv.txt \ upsc.txt \ upscmd.txt \ upsd.txt \ - upsdrvctl.txt \ upslog.txt \ upsmon.txt \ upsrw.txt \ upssched.txt +if WITH_MANS MAN_CLIENT_PAGES = \ nutupsdrv.8 \ + nut-driver-enumerator.8 \ upsc.8 \ upscmd.8 \ upsd.8 \ upsdrvctl.8 \ + upsdrvsvcctl.8 \ upslog.8 \ upsmon.8 \ upsrw.8 \ upssched.8 +endif man8_MANS = $(MAN_CLIENT_PAGES) HTML_CLIENT_MANS = \ nutupsdrv.html \ + nut-driver-enumerator.html \ upsc.html \ upscmd.html \ upsd.html \ upsdrvctl.html \ + upsdrvsvcctl.html \ upslog.html \ upsmon.html \ upsrw.html \ @@ -76,7 +100,9 @@ HTML_CLIENT_MANS = \ SRC_TOOL_PAGES = nut-scanner.txt nut-recorder.txt +if WITH_MANS MAN_TOOL_PAGES = nut-scanner.8 nut-recorder.8 +endif man8_MANS += $(MAN_TOOL_PAGES) @@ -91,6 +117,7 @@ SRC_CGI_PAGES = \ upsstats.cgi.txt \ upsimage.cgi.txt +if WITH_MANS MAN5_CGI_PAGES = \ hosts.conf.5 \ upsset.conf.5 \ @@ -100,11 +127,11 @@ MAN8_CGI_PAGES = \ upsset.cgi.8 \ upsstats.cgi.8 \ upsimage.cgi.8 +endif if WITH_CGI - man5_MANS += $(MAN5_CGI_PAGES) - - man8_MANS += $(MAN8_CGI_PAGES) +man5_MANS += $(MAN5_CGI_PAGES) +man8_MANS += $(MAN8_CGI_PAGES) endif HTML_CGI_MANS = \ @@ -145,7 +172,7 @@ SRC_DEV_PAGES = \ nutscan.txt \ nutscan_scan_snmp.txt \ nutscan_scan_usb.txt \ - nutscan_scan_xml_http.txt \ + nutscan_scan_xml_http_range.txt \ nutscan_scan_nut.txt \ nutscan_scan_avahi.txt \ nutscan_scan_ipmi.txt \ @@ -162,7 +189,66 @@ SRC_DEV_PAGES = \ libupsclient-config.txt \ skel.txt +if WITH_MANS # NOTE: nutclient_*.3 has no source counterpart (libnutclient_*.txt) + +LIBNUTCLIENT_MISC_DEPS= \ + nutclient_authenticate.3 \ + nutclient_logout.3 \ + nutclient_device_login.3 \ + nutclient_get_device_num_logins.3 \ + nutclient_device_master.3 \ + nutclient_device_forced_shutdown.3 + +$(LIBNUTCLIENT_MISC_DEPS): libnutclient_misc.3 + touch $@ + +LIBNUTCLIENT_TCP_DEPS= \ + nutclient_tcp_create_client.3 \ + nutclient_tcp_disconnect.3 \ + nutclient_tcp_get_timeout.3 \ + nutclient_tcp_is_connected.3 \ + nutclient_tcp_reconnect.3 \ + nutclient_tcp_set_timeout.3 + +$(LIBNUTCLIENT_TCP_DEPS): libnutclient_tcp.3 + touch $@ + +LIBNUTCLIENT_GENERAL_DEPS= \ + nutclient_destroy.3 + +$(LIBNUTCLIENT_GENERAL_DEPS): libnutclient_general.3 + touch $@ + +LIBNUTCLIENT_VARIABLES_DEPS= \ + nutclient_get_device_rw_variables.3 \ + nutclient_get_device_variable_description.3 \ + nutclient_get_device_variables.3 \ + nutclient_get_device_variable_values.3 \ + nutclient_has_device_variable.3 \ + nutclient_set_device_variable_value.3 \ + nutclient_set_device_variable_values.3 + +$(LIBNUTCLIENT_VARIABLES_DEPS): libnutclient_variables.3 + touch $@ + +LIBNUTCLIENT_COMMANDS_DEPS= \ + nutclient_execute_device_command.3 \ + nutclient_get_device_command_description.3 \ + nutclient_get_device_commands.3 \ + nutclient_has_device_command.3 + +$(LIBNUTCLIENT_COMMANDS_DEPS): libnutclient_commands.3 + touch $@ + +LIBNUTCLIENT_DEVICES_DEPS= \ + nutclient_get_device_description.3 \ + nutclient_get_devices.3 \ + nutclient_has_device.3 + +$(LIBNUTCLIENT_DEVICES_DEPS): libnutclient_devices.3 + touch $@ + MAN3_DEV_PAGES = \ upsclient.3 \ upscli_add_host_cert.3 \ @@ -175,7 +261,9 @@ MAN3_DEV_PAGES = \ upscli_list_next.3 \ upscli_list_start.3 \ upscli_readline.3 \ + upscli_readline_timeout.3 \ upscli_sendline.3 \ + upscli_sendline_timeout.3 \ upscli_splitaddr.3 \ upscli_splitname.3 \ upscli_ssl.3 \ @@ -183,42 +271,21 @@ MAN3_DEV_PAGES = \ upscli_upserror.3 \ libnutclient.3 \ libnutclient_commands.3 \ + $(LIBNUTCLIENT_COMMANDS_DEPS) \ libnutclient_devices.3 \ + $(LIBNUTCLIENT_DEVICES_DEPS) \ libnutclient_general.3 \ + $(LIBNUTCLIENT_GENERAL_DEPS) \ libnutclient_misc.3 \ + $(LIBNUTCLIENT_MISC_DEPS) \ libnutclient_tcp.3 \ + $(LIBNUTCLIENT_TCP_DEPS) \ libnutclient_variables.3 \ - nutclient_authenticate.3 \ - nutclient_destroy.3 \ - nutclient_device_forced_shutdown.3 \ - nutclient_device_login.3 \ - nutclient_device_master.3 \ - nutclient_execute_device_command.3 \ - nutclient_get_device_command_description.3 \ - nutclient_get_device_commands.3 \ - nutclient_get_device_description.3 \ - nutclient_get_device_num_logins.3 \ - nutclient_get_device_rw_variables.3 \ - nutclient_get_devices.3 \ - nutclient_get_device_variable_description.3 \ - nutclient_get_device_variables.3 \ - nutclient_get_device_variable_values.3 \ - nutclient_has_device.3 \ - nutclient_has_device_command.3 \ - nutclient_has_device_variable.3 \ - nutclient_logout.3 \ - nutclient_set_device_variable_value.3 \ - nutclient_set_device_variable_values.3 \ - nutclient_tcp_create_client.3 \ - nutclient_tcp_disconnect.3 \ - nutclient_tcp_get_timeout.3 \ - nutclient_tcp_is_connected.3 \ - nutclient_tcp_reconnect.3 \ - nutclient_tcp_set_timeout.3 \ + $(LIBNUTCLIENT_VARIABLES_DEPS) \ nutscan.3 \ nutscan_scan_snmp.3 \ nutscan_scan_usb.3 \ - nutscan_scan_xml_http.3 \ + nutscan_scan_xml_http_range.3 \ nutscan_scan_nut.3 \ nutscan_scan_avahi.3 \ nutscan_scan_ipmi.3 \ @@ -233,14 +300,21 @@ MAN3_DEV_PAGES = \ nutscan_get_serial_ports_list.3 \ nutscan_init.3 +upscli_readline_timeout.3: upscli_readline.3 + touch $@ + +upscli_sendline_timeout.3: upscli_sendline.3 + touch $@ + MAN1_DEV_PAGES = \ libupsclient-config.1 +endif if WITH_DEV - man3_MANS = $(MAN3_DEV_PAGES) +man3_MANS = $(MAN3_DEV_PAGES) if !WITH_PKG_CONFIG - man1_MANS = $(MAN1_DEV_PAGES) +man1_MANS = $(MAN1_DEV_PAGES) endif # WITH_DEV endif @@ -273,7 +347,7 @@ HTML_DEV_MANS = \ nutscan.html \ nutscan_scan_snmp.html \ nutscan_scan_usb.html \ - nutscan_scan_xml_http.html \ + nutscan_scan_xml_http_range.html \ nutscan_scan_nut.html \ nutscan_scan_avahi.html \ nutscan_scan_ipmi.html \ @@ -295,7 +369,7 @@ HTML_DEV_MANS = \ # (--with-drivers=...) if SOME_DRIVERS - man8_MANS += $(DRIVER_MAN_LIST) +man8_MANS += $(DRIVER_MAN_LIST) else @@ -329,7 +403,8 @@ SRC_SERIAL_PAGES = \ mge-utalk.txt \ oneac.txt \ microdowell.txt \ - nutdrv_qx.txt \ + microsol-apc.txt \ + nutdrv_siemens_sitop.txt \ optiups.txt \ powercom.txt \ powerpanel.txt \ @@ -343,6 +418,7 @@ SRC_SERIAL_PAGES = \ victronups.txt \ apcupsd-ups.txt +if WITH_MANS MAN_SERIAL_PAGES = \ al175.8 \ apcsmart.8 \ @@ -369,9 +445,10 @@ MAN_SERIAL_PAGES = \ metasys.8 \ mge-shut.8 \ mge-utalk.8 \ - nutdrv_qx.8 \ oneac.8 \ microdowell.8 \ + microsol-apc.8 \ + nutdrv_siemens_sitop.8 \ optiups.8 \ powercom.8 \ powerpanel.8 \ @@ -384,9 +461,10 @@ MAN_SERIAL_PAGES = \ upscode2.8 \ victronups.8 \ apcupsd-ups.8 +endif if WITH_SERIAL - man8_MANS += $(MAN_SERIAL_PAGES) +man8_MANS += $(MAN_SERIAL_PAGES) endif HTML_SERIAL_MANS = \ @@ -415,9 +493,10 @@ HTML_SERIAL_MANS = \ metasys.html \ mge-shut.html \ mge-utalk.html \ - nutdrv_qx.html \ oneac.html \ microdowell.html \ + microsol-apc.html \ + nutdrv_siemens_sitop.html \ optiups.html \ powercom.html \ powerpanel.html \ @@ -433,10 +512,12 @@ HTML_SERIAL_MANS = \ # (--with-snmp) SRC_SNMP_PAGES = snmp-ups.txt +if WITH_MANS MAN_SNMP_PAGES = snmp-ups.8 +endif if WITH_SNMP - man8_MANS += $(MAN_SNMP_PAGES) +man8_MANS += $(MAN_SNMP_PAGES) endif HTML_SNMP_MANS = snmp-ups.html @@ -447,88 +528,142 @@ SRC_USB_LIBUSB_PAGES = \ blazer-common.txt \ blazer_usb.txt \ nutdrv_atcl_usb.txt \ - nutdrv_qx.txt \ richcomm_usb.txt \ riello_usb.txt \ tripplite_usb.txt \ usbhid-ups.txt +if WITH_MANS MAN_USB_LIBUSB_PAGES = \ bcmxcp_usb.8 \ blazer_usb.8 \ nutdrv_atcl_usb.8 \ - nutdrv_qx.8 \ richcomm_usb.8 \ riello_usb.8 \ tripplite_usb.8 \ usbhid-ups.8 +endif if WITH_USB - man8_MANS += $(MAN_USB_LIBUSB_PAGES) +man8_MANS += $(MAN_USB_LIBUSB_PAGES) endif HTML_USB_LIBUSB_MANS = \ bcmxcp_usb.html \ blazer_usb.html \ - nutdrv_qx.html \ nutdrv_atcl_usb.html \ richcomm_usb.html \ riello_usb.html \ tripplite_usb.html \ usbhid-ups.html +# (--with-serial / --with-usb) +SRC_SERIAL_USB_PAGES = \ + nutdrv_qx.txt + +if WITH_MANS +MAN_SERIAL_USB_PAGES = \ + nutdrv_qx.8 +endif + +if WITH_SERIAL +man8_MANS += $(MAN_SERIAL_USB_PAGES) +else +if WITH_USB +man8_MANS += $(MAN_SERIAL_USB_PAGES) +endif +endif + +HTML_SERIAL_USB_MANS = \ + nutdrv_qx.html + # (--with-neon) SRC_NETXML_PAGES = netxml-ups.txt +if WITH_MANS MAN_NETXML_PAGES = netxml-ups.8 +endif if WITH_NEON - man8_MANS += $(MAN_NETXML_PAGES) +man8_MANS += $(MAN_NETXML_PAGES) endif HTML_NETXML_MANS = netxml-ups.html # (--with-powerman) SRC_POWERMAN_PAGES = powerman-pdu.txt +if WITH_MANS MAN_POWERMAN_PAGES = powerman-pdu.8 +endif if WITH_LIBPOWERMAN - man8_MANS += $(MAN_POWERMAN_PAGES) +man8_MANS += $(MAN_POWERMAN_PAGES) endif HTML_POWERMAN_MANS = powerman-pdu.html # (--with-ipmi) SRC_IPMIPSU_PAGES = nut-ipmipsu.txt +if WITH_MANS MAN_IPMIPSU_PAGES = nut-ipmipsu.8 +endif if WITH_IPMI - man8_MANS += $(MAN_IPMIPSU_PAGES) +man8_MANS += $(MAN_IPMIPSU_PAGES) endif HTML_IPMIPSU_MANS = nut-ipmipsu.html SRC_MACOSX_PAGES = macosx-ups.txt +if WITH_MANS MAN_MACOSX_PAGES = macosx-ups.8 +endif if WITH_MACOSX - man8_MANS += $(MAN_MACOSX_PAGES) +man8_MANS += $(MAN_MACOSX_PAGES) endif HTML_MACOSX_MANS = macosx-ups.html -SRC_LINUX_I2C_PAGES = asem.txt -MAN_LINUX_I2C_PAGES = asem.8 - -if WITH_LINUX_I2C - man8_MANS += $(LINUX_I2C_PAGES) +SRC_MODBUS_PAGES = phoenixcontact_modbus.txt \ + generic_modbus.txt \ + huawei-ups2000.txt \ + socomec_jbus.txt \ + adelsystem_cbi.txt +if WITH_MANS +MAN_MODBUS_PAGES = phoenixcontact_modbus.8 \ + generic_modbus.8 \ + huawei-ups2000.8 \ + socomec_jbus.8 \ + adelsystem_cbi.8 endif -HTML_LINUX_I2C_MANS = asem.html +if WITH_MODBUS +man8_MANS += $(MAN_MODBUS_PAGES) +endif + +HTML_MODBUS_MANS = phoenixcontact_modbus.html \ + generic_modbus.html \ + huawei-ups2000.html \ + socomec_jbus.html \ + adelsystem_cbi.html + +SRC_LINUX_I2C_PAGES = asem.txt pijuice.txt +if WITH_MANS +MAN_LINUX_I2C_PAGES = asem.8 pijuice.8 +endif + +if WITH_LINUX_I2C +man8_MANS += $(MAN_LINUX_I2C_PAGES) +endif + +HTML_LINUX_I2C_MANS = asem.html pijuice.html # SOME_DRIVERS endif -MAN_MANS = \ +MAN_MANS = +if WITH_MANS +MAN_MANS += \ $(MAN_CONF_PAGES) \ $(MAN_CLIENT_PAGES) \ $(MAN_TOOL_PAGES) \ @@ -539,31 +674,60 @@ MAN_MANS = \ $(MAN_SERIAL_PAGES) \ $(MAN_SNMP_PAGES) \ $(MAN_USB_LIBUSB_PAGES) \ + $(MAN_SERIAL_USB_PAGES) \ $(MAN_NETXML_PAGES) \ $(MAN_POWERMAN_PAGES) \ $(MAN_IPMIPSU_PAGES) \ $(MAN_MACOSX_PAGES) \ + $(MAN_MODBUS_PAGES) \ $(MAN_LINUX_I2C_PAGES) +endif + +SRC_DRIVERS_PAGES = \ + $(SRC_SERIAL_PAGES) \ + $(SRC_SNMP_PAGES) \ + $(SRC_USB_LIBUSB_PAGES) \ + $(SRC_SERIAL_USB_PAGES) \ + $(SRC_NETXML_PAGES) \ + $(SRC_POWERMAN_PAGES) \ + $(SRC_IPMIPSU_PAGES) \ + $(SRC_MACOSX_PAGES) \ + $(SRC_MODBUS_PAGES) \ + $(SRC_LINUX_I2C_PAGES) # distribute everything, even those not installed by default # Note that 'dist' target requires AsciiDoc! -EXTRA_DIST = \ +SRC_ALL_PAGES = \ $(SRC_CONF_PAGES) \ $(SRC_CLIENT_PAGES) \ $(SRC_TOOL_PAGES) \ $(SRC_CGI_PAGES) \ $(SRC_DEV_PAGES) \ - $(SRC_SERIAL_PAGES) \ - $(SRC_SNMP_PAGES) \ - $(SRC_USB_LIBUSB_PAGES) \ - $(SRC_NETXML_PAGES) \ - $(SRC_POWERMAN_PAGES) \ - $(SRC_IPMIPSU_PAGES) \ - $(SRC_MACOSX_PAGES) \ - $(SRC_LINUX_I2C_PAGES) \ + $(SRC_DRIVERS_PAGES) + +EXTRA_DIST = \ + $(SRC_ALL_PAGES) \ $(MAN_MANS) \ asciidoc.conf +if ! WITH_MANS +if ! SKIP_MANS +# Cause "make dist" to fail, unless caller (like the stack of distcheck-dmf) +# runs ./configure --with-doc=skip (or --with-doc=man=skip specifically) +EXTRA_DIST += dist +dist: + @echo "ERROR: Manpage building was disabled by configure script, and these pages are required for our proper 'make dist'" >&2 ; false +endif +endif + +# For builds done from dist'ed sources, there may be a conflict of timestamps +# between original *.txt files and pre-built manpages etc. leading to skipping +# of manpage re-generation even if that activity is possible and requested. +# Possibly a cleaner, but less portable, solution would be to touch the +# generated files to long ago. Current solution assumes good valid clocks :) +dist-hook: + @echo "Fix up manpage source timestamps" && cd $(distdir) && touch $(SRC_ALL_PAGES) + HTML_MANS = \ $(HTML_CONF_MANS) \ $(HTML_CLIENT_MANS) \ @@ -573,53 +737,244 @@ HTML_MANS = \ $(HTML_SERIAL_MANS) \ $(HTML_SNMP_MANS) \ $(HTML_USB_LIBUSB_MANS) \ + $(HTML_SERIAL_USB_MANS) \ $(HTML_NETXML_MANS) \ $(HTML_POWERMAN_MANS) \ $(HTML_IPMIPSU_MANS) \ $(HTML_MACOSX_MANS) \ + $(HTML_MODBUS_MANS) \ $(HTML_LINUX_I2C_MANS) +# Note: target documents, except nutupsdrv.txt itself, start the +# list of drivers with `- linkman:nutupsdrv[8]` entry +# To regenerate these files, do `make distclean` first +LINKMAN_INCLUDE_GENERATED = linkman-driver-names.txt linkman-drivertool-names.txt +LINKMAN_INCLUDE_CONSUMERS = index.txt upsd.txt nutupsdrv.txt + +linkman-driver-names.txt: + @if test x"$(srcdir)" != x"$(builddir)" ; then \ + if ! test -s "$(builddir)/$@" && test -s "$(srcdir)/$(@F)" ; then \ + ln -fs "$(srcdir)/$(@F)" "$(builddir)/" ; \ + fi ; \ + fi + @if test -s "$@" ; then exit 0 ; fi ; \ + (LC_ALL=C; LANG=C; export LC_ALL LANG; \ + for F in $(SRC_DRIVERS_PAGES) ; do echo "$$F" ; done \ + | grep -vE '^nutupsdrv\.txt$$' \ + | sort -n | uniq \ + | sed 's,^\(.*\)\.txt$$,- linkman:\1[8],' ; \ + ) > "$@" + +linkman-drivertool-names.txt: + @if test x"$(srcdir)" != x"$(builddir)" ; then \ + if ! test -s "$(builddir)/$@" && test -s "$(srcdir)/$(@F)" ; then \ + ln -fs "$(srcdir)/$(@F)" "$(builddir)/" ; \ + fi ; \ + fi + @if test -s "$@" ; then exit 0 ; fi ; \ + (LC_ALL=C; LANG=C; export LC_ALL LANG; \ + for F in $(SRC_DRIVERTOOL_PAGES) ; do echo "$$F" ; done \ + | sort -n | uniq \ + | sed 's,^\(.*\)\.txt$$,- linkman:\1[8],' ; \ + ) > "$@" + +# Dependencies are about particular filenames, since over time +# we might have several use-cases for LINKMAN_INCLUDE_GENERATED: +$(LINKMAN_INCLUDE_CONSUMERS): linkman-driver-names.txt linkman-drivertool-names.txt + +# These files are generated when we build from git source so not tracked in +# git, and not part of tarball (to be in builddir) - so not in EXTRA_DIST. +DISTCLEANFILES = $(LINKMAN_INCLUDE_GENERATED) + all: -html-man: $(HTML_MANS) index.html +all-html html-man: $(HTML_MANS) index.html -CLEANFILES = *.xml *.html +# Have a way to build all man pages, not just those that fit currently +# configured drivers, daemons, developer aspect, etc. +all-man man-man: $(MAN_MANS) + +if WITH_MANS +if ! SKIP_MANS +check-local: check-man +else +check-local: check-man-txt check-man-pages + @echo "Man-page generation was SKIPPED per user request, so pregenerated pages were sanity-checked (if any)" >&2 +endif +else +check-local: check-man-txt check-man-pages + @echo "Man-page generation was not done, so pregenerated pages were sanity-checked (if any)" >&2 +endif + +check-man: check-man-txt check-man-pages check-html-man + +# the "for" loops might better use $^ but it might be not portable +check-man-html: check-html-man + +check-html-man: $(HTML_MANS) + @FAILED=""; CHECKED=0; LANG=C; LC_ALL=C; export LANG; export LC_ALL; \ + for F in $(HTML_MANS) ; do \ + CHECKED="`expr $$CHECKED + 1`"; \ + test -s "$$F" && { file "$$F" | $(EGREP) -i '(XML|HTML.*document)' > /dev/null ; } || FAILED="$$FAILED $$F" ; \ + done; if test -n "$$FAILED" ; then \ + echo "FAILED HTML-man sanity check for:$$FAILED" >&2 ; file $$FAILED >&2 ; exit 1; \ + fi; echo "PASSED HTML-man sanity check (checked $$CHECKED files)"; exit 0 + +# Note: many man-pages here have code samples and are mis-identified as C code +check-man-page: check-man-pages + +# Man-pages may be pre-generated (srcdir), or re-built (builddir) +check-man-pages: $(MAN_MANS) + @FAILED=""; CHECKED=0; LANG=C; LC_ALL=C; export LANG; export LC_ALL; \ + for F in $(MAN_MANS) ; do \ + CHECKED="`expr $$CHECKED + 1`"; \ + ( test -s "$(abs_srcdir)/$$F" && { file "$(abs_srcdir)/$$F" | $(EGREP) -i '(roff.* input|C source|ASCII text)' > /dev/null ; } ) || \ + ( test -s "$(abs_builddir)/$$F" && { file "$(abs_builddir)/$$F" | $(EGREP) -i '(roff.* input|C source|ASCII text)' > /dev/null ; } ) || \ + FAILED="$$FAILED $$F" ; \ + done; if test -n "$$FAILED" ; then \ + echo "FAILED man-page sanity check for:$$FAILED" >&2 ; \ + ( echo "SRCDIR:"; cd "$(abs_srcdir)/" && file $$FAILED ; \ + echo "BUILDDIR:"; cd "$(abs_builddir)/" && file $$FAILED ; \ + ) >&2 ; exit 1; \ + fi; echo "PASSED man-page sanity check (checked $$CHECKED files)"; exit 0 + +check-man-source: check-man-txt + +# Note: (GNU) make can helpfully add VPATH to the short source filenames +# which we had listed above, so the "case" below handles two possibilities +check-man-txt: $(SRC_ALL_PAGES) + @FAILED=""; CHECKED=0; LANG=C; LC_ALL=C; export LANG; export LC_ALL; \ + ( cd $(abs_srcdir) ) || exit; \ + for F in $(SRC_ALL_PAGES) ; do \ + CHECKED="`expr $$CHECKED + 1`"; \ + case "$$F" in \ + */*) ;; \ + *) F="$(abs_srcdir)/$$F" ;; \ + esac ; \ + test -s "$$F" && { file "$$F" | $(EGREP) -i '(ASCII|UTF-8|Unicode|ISO-8859|English).* text' > /dev/null ; } || FAILED="$$FAILED $$F" ; \ + done; if test -n "$$FAILED" ; then \ + echo "FAILED man-source sanity check for:$$FAILED" >&2 ; file $$FAILED >&2 ; exit 1; \ + fi; echo "PASSED man-source sanity check (checked $$CHECKED files)"; exit 0 + +CLEANFILES = *-spellchecked SUFFIXES = .txt .html .1 .3 .5 .8 +# For builds with allowed installation of prebuild man pages, check that +# they exist in sources (make would pull them automatically as a fallback +# from failed lookup in build products). For builds that require rebuild +# of man pages, abort with error if build product is missing. +if DOC_INSTALL_DISTED_MANS +SRC_PREBUILT_CLAUSE=|| [ -r "$(srcdir)/`basename $@`" ] +else +SRC_PREBUILT_CLAUSE= +endif + if HAVE_ASCIIDOC +CLEANFILES += *.1 *.3 *.5 *.8 *.xml *.html *.pdf + +# Working around a2x not friendly to parallelized runs. +# See more details in the main NUT docs/Makefile.am +DOCBUILD_BEGIN = { \ + if test -n "$${A2X_OUTDIR}" && test "$${A2X_OUTDIR}" != '.' ; then \ + rm -rf "./$${A2X_OUTDIR}" || true ; \ + test -d "$@" && rm -rf "$@" || true ; \ + mkdir -p "./$${A2X_OUTDIR}" || exit ; \ + for F in $(LINKMAN_INCLUDE_GENERATED) ; do \ + if [ -s "./$$F" ] ; then ln -f -s "../../$$F" "./$${A2X_OUTDIR}/" ; else \ + if [ -s "$(abs_srcdir)/$$F" ] ; then ln -f -s "$(abs_srcdir)/$$F" "./$${A2X_OUTDIR}/" ; fi ; fi ; \ + done ; \ + else A2X_OUTDIR='.' ; fi; \ + if test -s "${builddir}/docbook-xsl.css" \ + && test -r "${builddir}/docbook-xsl.css" \ + && ! test -w "${builddir}/docbook-xsl.css" \ + ; then chmod u+w "${builddir}/docbook-xsl.css" ; fi ; \ + chmod -R u+w "./$${A2X_OUTDIR}" || true ; \ + if test x"$(srcdir)" != x"$(builddir)" ; then \ + if ! test -s "$(builddir)/$<" && test -s "$(srcdir)/`basename $<`" ; then \ + ln -fs "$(srcdir)/`basename $<`" "$(builddir)/" ; \ + fi ; \ + fi ; \ + A2X_VERBOSE="$(ASCIIDOC_VERBOSE)"; if [ "$(V)" = 1 ]; then A2X_VERBOSE="--verbose"; fi; \ +} + +# Note that documents with sub-pages (see LIBNUTCLIENT_*_DEPS above) +# may generate multiple files in one go... so we move "*" and hope +# for no required hidden files (or would have to `find` them all). +DOCBUILD_END = { \ + if test -n "$${A2X_OUTDIR}" && test "$${A2X_OUTDIR}" != '.' ; then \ + chmod -R u+w "./$${A2X_OUTDIR}" || true ; \ + test -d "$@" && rm -rf "$@" || true ; \ + for F in $(LINKMAN_INCLUDE_GENERATED) ; do \ + rm -f "./$${A2X_OUTDIR}/$$F" || true ; \ + done ; \ + mv -f "./$${A2X_OUTDIR}/$(@F)" ./ || exit ; \ + mv -f "./$${A2X_OUTDIR}/"*.* ./ 2>/dev/null || true ; \ + rm -rf "./$${A2X_OUTDIR}" ; \ + fi ; \ +} + +### Regarding absolute paths in attributes below: by default asciidoc +### resolves include paths relative to the main document, so while we +### see the relative builddir as "." in the makefile, for included +### data it would mean the source directory where the .txt resides. .txt.html: - $(ASCIIDOC) --backend=xhtml11 \ - --attribute localdate=`TZ=UTC date +%Y-%m-%d` \ - --attribute localtime=`TZ=UTC date +%H:%M:%S` \ + @A2X_OUTDIR="tmp/man-html.$(@F).$$$$" ; \ + echo " DOC-MAN-HTML Generating $@"; \ + $(DOCBUILD_BEGIN) ; RES=0; \ + $(ASCIIDOC) --backend=xhtml11 $${A2X_VERBOSE} \ + --attribute localdate="`TZ=UTC date +%Y-%m-%d`" \ + --attribute localtime="`TZ=UTC date +%H:%M:%S`" \ --attribute nutversion="@PACKAGE_VERSION@" \ - -o $@ $< + --attribute srcdir="$(abs_srcdir)" \ + --attribute builddir="$(abs_builddir)" \ + -o "$${A2X_OUTDIR}/$(@F)" $< || RES=$$? ; \ + $(DOCBUILD_END) ; exit $$RES ### Prior to Asciidoc ~8.6.8, the --destination-dir flag didn't seem to affect the location of the intermediate .xml file. -A2X_MANPAGE_OPTS = --doctype manpage --format manpage \ - --xsltproc-opts "--nonet" \ +### This parameter is currently required; see docs/Makefile.am for more detail. +A2X_MANPAGE_OPTS = --doctype manpage --format manpage $${A2X_VERBOSE} \ + --xsltproc-opts="--nonet" \ --attribute mansource="Network UPS Tools" \ --attribute manversion="@PACKAGE_VERSION@" \ --attribute manmanual="NUT Manual" \ - --destination-dir=. + --attribute srcdir="$(abs_srcdir)" \ + --attribute builddir="$(abs_builddir)" \ + --destination-dir="$${A2X_OUTDIR}" .txt.1: - $(A2X) $(A2X_MANPAGE_OPTS) $< + @A2X_OUTDIR="tmp/man1.$(@F).$$$$" ; \ + echo " DOC-MAN Generating $@"; \ + $(DOCBUILD_BEGIN) ; RES=0; \ + $(A2X) $(A2X_MANPAGE_OPTS) $< || RES=$$? ; \ + $(DOCBUILD_END) ; exit $$RES .txt.3: - $(A2X) $(A2X_MANPAGE_OPTS) $< + @A2X_OUTDIR="tmp/man3.$(@F).$$$$" ; \ + echo " DOC-MAN Generating $@"; \ + $(DOCBUILD_BEGIN) ; RES=0; \ + $(A2X) $(A2X_MANPAGE_OPTS) $< || RES=$$? ; \ + $(DOCBUILD_END) ; exit $$RES .txt.5: - $(A2X) $(A2X_MANPAGE_OPTS) $< + @A2X_OUTDIR="tmp/man5.$(@F).$$$$" ; \ + echo " DOC-MAN Generating $@"; \ + $(DOCBUILD_BEGIN) ; RES=0; \ + $(A2X) $(A2X_MANPAGE_OPTS) $< || RES=$$? ; \ + $(DOCBUILD_END) ; exit $$RES .txt.8: - $(A2X) $(A2X_MANPAGE_OPTS) $< + @A2X_OUTDIR="tmp/man8.$(@F).$$$$" ; \ + echo " DOC-MAN Generating $@"; \ + $(DOCBUILD_BEGIN) ; RES=0; \ + $(A2X) $(A2X_MANPAGE_OPTS) $< || RES=$$? ; \ + $(DOCBUILD_END) ; exit $$RES else !HAVE_ASCIIDOC .txt.html: - @if [ -r "$@" ]; then \ + @if [ -r "$@" ] $(SRC_PREBUILT_CLAUSE); then \ echo "Not (re)building $@ manual page, since 'asciidoc', 'xmllint' or 'xsltproc' were not found." ; \ else \ echo "Could not find prebuilt $@ manual page." ; \ @@ -628,7 +983,7 @@ else !HAVE_ASCIIDOC fi .txt.1: - @if [ -r "$@" ]; then \ + @if [ -r "$@" ] $(SRC_PREBUILT_CLAUSE); then \ echo "Not (re)building $@ manual page, since 'asciidoc', 'xmllint' or 'xsltproc' were not found." ; \ else \ echo "Could not find prebuilt $@ manual page." ; \ @@ -637,7 +992,7 @@ else !HAVE_ASCIIDOC fi .txt.3: - @if [ -r "$@" ]; then \ + @if [ -r "$@" ] $(SRC_PREBUILT_CLAUSE); then \ echo "Not (re)building $@ manual page, since 'asciidoc', 'xmllint' or 'xsltproc' were not found." ; \ else \ echo "Could not find prebuilt $@ manual page." ; \ @@ -646,7 +1001,7 @@ else !HAVE_ASCIIDOC fi .txt.5: - @if [ -r "$@" ]; then \ + @if [ -r "$@" ] $(SRC_PREBUILT_CLAUSE); then \ echo "Not (re)building $@ manual page, since 'asciidoc', 'xmllint' or 'xsltproc' were not found." ; \ else \ echo "Could not find prebuilt $@ manual page." ; \ @@ -655,7 +1010,7 @@ else !HAVE_ASCIIDOC fi .txt.8: - @if [ -r "$@" ]; then \ + @if [ -r "$@" ] $(SRC_PREBUILT_CLAUSE); then \ echo "Not (re)building $@ manual page, since 'asciidoc', 'xmllint' or 'xsltproc' were not found." ; \ else \ echo "Could not find prebuilt $@ manual page." ; \ @@ -664,3 +1019,21 @@ else !HAVE_ASCIIDOC fi endif !HAVE_ASCIIDOC + +# NOTE: Due to portability, we do not use a GNU percent-wildcard extension: +#%-spellchecked: % Makefile.am $(top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) +# $(MAKE) -s -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC_ONE="$<" SPELLCHECK_DIR="$(srcdir)" $@ + +# NOTE: Portable suffix rules do not allow prerequisites, so we shim them here +# by a wildcard target in case the make implementation can put the two together. +*.txt-spellchecked: Makefile.am $(abs_top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) +.txt.txt-spellchecked: + $(MAKE) -s -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC_ONE="$<" SPELLCHECK_DIR="$(srcdir)" $@ + +spellcheck spellcheck-interactive spellcheck-sortdict: + $(MAKE) -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC="$(SRC_ALL_PAGES)" SPELLCHECK_DIR="$(srcdir)" $@ + +MAINTAINERCLEANFILES = Makefile.in .dirstamp + +clean-local: + rm -rf tmp diff --git a/docs/man/Makefile.in b/docs/man/Makefile.in index 71b13d4..b0610d3 100644 --- a/docs/man/Makefile.in +++ b/docs/man/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.16.3 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -20,15 +20,29 @@ # Notes: # - sources (.txt) and groff formats are both distributed, # - only sources are versioned ; groff files are generated at worst -# during 'make dist' +# during 'make dist' (while preparing a release tarball) # - HTML files are built upon request, if AsciiDoc is available, # - groff update will only happen if AsciiDoc is available too, # - all this can probably (and hopefully) be improved, but I've not # found a way to do pattern replacement on the fly for target deps! # FIXME: investigate an autogen.sh hook # - Ref: http://www.gnu.org/software/hello/manual/automake/Man-pages.html +# - WITH_MANS can be enabled if either we are building man-pages, or if +# the --with-doc=man=auto detected an inability to build the man-pages +# but enabled the DOC_INSTALL_DISTED_MANS toggle so we deliver disted +# files from source tree VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -102,24 +116,57 @@ target_triplet = @target@ @SOME_DRIVERS_FALSE@@WITH_SERIAL_TRUE@am__append_4 = $(MAN_SERIAL_PAGES) @SOME_DRIVERS_FALSE@@WITH_SNMP_TRUE@am__append_5 = $(MAN_SNMP_PAGES) @SOME_DRIVERS_FALSE@@WITH_USB_TRUE@am__append_6 = $(MAN_USB_LIBUSB_PAGES) -@SOME_DRIVERS_FALSE@@WITH_NEON_TRUE@am__append_7 = $(MAN_NETXML_PAGES) -@SOME_DRIVERS_FALSE@@WITH_LIBPOWERMAN_TRUE@am__append_8 = $(MAN_POWERMAN_PAGES) -@SOME_DRIVERS_FALSE@@WITH_IPMI_TRUE@am__append_9 = $(MAN_IPMIPSU_PAGES) -@SOME_DRIVERS_FALSE@@WITH_MACOSX_TRUE@am__append_10 = $(MAN_MACOSX_PAGES) -@SOME_DRIVERS_FALSE@@WITH_LINUX_I2C_TRUE@am__append_11 = $(LINUX_I2C_PAGES) +@SOME_DRIVERS_FALSE@@WITH_SERIAL_TRUE@am__append_7 = $(MAN_SERIAL_USB_PAGES) +@SOME_DRIVERS_FALSE@@WITH_SERIAL_FALSE@@WITH_USB_TRUE@am__append_8 = $(MAN_SERIAL_USB_PAGES) +@SOME_DRIVERS_FALSE@@WITH_NEON_TRUE@am__append_9 = $(MAN_NETXML_PAGES) +@SOME_DRIVERS_FALSE@@WITH_LIBPOWERMAN_TRUE@am__append_10 = $(MAN_POWERMAN_PAGES) +@SOME_DRIVERS_FALSE@@WITH_IPMI_TRUE@am__append_11 = $(MAN_IPMIPSU_PAGES) +@SOME_DRIVERS_FALSE@@WITH_MACOSX_TRUE@am__append_12 = $(MAN_MACOSX_PAGES) +@SOME_DRIVERS_FALSE@@WITH_MODBUS_TRUE@am__append_13 = $(MAN_MODBUS_PAGES) +@SOME_DRIVERS_FALSE@@WITH_LINUX_I2C_TRUE@am__append_14 = $(MAN_LINUX_I2C_PAGES) +@WITH_MANS_TRUE@am__append_15 = \ +@WITH_MANS_TRUE@ $(MAN_CONF_PAGES) \ +@WITH_MANS_TRUE@ $(MAN_CLIENT_PAGES) \ +@WITH_MANS_TRUE@ $(MAN_TOOL_PAGES) \ +@WITH_MANS_TRUE@ $(MAN5_CGI_PAGES) \ +@WITH_MANS_TRUE@ $(MAN8_CGI_PAGES) \ +@WITH_MANS_TRUE@ $(MAN1_DEV_PAGES) \ +@WITH_MANS_TRUE@ $(MAN3_DEV_PAGES) \ +@WITH_MANS_TRUE@ $(MAN_SERIAL_PAGES) \ +@WITH_MANS_TRUE@ $(MAN_SNMP_PAGES) \ +@WITH_MANS_TRUE@ $(MAN_USB_LIBUSB_PAGES) \ +@WITH_MANS_TRUE@ $(MAN_SERIAL_USB_PAGES) \ +@WITH_MANS_TRUE@ $(MAN_NETXML_PAGES) \ +@WITH_MANS_TRUE@ $(MAN_POWERMAN_PAGES) \ +@WITH_MANS_TRUE@ $(MAN_IPMIPSU_PAGES) \ +@WITH_MANS_TRUE@ $(MAN_MACOSX_PAGES) \ +@WITH_MANS_TRUE@ $(MAN_MODBUS_PAGES) \ +@WITH_MANS_TRUE@ $(MAN_LINUX_I2C_PAGES) + + +# Cause "make dist" to fail, unless caller (like the stack of distcheck-dmf) +# runs ./configure --with-doc=skip (or --with-doc=man=skip specifically) +@SKIP_MANS_FALSE@@WITH_MANS_FALSE@am__append_16 = dist +@HAVE_ASCIIDOC_TRUE@am__append_17 = *.1 *.3 *.5 *.8 *.xml *.html *.pdf subdir = docs/man -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nut_arg_with.m4 \ $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ $(top_srcdir)/m4/nut_check_libavahi.m4 \ $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ $(top_srcdir)/m4/nut_check_libgd.m4 \ $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ $(top_srcdir)/m4/nut_check_libneon.m4 \ $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ $(top_srcdir)/m4/nut_check_libnss.m4 \ @@ -128,11 +175,17 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ $(top_srcdir)/m4/nut_check_libusb.m4 \ $(top_srcdir)/m4/nut_check_libwrap.m4 \ $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ $(top_srcdir)/m4/nut_type_socklen_t.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = @@ -192,6 +245,7 @@ man8dir = $(mandir)/man8 NROFF = nroff MANS = $(man1_MANS) $(man3_MANS) $(man5_MANS) $(man8_MANS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) A2X = @A2X@ ACLOCAL = @ACLOCAL@ @@ -200,6 +254,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -210,6 +265,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -223,6 +279,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -232,9 +289,12 @@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ -EGREP = @EGREP@ + +# Is "egrep == grep -E" always valid? (maybe all a job for configure.ac) +EGREP = egrep EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -252,6 +312,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -262,21 +324,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -296,6 +366,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -309,6 +382,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -326,6 +400,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -339,6 +414,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -364,12 +442,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -379,6 +459,7 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ udevdir = @udevdir@ +#EGREP = grep -E # Base configuration and client manpages, always installed SRC_CONF_PAGES = \ @@ -389,13 +470,13 @@ SRC_CONF_PAGES = \ upsmon.conf.txt \ upssched.conf.txt -MAN_CONF_PAGES = \ - nut.conf.5 \ - ups.conf.5 \ - upsd.conf.5 \ - upsd.users.5 \ - upsmon.conf.5 \ - upssched.conf.5 +@WITH_MANS_TRUE@MAN_CONF_PAGES = \ +@WITH_MANS_TRUE@ nut.conf.5 \ +@WITH_MANS_TRUE@ ups.conf.5 \ +@WITH_MANS_TRUE@ upsd.conf.5 \ +@WITH_MANS_TRUE@ upsd.users.5 \ +@WITH_MANS_TRUE@ upsmon.conf.5 \ +@WITH_MANS_TRUE@ upssched.conf.5 man5_MANS = $(MAN_CONF_PAGES) $(am__append_1) HTML_CONF_MANS = \ @@ -406,45 +487,59 @@ HTML_CONF_MANS = \ upsmon.conf.html \ upssched.conf.html + +# NOTE: Currently SRC_DRIVERTOOL_PAGES are a separate list to generate +# a linkman-drivertool-names.txt file, but historically remain part of +# MAN/HTML_CLIENT_PAGES in the bigger picture. +SRC_DRIVERTOOL_PAGES = \ + nut-driver-enumerator.txt \ + upsdrvctl.txt \ + upsdrvsvcctl.txt + SRC_CLIENT_PAGES = \ + $(SRC_DRIVERTOOL_PAGES) \ nutupsdrv.txt \ upsc.txt \ upscmd.txt \ upsd.txt \ - upsdrvctl.txt \ upslog.txt \ upsmon.txt \ upsrw.txt \ upssched.txt -MAN_CLIENT_PAGES = \ - nutupsdrv.8 \ - upsc.8 \ - upscmd.8 \ - upsd.8 \ - upsdrvctl.8 \ - upslog.8 \ - upsmon.8 \ - upsrw.8 \ - upssched.8 +@WITH_MANS_TRUE@MAN_CLIENT_PAGES = \ +@WITH_MANS_TRUE@ nutupsdrv.8 \ +@WITH_MANS_TRUE@ nut-driver-enumerator.8 \ +@WITH_MANS_TRUE@ upsc.8 \ +@WITH_MANS_TRUE@ upscmd.8 \ +@WITH_MANS_TRUE@ upsd.8 \ +@WITH_MANS_TRUE@ upsdrvctl.8 \ +@WITH_MANS_TRUE@ upsdrvsvcctl.8 \ +@WITH_MANS_TRUE@ upslog.8 \ +@WITH_MANS_TRUE@ upsmon.8 \ +@WITH_MANS_TRUE@ upsrw.8 \ +@WITH_MANS_TRUE@ upssched.8 man8_MANS = $(MAN_CLIENT_PAGES) $(MAN_TOOL_PAGES) $(am__append_2) \ $(am__append_3) $(am__append_4) $(am__append_5) \ $(am__append_6) $(am__append_7) $(am__append_8) \ - $(am__append_9) $(am__append_10) $(am__append_11) + $(am__append_9) $(am__append_10) $(am__append_11) \ + $(am__append_12) $(am__append_13) $(am__append_14) HTML_CLIENT_MANS = \ nutupsdrv.html \ + nut-driver-enumerator.html \ upsc.html \ upscmd.html \ upsd.html \ upsdrvctl.html \ + upsdrvsvcctl.html \ upslog.html \ upsmon.html \ upsrw.html \ upssched.html SRC_TOOL_PAGES = nut-scanner.txt nut-recorder.txt -MAN_TOOL_PAGES = nut-scanner.8 nut-recorder.8 +@WITH_MANS_TRUE@MAN_TOOL_PAGES = nut-scanner.8 nut-recorder.8 HTML_TOOL_MANS = nut-scanner.html nut-recorder.html # CGI (--with-cgi) related manpages @@ -456,15 +551,15 @@ SRC_CGI_PAGES = \ upsstats.cgi.txt \ upsimage.cgi.txt -MAN5_CGI_PAGES = \ - hosts.conf.5 \ - upsset.conf.5 \ - upsstats.html.5 +@WITH_MANS_TRUE@MAN5_CGI_PAGES = \ +@WITH_MANS_TRUE@ hosts.conf.5 \ +@WITH_MANS_TRUE@ upsset.conf.5 \ +@WITH_MANS_TRUE@ upsstats.html.5 -MAN8_CGI_PAGES = \ - upsset.cgi.8 \ - upsstats.cgi.8 \ - upsimage.cgi.8 +@WITH_MANS_TRUE@MAN8_CGI_PAGES = \ +@WITH_MANS_TRUE@ upsset.cgi.8 \ +@WITH_MANS_TRUE@ upsstats.cgi.8 \ +@WITH_MANS_TRUE@ upsimage.cgi.8 HTML_CGI_MANS = \ hosts.conf.html \ @@ -504,7 +599,7 @@ SRC_DEV_PAGES = \ nutscan.txt \ nutscan_scan_snmp.txt \ nutscan_scan_usb.txt \ - nutscan_scan_xml_http.txt \ + nutscan_scan_xml_http_range.txt \ nutscan_scan_nut.txt \ nutscan_scan_avahi.txt \ nutscan_scan_ipmi.txt \ @@ -523,78 +618,98 @@ SRC_DEV_PAGES = \ # NOTE: nutclient_*.3 has no source counterpart (libnutclient_*.txt) -MAN3_DEV_PAGES = \ - upsclient.3 \ - upscli_add_host_cert.3 \ - upscli_cleanup.3 \ - upscli_connect.3 \ - upscli_disconnect.3 \ - upscli_fd.3 \ - upscli_get.3 \ - upscli_init.3 \ - upscli_list_next.3 \ - upscli_list_start.3 \ - upscli_readline.3 \ - upscli_sendline.3 \ - upscli_splitaddr.3 \ - upscli_splitname.3 \ - upscli_ssl.3 \ - upscli_strerror.3 \ - upscli_upserror.3 \ - libnutclient.3 \ - libnutclient_commands.3 \ - libnutclient_devices.3 \ - libnutclient_general.3 \ - libnutclient_misc.3 \ - libnutclient_tcp.3 \ - libnutclient_variables.3 \ - nutclient_authenticate.3 \ - nutclient_destroy.3 \ - nutclient_device_forced_shutdown.3 \ - nutclient_device_login.3 \ - nutclient_device_master.3 \ - nutclient_execute_device_command.3 \ - nutclient_get_device_command_description.3 \ - nutclient_get_device_commands.3 \ - nutclient_get_device_description.3 \ - nutclient_get_device_num_logins.3 \ - nutclient_get_device_rw_variables.3 \ - nutclient_get_devices.3 \ - nutclient_get_device_variable_description.3 \ - nutclient_get_device_variables.3 \ - nutclient_get_device_variable_values.3 \ - nutclient_has_device.3 \ - nutclient_has_device_command.3 \ - nutclient_has_device_variable.3 \ - nutclient_logout.3 \ - nutclient_set_device_variable_value.3 \ - nutclient_set_device_variable_values.3 \ - nutclient_tcp_create_client.3 \ - nutclient_tcp_disconnect.3 \ - nutclient_tcp_get_timeout.3 \ - nutclient_tcp_is_connected.3 \ - nutclient_tcp_reconnect.3 \ - nutclient_tcp_set_timeout.3 \ - nutscan.3 \ - nutscan_scan_snmp.3 \ - nutscan_scan_usb.3 \ - nutscan_scan_xml_http.3 \ - nutscan_scan_nut.3 \ - nutscan_scan_avahi.3 \ - nutscan_scan_ipmi.3 \ - nutscan_scan_eaton_serial.3 \ - nutscan_display_ups_conf.3 \ - nutscan_display_parsable.3 \ - nutscan_cidr_to_ip.3 \ - nutscan_new_device.3 \ - nutscan_free_device.3 \ - nutscan_add_option_to_device.3 \ - nutscan_add_device_to_device.3 \ - nutscan_get_serial_ports_list.3 \ - nutscan_init.3 +@WITH_MANS_TRUE@LIBNUTCLIENT_MISC_DEPS = \ +@WITH_MANS_TRUE@ nutclient_authenticate.3 \ +@WITH_MANS_TRUE@ nutclient_logout.3 \ +@WITH_MANS_TRUE@ nutclient_device_login.3 \ +@WITH_MANS_TRUE@ nutclient_get_device_num_logins.3 \ +@WITH_MANS_TRUE@ nutclient_device_master.3 \ +@WITH_MANS_TRUE@ nutclient_device_forced_shutdown.3 -MAN1_DEV_PAGES = \ - libupsclient-config.1 +@WITH_MANS_TRUE@LIBNUTCLIENT_TCP_DEPS = \ +@WITH_MANS_TRUE@ nutclient_tcp_create_client.3 \ +@WITH_MANS_TRUE@ nutclient_tcp_disconnect.3 \ +@WITH_MANS_TRUE@ nutclient_tcp_get_timeout.3 \ +@WITH_MANS_TRUE@ nutclient_tcp_is_connected.3 \ +@WITH_MANS_TRUE@ nutclient_tcp_reconnect.3 \ +@WITH_MANS_TRUE@ nutclient_tcp_set_timeout.3 + +@WITH_MANS_TRUE@LIBNUTCLIENT_GENERAL_DEPS = \ +@WITH_MANS_TRUE@ nutclient_destroy.3 + +@WITH_MANS_TRUE@LIBNUTCLIENT_VARIABLES_DEPS = \ +@WITH_MANS_TRUE@ nutclient_get_device_rw_variables.3 \ +@WITH_MANS_TRUE@ nutclient_get_device_variable_description.3 \ +@WITH_MANS_TRUE@ nutclient_get_device_variables.3 \ +@WITH_MANS_TRUE@ nutclient_get_device_variable_values.3 \ +@WITH_MANS_TRUE@ nutclient_has_device_variable.3 \ +@WITH_MANS_TRUE@ nutclient_set_device_variable_value.3 \ +@WITH_MANS_TRUE@ nutclient_set_device_variable_values.3 + +@WITH_MANS_TRUE@LIBNUTCLIENT_COMMANDS_DEPS = \ +@WITH_MANS_TRUE@ nutclient_execute_device_command.3 \ +@WITH_MANS_TRUE@ nutclient_get_device_command_description.3 \ +@WITH_MANS_TRUE@ nutclient_get_device_commands.3 \ +@WITH_MANS_TRUE@ nutclient_has_device_command.3 + +@WITH_MANS_TRUE@LIBNUTCLIENT_DEVICES_DEPS = \ +@WITH_MANS_TRUE@ nutclient_get_device_description.3 \ +@WITH_MANS_TRUE@ nutclient_get_devices.3 \ +@WITH_MANS_TRUE@ nutclient_has_device.3 + +@WITH_MANS_TRUE@MAN3_DEV_PAGES = \ +@WITH_MANS_TRUE@ upsclient.3 \ +@WITH_MANS_TRUE@ upscli_add_host_cert.3 \ +@WITH_MANS_TRUE@ upscli_cleanup.3 \ +@WITH_MANS_TRUE@ upscli_connect.3 \ +@WITH_MANS_TRUE@ upscli_disconnect.3 \ +@WITH_MANS_TRUE@ upscli_fd.3 \ +@WITH_MANS_TRUE@ upscli_get.3 \ +@WITH_MANS_TRUE@ upscli_init.3 \ +@WITH_MANS_TRUE@ upscli_list_next.3 \ +@WITH_MANS_TRUE@ upscli_list_start.3 \ +@WITH_MANS_TRUE@ upscli_readline.3 \ +@WITH_MANS_TRUE@ upscli_readline_timeout.3 \ +@WITH_MANS_TRUE@ upscli_sendline.3 \ +@WITH_MANS_TRUE@ upscli_sendline_timeout.3 \ +@WITH_MANS_TRUE@ upscli_splitaddr.3 \ +@WITH_MANS_TRUE@ upscli_splitname.3 \ +@WITH_MANS_TRUE@ upscli_ssl.3 \ +@WITH_MANS_TRUE@ upscli_strerror.3 \ +@WITH_MANS_TRUE@ upscli_upserror.3 \ +@WITH_MANS_TRUE@ libnutclient.3 \ +@WITH_MANS_TRUE@ libnutclient_commands.3 \ +@WITH_MANS_TRUE@ $(LIBNUTCLIENT_COMMANDS_DEPS) \ +@WITH_MANS_TRUE@ libnutclient_devices.3 \ +@WITH_MANS_TRUE@ $(LIBNUTCLIENT_DEVICES_DEPS) \ +@WITH_MANS_TRUE@ libnutclient_general.3 \ +@WITH_MANS_TRUE@ $(LIBNUTCLIENT_GENERAL_DEPS) \ +@WITH_MANS_TRUE@ libnutclient_misc.3 \ +@WITH_MANS_TRUE@ $(LIBNUTCLIENT_MISC_DEPS) \ +@WITH_MANS_TRUE@ libnutclient_tcp.3 \ +@WITH_MANS_TRUE@ $(LIBNUTCLIENT_TCP_DEPS) \ +@WITH_MANS_TRUE@ libnutclient_variables.3 \ +@WITH_MANS_TRUE@ $(LIBNUTCLIENT_VARIABLES_DEPS) \ +@WITH_MANS_TRUE@ nutscan.3 \ +@WITH_MANS_TRUE@ nutscan_scan_snmp.3 \ +@WITH_MANS_TRUE@ nutscan_scan_usb.3 \ +@WITH_MANS_TRUE@ nutscan_scan_xml_http_range.3 \ +@WITH_MANS_TRUE@ nutscan_scan_nut.3 \ +@WITH_MANS_TRUE@ nutscan_scan_avahi.3 \ +@WITH_MANS_TRUE@ nutscan_scan_ipmi.3 \ +@WITH_MANS_TRUE@ nutscan_scan_eaton_serial.3 \ +@WITH_MANS_TRUE@ nutscan_display_ups_conf.3 \ +@WITH_MANS_TRUE@ nutscan_display_parsable.3 \ +@WITH_MANS_TRUE@ nutscan_cidr_to_ip.3 \ +@WITH_MANS_TRUE@ nutscan_new_device.3 \ +@WITH_MANS_TRUE@ nutscan_free_device.3 \ +@WITH_MANS_TRUE@ nutscan_add_option_to_device.3 \ +@WITH_MANS_TRUE@ nutscan_add_device_to_device.3 \ +@WITH_MANS_TRUE@ nutscan_get_serial_ports_list.3 \ +@WITH_MANS_TRUE@ nutscan_init.3 + +@WITH_MANS_TRUE@MAN1_DEV_PAGES = \ +@WITH_MANS_TRUE@ libupsclient-config.1 @WITH_DEV_TRUE@man3_MANS = $(MAN3_DEV_PAGES) @WITH_DEV_TRUE@@WITH_PKG_CONFIG_FALSE@man1_MANS = $(MAN1_DEV_PAGES) @@ -627,7 +742,7 @@ HTML_DEV_MANS = \ nutscan.html \ nutscan_scan_snmp.html \ nutscan_scan_usb.html \ - nutscan_scan_xml_http.html \ + nutscan_scan_xml_http_range.html \ nutscan_scan_nut.html \ nutscan_scan_avahi.html \ nutscan_scan_ipmi.html \ @@ -675,7 +790,8 @@ HTML_DEV_MANS = \ @SOME_DRIVERS_FALSE@ mge-utalk.txt \ @SOME_DRIVERS_FALSE@ oneac.txt \ @SOME_DRIVERS_FALSE@ microdowell.txt \ -@SOME_DRIVERS_FALSE@ nutdrv_qx.txt \ +@SOME_DRIVERS_FALSE@ microsol-apc.txt \ +@SOME_DRIVERS_FALSE@ nutdrv_siemens_sitop.txt \ @SOME_DRIVERS_FALSE@ optiups.txt \ @SOME_DRIVERS_FALSE@ powercom.txt \ @SOME_DRIVERS_FALSE@ powerpanel.txt \ @@ -689,47 +805,48 @@ HTML_DEV_MANS = \ @SOME_DRIVERS_FALSE@ victronups.txt \ @SOME_DRIVERS_FALSE@ apcupsd-ups.txt -@SOME_DRIVERS_FALSE@MAN_SERIAL_PAGES = \ -@SOME_DRIVERS_FALSE@ al175.8 \ -@SOME_DRIVERS_FALSE@ apcsmart.8 \ -@SOME_DRIVERS_FALSE@ apcsmart-old.8 \ -@SOME_DRIVERS_FALSE@ bcmxcp.8 \ -@SOME_DRIVERS_FALSE@ belkin.8 \ -@SOME_DRIVERS_FALSE@ belkinunv.8 \ -@SOME_DRIVERS_FALSE@ bestfortress.8 \ -@SOME_DRIVERS_FALSE@ bestuferrups.8 \ -@SOME_DRIVERS_FALSE@ bestups.8 \ -@SOME_DRIVERS_FALSE@ bestfcom.8 \ -@SOME_DRIVERS_FALSE@ blazer_ser.8 \ -@SOME_DRIVERS_FALSE@ clone.8 \ -@SOME_DRIVERS_FALSE@ dummy-ups.8 \ -@SOME_DRIVERS_FALSE@ etapro.8 \ -@SOME_DRIVERS_FALSE@ everups.8 \ -@SOME_DRIVERS_FALSE@ gamatronic.8 \ -@SOME_DRIVERS_FALSE@ genericups.8 \ -@SOME_DRIVERS_FALSE@ isbmex.8 \ -@SOME_DRIVERS_FALSE@ ivtscd.8 \ -@SOME_DRIVERS_FALSE@ liebert.8 \ -@SOME_DRIVERS_FALSE@ liebert-esp2.8 \ -@SOME_DRIVERS_FALSE@ masterguard.8 \ -@SOME_DRIVERS_FALSE@ metasys.8 \ -@SOME_DRIVERS_FALSE@ mge-shut.8 \ -@SOME_DRIVERS_FALSE@ mge-utalk.8 \ -@SOME_DRIVERS_FALSE@ nutdrv_qx.8 \ -@SOME_DRIVERS_FALSE@ oneac.8 \ -@SOME_DRIVERS_FALSE@ microdowell.8 \ -@SOME_DRIVERS_FALSE@ optiups.8 \ -@SOME_DRIVERS_FALSE@ powercom.8 \ -@SOME_DRIVERS_FALSE@ powerpanel.8 \ -@SOME_DRIVERS_FALSE@ rhino.8 \ -@SOME_DRIVERS_FALSE@ riello_ser.8 \ -@SOME_DRIVERS_FALSE@ safenet.8 \ -@SOME_DRIVERS_FALSE@ solis.8 \ -@SOME_DRIVERS_FALSE@ tripplite.8 \ -@SOME_DRIVERS_FALSE@ tripplitesu.8 \ -@SOME_DRIVERS_FALSE@ upscode2.8 \ -@SOME_DRIVERS_FALSE@ victronups.8 \ -@SOME_DRIVERS_FALSE@ apcupsd-ups.8 +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@MAN_SERIAL_PAGES = \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ al175.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ apcsmart.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ apcsmart-old.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ bcmxcp.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ belkin.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ belkinunv.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ bestfortress.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ bestuferrups.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ bestups.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ bestfcom.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ blazer_ser.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ clone.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ dummy-ups.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ etapro.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ everups.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ gamatronic.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ genericups.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ isbmex.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ ivtscd.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ liebert.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ liebert-esp2.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ masterguard.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ metasys.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ mge-shut.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ mge-utalk.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ oneac.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ microdowell.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ microsol-apc.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ nutdrv_siemens_sitop.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ optiups.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ powercom.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ powerpanel.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ rhino.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ riello_ser.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ safenet.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ solis.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ tripplite.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ tripplitesu.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ upscode2.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ victronups.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ apcupsd-ups.8 @SOME_DRIVERS_FALSE@HTML_SERIAL_MANS = \ @SOME_DRIVERS_FALSE@ al175.html \ @@ -757,9 +874,10 @@ HTML_DEV_MANS = \ @SOME_DRIVERS_FALSE@ metasys.html \ @SOME_DRIVERS_FALSE@ mge-shut.html \ @SOME_DRIVERS_FALSE@ mge-utalk.html \ -@SOME_DRIVERS_FALSE@ nutdrv_qx.html \ @SOME_DRIVERS_FALSE@ oneac.html \ @SOME_DRIVERS_FALSE@ microdowell.html \ +@SOME_DRIVERS_FALSE@ microsol-apc.html \ +@SOME_DRIVERS_FALSE@ nutdrv_siemens_sitop.html \ @SOME_DRIVERS_FALSE@ optiups.html \ @SOME_DRIVERS_FALSE@ powercom.html \ @SOME_DRIVERS_FALSE@ powerpanel.html \ @@ -776,7 +894,7 @@ HTML_DEV_MANS = \ # (--with-snmp) @SOME_DRIVERS_FALSE@SRC_SNMP_PAGES = snmp-ups.txt -@SOME_DRIVERS_FALSE@MAN_SNMP_PAGES = snmp-ups.8 +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@MAN_SNMP_PAGES = snmp-ups.8 @SOME_DRIVERS_FALSE@HTML_SNMP_MANS = snmp-ups.html # (--with-usb) @@ -785,26 +903,23 @@ HTML_DEV_MANS = \ @SOME_DRIVERS_FALSE@ blazer-common.txt \ @SOME_DRIVERS_FALSE@ blazer_usb.txt \ @SOME_DRIVERS_FALSE@ nutdrv_atcl_usb.txt \ -@SOME_DRIVERS_FALSE@ nutdrv_qx.txt \ @SOME_DRIVERS_FALSE@ richcomm_usb.txt \ @SOME_DRIVERS_FALSE@ riello_usb.txt \ @SOME_DRIVERS_FALSE@ tripplite_usb.txt \ @SOME_DRIVERS_FALSE@ usbhid-ups.txt -@SOME_DRIVERS_FALSE@MAN_USB_LIBUSB_PAGES = \ -@SOME_DRIVERS_FALSE@ bcmxcp_usb.8 \ -@SOME_DRIVERS_FALSE@ blazer_usb.8 \ -@SOME_DRIVERS_FALSE@ nutdrv_atcl_usb.8 \ -@SOME_DRIVERS_FALSE@ nutdrv_qx.8 \ -@SOME_DRIVERS_FALSE@ richcomm_usb.8 \ -@SOME_DRIVERS_FALSE@ riello_usb.8 \ -@SOME_DRIVERS_FALSE@ tripplite_usb.8 \ -@SOME_DRIVERS_FALSE@ usbhid-ups.8 +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@MAN_USB_LIBUSB_PAGES = \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ bcmxcp_usb.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ blazer_usb.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ nutdrv_atcl_usb.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ richcomm_usb.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ riello_usb.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ tripplite_usb.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ usbhid-ups.8 @SOME_DRIVERS_FALSE@HTML_USB_LIBUSB_MANS = \ @SOME_DRIVERS_FALSE@ bcmxcp_usb.html \ @SOME_DRIVERS_FALSE@ blazer_usb.html \ -@SOME_DRIVERS_FALSE@ nutdrv_qx.html \ @SOME_DRIVERS_FALSE@ nutdrv_atcl_usb.html \ @SOME_DRIVERS_FALSE@ richcomm_usb.html \ @SOME_DRIVERS_FALSE@ riello_usb.html \ @@ -812,65 +927,83 @@ HTML_DEV_MANS = \ @SOME_DRIVERS_FALSE@ usbhid-ups.html +# (--with-serial / --with-usb) +@SOME_DRIVERS_FALSE@SRC_SERIAL_USB_PAGES = \ +@SOME_DRIVERS_FALSE@ nutdrv_qx.txt + +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@MAN_SERIAL_USB_PAGES = \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ nutdrv_qx.8 + +@SOME_DRIVERS_FALSE@HTML_SERIAL_USB_MANS = \ +@SOME_DRIVERS_FALSE@ nutdrv_qx.html + + # (--with-neon) @SOME_DRIVERS_FALSE@SRC_NETXML_PAGES = netxml-ups.txt -@SOME_DRIVERS_FALSE@MAN_NETXML_PAGES = netxml-ups.8 +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@MAN_NETXML_PAGES = netxml-ups.8 @SOME_DRIVERS_FALSE@HTML_NETXML_MANS = netxml-ups.html # (--with-powerman) @SOME_DRIVERS_FALSE@SRC_POWERMAN_PAGES = powerman-pdu.txt -@SOME_DRIVERS_FALSE@MAN_POWERMAN_PAGES = powerman-pdu.8 +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@MAN_POWERMAN_PAGES = powerman-pdu.8 @SOME_DRIVERS_FALSE@HTML_POWERMAN_MANS = powerman-pdu.html # (--with-ipmi) @SOME_DRIVERS_FALSE@SRC_IPMIPSU_PAGES = nut-ipmipsu.txt -@SOME_DRIVERS_FALSE@MAN_IPMIPSU_PAGES = nut-ipmipsu.8 +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@MAN_IPMIPSU_PAGES = nut-ipmipsu.8 @SOME_DRIVERS_FALSE@HTML_IPMIPSU_MANS = nut-ipmipsu.html @SOME_DRIVERS_FALSE@SRC_MACOSX_PAGES = macosx-ups.txt -@SOME_DRIVERS_FALSE@MAN_MACOSX_PAGES = macosx-ups.8 +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@MAN_MACOSX_PAGES = macosx-ups.8 @SOME_DRIVERS_FALSE@HTML_MACOSX_MANS = macosx-ups.html -@SOME_DRIVERS_FALSE@SRC_LINUX_I2C_PAGES = asem.txt -@SOME_DRIVERS_FALSE@MAN_LINUX_I2C_PAGES = asem.8 -@SOME_DRIVERS_FALSE@HTML_LINUX_I2C_MANS = asem.html +@SOME_DRIVERS_FALSE@SRC_MODBUS_PAGES = phoenixcontact_modbus.txt \ +@SOME_DRIVERS_FALSE@ generic_modbus.txt \ +@SOME_DRIVERS_FALSE@ huawei-ups2000.txt \ +@SOME_DRIVERS_FALSE@ socomec_jbus.txt \ +@SOME_DRIVERS_FALSE@ adelsystem_cbi.txt + +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@MAN_MODBUS_PAGES = phoenixcontact_modbus.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ generic_modbus.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ huawei-ups2000.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ socomec_jbus.8 \ +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@ adelsystem_cbi.8 + +@SOME_DRIVERS_FALSE@HTML_MODBUS_MANS = phoenixcontact_modbus.html \ +@SOME_DRIVERS_FALSE@ generic_modbus.html \ +@SOME_DRIVERS_FALSE@ huawei-ups2000.html \ +@SOME_DRIVERS_FALSE@ socomec_jbus.html \ +@SOME_DRIVERS_FALSE@ adelsystem_cbi.html + +@SOME_DRIVERS_FALSE@SRC_LINUX_I2C_PAGES = asem.txt pijuice.txt +@SOME_DRIVERS_FALSE@@WITH_MANS_TRUE@MAN_LINUX_I2C_PAGES = asem.8 pijuice.8 +@SOME_DRIVERS_FALSE@HTML_LINUX_I2C_MANS = asem.html pijuice.html # SOME_DRIVERS -MAN_MANS = \ - $(MAN_CONF_PAGES) \ - $(MAN_CLIENT_PAGES) \ - $(MAN_TOOL_PAGES) \ - $(MAN5_CGI_PAGES) \ - $(MAN8_CGI_PAGES) \ - $(MAN1_DEV_PAGES) \ - $(MAN3_DEV_PAGES) \ - $(MAN_SERIAL_PAGES) \ - $(MAN_SNMP_PAGES) \ - $(MAN_USB_LIBUSB_PAGES) \ - $(MAN_NETXML_PAGES) \ - $(MAN_POWERMAN_PAGES) \ - $(MAN_IPMIPSU_PAGES) \ - $(MAN_MACOSX_PAGES) \ - $(MAN_LINUX_I2C_PAGES) +MAN_MANS = $(am__append_15) +SRC_DRIVERS_PAGES = \ + $(SRC_SERIAL_PAGES) \ + $(SRC_SNMP_PAGES) \ + $(SRC_USB_LIBUSB_PAGES) \ + $(SRC_SERIAL_USB_PAGES) \ + $(SRC_NETXML_PAGES) \ + $(SRC_POWERMAN_PAGES) \ + $(SRC_IPMIPSU_PAGES) \ + $(SRC_MACOSX_PAGES) \ + $(SRC_MODBUS_PAGES) \ + $(SRC_LINUX_I2C_PAGES) # distribute everything, even those not installed by default # Note that 'dist' target requires AsciiDoc! -EXTRA_DIST = \ +SRC_ALL_PAGES = \ $(SRC_CONF_PAGES) \ $(SRC_CLIENT_PAGES) \ $(SRC_TOOL_PAGES) \ $(SRC_CGI_PAGES) \ $(SRC_DEV_PAGES) \ - $(SRC_SERIAL_PAGES) \ - $(SRC_SNMP_PAGES) \ - $(SRC_USB_LIBUSB_PAGES) \ - $(SRC_NETXML_PAGES) \ - $(SRC_POWERMAN_PAGES) \ - $(SRC_IPMIPSU_PAGES) \ - $(SRC_MACOSX_PAGES) \ - $(SRC_LINUX_I2C_PAGES) \ - $(MAN_MANS) \ - asciidoc.conf + $(SRC_DRIVERS_PAGES) +EXTRA_DIST = $(SRC_ALL_PAGES) $(MAN_MANS) asciidoc.conf \ + $(am__append_16) HTML_MANS = \ $(HTML_CONF_MANS) \ $(HTML_CLIENT_MANS) \ @@ -880,27 +1013,93 @@ HTML_MANS = \ $(HTML_SERIAL_MANS) \ $(HTML_SNMP_MANS) \ $(HTML_USB_LIBUSB_MANS) \ + $(HTML_SERIAL_USB_MANS) \ $(HTML_NETXML_MANS) \ $(HTML_POWERMAN_MANS) \ $(HTML_IPMIPSU_MANS) \ $(HTML_MACOSX_MANS) \ + $(HTML_MODBUS_MANS) \ $(HTML_LINUX_I2C_MANS) -CLEANFILES = *.xml *.html + +# Note: target documents, except nutupsdrv.txt itself, start the +# list of drivers with `- linkman:nutupsdrv[8]` entry +# To regenerate these files, do `make distclean` first +LINKMAN_INCLUDE_GENERATED = linkman-driver-names.txt linkman-drivertool-names.txt +LINKMAN_INCLUDE_CONSUMERS = index.txt upsd.txt nutupsdrv.txt + +# These files are generated when we build from git source so not tracked in +# git, and not part of tarball (to be in builddir) - so not in EXTRA_DIST. +DISTCLEANFILES = $(LINKMAN_INCLUDE_GENERATED) +CLEANFILES = *-spellchecked $(am__append_17) SUFFIXES = .txt .html .1 .3 .5 .8 +@DOC_INSTALL_DISTED_MANS_FALSE@SRC_PREBUILT_CLAUSE = + +# For builds with allowed installation of prebuild man pages, check that +# they exist in sources (make would pull them automatically as a fallback +# from failed lookup in build products). For builds that require rebuild +# of man pages, abort with error if build product is missing. +@DOC_INSTALL_DISTED_MANS_TRUE@SRC_PREBUILT_CLAUSE = || [ -r "$(srcdir)/`basename $@`" ] + +# Working around a2x not friendly to parallelized runs. +# See more details in the main NUT docs/Makefile.am +@HAVE_ASCIIDOC_TRUE@DOCBUILD_BEGIN = { \ +@HAVE_ASCIIDOC_TRUE@ if test -n "$${A2X_OUTDIR}" && test "$${A2X_OUTDIR}" != '.' ; then \ +@HAVE_ASCIIDOC_TRUE@ rm -rf "./$${A2X_OUTDIR}" || true ; \ +@HAVE_ASCIIDOC_TRUE@ test -d "$@" && rm -rf "$@" || true ; \ +@HAVE_ASCIIDOC_TRUE@ mkdir -p "./$${A2X_OUTDIR}" || exit ; \ +@HAVE_ASCIIDOC_TRUE@ for F in $(LINKMAN_INCLUDE_GENERATED) ; do \ +@HAVE_ASCIIDOC_TRUE@ if [ -s "./$$F" ] ; then ln -f -s "../../$$F" "./$${A2X_OUTDIR}/" ; else \ +@HAVE_ASCIIDOC_TRUE@ if [ -s "$(abs_srcdir)/$$F" ] ; then ln -f -s "$(abs_srcdir)/$$F" "./$${A2X_OUTDIR}/" ; fi ; fi ; \ +@HAVE_ASCIIDOC_TRUE@ done ; \ +@HAVE_ASCIIDOC_TRUE@ else A2X_OUTDIR='.' ; fi; \ +@HAVE_ASCIIDOC_TRUE@ if test -s "${builddir}/docbook-xsl.css" \ +@HAVE_ASCIIDOC_TRUE@ && test -r "${builddir}/docbook-xsl.css" \ +@HAVE_ASCIIDOC_TRUE@ && ! test -w "${builddir}/docbook-xsl.css" \ +@HAVE_ASCIIDOC_TRUE@ ; then chmod u+w "${builddir}/docbook-xsl.css" ; fi ; \ +@HAVE_ASCIIDOC_TRUE@ chmod -R u+w "./$${A2X_OUTDIR}" || true ; \ +@HAVE_ASCIIDOC_TRUE@ if test x"$(srcdir)" != x"$(builddir)" ; then \ +@HAVE_ASCIIDOC_TRUE@ if ! test -s "$(builddir)/$<" && test -s "$(srcdir)/`basename $<`" ; then \ +@HAVE_ASCIIDOC_TRUE@ ln -fs "$(srcdir)/`basename $<`" "$(builddir)/" ; \ +@HAVE_ASCIIDOC_TRUE@ fi ; \ +@HAVE_ASCIIDOC_TRUE@ fi ; \ +@HAVE_ASCIIDOC_TRUE@ A2X_VERBOSE="$(ASCIIDOC_VERBOSE)"; if [ "$(V)" = 1 ]; then A2X_VERBOSE="--verbose"; fi; \ +@HAVE_ASCIIDOC_TRUE@} + + +# Note that documents with sub-pages (see LIBNUTCLIENT_*_DEPS above) +# may generate multiple files in one go... so we move "*" and hope +# for no required hidden files (or would have to `find` them all). +@HAVE_ASCIIDOC_TRUE@DOCBUILD_END = { \ +@HAVE_ASCIIDOC_TRUE@ if test -n "$${A2X_OUTDIR}" && test "$${A2X_OUTDIR}" != '.' ; then \ +@HAVE_ASCIIDOC_TRUE@ chmod -R u+w "./$${A2X_OUTDIR}" || true ; \ +@HAVE_ASCIIDOC_TRUE@ test -d "$@" && rm -rf "$@" || true ; \ +@HAVE_ASCIIDOC_TRUE@ for F in $(LINKMAN_INCLUDE_GENERATED) ; do \ +@HAVE_ASCIIDOC_TRUE@ rm -f "./$${A2X_OUTDIR}/$$F" || true ; \ +@HAVE_ASCIIDOC_TRUE@ done ; \ +@HAVE_ASCIIDOC_TRUE@ mv -f "./$${A2X_OUTDIR}/$(@F)" ./ || exit ; \ +@HAVE_ASCIIDOC_TRUE@ mv -f "./$${A2X_OUTDIR}/"*.* ./ 2>/dev/null || true ; \ +@HAVE_ASCIIDOC_TRUE@ rm -rf "./$${A2X_OUTDIR}" ; \ +@HAVE_ASCIIDOC_TRUE@ fi ; \ +@HAVE_ASCIIDOC_TRUE@} + ### Prior to Asciidoc ~8.6.8, the --destination-dir flag didn't seem to affect the location of the intermediate .xml file. -@HAVE_ASCIIDOC_TRUE@A2X_MANPAGE_OPTS = --doctype manpage --format manpage \ -@HAVE_ASCIIDOC_TRUE@ --xsltproc-opts "--nonet" \ +### This parameter is currently required; see docs/Makefile.am for more detail. +@HAVE_ASCIIDOC_TRUE@A2X_MANPAGE_OPTS = --doctype manpage --format manpage $${A2X_VERBOSE} \ +@HAVE_ASCIIDOC_TRUE@ --xsltproc-opts="--nonet" \ @HAVE_ASCIIDOC_TRUE@ --attribute mansource="Network UPS Tools" \ @HAVE_ASCIIDOC_TRUE@ --attribute manversion="@PACKAGE_VERSION@" \ @HAVE_ASCIIDOC_TRUE@ --attribute manmanual="NUT Manual" \ -@HAVE_ASCIIDOC_TRUE@ --destination-dir=. +@HAVE_ASCIIDOC_TRUE@ --attribute srcdir="$(abs_srcdir)" \ +@HAVE_ASCIIDOC_TRUE@ --attribute builddir="$(abs_builddir)" \ +@HAVE_ASCIIDOC_TRUE@ --destination-dir="$${A2X_OUTDIR}" +MAINTAINERCLEANFILES = Makefile.in .dirstamp all: all-am .SUFFIXES: -.SUFFIXES: .txt .html .1 .3 .5 .8 +.SUFFIXES: .txt .html .1 .3 .5 .8 .txt-spellchecked $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ @@ -913,14 +1112,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu docs/man/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu docs/man/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -1108,7 +1306,10 @@ ctags CTAGS: cscope cscopelist: -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -1138,7 +1339,11 @@ distdir: $(DISTFILES) || exit 1; \ fi; \ done + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" distdir="$(distdir)" \ + dist-hook check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-local check: check-am all-am: Makefile $(MANS) installdirs: @@ -1172,13 +1377,15 @@ clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am -clean-am: clean-generic clean-libtool mostlyclean-am +clean-am: clean-generic clean-libtool clean-local mostlyclean-am distclean: distclean-am -rm -f Makefile @@ -1245,48 +1452,202 @@ uninstall-am: uninstall-man uninstall-man: uninstall-man1 uninstall-man3 uninstall-man5 \ uninstall-man8 -.MAKE: install-am install-strip +.MAKE: check-am install-am install-strip -.PHONY: all all-am check check-am clean clean-generic clean-libtool \ - cscopelist-am ctags-am distclean distclean-generic \ - distclean-libtool distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-man1 install-man3 install-man5 install-man8 \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags-am uninstall uninstall-am uninstall-man uninstall-man1 \ - uninstall-man3 uninstall-man5 uninstall-man8 +.PHONY: all all-am check check-am check-local clean clean-generic \ + clean-libtool clean-local cscopelist-am ctags-am dist-hook \ + distclean distclean-generic distclean-libtool distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-man1 \ + install-man3 install-man5 install-man8 install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ + uninstall-am uninstall-man uninstall-man1 uninstall-man3 \ + uninstall-man5 uninstall-man8 +.PRECIOUS: Makefile + + +@WITH_MANS_TRUE@$(LIBNUTCLIENT_MISC_DEPS): libnutclient_misc.3 +@WITH_MANS_TRUE@ touch $@ + +@WITH_MANS_TRUE@$(LIBNUTCLIENT_TCP_DEPS): libnutclient_tcp.3 +@WITH_MANS_TRUE@ touch $@ + +@WITH_MANS_TRUE@$(LIBNUTCLIENT_GENERAL_DEPS): libnutclient_general.3 +@WITH_MANS_TRUE@ touch $@ + +@WITH_MANS_TRUE@$(LIBNUTCLIENT_VARIABLES_DEPS): libnutclient_variables.3 +@WITH_MANS_TRUE@ touch $@ + +@WITH_MANS_TRUE@$(LIBNUTCLIENT_COMMANDS_DEPS): libnutclient_commands.3 +@WITH_MANS_TRUE@ touch $@ + +@WITH_MANS_TRUE@$(LIBNUTCLIENT_DEVICES_DEPS): libnutclient_devices.3 +@WITH_MANS_TRUE@ touch $@ + +@WITH_MANS_TRUE@upscli_readline_timeout.3: upscli_readline.3 +@WITH_MANS_TRUE@ touch $@ + +@WITH_MANS_TRUE@upscli_sendline_timeout.3: upscli_sendline.3 +@WITH_MANS_TRUE@ touch $@ +@SKIP_MANS_FALSE@@WITH_MANS_FALSE@dist: +@SKIP_MANS_FALSE@@WITH_MANS_FALSE@ @echo "ERROR: Manpage building was disabled by configure script, and these pages are required for our proper 'make dist'" >&2 ; false + +# For builds done from dist'ed sources, there may be a conflict of timestamps +# between original *.txt files and pre-built manpages etc. leading to skipping +# of manpage re-generation even if that activity is possible and requested. +# Possibly a cleaner, but less portable, solution would be to touch the +# generated files to long ago. Current solution assumes good valid clocks :) +dist-hook: + @echo "Fix up manpage source timestamps" && cd $(distdir) && touch $(SRC_ALL_PAGES) + +linkman-driver-names.txt: + @if test x"$(srcdir)" != x"$(builddir)" ; then \ + if ! test -s "$(builddir)/$@" && test -s "$(srcdir)/$(@F)" ; then \ + ln -fs "$(srcdir)/$(@F)" "$(builddir)/" ; \ + fi ; \ + fi + @if test -s "$@" ; then exit 0 ; fi ; \ + (LC_ALL=C; LANG=C; export LC_ALL LANG; \ + for F in $(SRC_DRIVERS_PAGES) ; do echo "$$F" ; done \ + | grep -vE '^nutupsdrv\.txt$$' \ + | sort -n | uniq \ + | sed 's,^\(.*\)\.txt$$,- linkman:\1[8],' ; \ + ) > "$@" + +linkman-drivertool-names.txt: + @if test x"$(srcdir)" != x"$(builddir)" ; then \ + if ! test -s "$(builddir)/$@" && test -s "$(srcdir)/$(@F)" ; then \ + ln -fs "$(srcdir)/$(@F)" "$(builddir)/" ; \ + fi ; \ + fi + @if test -s "$@" ; then exit 0 ; fi ; \ + (LC_ALL=C; LANG=C; export LC_ALL LANG; \ + for F in $(SRC_DRIVERTOOL_PAGES) ; do echo "$$F" ; done \ + | sort -n | uniq \ + | sed 's,^\(.*\)\.txt$$,- linkman:\1[8],' ; \ + ) > "$@" + +# Dependencies are about particular filenames, since over time +# we might have several use-cases for LINKMAN_INCLUDE_GENERATED: +$(LINKMAN_INCLUDE_CONSUMERS): linkman-driver-names.txt linkman-drivertool-names.txt all: -html-man: $(HTML_MANS) index.html +all-html html-man: $(HTML_MANS) index.html +# Have a way to build all man pages, not just those that fit currently +# configured drivers, daemons, developer aspect, etc. +all-man man-man: $(MAN_MANS) + +@SKIP_MANS_FALSE@@WITH_MANS_TRUE@check-local: check-man +@SKIP_MANS_TRUE@@WITH_MANS_TRUE@check-local: check-man-txt check-man-pages +@SKIP_MANS_TRUE@@WITH_MANS_TRUE@ @echo "Man-page generation was SKIPPED per user request, so pregenerated pages were sanity-checked (if any)" >&2 +@WITH_MANS_FALSE@check-local: check-man-txt check-man-pages +@WITH_MANS_FALSE@ @echo "Man-page generation was not done, so pregenerated pages were sanity-checked (if any)" >&2 + +check-man: check-man-txt check-man-pages check-html-man + +# the "for" loops might better use $^ but it might be not portable +check-man-html: check-html-man + +check-html-man: $(HTML_MANS) + @FAILED=""; CHECKED=0; LANG=C; LC_ALL=C; export LANG; export LC_ALL; \ + for F in $(HTML_MANS) ; do \ + CHECKED="`expr $$CHECKED + 1`"; \ + test -s "$$F" && { file "$$F" | $(EGREP) -i '(XML|HTML.*document)' > /dev/null ; } || FAILED="$$FAILED $$F" ; \ + done; if test -n "$$FAILED" ; then \ + echo "FAILED HTML-man sanity check for:$$FAILED" >&2 ; file $$FAILED >&2 ; exit 1; \ + fi; echo "PASSED HTML-man sanity check (checked $$CHECKED files)"; exit 0 + +# Note: many man-pages here have code samples and are mis-identified as C code +check-man-page: check-man-pages + +# Man-pages may be pre-generated (srcdir), or re-built (builddir) +check-man-pages: $(MAN_MANS) + @FAILED=""; CHECKED=0; LANG=C; LC_ALL=C; export LANG; export LC_ALL; \ + for F in $(MAN_MANS) ; do \ + CHECKED="`expr $$CHECKED + 1`"; \ + ( test -s "$(abs_srcdir)/$$F" && { file "$(abs_srcdir)/$$F" | $(EGREP) -i '(roff.* input|C source|ASCII text)' > /dev/null ; } ) || \ + ( test -s "$(abs_builddir)/$$F" && { file "$(abs_builddir)/$$F" | $(EGREP) -i '(roff.* input|C source|ASCII text)' > /dev/null ; } ) || \ + FAILED="$$FAILED $$F" ; \ + done; if test -n "$$FAILED" ; then \ + echo "FAILED man-page sanity check for:$$FAILED" >&2 ; \ + ( echo "SRCDIR:"; cd "$(abs_srcdir)/" && file $$FAILED ; \ + echo "BUILDDIR:"; cd "$(abs_builddir)/" && file $$FAILED ; \ + ) >&2 ; exit 1; \ + fi; echo "PASSED man-page sanity check (checked $$CHECKED files)"; exit 0 + +check-man-source: check-man-txt + +# Note: (GNU) make can helpfully add VPATH to the short source filenames +# which we had listed above, so the "case" below handles two possibilities +check-man-txt: $(SRC_ALL_PAGES) + @FAILED=""; CHECKED=0; LANG=C; LC_ALL=C; export LANG; export LC_ALL; \ + ( cd $(abs_srcdir) ) || exit; \ + for F in $(SRC_ALL_PAGES) ; do \ + CHECKED="`expr $$CHECKED + 1`"; \ + case "$$F" in \ + */*) ;; \ + *) F="$(abs_srcdir)/$$F" ;; \ + esac ; \ + test -s "$$F" && { file "$$F" | $(EGREP) -i '(ASCII|UTF-8|Unicode|ISO-8859|English).* text' > /dev/null ; } || FAILED="$$FAILED $$F" ; \ + done; if test -n "$$FAILED" ; then \ + echo "FAILED man-source sanity check for:$$FAILED" >&2 ; file $$FAILED >&2 ; exit 1; \ + fi; echo "PASSED man-source sanity check (checked $$CHECKED files)"; exit 0 + +### Regarding absolute paths in attributes below: by default asciidoc +### resolves include paths relative to the main document, so while we +### see the relative builddir as "." in the makefile, for included +### data it would mean the source directory where the .txt resides. @HAVE_ASCIIDOC_TRUE@.txt.html: -@HAVE_ASCIIDOC_TRUE@ $(ASCIIDOC) --backend=xhtml11 \ -@HAVE_ASCIIDOC_TRUE@ --attribute localdate=`TZ=UTC date +%Y-%m-%d` \ -@HAVE_ASCIIDOC_TRUE@ --attribute localtime=`TZ=UTC date +%H:%M:%S` \ +@HAVE_ASCIIDOC_TRUE@ @A2X_OUTDIR="tmp/man-html.$(@F).$$$$" ; \ +@HAVE_ASCIIDOC_TRUE@ echo " DOC-MAN-HTML Generating $@"; \ +@HAVE_ASCIIDOC_TRUE@ $(DOCBUILD_BEGIN) ; RES=0; \ +@HAVE_ASCIIDOC_TRUE@ $(ASCIIDOC) --backend=xhtml11 $${A2X_VERBOSE} \ +@HAVE_ASCIIDOC_TRUE@ --attribute localdate="`TZ=UTC date +%Y-%m-%d`" \ +@HAVE_ASCIIDOC_TRUE@ --attribute localtime="`TZ=UTC date +%H:%M:%S`" \ @HAVE_ASCIIDOC_TRUE@ --attribute nutversion="@PACKAGE_VERSION@" \ -@HAVE_ASCIIDOC_TRUE@ -o $@ $< +@HAVE_ASCIIDOC_TRUE@ --attribute srcdir="$(abs_srcdir)" \ +@HAVE_ASCIIDOC_TRUE@ --attribute builddir="$(abs_builddir)" \ +@HAVE_ASCIIDOC_TRUE@ -o "$${A2X_OUTDIR}/$(@F)" $< || RES=$$? ; \ +@HAVE_ASCIIDOC_TRUE@ $(DOCBUILD_END) ; exit $$RES @HAVE_ASCIIDOC_TRUE@.txt.1: -@HAVE_ASCIIDOC_TRUE@ $(A2X) $(A2X_MANPAGE_OPTS) $< +@HAVE_ASCIIDOC_TRUE@ @A2X_OUTDIR="tmp/man1.$(@F).$$$$" ; \ +@HAVE_ASCIIDOC_TRUE@ echo " DOC-MAN Generating $@"; \ +@HAVE_ASCIIDOC_TRUE@ $(DOCBUILD_BEGIN) ; RES=0; \ +@HAVE_ASCIIDOC_TRUE@ $(A2X) $(A2X_MANPAGE_OPTS) $< || RES=$$? ; \ +@HAVE_ASCIIDOC_TRUE@ $(DOCBUILD_END) ; exit $$RES @HAVE_ASCIIDOC_TRUE@.txt.3: -@HAVE_ASCIIDOC_TRUE@ $(A2X) $(A2X_MANPAGE_OPTS) $< +@HAVE_ASCIIDOC_TRUE@ @A2X_OUTDIR="tmp/man3.$(@F).$$$$" ; \ +@HAVE_ASCIIDOC_TRUE@ echo " DOC-MAN Generating $@"; \ +@HAVE_ASCIIDOC_TRUE@ $(DOCBUILD_BEGIN) ; RES=0; \ +@HAVE_ASCIIDOC_TRUE@ $(A2X) $(A2X_MANPAGE_OPTS) $< || RES=$$? ; \ +@HAVE_ASCIIDOC_TRUE@ $(DOCBUILD_END) ; exit $$RES @HAVE_ASCIIDOC_TRUE@.txt.5: -@HAVE_ASCIIDOC_TRUE@ $(A2X) $(A2X_MANPAGE_OPTS) $< +@HAVE_ASCIIDOC_TRUE@ @A2X_OUTDIR="tmp/man5.$(@F).$$$$" ; \ +@HAVE_ASCIIDOC_TRUE@ echo " DOC-MAN Generating $@"; \ +@HAVE_ASCIIDOC_TRUE@ $(DOCBUILD_BEGIN) ; RES=0; \ +@HAVE_ASCIIDOC_TRUE@ $(A2X) $(A2X_MANPAGE_OPTS) $< || RES=$$? ; \ +@HAVE_ASCIIDOC_TRUE@ $(DOCBUILD_END) ; exit $$RES @HAVE_ASCIIDOC_TRUE@.txt.8: -@HAVE_ASCIIDOC_TRUE@ $(A2X) $(A2X_MANPAGE_OPTS) $< +@HAVE_ASCIIDOC_TRUE@ @A2X_OUTDIR="tmp/man8.$(@F).$$$$" ; \ +@HAVE_ASCIIDOC_TRUE@ echo " DOC-MAN Generating $@"; \ +@HAVE_ASCIIDOC_TRUE@ $(DOCBUILD_BEGIN) ; RES=0; \ +@HAVE_ASCIIDOC_TRUE@ $(A2X) $(A2X_MANPAGE_OPTS) $< || RES=$$? ; \ +@HAVE_ASCIIDOC_TRUE@ $(DOCBUILD_END) ; exit $$RES @HAVE_ASCIIDOC_FALSE@.txt.html: -@HAVE_ASCIIDOC_FALSE@ @if [ -r "$@" ]; then \ +@HAVE_ASCIIDOC_FALSE@ @if [ -r "$@" ] $(SRC_PREBUILT_CLAUSE); then \ @HAVE_ASCIIDOC_FALSE@ echo "Not (re)building $@ manual page, since 'asciidoc', 'xmllint' or 'xsltproc' were not found." ; \ @HAVE_ASCIIDOC_FALSE@ else \ @HAVE_ASCIIDOC_FALSE@ echo "Could not find prebuilt $@ manual page." ; \ @@ -1295,7 +1656,7 @@ html-man: $(HTML_MANS) index.html @HAVE_ASCIIDOC_FALSE@ fi @HAVE_ASCIIDOC_FALSE@.txt.1: -@HAVE_ASCIIDOC_FALSE@ @if [ -r "$@" ]; then \ +@HAVE_ASCIIDOC_FALSE@ @if [ -r "$@" ] $(SRC_PREBUILT_CLAUSE); then \ @HAVE_ASCIIDOC_FALSE@ echo "Not (re)building $@ manual page, since 'asciidoc', 'xmllint' or 'xsltproc' were not found." ; \ @HAVE_ASCIIDOC_FALSE@ else \ @HAVE_ASCIIDOC_FALSE@ echo "Could not find prebuilt $@ manual page." ; \ @@ -1304,7 +1665,7 @@ html-man: $(HTML_MANS) index.html @HAVE_ASCIIDOC_FALSE@ fi @HAVE_ASCIIDOC_FALSE@.txt.3: -@HAVE_ASCIIDOC_FALSE@ @if [ -r "$@" ]; then \ +@HAVE_ASCIIDOC_FALSE@ @if [ -r "$@" ] $(SRC_PREBUILT_CLAUSE); then \ @HAVE_ASCIIDOC_FALSE@ echo "Not (re)building $@ manual page, since 'asciidoc', 'xmllint' or 'xsltproc' were not found." ; \ @HAVE_ASCIIDOC_FALSE@ else \ @HAVE_ASCIIDOC_FALSE@ echo "Could not find prebuilt $@ manual page." ; \ @@ -1313,7 +1674,7 @@ html-man: $(HTML_MANS) index.html @HAVE_ASCIIDOC_FALSE@ fi @HAVE_ASCIIDOC_FALSE@.txt.5: -@HAVE_ASCIIDOC_FALSE@ @if [ -r "$@" ]; then \ +@HAVE_ASCIIDOC_FALSE@ @if [ -r "$@" ] $(SRC_PREBUILT_CLAUSE); then \ @HAVE_ASCIIDOC_FALSE@ echo "Not (re)building $@ manual page, since 'asciidoc', 'xmllint' or 'xsltproc' were not found." ; \ @HAVE_ASCIIDOC_FALSE@ else \ @HAVE_ASCIIDOC_FALSE@ echo "Could not find prebuilt $@ manual page." ; \ @@ -1322,7 +1683,7 @@ html-man: $(HTML_MANS) index.html @HAVE_ASCIIDOC_FALSE@ fi @HAVE_ASCIIDOC_FALSE@.txt.8: -@HAVE_ASCIIDOC_FALSE@ @if [ -r "$@" ]; then \ +@HAVE_ASCIIDOC_FALSE@ @if [ -r "$@" ] $(SRC_PREBUILT_CLAUSE); then \ @HAVE_ASCIIDOC_FALSE@ echo "Not (re)building $@ manual page, since 'asciidoc', 'xmllint' or 'xsltproc' were not found." ; \ @HAVE_ASCIIDOC_FALSE@ else \ @HAVE_ASCIIDOC_FALSE@ echo "Could not find prebuilt $@ manual page." ; \ @@ -1330,6 +1691,22 @@ html-man: $(HTML_MANS) index.html @HAVE_ASCIIDOC_FALSE@ exit 1; \ @HAVE_ASCIIDOC_FALSE@ fi +# NOTE: Due to portability, we do not use a GNU percent-wildcard extension: +#%-spellchecked: % Makefile.am $(top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) +# $(MAKE) -s -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC_ONE="$<" SPELLCHECK_DIR="$(srcdir)" $@ + +# NOTE: Portable suffix rules do not allow prerequisites, so we shim them here +# by a wildcard target in case the make implementation can put the two together. +*.txt-spellchecked: Makefile.am $(abs_top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) +.txt.txt-spellchecked: + $(MAKE) -s -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC_ONE="$<" SPELLCHECK_DIR="$(srcdir)" $@ + +spellcheck spellcheck-interactive spellcheck-sortdict: + $(MAKE) -f $(top_builddir)/docs/Makefile SPELLCHECK_SRC="$(SRC_ALL_PAGES)" SPELLCHECK_DIR="$(srcdir)" $@ + +clean-local: + rm -rf tmp + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/docs/man/adelsystem_cbi.8 b/docs/man/adelsystem_cbi.8 new file mode 100644 index 0000000..38c08dc --- /dev/null +++ b/docs/man/adelsystem_cbi.8 @@ -0,0 +1,160 @@ +'\" t +.\" Title: adelsystem_cbi +.\" Author: [see the "AUTHOR" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 +.\" Manual: NUT Manual +.\" Source: Network UPS Tools 2.8.0 +.\" Language: English +.\" +.TH "ADELSYSTEM_CBI" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +adelsystem_cbi \- Driver for the ADELSYSTEM CB/CBI DC\-UPS +.SH "SYNOPSIS" +.sp +\fBadelsystem_cbi\fR \-h +.sp +\fBadelsystem_cbi\fR \-a \fIDEVICE_NAME\fR [\fIOPTIONS\fR] +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +This man page only documents the specific features of the \fBadelsystem_cbi\fR driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. +.sp .5v +.RE +.SH "SUPPORTED HARDWARE" +.sp +This is the driver for the adelsystem cb/cbi dc\-ups devices\&. +.sp +The driver has been tested against CBI2801224A, all in one 12/24Vdc DC\-UPS\&. +.PP +More information about this UPS can be found here: +.RS 4 +https://www\&.adelsystem\&.com/en/products/dc\-ups\-/ +.RE +.SH "EXTRA ARGUMENTS" +.sp +This driver supports the following optional settings in the \fBups.conf\fR(5) file: +.SS "Serial:" +.PP +\fBser_baud_rate\fR=\fIvalue\fR +.RS 4 +A integer specifying the serial port baud rate (default 9600)\&. +.RE +.PP +\fBser_data_bit\fR=\fIvalue\fR +.RS 4 +A integer specifying the serial port data bit (default 8)\&. +.RE +.PP +\fBser_parity\fR=\fIvalue\fR +.RS 4 +A character specifying the serial port parity (default N)\&. +.RE +.PP +\fBser_stop_bit\fR=\fIvalue\fR +.RS 4 +An integer specifying the serial port stop bit (default 1)\&. +.RE +.SS "Modbus:" +.PP +\fBdev_slave_id\fR=\fIvalue\fR +.RS 4 +An integer specifying the device modbus slave ID (default 1)\&. +.RE +.SH "CONFIGURATION" +.sp +Here is an example of adelsystem_cbi driver configuration in \fBups\&.conf\fR file: +.sp +.if n \{\ +.RS 4 +.\} +.nf +[adelsystem_cbi] + driver = adelsystem_cbi + port = /dev/ttyUSB0 + desc = "adelsystem cb/cbi ups driver" + # serial settings + ser_baud_rate = 9600 + ser_parity = N + ser_data_bit = 8 + ser_stop_bit = 1 + # modbus slave id + dev_slave_id = 5 +.fi +.if n \{\ +.RE +.\} +.SH "INSTANT COMMANDS" +.sp +This driver support the following instant commands: +.PP +load\&.off +.RS 4 +executes "instant poweroff" +.RE +.SH "INSTALLATION" +.sp +This driver is not built by default\&. You can build it by installing libmodbus and running configure \-\-with\-modbus=yes\&. +.sp +You also need to give proper permissions on the local serial device file (/dev/ttyUSB0 for example) to allow the run\-time NUT driver user account to access it\&. +.SH "AUTHOR" +.sp +Dimitris Economou +.SH "SEE ALSO" +.SS "The core driver:" +.sp +\fBnutupsdrv\fR(8), \fBups.conf\fR(5) +.SS "Internet resources:" +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The NUT (Network UPS Tools) home page: +http://www\&.networkupstools\&.org/ +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +libmodbus home page: +http://libmodbus\&.org +.RE diff --git a/docs/man/adelsystem_cbi.txt b/docs/man/adelsystem_cbi.txt new file mode 100644 index 0000000..e8d1bd9 --- /dev/null +++ b/docs/man/adelsystem_cbi.txt @@ -0,0 +1,111 @@ +ADELSYSTEM_CBI(8) +================= + +NAME +---- + +adelsystem_cbi - Driver for the ADELSYSTEM CB/CBI DC-UPS + +SYNOPSIS +-------- + +*adelsystem_cbi* -h + +*adelsystem_cbi* -a 'DEVICE_NAME' ['OPTIONS'] + +NOTE: This man page only documents the specific features of the *adelsystem_cbi* +driver. For information about the core driver, see linkman:nutupsdrv[8]. + +SUPPORTED HARDWARE +------------------ + +This is the driver for the adelsystem cb/cbi dc-ups devices. + +The driver has been tested against CBI2801224A, all in one 12/24Vdc DC-UPS. + +More information about this UPS can be found here: :: +https://www.adelsystem.com/en/products/dc-ups-/ + + +EXTRA ARGUMENTS +--------------- + +This driver supports the following optional settings in the +linkman:ups.conf[5] file: + +Serial: +~~~~~~ + +*ser_baud_rate*='value':: +A integer specifying the serial port baud rate (default 9600). + +*ser_data_bit*='value':: +A integer specifying the serial port data bit (default 8). + +*ser_parity*='value':: +A character specifying the serial port parity (default N). + +*ser_stop_bit*='value':: +An integer specifying the serial port stop bit (default 1). + +Modbus: +~~~~~~ + +*dev_slave_id*='value':: +An integer specifying the device modbus slave ID (default 1). + + +CONFIGURATION +------------- + +Here is an example of adelsystem_cbi driver configuration in *ups.conf* file: +---- +[adelsystem_cbi] + driver = adelsystem_cbi + port = /dev/ttyUSB0 + desc = "adelsystem cb/cbi ups driver" + # serial settings + ser_baud_rate = 9600 + ser_parity = N + ser_data_bit = 8 + ser_stop_bit = 1 + # modbus slave id + dev_slave_id = 5 +---- + +INSTANT COMMANDS +---------------- + +This driver support the following instant commands: + +load.off:: +executes "instant poweroff" + +INSTALLATION +------------ + +This driver is not built by default. You can build it by installing +libmodbus and running `configure --with-modbus=yes`. + +You also need to give proper permissions on the local serial device +file (/dev/ttyUSB0 for example) to allow the run-time NUT driver user +account to access it. + +AUTHOR +------ + +Dimitris Economou + +SEE ALSO +-------- + +The core driver: +~~~~~~~~~~~~~~~~ + +linkman:nutupsdrv[8], linkman:ups.conf[5] + +Internet resources: +~~~~~~~~~~~~~~~~~~~ + +* The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ +* libmodbus home page: http://libmodbus.org diff --git a/docs/man/al175.8 b/docs/man/al175.8 index 5c48bf8..40cdc34 100644 --- a/docs/man/al175.8 +++ b/docs/man/al175.8 @@ -1,13 +1,13 @@ '\" t .\" Title: al175 .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "AL175" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "AL175" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -46,7 +46,7 @@ Eltek MPSU4000 with AL175 alarm module .RE .\} .sp -It may also work with other UPSes equiped with AL175 alarm module, but they have not been tested\&. +It may also work with other UPSes equipped with AL175 alarm module, but they have not been tested\&. .sp AL175 have to be configured to operate in COMLI mode\&. See documentation supplied with your hardware on how to do it\&. .SH "EXTRA ARGUMENTS" diff --git a/docs/man/al175.txt b/docs/man/al175.txt index fc4f202..7ba616b 100644 --- a/docs/man/al175.txt +++ b/docs/man/al175.txt @@ -3,21 +3,24 @@ AL175(8) NAME ---- + al175 - Driver for Eltek UPS models with AL175 alarm module NOTE ---- + This man page only documents the hardware-specific features of the *al175* driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + The *al175* driver is known to work with the following UPSes: Eltek MPSU4000 with AL175 alarm module -It may also work with other UPSes equiped with AL175 alarm module, +It may also work with other UPSes equipped with AL175 alarm module, but they have not been tested. @@ -26,11 +29,13 @@ See documentation supplied with your hardware on how to do it. EXTRA ARGUMENTS --------------- + This driver does not support any extra settings in the linkman:ups.conf[5]. INSTANT COMMANDS ---------------- + This driver supports some extra commands (see linkman:upscmd[8]): *test.battery.start*:: @@ -41,6 +46,7 @@ Stop a battery test. VARIABLES --------- + Besides status, this driver reads UPS state into following variables: - *ups.test.result* @@ -53,12 +59,14 @@ Besides status, this driver reads UPS state into following variables: KNOWN ISSUES AND BUGS --------------------- + * Shutdown is not supported. FIXME * The driver was reworked to meet the project code quality criteria, without testing on real hardware. Some bugs may have crept in. AUTHOR ------ + Kirill Smelkov SEE ALSO @@ -66,8 +74,10 @@ SEE ALSO The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/apcsmart-old.8 b/docs/man/apcsmart-old.8 index d4e2d85..829d0be 100644 --- a/docs/man/apcsmart-old.8 +++ b/docs/man/apcsmart-old.8 @@ -1,13 +1,13 @@ '\" t .\" Title: apcsmart-old -.\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "APCSMART\-OLD" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "APCSMART\-OLD" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -112,9 +112,13 @@ Mode 4 exploits an oddity in the CS 350 models since they only seem to support t Some older APC UPS models return bogus data in the status register during a front panel test\&. This is usually detected and discarded, but some other unexpected values have occasionally slipped through\&. .sp APC UPS models with both USB and serial ports require a power cycle when switching from USB communication to serial, and perhaps vice versa\&. -.SH "AUTHOR" +.SH "AUTHORS AND HISTORY" .sp -Nigel Metheringham (drawing heavily on the original apcsmart driver by Russell Kroll)\&. This driver was called newapc for a time and was renamed in the 1\&.5 series\&. In 2\&.6\&.2 the driver was renamed to apcsmart\-old, being superseded by updated version with new features\&. +Nigel Metheringham (drawing heavily on the original apcsmart driver by Russell Kroll)\&. +.sp +This driver was called newapc for a time and was renamed in the 1\&.5 series\&. +.sp +In 2\&.6\&.2 the driver was renamed to apcsmart\-old, being superseded by updated version with new features\&. .SH "SEE ALSO" .SS "The core driver:" .sp diff --git a/docs/man/apcsmart-old.txt b/docs/man/apcsmart-old.txt index 43ed048..6ca4cff 100644 --- a/docs/man/apcsmart-old.txt +++ b/docs/man/apcsmart-old.txt @@ -1,7 +1,7 @@ APCSMART-OLD(8) =============== -NAME +NAME ---- apcsmart-old - Driver for American Power Conversion Smart Protocol UPS equipment @@ -83,21 +83,27 @@ other unexpected values have occasionally slipped through. APC UPS models with both USB and serial ports require a power cycle when switching from USB communication to serial, and perhaps vice versa. -AUTHOR ------- +AUTHORS AND HISTORY +------------------- + Nigel Metheringham (drawing -heavily on the original apcsmart driver by Russell Kroll). This driver -was called newapc for a time and was renamed in the 1.5 series. In 2.6.2 -the driver was renamed to apcsmart-old, being superseded by updated version -with new features. +heavily on the original `apcsmart` driver by Russell Kroll). + +This driver was called `newapc` for a time and was renamed in +the 1.5 series. + +In 2.6.2 the driver was renamed to `apcsmart-old`, being superseded +by updated version with new features. SEE ALSO -------- The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/apcsmart.8 b/docs/man/apcsmart.8 index 30d20d5..24000cf 100644 --- a/docs/man/apcsmart.8 +++ b/docs/man/apcsmart.8 @@ -1,13 +1,13 @@ '\" t .\" Title: apcsmart -.\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "APCSMART" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "APCSMART" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -89,7 +89,7 @@ Smart\-UPS 900I .PP "new" models .RS 4 -These models usually come from late 1990s / pre\-2009 times\&. They are often referred as "3rd\&. gen"\&. For the most part, they have programmable EEPROM, report supported commands and capabilites, and should work just fine with the apcsmart driver\&. +These models usually come from late 1990s / pre\-2009 times\&. They are often referred as "3rd\&. gen"\&. For the most part, they have programmable EEPROM, report supported commands and capabilities, and should work just fine with the apcsmart driver\&. .RE .PP "microlink" models @@ -99,9 +99,11 @@ WARNING: these are not supported by \fBapcsmart\fR (or -\fBapcupsd\fR, for that matter, if you\(cqre wondering)\&. Around 2007, APC (now APC Schneider) decided to go back to its proprietry roots, and all the new models (SMT, SMX, SURTD) use completely different protocol and cables\&. If you purchased a new APC UPS \- that uses cable with RJ45 on the one end, and DB\-9 on the other \- then you have such model\&. Your only option to support it through +\fBapcupsd\fR, for that matter, if you\(cqre wondering)\&. Around 2007, APC (now APC Schneider) decided to go back to its proprietary roots, and all the new models (SMT, SMX, SURTD) use completely different protocol and cables\&. If you purchased a new APC UPS \- that uses cable with RJ45 on the one end, and DB\-9 on the other \- then you have such model\&. Your only option to support it through \fBNUT\fR -is to purchase a "legacy communications card" \- part #AP9620 (google \*(AqAP9620\*(Aq for more details)\&. Or if that\(cqs not an option, rely on official software\&. +is to purchase a "legacy communications card" \- part #AP9620 (google +\fIAP9620\fR +for more details)\&. Or if that\(cqs not an option, rely on official software\&. .RE .PP Microsol models @@ -140,7 +142,7 @@ Back\-UPS BZ2200BI\-BR Another thing to remember is that Smart protocol is not USB protocol\&. If you have UPS with both USB and serial ports, then depending on how you connect it, you will need either apcsmart or usbhid\-ups driver\&. .SH "CABLING" .sp -This driver expects to see a 940\-0024C cable or a clone by default\&. You can switch to the 940\-0095B dual\-mode cable support with the \*(Aqcable=\*(Aq definition described below\&. +This driver expects to see a 940\-0024C cable or a clone by default\&. You can switch to the 940\-0095B dual\-mode cable support with the \fIcable=\fR definition described below\&. .sp If your 940\-xx24X cable is broken or missing, use this diagram to build a clone: .sp @@ -171,7 +173,7 @@ Alternatively, you can also provide it on the command line using: \-x \fBcable\fR=940\-0095B .SH "TTY MODES" .sp -By default the driver works in canonical mode, but it proved to be a problem in Windows systems\&. Furthermore there\(cqs a possibility of some obscure serial cards or serial\-USB converters that could cause problems as well\&. You can use \*(Aqttymode=\*(Aq option to force non\-canonical discipline in \fBups.conf\fR(5): +By default the driver works in canonical mode, but it proved to be a problem in Windows systems\&. Furthermore there\(cqs a possibility of some obscure serial cards or serial\-USB converters that could cause problems as well\&. You can use \fIttymode=\fR option to force non\-canonical discipline in \fBups.conf\fR(5): .sp \fBttymode\fR=raw .sp @@ -203,47 +205,53 @@ APC hardware supports a lot of shutdown methods, that themselves can differ in b This is most basic command present in probably all APC models\&. It will hibernate the UPS, and subsequently wake it up when the mains supply returns\&. \fBThe command doesn\(cqt work if the UPS is running on mains\&.\fR .PP -"old" models +"old" models: .RS 4 The behaviour here is unfortunately pretty primitive \- when the power returns, the UPS just wakes up\&. No grace periods, no min\&. battery charge condition, etc\&. This is probably not what you want\&. .RE .PP -"new" models +"new" models: .RS 4 -The behaviour here is as expected \- the power is cut off after the EEPROM defined grace period\&. The UPS will wake up when the power returns, after the EEPROM defined delay AND if the EEPROM defined min\&. battery charge level is met\&. The delay is counted from the power\*(Aqs return\&. +The behaviour here is as expected \- the power is cut off after the EEPROM defined grace period\&. The UPS will wake up when the power returns, after the EEPROM defined delay AND if the EEPROM defined min\&. battery charge level is met\&. The delay is counted from the power\(cqs return\&. .RE .RE .PP \fBCS\fR (aka "force OB hack") .RS 4 -This is a trick to make UPS power down even if it\*(Aqs running on mains\&. Immediately before issuing +This is a trick to make UPS power down even if it\(cqs running on mains\&. Immediately before issuing \fBS\fR, "simulate power failure" is issued\&. The remaining behaviour is as in \fBS\fR case\&. .sp +There\(cqs a delay between "simulate power failure" and +\fBS\fR +\- by default set to 3\&.5s\&. You can control it through +\fBcshdelay\fR +option (allowed values are from 0 to 9\&.9)\&. +.sp The name came from APC CS models, where such trick was used to power down UPSes in consistent fashion using only -\fBS\fR\&. It\*(Aqs better to use +\fBS\fR\&. It\(cqs better to use \fB@nnn\fR command if your UPS supports it (and is not too old, see below)\&. .RE .PP \fB@nnn\fR (hard hibernate) .RS 4 -This is basic command used to hibernate UPS regardless if it\*(Aqs running on batteries or on mains\&. The option takes 3 digits argument which can be used to specify additional wakeup delay (in 6 minute units)\&. +This is basic command used to hibernate UPS regardless if it\(cqs running on batteries or on mains\&. The option takes 3 digits argument which can be used to specify additional wake\-up delay (in 6 minute units)\&. .PP -"old" models +"old" models: .RS 4 -The behaviour is \- unfortunately \- similary primitive to +The behaviour is \- unfortunately \- similarly primitive to \fBS\fR\&. The UPS unconditionally wakes up after nnn*6 minutes \- -\fBit doesn\*(Aqt care if the power returned !\fR -If nnn = 000, then UPS will do precisely nothing\&. On those models you\*(Aqre better specifying nnn > 0, if you can estimate the kind of power problems that might be happening in your environment\&. Another thing to consider with "old" models \- you might lose the connection with the UPS, until it wakes up (with +\fBit doesn\(cqt care if the power returned !\fR +If nnn = 000, then UPS will do precisely nothing\&. On those models you\(cqre better specifying nnn > 0, if you can estimate the kind of power problems that might be happening in your environment\&. Another thing to consider with "old" models \- you might lose the connection with the UPS, until it wakes up (with \fBS\fR, the serial connection is kept alive)\&. .RE .PP -"new" models +"new" models: .RS 4 All the usual variables defined in EEPROM are respected (see -\fBS\fR)\&. Additionally, if nnn > 0, the nnn*6 minutes are added to EEPROM defined delay\&. UPS will not power up if it\*(Aqs running on batteries, contrary to what "old" models used to do \- the combined delay is counted from the moment of power return\&. +\fBS\fR)\&. Additionally, if nnn > 0, the nnn*6 minutes are added to EEPROM defined delay\&. UPS will not power up if it\(cqs running on batteries, contrary to what "old" models used to do \- the combined delay is counted from the moment of power return\&. .RE .sp Supposedly there exist models that take 2 digits instead of 3\&. Just in case, NUT also supports such variation\&. You have to provide exactly 2 digits to trigger it (\fBawd\fR @@ -270,18 +278,18 @@ This option takes a single digit (0\-5) as an argument\&. See below for details\ .PP \fBadvorder\fR=no|[0\-4]+ .RS 4 -This option takes string of digits as an argument\&. Methods listed are tried in turn until one of them succeedes\&. Note that the meaning of digits is different from +This option takes string of digits as an argument\&. Methods listed are tried in turn until one of them succeeds\&. Note that the meaning of digits is different from \fBsdtype\fR\&. See below for details\&. .RE .PP \fBawd\fR=[0\-9]{1,3} .RS 4 -This option lets you specify additional wakeup delay used by +This option lets you specify additional wake\-up delay used by \fB@\fR\&. If you provide exactly 2 digits, the driver will try 2 digits variation (see previous section for more info)\&. Otherwise standard 3 digits variation is used\&. \fBNote: the time unit is 6 minutes !\fR .RE .sp -Keep in mind that \fBsdtype\fR and \fBadvorder\fR are mutually exclusive\&. If \fBadvorder\fR is provided, \fBsdtype\fR is ignored\&. If \fBadvorder\fR is set to \*(Aqno\*(Aq, \fBsdtype\fR is used instead\&. +Keep in mind that \fBsdtype\fR and \fBadvorder\fR are mutually exclusive\&. If \fBadvorder\fR is provided, \fBsdtype\fR is ignored\&. If \fBadvorder\fR is set to \fIno\fR, \fBsdtype\fR is used instead\&. .sp If nothing is provided, \fBNUT\fR will assume \fBsdtype\fR=0 \- which is generally fine for anything not too ancient or not too quirky\&. .SS "SDTYPE" @@ -330,14 +338,14 @@ issue hard hibernate (\fB@\fR) .ps -1 .br .sp -Hard hibernate\*(Aqs additional wakeup delay can be provided by \fBawd\fR\&. +Hard hibernate\(cqs additional wake\-up delay can be provided by \fBawd\fR\&. .sp .5v .RE .SS "ADVORDER" .sp -The argument is either a word \*(Aqno\*(Aq, or a string of 1 \- 5 digits in [0 \- 4] range\&. Each digit maps to the one of shutdown methods supported by APC UPSes\&. Methods listed in this way are tried in order, until one of them succedes\&. +The argument is either a word \fIno\fR, or a string of 1 \- 5 digits in [0 \- 4] range\&. Each digit maps to the one of shutdown methods supported by APC UPSes\&. Methods listed in this way are tried in order, until one of them succeeds\&. .sp -If \fBadvorder\fR is undefined or set to \*(Aqno\*(Aq, \fBsdtype\fR is used instead\&. +If \fBadvorder\fR is undefined or set to \fIno\fR, \fBsdtype\fR is used instead\&. .sp The mapping is as follows: .TS @@ -397,7 +405,7 @@ T} .ps -1 .br .sp -Hard hibernate\*(Aqs additional wakeup delay can be provided by \fBawd\fR\&. +Hard hibernate\(cqs additional wake\-up delay can be provided by \fBawd\fR\&. .sp .5v .RE .SH "IGNORING LB STATE" @@ -435,7 +443,7 @@ This would cause apcsmart to go into shutdown \fIonly\fR if detected battery cha .sp You could ask \- why bother ? Well, the reason is already hinted above\&. APC units can be very picky about the batteries, and their firmware can underestimate the remaining runtime (especially right after going into OB state)\&. \fBignorelb\fR option and \fBoverride\&.*\fR let you remain in control of the UPS, not UPS in control of you\&. .sp -Furthermore, this allows to specify conditions similary to how it\(cqs done in apcupsd daemon, so it should be welcome by people used to that software\&. +Furthermore, this allows to specify conditions similarly to how it\(cqs done in apcupsd daemon, so it should be welcome by people used to that software\&. .SH "SUPPORTED INSTANT COMMANDS" .sp The apcsmart driver exposes following instant commands: @@ -452,7 +460,7 @@ executes "force OB hack" .PP shutdown\&.return at: .RS 4 -executes "hard hibernate" with *6 minutes additional wakeup delay ( format is the same as of +executes "hard hibernate" with *6 minutes additional wake\-up delay ( format is the same as of \fBawd\fR option) .RE @@ -467,7 +475,7 @@ load\&.off executes "instant poweroff" .RE .sp -All the above commands must be issued 2nd time to have any effect (no less than 3 seconds, and no more than 15 seconds after the initial call)\&. Those commands are mostly useful for manual testing, when your machine is not powered by the UPS you\*(Aqre testing\&. +All the above commands must be issued 2nd time to have any effect (no less than 3 seconds, and no more than 15 seconds after the initial call)\&. Those commands are mostly useful for manual testing, when your machine is not powered by the UPS you\(cqre testing\&. .sp Other supported commands: .sp @@ -571,15 +579,19 @@ calibrate\&.stop .RE .SH "PREVIOUS DRIVER VERSION" .sp -Previous driver is still available as \fBapcsmart\-old\fR, should there be any need to use earlier version (bugs, incompatiblities with new functionality, etc\&.)\&. In due time, \fBapcsmart\-old\fR will be phased out completely, but this won\(cqt happen until the new version gets solid exposure with no pending issues\&. +Previous driver is still available as \fBapcsmart\-old\fR, should there be any need to use earlier version (bugs, incompatibilities with new functionality, etc\&.)\&. In due time, \fBapcsmart\-old\fR will be phased out completely, but this won\(cqt happen until the new version gets solid exposure with no pending issues\&. .SH "BUGS" .sp Some older APC UPS models return bogus data in the status register during a front panel test\&. This is usually detected and discarded, but some other unexpected values have occasionally slipped through\&. .sp APC UPS models with both USB and serial ports require a power cycle when switching from USB communication to serial, and perhaps vice versa\&. -.SH "AUTHOR" +.SH "AUTHORS AND HISTORY" .sp -Nigel Metheringham (drawing heavily on the original apcsmart driver by Russell Kroll)\&. This driver was called newapc for a time and was renamed in the 1\&.5 series\&. In 2\&.6\&.2 it was renamed to apcsmart\-old, being superseded by updated version with new features, which is maintained by Michal Soltys +Nigel Metheringham (drawing heavily on the original apcsmart driver by Russell Kroll)\&. +.sp +This driver was called newapc for a time and was renamed in the 1\&.5 series\&. +.sp +In 2\&.6\&.2 it was renamed to apcsmart\-old, being superseded by updated version with new features, which is maintained by Michal Soltys .SH "SEE ALSO" .sp \fBnutupsdrv\fR(8), \fBups.conf\fR(5), \fBusbhid-ups\fR(8), \fBsolis\fR(8) diff --git a/docs/man/apcsmart.txt b/docs/man/apcsmart.txt index 6a474c7..503ff57 100644 --- a/docs/man/apcsmart.txt +++ b/docs/man/apcsmart.txt @@ -1,7 +1,7 @@ APCSMART(8) =========== -NAME +NAME ---- apcsmart - Driver for American Power Conversion Smart Protocol UPS equipment @@ -46,18 +46,18 @@ division isn't strict by any means, and the borders between those are pretty fuz "new" models:: These models usually come from late 1990s / pre-2009 times. They are often referred as "3rd. gen". For the most part, they have programmable EEPROM, - report supported commands and capabilites, and should work just fine with the + report supported commands and capabilities, and should work just fine with the apcsmart driver. "microlink" models:: WARNING: these are not _natively_ supported by *apcsmart* (or *apcupsd*, for that matter, if you're wondering). Around 2007, APC (now APC Schneider) - decided to go back to its proprietry roots, and all the new models (SMT, + decided to go back to its proprietary roots, and all the new models (SMT, SMX, SURTD) use completely different protocol and cables. If you purchased a new APC UPS - that uses cable with RJ45 on the one end, and DB-9 on the other - then you have such model. Your only option to support it through *NUT* is to purchase a "legacy communications card" - part #AP9620 (google - \'AP9620' for more details). Or if that's not an option, rely on official + 'AP9620' for more details). Or if that's not an option, rely on official software. Microsol models:: @@ -80,7 +80,7 @@ CABLING ------- This driver expects to see a 940-0024C cable or a clone by default. You -can switch to the 940-0095B dual-mode cable support with the \'cable=' +can switch to the 940-0095B dual-mode cable support with the 'cable=' definition described below. If your 940-xx24X cable is broken or missing, use this diagram to build @@ -108,7 +108,7 @@ TTY MODES By default the driver works in canonical mode, but it proved to be a problem in Windows systems. Furthermore there's a possibility of some obscure serial cards or serial-USB converters that could cause problems as well. You can use -\'ttymode=' option to force non-canonical discipline in linkman:ups.conf[5]: +'ttymode=' option to force non-canonical discipline in linkman:ups.conf[5]: *ttymode*=raw @@ -128,48 +128,54 @@ behaviour quite a bit, depending on the model. This is most basic command present in probably all APC models. It will hibernate the UPS, and subsequently wake it up when the mains supply returns. *The command doesn't work if the UPS is running on mains.* - - "old" models::: ++ +-- + "old" models: :: The behaviour here is unfortunately pretty primitive - when the power returns, the UPS just wakes up. No grace periods, no min. battery charge condition, etc. This is probably not what you want. - "new" models::: + "new" models: :: The behaviour here is as expected - the power is cut off after the EEPROM defined grace period. The UPS will wake up when the power returns, after the EEPROM defined delay AND if the EEPROM defined min. - battery charge level is met. The delay is counted from the power\'s + battery charge level is met. The delay is counted from the power's return. - +-- ++ *CS* (aka "force OB hack"):: - This is a trick to make UPS power down even if it\'s running on mains. + This is a trick to make UPS power down even if it's running on mains. Immediately before issuing *S*, "simulate power failure" is issued. The remaining behaviour is as in *S* case. + +There's a delay between "simulate power failure" and *S* - by default set to +3.5s. You can control it through *cshdelay* option (allowed values are from 0 +to 9.9). ++ The name came from APC CS models, where such trick was used to power down -UPSes in consistent fashion using only *S*. It\'s better to use *@nnn* +UPSes in consistent fashion using only *S*. It's better to use *@nnn* command if your UPS supports it (and is not too old, see below). *@nnn* (hard hibernate):: - This is basic command used to hibernate UPS regardless if it\'s + This is basic command used to hibernate UPS regardless if it's running on batteries or on mains. The option takes 3 digits argument which - can be used to specify additional wakeup delay (in 6 minute units). + can be used to specify additional wake-up delay (in 6 minute units). + -- - "old" models::: - The behaviour is - unfortunately - similary primitive to *S*. The UPS - unconditionally wakes up after $$nnn*6$$ minutes - *it doesn\'t care if the + "old" models: :: + The behaviour is - unfortunately - similarly primitive to *S*. The UPS + unconditionally wakes up after $$nnn*6$$ minutes - *it doesn't care if the power returned !* If nnn = 000, then UPS will do precisely nothing. On - those models you\'re better specifying nnn > 0, if you can estimate + those models you're better specifying nnn > 0, if you can estimate the kind of power problems that might be happening in your environment. Another thing to consider with "old" models - you might lose the connection with the UPS, until it wakes up (with *S*, the serial connection is kept alive). - "new" models::: + "new" models: :: All the usual variables defined in EEPROM are respected (see *S*). Additionally, if nnn > 0, the $$nnn*6$$ minutes are added to EEPROM - defined delay. UPS will not power up if it\'s running on batteries, + defined delay. UPS will not power up if it's running on batteries, contrary to what "old" models used to do - the combined delay is counted from the moment of power return. -- @@ -197,17 +203,17 @@ There are three options used to control the shutdown behaviour. *advorder*=no|[0-4]+:: This option takes string of digits as an argument. Methods listed are tried - in turn until one of them succeedes. Note that the meaning of digits is + in turn until one of them succeeds. Note that the meaning of digits is different from *sdtype*. See below for details. *awd*=[0-9]{1,3}:: - This option lets you specify additional wakeup delay used by *@*. If you + This option lets you specify additional wake-up delay used by *@*. If you provide exactly 2 digits, the driver will try 2 digits variation (see previous section for more info). Otherwise standard 3 digits variation is used. *Note: the time unit is 6 minutes !* Keep in mind that *sdtype* and *advorder* are mutually exclusive. If *advorder* -is provided, *sdtype* is ignored. If *advorder* is set to \'no', *sdtype* is +is provided, *sdtype* is ignored. If *advorder* is set to 'no', *sdtype* is used instead. If nothing is provided, *NUT* will assume *sdtype*=0 - which is generally fine @@ -234,16 +240,16 @@ issue "force OB hack" (*CS*) 5:: issue hard hibernate (*@*) -NOTE: Hard hibernate\'s additional wakeup delay can be provided by *awd*. +NOTE: Hard hibernate's additional wake-up delay can be provided by *awd*. ADVORDER ~~~~~~~~ -The argument is either a word \'no', or a string of 1 - 5 digits in [0 - 4] +The argument is either a word 'no', or a string of 1 - 5 digits in [0 - 4] range. Each digit maps to the one of shutdown methods supported by APC UPSes. -Methods listed in this way are tried in order, until one of them succedes. +Methods listed in this way are tried in order, until one of them succeeds. -If *advorder* is undefined or set to \'no', *sdtype* is used instead. +If *advorder* is undefined or set to 'no', *sdtype* is used instead. The mapping is as follows: @@ -254,7 +260,7 @@ The mapping is as follows: 3:: instant poweroff (*Z*) 4:: "force OB hack" (*CS*) -NOTE: Hard hibernate\'s additional wakeup delay can be provided by *awd*. +NOTE: Hard hibernate's additional wake-up delay can be provided by *awd*. IGNORING LB STATE ----------------- @@ -263,7 +269,7 @@ APC units - even if they report LB mode - will not go into shutdown automatically. This gives us even more control with reference to "when to actually shutdown PSU". Since version 2.6.2, NUT supports *ignorelb* option in driver's section of linkman:ups.conf[5]. When such option is in effect, -the core driver will ignore LB state as reported by specific driver and +the core driver will ignore LB state as reported by specific driver and start shutdown basing the decision _only_ on two conditions: battery.charge < battery.charge.low @@ -289,8 +295,6 @@ shutdown. You might want to disable this condition entirely, when relying on such feature). Simple example: - -[source,conf] ---- [apc] ignorelb @@ -307,7 +311,7 @@ remaining runtime (especially right after going into OB state). *ignorelb* option and *$$override.*$$* let you remain in control of the UPS, not UPS in control of you. -Furthermore, this allows to specify conditions similary to how it's done in +Furthermore, this allows to specify conditions similarly to how it's done in apcupsd daemon, so it should be welcome by people used to that software. @@ -321,7 +325,7 @@ executes soft hibernate shutdown.return cs:: executes "force OB hack" shutdown.return at::: -executes "hard hibernate" with $$*6$$ minutes additional wakeup delay ( format +executes "hard hibernate" with $$*6$$ minutes additional wake-up delay ( format is the same as of *awd* option) shutdown.stayoff:: executes "delayed poweroff" @@ -331,7 +335,7 @@ executes "instant poweroff" All the above commands must be issued 2nd time to have any effect (no less than 3 seconds, and no more than 15 seconds after the initial call). Those commands are mostly useful for manual testing, when your machine is not powered by the UPS -you\'re testing. +you're testing. Other supported commands: @@ -349,7 +353,7 @@ PREVIOUS DRIVER VERSION ----------------------- Previous driver is still available as *apcsmart-old*, should there be any need to -use earlier version (bugs, incompatiblities with new functionality, etc.). In +use earlier version (bugs, incompatibilities with new functionality, etc.). In due time, *apcsmart-old* will be phased out completely, but this won't happen until the new version gets solid exposure with no pending issues. @@ -363,14 +367,18 @@ other unexpected values have occasionally slipped through. APC UPS models with both USB and serial ports require a power cycle when switching from USB communication to serial, and perhaps vice versa. -AUTHOR ------- +AUTHORS AND HISTORY +------------------- Nigel Metheringham (drawing -heavily on the original apcsmart driver by Russell Kroll). This driver -was called newapc for a time and was renamed in the 1.5 series. In 2.6.2 -it was renamed to apcsmart-old, being superseded by updated version with -new features, which is maintained by Michal Soltys +heavily on the original `apcsmart` driver by Russell Kroll). + +This driver was called `newapc` for a time and was renamed in +the 1.5 series. + +In 2.6.2 it was renamed to `apcsmart-old`, being superseded by +updated version with new features, which is maintained by Michal +Soltys SEE ALSO -------- @@ -380,6 +388,7 @@ linkman:solis[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ // vim: tw=80 ai si ts=8 sts=4 sw=4 et : diff --git a/docs/man/apcupsd-ups.8 b/docs/man/apcupsd-ups.8 index 9035797..c8e4657 100644 --- a/docs/man/apcupsd-ups.8 +++ b/docs/man/apcupsd-ups.8 @@ -1,13 +1,13 @@ '\" t .\" Title: apcupsd-ups .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "APCUPSD\-UPS" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "APCUPSD\-UPS" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -34,7 +34,7 @@ apcupsd-ups \- Driver for apcupsd client access This man page only documents the specific features of the \fBapcupsd\-ups\fR driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. .SH "DESCRIPTION" .sp -This driver is a client to \fBapcupsd\fR\&. +This driver is a client to \fBapcupsd\fR (another UPS monitoring project)\&. .sp \fBapcupsd\-ups\fR acts as an \fBapcupsd\fR client, simply forwarding data\&. This can be useful in cases where both protocols are required in a network, or in case apcupsd has a required UPS access mode missing from NUT\&. .SH "EXTRA ARGUMENTS" @@ -62,7 +62,7 @@ For instance: .\} .SH "BACKGROUND" .sp -This driver was originally written in one evening to allow interworking with \fBapcupsd\fR\&. +This driver was originally written in one evening to allow interoperating with \fBapcupsd\fR\&. .SH "SUPPORTED VARIABLES" .sp The following variables are translated from \fBapcupsd\fR to NUT\&. All times should be converted to seconds (please file a bug if you notice a mismatch in units)\&. @@ -352,6 +352,26 @@ Andreas Steinmetz \fBups.conf\fR(5), \fBnutupsdrv\fR(8) .SS "Internet Resources:" .sp -The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The NUT (Network UPS Tools) home page: +http://www\&.networkupstools\&.org/ +.RE .sp -The apcupsd home page: http://www\&.apcupsd\&.org/ +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The apcupsd home page: +http://www\&.apcupsd\&.org/ +.RE diff --git a/docs/man/apcupsd-ups.txt b/docs/man/apcupsd-ups.txt index 6c56aee..1017bd2 100644 --- a/docs/man/apcupsd-ups.txt +++ b/docs/man/apcupsd-ups.txt @@ -3,17 +3,20 @@ APCUPSD-UPS(8) NAME ---- + apcupsd-ups - Driver for apcupsd client access NOTE ---- + This man page only documents the specific features of the *apcupsd-ups* driver. For information about the core driver, see linkman:nutupsdrv[8]. DESCRIPTION ----------- -This driver is a client to *apcupsd*. + +This driver is a client to *apcupsd* (another UPS monitoring project). *apcupsd-ups* acts as an *apcupsd* client, simply forwarding data. This can be useful in cases where both protocols are required in a network, @@ -37,13 +40,15 @@ For instance: BACKGROUND ---------- -This driver was originally written in one evening to allow interworking with *apcupsd*. +This driver was originally written in one evening to allow interoperating +with *apcupsd*. SUPPORTED VARIABLES ------------------- -The following variables are translated from *apcupsd* to NUT. All times should be -converted to seconds (please file a bug if you notice a mismatch in units). +The following variables are translated from *apcupsd* to NUT. +All times should be converted to seconds (please file a bug +if you notice a mismatch in units). [width="50%",cols="m,m",options="header"] |=============================== @@ -85,6 +90,7 @@ converted to seconds (please file a bug if you notice a mismatch in units). LIMITATIONS ----------- + Access to *apcupsd* is strictly read only: no commands can be issued. This stems from the design of *apcupsd*, where the settings are changed in *apctest*. In order to run *apctest*, *apcupsd* must be stopped (and *apcupsd* @@ -92,6 +98,7 @@ exposes the UPS to the network). AUTHOR ------ + Andreas Steinmetz SEE ALSO @@ -102,6 +109,6 @@ linkman:nutupsdrv[8] Internet Resources: ~~~~~~~~~~~~~~~~~~~ -The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ -The apcupsd home page: http://www.apcupsd.org/ +* The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ +* The apcupsd home page: http://www.apcupsd.org/ diff --git a/docs/man/asem.8 b/docs/man/asem.8 index 8f594e6..7903235 100644 --- a/docs/man/asem.8 +++ b/docs/man/asem.8 @@ -1,13 +1,13 @@ '\" t .\" Title: asem -.\" Author: [see the "AUTHORS" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [see the "AUTHOR" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "ASEM" "8" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "ASEM" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -71,7 +71,7 @@ Beware that the SystemIO memory used by the I2C controller is reserved by ACPI\& .SH "KNOWN ISSUES AND BUGS" .sp The driver shutdown function is not implemented, so other arrangements must be made to turn off the UPS\&. -.SH "AUTHORS" +.SH "AUTHOR" .sp Giuseppe Corbelli .SH "SEE ALSO" @@ -80,8 +80,38 @@ Giuseppe Corbelli \fBnutupsdrv\fR(8) .SS "Internet resources:" .sp -PB1300 specifications: http://www\&.asem\&.it/en/products/industrial\-automation/box\-pcs/performance/pb1300/ +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +PB1300 specifications: +http://www\&.asem\&.it/en/products/industrial\-automation/box\-pcs/performance/pb1300/ +.RE .sp -BQ2060 datasheet: http://www\&.ti\&.com/lit/ds/symlink/bq2060\&.pdf +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +BQ2060 datasheet: +http://www\&.ti\&.com/lit/ds/symlink/bq2060\&.pdf +.RE .sp -The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The NUT (Network UPS Tools) home page: +http://www\&.networkupstools\&.org/ +.RE diff --git a/docs/man/asem.txt b/docs/man/asem.txt index 25f67ab..b45cf11 100644 --- a/docs/man/asem.txt +++ b/docs/man/asem.txt @@ -3,16 +3,19 @@ ASEM(8) NAME ---- + asem - driver for UPS in ASEM PB1300 NOTE ---- + This man page only documents the hardware-specific features of the *asem* driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + The *asem* driver supports the UPS in ASEM PB1300 embedded PCs. Likely other I2C devices from the same manufacturer will work too, since this is a "custom" charger. @@ -35,12 +38,13 @@ This driver also supports the following optional settings: *lb*='num':: Set the low battery threshold to 'num' volts. - + *hb*='num':: Set the high battery threshold to 'num' volts. INSTALLATION ------------ + This driver is specific to the Linux I2C API, and requires the lm_sensors libi2c-dev or its equivalent to compile. @@ -60,11 +64,13 @@ DIAGNOSTICS KNOWN ISSUES AND BUGS --------------------- + The driver shutdown function is not implemented, so other arrangements must be made to turn off the UPS. -AUTHORS -------- +AUTHOR +------ + Giuseppe Corbelli SEE ALSO @@ -72,12 +78,13 @@ SEE ALSO The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ -PB1300 specifications: http://www.asem.it/en/products/industrial-automation/box-pcs/performance/pb1300/ -BQ2060 datasheet: http://www.ti.com/lit/ds/symlink/bq2060.pdf - -The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ +* PB1300 specifications: + http://www.asem.it/en/products/industrial-automation/box-pcs/performance/pb1300/ +* BQ2060 datasheet: http://www.ti.com/lit/ds/symlink/bq2060.pdf +* The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/bcmxcp.8 b/docs/man/bcmxcp.8 index 3088755..428f128 100644 --- a/docs/man/bcmxcp.8 +++ b/docs/man/bcmxcp.8 @@ -1,13 +1,13 @@ '\" t .\" Title: bcmxcp .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "BCMXCP" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "BCMXCP" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -58,7 +58,8 @@ Communication speed for the UPS\&. If this is set to 9600, it tries to connect t .sp -1 .IP \(bu 2.3 .\} -\fBshutdown_delay =\fR\fI120\fR +\fBshutdown_delay =\fR +\fI120\fR .RE .sp .RS 4 @@ -69,7 +70,8 @@ Communication speed for the UPS\&. If this is set to 9600, it tries to connect t .sp -1 .IP \(bu 2.3 .\} -\fBbaud_rate =\fR\fInone\fR +\fBbaud_rate =\fR +\fInone\fR .RE .SH "INSTANT COMMANDS" .sp diff --git a/docs/man/bcmxcp.txt b/docs/man/bcmxcp.txt index 3037a9c..037e1b0 100644 --- a/docs/man/bcmxcp.txt +++ b/docs/man/bcmxcp.txt @@ -8,12 +8,14 @@ bcmxcp - Driver for UPSes supporting the serial BCM/XCP protocol NOTE ---- + This man page only documents the hardware-specific features of the bcmxcp driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + This driver should recognize all serial BCM/XCP-compatible UPSes. It has been developed and tested on Powerware PW5115 and PW9120 hardware. If your UPS has a USB connection, you may also consult the linkman:bcmxcp_usb[8] driver @@ -21,11 +23,12 @@ documentation. EXTRA ARGUMENTS --------------- -This driver supports the following optional settings in the + +This driver supports the following optional settings in the linkman:ups.conf[5]. *shutdown_delay=*'delay':: -The number of seconds that the UPS should wait between receiving the +The number of seconds that the UPS should wait between receiving the shutdown command (`upsdrvctl shutdown`) and actually shutting off. *baud_rate=*'rate':: @@ -33,18 +36,20 @@ Communication speed for the UPS. If this is set to 9600, it tries to connect to the UPS at 9600bps. If it fails to communicate, it will go into baud-hunting. It starts at 1200 and goes up to 19200. If it succeeds, it tell you the speed it connected with. If not included in the config, it defaults to baud-hunting. - + DEFAULT VALUES FOR THE EXTRA ARGUMENTS -------------------------------------- + - *shutdown_delay =* '120' - *baud_rate =* 'none' INSTANT COMMANDS ---------------- + This driver supports the following Instant Commands: *shutdown.return*:: -Turn off the load and return when power is back. +Turn off the load and return when power is back. *shutdown.stayoff*:: Turn off the load and remain off. @@ -54,7 +59,7 @@ Start a battery test. *outlet.n.shutdown.return*:: Turn off the load on outlet 'n' and return when power is back. -('n' is the outlet number reported by the upsc command) +('n' is the outlet number reported by the upsc command) TODO LIST --------- @@ -67,22 +72,28 @@ Access the config register to change settings. BUGS ---- + None known. AUTHOR ------ + Tore Ørpetveit SEE ALSO -------- + The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] The USB BCM/XCP driver: ~~~~~~~~~~~~~~~~~~~~~~~ + linkman:bcmxcp_usb[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/bcmxcp_usb.8 b/docs/man/bcmxcp_usb.8 index 77ed3f1..60e2adf 100644 --- a/docs/man/bcmxcp_usb.8 +++ b/docs/man/bcmxcp_usb.8 @@ -1,13 +1,13 @@ '\" t .\" Title: bcmxcp_usb -.\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [see the "AUTHORS" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "BCMXCP_USB" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "BCMXCP_USB" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -71,7 +71,7 @@ Start a battery test\&. BCM/XCP supports reporting a wide range of UPS alarm conditions\&. .RE .PP -\fBReport UPS statistics informations\fR +\fBReport UPS statistics information\fR .RS 4 BCM/XCP supports reporting of UPS statistics data\&. .RE @@ -102,9 +102,29 @@ bcmxcp_usb only supports 1 UPS at this time\&. You can put the "auto" value for .SS ""Got EPERM: Operation not permitted upon driver startup"" .sp You have forgotten to install the hotplug files, as explained in the INSTALLATION section above\&. Don\(cqt forget to restart hotplug so that it applies these changes\&. -.SH "AUTHOR" +.SH "AUTHORS" .sp -Tore Ørpetveit , Wolfgang Ocker +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Tore Ørpetveit +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Wolfgang Ocker +.RE .SH "SEE ALSO" .SS "The core driver:" .sp diff --git a/docs/man/bcmxcp_usb.txt b/docs/man/bcmxcp_usb.txt index a69d631..2eae9f5 100644 --- a/docs/man/bcmxcp_usb.txt +++ b/docs/man/bcmxcp_usb.txt @@ -3,10 +3,12 @@ BCMXCP_USB(8) NAME ---- + bcmxcp_usb - Experimental driver for UPSes supporting the BCM/XCP protocol over USB NOTE ---- + This man page only documents the hardware-specific features of the bcmxcp_usb driver. For information about the core driver, see linkman:nutupsdrv[8]. @@ -14,6 +16,7 @@ This driver is a variant of the serial driver bcmxcp and uses the same core code SUPPORTED HARDWARE ------------------ + This driver should recognize all BCM/XCP-compatible UPSes that are connected via USB. It has been developed and tested on Powerware PW3501 hardware. It also has been tested on PW5110 hardware. @@ -21,23 +24,25 @@ been tested on PW5110 hardware. EXTRA ARGUMENTS --------------- -This driver supports the following optional settings in the +This driver supports the following optional settings in the linkman:ups.conf[5]. *shutdown_delay=*'delay':: -The number of seconds that the UPS should wait between receiving the +The number of seconds that the UPS should wait between receiving the shutdown command and actually shutting off. DEFAULT VALUES FOR THE EXTRA ARGUMENTS -------------------------------------- + *shutdown_delay =*'120' INSTANT COMMANDS ---------------- + This driver supports the following Instant Commands: *shutdown.return*:: -Turn off the load and return when power is back. +Turn off the load and return when power is back. *shutdown.stayoff*:: Turn off the load and remain off. @@ -51,11 +56,12 @@ TODO LIST *Report UPS alarm status*:: BCM/XCP supports reporting a wide range of UPS alarm conditions. -*Report UPS statistics informations*:: +*Report UPS statistics information*:: BCM/XCP supports reporting of UPS statistics data. EXPERIMENTAL DRIVER ------------------- + This driver has been tagged experimental, even if it has been reported to be stable. Thus it is not suitable for production systems and it is not built by default. This is mainly due to the fact that it is a @@ -63,6 +69,7 @@ new driver. INSTALLATION ------------ + This driver is not built by default. You can build it by using "configure --with-usb=yes". Note that it will also install other USB drivers. @@ -74,6 +81,7 @@ must have execution flag set (ie using chmod +x ...). IMPLEMENTATION -------------- + bcmxcp_usb only supports 1 UPS at this time. You can put the "auto" value for port in `ups.conf`, i.e.: @@ -83,6 +91,7 @@ bcmxcp_usb only supports 1 UPS at this time. You can put the KNOWN ISSUES AND BUGS --------------------- + "Got EPERM: Operation not permitted upon driver startup" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -90,18 +99,21 @@ You have forgotten to install the hotplug files, as explained in the INSTALLATION section above. Don't forget to restart hotplug so that it applies these changes. -AUTHOR ------- -Tore Ørpetveit , -Wolfgang Ocker +AUTHORS +------- + +* Tore Ørpetveit +* Wolfgang Ocker SEE ALSO -------- The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/belkin.8 b/docs/man/belkin.8 index 07089fa..4798967 100644 --- a/docs/man/belkin.8 +++ b/docs/man/belkin.8 @@ -1,13 +1,13 @@ '\" t .\" Title: belkin -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "BELKIN" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "BELKIN" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -37,6 +37,8 @@ This man page only documents the hardware\-specific features of the belkin drive The \fBbelkin\fR driver is known to support the Regulator Pro 525 (F6C525\-SER)\&. Other similar models such as the 425 and 625 should also work\&. .sp The Trust UPS and older Belkin units are not supported\&. +.sp +This driver only supports serial connections\&. If your UPS has a USB port, please consult the Hardware Compatibility List (HCL) to see which of the USB drivers you should use\&. .SH "EXTRA ARGUMENTS" .sp This driver does not support any extra settings in the \fBups.conf\fR(5)\&. @@ -63,6 +65,9 @@ the driver doesn\(cqt go anywhere near these character sequences, so it won\(cqt .SS "The core driver:" .sp \fBnutupsdrv\fR(8) +.SS "Other Belkin drivers:" +.sp +\fBbelkinunv\fR(8), \fBblazer_ser\fR(8), \fBblazer_usb\fR(8), \fBusbhid-ups\fR(8) .SS "Internet resources:" .sp The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/belkin.txt b/docs/man/belkin.txt index 495201e..57e0320 100644 --- a/docs/man/belkin.txt +++ b/docs/man/belkin.txt @@ -3,27 +3,32 @@ BELKIN(8) NAME ---- - + belkin - Driver for Belkin serial UPS equipment NOTE ---- This man page only documents the hardware-specific features of the -belkin driver. For information about the core driver, see +belkin driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + The *belkin* driver is known to support the Regulator Pro 525 (F6C525-SER). Other similar models such as the 425 and 625 should also work. The Trust UPS and older Belkin units are not supported. +This driver only supports serial connections. If your UPS has a USB port, +please consult the Hardware Compatibility List (HCL) to see which of the USB +drivers you should use. + EXTRA ARGUMENTS --------------- -This driver does not support any extra settings in the +This driver does not support any extra settings in the linkman:ups.conf[5]. BUGS @@ -42,8 +47,18 @@ SEE ALSO The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] +Other Belkin drivers: +~~~~~~~~~~~~~~~~~~~~~ + +linkman:belkinunv[8], +linkman:blazer_ser[8], +linkman:blazer_usb[8], +linkman:usbhid-ups[8] + Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/belkinunv.8 b/docs/man/belkinunv.8 index 13d3ba5..0e18d03 100644 --- a/docs/man/belkinunv.8 +++ b/docs/man/belkinunv.8 @@ -1,13 +1,13 @@ '\" t .\" Title: belkinunv .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "BELKINUNV" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "BELKINUNV" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -32,6 +32,8 @@ belkinunv \- Driver for Belkin "Universal UPS" and compatible .SH "NOTE" .sp This man page only documents the hardware\-specific features of the belkin driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. +.sp +This driver only supports serial connections\&. If your UPS has a USB port, please consult the Hardware Compatibility List (HCL) to see which of the USB drivers you should use\&. .SH "SUPPORTED HARDWARE" .sp The belkinunv driver is known to work with the Belkin Universal UPS models F6C800\-UNV and F6C120\-UNV, and is expected to work with other Belkin Universal UPS models\&. The driver only supports serial communication, not USB\&. @@ -318,10 +320,16 @@ When used with the \fB\-x wait\fR option, the exit status is normally \fB0\fR\&. .SH "EXTRA ARGUMENTS" .sp This driver does not support any extra settings in \fBups.conf\fR(5)\&. +.SH "AUTHOR" +.sp +Peter Selinger .SH "SEE ALSO" .SS "The core driver:" .sp \fBnutupsdrv\fR(8) +.SS "Other Belkin drivers:" +.sp +\fBbelkinunv\fR(8), \fBblazer_ser\fR(8), \fBblazer_usb\fR(8), \fBusbhid-ups\fR(8) .SS "Internet resources:" .sp .RS 4 @@ -346,7 +354,5 @@ http://www\&.networkupstools\&.org/ .\} The documentation for the protocol used by this UPS: belkin\-universal\-ups\&.html +(replica on NUT site) .RE -.SH "AUTHOR" -.sp -Peter Selinger diff --git a/docs/man/belkinunv.txt b/docs/man/belkinunv.txt index cc8bb99..4d8d8c2 100644 --- a/docs/man/belkinunv.txt +++ b/docs/man/belkinunv.txt @@ -8,12 +8,18 @@ belkinunv - Driver for Belkin "Universal UPS" and compatible NOTE ---- + This man page only documents the hardware-specific features of the -belkin driver. For information about the core driver, see +belkin driver. For information about the core driver, see linkman:nutupsdrv[8]. +This driver only supports serial connections. If your UPS has a USB port, +please consult the Hardware Compatibility List (HCL) to see which of the USB +drivers you should use. + SUPPORTED HARDWARE ------------------ + The belkinunv driver is known to work with the Belkin Universal UPS models F6C800-UNV and F6C120-UNV, and is expected to work with other Belkin Universal UPS models. The driver only supports serial @@ -28,6 +34,7 @@ are supported using the linkman:genericups[8] driver with SOFT SHUTDOWN WORKAROUND ------------------------ + One problem with the Belkin Universal UPS is that it cannot enter a soft shutdown (shut down the load until AC power returns) unless the batteries are completely depleted. Thus, one cannot just shut off the @@ -51,7 +58,7 @@ system reboots in this case. If AC power does not come back on, the UPS will eventually run out of batteries, kill the computer's power supply, and go into soft shutdown mode, which means everything will reboot properly when the power returns. In either case, a deadlock is -avoided. +avoided. In addition, if an optional integer argument is given to the *-x wait* option, this causes *belkinunv* to wait not only for AC power to be present, @@ -69,6 +76,7 @@ startup scripts. OPTIONS ------- + See also linkman:nutupsdrv[8] for generic options. Never use the *-k* option with this driver; it does not work properly. @@ -92,7 +100,7 @@ used in a startup script, to ensure the computer remains bootable even if the UPS has been disconnected during the power failure (for instance, you attached your computer to a generator, carried it to a neighbor's house, or -whatever). +whatever). *-x flash*:: This option only has an effect when used in conjunction with the *-x wait* @@ -122,6 +130,7 @@ line. VARIABLES --------- + *battery.charge*:: *battery.runtime*:: @@ -245,7 +254,7 @@ load is online *ACFAIL*:: AC failure. Note that this refers to the AC input, and thus it is not the same as "OB". An AC failure can occur at any time, for instance, -during a battery test, or when the UPS load is off. +during a battery test, or when the UPS load is off. *OVER*:: overload @@ -264,7 +273,7 @@ charging *DEPLETED*:: the battery is depleted. When the UPS raises this flag, it -simultaneously switches off the load. +simultaneously switches off the load. *RB*:: replace battery @@ -323,20 +332,32 @@ EXTRA ARGUMENTS This driver does not support any extra settings in linkman:ups.conf[5]. +AUTHOR +------ + +Peter Selinger + SEE ALSO -------- The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] +Other Belkin drivers: +~~~~~~~~~~~~~~~~~~~~~ + +linkman:belkinunv[8], +linkman:blazer_ser[8], +linkman:blazer_usb[8], +linkman:usbhid-ups[8] + Internet resources: ~~~~~~~~~~~~~~~~~~~ - - The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ - - The documentation for the protocol used by this UPS: -link:http://www.mscs.dal.ca/~selinger/ups/belkin-universal-ups.html[belkin-universal-ups.html] -AUTHOR ------- - -Peter Selinger +* The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ +* The documentation for the protocol used by this UPS: + link:http://www.mscs.dal.ca/~selinger/ups/belkin-universal-ups.html[belkin-universal-ups.html] + (link:https://networkupstools.org/protocols/belkin-universal.html[replica + on NUT site]) diff --git a/docs/man/bestfcom.8 b/docs/man/bestfcom.8 index ec46368..f83b2cb 100644 --- a/docs/man/bestfcom.8 +++ b/docs/man/bestfcom.8 @@ -1,13 +1,13 @@ '\" t .\" Title: bestfcom .\" Author: [see the "AUTHORS" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "BESTFCOM" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "BESTFCOM" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -40,13 +40,49 @@ Best Power Fortress/Ferrups implementing the Fortress UPS Protocol (f\-command s This driver does not support any extra settings in the \fBups.conf\fR(5)\&. .SH "AUTHORS" .sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} Kent Polk (bestfcom) +.RE .sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} Andreas Wrede, John Stone (bestuferrups) +.RE .sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} Grant Taylor (bestfort) +.RE .sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} Russell Kroll (bestups) +.RE .SH "SEE ALSO" .SS "The core driver:" .sp diff --git a/docs/man/bestfcom.txt b/docs/man/bestfcom.txt index d742e8a..6700185 100644 --- a/docs/man/bestfcom.txt +++ b/docs/man/bestfcom.txt @@ -8,38 +8,40 @@ bestfcom - Driver for Best Power Fortress/Ferrups NOTE ---- + This man page only documents the hardware-specific features of the bestfcom driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + Best Power Fortress/Ferrups implementing the Fortress UPS Protocol (f-command set). EXTRA ARGUMENTS --------------- -This driver does not support any extra settings in the +This driver does not support any extra settings in the linkman:ups.conf[5]. AUTHORS ------- -Kent Polk (bestfcom) -Andreas Wrede, John Stone (bestuferrups) - -Grant Taylor (bestfort) - -Russell Kroll (bestups) +* Kent Polk (bestfcom) +* Andreas Wrede, John Stone (bestuferrups) +* Grant Taylor (bestfort) +* Russell Kroll (bestups) SEE ALSO -------- The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/bestfortress.8 b/docs/man/bestfortress.8 index 130fd8c..d96dee0 100644 --- a/docs/man/bestfortress.8 +++ b/docs/man/bestfortress.8 @@ -1,13 +1,13 @@ '\" t .\" Title: bestfortress -.\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [see the "AUTHORS" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "BESTFORTRESS" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "BESTFORTRESS" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -50,9 +50,29 @@ Set the full\-scale value of the \fBups\&.load\fR variable\&. .RE -.SH "AUTHOR" +.SH "AUTHORS" .sp -Holger Dietze , Stuart D\&. Gathman +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Holger Dietze +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Stuart D\&. Gathman +.RE .SH "SEE ALSO" .SS "The core driver:" .sp diff --git a/docs/man/bestfortress.txt b/docs/man/bestfortress.txt index 8bc969a..aac0b8b 100644 --- a/docs/man/bestfortress.txt +++ b/docs/man/bestfortress.txt @@ -15,10 +15,12 @@ linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + This driver supports old Best Fortress UPS equipment using a serial connection. EXTRA ARGUMENTS --------------- + This driver supports the following optional settings in the linkman:ups.conf[5]: @@ -28,22 +30,26 @@ Set the speed of the serial connection - 1200, 2400, 4800 or 9600. *max_load*='VA':: Set the full-scale value of the *ups.load* variable. -AUTHOR ------- -Holger Dietze , -Stuart D. Gathman +AUTHORS +------- + +* Holger Dietze +* Stuart D. Gathman SEE ALSO -------- The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] The newer Best Power drivers: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + linkman:bestups[8], linkman:bestuferrups[8], linkman:bestfcom[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/bestuferrups.8 b/docs/man/bestuferrups.8 index b56a422..1fc7857 100644 --- a/docs/man/bestuferrups.8 +++ b/docs/man/bestuferrups.8 @@ -1,13 +1,13 @@ '\" t .\" Title: bestuferrups .\" Author: [see the "AUTHORS" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "BESTUFERRUPS" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "BESTUFERRUPS" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -40,11 +40,38 @@ Best Power Micro\-Ferrups ME3100, probably other similar models too\&. This driver does not support any extra settings in the \fBups.conf\fR(5)\&. .SH "AUTHORS" .sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} Andreas Wrede, John Stone (bestuferrups) +.RE .sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} Grant Taylor (bestfort) +.RE .sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} Russell Kroll (bestups) +.RE .SH "SEE ALSO" .SS "The core driver:" .sp diff --git a/docs/man/bestuferrups.txt b/docs/man/bestuferrups.txt index 49f4645..cfe857d 100644 --- a/docs/man/bestuferrups.txt +++ b/docs/man/bestuferrups.txt @@ -8,35 +8,38 @@ bestuferrups - Driver for Best Power Micro-Ferrups NOTE ---- + This man page only documents the hardware-specific features of the bestuferrups driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + Best Power Micro-Ferrups ME3100, probably other similar models too. EXTRA ARGUMENTS --------------- -This driver does not support any extra settings in the +This driver does not support any extra settings in the linkman:ups.conf[5]. AUTHORS ------- -Andreas Wrede, John Stone (bestuferrups) -Grant Taylor (bestfort) - -Russell Kroll (bestups) +* Andreas Wrede, John Stone (bestuferrups) +* Grant Taylor (bestfort) +* Russell Kroll (bestups) SEE ALSO -------- The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/bestups.8 b/docs/man/bestups.8 index 0d6ab8e..009477a 100644 --- a/docs/man/bestups.8 +++ b/docs/man/bestups.8 @@ -1,13 +1,13 @@ '\" t .\" Title: bestups -.\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [see the "AUTHORS" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "BESTUPS" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "BESTUPS" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -32,6 +32,11 @@ bestups \- Driver for Best Power / SOLA (Phoenixtec protocol) UPS equipment .SH "NOTE" .sp This man page only documents the hardware\-specific features of the bestups driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. +.SH "NOTE" +.sp +Please note that this driver is deprecated and will not receive new development\&. If it works for managing your devices \(em fine, but if you are running it to try setting up a new device, please consider the newer \fBnutdrv_qx\fR(8) instead, which should handle all \fIQ*\fR protocol variants for NUT\&. +.sp +Please do also report if your device works with this driver, but \fBnutdrv_qx\fR(8) would not actually support it with any subdriver! .SH "SUPPORTED HARDWARE" .sp \fBbestups\fR was designed to monitor Best Power UPS hardware like the Fortress, Fortress Telecom, Axxium Rackmount and Patriot Pro\&. It also recognizes and supports SOLA units such as the 325, 520 and 620\&. In addition, the Best 610 is supported using the \(oqID\(cq option\&. @@ -90,12 +95,32 @@ Example: a Best 610 1\&.5KVA unit would use the string "610,1500,120,120,10\&.0, .sp The battery charge percentage value (in battery\&.charge) is derived from the voltage data that the UPS returns, since the UPS doesn\(cqt return that value directly\&. On some hardware, the charge will remain at 100% for a long time and then drops quickly shortly before the battery runs out\&. You can confirm from the battery\&.voltage readings that this is a problem with the UPS and not this driver\&. .sp -Similarly, the float from the charger in some models forces the battery charge percentage back up to 100% immedately after the UPS goes back on\-line, so you can\(cqt tell when it is really recharged\&. +Similarly, the float from the charger in some models forces the battery charge percentage back up to 100% immediately after the UPS goes back on\-line, so you can\(cqt tell when it is really recharged\&. .sp Finally, some models give one value for the battery\(cqs nominal voltage and yet actually have a nominal voltage slightly below that\&. This leads to things such as the perpetual 98\&.7% charge on the author\(cqs Fortress 750, even when it\(cqs been charging for weeks\&. You can use nombattvolt= in \fBups.conf\fR(8) to fix this\&. -.SH "AUTHOR" +.SH "AUTHORS" .sp -Russell Kroll, Jason White +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Russell Kroll +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Jason White +.RE .SH "SEE ALSO" .SS "The core driver:" .sp diff --git a/docs/man/bestups.txt b/docs/man/bestups.txt index 61704f6..f2904bf 100644 --- a/docs/man/bestups.txt +++ b/docs/man/bestups.txt @@ -10,14 +10,28 @@ NOTE ---- This man page only documents the hardware-specific features of the -bestups driver. For information about the core driver, see +bestups driver. For information about the core driver, see linkman:nutupsdrv[8]. +NOTE +---- + +Please note that this driver is deprecated and will not receive +new development. If it works for managing your devices -- fine, +but if you are running it to try setting up a new device, please +consider the newer linkman:nutdrv_qx[8] instead, which should +handle all 'Q*' protocol variants for NUT. + +Please do also report if your device works with this driver, +but linkman:nutdrv_qx[8] would not actually support it with any +subdriver! + SUPPORTED HARDWARE ------------------ + *bestups* was designed to monitor Best Power UPS hardware like the Fortress, Fortress Telecom, Axxium Rackmount and Patriot Pro. It also recognizes -and supports SOLA units such as the 325, 520 and 620. In addition, the +and supports SOLA units such as the 325, 520 and 620. In addition, the Best 610 is supported using the `ID' option. Other UPS hardware using the Phoenixtec protocol should also work, but @@ -54,31 +68,31 @@ case you can set `battvoltmult = 12` in linkman:ups.conf[8] to fix this. *ID=*'string':: Set the Identification response string. This should only be used -with hardware that supports the Phoenixtec protocol status inquiry -commands, but not the "ID" command, such as the Best/SOLA 610. Format +with hardware that supports the Phoenixtec protocol status inquiry +commands, but not the "ID" command, such as the Best/SOLA 610. Format of the ID string is: AAA,BBBB,CCC,DDD,EE.E,FF.F + AAA is the three-character identification for the UPS model. + -BBBB is the output power in VA (volt amperes). B is an integer number +BBBB is the output power in VA (volt amperes). B is an integer number ranging from 0 to 9. + -CCC is the Nominal Input Voltage. C is an integer number ranging from 0 +CCC is the Nominal Input Voltage. C is an integer number ranging from 0 to 9. The unit is Volts AC. + -DDD is the Nominal Output Voltage. D is an integer number ranging from 0 +DDD is the Nominal Output Voltage. D is an integer number ranging from 0 to 9. The unit is Volts AC. + -EE.E is the Battery Voltage that will cause the UPS to shut itself off. -E is an integer number ranging from 0 to 9. Then unit is Volts DC and a +EE.E is the Battery Voltage that will cause the UPS to shut itself off. +E is an integer number ranging from 0 to 9. Then unit is Volts DC and a decimal point is present. + -FF.F or FFF.F is the Battery Voltage at full charge. F is an integer -number ranging from 0 to 9. Then unit is Volts DC. Typically, for 700VA, -1KVA and 1.5KVA units, the format is FF.F. For 2KVA and 3KVA units, the +FF.F or FFF.F is the Battery Voltage at full charge. F is an integer +number ranging from 0 to 9. Then unit is Volts DC. Typically, for 700VA, +1KVA and 1.5KVA units, the format is FF.F. For 2KVA and 3KVA units, the format is FFF.F. + -Example: a Best 610 1.5KVA unit would use the string +Example: a Best 610 1.5KVA unit would use the string "610,1500,120,120,10.0,48.0". BUGS @@ -89,29 +103,33 @@ the voltage data that the UPS returns, since the UPS doesn't return that value directly. On some hardware, the charge will remain at 100% for a long time and then drops quickly shortly before the battery runs out. You can confirm from the `battery.voltage` readings that this is a problem -with the UPS and not this driver. +with the UPS and not this driver. Similarly, the float from the charger in some models forces the battery -charge percentage back up to 100% immedately after the UPS goes back +charge percentage back up to 100% immediately after the UPS goes back on-line, so you can't tell when it is really recharged. Finally, some models give one value for the battery's nominal voltage and yet actually have a nominal voltage slightly below that. This leads to things such as the perpetual 98.7% charge on the author's Fortress 750, -even when it's been charging for weeks. You can use `nombattvolt=` in +even when it's been charging for weeks. You can use `nombattvolt=` in linkman:ups.conf[8] to fix this. -AUTHOR ------- -Russell Kroll, Jason White +AUTHORS +------- + +* Russell Kroll +* Jason White SEE ALSO -------- The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/blazer-common.txt b/docs/man/blazer-common.txt index 7449624..dc53dc8 100644 --- a/docs/man/blazer-common.txt +++ b/docs/man/blazer-common.txt @@ -1,9 +1,22 @@ NOTE ---- + This man page only documents the hardware-specific features of the blazer driver. For information about the core driver, see linkman:nutupsdrv[8]. +NOTE +---- + +Please note that this driver is deprecated and will not receive +new development. If it works for managing your devices -- fine, +but if you are running it to try setting up a new device, please +consider the newer linkman:nutdrv_qx[8] instead, which should +handle all 'Q*' protocol variants for NUT. + +Please do also report if your device works with this driver, +but linkman:nutdrv_qx[8] would not actually support it with any +subdriver! SUPPORTED HARDWARE ------------------ @@ -144,10 +157,18 @@ Examples: *bus =* 'regex':: -Select a UPS on a specific USB bus or group of busses. The argument is +Select a UPS on a specific USB bus or group of buses. The argument is a regular expression that must match the bus name where the UPS is connected (e.g. bus="002", bus="00[2-3]"). +*device =* 'regex':: + +Select a UPS on a specific USB device or group of devices. The argument is +a regular expression that must match the device name where the UPS is +connected (e.g. device="001", device="00[1-2]"). +Note that device numbers are not guaranteed by the OS to be stable across +re-boots or device re-plugging. + *subdriver =* 'string':: Select a serial-over-USB subdriver to use. You have a choice between *phoenix*, @@ -296,8 +317,8 @@ The temperature and load value is known to be bogus in some models. AUTHORS ------- -Arjen de Korte , -Alexander Gordeev +* Arjen de Korte +* Alexander Gordeev SEE ALSO @@ -315,7 +336,5 @@ linkman:nutupsdrv[8], linkman:upsc[8], linkman:upscmd[8], linkman:upsrw[8] Internet Resources: ~~~~~~~~~~~~~~~~~~~ -The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ - -The NUT HCL: http://www.networkupstools.org/stable-hcl.html - +* The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ +* The NUT HCL: http://www.networkupstools.org/stable-hcl.html diff --git a/docs/man/blazer_ser.8 b/docs/man/blazer_ser.8 index 1939739..dafaaa4 100644 --- a/docs/man/blazer_ser.8 +++ b/docs/man/blazer_ser.8 @@ -1,13 +1,13 @@ '\" t .\" Title: blazer_ser .\" Author: [see the "AUTHORS" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "BLAZER_SER" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "BLAZER_SER" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -32,6 +32,11 @@ blazer_ser \- Driver for Megatec/Q1 protocol serial based UPS equipment .SH "NOTE" .sp This man page only documents the hardware\-specific features of the blazer driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. +.SH "NOTE" +.sp +Please note that this driver is deprecated and will not receive new development\&. If it works for managing your devices \(em fine, but if you are running it to try setting up a new device, please consider the newer \fBnutdrv_qx\fR(8) instead, which should handle all \fIQ*\fR protocol variants for NUT\&. +.sp +Please do also report if your device works with this driver, but \fBnutdrv_qx\fR(8) would not actually support it with any subdriver! .SH "SUPPORTED HARDWARE" .sp The blazer driver is known to work with various UPSes from Blazer, Energy Sistem, Fenton Technologies, General Electric, Mustek and many others\&. The NUT compatibility table lists all the known supported models\&. Keep in mind, however, that other models not listed there may also be supported, but haven\(cqt been tested\&. @@ -260,12 +265,52 @@ Some models report a bogus value for the beeper status (will always be \fIenable The temperature and load value is known to be bogus in some models\&. .SH "AUTHORS" .sp -Arjen de Korte , Alexander Gordeev +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Arjen de Korte +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Alexander Gordeev +.RE .SH "SEE ALSO" .sp \fBblazer_usb\fR(8), \fBnutupsdrv\fR(8), \fBupsc\fR(8), \fBupscmd\fR(8), \fBupsrw\fR(8) .SS "Internet Resources:" .sp -The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The NUT (Network UPS Tools) home page: +http://www\&.networkupstools\&.org/ +.RE .sp -The NUT HCL: http://www\&.networkupstools\&.org/stable\-hcl\&.html +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The NUT HCL: +http://www\&.networkupstools\&.org/stable\-hcl\&.html +.RE diff --git a/docs/man/blazer_usb.8 b/docs/man/blazer_usb.8 index 726070c..262eb78 100644 --- a/docs/man/blazer_usb.8 +++ b/docs/man/blazer_usb.8 @@ -1,13 +1,13 @@ '\" t .\" Title: blazer_usb .\" Author: [see the "AUTHORS" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "BLAZER_USB" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "BLAZER_USB" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -32,6 +32,11 @@ blazer_usb \- Driver for Megatec/Q1 protocol USB based UPS equipment .SH "NOTE" .sp This man page only documents the hardware\-specific features of the blazer driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. +.SH "NOTE" +.sp +Please note that this driver is deprecated and will not receive new development\&. If it works for managing your devices \(em fine, but if you are running it to try setting up a new device, please consider the newer \fBnutdrv_qx\fR(8) instead, which should handle all \fIQ*\fR protocol variants for NUT\&. +.sp +Please do also report if your device works with this driver, but \fBnutdrv_qx\fR(8) would not actually support it with any subdriver! .SH "SUPPORTED HARDWARE" .sp The blazer driver is known to work with various UPSes from Blazer, Energy Sistem, Fenton Technologies, General Electric, Mustek and many others\&. The NUT compatibility table lists all the known supported models\&. Keep in mind, however, that other models not listed there may also be supported, but haven\(cqt been tested\&. @@ -183,7 +188,12 @@ Examples: .PP \fBbus =\fR \fIregex\fR .RS 4 -Select a UPS on a specific USB bus or group of busses\&. The argument is a regular expression that must match the bus name where the UPS is connected (e\&.g\&. bus="002", bus="00[2\-3]")\&. +Select a UPS on a specific USB bus or group of buses\&. The argument is a regular expression that must match the bus name where the UPS is connected (e\&.g\&. bus="002", bus="00[2\-3]")\&. +.RE +.PP +\fBdevice =\fR \fIregex\fR +.RS 4 +Select a UPS on a specific USB device or group of devices\&. The argument is a regular expression that must match the device name where the UPS is connected (e\&.g\&. device="001", device="00[1\-2]")\&. Note that device numbers are not guaranteed by the OS to be stable across re\-boots or device re\-plugging\&. .RE .PP \fBsubdriver =\fR \fIstring\fR @@ -323,12 +333,52 @@ Some models report a bogus value for the beeper status (will always be \fIenable The temperature and load value is known to be bogus in some models\&. .SH "AUTHORS" .sp -Arjen de Korte , Alexander Gordeev +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Arjen de Korte +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Alexander Gordeev +.RE .SH "SEE ALSO" .sp \fBblazer_ser\fR(8), \fBnutupsdrv\fR(8), \fBupsc\fR(8), \fBupscmd\fR(8), \fBupsrw\fR(8) .SS "Internet Resources:" .sp -The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The NUT (Network UPS Tools) home page: +http://www\&.networkupstools\&.org/ +.RE .sp -The NUT HCL: http://www\&.networkupstools\&.org/stable\-hcl\&.html +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The NUT HCL: +http://www\&.networkupstools\&.org/stable\-hcl\&.html +.RE diff --git a/docs/man/clone.8 b/docs/man/clone.8 index 9636925..0519d89 100644 --- a/docs/man/clone.8 +++ b/docs/man/clone.8 @@ -1,13 +1,13 @@ '\" t .\" Title: clone .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "CLONE" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "CLONE" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -71,7 +71,7 @@ Set the timer (in seconds) before the outlet is turned off after the shutdown co .PP \fBondelay\fR=\fInum\fR .RS 4 -Set the timer (in seconds) for the outlet to switch on in case the power returns after the oulet has been switched off\&. Defaults to 30 seconds\&. +Set the timer (in seconds) for the outlet to switch on in case the power returns after the outlet has been switched off\&. Defaults to 30 seconds\&. .RE .PP \fBmincharge\fR=\fIvalue\fR @@ -91,45 +91,44 @@ The port specification in the \fBups.conf\fR(5) reference the driver socket that .RS 4 .\} .nf -[realups] - driver = usbhid\-ups - port = auto -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -[clone\-outlet\-1] - driver = clone - port = usbhid\-ups\-realups - load\&.on = outlet\&.1\&.load\&.on - load\&.off = outlet\&.1\&.load\&.off - load\&.status = outlet\&.1\&.status - [\&.\&.\&.] + [realups] + driver = usbhid\-ups + port = auto + + [clone\-outlet\-1] + driver = clone + port = usbhid\-ups\-realups + load\&.on = outlet\&.1\&.load\&.on + load\&.off = outlet\&.1\&.load\&.off + load\&.status = outlet\&.1\&.status + [\&.\&.\&.] .fi .if n \{\ .RE .\} .SH "IMPORTANT" .sp -Unlike a real UPS, you should \fBnot\fR configure a upsmon master for this driver\&. When a upsmon master sees the OB LB flags and tells the upsd server it is OK to initiate the shutdown sequence, the server will latch the FSD status and it will not be possible to restart the systems connected without restarting the upsd server\&. +Unlike a real UPS, you should \fBnot\fR configure a upsmon primary mode for this driver\&. When a upsmon primary sees the OB LB flags and tells the upsd server it is OK to initiate the shutdown sequence, the server will latch the FSD status and it will not be possible to restart the systems connected without restarting the upsd server\&. .sp -This will be a problem if the power returns after the clone UPS initiated the shutdown sequence on it\(cqs outlet, but returns before the real UPS begins shutting down\&. The solution is in the clone driver, that will insert the FSD flag if needed without the help of a upsmon master\&. +This will be a problem if the power returns after the clone UPS initiated the shutdown sequence on it\(cqs outlet, but returns before the real UPS begins shutting down\&. The solution is in the clone driver, that will insert the FSD flag if needed without the help of a upsmon primary\&. .SH "CAVEATS" .sp The clone UPS will follow the status on the real UPS driver\&. You can only make the clone UPS shutdown earlier than the real UPS driver, not later\&. If the real UPS driver initiates a shutdown, the clone UPS driver will immediately follow\&. .sp Be aware that the commands to shutdown/restart an outlet on the real UPS drivers are not affected, so if you tell the real UPS driver to shutdown the outlet of the clone UPS driver, your clients will lose power without warning\&. +.sp +If you use service management frameworks like systemd or SMF to manage the dependencies between driver instances and other units, then you may have to set up special dependencies (e\&.g\&. with systemd "drop\-in" snippet files) to queue your clone drivers to start after the "real" device drivers\&. .SH "AUTHOR" .sp Arjen de Korte .SH "SEE ALSO" .sp \fBupscmd\fR(1), \fBupsrw\fR(1), \fBups.conf\fR(5), \fBnutupsdrv\fR(8) +.SS "Dummy driver:" +.sp +The "repeater" mode of \fIdummy\-ups\fR driver is in some ways similar to the \fIclone\fR driver, by relaying information from a locally or remotely running "real" device driver (and NUT data server)\&. +.sp +\fBdummy-ups\fR(8) .SS "Internet Resources:" .sp The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/clone.txt b/docs/man/clone.txt index 6a844ac..555e5c7 100644 --- a/docs/man/clone.txt +++ b/docs/man/clone.txt @@ -3,22 +3,26 @@ CLONE(8) NAME ---- + clone - UPS driver clone NOTE ---- + This man page only documents the specific features of the clone driver. For information about the core driver, see linkman:nutupsdrv[8]. DESCRIPTION ----------- + This driver, which sits on top of another driver socket, allows users to group clients to a particular outlet of a device and deal with this output as if it was a normal UPS. EXTRA ARGUMENTS --------------- + This driver supports the following settings: *load.off*='command':: @@ -46,7 +50,7 @@ was issued. Defaults to 120 seconds. *ondelay*='num':: Set the timer (in seconds) for the outlet to switch on in case the power -returns after the oulet has been switched off. Defaults to 30 seconds. +returns after the outlet has been switched off. Defaults to 30 seconds. *mincharge*='value':: Set the remaining battery level when the clone UPS switches to LB @@ -58,9 +62,11 @@ Set the remaining battery runtime when the clone UPS switches to LB IMPLEMENTATION -------------- + The port specification in the linkman:ups.conf[5] reference the driver socket that the "real" UPS driver is using. For example: +------ [realups] driver = usbhid-ups port = auto @@ -72,11 +78,13 @@ socket that the "real" UPS driver is using. For example: load.off = outlet.1.load.off load.status = outlet.1.status [...] +------ IMPORTANT --------- -Unlike a real UPS, you should *not* configure a upsmon master for this -driver. When a upsmon master sees the OB LB flags and tells the upsd server + +Unlike a real UPS, you should *not* configure a upsmon primary mode for this +driver. When a upsmon primary sees the OB LB flags and tells the upsd server it is OK to initiate the shutdown sequence, the server will latch the FSD status and it will not be possible to restart the systems connected without restarting the upsd server. @@ -84,10 +92,11 @@ restarting the upsd server. This will be a problem if the power returns after the clone UPS initiated the shutdown sequence on it's outlet, but returns before the real UPS begins shutting down. The solution is in the clone driver, that will insert the -FSD flag if needed without the help of a upsmon master. +FSD flag if needed without the help of a upsmon primary. CAVEATS ------- + The clone UPS will follow the status on the real UPS driver. You can only make the clone UPS shutdown earlier than the real UPS driver, not later. If the real UPS driver initiates a shutdown, the clone UPS driver will @@ -98,8 +107,19 @@ drivers are not affected, so if you tell the real UPS driver to shutdown the outlet of the clone UPS driver, your clients will lose power without warning. +If you use service management frameworks like systemd or SMF to manage the +dependencies between driver instances and other units, then you may have +to set up special dependencies (e.g. with systemd "drop-in" snippet files) +to queue your `clone` drivers to start after the "real" device drivers. + +////////////////////////////////////// +TODO later: declare the driver as "optional", see +https://github.com/networkupstools/nut/issues/1389 +////////////////////////////////////// + AUTHOR ------ + Arjen de Korte SEE ALSO @@ -110,6 +130,16 @@ linkman:upsrw[1], linkman:ups.conf[5], linkman:nutupsdrv[8] +Dummy driver: +~~~~~~~~~~~~~ + +The "repeater" mode of 'dummy-ups' driver is in some ways similar to the +'clone' driver, by relaying information from a locally or remotely running +"real" device driver (and NUT data server). + +linkman:dummy-ups[8] + Internet Resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/dummy-ups.8 b/docs/man/dummy-ups.8 index 76731e0..3a39b67 100644 --- a/docs/man/dummy-ups.8 +++ b/docs/man/dummy-ups.8 @@ -1,13 +1,13 @@ '\" t .\" Title: dummy-ups .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "DUMMY\-UPS" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "DUMMY\-UPS" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -31,22 +31,110 @@ dummy-ups \- Driver for multi\-purpose UPS emulation .SH "NOTE" .sp -This man page only documents the specific features of the dummy\-ups driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. +This man page only documents the specific features of the \fBdummy\-ups\fR driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. .SH "DESCRIPTION" .sp -This program is a multi\-purpose UPS emulation tool\&. Its behavior depends on the running mode: +This program is a multi\-purpose UPS emulation tool\&. Its general behavior depends on the running mode: "dummy" ("dummy\-once" or "dummy\-loop"), or "repeater"\&. .SS "Dummy Mode" .sp -\fBdummy\-ups\fR looks like a standard device driver to \fBupsd\fR(8) and allows one to change any value for testing purposes\&. It is both interactive, controllable through the \fBupsrw\fR(1) and \fBupscmd\fR(1) commands (or equivalent graphical tool), and batchable through script files\&. It can be configured, launched and used as any other real driver\&. This mode is mostly useful for development and testing purposes\&. +In this mode, \fBdummy\-ups\fR looks like a standard NUT device driver to \fBupsd\fR(8) and allows one to change any value for testing purposes\&. It is both interactive, controllable through the \fBupsrw\fR(1) and \fBupscmd\fR(1) commands (or equivalent graphical tool), and batchable through script files\&. It can be configured, launched and used as any other "real" NUT driver\&. This mode is mostly useful for development and testing purposes\&. +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +See below about the differences of dummy\-once vs\&. dummy\-loop modes \(em the former may be more suitable for "interactive" uses and tests\&. +.sp .5v +.RE .SS "Repeater Mode" .sp -\fBdummy\-ups\fR acts as a NUT client, simply forwarding data\&. This can be useful for supervision purposes\&. This can also allow some load sharing between several UPS instances, using a point\-to\-point communication with the UPS\&. +In this mode, \fBdummy\-ups\fR acts as a NUT client, simply forwarding data\&. This can be useful for supervision purposes\&. This mode can also allow some load sharing between several upsd instances communicating with ultimate NUT clients, with a "central" one using a point\-to\-point communication with the UPS\&. This arrangement can also help with networked UPSes, whose network management cards can be overwhelmed with a farm of servers directly polling SNMP or other protocols every few seconds\&. .SH "IMPLEMENTATION" .sp -The port specification depends on the running mode, and allows the driver to select the right mode\&. +The port specification in ups\&.conf depends on the running mode, and allows the driver to select the right mode of operation\&. +.sp +Since NUT v2\&.8\&.0, the mode specification in ups\&.conf allows users to override the mode of operation which would be otherwise guessed by the driver\&. .SS "Dummy Mode" .sp -Port is a definition file name for \fBdummy\-ups\fR\&. This can either be an absolute or a relative path name\&. In the latter case the NUT sysconfig directory (ie /etc/nut, /usr/local/ups/etc, \&...) is prepended\&. +In this context, port in the ups\&.conf block defines a file name for the \fBdummy\-ups\fR to read data from\&. This can either be an absolute or a relative path name\&. In the latter case the NUT sysconfig directory (i\&.e\&. /etc/nut, /usr/local/ups/etc, \&...) is prepended\&. +.sp +Since NUT v2\&.8\&.0 two aspects of this mode are differentiated: +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +dummy\-once +reads the specified file once to the end (interrupting for +TIMER +lines, etc\&.) and does not re\-process it until the filesystem timestamp of the data file is changed; this reduces run\-time stress if you test with a lot of dummy devices, and allows use/test cases to +upsrw +variables into the driver instance \(em and they remain in memory until the driver is restarted (or the file is touched or modified); +.sp +Since NUT v2\&.8\&.0 +dummy\-once +is assigned by default to files with a +*\&.dev +naming pattern\&. +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +dummy\-loop +reads the specified file again and again, with a short sleep between the processing cycles; for sequence files using a +TIMER +keyword (see below), or for use/test cases which modify file contents with external means, this allows an impression of a device whose state changes over time\&. +.sp +Before NUT v2\&.8\&.0 this was the only aspect, so a simple +dummy +mode value maps to this behavior for backwards compatibility\&. +.sp +Since NUT v2\&.8\&.0 +dummy\-loop +is assigned by default to files with a +*\&.seq +naming pattern, and +dummy +is assigned by default to files with other naming patterns that the driver could not classify\&. +.RE +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +Said defaulting based on filename pattern can break third\-party test scripts which earlier expected *\&.dev files to work as a looping sequence with a TIMER keywords to change values slowly\&. Now such files should get processed to the end once\&. +.sp +Specify mode=dummy\-loop driver option or rename the data file used in the port option for legacy behavior\&. +.sp +Use/Test\-cases which modified such files content externally should not be impacted\&. +.sp .5v +.RE .sp For instance: .sp @@ -54,22 +142,55 @@ For instance: .RS 4 .\} .nf -[dummy] +[dummy1] driver = dummy\-ups - port = evolution500\&.dev - desc = "dummy\-ups in dummy mode" + port = evolution500\&.seq + desc = "dummy\-ups in dummy\-loop mode" .fi .if n \{\ .RE .\} .sp -This file is generally named "something\&.dev"\&. It contains a list of all valid data and associated values, and has the same format as an \fBupsc\fR(8) dump (: )\&. So you can easily create definition files from an existing UPS using "upsc > file\&.dev"\&. It can also be empty, in which case only a basic set of data is available: device\&.\fB, driver\&.\fR, ups\&.mfr, ups\&.model, ups\&.status +.if n \{\ +.RS 4 +.\} +.nf +[dummy2] + driver = dummy\-ups + port = epdu\-managed\&.dev + desc = "dummy\-ups in dummy\-once mode" +.fi +.if n \{\ +.RE +.\} .sp -Samples definition files are available in the "data" directory of the nut source tree, and generally in the sysconfig directory of your system distribution\&. +This file is generally named something\&.dev or something\&.seq\&. It contains a list of all valid variables and associated values (you can later use upsrw only to modify values of these variables), and has the same format as an \fBupsc\fR(8) dump (: )\&. So you can easily create definition files from an existing UPS using upsc > file\&.dev\&. .sp -Since \fBdummy\-ups\fR will loop on reading this file, you can dynamically modify it to interact with the driver\&. This will avoid message spam into your system log files, if you are using NUT default configuration\&. +Note that the Network UPS project provides an extensive DDL (Devices Dumps Library) with files which can be used for modelling real devices\&. Entries for the DDL library are best prepared with the tools/nut\-ddl\-dump\&.sh script from NUT sources instead of plain upsc, to provide some additional data points from other NUT clients as well\&. .sp -You can also use the "TIMER " instruction to create scheduled events sequences\&. For example, the following sequence will loop on switching ups\&.status between "OL", "OB" and "OB LB" every minute: +The file can also be empty, in which case only a basic set of data is available: device\&.*, driver\&.*, ups\&.mfr, ups\&.model, ups\&.status as filled by the driver itself\&. +.sp +Some sample definition files are available in the data directory of the NUT source tree, and generally in the sysconfig or share directory of your system distribution\&. +.sp +Since \fBdummy\-ups\fR will usually loop on reading this file, you can dynamically modify it with some external process to "interact" with the driver\&. This will avoid message spam into your system log files, if you are using NUT default configuration\&. +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +By default since NUT v2\&.8\&.0, it will not loop on files in dummy\-once mode, e\&.g\&. those with a \&.dev extension, unless their timestamp changes\&. +.sp .5v +.RE +.sp +You can also use the TIMER instruction to create scheduled event sequences (such files are traditionally named with the \&.seq extension)\&. For example, the following sequence will loop on switching ups\&.status between "OL", "OB" and "OB LB" every minute: .sp .if n \{\ .RS 4 @@ -79,17 +200,19 @@ ups\&.status: OL TIMER 60 ups\&.status: OB TIMER 60 -ups\&.status: LB +ups\&.status: OB LB TIMER 60 .fi .if n \{\ .RE .\} .sp -It is wise to end the script with a TIMER\&. Otherwise dummy\-ups will directly go back to the beginning of the file\&. +It is wise to end the script for dummy\-loop mode with a TIMER keyword\&. Otherwise dummy\-ups will directly go back to the beginning of the file and, in particular, forget any values you could have just set with upsrw\&. +.sp +Note that to avoid CPU overload with an infinite loop, the driver "sleeps" a bit between file\-reading cycles (currently this delay is hardcoded to one second), independently of (and/or in addition to) any TIMER keywords\&. .SS "Repeater Mode" .sp -Port is the name of a remote UPS, using the NUT form, ie: +In this context, port in the ups\&.conf block is the name of a remote UPS, using the NUT format, i\&.e\&.: .sp .if n \{\ .RS 4 @@ -108,40 +231,52 @@ For instance: .\} .nf [repeater] - driver = dummy\-ups - port = ups@hostname - desc = "dummy\-ups in repeater mode" + driver = dummy\-ups + port = ups1@remotehost + desc = "dummy\-ups in repeater mode" .fi .if n \{\ .RE .\} .sp Unlike UPS specifications in the rest of NUT, the @hostname portion is not optional \- it is the @ character which enables Repeater Mode\&. To refer to an UPS on the same host as \fBdummy\-ups\fR, use port = upsname@localhost\&. +.sp +Note that to avoid CPU overload with an infinite loop, the driver "sleeps" a bit between data\-requesting cycles (currently this delay is hardcoded to one second), so propagation of data updates available to a remote upsd may lag by this much\&. .SH "INTERACTION" .sp Once the driver is loaded in dummy mode, you can change any variables, except those of the driver\&.* and server\&.* collections\&. You can do this by either editing the definition file, or use the \fBupsrw\fR(1) and \fBupscmd\fR(1) commands\&. .sp -Note that in simulation mode, new variables can be added on the fly, by adding these to the definition file\&. Conversely, if you need to remove variable (such as transient ones, like ups\&.alarm), simply update these by setting an empty value\&. As a result, they will get removed from the data\&. +Note that in simulation mode, new variables can be added on the fly, but only by adding these to the definition file (and waiting for it to be re\-read)\&. That is, the driver should not allow to define a new variable via upsrw\&. .sp -In repeater mode, the driver acts according to the capabilities of the UPS, and so support the same instant commands and settable values\&. +Conversely, if you need to remove a variable (such as transient ones, like ups\&.alarm), simply update these by setting an empty value\&. As a result, they will get removed from the data\&. +.sp +In repeater mode, the driver acts according to the capabilities of the UPS, and so supports the same instant commands and settable values\&. .SH "BACKGROUND" .sp -Dummy Mode was originally written in one evening to replace the previous dummycons testing driver, which was too limited, and required a terminal for interaction\&. +Dummy Mode was originally written in one evening to replace the previous \fIdummycons\fR testing driver, which was too limited, and required a terminal for interaction\&. .sp \fBdummy\-ups\fR is useful for NUT client development, and other testing purposes\&. .sp It also helps the NUT Quality Assurance effort, by automating some tests on the NUT framework\&. .sp -It now offers a repeater mode\&. This will help in building the Meta UPS approach, which allows one to build a virtual device, composed of several other devices (either UPS, PDUs)\&. +It now offers a repeater mode\&. This will help in building the Meta UPS approach, which allows one to build a virtual device, composed of several other devices (either UPS, PDUs), or perhaps represent the same device which supports several communication protocols and different media (Serial, USB, SNMP\&...) .SH "BUGS" .sp Instant commands are not yet supported in Dummy Mode, and data need name/value checking enforcement, as well as boundaries or enumeration definition\&. +.SH "CAVEATS" +.sp +If you use service management frameworks like systemd or SMF to manage the dependencies between driver instances and the data server, and some of these drivers are dummy\-ups in repeater mode representing data from another driver running on the same system, then you may have to set up special dependencies (e\&.g\&. with systemd "drop\-in" snippet files) to allow your nut\-server to start after the "real" device drivers and before such repeater drivers (without a responding server, they would fail to start anyway)\&. This may also need special care in upsd\&.conf and/or ups\&.conf files to not block the system start\-up for too long while the repeater driver has not started\&. .SH "AUTHOR" .sp Arnaud Quette .SH "SEE ALSO" .sp \fBupscmd\fR(1), \fBupsrw\fR(1), \fBups.conf\fR(5), \fBnutupsdrv\fR(8) +.SS "Clone driver:" +.sp +The "repeater" mode of \fIdummy\-ups\fR driver is in some ways similar to the \fIclone\fR driver, which sits on top of another driver socket, and allows users to group clients to a particular outlet of a device and deal with this output as if it were a normal UPS\&. +.sp +\fBclone\fR(8) .SS "Internet Resources:" .sp The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/dummy-ups.txt b/docs/man/dummy-ups.txt index 385f5be..e3ed2f6 100644 --- a/docs/man/dummy-ups.txt +++ b/docs/man/dummy-ups.txt @@ -3,141 +3,262 @@ DUMMY-UPS(8) NAME ---- + dummy-ups - Driver for multi-purpose UPS emulation NOTE ---- + This man page only documents the specific features of the -dummy-ups driver. For information about the core driver, see +*dummy-ups* driver. For information about the core driver, see linkman:nutupsdrv[8]. DESCRIPTION ----------- + This program is a multi-purpose UPS emulation tool. -Its behavior depends on the running mode: +Its general behavior depends on the running mode: "dummy" ("dummy-once" +or "dummy-loop"), or "repeater". +//////////////////////////////////////// +...or "meta" eventually. +//////////////////////////////////////// Dummy Mode ~~~~~~~~~~ -*dummy-ups* looks like a standard device driver to linkman:upsd[8] and -allows one to change any value for testing purposes. It is both interactive, -controllable through the linkman:upsrw[1] and linkman:upscmd[1] commands (or -equivalent graphical tool), and batchable through script files. It can be -configured, launched and used as any other real driver. This mode is mostly -useful for development and testing purposes. +In this mode, *dummy-ups* looks like a standard NUT device driver to +linkman:upsd[8] and allows one to change any value for testing purposes. +It is both interactive, controllable through the linkman:upsrw[1] and +linkman:upscmd[1] commands (or equivalent graphical tool), and batchable +through script files. It can be configured, launched and used as any other +"real" NUT driver. This mode is mostly useful for development and testing +purposes. + +NOTE: See below about the differences of `dummy-once` vs. `dummy-loop` +modes -- the former may be more suitable for "interactive" uses and tests. Repeater Mode ~~~~~~~~~~~~~ -*dummy-ups* acts as a NUT client, simply forwarding data. This can be useful -for supervision purposes. This can also allow some load sharing between several -UPS instances, using a point-to-point communication with the UPS. +In this mode, *dummy-ups* acts as a NUT client, simply forwarding data. +This can be useful for supervision purposes. This mode can also allow some +load sharing between several `upsd` instances communicating with ultimate +NUT clients, with a "central" one using a point-to-point communication with +the UPS. This arrangement can also help with networked UPSes, whose network +management cards can be overwhelmed with a farm of servers directly polling +SNMP or other protocols every few seconds. + +//////////////////////////////////////// +Future intention: Meta mode to aggregate several drivers as one device +e.g. to represent same UPS with Serial + USB + SNMP links, and/or cover +an SNMP UPS that supports different data in different MIBs. +//////////////////////////////////////// IMPLEMENTATION -------------- -The port specification depends on the running mode, and allows the driver to -select the right mode. +The `port` specification in `ups.conf` depends on the running mode, and allows +the driver to select the right mode of operation. + +Since NUT v2.8.0, the `mode` specification in `ups.conf` allows users to +override the mode of operation which would be otherwise guessed by the driver. Dummy Mode ~~~~~~~~~~ -Port is a definition file name for *dummy-ups*. This can either -be an absolute or a relative path name. In the latter case the NUT -sysconfig directory (ie /etc/nut, /usr/local/ups/etc, ...) is prepended. +In this context, `port` in the `ups.conf` block defines a file name for the +*dummy-ups* to read data from. This can either be an absolute or a relative +path name. In the latter case the NUT sysconfig directory (i.e. `/etc/nut`, +`/usr/local/ups/etc`, ...) is prepended. + +Since NUT v2.8.0 two aspects of this mode are differentiated: + +* `dummy-once` reads the specified file once to the end (interrupting for + `TIMER` lines, etc.) and does not re-process it until the filesystem + timestamp of the data file is changed; this reduces run-time stress if + you test with a lot of dummy devices, and allows use/test cases to + `upsrw` variables into the driver instance -- and they remain in memory + until the driver is restarted (or the file is touched or modified); ++ +Since NUT v2.8.0 `dummy-once` is assigned by default to files with a `*.dev` + naming pattern. + +* `dummy-loop` reads the specified file again and again, with a short sleep + between the processing cycles; for sequence files using a `TIMER` keyword + (see below), or for use/test cases which modify file contents with external + means, this allows an impression of a device whose state changes over time. ++ +Before NUT v2.8.0 this was the only aspect, so a simple `dummy` mode value + maps to this behavior for backwards compatibility. ++ +Since NUT v2.8.0 `dummy-loop` is assigned by default to files with a `*.seq` + naming pattern, and `dummy` is assigned by default to files with other + naming patterns that the driver could not classify. + +[NOTE] +====== +Said defaulting based on filename pattern can break third-party +test scripts which earlier expected `*.dev` files to work as a +looping sequence with a `TIMER` keywords to change values slowly. +Now such files should get processed to the end once. + +Specify `mode=dummy-loop` driver option or rename the data file +used in the `port` option for legacy behavior. + +Use/Test-cases which modified such files content externally should +not be impacted. +====== For instance: - [dummy] + [dummy1] driver = dummy-ups - port = evolution500.dev - desc = "dummy-ups in dummy mode" + port = evolution500.seq + desc = "dummy-ups in dummy-loop mode" -This file is generally named "something.dev". It contains a list of all -valid data and associated values, and has the same format as an linkman:upsc[8] -dump (: ). So you can easily create definition -files from an existing UPS using "upsc > file.dev". -It can also be empty, in which case only a basic set of data is available: -device.*, driver.*, ups.mfr, ups.model, ups.status + [dummy2] + driver = dummy-ups + port = epdu-managed.dev + desc = "dummy-ups in dummy-once mode" -Samples definition files are available in the "data" directory of the nut source -tree, and generally in the sysconfig directory of your system distribution. +This file is generally named `something.dev` or `something.seq`. It contains +a list of all valid variables and associated values (you can later use `upsrw` +only to modify values of these variables), and has the same format as an +linkman:upsc[8] dump (`: `). So you can easily create +definition files from an existing UPS using `upsc > file.dev`. -Since *dummy-ups* will loop on reading this file, you can dynamically modify -it to interact with the driver. This will avoid message spam into your -system log files, if you are using NUT default configuration. +Note that the Network UPS project provides an extensive +link:https://networkupstools.org/ddl/index.html[DDL (Devices Dumps Library)] +with files which can be used for modelling real devices. +Entries for the DDL library are best prepared with the +link:https://raw.githubusercontent.com/networkupstools/nut/master/tools/nut-ddl-dump.sh[`tools/nut-ddl-dump.sh`] +script from NUT sources instead of plain `upsc`, to provide some additional +data points from other NUT clients as well. -You can also use the "TIMER " instruction to create scheduled events -sequences. For example, the following sequence will loop on switching ups.status +The file can also be empty, in which case only a basic set of data is +available: `device.*`, `driver.*`, `ups.mfr`, `ups.model`, `ups.status` +as filled by the driver itself. + +Some sample definition files are available in the `data` directory of the +NUT source tree, and generally in the sysconfig or share directory of your +system distribution. + +Since *dummy-ups* will usually loop on reading this file, you can dynamically +modify it with some external process to "interact" with the driver. +This will avoid message spam into your system log files, if you are +using NUT default configuration. + +NOTE: By default since NUT v2.8.0, it will not loop on files in `dummy-once` +mode, e.g. those with a `.dev` extension, unless their timestamp changes. + +You can also use the `TIMER ` instruction to create scheduled event +sequences (such files are traditionally named with the `.seq` extension). +For example, the following sequence will loop on switching `ups.status` between "OL", "OB" and "OB LB" every minute: ups.status: OL TIMER 60 ups.status: OB TIMER 60 - ups.status: LB + ups.status: OB LB TIMER 60 -It is wise to end the script with a TIMER. Otherwise dummy-ups will directly -go back to the beginning of the file. +It is wise to end the script for `dummy-loop` mode with a `TIMER` keyword. +Otherwise `dummy-ups` will directly go back to the beginning of the file +and, in particular, forget any values you could have just set with `upsrw`. + +Note that to avoid CPU overload with an infinite loop, the driver "sleeps" +a bit between file-reading cycles (currently this delay is hardcoded to one +second), independently of (and/or in addition to) any `TIMER` keywords. Repeater Mode ~~~~~~~~~~~~~ -Port is the name of a remote UPS, using the NUT form, ie: +In this context, `port` in the `ups.conf` block is the name of a remote UPS, +using the NUT format, i.e.: @[:] For instance: - [repeater] + [repeater] driver = dummy-ups - port = ups@hostname + port = ups1@remotehost desc = "dummy-ups in repeater mode" Unlike UPS specifications in the rest of NUT, the `@hostname` portion is not optional - it is the `@` character which enables Repeater Mode. To refer to an UPS on the same host as *dummy-ups*, use `port = upsname@localhost`. +Note that to avoid CPU overload with an infinite loop, the driver "sleeps" a +bit between data-requesting cycles (currently this delay is hardcoded to one +second), so propagation of data updates available to a remote `upsd` may lag +by this much. + INTERACTION ----------- Once the driver is loaded in dummy mode, you can change any variables, except -those of the driver.* and server.* collections. +those of the `driver.*` and `server.*` collections. You can do this by either editing the definition file, or use the linkman:upsrw[1] and linkman:upscmd[1] commands. -Note that in simulation mode, new variables can be added on the fly, by -adding these to the definition file. Conversely, if you need to remove -variable (such as transient ones, like ups.alarm), simply update these -by setting an empty value. As a result, they will get removed from the data. +Note that in simulation mode, new variables can be added on the fly, but only +by adding these to the definition file (and waiting for it to be re-read). +That is, the driver should not allow to define a new variable via `upsrw`. -In repeater mode, the driver acts according to the capabilities of the UPS, and -so support the same instant commands and settable values. +Conversely, if you need to remove a variable (such as transient ones, like +`ups.alarm`), simply update these by setting an empty value. As a result, +they will get removed from the data. + +In repeater mode, the driver acts according to the capabilities of the UPS, +and so supports the same instant commands and settable values. BACKGROUND ---------- Dummy Mode was originally written in one evening to replace the previous -dummycons testing driver, which was too limited, and required a terminal for -interaction. +'dummycons' testing driver, which was too limited, and required a terminal +for interaction. *dummy-ups* is useful for NUT client development, and other testing purposes. -It also helps the NUT Quality Assurance effort, by automating some tests on the -NUT framework. +It also helps the NUT Quality Assurance effort, by automating some tests on +the NUT framework. It now offers a repeater mode. This will help in building the Meta UPS approach, which allows one to build a virtual device, composed of several other devices -(either UPS, PDUs). +(either UPS, PDUs), or perhaps represent the same device which supports +several communication protocols and different media (Serial, USB, SNMP...) BUGS ---- + Instant commands are not yet supported in Dummy Mode, and data need name/value checking enforcement, as well as boundaries or enumeration definition. +CAVEATS +------- + +If you use service management frameworks like systemd or SMF to manage +the dependencies between driver instances and the data server, and some +of these drivers are `dummy-ups` in repeater mode representing data +from another driver running on the same system, then you may have to +set up special dependencies (e.g. with systemd "drop-in" snippet files) +to allow your `nut-server` to start after the "real" device drivers and +before such repeater drivers (without a responding server, they would fail +to start anyway). This may also need special care in `upsd.conf` and/or +`ups.conf` files to not block the system start-up for too long while the +repeater driver has not started. + +////////////////////////////////////// +TODO later: declare the driver as "optional", see +https://github.com/networkupstools/nut/issues/1389 +////////////////////////////////////// + AUTHOR ------ + Arnaud Quette SEE ALSO @@ -148,6 +269,17 @@ linkman:upsrw[1], linkman:ups.conf[5], linkman:nutupsdrv[8] +Clone driver: +~~~~~~~~~~~~~ + +The "repeater" mode of 'dummy-ups' driver is in some ways similar to the +'clone' driver, which sits on top of another driver socket, and allows +users to group clients to a particular outlet of a device and deal with +this output as if it were a normal UPS. + +linkman:clone[8] + Internet Resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/etapro.8 b/docs/man/etapro.8 index 1a22ae7..e9c3c95 100644 --- a/docs/man/etapro.8 +++ b/docs/man/etapro.8 @@ -1,13 +1,13 @@ '\" t .\" Title: etapro .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "ETAPRO" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "ETAPRO" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/etapro.txt b/docs/man/etapro.txt index 3b827e2..86d9212 100644 --- a/docs/man/etapro.txt +++ b/docs/man/etapro.txt @@ -3,33 +3,41 @@ ETAPRO(8) NAME ---- + etapro - Driver for ETA UPS equipment NOTE ---- + This man page only documents the hardware-specific features of the etapro driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + This driver supports ETA UPS equipment with the "PRO" option for smart mode. EXTRA ARGUMENTS --------------- + This driver does not support any extra settings in the linkman:ups.conf[5]. AUTHOR ------ + Marek Michalkiewicz SEE ALSO -------- + The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/everups.8 b/docs/man/everups.8 index 59a9e4c..66df659 100644 --- a/docs/man/everups.8 +++ b/docs/man/everups.8 @@ -1,13 +1,13 @@ '\" t .\" Title: everups .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "EVERUPS" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "EVERUPS" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/everups.txt b/docs/man/everups.txt index cf01bc0..7700982 100644 --- a/docs/man/everups.txt +++ b/docs/man/everups.txt @@ -3,22 +3,25 @@ EVERUPS(8) NAME ---- + everups - Driver for Ever UPS models NOTE ---- + This man page only documents the hardware-specific features of the everups driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + This driver should recognize the NET *-DPC and AP *-PRO models. EXTRA ARGUMENTS --------------- -This driver does not support any extra settings in the +This driver does not support any extra settings in the linkman:ups.conf[5]. BUGS @@ -30,6 +33,7 @@ don't sleep and force a reboot. AUTHOR ------ + Bartek Szady SEE ALSO @@ -37,8 +41,10 @@ SEE ALSO The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/gamatronic.8 b/docs/man/gamatronic.8 index 2453623..2fdb3a9 100644 --- a/docs/man/gamatronic.8 +++ b/docs/man/gamatronic.8 @@ -1,13 +1,13 @@ '\" t .\" Title: gamatronic .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "GAMATRONIC" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "GAMATRONIC" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/gamatronic.txt b/docs/man/gamatronic.txt index ac9db3f..9512295 100644 --- a/docs/man/gamatronic.txt +++ b/docs/man/gamatronic.txt @@ -3,16 +3,19 @@ GAMATRONIC(8) NAME ---- + gamatronic - Driver for Gamatronic UPS equipment NOTE ---- + This man page only documents the hardware-specific features of the gamatronic driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + Various - Rebuilt to work with Gamatronic UPS Units, but should recognize any UPS that speaks the SEC protocol at 1200-19200 bps. @@ -24,6 +27,7 @@ linkman:ups.conf[5]. AUTHOR ------ + Nadav Moskovitch SEE ALSO @@ -31,8 +35,10 @@ SEE ALSO The core driver ~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources ~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/generic_modbus.8 b/docs/man/generic_modbus.8 new file mode 100644 index 0000000..cc2fd34 --- /dev/null +++ b/docs/man/generic_modbus.8 @@ -0,0 +1,355 @@ +'\" t +.\" Title: generic_modbus +.\" Author: [see the "AUTHOR" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 +.\" Manual: NUT Manual +.\" Source: Network UPS Tools 2.8.0 +.\" Language: English +.\" +.TH "GENERIC_MODBUS" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +generic_modbus \- Driver for contact (direct) signal UPS devices connected via modbus remote I/O gateways +.SH "SYNOPSIS" +.sp +\fBgeneric_modbus\fR \-h +.sp +\fBgeneric_modbus\fR \-a \fIDEVICE_NAME\fR [\fIOPTIONS\fR] +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +This man page only documents the specific features of the \fBgeneric_modbus\fR driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. +.sp .5v +.RE +.SH "SUPPORTED HARDWARE" +.sp +This is a generic modbus driver expected to work with contact (direct) signal UPS devices, connected via modbus RIO (remote I/O) either serial or TCP/IP\&. +.sp +The driver has been tested against PULS UPS (model UB40\&.241) via MOXA ioLogikR1212 (RS485) and ioLogikE1212 (TCP/IP)\&. +.PP +More information about this UPS can be found here: +.RS 4 +https://products\&.pulspower\&.com/ca/ubc10\-241\-n1\&.html +.RE +.PP +More information about Moxa ioLogik R1212, E1212 can be found here: +.RS 4 +https://www\&.moxa\&.com/en/products/industrial\-edge\-connectivity/controllers\-and\-ios +.RE +.sp +The PULS UPS UB40\&.241 supports the following signals: +.sp +.if n \{\ +.RS 4 +.\} +.nf +Ready contact (DO) <\-\-> HB +Buffering contact (DO) <\-\-> OL | OB +Battery\-low (DO) <\-\-> LB +Replace Battery (DO) <\-\-> RB +Inhibit (DI) <\-\-> FSD +.fi +.if n \{\ +.RE +.\} +.sp +Digital port direction (DI/DO) assumes the device perspective +.sp +The driver\(cqs concept is to map the UPS states (as defined in NUT) onto UPS contacts\*(Aq states\&. The driver has an extended configuration interface implemented using variables defined in ups\&.conf\&. +.SH "HARDWARE INTERCONNECTION" +.sp +The commission of modbus remote I/O server as well as UPS device is carried out following the corresponding instruction manuals\&. The following figure depicts the anticipated communication path and hardware interconnection: +.sp +.if n \{\ +.RS 4 +.\} +.nf ++\-\-\-\-\-\-+ +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ +\-\-\-\-\-\-\-\-\-\-\-\-+ +\-\-\-\-\-\-\-\-\-\-\-\-+ +| UPSD | <\-\-\-> | GENERIC_MODBUS | <\-\-\-> | MODBUS RIO | <\-\-\-> | UPS DEVICE | ++\-\-\-\-\-\-+ (1) +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ (2) +\-\-\-\-\-\-\-\-\-\-\-\-+ (3) +\-\-\-\-\-\-\-\-\-\-\-\-+ + | | + +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ + HOST CONTROLLER + +(1) Unix IPC +(2) RS232 | TCP/IP +(3) contacts +.fi +.if n \{\ +.RE +.\} +.SH "EXTRA ARGUMENTS" +.sp +This driver supports the following optional settings in the \fBups.conf\fR(5) file: +.SS "Generic:" +.PP +\fBdevice_mfr\fR=\fIvalue\fR +.RS 4 +A string specifying the manufacturer of the UPS device (default UNKNOWN)\&. +.RE +.PP +\fBdevice_model\fR=\fIvalue\fR +.RS 4 +A string specifying the model of the UPS device (default UNKNOWN)\&. +.RE +.SS "Serial:" +.PP +\fBser_baud_rate\fR=\fIvalue\fR +.RS 4 +A integer specifying the serial port baud rate (default 9600)\&. +.RE +.PP +\fBser_data_bit\fR=\fIvalue\fR +.RS 4 +A integer specifying the serial port data bit (default 8)\&. +.RE +.PP +\fBser_parity\fR=\fIvalue\fR +.RS 4 +A character specifying the serial port parity (default N)\&. +.RE +.PP +\fBser_stop_bit\fR=\fIvalue\fR +.RS 4 +An integer specifying the serial port stop bit (default 1)\&. +.RE +.SS "Modbus:" +.PP +\fBrio_slave_id\fR=\fIvalue\fR +.RS 4 +An integer specifying the RIO modbus slave ID (default 1)\&. +.RE +.SS "States (X = OL, OB, LB, HB, RB, CHRG, DISCHRG, FSD)" +.PP +\fB_addr\fR=\fIvalue\fR +.RS 4 +A number specifying the modbus address for the X state\&. +.RE +.PP +\fB_regtype\fR=\fIvalue\fR +.RS 4 +A number specifying the modbus register type for the X state +.RE +.PP +Default values: +.RS 4 +.sp +.if n \{\ +.RS 4 +.\} +.nf +1 for X = OL, OB, LB ,HB, RB, CHRG, DISCHRG +0 for X = FSD +.fi +.if n \{\ +.RE +.\} +.RE +.PP +Valid values: +.RS 4 +.sp +.if n \{\ +.RS 4 +.\} +.nf +0:COIL, 1:INPUT_B, 2:INPUT_R, 3:HOLDING +.fi +.if n \{\ +.RE +.\} +.RE +.PP +\fB_noro\fR=\fIvalue\fR +.RS 4 +A number specifying the contact configuration for the X state (default 1)\&. +.RE +.PP +Valid values: +.RS 4 +.sp +.if n \{\ +.RS 4 +.\} +.nf +0:NC, 1:NO +.fi +.if n \{\ +.RE +.\} +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +NO stands for normally open and NC for normally closed contact +.sp .5v +.RE +.RE +.SS "Shutdown" +.PP +\fBFSD_pulse_duration\fR=\fIvalue\fR +.RS 4 +A number specifying the duration in ms for the inhibit pulse\&. If it\(cqs not defined, signal has only one transition depending on FSD_noro configuration\&. +.sp +Examples for FSD signal configuration: +.RE +.sp +.if n \{\ +.RS 4 +.\} +.nf +FSD_noro = 1 +FSD_pulse_duration = 150 + + +\-\-\-\-\-+ + | | +inhibit pulse >\-\-\-\-\-+ +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-> + <\-\-\-> + 150ms + + +FSD_noro = 0 + +inhibit pulse >\-\-\-\-\-+ + | + +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-> +.fi +.if n \{\ +.RE +.\} +.SH "CONFIGURATION" +.sp +Here is an example of generic_modbus driver configuration in \fBups\&.conf\fR file: +.sp +.if n \{\ +.RS 4 +.\} +.nf +[generic_modbus] + driver = generic_modbus + port = /dev/ttyUSB0 + desc = "generic ups driver" + # device info + device_mfr = "PULS" + device_model = "UB40\&.241" + # serial settings + ser_baud_rate = 9600 + ser_parity = N + ser_data_bit = 8 + ser_stop_bit = 1 + # modbus slave id + rio_slave_id = 5 + # UPS signal state attributes + OB_addr = 0x0 + OB_regtype = 1 + OB_noro = 0 + LB_addr = 0x1 + LB_regtype = 1 + HB_addr = 0x2 + HB_regtype = 1 + RB_addr = 0x3 + RB_regtype = 1 + FSD_addr = 0x0 + FSD_regtype = 0 + FSD_pulse_duration = 150 +.fi +.if n \{\ +.RE +.\} +.SH "INSTANT COMMANDS" +.sp +This driver support the following instant commands: +.PP +load\&.off +.RS 4 +executes "instant poweroff" +.RE +.SH "INSTALLATION" +.sp +This driver is not built by default\&. You can build it by installing libmodbus and running configure \-\-with\-modbus=yes\&. +.sp +You also need to give proper permissions on the local serial device file (/dev/ttyUSB0 for example) to allow the run\-time NUT driver user account to access it\&. +.SH "OTHER NOTES" +.sp +The generic_modbus driver intends to support generic UPS devices with contact signals through modbus TCP/RTU gateways (also known as RIO \(em remote I/Os)\&. The data and signal path looks like this: +.sp +.if n \{\ +.RS 4 +.\} +.nf +[UPSD] <\-\-\- IPC \-\-\-> [GENERIC_UPS] <\-\-\- modbus TCP/RTU \-\-\-> MODBUS\-RIO <\-\-\- contacts \-\-\-> [UPS DEVICE] +.fi +.if n \{\ +.RE +.\} +.sp +On the other hand, you can setup any kind of modbus server, and configure the generic_modbus driver to connect and read or write specific registers\&. Your application / modbus server could then drive NUT statuses (e\&.g\&. OL, OB, HB etc) by writing over those registers\&. +.SH "AUTHOR" +.sp +Dimitris Economou +.SH "SEE ALSO" +.SS "The core driver:" +.sp +\fBnutupsdrv\fR(8), \fBups.conf\fR(5) +.SS "Internet resources:" +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The NUT (Network UPS Tools) home page: +http://www\&.networkupstools\&.org/ +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +libmodbus home page: +http://libmodbus\&.org +.RE diff --git a/docs/man/generic_modbus.txt b/docs/man/generic_modbus.txt new file mode 100644 index 0000000..37f9de6 --- /dev/null +++ b/docs/man/generic_modbus.txt @@ -0,0 +1,247 @@ +GENERIC_MODBUS(8) +================= + +NAME +---- + +generic_modbus - Driver for contact (direct) signal UPS devices connected via modbus remote I/O gateways + +SYNOPSIS +-------- + +*generic_modbus* -h + +*generic_modbus* -a 'DEVICE_NAME' ['OPTIONS'] + +NOTE: This man page only documents the specific features of the *generic_modbus* +driver. For information about the core driver, see linkman:nutupsdrv[8]. + +SUPPORTED HARDWARE +------------------ + +This is a generic modbus driver expected to work with contact (direct) signal +UPS devices, connected via modbus RIO (remote I/O) either serial or TCP/IP. + +The driver has been tested against PULS UPS (model UB40.241) +via MOXA ioLogikR1212 (RS485) and ioLogikE1212 (TCP/IP). + +More information about this UPS can be found here: :: +https://products.pulspower.com/ca/ubc10-241-n1.html + +More information about Moxa ioLogik R1212, E1212 can be found here: :: +https://www.moxa.com/en/products/industrial-edge-connectivity/controllers-and-ios + +The PULS UPS UB40.241 supports the following signals: +---- +Ready contact (DO) <--> HB +Buffering contact (DO) <--> OL | OB +Battery-low (DO) <--> LB +Replace Battery (DO) <--> RB +Inhibit (DI) <--> FSD +---- + +Digital port direction (DI/DO) assumes the device perspective + +The driver's concept is to map the UPS states (as defined in NUT) onto +UPS contacts' states. The driver has an extended configuration interface +implemented using variables defined in ups.conf. + +HARDWARE INTERCONNECTION +------------------------ + +The commission of modbus remote I/O server as well as UPS device is carried +out following the corresponding instruction manuals. The following figure +depicts the anticipated communication path and hardware interconnection: +---- ++------+ +----------------+ +------------+ +------------+ +| UPSD | <---> | GENERIC_MODBUS | <---> | MODBUS RIO | <---> | UPS DEVICE | ++------+ (1) +----------------+ (2) +------------+ (3) +------------+ + | | + +-------------------+ + HOST CONTROLLER + +(1) Unix IPC +(2) RS232 | TCP/IP +(3) contacts +---- + +EXTRA ARGUMENTS +--------------- + +This driver supports the following optional settings in the +linkman:ups.conf[5] file: + +Generic: +~~~~~~~ + +*device_mfr*='value':: +A string specifying the manufacturer of the UPS device (default UNKNOWN). + +*device_model*='value':: +A string specifying the model of the UPS device (default UNKNOWN). + +Serial: +~~~~~~ + +*ser_baud_rate*='value':: +A integer specifying the serial port baud rate (default 9600). + +*ser_data_bit*='value':: +A integer specifying the serial port data bit (default 8). + +*ser_parity*='value':: +A character specifying the serial port parity (default N). + +*ser_stop_bit*='value':: +An integer specifying the serial port stop bit (default 1). + +Modbus: +~~~~~~ + +*rio_slave_id*='value':: +An integer specifying the RIO modbus slave ID (default 1). + +States (X = OL, OB, LB, HB, RB, CHRG, DISCHRG, FSD) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +*_addr*='value':: +A number specifying the modbus address for the X state. + +*_regtype*='value':: +A number specifying the modbus register type for the X state +Default values: :: ++ +---- +1 for X = OL, OB, LB ,HB, RB, CHRG, DISCHRG +0 for X = FSD +---- +Valid values: :: ++ +---- +0:COIL, 1:INPUT_B, 2:INPUT_R, 3:HOLDING +---- + +*_noro*='value':: +A number specifying the contact configuration for the X state (default 1). +Valid values: :: ++ +---- +0:NC, 1:NO +---- ++ +NOTE: NO stands for normally open and NC for normally closed contact + +Shutdown +~~~~~~~~ + +*FSD_pulse_duration*='value':: +A number specifying the duration in ms for the inhibit pulse. +If it's not defined, signal has only one transition depending +on FSD_noro configuration. ++ +Examples for FSD signal configuration: +---- +FSD_noro = 1 +FSD_pulse_duration = 150 + + +-----+ + | | +inhibit pulse >-----+ +------------------> + <---> + 150ms + + +FSD_noro = 0 + +inhibit pulse >-----+ + | + +------------------------> + +---- + +CONFIGURATION +------------- + +Here is an example of generic_modbus driver configuration in *ups.conf* file: +---- +[generic_modbus] + driver = generic_modbus + port = /dev/ttyUSB0 + desc = "generic ups driver" + # device info + device_mfr = "PULS" + device_model = "UB40.241" + # serial settings + ser_baud_rate = 9600 + ser_parity = N + ser_data_bit = 8 + ser_stop_bit = 1 + # modbus slave id + rio_slave_id = 5 + # UPS signal state attributes + OB_addr = 0x0 + OB_regtype = 1 + OB_noro = 0 + LB_addr = 0x1 + LB_regtype = 1 + HB_addr = 0x2 + HB_regtype = 1 + RB_addr = 0x3 + RB_regtype = 1 + FSD_addr = 0x0 + FSD_regtype = 0 + FSD_pulse_duration = 150 +---- + +INSTANT COMMANDS +---------------- + +This driver support the following instant commands: + +load.off:: +executes "instant poweroff" + +INSTALLATION +------------ + +This driver is not built by default. You can build it by installing +libmodbus and running `configure --with-modbus=yes`. + +You also need to give proper permissions on the local serial device +file (/dev/ttyUSB0 for example) to allow the run-time NUT driver user +account to access it. + +OTHER NOTES +----------- + +The `generic_modbus` driver intends to support generic UPS devices with +contact signals through modbus TCP/RTU gateways (also known as RIO -- +remote I/Os). The data and signal path looks like this: + +---- +[UPSD] <--- IPC ---> [GENERIC_UPS] <--- modbus TCP/RTU ---> MODBUS-RIO <--- contacts ---> [UPS DEVICE] +---- + +On the other hand, you can setup any kind of modbus server, and configure +the `generic_modbus` driver to connect and read or write specific registers. +Your application / modbus server could then drive NUT statuses (e.g. OL, OB, +HB etc) by writing over those registers. + +AUTHOR +------ + +Dimitris Economou + +SEE ALSO +-------- + +The core driver: +~~~~~~~~~~~~~~~~ + +linkman:nutupsdrv[8], linkman:ups.conf[5] + +Internet resources: +~~~~~~~~~~~~~~~~~~~ + +* The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ +* libmodbus home page: http://libmodbus.org diff --git a/docs/man/genericups.8 b/docs/man/genericups.8 index 591a0b8..77b8ff1 100644 --- a/docs/man/genericups.8 +++ b/docs/man/genericups.8 @@ -1,13 +1,13 @@ '\" t .\" Title: genericups -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "GENERICUPS" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "GENERICUPS" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -36,7 +36,7 @@ This man page only documents the specific features of the genericups driver\&. F .sp This driver supports hardware from many different manufacturers as it only uses the very simplest of signaling schemes\&. Contact closure refers to a kind of interface where basic high/low signals are provided to indicate status\&. This kind of UPS can only report line power and battery status\&. .sp -This means that you will only get the essentials in ups\&.status: OL, OB, and LB\&. Anything else requires a smarter UPS\&. +This means that you will only get the essentials in ups\&.status: OL, OB, and LB (some UPSes may also support RB and BYPASS)\&. Anything else requires a smarter UPS\&. .SH "CABLING" .sp Cabling is different for every kind of UPS\&. See the table below for information on what is known to work with a given UPS type\&. @@ -137,6 +137,16 @@ LB Low battery .RE .PP +RB +.RS 4 +Replace battery +.RE +.PP +BYPASS +.RS 4 +Battery bypass active or no battery installed +.RE +.PP SD .RS 4 Shutdown load @@ -172,10 +182,27 @@ DTR Data Terminal Ready\&. Sent by the PC\&. .RE .PP +DSR +.RS 4 +Data Set Ready\&. Received from the UPS\&. +.RE +.PP ST .RS 4 Send a BREAK on the transmit data line .RE +.PP +NULL +.RS 4 +Disable this signal\&. Disabled signal will always be low except for OL which will always be high\&. +.RE +.PP +none +.RS 4 +Alias to +NULL +which matches some other documentation\&. +.RE .sp A "\-" in front of a signal name (like \-RNG) means that the indicated condition is signaled with an active low signal\&. For example, [LB=\-RNG] means the battery is low when the ring indicate line goes low, and that the battery is OK when that line is held high\&. .SH "UPS TYPES" @@ -475,6 +502,18 @@ Check docs/cables/powerware\&.txt .if n \{\ .RE .\} +.sp +23 = Generic FTTx (Fiber to the x) battery backup with 4\-wire telemetry interface +.sp +.if n \{\ +.RS 4 +.\} +.nf +[CP=RTS] [OL=CTS] [LB=\-DCD] [RB=\-RNG] [BYPASS=\-DSR] [SD=none] +.fi +.if n \{\ +.RE +.\} .SH "SIMILAR MODELS" .sp Many different UPS companies make models with similar interfaces\&. The RUPS cable seems to be especially popular in the "power strip" variety of UPS found in office supply stores\&. If your UPS works with an entry in the table above, but the model or manufacturer information don\(cqt match, don\(cqt despair\&. You can fix that easily by using the mfr and model variables documented above in your \fBups.conf\fR(5)\&. @@ -581,13 +620,13 @@ Types 7 and 10 should both work with the PhoenixTec A1000\&. .sp There is no way to reliably detect a contact\-closure UPS\&. This means the driver will start up happily even if no UPS is detected\&. It also means that if the connection between the UPS and computer is interrupted, you may not be able to sense this in software\&. .sp -Most contact\-closure UPSes will not power down the load if the line power is present\&. This can create a race when using slave \fBupsmon\fR(8) systems\&. See the \fBupsmon\fR(8) man page for more information\&. +Most contact\-closure UPSes will not power down the load if the line power is present\&. This can create a race when using secondary \fBupsmon\fR(8) systems\&. See the \fBupsmon\fR(8) man page for more information\&. .sp The solution to both of these problems is to upgrade to a smart protocol UPS of some kind that allows detection and proper load cycling on command\&. .SH "SEE ALSO" .SS "The core driver" .sp \fBnutupsdrv\fR(8) -.SS "Internet resources" +.SS "Internet resources:" .sp The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/genericups.txt b/docs/man/genericups.txt index c54a10d..54c4a6b 100644 --- a/docs/man/genericups.txt +++ b/docs/man/genericups.txt @@ -3,30 +3,36 @@ GENERICUPS(8) NAME ---- + genericups - Driver for contact-closure UPS equipment NOTE ---- -This man page only documents the specific features of the genericups + +This man page only documents the specific features of the genericups driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ -This driver supports hardware from many different manufacturers as it only -uses the very simplest of signaling schemes. Contact closure refers to a -kind of interface where basic high/low signals are provided to indicate + +This driver supports hardware from many different manufacturers as it only +uses the very simplest of signaling schemes. Contact closure refers to a +kind of interface where basic high/low signals are provided to indicate status. This kind of UPS can only report line power and battery status. This means that you will only get the essentials in ups.status: OL, OB, -and LB. Anything else requires a smarter UPS. +and LB (some UPSes may also support RB and BYPASS). Anything else requires +a smarter UPS. CABLING ------- -Cabling is different for every kind of UPS. See the table below for + +Cabling is different for every kind of UPS. See the table below for information on what is known to work with a given UPS type. EXTRA ARGUMENTS --------------- + This driver supports the following settings in the linkman:ups.conf[5]: upstype='type':: @@ -37,25 +43,25 @@ are available. mfr='string':: -Optional. The very nature of a generic UPS driver sometimes means that -the stock manufacturer data has no relation to the actual hardware that is -attached. With the `mfr` setting, you can change the value that is seen by +Optional. The very nature of a generic UPS driver sometimes means that +the stock manufacturer data has no relation to the actual hardware that is +attached. With the `mfr` setting, you can change the value that is seen by clients that monitor this UPS. model='string':: -Optional. This is like `mfr` above, but it overrides the model string +Optional. This is like `mfr` above, but it overrides the model string instead. serial='string':: Optional. This is like `mfr` above and intended to record the identification -string of the UPS. It is titled "serial" because usually this string is +string of the UPS. It is titled "serial" because usually this string is referred to as the serial number. sdtime='value':: -Optional. The driver will sleep for this many seconds after setting the +Optional. The driver will sleep for this many seconds after setting the shutdown signal. This is necessary for some hardware which requires a sustained level to activate the shutdown sequence. + @@ -88,13 +94,18 @@ recognizes a low battery condition when DCD is not held high. TYPE INFORMATION ---------------- -The essence of a UPS definition in this driver is how it uses the serial + +The essence of a UPS definition in this driver is how it uses the serial lines that are available. These are the abbreviations you will see below: OL:: On line (no power failure) (opposite of OB - on battery) LB:: Low battery +RB:: Replace battery + +BYPASS:: Battery bypass active or no battery installed + SD:: Shutdown load CP:: Cable power (must be present for cable to have valid reading) @@ -109,78 +120,85 @@ RNG:: Ring indicate. Received from the UPS. DTR:: Data Terminal Ready. Sent by the PC. +DSR:: Data Set Ready. Received from the UPS. + ST:: Send a BREAK on the transmit data line -A "-" in front of a signal name (like -RNG) means that the indicated -condition is signaled with an active low signal. For example, [LB=-RNG] -means the battery is low when the ring indicate line goes low, and that +NULL:: Disable this signal. Disabled signal will always be low except for OL + which will always be high. + +none:: Alias to `NULL` which matches some other documentation. + +A "-" in front of a signal name (like -RNG) means that the indicated +condition is signaled with an active low signal. For example, [LB=-RNG] +means the battery is low when the ring indicate line goes low, and that the battery is OK when that line is held high. UPS TYPES --------- -0 = UPSonic LAN Saver 600 +0 = UPSonic LAN Saver 600 [CP=DTR+RTS] [OL=-CTS] [LB=DCD] [SD=DTR] -1 = APC Back-UPS/Back-UPS Pro/Smart-UPS with 940-0095A/C cable +1 = APC Back-UPS/Back-UPS Pro/Smart-UPS with 940-0095A/C cable [CP=DTR] [OL=-RNG] [LB=DCD] [SD=RTS] -2 = APC Back-UPS/Back-UPS Pro/Smart-UPS with 940-0020B cable +2 = APC Back-UPS/Back-UPS Pro/Smart-UPS with 940-0020B cable [CP=RTS] [OL=-CTS] [LB=DCD] [SD=DTR+RTS] Type 2 has also been reported to work with the 940-0020C cable. -3 = PowerTech Comp1000 with DTR cable power +3 = PowerTech Comp1000 with DTR cable power [CP=DTR] [OL=CTS] [LB=DCD] [SD=DTR+RTS] -4 = Generic RUPS Model +4 = Generic RUPS Model [CP=RTS] [OL=CTS] [LB=-DCD] [SD=-RTS] -5 = Tripp Lite UPS with Lan2.2 interface (black 73-0844 cable) +5 = Tripp Lite UPS with Lan2.2 interface (black 73-0844 cable) [CP=DTR] [OL=CTS] [LB=-DCD] [SD=DTR+RTS] -6 = Best Patriot with INT51 cable +6 = Best Patriot with INT51 cable [CP=DTR] [OL=CTS] [LB=-DCD] [SD=RTS] -7 = CyberPower Power99 +7 = CyberPower Power99 Also Upsonic Power Guardian PG-500, Belkin Belkin Home Office, F6H350-SER, F6H500-SER, F6H650-SER, Eaton Management Card Contact - Config3 with cable 66033 (shutdown does not work) [CP=RTS] [OL=CTS] [LB=-DCD] [SD=DTR] -8 = Nitram Elite 500 +8 = Nitram Elite 500 [CP=DTR] [OL=CTS] [LB=-DCD] [SD=???] -9 = APC Back-UPS/Back-UPS Pro/Smart-UPS with 940-0023A cable +9 = APC Back-UPS/Back-UPS Pro/Smart-UPS with 940-0023A cable [CP=none] [OL=-DCD] [LB=CTS] [SD=RTS] -10 = Victron Lite with crack cable +10 = Victron Lite with crack cable [CP=RTS] [OL=CTS] [LB=-DCD] [SD=DTR] -11 = Powerware 3115 +11 = Powerware 3115 [CP=DTR] [OL=-CTS] [LB=-DCD] [SD=ST] -12 = APC Back-UPS Office with 940-0119A cable +12 = APC Back-UPS Office with 940-0119A cable [CP=RTS] [OL=-CTS] [LB=DCD] [SD=DTR] -13 = RPT Repoteck RPT-800A/RPT-162A +13 = RPT Repoteck RPT-800A/RPT-162A [CP=DTR+RTS] [OL=DCD] [LB=-CTS] [SD=ST] -14 = Online P-series +14 = Online P-series [CP=DTR] [OL=DCD] [LB=-CTS] [SD=RTS] @@ -219,21 +237,26 @@ UPS TYPES [CP=RTS] [OL=CTS] [LB=-DCD] [SD=DTR] +23 = Generic FTTx (Fiber to the x) battery backup + with 4-wire telemetry interface + + [CP=RTS] [OL=CTS] [LB=-DCD] [RB=-RNG] [BYPASS=-DSR] [SD=none] + SIMILAR MODELS -------------- -Many different UPS companies make models with similar interfaces. The -RUPS cable seems to be especially popular in the "power strip" variety of +Many different UPS companies make models with similar interfaces. The +RUPS cable seems to be especially popular in the "power strip" variety of UPS found in office supply stores. If your UPS works with an entry in the table above, but the model or manufacturer information don't match, -don't despair. You can fix that easily by using the mfr and model +don't despair. You can fix that easily by using the mfr and model variables documented above in your linkman:ups.conf[5]. TESTING COMPATIBILITY --------------------- -If your UPS isn't listed above, you can try going through the list until -you find one that works. There is a lot of cable and interface reuse in +If your UPS isn't listed above, you can try going through the list until +you find one that works. There is a lot of cable and interface reuse in the UPS world, and you may find a match. To do this, first make sure nothing important is plugged into the @@ -244,7 +267,7 @@ supplied to the outlets. Now, you can either attempt to make an educated guess based on the documentation your manufacturer has provided (if any), or just start -going down the list. +going down the list. Step 1 ~~~~~~ @@ -319,20 +342,20 @@ Change the port and upstype values to match your system. NEW SUPPORT ----------- -If the above testing sequence fails, you will probably need to create a -new entry to support your hardware. All UPS types are determined from the +If the above testing sequence fails, you will probably need to create a +new entry to support your hardware. All UPS types are determined from the table in the genericups.h file in the source tree. -On a standard 9 pin serial port, there are 6 lines that are used as the -standard "high/low" signal levels. 4 of them are incoming (to the PC, -from the UPS), and the other 2 are outgoing (to the UPS, from the PC). +On a standard 9 pin serial port, there are 6 lines that are used as the +standard "high/low" signal levels. 4 of them are incoming (to the PC, +from the UPS), and the other 2 are outgoing (to the UPS, from the PC). The other 3 are the receive/transmit lines and the ground. -Be aware that many manufacturers remap pins within the cable. If you have -any doubts, a quick check with a multimeter should confirm whether the -cable is straight-through or not. Another thing to keep in mind is that -some cables have electronics in them to do special things. Some have -resistors and transistors on board to change behavior depending on what's +Be aware that many manufacturers remap pins within the cable. If you have +any doubts, a quick check with a multimeter should confirm whether the +cable is straight-through or not. Another thing to keep in mind is that +some cables have electronics in them to do special things. Some have +resistors and transistors on board to change behavior depending on what's being supplied by the PC. SPECIFIC MODEL NOTES @@ -340,17 +363,17 @@ SPECIFIC MODEL NOTES These have been contributed by users of this driver. -The Centralion CL series may power down the load if the driver starts up -with the UPS running on battery as the default line settings contain the +The Centralion CL series may power down the load if the driver starts up +with the UPS running on battery as the default line settings contain the shutdown sequence. - Neil Muller -The Tripp-Lite Internet Office 700 must be used with the black 73-0844 -cable instead of the gray 73-0743 cable. This entry should work with any -of their models with the Lan 2.2 interface - see the sticker by the DB9 +The Tripp-Lite Internet Office 700 must be used with the black 73-0844 +cable instead of the gray 73-0743 cable. This entry should work with any +of their models with the Lan 2.2 interface - see the sticker by the DB9 connector on the UPS. - Stephen Brown -Type 5 should work with the Tripp-Lite Lan 2.1 interface and the 73-0724 -cable. This was tested with the OmniSmart 675 PNP on Red Hat 7.2. - Q +Type 5 should work with the Tripp-Lite Lan 2.1 interface and the 73-0724 +cable. This was tested with the OmniSmart 675 PNP on Red Hat 7.2. - Q Giese Types 7 and 10 should both work with the PhoenixTec A1000. @@ -358,16 +381,16 @@ Types 7 and 10 should both work with the PhoenixTec A1000. BUGS ---- -There is no way to reliably detect a contact-closure UPS. This means the -driver will start up happily even if no UPS is detected. It also means -that if the connection between the UPS and computer is interrupted, you +There is no way to reliably detect a contact-closure UPS. This means the +driver will start up happily even if no UPS is detected. It also means +that if the connection between the UPS and computer is interrupted, you may not be able to sense this in software. -Most contact-closure UPSes will not power down the load if the line power -is present. This can create a race when using slave linkman:upsmon[8] +Most contact-closure UPSes will not power down the load if the line power +is present. This can create a race when using secondary linkman:upsmon[8] systems. See the linkman:upsmon[8] man page for more information. -The solution to both of these problems is to upgrade to a smart protocol +The solution to both of these problems is to upgrade to a smart protocol UPS of some kind that allows detection and proper load cycling on command. SEE ALSO @@ -375,8 +398,10 @@ SEE ALSO The core driver ~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] -Internet resources -~~~~~~~~~~~~~~~~~~ +Internet resources: +~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/hosts.conf.5 b/docs/man/hosts.conf.5 index 45ca6cc..298105f 100644 --- a/docs/man/hosts.conf.5 +++ b/docs/man/hosts.conf.5 @@ -1,13 +1,13 @@ '\" t .\" Title: hosts.conf -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "HOSTS\&.CONF" "5" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "HOSTS\&.CONF" "5" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/hosts.conf.txt b/docs/man/hosts.conf.txt index 273ae98..8d86ea8 100644 --- a/docs/man/hosts.conf.txt +++ b/docs/man/hosts.conf.txt @@ -36,4 +36,5 @@ linkman:upsset.cgi[8], linkman:upsstats.cgi[8], linkman:upsimage.cgi[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/huawei-ups2000.8 b/docs/man/huawei-ups2000.8 new file mode 100644 index 0000000..40ada33 --- /dev/null +++ b/docs/man/huawei-ups2000.8 @@ -0,0 +1,489 @@ +'\" t +.\" Title: huawei_ups2000 +.\" Author: [see the "AUTHOR" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 +.\" Manual: NUT Manual +.\" Source: Network UPS Tools 2.8.0 +.\" Language: English +.\" +.TH "HUAWEI_UPS2000" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +huawei-ups2000 \- Driver for Huawei UPS2000 (1kVA\-3kVA) UPS with USB or RS\-232 serial Modbus connection\&. +.SH "SYNOPSIS" +.sp +\fBhuawei\-ups2000\fR \-h +.sp +\fBhuawei\-ups2000\fR \-a \fIDEVICE_NAME\fR [\fIOPTIONS\fR] +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +This man page only documents the hardware\-specific features of the huawei\-ups2000 driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. +.sp .5v +.RE +.SH "SUPPORTED HARDWARE" +.sp +This driver supports Huawei UPS2000 series, online (double conversion) UPS with the following characteristics\&. +.sp +.RS 4 +.ie n \{\ +\h'-04' 1.\h'+01'\c +.\} +.el \{\ +.sp -1 +.IP " 1." 4.2 +.\} +Output power: 1 kVA to 3 kVA (higher power models are unsupported)\&. +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04' 2.\h'+01'\c +.\} +.el \{\ +.sp -1 +.IP " 2." 4.2 +.\} +Connection: USB or RS\-232 (USB is only supported on Linux 5\&.12 and newer kernels, read the section +\fBCabling\fR +carefully)\&. +.RE +.sp +The UPS2000 series has two variants: UPS2000\-A with a tower chassis, and UPS2000\-G with a rack\-mount chassis\&. Both should be equally supported, but more testers are needed\&. +.sp +Currently, it has been tested on the following models\&. +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +UPS2000\-A\-1KTTS (firmware: V2R1C1SPC40, P1\&.0\-D1\&.0) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +UPS2000\-A\-2KTTS (firmware: V2R1C1SPC50, P1\&.0\-D1\&.0) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +UPS2000\-G\-3KRTS (firmware: V2R1C1SPC40, P1\&.0\-D1\&.0) +.RE +.sp +If your model is not in the list, we encourage you to report successful or unsuccessful results to the bug tracker or the mailing list\&. Make sure to include the full model number of your UPS manually in your report, because the firmware only reports "UPS2000\-A" for all models, including the G series\&. +.sp +huawei\-ups2000 uses the libmodbus project, for Modbus implementation\&. +.SH "CABLING" +.sp +The UPS has a USB port and a RS\-232 port\&. Both are supported, but USB is only usable on Linux 5\&.12 and later, via the \fBxr_serial\fR kernel module (see subsection \fBUSB\fR for details)\&. RS\-232 is supported on all operating systems\&. +.sp +Only one port can be used at a time\&. When USB is used, RS\-232 should be unplugged from the UPS, and vice versa\&. Further, optional adapter cards, such as RS\-485 or SNMP, are not supported\&. They should be removed from the UPS\&. +.sp +Because the UPS port can be unresponsive under certain circumstances, it\(cqs recommended to power cycle your UPS after making a cabling change, especially after changing the port type\&. That is, turn off the UPS power output via the front panel, then unplug the UPS from line power input\&. Wait for the LCD screen to go black\&. Finally reconnect line power and restart your UPS\&. +.SS "USB" +.sp +The USB port on the UPS2000 is powered by a MaxLinear/Exar RX21V1410 USB\-to\-serial converter chip, it\(cqs only supported by Linux 5\&.12 or newer, via the \fBxr_serial\fR kernel module\&. +.sp +When the UPS2000 is connected via USB to a supported Linux system, you should see the following logs in \fBdmesg\fR\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf +xr_serial 1\-1\&.2:1\&.1: xr_serial converter detected +usb 1\-1\&.2: xr_serial converter now attached to ttyUSB0 +.fi +.if n \{\ +.RE +.\} +.sp +The driver must be \fBxr_serial\fR\&. If your system doesn\(cqt have the necessary device driver, you will get this message instead: +.sp +.if n \{\ +.RS 4 +.\} +.nf +cdc_acm 1\-1\&.2:1\&.0: ttyACM0: USB ACM device +.fi +.if n \{\ +.RE +.\} +.sp +The generic driver \fBcdc_acm\fR is incompatible and cannot be used\&. You should upgrade your Linux kernel to Linux 5\&.12 or newer\&. +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBWarning\fR +.ps -1 +.br +.sp +On an unsupported system, the USB device can still be recognized as a USB ACM device, but communication is impossible, please don\(cqt waste your time on \fBcdc_acm\fR\&. +.sp .5v +.RE +.sp +If you\(cqre already running on Linux 5\&.12 or newer kernels, but still cannot see the \fBxr_serial\fR driver, it means the driver is not enabled in your kernel build\&. If you\(cqre a regular user, you should file a bug report to your Linux distro maintainers and ask them to enable \fBxr_serial\fR (kernel option CONFIG_USB_SERIAL_XR)\&. +.sp +When upgrading the Linux kernel isn\(cqt an option, or when you are using another operating system (e\&.g\&. FreeBSD), RS\-232 must be used\&. +.SS "RS\-232" +.sp +RS\-232 is supported on all operating systems, either via a built\-in serial port on your computer, or by using an external USB\-to\-RS\-232 converter\&. If you plan to use an USB\-to\-RS\-232 converter, make sure it\(cqs supported by your operating system\&. +.SH "INSTALLATION" +.sp +This driver is not built by default\&. You can build it by installing libmodbus (with development packages) and running +.sp +.if n \{\ +.RS 4 +.\} +.nf +configure \-\-with\-serial=yes \-\-with\-modbus=yes +.fi +.if n \{\ +.RE +.\} +.sp +You also need to give proper (R/W) permissions on the local serial device file to allow the NUT driver run\-time user to access it\&. This may need additional setup for start\-up scripting, udev or upower rules, to apply the rights on every boot \(em especially if your device nodes are tracked by a virtual filesystem\&. +.sp +For example, a USB\-to\-serial converter can be identified as /dev/ttyACM0 or /dev/ttyUSB0 on Linux, or /dev/ttyU0 on FreeBSD (note the capital "U")\&. A built\-in serial port can be identified as /dev/ttyS0 on Linux or one of /dev/cua* names on FreeBSD\&. +.SH "EXTRA ARGUMENTS" +.sp +This driver supports the following optional settings in the \fBups.conf\fR(5) file: +.PP +\fBoffdelay=\fR\fIvalue\fR +.RS 4 +Time to wait before shutting down the UPS (seconds), acceptable range is 6 seconds (0\&.1 minutes) to 5940 seconds (99 minutes)\&. Defaults to 60 seconds\&. Must be a multiple of 6 seconds\&. To ensure your system has adequate time to shut down after a power failure, it\(cqs highly recommended to adjust +\fBoffdelay\fR\&. +.RE +.PP +\fBrebootdelay=\fR\fIvalue\fR +.RS 4 +Time to wait before rebooting the UPS (seconds), acceptable range is 6 seconds (0\&.1 minutes) to 5940 seconds (99 minutes)\&. Defaults to 60 seconds\&. Must be a multiple of 6 seconds\&. This is used by the +\fBshutdown\&.reboot\&.graceful\fR +instant command\&. If you\(cqve adjusted +\fBoffdelay\fR, you should also adjust +\fBrebootdelay\fR\&. +.RE +.PP +\fBondelay=\fR\fIvalue\fR +.RS 4 +Time to wait before switching on the UPS (seconds), acceptable range is 60 seconds (1 minutes) to 5940 seconds (99 minutes)\&. Defaults to 60 seconds\&. Must be a multiple of 60 seconds (not 6 seconds)\&. You don\(cqt need to adjust this delay unless you have special requirements\&. +.RE +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +Due to hardware limitation, in this driver, \fBondelay\fR is respected only when line power is available\&. If a power failure has occurred, the UPS and the load is always immediately switched on, as soon (or as late) as line power is restored\&. +.sp .5v +.RE +.SH "INSTANT COMMANDS" +.sp +This driver supports some instant commands (see \fBupscmd\fR(8)): +.PP +\fBshutdown\&.stayoff\fR +.RS 4 +After an +\fBoffdelay\fR, turn off the load\&. When line power is back, remain off\&. +.RE +.PP +\fBshutdown\&.return\fR +.RS 4 +After an +\fBoffdelay\fR, turn off the load\&. When line power is back, turn on the load, possibly after an +\fBondelay\fR\&. +.RE +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +Normally, the load is turned on as soon as line power is back\&. But if line power is never lost, or has came back unexpectedly in the middle of an ongoing shutdown (an undesirable "power race" condition that many entry\-level products on the market fail to recover from), the load is turned on after an \fBondelay\fR\&. Thus, UPS2000 is unaffected by a power race, the load is guaranteed to always restart\&. +.sp .5v +.RE +.PP +\fBshutdown\&.reboot\fR +.RS 4 +Like +\fBshutdown\&.return\fR, except that the load is turned off immediately (6 seconds in this implementation)\&. +.RE +.PP +\fBshutdown\&.reboot\&.graceful\fR +.RS 4 +Like +\fBshutdown\&.return\fR, except that the load is turned off after a +\fBrebootdelay\fR, not an +\fBoffdelay\fR\&. +.RE +.PP +\fBbeeper\&.enable\fR +.RS 4 +Enable the UPS beeper\&. +.RE +.PP +\fBbeeper\&.disable\fR +.RS 4 +Disable the UPS beeper\&. +.RE +.PP +\fBbeeper\&.toggle\fR +.RS 4 +Toggle the UPS beeper\&. +.RE +.PP +\fBbypass\&.start\fR +.RS 4 +Put the UPS in bypass mode\&. Use with caution\&. It exposes your equipment to unregulated line power and provides no protection from power failures\&. Also, the UPS may shut down whenever the bypass input voltage is out of the nominal range\&. As a warning, the UPS beeps once every 10 seconds in bypass mode\&. +.RE +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +The driver has a basic foolproof mechanism\&. If the bypass input is already abnormal due to a power failure, the driver refuses to enter bypass mode by aborting the command and logging an error\&. However, it offers no protection after the UPS has entered (or in the middle of entering) bypass mode\&. Thus, again, use with caution\&. +.sp .5v +.RE +.PP +\fBbypass\&.stop\fR +.RS 4 +Put the UPS out of bypass mode\&. +.RE +.PP +\fBload\&.on\fR +.RS 4 +Turn on the load immediately\&. +.RE +.PP +\fBload\&.off\fR +.RS 4 +Turn off the load immediately\&. Use with caution, everything on the UPS will lost power\&. +.RE +.PP +\fBtest\&.battery\&.start\&.quick\fR +.RS 4 +Perform a short battery test\&. +.RE +.PP +\fBtest\&.battery\&.start\&.deep\fR +.RS 4 +Perform a long battery test\&. +.RE +.PP +\fBtest\&.battery\&.stop\fR +.RS 4 +Stop a running battery test\&. +.RE +.SH "VARIABLES" +.sp +This driver supports some writable runtime variables (see \fBupsrw\fR(8)): +.PP +\fBups\&.beeper\&.status\fR +.RS 4 +Enable or disable the UPS beeper, +\fBdisabled\fR +or +\fBenabled\fR\&. +.RE +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +The beeper can only be disabled completely, it cannot be temporally muted until the next alarm, but the option \fBmuted\fR is also accepted for convenience, \fBmuted\fR is treated as an alias of \fBdisabled\fR\&. +.sp .5v +.RE +.PP +\fBups\&.delay\&.shutdown\fR +.RS 4 +Seconds to wait after shutdown with delay command\&. It\(cqs the runtime equivalent of +\fBoffdelay\fR\&. See description of +\fBoffdelay\fR\&. +.RE +.PP +\fBups\&.delay\&.reboot\fR +.RS 4 +Seconds to wait before rebooting the UPS, it\(cqs the runtime equivalent of +\fBrebootdelay\fR\&. See description of +\fBrebootdelay\fR\&. +.RE +.PP +\fBups\&.delay\&.start\fR +.RS 4 +Seconds to wait before restarting the load, it\(cqs the runtime equivalent of +\fBondelay\fR\&. See description of +\fBondelay\fR\&. +.RE +.SH "KNOWN ISSUES AND BUGS" +.SS "Battery status has a non\-fatal read failure" +.sp +It\(cqs usually harmless and can be safely ignored\&. It\(cqs only logged for informative purposes (\fBLOG_INFO\fR), not as a warning or error\&. +.SS "Data stale" +.sp +Under certain circumstances, some registers can return invalid values and trigger a "data stale" error\&. Once a data stale error has occurred, you should see error messages similar to the example below in the system log\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf +huawei\-ups2000: register 2002 has invalid value a000, +upsd: Data for UPS [huawei] is stale \- check driver +upsd: UPS [huawei] data is no longer stale +.fi +.if n \{\ +.RE +.\} +.sp +So far all known problems have been fixed by the author, but an unknown one cannot be ruled out\&. If you have encountered "data stale" problems during normal uses, please file a bug report with full logs attached\&. +.sp +Before troubleshooting or reporting a problem, it\(cqs important to check your \fBdmesg\fR log for USB connect and disconnect events to avoid wasting time on the NUT driver when the actual problem is USB\&. For example, if someone yanks the cable out of the USB port, or if a new USB device is plugged into a USB host/hub that is struggling to power its ports (common on single\-board computers like Raspberry Pi), or if you have flaky cabling or EMI noise, the serial converter can get disconnected from USB, at least briefly\&. This creates a permanent data stale, the driver must be restarted (plugging the USB back won\(cqt fix it, since the driver is still using the nonexistent serial device)\&. These USB problems usually have nothing to do with NUT\&. If it\(cqs the case, you should solve the underlying USB problem \- check the cable, check the converter, try a powered USB hub, try a full\-speed USB isolator, etc\&. +.SS "Serial port becomes unresponsive" +.sp +Some malformed commands are known to lock up the serial port (including USB, which is a USB\-to\-serial device)\&. Upon receiving them, UPS2000 stops all serial communications\&. The result is a completely unresponsive UPS, regardless of what you do \- restarting NUT, rebooting the computer \- cannot restore connectivity, as if someone has unplugged the RS\-232 cable\&. To recover, simply power cycle the UPS: Turn off the UPS output via the front panel, then unplug the UPS from line power\&. Wait for the LCD front screen to go black\&. Finally reconnect line power and restart your UPS\&. +.sp +That being said, a serial port lockup is unlikely to happen\&. To our best knowledge, this driver never sends malformed commands to the UPS (it was only a problem during early development)\&. Furthermore, due to a CRC checksum, they\(cqre unlikely to be accidentally generated\&. +.sp +Still, we recommend to power cycle your UPS after making a cabling change, especially after changing from RS\-485/USB to RS\-232, just to ensure the UPS selects the correct communication interface\&. Also, if you have discovered a reproducible serial port lockup problem, it can be an previously unknown bug, make sure to file a bug report\&. +.SS "USB is unsupported" +.sp +As previously stated, only RS\-232 is supported on all systems\&. USB requires a device\-specific driver, which is only available on Linux 5\&.12 and newer kernels\&. +.sp +On an unsupported system, the USB device can still be recognized as a USB ACM device, but in reality, communication is impossible\&. It can only be fixed by implementing a driver for your system, nothing can be done within NUT\&. +.sp +Finally, in the unlike scenario that you are using NUT on Microsoft Windows, you should be able to install the USB device driver following the steps in the Huawei UPS2000 (1 kVA\-3 kVA) Modbus Protocol Development Guide\&. +.SH "AUTHOR" +.sp +Yifeng Li +.SH "SEE ALSO" +.SS "The core driver:" +.sp +\fBnutupsdrv\fR(8) +.SS "Internet resources:" +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The NUT (Network UPS Tools) home page: +http://www\&.networkupstools\&.org/ +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Huawei UPS2000\-A (1 kVA\-3 kVA) User Manual: +https://support\&.huawei\&.com/enterprise/en/doc/EDOC1000084260 +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Huawei UPS2000 (1 kVA\-3 kVA) Modbus Protocol Development Guide: +https://support\&.huawei\&.com/enterprise/en/doc/EDOC1000110696 +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +libmodbus home page: +http://libmodbus\&.org +.RE diff --git a/docs/man/huawei-ups2000.txt b/docs/man/huawei-ups2000.txt new file mode 100644 index 0000000..af38350 --- /dev/null +++ b/docs/man/huawei-ups2000.txt @@ -0,0 +1,364 @@ +HUAWEI_UPS2000(8) +================== + +NAME +---- + +huawei-ups2000 - Driver for Huawei UPS2000 (1kVA-3kVA) UPS with USB or +RS-232 serial Modbus connection. + +SYNOPSIS +-------- + +*huawei-ups2000* -h + +*huawei-ups2000* -a 'DEVICE_NAME' ['OPTIONS'] + +NOTE: This man page only documents the hardware-specific features of the +huawei-ups2000 driver. For information about the core driver, see +linkman:nutupsdrv[8]. + +SUPPORTED HARDWARE +------------------ + +This driver supports Huawei UPS2000 series, online (double conversion) +UPS with the following characteristics. + +1. Output power: 1 kVA to 3 kVA (higher power models are unsupported). + +2. Connection: USB or RS-232 (USB is only supported on Linux 5.12 and +newer kernels, read the section *Cabling* carefully). + +The UPS2000 series has two variants: UPS2000-A with a tower chassis, +and UPS2000-G with a rack-mount chassis. Both should be equally supported, +but more testers are needed. + +Currently, it has been tested on the following models. + +* UPS2000-A-1KTTS (firmware: V2R1C1SPC40, P1.0-D1.0) +* UPS2000-A-2KTTS (firmware: V2R1C1SPC50, P1.0-D1.0) +* UPS2000-G-3KRTS (firmware: V2R1C1SPC40, P1.0-D1.0) + +If your model is not in the list, we encourage you to report successful +or unsuccessful results to the bug tracker or the mailing list. +Make sure to include the full model number of your UPS manually +in your report, because the firmware only reports "UPS2000-A" +for all models, including the G series. + +huawei-ups2000 uses the libmodbus project, for Modbus implementation. + +CABLING +------- + +The UPS has a USB port and a RS-232 port. Both are supported, but USB is +only usable on Linux 5.12 and later, via the *xr_serial* kernel module (see +subsection *USB* for details). RS-232 is supported on all operating systems. + +Only one port can be used at a time. When USB is used, RS-232 should be +unplugged from the UPS, and vice versa. Further, optional adapter cards, +such as RS-485 or SNMP, are not supported. They should be removed from +the UPS. + +Because the UPS port can be unresponsive under certain circumstances, it's +recommended to power cycle your UPS after making a cabling change, especially +after changing the port type. That is, turn off the UPS power output via the +front panel, then unplug the UPS from line power input. Wait for the LCD +screen to go black. Finally reconnect line power and restart your UPS. + +USB +~~~~ + +The USB port on the UPS2000 is powered by a MaxLinear/Exar RX21V1410 +USB-to-serial converter chip, it's only supported by Linux 5.12 or +newer, via the *xr_serial* kernel module. + +When the UPS2000 is connected via USB to a supported Linux system, +you should see the following logs in *dmesg*. + + xr_serial 1-1.2:1.1: xr_serial converter detected + usb 1-1.2: xr_serial converter now attached to ttyUSB0 + +The driver must be *xr_serial*. If your system doesn't have the +necessary device driver, you will get this message instead: + + cdc_acm 1-1.2:1.0: ttyACM0: USB ACM device + +The generic driver *cdc_acm* is incompatible and cannot be used. +You should upgrade your Linux kernel to Linux 5.12 or newer. + +WARNING: On an unsupported system, the USB device can still be +recognized as a USB ACM device, but communication is impossible, +please don't waste your time on *cdc_acm*. + +If you're already running on Linux 5.12 or newer kernels, but still +cannot see the *xr_serial* driver, it means the driver is not enabled +in your kernel build. If you're a regular user, you should file a bug +report to your Linux distro maintainers and ask them to enable +*xr_serial* (kernel option `CONFIG_USB_SERIAL_XR`). + +When upgrading the Linux kernel isn't an option, or when you are using +another operating system (e.g. FreeBSD), RS-232 must be used. + +RS-232 +~~~~~~ + +RS-232 is supported on all operating systems, either via a built-in serial +port on your computer, or by using an external USB-to-RS-232 converter. If +you plan to use an USB-to-RS-232 converter, make sure it's supported by your +operating system. + + +INSTALLATION +------------ + +This driver is not built by default. You can build it by installing libmodbus +(with development packages) and running + + configure --with-serial=yes --with-modbus=yes + +You also need to give proper (R/W) permissions on the local serial device file +to allow the NUT driver run-time user to access it. This may need additional +setup for start-up scripting, udev or upower rules, to apply the rights on every +boot -- especially if your device nodes are tracked by a virtual filesystem. + +For example, a USB-to-serial converter can be identified as `/dev/ttyACM0` +or `/dev/ttyUSB0` on Linux, or `/dev/ttyU0` on FreeBSD (note the capital "U"). +A built-in serial port can be identified as `/dev/ttyS0` on Linux or one of +`/dev/cua*` names on FreeBSD. + +EXTRA ARGUMENTS +--------------- +This driver supports the following optional settings in the +linkman:ups.conf[5] file: + +*offdelay=*'value':: +Time to wait before shutting down the UPS (seconds), acceptable range is +6 seconds (0.1 minutes) to 5940 seconds (99 minutes). Defaults to 60 seconds. +Must be a multiple of 6 seconds. To ensure your system has adequate time +to shut down after a power failure, it's highly recommended to adjust +*offdelay*. + +*rebootdelay=*'value':: +Time to wait before rebooting the UPS (seconds), acceptable range is +6 seconds (0.1 minutes) to 5940 seconds (99 minutes). Defaults to 60 seconds. +Must be a multiple of 6 seconds. This is used by the *shutdown.reboot.graceful* +instant command. If you've adjusted *offdelay*, you should also adjust +*rebootdelay*. + +*ondelay=*'value':: +Time to wait before switching on the UPS (seconds), acceptable range is +60 seconds (1 minutes) to 5940 seconds (99 minutes). Defaults to 60 seconds. +Must be a multiple of 60 seconds (not 6 seconds). You don't need to adjust +this delay unless you have special requirements. + +NOTE: Due to hardware limitation, in this driver, *ondelay* is respected +only when line power is available. If a power failure has occurred, the +UPS and the load is always immediately switched on, as soon (or as late) +as line power is restored. + +INSTANT COMMANDS +---------------- + +This driver supports some instant commands (see linkman:upscmd[8]): + +*shutdown.stayoff*:: +After an *offdelay*, turn off the load. When line power is back, +remain off. + +*shutdown.return*:: +After an *offdelay*, turn off the load. When line power is back, +turn on the load, possibly after an *ondelay*. + +NOTE: Normally, the load is turned on as soon as line power is back. +But if line power is never lost, or has came back unexpectedly +in the middle of an ongoing shutdown (an undesirable "power race" +condition that many entry-level products on the market fail to +recover from), the load is turned on after an *ondelay*. Thus, +UPS2000 is unaffected by a power race, the load is guaranteed to +always restart. + +*shutdown.reboot*:: +Like *shutdown.return*, except that the load is turned off immediately +(6 seconds in this implementation). + +*shutdown.reboot.graceful*:: +Like *shutdown.return*, except that the load is turned off after a +*rebootdelay*, not an *offdelay*. + +*beeper.enable*:: + +Enable the UPS beeper. + +*beeper.disable*:: + +Disable the UPS beeper. + +*beeper.toggle*:: + +Toggle the UPS beeper. + +*bypass.start*:: + +Put the UPS in bypass mode. Use with caution. It exposes your equipment +to unregulated line power and provides no protection from power failures. +Also, the UPS may shut down whenever the bypass input voltage is out +of the nominal range. As a warning, the UPS beeps once every 10 seconds +in bypass mode. + +NOTE: The driver has a basic foolproof mechanism. If the bypass input +is already abnormal due to a power failure, the driver refuses to enter +bypass mode by aborting the command and logging an error. However, it +offers no protection after the UPS has entered (or in the middle of +entering) bypass mode. Thus, again, use with caution. + +*bypass.stop*:: + +Put the UPS out of bypass mode. + +*load.on*:: + +Turn on the load immediately. + +*load.off*:: + +Turn off the load immediately. Use with caution, everything on the UPS +will lost power. + +*test.battery.start.quick*:: + +Perform a short battery test. + +*test.battery.start.deep*:: + +Perform a long battery test. + +*test.battery.stop*:: + +Stop a running battery test. + +VARIABLES +--------- + +This driver supports some writable runtime variables (see linkman:upsrw[8]): + +**ups.beeper.status**:: +Enable or disable the UPS beeper, *disabled* or *enabled*. + +NOTE: The beeper can only be disabled completely, it cannot be +temporally muted until the next alarm, but the option *muted* is +also accepted for convenience, *muted* is treated as an alias of +*disabled*. + +**ups.delay.shutdown**:: +Seconds to wait after shutdown with delay command. It's the runtime +equivalent of *offdelay*. See description of *offdelay*. + +**ups.delay.reboot**:: +Seconds to wait before rebooting the UPS, it's the runtime +equivalent of *rebootdelay*. See description of *rebootdelay*. + +**ups.delay.start**:: +Seconds to wait before restarting the load, it's the runtime +equivalent of *ondelay*. See description of *ondelay*. + +KNOWN ISSUES AND BUGS +--------------------- + +Battery status has a non-fatal read failure +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +It's usually harmless and can be safely ignored. It's only logged for +informative purposes (*LOG_INFO*), not as a warning or error. + +Data stale +~~~~~~~~~~~ + +Under certain circumstances, some registers can return invalid values +and trigger a "data stale" error. Once a data stale error has occurred, +you should see error messages similar to the example below in the system +log. + + huawei-ups2000: register 2002 has invalid value a000, + upsd: Data for UPS [huawei] is stale - check driver + upsd: UPS [huawei] data is no longer stale + +So far all known problems have been fixed by the author, but an unknown one +cannot be ruled out. If you have encountered "data stale" problems during +normal uses, please file a bug report with full logs attached. + +Before troubleshooting or reporting a problem, it's important to check +your *dmesg* log for USB connect and disconnect events to avoid wasting +time on the NUT driver when the actual problem is USB. For example, if +someone yanks the cable out of the USB port, or if a new USB device is +plugged into a USB host/hub that is struggling to power its ports +(common on single-board computers like Raspberry Pi), or if you have +flaky cabling or EMI noise, the serial converter can get disconnected +from USB, at least briefly. This creates a permanent data stale, the driver +must be restarted (plugging the USB back won't fix it, since the driver +is still using the nonexistent serial device). These USB problems usually +have nothing to do with NUT. If it's the case, you should solve the +underlying USB problem - check the cable, check the converter, try a +powered USB hub, try a full-speed USB isolator, etc. + +Serial port becomes unresponsive +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Some malformed commands are known to lock up the serial port (including +USB, which is a USB-to-serial device). Upon receiving them, UPS2000 stops +all serial communications. The result is a completely unresponsive UPS, +regardless of what you do - restarting NUT, rebooting the computer - +cannot restore connectivity, as if someone has unplugged the RS-232 cable. +To recover, simply power cycle the UPS: Turn off the UPS output via the +front panel, then unplug the UPS from line power. Wait for the LCD front +screen to go black. Finally reconnect line power and restart your UPS. + +That being said, a serial port lockup is unlikely to happen. To our best +knowledge, this driver never sends malformed commands to the UPS (it was +only a problem during early development). Furthermore, due to a CRC checksum, +they're unlikely to be accidentally generated. + +Still, we recommend to power cycle your UPS after making a cabling change, +especially after changing from RS-485/USB to RS-232, just to ensure the +UPS selects the correct communication interface. Also, if you have +discovered a reproducible serial port lockup problem, it can be an +previously unknown bug, make sure to file a bug report. + +USB is unsupported +~~~~~~~~~~~~~~~~~~~ + +As previously stated, only RS-232 is supported on all systems. USB +requires a device-specific driver, which is only available on Linux +5.12 and newer kernels. + +On an unsupported system, the USB device can still be recognized as a +USB ACM device, but in reality, communication is impossible. It can +only be fixed by implementing a driver for your system, nothing can +be done within NUT. + +Finally, in the unlike scenario that you are using NUT on Microsoft +Windows, you should be able to install the USB device driver following +the steps in the Huawei UPS2000 (1 kVA-3 kVA) Modbus Protocol Development +Guide. + +AUTHOR +------ + +Yifeng Li + +SEE ALSO +-------- + +The core driver: +~~~~~~~~~~~~~~~~ + +linkman:nutupsdrv[8] + +Internet resources: +~~~~~~~~~~~~~~~~~~~ + +* The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ +* Huawei UPS2000-A (1 kVA-3 kVA) User Manual: + https://support.huawei.com/enterprise/en/doc/EDOC1000084260 +* Huawei UPS2000 (1 kVA-3 kVA) Modbus Protocol Development Guide: + https://support.huawei.com/enterprise/en/doc/EDOC1000110696 +* libmodbus home page: http://libmodbus.org diff --git a/docs/man/isbmex.8 b/docs/man/isbmex.8 index 3496fe2..6083184 100644 --- a/docs/man/isbmex.8 +++ b/docs/man/isbmex.8 @@ -1,13 +1,13 @@ '\" t .\" Title: isbmex .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "ISBMEX" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "ISBMEX" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/isbmex.txt b/docs/man/isbmex.txt index 9b97d16..985f0ff 100644 --- a/docs/man/isbmex.txt +++ b/docs/man/isbmex.txt @@ -15,6 +15,7 @@ linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + This driver supports SOLA/BASIC Mexico ISBMEX protocol UPS equipment. EXTRA ARGUMENTS @@ -25,6 +26,7 @@ linkman:ups.conf[5]. AUTHOR ------ + Edscott Wilson Garcia SEE ALSO @@ -32,8 +34,10 @@ SEE ALSO The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/ivtscd.8 b/docs/man/ivtscd.8 index 2854115..6bdbb80 100644 --- a/docs/man/ivtscd.8 +++ b/docs/man/ivtscd.8 @@ -1,13 +1,13 @@ '\" t .\" Title: ivtscd .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "IVTSCD" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "IVTSCD" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/ivtscd.txt b/docs/man/ivtscd.txt index 6a2c7c4..0696c87 100644 --- a/docs/man/ivtscd.txt +++ b/docs/man/ivtscd.txt @@ -3,32 +3,40 @@ IVTSCD(8) NAME ---- + ivtscd - driver for the IVT Solar Controller Device NOTE ---- + This man page only documents the hardware-specific features of the *ivtscd* driver. For information about the core driver, see linkman:nutupsdrv[8]. DESCRIPTION ----------- + This driver allows to access the IVT SCD-series devices. EXTRA ARGUMENTS --------------- + This driver does not support any extra argument. AUTHOR ------ + Arjen de Korte SEE ALSO -------- + The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/libnutclient.3 b/docs/man/libnutclient.3 index 1fdb60f..f41cd09 100644 --- a/docs/man/libnutclient.3 +++ b/docs/man/libnutclient.3 @@ -1,13 +1,13 @@ '\" t .\" Title: libnutclient -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "LIBNUTCLIENT" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "LIBNUTCLIENT" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/libnutclient.txt b/docs/man/libnutclient.txt index d23b705..668eb83 100644 --- a/docs/man/libnutclient.txt +++ b/docs/man/libnutclient.txt @@ -39,10 +39,12 @@ See the `nutclient.h` header for more information. ERROR HANDLING -------------- + There is currently no specific mechanism around error handling. SEE ALSO -------- + linkman:libnutclient_devices[3] linkman:libnutclient_commands[3] linkman:libnutclient_general[3] diff --git a/docs/man/libnutclient_commands.3 b/docs/man/libnutclient_commands.3 index 649a757..e202009 100644 --- a/docs/man/libnutclient_commands.3 +++ b/docs/man/libnutclient_commands.3 @@ -1,13 +1,13 @@ '\" t .\" Title: libnutclient_commands -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "LIBNUTCLIENT_COMMAND" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "LIBNUTCLIENT_COMMAND" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -40,26 +40,121 @@ typedef void* NUTCLIENT_t; .fi .sp .nf -strarr nutclient_get_device_commands(NUTCLIENT_t client, const char* dev); -int nutclient_has_device_command(NUTCLIENT_t client, const char* dev, const char* cmd); -char* nutclient_get_device_command_description(NUTCLIENT_t client, const char* dev, const char* cmd); -void nutclient_execute_device_command(NUTCLIENT_t client, const char* dev, const char* cmd); +typedef char** strarr; +.fi +.sp +.nf +strarr nutclient_get_device_commands( + NUTCLIENT_t client, + const char* dev); +.fi +.sp +.nf +int nutclient_has_device_command( + NUTCLIENT_t client, + const char* dev, const char* cmd); +.fi +.sp +.nf +char* nutclient_get_device_command_description( + NUTCLIENT_t client, + const char* dev, const char* cmd); +.fi +.sp +.nf +void nutclient_execute_device_command( + NUTCLIENT_t client, + const char* dev, const char* cmd, + const char* param=""); .fi .SH "DESCRIPTION" .sp These functions allow to manage instant commands of devices\&. .sp -The \fBnutclient_get_device_commands()\fR function retrieve the list of command names for a device\&. The returned strarr must be freed by \fIstrarr_free\fR\&. +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The +\fBnutclient_get_device_commands()\fR +function retrieves the list of command names for a device\&. .sp -The \fBnutclient_has_device_command\fR function test if the specified command is supported by the device\&. Return 1 is supported and 0 if not\&. +The returned strarr must be freed by +\fIstrarr_free\fR\&. +.RE .sp -The \fBnutclient_get_device_command_description\fR function retrieve the command description, if any\&. The resturned string must be freed\&. +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The +\fBnutclient_has_device_command\fR +function tests if the specified command is supported by the device\&. .sp -The \fBnutclient_execute_device_command\fR intend to execute the instant command\&. +Return 1 is supported and 0 if not\&. +.RE .sp -\fIdev\fR is the device name\&. +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The +\fBnutclient_get_device_command_description\fR +function retrieves the command description, if any\&. .sp -\fIcmd\fR is the instant command name\&. +The returned string must be freed\&. +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The +\fBnutclient_execute_device_command\fR +intends to execute the instant command, with an optional parameter\&. +.RE +.sp +Common arguments: +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fIdev\fR +is the device name\&. +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fIcmd\fR +is the instant command name\&. +.RE .SH "SEE ALSO" .sp \fBlibnutclient\fR(3) \fBlibnutclient_devices\fR(3) \fBlibnutclient_general\fR(3) diff --git a/docs/man/libnutclient_commands.txt b/docs/man/libnutclient_commands.txt index 339fd2c..33a90ca 100644 --- a/docs/man/libnutclient_commands.txt +++ b/docs/man/libnutclient_commands.txt @@ -4,9 +4,11 @@ LIBNUTCLIENT_COMMANDS(3) NAME ---- -libnutclient_commands, nutclient_get_device_commands, nutclient_has_device_command, -nutclient_get_device_command_description, nutclient_execute_device_command - -Instant command related functions in Network UPS Tools high-level client access library +libnutclient_commands, nutclient_get_device_commands, +nutclient_has_device_command, nutclient_get_device_command_description, +nutclient_execute_device_command - +Instant command related functions in Network UPS Tools high-level client +access library SYNOPSIS -------- @@ -15,33 +17,57 @@ SYNOPSIS typedef void* NUTCLIENT_t; - strarr nutclient_get_device_commands(NUTCLIENT_t client, const char* dev); - int nutclient_has_device_command(NUTCLIENT_t client, const char* dev, const char* cmd); - char* nutclient_get_device_command_description(NUTCLIENT_t client, const char* dev, const char* cmd); - void nutclient_execute_device_command(NUTCLIENT_t client, const char* dev, const char* cmd); + typedef char** strarr; + + strarr nutclient_get_device_commands( + NUTCLIENT_t client, + const char* dev); + + int nutclient_has_device_command( + NUTCLIENT_t client, + const char* dev, const char* cmd); + + char* nutclient_get_device_command_description( + NUTCLIENT_t client, + const char* dev, const char* cmd); + + void nutclient_execute_device_command( + NUTCLIENT_t client, + const char* dev, const char* cmd, + const char* param=""); DESCRIPTION ----------- These functions allow to manage instant commands of devices. -The *nutclient_get_device_commands()* function retrieve the list of command names for a device. +* The *nutclient_get_device_commands()* function retrieves + the list of command names for a device. ++ The returned strarr must be freed by 'strarr_free'. -The *nutclient_has_device_command* function test if the specified command is supported by the device. +* The *nutclient_has_device_command* function tests if the + specified command is supported by the device. ++ Return 1 is supported and 0 if not. -The *nutclient_get_device_command_description* function retrieve the command description, if any. -The resturned string must be freed. +* The *nutclient_get_device_command_description* function + retrieves the command description, if any. ++ +The returned string must be freed. -The *nutclient_execute_device_command* intend to execute the instant command. +* The *nutclient_execute_device_command* intends to execute + the instant command, with an optional parameter. -'dev' is the device name. +Common arguments: -'cmd' is the instant command name. +* 'dev' is the device name. + +* 'cmd' is the instant command name. SEE ALSO -------- + linkman:libnutclient[3] linkman:libnutclient_devices[3] linkman:libnutclient_general[3] diff --git a/docs/man/libnutclient_devices.3 b/docs/man/libnutclient_devices.3 index 5874269..9e9385e 100644 --- a/docs/man/libnutclient_devices.3 +++ b/docs/man/libnutclient_devices.3 @@ -1,13 +1,13 @@ '\" t .\" Title: libnutclient_devices -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "LIBNUTCLIENT_DEVICES" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "LIBNUTCLIENT_DEVICES" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -40,21 +40,81 @@ typedef void* NUTCLIENT_t; .fi .sp .nf +typedef char** strarr; +.fi +.sp +.nf strarr nutclient_get_devices(NUTCLIENT_t client); +.fi +.sp +.nf int nutclient_has_device(NUTCLIENT_t client, const char* dev); +.fi +.sp +.nf char* nutclient_get_device_description(NUTCLIENT_t client, const char* dev); .fi .SH "DESCRIPTION" .sp These functions allow to manage devices\&. .sp -The \fBnutclient_get_devices()\fR function retrieve the list of devices monitored by a client\&. The returned strarr must be freed by \fIstrarr_free\fR\&. +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The +\fBnutclient_get_devices()\fR +function retrieves the list of devices monitored by a client\&. .sp -The \fBnutclient_has_device()\fR function test if a device is monitored by a client\&. +The returned strarr must be freed by +\fIstrarr_free\fR\&. +.RE .sp -The \fBnutclient_get_device_description()\fR function retrieve the device description\&. The returned description string must be freed\&. +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The +\fBnutclient_has_device()\fR +function tests if a device is monitored by a client\&. +.RE .sp -\fIdev\fR is the device name\&. +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The +\fBnutclient_get_device_description()\fR +function retrieves the device description\&. +.sp +The returned description string must be freed\&. +.RE +.sp +Common arguments: +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fIdev\fR +is the device name\&. +.RE .SH "SEE ALSO" .sp \fBlibnutclient\fR(3) \fBlibnutclient_commands\fR(3) \fBlibnutclient_devices\fR(3) \fBlibnutclient_general\fR(3) \fBlibnutclient_variables\fR(3) diff --git a/docs/man/libnutclient_devices.txt b/docs/man/libnutclient_devices.txt index dd69101..700673f 100644 --- a/docs/man/libnutclient_devices.txt +++ b/docs/man/libnutclient_devices.txt @@ -4,8 +4,10 @@ LIBNUTCLIENT_DEVICES(3) NAME ---- -libnutclient_devices, nutclient_get_devices, nutclient_has_device, nutclient_get_device_description - -Device related functions in Network UPS Tools high-level client access library +libnutclient_devices, nutclient_get_devices, nutclient_has_device, +nutclient_get_device_description - +Device related functions in Network UPS Tools high-level client access +library SYNOPSIS -------- @@ -14,8 +16,12 @@ SYNOPSIS typedef void* NUTCLIENT_t; + typedef char** strarr; + strarr nutclient_get_devices(NUTCLIENT_t client); + int nutclient_has_device(NUTCLIENT_t client, const char* dev); + char* nutclient_get_device_description(NUTCLIENT_t client, const char* dev); DESCRIPTION @@ -23,21 +29,28 @@ DESCRIPTION These functions allow to manage devices. -The *nutclient_get_devices()* function retrieve the list of devices monitored by a client. +* The *nutclient_get_devices()* function retrieves the list of devices + monitored by a client. ++ The returned strarr must be freed by 'strarr_free'. -The *nutclient_has_device()* function test if a device is monitored by a client. +* The *nutclient_has_device()* function tests if a device is monitored + by a client. -The *nutclient_get_device_description()* function retrieve the device description. +* The *nutclient_get_device_description()* function retrieves the device + description. ++ The returned description string must be freed. -'dev' is the device name. +Common arguments: + +* 'dev' is the device name. SEE ALSO -------- + linkman:libnutclient[3] linkman:libnutclient_commands[3] linkman:libnutclient_devices[3] linkman:libnutclient_general[3] linkman:libnutclient_variables[3] - diff --git a/docs/man/libnutclient_general.3 b/docs/man/libnutclient_general.3 index 925a2d6..7487cad 100644 --- a/docs/man/libnutclient_general.3 +++ b/docs/man/libnutclient_general.3 @@ -1,13 +1,13 @@ '\" t .\" Title: libnutclient_general -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "LIBNUTCLIENT_GENERAL" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "LIBNUTCLIENT_GENERAL" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -49,6 +49,9 @@ typedef char** strarr; .sp .nf strarr strarr_alloc(unsigned short count); +.fi +.sp +.nf void strarr_free(strarr arr); .fi .SH "DESCRIPTION" diff --git a/docs/man/libnutclient_general.txt b/docs/man/libnutclient_general.txt index 909549a..7d41acf 100644 --- a/docs/man/libnutclient_general.txt +++ b/docs/man/libnutclient_general.txt @@ -5,7 +5,8 @@ NAME ---- libnutclient_general, nutclient_destroy, strarr_alloc, strarr_free - -General and utility functions in Network UPS Tools high-level client access library +General and utility functions in Network UPS Tools high-level client +access library SYNOPSIS -------- @@ -19,6 +20,7 @@ SYNOPSIS typedef char** strarr; strarr strarr_alloc(unsigned short count); + void strarr_free(strarr arr); DESCRIPTION @@ -42,4 +44,5 @@ It also frees all pointed strings. SEE ALSO -------- + linkman:libnutclient[3] diff --git a/docs/man/libnutclient_misc.3 b/docs/man/libnutclient_misc.3 index 0092a25..0485cba 100644 --- a/docs/man/libnutclient_misc.3 +++ b/docs/man/libnutclient_misc.3 @@ -1,13 +1,13 @@ '\" t .\" Title: libnutclient_misc -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "LIBNUTCLIENT_MISC" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "LIBNUTCLIENT_MISC" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -28,7 +28,7 @@ .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" -libnutclient_misc, nutclient_authenticate, nutclient_logout, nutclient_device_login, nutclient_get_device_num_logins, nutclient_device_master, nutclient_device_forced_shutdown \- Miscelaneous functions in Network UPS Tools high\-level client access library +libnutclient_misc, nutclient_authenticate, nutclient_logout, nutclient_device_login, nutclient_get_device_num_logins, nutclient_device_master, nutclient_device_forced_shutdown \- Miscellaneous functions in Network UPS Tools high\-level client access library .SH "SYNOPSIS" .sp .nf @@ -40,28 +40,67 @@ typedef void* NUTCLIENT_t; .fi .sp .nf -void nutclient_authenticate(NUTCLIENT_t client, const char* login, const char* passwd); +void nutclient_authenticate( + NUTCLIENT_t client, + const char* login, const char* passwd); +.fi +.sp +.nf void nutclient_logout(NUTCLIENT_t client); +.fi +.sp +.nf void nutclient_device_login(NUTCLIENT_t client, const char* dev); +.fi +.sp +.nf int nutclient_get_device_num_logins(NUTCLIENT_t client, const char* dev); +.fi +.sp +.nf +void nutclient_device_primary(NUTCLIENT_t client, const char* dev); +/* OBSOLETED name: */ void nutclient_device_master(NUTCLIENT_t client, const char* dev); +.fi +.sp +.nf void nutclient_device_forced_shutdown(NUTCLIENT_t client, const char* dev); .fi .SH "DESCRIPTION" .sp -The \fBnutclient_authenticate()\fR function authenticate the user\&. +The \fBnutclient_authenticate()\fR function authenticates the user\&. .sp -\fIlogin\fR is the user name\&. +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fIlogin\fR +is the user name\&. +.RE .sp -\fIpasswd\fR is the user password\&. +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fIpasswd\fR +is the user password\&. +.RE .sp -The \fBnutclient_logout()\fR function disconnect gracefully from the server\&. +The \fBnutclient_logout()\fR function disconnects gracefully from the server\&. .sp -The \fBnutclient_device_login()\fR function log the fact that a system is drawing power from this UPS\&. +The \fBnutclient_device_login()\fR function logs the fact that a system is drawing power from this UPS\&. .sp -The \fBnutclient_get_device_num_logins()\fR function retrieve the number of clients which have been logged for this device\&. +The \fBnutclient_get_device_num_logins()\fR function retrieves the number of clients which have been logged for this device\&. .sp -The \fBnutclient_device_master()\fR function make sure that master\-level functions like FSD are available if necessary\&. +The \fBnutclient_device_master()\fR and \fBnutclient_device_primary()\fR (note: the former is obsoleted since NUT v2\&.8\&.0 in favor of the latter) functions make sure that primary\-mode functions like FSD are available if necessary\&. .sp The \fBnutclient_device_forced_shutdown()\fR function sets the "forced shutdown" flag on the device\&. .sp diff --git a/docs/man/libnutclient_misc.txt b/docs/man/libnutclient_misc.txt index d8b2fef..2635db4 100644 --- a/docs/man/libnutclient_misc.txt +++ b/docs/man/libnutclient_misc.txt @@ -4,10 +4,10 @@ LIBNUTCLIENT_MISC(3) NAME ---- -libnutclient_misc, nutclient_authenticate, nutclient_logout, -nutclient_device_login, nutclient_get_device_num_logins, +libnutclient_misc, nutclient_authenticate, nutclient_logout, +nutclient_device_login, nutclient_get_device_num_logins, nutclient_device_master, nutclient_device_forced_shutdown - -Miscelaneous functions in Network UPS Tools high-level client access library +Miscellaneous functions in Network UPS Tools high-level client access library SYNOPSIS -------- @@ -16,37 +16,49 @@ SYNOPSIS typedef void* NUTCLIENT_t; - void nutclient_authenticate(NUTCLIENT_t client, const char* login, const char* passwd); + void nutclient_authenticate( + NUTCLIENT_t client, + const char* login, const char* passwd); + void nutclient_logout(NUTCLIENT_t client); + void nutclient_device_login(NUTCLIENT_t client, const char* dev); + int nutclient_get_device_num_logins(NUTCLIENT_t client, const char* dev); + + void nutclient_device_primary(NUTCLIENT_t client, const char* dev); + /* OBSOLETED name: */ void nutclient_device_master(NUTCLIENT_t client, const char* dev); + void nutclient_device_forced_shutdown(NUTCLIENT_t client, const char* dev); DESCRIPTION ----------- -The *nutclient_authenticate()* function authenticate the user. +The *nutclient_authenticate()* function authenticates the user. -'login' is the user name. +* 'login' is the user name. -'passwd' is the user password. +* 'passwd' is the user password. -The *nutclient_logout()* function disconnect gracefully from the server. +The *nutclient_logout()* function disconnects gracefully from the server. -The *nutclient_device_login()* function log the fact that a system +The *nutclient_device_login()* function logs the fact that a system is drawing power from this UPS. -The *nutclient_get_device_num_logins()* function retrieve the number of clients -which have been logged for this device. +The *nutclient_get_device_num_logins()* function retrieves the number of +clients which have been logged for this device. -The *nutclient_device_master()* function make sure that master-level -functions like FSD are available if necessary. +The *nutclient_device_master()* and *nutclient_device_primary()* (note: +the former is obsoleted since NUT v2.8.0 in favor of the latter) functions +make sure that primary-mode functions like FSD are available if necessary. -The *nutclient_device_forced_shutdown()* function sets the "forced shutdown" flag on the device. +The *nutclient_device_forced_shutdown()* function sets the "forced shutdown" +flag on the device. 'dev' is the device name. SEE ALSO -------- + linkman:libnutclient[3] diff --git a/docs/man/libnutclient_tcp.3 b/docs/man/libnutclient_tcp.3 index 6460dda..c341fd1 100644 --- a/docs/man/libnutclient_tcp.3 +++ b/docs/man/libnutclient_tcp.3 @@ -1,13 +1,13 @@ '\" t .\" Title: libnutclient_tcp -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "LIBNUTCLIENT_TCP" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "LIBNUTCLIENT_TCP" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -33,6 +33,8 @@ libnutclient_tcp, nutclient_tcp_create_client, nutclient_tcp_is_connected, nutcl .sp .nf #include +#include /* uint16_t */ +#include /* time_t */ .fi .sp .nf @@ -40,12 +42,28 @@ typedef NUTCLIENT_t NUTCLIENT_TCP_t; .fi .sp .nf -NUTCLIENT_TCP_t nutclient_tcp_create_client(const char* host, unsigned short port); +NUTCLIENT_TCP_t nutclient_tcp_create_client( + const char* host, uint16_t port); +.fi +.sp +.nf int nutclient_tcp_is_connected(NUTCLIENT_TCP_t client); +.fi +.sp +.nf void nutclient_tcp_disconnect(NUTCLIENT_TCP_t client); +.fi +.sp +.nf int nutclient_tcp_reconnect(NUTCLIENT_TCP_t client); -void nutclient_tcp_set_timeout(NUTCLIENT_TCP_t client, long timeout); -long nutclient_tcp_get_timeout(NUTCLIENT_TCP_t client); +.fi +.sp +.nf +void nutclient_tcp_set_timeout(NUTCLIENT_TCP_t client, time_t timeout); +.fi +.sp +.nf +time_t nutclient_tcp_get_timeout(NUTCLIENT_TCP_t client); .fi .SH "DESCRIPTION" .sp @@ -53,9 +71,29 @@ These functions allow to manage connections to \fBupsd\fR(8) using NUT TCP proto .sp The \fBnutclient_tcp_create_client()\fR function create the \fINUTCLIENT_TCP_t\fR context and intend to connect to upsd at \fIhost\fR and \fIport\fR\&. The context must be freed by \fInutclient_destroy()\fR .sp -\fIhost\fR can be a sever name or a valid IPv4 or IPv6 adress like "localhost", "127\&.0\&.0\&.1" or "::1"\&. +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fIhost\fR +can be a sever name or a valid IPv4 or IPv6 address like "localhost", "127\&.0\&.0\&.1" or "::1"\&. +.RE .sp -\fIport\fR is a valid TCP port, genrally 3493\&. +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fIport\fR +is a valid TCP port, generally 3493\&. +.RE .sp The \fBnutclient_tcp_is_connected()\fR function test if the connection is valid\&. .sp diff --git a/docs/man/libnutclient_tcp.txt b/docs/man/libnutclient_tcp.txt index 4c17300..299fce2 100644 --- a/docs/man/libnutclient_tcp.txt +++ b/docs/man/libnutclient_tcp.txt @@ -7,48 +7,64 @@ NAME libnutclient_tcp, nutclient_tcp_create_client, nutclient_tcp_is_connected, nutclient_tcp_disconnect, nutclient_tcp_reconnect, nutclient_tcp_set_timeout, nutclient_tcp_get_timeout - -TCP protocol related function for Network UPS Tools high-level client access library +TCP protocol related function for Network UPS Tools high-level client +access library SYNOPSIS -------- #include + #include /* uint16_t */ + #include /* time_t */ typedef NUTCLIENT_t NUTCLIENT_TCP_t; - NUTCLIENT_TCP_t nutclient_tcp_create_client(const char* host, unsigned short port); + NUTCLIENT_TCP_t nutclient_tcp_create_client( + const char* host, uint16_t port); + int nutclient_tcp_is_connected(NUTCLIENT_TCP_t client); + void nutclient_tcp_disconnect(NUTCLIENT_TCP_t client); + int nutclient_tcp_reconnect(NUTCLIENT_TCP_t client); - void nutclient_tcp_set_timeout(NUTCLIENT_TCP_t client, long timeout); - long nutclient_tcp_get_timeout(NUTCLIENT_TCP_t client); + + void nutclient_tcp_set_timeout(NUTCLIENT_TCP_t client, time_t timeout); + + time_t nutclient_tcp_get_timeout(NUTCLIENT_TCP_t client); DESCRIPTION ----------- -These functions allow to manage connections to linkman:upsd[8] using NUT TCP protocol. +These functions allow to manage connections to linkman:upsd[8] +using NUT TCP protocol. -The *nutclient_tcp_create_client()* function create the 'NUTCLIENT_TCP_t' context and -intend to connect to upsd at 'host' and 'port'. The context must be freed by 'nutclient_destroy()' +The *nutclient_tcp_create_client()* function create the 'NUTCLIENT_TCP_t' +context and intend to connect to upsd at 'host' and 'port'. +The context must be freed by 'nutclient_destroy()' -'host' can be a sever name or a valid IPv4 or IPv6 adress like "localhost", "127.0.0.1" or "::1". +* 'host' can be a sever name or a valid IPv4 or IPv6 address like +"localhost", "127.0.0.1" or "::1". -'port' is a valid TCP port, genrally 3493. +* 'port' is a valid TCP port, generally 3493. The *nutclient_tcp_is_connected()* function test if the connection is valid. -The *nutclient_tcp_disconnect()* function force to disconnect the specified connection. +The *nutclient_tcp_disconnect()* function force to disconnect the specified +connection. The *nutclient_tcp_reconnect()* function force to reconnect a connection, disconnecting it if needed. -The *nutclient_tcp_set_timeout()* function set the timeout duration for I/O operations. +The *nutclient_tcp_set_timeout()* function set the timeout duration +for I/O operations. -The *nutclient_tcp_get_timeout()* function retrieve the timeout duration for I/O operations. +The *nutclient_tcp_get_timeout()* function retrieve the timeout duration +for I/O operations. 'timeout' values are specified in seconds, negatives values for blocking. SEE ALSO -------- + linkman:libnutclient[3] linkman:libnutclient_general[3] diff --git a/docs/man/libnutclient_variables.3 b/docs/man/libnutclient_variables.3 index 6819c91..ba2039e 100644 --- a/docs/man/libnutclient_variables.3 +++ b/docs/man/libnutclient_variables.3 @@ -1,13 +1,13 @@ '\" t .\" Title: libnutclient_variables -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "LIBNUTCLIENT_VARIABL" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "LIBNUTCLIENT_VARIABL" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -40,39 +40,110 @@ typedef void* NUTCLIENT_t; .fi .sp .nf -strarr nutclient_get_device_variables(NUTCLIENT_t client, const char* dev); -strarr nutclient_get_device_rw_variables(NUTCLIENT_t client, const char* dev); -int nutclient_has_device_variable(NUTCLIENT_t client, const char* dev, const char* var); -char* nutclient_get_device_variable_description(NUTCLIENT_t client, const char* dev, const char* var); -strarr nutclient_get_device_variable_values(NUTCLIENT_t client, const char* dev, const char* var); -void nutclient_set_device_variable_value(NUTCLIENT_t client, const char* dev, const char* var, const char* value); -void nutclient_set_device_variable_values(NUTCLIENT_t client, const char* dev, const char* var, const strarr values); +typedef char** strarr; +.fi +.sp +.nf +strarr nutclient_get_device_variables(NUTCLIENT_t client, + const char* dev); +.fi +.sp +.nf +strarr nutclient_get_device_rw_variables(NUTCLIENT_t client, + const char* dev); +.fi +.sp +.nf +int nutclient_has_device_variable(NUTCLIENT_t client, + const char* dev, const char* var); +.fi +.sp +.nf +char* nutclient_get_device_variable_description(NUTCLIENT_t client, + const char* dev, const char* var); +.fi +.sp +.nf +strarr nutclient_get_device_variable_values(NUTCLIENT_t client, + const char* dev, const char* var); +.fi +.sp +.nf +void nutclient_set_device_variable_value(NUTCLIENT_t client, + const char* dev, const char* var, const char* value); +.fi +.sp +.nf +void nutclient_set_device_variable_values(NUTCLIENT_t client, + const char* dev, const char* var, const strarr values); .fi .SH "DESCRIPTION" .sp These functions allow to manage variables of devices\&. .sp -The \fBnutclient_get_device_variables()\fR function retrieve the list of variables names for a device\&. The returned strarr must be freed by \fIstrarr_free\fR\&. +The \fBnutclient_get_device_variables()\fR function retrieves the list of variables names for a device\&. The returned strarr must be freed by \fIstrarr_free\fR\&. .sp -The \fBnutclient_get_device_rw_variables\fR function retrieve the list of read\-write variables names for a device\&. The returned strarr must be freed by \fIstrarr_free\fR\&. +The \fBnutclient_get_device_rw_variables\fR function retrieves the list of read\-write variables names for a device\&. The returned strarr must be freed by \fIstrarr_free\fR\&. .sp -The \fBnutclient_has_device_variable\fR function test if the specified variable is supported by the device\&. Return 1 is supported and 0 if not\&. +The \fBnutclient_has_device_variable\fR function tests if the specified variable is supported by the device\&. Return 1 is supported and 0 if not\&. .sp -The \fBnutclient_get_device_variable_description\fR function retrieve the variable description, if any\&. The resturned string must be freed\&. +The \fBnutclient_get_device_variable_description\fR function retrieves the variable description, if any\&. The returned string must be freed\&. .sp The \fBnutclient_get_device_variable_values\fR returns variable values (generally only one)\&. The returned strarr must be freed by \fIstrarr_free\fR\&. .sp -The \fBnutclient_set_device_variable_value\fR intend to set the value of the specified variable\&. +The \fBnutclient_set_device_variable_value\fR intends to set the value of the specified variable\&. .sp -The \fBnutclient_set_device_variable_values\fR intend to set multiple values of the specified variable\&. +The \fBnutclient_set_device_variable_values\fR intends to set multiple values of the specified variable\&. .sp -\fIdev\fR is the device name\&. +Common arguments: .sp -\fIvar\fR is the variable name\&. +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fIdev\fR +is the device name\&. +.RE .sp -\fIvalue\fR is the variable value\&. +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fIvar\fR +is the variable name\&. +.RE .sp -\fIvalues\fR is the variable array of values\&. +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fIvalue\fR +is the variable value\&. +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fIvalues\fR +is the variable array of values\&. +.RE .SH "SEE ALSO" .sp \fBlibnutclient\fR(3) \fBlibnutclient_devices\fR(3) \fBlibnutclient_general\fR(3) diff --git a/docs/man/libnutclient_variables.txt b/docs/man/libnutclient_variables.txt index 2e84c79..fbeeb3d 100644 --- a/docs/man/libnutclient_variables.txt +++ b/docs/man/libnutclient_variables.txt @@ -6,9 +6,11 @@ NAME libnutclient_variables, nutclient_get_device_variables, nutclient_get_device_rw_variables, nutclient_has_device_variable, -nutclient_get_device_variable_description, nutclient_get_device_variable_values, +nutclient_get_device_variable_description, +nutclient_get_device_variable_values, nutclient_set_device_variable_value, nutclient_set_device_variable_values - -Variable related functions in Network UPS Tools high-level client access library +Variable related functions in Network UPS Tools high-level client access +library SYNOPSIS -------- @@ -17,48 +19,73 @@ SYNOPSIS typedef void* NUTCLIENT_t; - strarr nutclient_get_device_variables(NUTCLIENT_t client, const char* dev); - strarr nutclient_get_device_rw_variables(NUTCLIENT_t client, const char* dev); - int nutclient_has_device_variable(NUTCLIENT_t client, const char* dev, const char* var); - char* nutclient_get_device_variable_description(NUTCLIENT_t client, const char* dev, const char* var); - strarr nutclient_get_device_variable_values(NUTCLIENT_t client, const char* dev, const char* var); - void nutclient_set_device_variable_value(NUTCLIENT_t client, const char* dev, const char* var, const char* value); - void nutclient_set_device_variable_values(NUTCLIENT_t client, const char* dev, const char* var, const strarr values); + typedef char** strarr; + + strarr nutclient_get_device_variables(NUTCLIENT_t client, + const char* dev); + + strarr nutclient_get_device_rw_variables(NUTCLIENT_t client, + const char* dev); + + int nutclient_has_device_variable(NUTCLIENT_t client, + const char* dev, const char* var); + + char* nutclient_get_device_variable_description(NUTCLIENT_t client, + const char* dev, const char* var); + + strarr nutclient_get_device_variable_values(NUTCLIENT_t client, + const char* dev, const char* var); + + void nutclient_set_device_variable_value(NUTCLIENT_t client, + const char* dev, const char* var, const char* value); + + void nutclient_set_device_variable_values(NUTCLIENT_t client, + const char* dev, const char* var, const strarr values); DESCRIPTION ----------- These functions allow to manage variables of devices. -The *nutclient_get_device_variables()* function retrieve the list of variables names for a device. +The *nutclient_get_device_variables()* function retrieves the list +of variables names for a device. The returned strarr must be freed by 'strarr_free'. -The *nutclient_get_device_rw_variables* function retrieve the list of read-write variables names for a device. +The *nutclient_get_device_rw_variables* function retrieves the list +of read-write variables names for a device. The returned strarr must be freed by 'strarr_free'. -The *nutclient_has_device_variable* function test if the specified variable is supported by the device. +The *nutclient_has_device_variable* function tests if the specified +variable is supported by the device. Return 1 is supported and 0 if not. -The *nutclient_get_device_variable_description* function retrieve the variable description, if any. -The resturned string must be freed. +The *nutclient_get_device_variable_description* function retrieves +the variable description, if any. +The returned string must be freed. -The *nutclient_get_device_variable_values* returns variable values (generally only one). +The *nutclient_get_device_variable_values* returns variable values +(generally only one). The returned strarr must be freed by 'strarr_free'. -The *nutclient_set_device_variable_value* intend to set the value of the specified variable. +The *nutclient_set_device_variable_value* intends to set the value +of the specified variable. -The *nutclient_set_device_variable_values* intend to set multiple values of the specified variable. +The *nutclient_set_device_variable_values* intends to set multiple +values of the specified variable. -'dev' is the device name. +Common arguments: -'var' is the variable name. +* 'dev' is the device name. -'value' is the variable value. +* 'var' is the variable name. -'values' is the variable array of values. +* 'value' is the variable value. + +* 'values' is the variable array of values. SEE ALSO -------- + linkman:libnutclient[3] linkman:libnutclient_devices[3] linkman:libnutclient_general[3] diff --git a/docs/man/libupsclient-config.1 b/docs/man/libupsclient-config.1 index 5094f7e..bf0bf06 100644 --- a/docs/man/libupsclient-config.1 +++ b/docs/man/libupsclient-config.1 @@ -1,13 +1,13 @@ '\" t .\" Title: libupsclient-config .\" Author: [see the "AUTHORS" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "LIBUPSCLIENT\-CONFIG" "1" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "LIBUPSCLIENT\-CONFIG" "1" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/libupsclient-config.txt b/docs/man/libupsclient-config.txt index 730a5b2..526276c 100644 --- a/docs/man/libupsclient-config.txt +++ b/docs/man/libupsclient-config.txt @@ -4,10 +4,12 @@ LIBUPSCLIENT-CONFIG(1) NAME ---- -libupsclient-config - script to get information about the installed version of libupsclient +libupsclient-config - script to get information about the installed +version of libupsclient SYNOPSIS -------- + *libupsclient-config* [--version] [--libs] [--cflags] DESCRIPTION @@ -15,7 +17,7 @@ DESCRIPTION *libupsclient-config* is a tool that is used to determine the compiler and linker flags that should be used to compile and link programs that use -*libupsclient* from the Network UPS Tools project. +*libupsclient* from the Network UPS Tools project. OPTIONS ------- @@ -33,6 +35,7 @@ Print the compiler flags that are necessary to compile a *libupsclient* program. AUTHORS ------- + This manual page was written by Arnaud Quette . SEE ALSO @@ -42,5 +45,5 @@ linkman:upsclient[3] Internet resources: ~~~~~~~~~~~~~~~~~~~ -The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ +The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/liebert-esp2.8 b/docs/man/liebert-esp2.8 index bd5373f..829d00a 100644 --- a/docs/man/liebert-esp2.8 +++ b/docs/man/liebert-esp2.8 @@ -1,13 +1,13 @@ '\" t .\" Title: liebert-esp2 -.\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [see the "AUTHORS" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "LIEBERT\-ESP2" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "LIEBERT\-ESP2" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -32,9 +32,27 @@ liebert-esp2 \- Driver for Liebert UPS, using the ESP\-II serial protocol .SH "NOTE" .sp This man page only documents the hardware\-specific features of the liebert\-esp2 driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. +.SH "SPECIAL CABLING NOTE" +.sp +Be aware that an RS\-232 cable with ONLY the RX, TX and ground pin must be used when interfacing with GXT2 series UPS units (and possibly others), since the handshaking lines are used for purposes other than RS\-232 flow control\&. Use of a standard RS\-232 cable with full handshaking may result in undesired operation and/or shutdown\&. It is therefore advisable to confirm the proper cable/wiring with the diagram provided in the manual with your UPS\&. .SH "SUPPORTED HARDWARE" .sp +Tested to work on the following units: +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Liebert GXT2\-6000RT208 +.RE +.sp This is an experimental driver\&. You have been warned\&. +.sp +This driver currently does not support modification of configuration parameters, such as the low battery warning time and automatic restart policy\&. .SH "EXTRA ARGUMENTS" .sp This driver supports the following optional settings in \fBups.conf\fR(5): @@ -43,9 +61,40 @@ This driver supports the following optional settings in \fBups.conf\fR(5): .RS 4 Set the speed of the serial connection \- 1200, 2400 (default), 4800, 9600 or 19200\&. .RE -.SH "AUTHOR" +.SH "AUTHORS" .sp -Richard Gregory , Arjen de Korte +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Richard Gregory +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Arjen de Korte +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Nash Kaminski +.RE .SH "SEE ALSO" .SS "The core driver:" .sp diff --git a/docs/man/liebert-esp2.txt b/docs/man/liebert-esp2.txt index e34fb06..e71fb72 100644 --- a/docs/man/liebert-esp2.txt +++ b/docs/man/liebert-esp2.txt @@ -1,21 +1,40 @@ LIEBERT-ESP2(8) ============== -NAME +NAME ---- liebert-esp2 - Driver for Liebert UPS, using the ESP-II serial protocol NOTE ---- + This man page only documents the hardware-specific features of the -liebert-esp2 driver. For information about the core driver, see +liebert-esp2 driver. For information about the core driver, see linkman:nutupsdrv[8]. +SPECIAL CABLING NOTE +-------------------- + +Be aware that an RS-232 cable with ONLY the RX, TX and ground pin +must be used when interfacing with GXT2 series UPS units (and possibly others), +since the handshaking lines are used for purposes other than RS-232 flow control. +Use of a standard RS-232 cable with full handshaking may result in +undesired operation and/or shutdown. It is therefore advisable to confirm +the proper cable/wiring with the diagram provided in the manual with your UPS. + SUPPORTED HARDWARE ------------------ + +Tested to work on the following units: + +* Liebert GXT2-6000RT208 + This is an experimental driver. You have been warned. +This driver currently does not support modification of configuration parameters, +such as the low battery warning time and automatic restart policy. + EXTRA ARGUMENTS --------------- @@ -24,17 +43,22 @@ This driver supports the following optional settings in linkman:ups.conf[5]: *baudrate=*'num':: Set the speed of the serial connection - 1200, 2400 (default), 4800, 9600 or 19200. -AUTHOR ------- -Richard Gregory , Arjen de Korte +AUTHORS +------- + +* Richard Gregory +* Arjen de Korte +* Nash Kaminski SEE ALSO -------- The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/liebert.8 b/docs/man/liebert.8 index 7fe9f6c..d4fc4b6 100644 --- a/docs/man/liebert.8 +++ b/docs/man/liebert.8 @@ -1,13 +1,13 @@ '\" t .\" Title: liebert -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "LIEBERT" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "LIEBERT" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/liebert.txt b/docs/man/liebert.txt index dfaa795..b913659 100644 --- a/docs/man/liebert.txt +++ b/docs/man/liebert.txt @@ -8,12 +8,14 @@ liebert - Driver for Liebert contact-closure UPS equipment NOTE ---- + This man page only documents the hardware-specific features of the liebert driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + This driver supports some Liebert UPS equipment with a contact-closure interface. This includes the UPStation GXT2 with their contact-closure cable. The smart mode ("Multilink") cable is not supported by this @@ -42,8 +44,10 @@ SEE ALSO The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/macosx-ups.8 b/docs/man/macosx-ups.8 index 953fb65..b726d06 100644 --- a/docs/man/macosx-ups.8 +++ b/docs/man/macosx-ups.8 @@ -1,13 +1,13 @@ '\" t .\" Title: macosx-ups -.\" Author: [see the "AUTHORS" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [see the "AUTHOR" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "MACOSX\-UPS" "8" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "MACOSX\-UPS" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -43,7 +43,7 @@ If the UPS is visible in the Energy Saver preferences pane of System Preferences .RS 4 Due to changes in the way that Mac OS X lists power sources, the \fBport\fR -parameter no longer has any effect\&. The rest of NUT still requres a value here, and our traditional "don\(cqt care" value is +parameter no longer has any effect\&. The rest of NUT still requires a value here, and our traditional "don\(cqt care" value is auto\&. .RE .PP @@ -63,7 +63,7 @@ This driver is a monitoring\-only driver, and cannot shut down an UPS on its own The default distribution of \fBapcupsd\fR installs a kernel extension which prevents Mac OS X from attaching to the UPS\&. In order to use this driver after installing apcupsd, you must first run the apcupsd\-uninstall script and reboot\&. .sp Note that other UPS monitoring solutions may show more detail than what is provided by the built\-in Mac OS X driver\&. In particular, voltages other than the battery voltage, as well as current and frequency, are typically not shown\&. It may be possible to monitor these values with \fBapcupsd\fR (for APC hardware only) or \fBusbhid-ups\fR(8)\&. -.SH "AUTHORS" +.SH "AUTHOR" .sp Charles Lepple .SH "SEE ALSO" @@ -74,6 +74,26 @@ Charles Lepple \fBnutupsdrv\fR(8) .SS "Internet resources:" .sp -The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The NUT (Network UPS Tools) home page: +http://www\&.networkupstools\&.org/ +.RE .sp -The apcupsd home page: http://www\&.apcupsd\&.org/ +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The apcupsd home page: +http://www\&.apcupsd\&.org/ +.RE diff --git a/docs/man/macosx-ups.txt b/docs/man/macosx-ups.txt index 956abde..2338be2 100644 --- a/docs/man/macosx-ups.txt +++ b/docs/man/macosx-ups.txt @@ -3,16 +3,19 @@ MACOSX-UPS(8) NAME ---- + macosx-ups - monitor for Mac OS X built-in UPS and battery driver NOTE ---- + This man page only documents the hardware-specific features of the *macosx-ups* driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + *macosx-ups* supports any USB HID Power Device Class (PDC) UPS which is matched by the Mac OS X built-in drivers. It also can monitor a laptop internal battery as though it were an UPS. @@ -23,9 +26,10 @@ Preferences, this driver should be able to monitor it. EXTRA ARGUMENTS ---------------- + *port*=auto:: Due to changes in the way that Mac OS X lists power sources, the *port* -parameter no longer has any effect. The rest of NUT still requres a value here, +parameter no longer has any effect. The rest of NUT still requires a value here, and our traditional "don't care" value is `auto`. *model*='regex':: @@ -60,8 +64,9 @@ the battery voltage, as well as current and frequency, are typically not shown. It may be possible to monitor these values with *apcupsd* (for APC hardware only) or linkman:usbhid-ups[8]. -AUTHORS -------- +AUTHOR +------ + Charles Lepple SEE ALSO @@ -71,10 +76,11 @@ linkman:usbhid-ups[8], *pmset*(8), *regex*(3) The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ -The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ -The apcupsd home page: http://www.apcupsd.org/ +* The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ +* The apcupsd home page: http://www.apcupsd.org/ diff --git a/docs/man/masterguard.8 b/docs/man/masterguard.8 index 0947360..072a1cb 100644 --- a/docs/man/masterguard.8 +++ b/docs/man/masterguard.8 @@ -1,13 +1,13 @@ '\" t .\" Title: masterguard .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "MASTERGUARD" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "MASTERGUARD" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -32,9 +32,14 @@ masterguard \- Driver for Masterguard UPS equipment .SH "NOTE" .sp This man page only documents the hardware\-specific features of the masterguard driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. +.SH "NOTE" +.sp +Please note that this driver is deprecated and will not receive new development\&. If it works for managing your devices \(em fine, but if you are running it to try setting up a new device, please consider the newer \fBnutdrv_qx\fR(8) instead, which should handle all \fIQ*\fR protocol variants for NUT\&. +.sp +Please do also report if your device works with this driver, but \fBnutdrv_qx\fR(8) would not actually support it with any subdriver! .SH "SUPPORTED HARDWARE" .sp -This driver supports Masterguard UPS equipment\&. +This driver supports Masterguard UPS equipment (serial connection only)\&. .SH "EXTRA ARGUMENTS" .PP \fBCS\fR @@ -45,6 +50,9 @@ Cancel the shutdown procedure\&. .sp Michael Spanier .SH "SEE ALSO" +.SS "Newer driver:" +.sp +\fBnutdrv_qx\fR(8) .SS "The core driver:" .sp \fBnutupsdrv\fR(8) diff --git a/docs/man/masterguard.txt b/docs/man/masterguard.txt index 0820025..373fc2f 100644 --- a/docs/man/masterguard.txt +++ b/docs/man/masterguard.txt @@ -3,17 +3,33 @@ MASTERGUARD(8) NAME ---- + masterguard - Driver for Masterguard UPS equipment NOTE ---- + This man page only documents the hardware-specific features of the masterguard driver. For information about the core driver, see linkman:nutupsdrv[8]. +NOTE +---- + +Please note that this driver is deprecated and will not receive +new development. If it works for managing your devices -- fine, +but if you are running it to try setting up a new device, please +consider the newer linkman:nutdrv_qx[8] instead, which should +handle all 'Q*' protocol variants for NUT. + +Please do also report if your device works with this driver, +but linkman:nutdrv_qx[8] would not actually support it with any +subdriver! + SUPPORTED HARDWARE ------------------ -This driver supports Masterguard UPS equipment. + +This driver supports Masterguard UPS equipment (serial connection only). EXTRA ARGUMENTS --------------- @@ -23,15 +39,23 @@ Cancel the shutdown procedure. AUTHOR ------ + Michael Spanier SEE ALSO -------- +Newer driver: +~~~~~~~~~~~~~ + +linkman:nutdrv_qx[8] + The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/metasys.8 b/docs/man/metasys.8 index 0ef74a8..3e4ae30 100644 --- a/docs/man/metasys.8 +++ b/docs/man/metasys.8 @@ -1,13 +1,13 @@ '\" t .\" Title: metasys .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "METASYS" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "METASYS" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/metasys.txt b/docs/man/metasys.txt index 4a6fc2e..d134fe5 100644 --- a/docs/man/metasys.txt +++ b/docs/man/metasys.txt @@ -1,7 +1,7 @@ METASYS(8) ========== -NAME +NAME ---- metasys - Driver for Meta System UPS equipment @@ -10,7 +10,7 @@ NOTE ---- This man page only documents the hardware-specific features of the -metasys driver. For information about the core driver, see +metasys driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE @@ -32,16 +32,19 @@ The driver should support all the common features of the ups models: CABLING ------- + The needed cable is a standard pin-to-pin serial cable with at least pins 2, 3, and 5 (on DB9 connector) connected. EXTRA ARGUMENTS --------------- + This driver supports no extra arguments from linkman:ups.conf[5]. BUGS ---- -This driver has been tested on Meta System HF Millennium 820 and + +This driver has been tested on Meta System HF Millennium 820 and ally HF 1000 only. Any information about the use of the driver with the other listed @@ -49,6 +52,7 @@ UPS are really welcome. AUTHOR ------ + Fabio Di Niro SEE ALSO @@ -56,8 +60,10 @@ SEE ALSO The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/mge-shut.8 b/docs/man/mge-shut.8 index c3faf44..4e7d572 100644 --- a/docs/man/mge-shut.8 +++ b/docs/man/mge-shut.8 @@ -1,13 +1,13 @@ '\" t .\" Title: mge-shut .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "MGE\-SHUT" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "MGE\-SHUT" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -89,7 +89,7 @@ The default value is 30 (in seconds)\&. Usually this \fBmust be greater\fR than offdelay, but the driver will \fBnot\fR -warn you upon startup if it isn\(cqt\&. Some UPS\(cqes will restart no matter what, even if the power is (still) out at the moment this timer elapses\&. In that case, you could try if setting +warn you upon startup if it isn\(cqt\&. Some UPSes will restart no matter what, even if the power is (still) out at the moment this timer elapses\&. In that case, you could try if setting \fIondelay = \-1\fR in \fBups\&.conf\fR diff --git a/docs/man/mge-shut.txt b/docs/man/mge-shut.txt index d8e19c3..91d96b7 100644 --- a/docs/man/mge-shut.txt +++ b/docs/man/mge-shut.txt @@ -1,4 +1,4 @@ -MGE-SHUT(8) +MGE-SHUT(8) =========== NAME @@ -44,7 +44,7 @@ sent (via the *-k* switch). + The default value is 20 (in seconds). Usually this *must be lower* than 'ondelay', but the driver will *not* warn you upon startup if it isn't. - + *ondelay*='num':: Set the timer for the UPS to switch on in case the power returns after the kill power command had been sent but before the actual switch off. This @@ -53,7 +53,7 @@ a power failure. + The default value is 30 (in seconds). Usually this *must be greater* than offdelay, but the driver will *not* warn you upon startup if it -isn't. Some UPS'es will restart no matter what, even if the power is +isn't. Some UPSes will restart no matter what, even if the power is (still) out at the moment this timer elapses. In that case, you could try if setting 'ondelay = -1' in *ups.conf* helps. + @@ -90,8 +90,10 @@ SEE ALSO The core driver ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources ~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/mge-utalk.8 b/docs/man/mge-utalk.8 index 0c8d5d9..e84fc4f 100644 --- a/docs/man/mge-utalk.8 +++ b/docs/man/mge-utalk.8 @@ -1,13 +1,13 @@ '\" t .\" Title: mge-utalk -.\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [see the "AUTHORS" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "MGE\-UTALK" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "MGE\-UTALK" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -54,22 +54,93 @@ This man page only documents the hardware\-specific features of the mge\-utalk d .sp mge\-utalk supports the following legacy units, using the MGE UTalk protocol: .sp -.if n \{\ .RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c .\} -.nf -Pulsar ESV+, -Pulsar ES+, -Pulsar EL, -Pulsar EX, -Pulsar EXtreme, -Comet EXtreme, -Comet (Utalk Serial Card, ref 66060), -Galaxy (Utalk Serial Card, ref 66060)\&. -.fi -.if n \{\ +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Pulsar ESV+ .RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c .\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Pulsar ES+ +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Pulsar EL +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Pulsar EX +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Pulsar EXtreme +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Comet EXtreme +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Comet (Utalk Serial Card, ref 66060) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Galaxy (Utalk Serial Card, ref 66060) +.RE .sp This driver also support some newer models with backward UTalk compatibility, such as Pulsar Evolution and Pulsar EXtreme C\&. As these models also support the SHUT protocol, prefer mge\-shut for serial communication, or use the USB port, if available, with the usbhid\-ups driver\&. .SH "EXTRA ARGUMENTS" @@ -108,9 +179,84 @@ Set this flag if you are running Linux on an Oldworld Macintosh box (all beige A .SS "Repetitive timeout and staleness" .sp Older models, such as ES/ESV ones, might report repetitive "data stale" errors\&. This is due to the fact that these models don\(cqt support too much polling\&. To solve this problem, add "pollinterval=20" in ups\&.conf, and change the value of MAXAGE to 25 in upsd\&.conf, and DEADTIME to 25 in upsmon\&.conf\&. -.SH "AUTHOR" +.SH "AUTHORS" .sp -Hans Ekkehard Plesser, Arnaud Quette, Martin Loyer, Patrick Agrain, Nicholas Reilly, Dave Abbott, Marek Kralewski +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Hans Ekkehard Plesser +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Arnaud Quette +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Martin Loyer +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Patrick Agrain +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Nicholas Reilly +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Dave Abbott +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Marek Kralewski +.RE .SH "SEE ALSO" .SS "The core driver" .sp diff --git a/docs/man/mge-utalk.txt b/docs/man/mge-utalk.txt index ef11baa..4dd0384 100644 --- a/docs/man/mge-utalk.txt +++ b/docs/man/mge-utalk.txt @@ -1,4 +1,4 @@ -MGE-UTALK(8) +MGE-UTALK(8) ============ NAME @@ -14,7 +14,7 @@ SYNOPSIS *mge-utalk* -a 'UPS_NAME' ['OPTIONS'] NOTE: This man page only documents the hardware-specific features of the -mge-utalk driver. For information about the core driver, see +mge-utalk driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE @@ -22,14 +22,14 @@ SUPPORTED HARDWARE mge-utalk supports the following legacy units, using the MGE UTalk protocol: - Pulsar ESV+, - Pulsar ES+, - Pulsar EL, - Pulsar EX, - Pulsar EXtreme, - Comet EXtreme, - Comet (Utalk Serial Card, ref 66060), - Galaxy (Utalk Serial Card, ref 66060). +* Pulsar ESV+ +* Pulsar ES+ +* Pulsar EL +* Pulsar EX +* Pulsar EXtreme +* Comet EXtreme +* Comet (Utalk Serial Card, ref 66060) +* Galaxy (Utalk Serial Card, ref 66060) This driver also support some newer models with backward UTalk compatibility, such as Pulsar Evolution and Pulsar EXtreme C. As these models also support @@ -75,24 +75,26 @@ This is due to the fact that these models don't support too much polling. To solve this problem, add "pollinterval=20" in ups.conf, and change the value of MAXAGE to 25 in upsd.conf, and DEADTIME to 25 in upsmon.conf. -AUTHOR ------- +AUTHORS +------- -Hans Ekkehard Plesser, -Arnaud Quette, -Martin Loyer, -Patrick Agrain, -Nicholas Reilly, -Dave Abbott, -Marek Kralewski +* Hans Ekkehard Plesser +* Arnaud Quette +* Martin Loyer +* Patrick Agrain +* Nicholas Reilly +* Dave Abbott +* Marek Kralewski SEE ALSO -------- The core driver ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources ~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/microdowell.8 b/docs/man/microdowell.8 index 86eb1a8..8cfe267 100644 --- a/docs/man/microdowell.8 +++ b/docs/man/microdowell.8 @@ -1,13 +1,13 @@ '\" t .\" Title: microdowell .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "MICRODOWELL" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "MICRODOWELL" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/microdowell.txt b/docs/man/microdowell.txt index 9277379..a23ead2 100644 --- a/docs/man/microdowell.txt +++ b/docs/man/microdowell.txt @@ -15,8 +15,9 @@ linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ -This driver was developed for the Enterprise Nxx and Bxx models. Other -Microdowell models may work, too. + +This driver was developed for the Enterprise Nxx and Bxx models. +Other Microdowell models may work, too. EXTRA ARGUMENTS --------------- @@ -26,6 +27,7 @@ linkman:ups.conf[5]. AUTHOR ------ + Elio Corbolante SEE ALSO @@ -33,8 +35,10 @@ SEE ALSO The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/microsol-apc.8 b/docs/man/microsol-apc.8 new file mode 100644 index 0000000..4d06ad0 --- /dev/null +++ b/docs/man/microsol-apc.8 @@ -0,0 +1,146 @@ +'\" t +.\" Title: microsol-apc +.\" Author: [see the "AUTHORS" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 +.\" Manual: NUT Manual +.\" Source: Network UPS Tools 2.8.0 +.\" Language: English +.\" +.TH "MICROSOL\-APC" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +microsol-apc \- Driver for APC Back\-UPS BR UPS equipment +.SH "NOTE" +.sp +This man page only documents the hardware\-specific features of the microsol\-apc driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. +.SH "SUPPORTED HARDWARE" +.sp +This driver supports the following UPS models: +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +APC Back\-UPS BZ1500\-BR +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +APC Back\-UPS BZ2200I\-BR +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +APC Back\-UPS BZ2200BI\-BR +.RE +.sp +In 2009, Schneider Electric acquired Microsol Technologies, and by 2012, the entire Microsol line was being sold under the APC brand\&. This driver supports these newer, APC\-branded models\&. Older equipment should use \fBsolis\fR(8)\&. +.SH "EXTRA ARGUMENTS" +.sp +This driver support the following extra optional settings in the \fBups.conf\fR(5)\&. +.sp +\fBbattext = n\fR \- (default = 0, no extra battery, where n = Ampere*hour ) +.sp +\fBprgshut = 1\fR \- (default = 0, no programmable shutdown ) +.SH "COMMANDS" +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +shutdown\&.return \- Shut down in \&.3 minutes and restart in \&.3 minutes +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +shutdown\&.stayoff \- Shut down in \&.3 minutes and do not return +.RE +.SH "ISSUES" +.sp +For other APC\-Microsol models, the reported voltages, currents and power will be incorrect, as the communication protocol reports unprocessed data instead of real values, needing model\-specific post\-processing by the driver\&. Monitoring of UPS state (on\-battery/on\-line, critical battery) should work for other models, but is untested\&. +.SH "AUTHORS" +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Ygor A\&. S\&. Regados +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Roberto P\&. Velloso +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Silvino B\&. Magalhães +.RE +.SH "SEE ALSO" +.SS "The core driver:" +.sp +\fBnutupsdrv\fR(8) +.SS "Internet resources:" +.sp +The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/microsol-apc.txt b/docs/man/microsol-apc.txt new file mode 100644 index 0000000..74e3225 --- /dev/null +++ b/docs/man/microsol-apc.txt @@ -0,0 +1,73 @@ +MICROSOL-APC(8) +=============== + +NAME +---- + +microsol-apc - Driver for APC Back-UPS BR UPS equipment + +NOTE +---- + +This man page only documents the hardware-specific features of the +microsol-apc driver. For information about the core driver, see +linkman:nutupsdrv[8]. + +SUPPORTED HARDWARE +------------------ + +This driver supports the following UPS models: + + * APC Back-UPS BZ1500-BR + * APC Back-UPS BZ2200I-BR + * APC Back-UPS BZ2200BI-BR + +In 2009, Schneider Electric acquired Microsol Technologies, and by 2012, the +entire Microsol line was being sold under the APC brand. This driver supports +these newer, APC-branded models. Older equipment should use linkman:solis[8]. + +EXTRA ARGUMENTS +--------------- + +This driver support the following extra optional settings in the +linkman:ups.conf[5]. + +*battext = n* - (default = 0, no extra battery, where n = Ampere*hour ) + +*prgshut = 1* - (default = 0, no programmable shutdown ) + +COMMANDS +-------- + + * shutdown.return - Shut down in .3 minutes and restart in .3 minutes + + * shutdown.stayoff - Shut down in .3 minutes and do not return + +ISSUES +------ + +For other APC-Microsol models, the reported voltages, currents and power will +be incorrect, as the communication protocol reports unprocessed data instead of +real values, needing model-specific post-processing by the driver. Monitoring +of UPS state (on-battery/on-line, critical battery) should work for other +models, but is untested. + +AUTHORS +------- + +* Ygor A. S. Regados +* Roberto P. Velloso +* Silvino B. Magalhães + +SEE ALSO +-------- + +The core driver: +~~~~~~~~~~~~~~~~ + +linkman:nutupsdrv[8] + +Internet resources: +~~~~~~~~~~~~~~~~~~~ + +The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/netxml-ups.8 b/docs/man/netxml-ups.8 index 3548020..ebb1a93 100644 --- a/docs/man/netxml-ups.8 +++ b/docs/man/netxml-ups.8 @@ -1,13 +1,13 @@ '\" t .\" Title: netxml-ups .\" Author: [see the "AUTHORS" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NETXML\-UPS" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NETXML\-UPS" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -34,7 +34,7 @@ netxml-ups \- Driver for Eaton / MGE Network Management Card / Proxy (XML/HTTP P This man page only documents the hardware\-specific features of the netxml\-ups driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. .SH "SUPPORTED HARDWARE" .sp -netxml\-ups support all recent Eaton / MGE models which use a Network Management Card or Proxy (MGE XML/HTTP protocol based)\&. This applies to both Eaton (previously MGE Office Protection Systems) and to MGE UPS SYSTEMS\&. Supported card and proxy models are: +netxml\-ups supports all recent Eaton / MGE models which use a Network Management Card or Proxy (MGE XML/HTTP protocol based)\&. This applies to both Eaton (previously MGE Office Protection Systems) and to MGE UPS SYSTEMS\&. Supported card and proxy models are: .sp .RS 4 .ie n \{\ @@ -142,6 +142,11 @@ Set the shutdown timer, in seconds\&. After \fIvalue\fR seconds running on battery, the local system will receive a notification to shutdown\&. Defaults to "none" (disabled)\&. .RE +.PP +\fBdo_convert_deci\fR +.RS 4 +If this flag value is present, the driver assumes you have a very old MGE networked UPS (or rather an old network management card firmware) which serves certain measurements spelled 10x too big in the XML markup\&. Originally such measurements were decimated by the driver \(em but this is wrong for newer, more sane, devices \(em so this behavior was deprecated and is now disabled by default\&. Enabling this flag in configuration of a particular driver instance restores the old behavior for those measurements\&. +.RE .SH "IMPLEMENTATION" .sp The hostname of the UPS is specified with the "port" value in \fBups\&.conf\fR, i\&.e\&.: diff --git a/docs/man/netxml-ups.txt b/docs/man/netxml-ups.txt index 86c86dc..acc672e 100644 --- a/docs/man/netxml-ups.txt +++ b/docs/man/netxml-ups.txt @@ -1,20 +1,23 @@ netxml-ups(8) ============= -NAME +NAME ---- + netxml-ups - Driver for Eaton / MGE Network Management Card / Proxy (XML/HTTP Protocol) equipment NOTE ---- + This man page only documents the hardware-specific features of the -netxml-ups driver. For information about the core driver, see +netxml-ups driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ -netxml-ups support all recent Eaton / MGE models which use a Network + +netxml-ups supports all recent Eaton / MGE models which use a Network Management Card or Proxy (MGE XML/HTTP protocol based). This applies to both Eaton (previously MGE Office Protection Systems) and to MGE UPS SYSTEMS. Supported card and proxy models are: @@ -24,7 +27,7 @@ Supported card and proxy models are: * NMC Transverse (Ref 66074), * NMC & Modbus/JBus (Ref 66103), * Network Management Proxy, - * ePDU Monitored (newer version). + * ePDU Monitored (newer version). Older models, such as SNMP card (Ref 66062 and Ref 66045), use the SNMP protocol and should use the linkman:snmp-ups[8] driver with the "mibs=mge" @@ -32,7 +35,8 @@ parameter. EXTRA ARGUMENTS --------------- -This driver supports the following optional settings in the + +This driver supports the following optional settings in the linkman:ups.conf[5]: *timeout*='value':: @@ -66,8 +70,18 @@ Set the shutdown timer, in seconds. After 'value' seconds running on battery, the local system will receive a notification to shutdown. Defaults to "none" (disabled). +*do_convert_deci*:: +If this flag value is present, the driver assumes you have a very old +MGE networked UPS (or rather an old network management card firmware) +which serves certain measurements spelled 10x too big in the XML markup. +Originally such measurements were decimated by the driver -- but this is +wrong for newer, more sane, devices -- so this behavior was deprecated +and is now disabled by default. Enabling this flag in configuration of a +particular driver instance restores the old behavior for those measurements. + IMPLEMENTATION -------------- + The hostname of the UPS is specified with the "port" value in *ups.conf*, i.e.: @@ -85,6 +99,7 @@ linkman:ups.conf[5]) to at least 5 seconds. KNOWN ISSUES ------------ + Don't connect to the UPS through a proxy. Although it would be trivial to add support for proxies, this is not recommended and don't ask for it. Not only because it will prevent the driver to make a persistent connection to the UPS, @@ -93,6 +108,7 @@ whatever reason), the driver will no longer be able to reach the UPS. AUTHORS ------- + Arjen de Korte SEE ALSO @@ -100,8 +116,10 @@ SEE ALSO The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/nut-driver-enumerator.8 b/docs/man/nut-driver-enumerator.8 new file mode 100644 index 0000000..49576a9 --- /dev/null +++ b/docs/man/nut-driver-enumerator.8 @@ -0,0 +1,158 @@ +'\" t +.\" Title: nut-driver-enumerator +.\" Author: [see the "AUTHOR" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 +.\" Manual: NUT Manual +.\" Source: Network UPS Tools 2.8.0 +.\" Language: English +.\" +.TH "NUT\-DRIVER\-ENUMERA" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +nut-driver-enumerator \- tool to map NUT device entries to service instances +.SH "SYNOPSIS" +.sp +\fBnut\-driver\-enumerator\&.sh\fR \-h +.sp +\fBnut\-driver\-enumerator\&.sh\fR (no args) +.sp +\fBnut\-driver\-enumerator\&.sh\fR [\-\-COMMAND] +.SH "DESCRIPTION" +.sp +\fBnut\-driver\-enumerator\&.sh\fR implements the set\-up and querying of the mapping between NUT driver configuration sections for each individual monitored device, and the operating system service management framework service instances into which such drivers are wrapped for independent execution and management (on platforms where NUT currently supports this integration \(em currently this covers Linux distributions with systemd and systems derived from Solaris 10 codebase, including proprietary Sun/Oracle Solaris and numerous open\-source illumos distributions with SMF)\&. It may be not installed in packaging for other operating systems\&. +.sp +This script provides a uniform interface for further NUT tools such as \fBupsdrvsvcctl\fR(8) to implement their logic as platform\-independently as was possible and practical\&. It is not currently intended for end\-user consumption (and so is located in the \fIlibexec\fR directory), with \fBupsdrvsvcctl\fR exposing the most useful data and actions with its \fIlist\fR and \fIresync\fR arguments\&. +.sp +One part of the platform complexity that \fBnut\-driver\-enumerator\&.sh\fR hides is the difference of rules for valid service instance names in various frameworks, as well as system tools and naming patterns involved\&. +.SH "COMMANDS" +.PP +\fBnut\-driver\-enumerator\&.sh (no args)\fR +.RS 4 +Update wrapping of devices into services +.RE +.PP +\fBnut\-driver\-enumerator\&.sh \-\-daemon(=freq)\fR +.RS 4 +Update wrapping of devices into services in an infinite loop; Default freq is 60 sec\&. +.RE +.PP +\fBnut\-driver\-enumerator\&.sh \-\-reconfigure\fR +.RS 4 +Stop and un\-register all service instances and recreate them (e\&.g\&. if new dependency template was defined in a new version of the script or package) +.RE +.PP +\fBnut\-driver\-enumerator\&.sh \-\-get\-service\-framework\fR +.RS 4 +Print the detected service management framework in this OS +.RE +.PP +\fBnut\-driver\-enumerator\&.sh \-\-list\-devices\fR +.RS 4 +Print list of devices in NUT config +.RE +.PP +\fBnut\-driver\-enumerator\&.sh \-\-list\-services\fR +.RS 4 +Print list of service instances which wrap registered NUT devices (full name of service unit) +.RE +.PP +\fBnut\-driver\-enumerator\&.sh \-\-list\-instances\fR +.RS 4 +Print list of service instances which wrap registered NUT devices (just instance suffix) +.RE +.PP +\fBnut\-driver\-enumerator\&.sh \-\-get\-service\-for\-device DEV\fR +.RS 4 +Print the full name of service unit which wraps a NUT device named +DEV +.RE +.PP +\fBnut\-driver\-enumerator\&.sh \-\-get\-device\-for\-service SVC\fR +.RS 4 +Print the NUT device name for full or instance\-suffix name of a service unit +SVC +which wraps it +.RE +.PP +\fBnut\-driver\-enumerator\&.sh \-\-list\-services\-for\-devices\fR +.RS 4 +Print a TAB\-separated list of service units and corresponding NUT device names which each such unit wraps +.RE +.PP +\fBnut\-driver\-enumerator\&.sh \-\-show\-all\-configs\fR +.RS 4 +Show the complete normalized list of device configuration blocks (same as used later by the parser in the script to make decisions) +.RE +.PP +\fBnut\-driver\-enumerator\&.sh \-\-show\-device\-config DEV\fR +.RS 4 +Show configuration block of the specified NUT device +.RE +.PP +\fBnut\-driver\-enumerator\&.sh \-\-show\-device\-config\-value DEV KEY\fR +.RS 4 +Show single configuration key of the specified NUT device +.RE +.SH "ENVIRONMENT VARIABLES" +.sp +By default \fBnut\-driver\-enumerator\&.sh\fR executed without arguments would automatically start any newly registered service instances wrapping the NUT devices, and would also restart the nut\-server service if the configuration was changed\&. Environment variable AUTO_START=no disables this default part of the action\&. +.sp +Also see below for environment variable REPORT_RESTART_42=no value\&. +.SH "DIAGNOSTICS" +.sp +\fBnut\-driver\-enumerator\&.sh\fR will return a zero exit code if it had nothing to do (all currently defined drivers match all of the currently defined service instances, one\-to\-one) and if it had no errors in its operation\&. +.sp +Other codes can be returned as a result of re\-synchronization of mappings: +.PP +\fB42\fR +.RS 4 +NUT device sections and system service instances differed before, but now match up \(em so now the caller should likely restart some services\&. Note that the drivers\*(Aq service instances may have been started or stopped as required (by +AUTO_START=yes) \(em but maybe the upsmon or upssched services should restart\&. If you pass environment variable +REPORT_RESTART_42=no +then this codepath would return 0 (as a non\-error exit code)\&. In default mode, such non\-null reconfiguration should cause the nut\-driver\-enumerator service to restart and this would propagate to other NUT services that depend on it\&. +.RE +.PP +\fB13\fR +.RS 4 +Sections and services differed, and still do not match up +.RE +.PP +\fB1\fR +.RS 4 +Bad inputs, e\&.g\&. unrecognized service management framework +.RE +.PP +\fB2\fR +.RS 4 +Absent or unreadable +ups\&.conf +file +.RE +.SH "AUTHOR" +.sp +Jim Klimov +.SH "SEE ALSO" +.sp +\fBupsdrvsvcctl\fR(8), \fBups.conf\fR(5) +.SS "Internet resources:" +.sp +The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/nut-driver-enumerator.txt b/docs/man/nut-driver-enumerator.txt new file mode 100644 index 0000000..6fe92db --- /dev/null +++ b/docs/man/nut-driver-enumerator.txt @@ -0,0 +1,150 @@ +NUT-DRIVER-ENUMERATOR(8) +======================== + +NAME +---- + +nut-driver-enumerator - tool to map NUT device entries to service instances + +SYNOPSIS +-------- + +*nut-driver-enumerator.sh* -h + +*nut-driver-enumerator.sh* (no args) + +*nut-driver-enumerator.sh* [--COMMAND] + + +DESCRIPTION +----------- + +*nut-driver-enumerator.sh* implements the set-up and querying of the +mapping between NUT driver configuration sections for each individual +monitored device, and the operating system service management framework +service instances into which such drivers are wrapped for independent +execution and management (on platforms where NUT currently supports +this integration -- currently this covers Linux distributions with +systemd and systems derived from Solaris 10 codebase, including +proprietary Sun/Oracle Solaris and numerous open-source illumos +distributions with SMF). It may be not installed in packaging for +other operating systems. + +This script provides a uniform interface for further NUT tools +such as linkman:upsdrvsvcctl[8] to implement their logic as +platform-independently as was possible and practical. It is not +currently intended for end-user consumption (and so is located in +the 'libexec' directory), with *upsdrvsvcctl* exposing the most +useful data and actions with its 'list' and 'resync' arguments. + +One part of the platform complexity that *nut-driver-enumerator.sh* +hides is the difference of rules for valid service instance names +in various frameworks, as well as system tools and naming patterns +involved. + +COMMANDS +-------- + +*nut-driver-enumerator.sh (no args)*:: +Update wrapping of devices into services + +*nut-driver-enumerator.sh --daemon(=freq)*:: +Update wrapping of devices into services in an infinite loop; +Default freq is 60 sec. + +*nut-driver-enumerator.sh --reconfigure*:: +Stop and un-register all service instances and recreate them +(e.g. if new dependency template was defined in a new +version of the script or package) + +*nut-driver-enumerator.sh --get-service-framework*:: +Print the detected service management framework in this OS + +*nut-driver-enumerator.sh --list-devices*:: +Print list of devices in NUT config + +*nut-driver-enumerator.sh --list-services*:: +Print list of service instances which wrap registered +NUT devices (full name of service unit) + +*nut-driver-enumerator.sh --list-instances*:: +Print list of service instances which wrap registered +NUT devices (just instance suffix) + +*nut-driver-enumerator.sh --get-service-for-device DEV*:: +Print the full name of service unit which wraps a NUT +device named `DEV` + +*nut-driver-enumerator.sh --get-device-for-service SVC*:: +Print the NUT device name for full or instance-suffix name of +a service unit `SVC` which wraps it + +*nut-driver-enumerator.sh --list-services-for-devices*:: +Print a TAB-separated list of service units and corresponding +NUT device names which each such unit wraps + +*nut-driver-enumerator.sh --show-all-configs*:: +Show the complete normalized list of device configuration blocks +(same as used later by the parser in the script to make decisions) + +*nut-driver-enumerator.sh --show-device-config DEV*:: +Show configuration block of the specified NUT device + +*nut-driver-enumerator.sh --show-device-config-value DEV KEY*:: +Show single configuration key of the specified NUT device + +ENVIRONMENT VARIABLES +--------------------- + +By default *nut-driver-enumerator.sh* executed without arguments would +automatically start any newly registered service instances wrapping the +NUT devices, and would also restart the `nut-server` service if the +configuration was changed. Environment variable `AUTO_START=no` disables +this default part of the action. + +Also see below for environment variable `REPORT_RESTART_42=no` value. + +DIAGNOSTICS +----------- + +*nut-driver-enumerator.sh* will return a zero exit code if it had nothing +to do (all currently defined drivers match all of the currently defined +service instances, one-to-one) and if it had no errors in its operation. + +Other codes can be returned as a result of re-synchronization of mappings: + +*42*:: +NUT device sections and system service instances differed before, but +now match up -- so now the caller should likely restart some services. +Note that the drivers' service instances may have been started or stopped +as required (by `AUTO_START=yes`) -- but maybe the upsmon or upssched +services should restart. +If you pass environment variable `REPORT_RESTART_42=no` then +this codepath would return 0 (as a non-error exit code). +In default mode, such non-null reconfiguration should cause +the nut-driver-enumerator service to restart and this would +propagate to other NUT services that depend on it. + +*13*:: +Sections and services differed, and still do not match up + +*1*:: +Bad inputs, e.g. unrecognized service management framework + +*2*:: +Absent or unreadable `ups.conf` file + +AUTHOR +------ + +Jim Klimov + +SEE ALSO +-------- + +linkman:upsdrvsvcctl[8], linkman:ups.conf[5] + +Internet resources: +~~~~~~~~~~~~~~~~~~~ + +The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/nut-ipmipsu.8 b/docs/man/nut-ipmipsu.8 index c5fb963..021d322 100644 --- a/docs/man/nut-ipmipsu.8 +++ b/docs/man/nut-ipmipsu.8 @@ -1,13 +1,13 @@ '\" t .\" Title: nut-ipmipsu .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUT\-IPMIPSU" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUT\-IPMIPSU" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -223,6 +223,26 @@ Arnaud Quette \fBnutupsdrv\fR(8) .SS "Internet resources:" .sp -The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The NUT (Network UPS Tools) home page: +http://www\&.networkupstools\&.org/ +.RE .sp -GNU FreeIPMI home page: http://www\&.gnu\&.org/software/freeipmi/ +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +GNU FreeIPMI home page: +http://www\&.gnu\&.org/software/freeipmi/ +.RE diff --git a/docs/man/nut-ipmipsu.txt b/docs/man/nut-ipmipsu.txt index 11c4f5c..5191ea2 100644 --- a/docs/man/nut-ipmipsu.txt +++ b/docs/man/nut-ipmipsu.txt @@ -1,4 +1,4 @@ -NUT-IPMIPSU(8) +NUT-IPMIPSU(8) ============== NAME @@ -100,16 +100,19 @@ Here is an example output for a Dell r610 server: AUTHOR ------ + Arnaud Quette SEE ALSO -------- + The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ -The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ -GNU FreeIPMI home page: http://www.gnu.org/software/freeipmi/ +* The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ +* GNU FreeIPMI home page: http://www.gnu.org/software/freeipmi/ diff --git a/docs/man/nut-recorder.8 b/docs/man/nut-recorder.8 index 1b03f48..856902d 100644 --- a/docs/man/nut-recorder.8 +++ b/docs/man/nut-recorder.8 @@ -1,13 +1,13 @@ '\" t .\" Title: nut-recorder .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUT\-RECORDER" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUT\-RECORDER" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -96,8 +96,9 @@ You can then define a dummy device in \fBups.conf\fR(5): .sp Arnaud Quette .SH "SEE ALSO" +.SS "The dummy\-ups driver:" .sp \fBdummy-ups\fR(8) -.SH "INTERNET RESOURCES" +.SS "Internet resources:" .sp The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/nut-recorder.txt b/docs/man/nut-recorder.txt index e202239..edde4ae 100644 --- a/docs/man/nut-recorder.txt +++ b/docs/man/nut-recorder.txt @@ -1,17 +1,19 @@ NUT-RECORDER(8) =============== - NAME ---- + nut-recorder - utility to record device status and values changes SYNOPSIS -------- + *nut-recorder* 'device-name' [output-file] [interval] DESCRIPTION ----------- + *nut-recorder* is an utility to record sequences from running devices (such as power failures, or any other value changes) from upsd, and dump it in a .seq format. @@ -21,6 +23,7 @@ to replay the sequence. OPTIONS ------- + 'device-name':: Record the changes of this device. The format for this option is @@ -60,14 +63,18 @@ You can then define a dummy device in linkman:ups.conf[5]: AUTHOR ------ + Arnaud Quette SEE ALSO -------- +The dummy-ups driver: +~~~~~~~~~~~~~~~~~~~~~ + linkman:dummy-ups[8] -INTERNET RESOURCES ------------------- +Internet resources: +~~~~~~~~~~~~~~~~~~~ The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/nut-scanner.8 b/docs/man/nut-scanner.8 index a18ba23..e1eaeb9 100644 --- a/docs/man/nut-scanner.8 +++ b/docs/man/nut-scanner.8 @@ -1,13 +1,13 @@ '\" t .\" Title: nut-scanner -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUT\-SCANNER" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUT\-SCANNER" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -103,7 +103,7 @@ Scan NUT compatible power supplies available via IPMI on the current host, or ov .PP \fB\-E\fR | \fB\-\-eaton_serial\fR \fIserial ports\fR .RS 4 -Scan Eaton devices (XCP and SHUT) available via serial bus on the current host\&. This option must be requested explicitely, even for a complete scan\&. +Scan Eaton devices (XCP and SHUT) available via serial bus on the current host\&. This option must be requested explicitly, even for a complete scan\&. \fIserial ports\fR can be expressed in various forms: .sp @@ -127,7 +127,7 @@ to scan all serial ports\&. .sp -1 .IP \(bu 2.3 .\} -a single charcater indicating a port number (\fI0\fR +a single character indicating a port number (\fI0\fR (zero) for /dev/ttyS0 and /dev/ttyUSB0 on Linux, \fI1\fR for COM1 on Windows, @@ -144,7 +144,7 @@ for /dev/ttya on Solaris\&...) .IP \(bu 2.3 .\} a range of N characters, hyphen separated, describing the range of ports using -\fIX\-Y\fR, where X and Y are characters refering to the port number\&. +\fIX\-Y\fR, where X and Y are characters referring to the port number\&. .RE .sp .RS 4 @@ -229,7 +229,9 @@ used for authenticated SNMPv3 messages\&. This parameter is mandatory if you set .RS 4 Set the \fIauthentication protocol\fR -used for authenticated SNMPv3 messages\&. Allowed values are MD5 or SHA\&. Default value is MD5\&. +used for authenticated SNMPv3 messages\&. Allowed values are MD5, SHA, SHA256, SHA384 or SHA512 (depending on Net\-SNMP library capabilities; check help of the +nut\-scanner +binary program for the run\-time supported list)\&. Default value is MD5\&. .RE .PP \fB\-W\fR | \fB\-\-authPassword\fR \fIauthentication pass phrase\fR @@ -245,7 +247,9 @@ to authNoPriv or authPriv\&. .RS 4 Set the \fIprivacy protocol\fR -used for encrypted SNMPv3 messages\&. Allowed values are DES or AES\&. Default value is DES\&. +used for encrypted SNMPv3 messages\&. Allowed values are DES, AES, AES192 or AES256 (depending on Net\-SNMP library capabilities; check help of the +nut\-scanner +binary program for the run\-time supported list)\&. Default value is DES\&. .RE .PP \fB\-X\fR | \fB\-\-privPassword\fR \fIprivacy pass phrase\fR @@ -275,7 +279,7 @@ Specify the IPMI 1\&.5 authentication type to use (NONE, STRAIGHT_PASSWORD_KEY, IPMI interface , thus in IPMI 1\&.5 mode\&. .RE .PP -\fB\-D\fR | \fB\-\-cipher_suite_id\fR \fIcipher suite identifier\fR +\fB\-L\fR | \fB\-\-cipher_suite_id\fR \fIcipher suite identifier\fR .RS 4 Specify the IPMI 2\&.0 cipher suite ID to use\&. The Cipher Suite ID identifies a set of authentication, integrity, and confidentiality algorithms to use for IPMI 2\&.0 communication\&. The authentication algorithm identifies the algorithm to use for session setup, the integrity algorithm identifies the algorithm to use for session packet signatures, and the confidentiality algorithm identifies the algorithm to use for payload encryption (default=3)\&. .sp @@ -429,6 +433,11 @@ Display available bus that can be scanned , depending on how the binary has been .RS 4 Display only scan result\&. No information on currently scanned bus is displayed\&. .RE +.PP +\fB\-D\fR | \fB\-\-nut_debug_level\fR +.RS 4 +Raise the debugging level\&. Use this multiple times to see more details\&. +.RE .SH "EXAMPLES" .sp To scan USB devices only: @@ -461,6 +470,6 @@ To scan for Eaton serial devices on ports 1 and 2 (COM1 and COM2 on Windows): .SH "SEE ALSO" .sp \fBups.conf\fR(5) -.SH "INTERNET RESOURCES" +.SS "Internet resources:" .sp The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/nut-scanner.txt b/docs/man/nut-scanner.txt index 7f99465..9560360 100644 --- a/docs/man/nut-scanner.txt +++ b/docs/man/nut-scanner.txt @@ -1,13 +1,14 @@ NUT-SCANNER(8) ============== - NAME ---- + nut-scanner - scan communication buses for NUT devices SYNOPSIS -------- + *nut-scanner* -h *nut-scanner* ['OPTIONS'] @@ -29,6 +30,7 @@ both during compilation and runtime, then SNMP discovery will be available. OPTIONS ------- + *-h*:: Display the help text. @@ -54,7 +56,7 @@ List all NUT-compatible USB devices currently plugged in. Scan SNMP devices. Requires at least a 'start IP', and optionally, an 'end IP'. See specific SNMP OPTIONS for community and security settings. *-M* | *--xml_scan*:: -Scan XML/HTTP devices. Broadcast a network message on the current network interfaces to retrieve XML/HTTP capable devices. No IP required. +Scan XML/HTTP devices. Broadcast a network message on the current network interfaces to retrieve XML/HTTP capable devices. No IP required. *-O* | *--oldnut_scan*:: Scan NUT devices (i.e. upsd daemon) on IP ranging from 'start IP' to 'end IP'. @@ -67,14 +69,14 @@ Scan NUT compatible power supplies available via IPMI on the current host, or ov *-E* | *--eaton_serial* 'serial ports':: Scan Eaton devices (XCP and SHUT) available via serial bus on the current host. -This option must be requested explicitely, even for a complete scan. +This option must be requested explicitly, even for a complete scan. 'serial ports' can be expressed in various forms: - 'auto' to scan all serial ports. -- a single charcater indicating a port number ('0' (zero) for /dev/ttyS0 and +- a single character indicating a port number ('0' (zero) for /dev/ttyS0 and /dev/ttyUSB0 on Linux, '1' for COM1 on Windows, 'a' for /dev/ttya on Solaris...) - a range of N characters, hyphen separated, describing the range of -ports using 'X-Y', where X and Y are characters refering to the port number. +ports using 'X-Y', where X and Y are characters referring to the port number. - a single port name. - a list of ports name, coma separated, like '/dev/ttyS1,/dev/ttyS4'. @@ -116,13 +118,13 @@ Set the 'security level' used for SNMPv3 messages. Allowed values are: noAuthNoP Set the 'security name' used for authenticated SNMPv3 messages. This parameter is mandatory if you set 'security level'. *-w* | *--authProtocol* 'authentication protocol':: -Set the 'authentication protocol' used for authenticated SNMPv3 messages. Allowed values are MD5 or SHA. Default value is MD5. +Set the 'authentication protocol' used for authenticated SNMPv3 messages. Allowed values are MD5, SHA, SHA256, SHA384 or SHA512 (depending on Net-SNMP library capabilities; check help of the `nut-scanner` binary program for the run-time supported list). Default value is MD5. *-W* | *--authPassword* 'authentication pass phrase':: Set the 'authentication pass phrase' used for authenticated SNMPv3 messages. This parameter is mandatory if you set 'security level' to authNoPriv or authPriv. *-x* | *--privProtocol* 'privacy protocol':: -Set the 'privacy protocol' used for encrypted SNMPv3 messages. Allowed values are DES or AES. Default value is DES. +Set the 'privacy protocol' used for encrypted SNMPv3 messages. Allowed values are DES, AES, AES192 or AES256 (depending on Net-SNMP library capabilities; check help of the `nut-scanner` binary program for the run-time supported list). Default value is DES. *-X* | *--privPassword* 'privacy pass phrase':: Set the 'privacy pass phrase' used for encrypted SNMPv3 messages. This parameter is mandatory if you set 'security level' to authPriv. @@ -140,7 +142,7 @@ Specify the password to use when authenticating with the remote host (mandatory Specify the IPMI 1.5 authentication type to use (NONE, STRAIGHT_PASSWORD_KEY, MD2, and MD5) with the remote host (default=MD5). This forces connection through the 'lan' IPMI interface , thus in IPMI 1.5 mode. -*-D* | *--cipher_suite_id* 'cipher suite identifier':: +*-L* | *--cipher_suite_id* 'cipher suite identifier':: Specify the IPMI 2.0 cipher suite ID to use. The Cipher Suite ID identifies a set of authentication, integrity, and confidentiality algorithms to use for IPMI 2.0 communication. The authentication algorithm identifies the algorithm to use for session setup, the integrity algorithm identifies the algorithm to use for session packet signatures, and the @@ -173,6 +175,9 @@ Display available bus that can be scanned , depending on how the binary has been *-q* | *--quiet*:: Display only scan result. No information on currently scanned bus is displayed. +*-D* | *--nut_debug_level*:: +Raise the debugging level. Use this multiple times to see more details. + EXAMPLES -------- @@ -210,7 +215,7 @@ SEE ALSO linkman:ups.conf[5] -INTERNET RESOURCES ------------------- +Internet resources: +~~~~~~~~~~~~~~~~~~~ The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/nut.conf.5 b/docs/man/nut.conf.5 index f7b7e24..cf06517 100644 --- a/docs/man/nut.conf.5 +++ b/docs/man/nut.conf.5 @@ -1,13 +1,13 @@ '\" t .\" Title: nut.conf -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUT\&.CONF" "5" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUT\&.CONF" "5" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -94,7 +94,7 @@ above indicates that no upsmon should be running\&. .PP \fBPOWEROFF_WAIT\fR .RS 4 -Optional\&. At the end of an emergency system halt, the upsmon master will signal the UPS to switch off\&. This may fail for a number of reasons\&. Most notably is the case that mains power returns during the shutdown process\&. See the section "Power races" in /usr/share/doc/nut/FAQ\&.txt\&.gz\&. The system will wait this long for the UPS to cut power, and then reboot\&. It should be long enough to exhaust the batteries, in case line power continues to be unavailable\&. On the other hand, it should not be so long that the system remains offline for an unreasonable amount of time if line power has returned\&. See sleep(1) for compatible time syntax\&. If you specify the time in seconds, use the "s" suffix\&. +Optional\&. At the end of an emergency system halt, the upsmon primary will signal the UPS to switch off\&. This may fail for a number of reasons\&. Most notably is the case that mains power returns during the shutdown process\&. See the section "Power races" in /usr/share/doc/nut/FAQ\&.txt\&.gz\&. The system will wait this long for the UPS to cut power, and then reboot\&. It should be long enough to exhaust the batteries, in case line power continues to be unavailable\&. On the other hand, it should not be so long that the system remains offline for an unreasonable amount of time if line power has returned\&. See sleep(1) for compatible time syntax\&. If you specify the time in seconds, use the "s" suffix\&. .RE .if n \{\ .sp @@ -118,57 +118,25 @@ this workaround might be dangerous under some circumstances\&. Please read http: .RS 4 .\} .nf -# /etc/nut/nut\&.conf\&. See nut\&.conf(5) -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -MODE=none -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -UPSD_OPTIONS="" -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -UPSMON_OPTIONS="" -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -# POWEROFF_WAIT=15m + # /etc/nut/nut\&.conf\&. See nut\&.conf(5) + + MODE=none + + UPSD_OPTIONS="" + + UPSMON_OPTIONS="" + + # POWEROFF_WAIT=15m .fi .if n \{\ .RE .\} .SH "INTEGRATION" .sp -An init script, such as /etc/init\&.d/nut, is expected to source this file in order to determine which component(s) has to be started\&. +An init script, such as /etc/init\&.d/nut, is expected to source this file in order to determine which components have to be started\&. .SH "SEE ALSO" .sp \fBups.conf\fR(5), \fBupsd.conf\fR(5), \fBupsd.users\fR(5), \fBupsmon.conf\fR(5) -.SH "INTERNET RESOURCES" +.SS "Internet resources:" .sp The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/nut.conf.txt b/docs/man/nut.conf.txt index 881a08a..90f7106 100644 --- a/docs/man/nut.conf.txt +++ b/docs/man/nut.conf.txt @@ -3,6 +3,7 @@ NUT.CONF(5) NAME ---- + nut.conf - UPS definitions for Network UPS Tools DESCRIPTION @@ -64,7 +65,7 @@ more details. It is ignored when 'MODE' above indicates that no upsmon should be running. *POWEROFF_WAIT*:: -Optional. At the end of an emergency system halt, the upsmon master +Optional. At the end of an emergency system halt, the upsmon primary will signal the UPS to switch off. This may fail for a number of reasons. Most notably is the case that mains power returns during the shutdown process. See the section "Power races" in @@ -82,6 +83,7 @@ Please read http://bugs.debian.org/358696 for more details. EXAMPLE ------- +------ # /etc/nut/nut.conf. See nut.conf(5) MODE=none @@ -91,12 +93,13 @@ EXAMPLE UPSMON_OPTIONS="" # POWEROFF_WAIT=15m +------ INTEGRATION ----------- An init script, such as /etc/init.d/nut, is expected to source this -file in order to determine which component(s) has to be started. +file in order to determine which components have to be started. SEE ALSO -------- @@ -104,6 +107,7 @@ SEE ALSO linkman:ups.conf[5], linkman:upsd.conf[5], linkman:upsd.users[5], linkman:upsmon.conf[5] -INTERNET RESOURCES ------------------- +Internet resources: +~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/nutclient_authenticate.3 b/docs/man/nutclient_authenticate.3 index b7346a9..d2c6e59 100644 --- a/docs/man/nutclient_authenticate.3 +++ b/docs/man/nutclient_authenticate.3 @@ -1 +1 @@ -.so libnutclient_misc.3 +.so man3/libnutclient_misc.3 diff --git a/docs/man/nutclient_destroy.3 b/docs/man/nutclient_destroy.3 index b2f546d..8269028 100644 --- a/docs/man/nutclient_destroy.3 +++ b/docs/man/nutclient_destroy.3 @@ -1 +1 @@ -.so libnutclient_general.3 +.so man3/libnutclient_general.3 diff --git a/docs/man/nutclient_device_forced_shutdown.3 b/docs/man/nutclient_device_forced_shutdown.3 index b7346a9..d2c6e59 100644 --- a/docs/man/nutclient_device_forced_shutdown.3 +++ b/docs/man/nutclient_device_forced_shutdown.3 @@ -1 +1 @@ -.so libnutclient_misc.3 +.so man3/libnutclient_misc.3 diff --git a/docs/man/nutclient_device_login.3 b/docs/man/nutclient_device_login.3 index b7346a9..d2c6e59 100644 --- a/docs/man/nutclient_device_login.3 +++ b/docs/man/nutclient_device_login.3 @@ -1 +1 @@ -.so libnutclient_misc.3 +.so man3/libnutclient_misc.3 diff --git a/docs/man/nutclient_device_master.3 b/docs/man/nutclient_device_master.3 index b7346a9..d2c6e59 100644 --- a/docs/man/nutclient_device_master.3 +++ b/docs/man/nutclient_device_master.3 @@ -1 +1 @@ -.so libnutclient_misc.3 +.so man3/libnutclient_misc.3 diff --git a/docs/man/nutclient_execute_device_command.3 b/docs/man/nutclient_execute_device_command.3 index 36dc188..ae0e4eb 100644 --- a/docs/man/nutclient_execute_device_command.3 +++ b/docs/man/nutclient_execute_device_command.3 @@ -1 +1 @@ -.so libnutclient_commands.3 +.so man3/libnutclient_commands.3 diff --git a/docs/man/nutclient_get_device_command_description.3 b/docs/man/nutclient_get_device_command_description.3 index 36dc188..ae0e4eb 100644 --- a/docs/man/nutclient_get_device_command_description.3 +++ b/docs/man/nutclient_get_device_command_description.3 @@ -1 +1 @@ -.so libnutclient_commands.3 +.so man3/libnutclient_commands.3 diff --git a/docs/man/nutclient_get_device_commands.3 b/docs/man/nutclient_get_device_commands.3 index 36dc188..ae0e4eb 100644 --- a/docs/man/nutclient_get_device_commands.3 +++ b/docs/man/nutclient_get_device_commands.3 @@ -1 +1 @@ -.so libnutclient_commands.3 +.so man3/libnutclient_commands.3 diff --git a/docs/man/nutclient_get_device_description.3 b/docs/man/nutclient_get_device_description.3 index 95bc2dc..6499d7b 100644 --- a/docs/man/nutclient_get_device_description.3 +++ b/docs/man/nutclient_get_device_description.3 @@ -1 +1 @@ -.so libnutclient_devices.3 +.so man3/libnutclient_devices.3 diff --git a/docs/man/nutclient_get_device_num_logins.3 b/docs/man/nutclient_get_device_num_logins.3 index b7346a9..d2c6e59 100644 --- a/docs/man/nutclient_get_device_num_logins.3 +++ b/docs/man/nutclient_get_device_num_logins.3 @@ -1 +1 @@ -.so libnutclient_misc.3 +.so man3/libnutclient_misc.3 diff --git a/docs/man/nutclient_get_device_rw_variables.3 b/docs/man/nutclient_get_device_rw_variables.3 index 087bc31..cfb1867 100644 --- a/docs/man/nutclient_get_device_rw_variables.3 +++ b/docs/man/nutclient_get_device_rw_variables.3 @@ -1 +1 @@ -.so libnutclient_variables.3 +.so man3/libnutclient_variables.3 diff --git a/docs/man/nutclient_get_device_variable_description.3 b/docs/man/nutclient_get_device_variable_description.3 index 087bc31..cfb1867 100644 --- a/docs/man/nutclient_get_device_variable_description.3 +++ b/docs/man/nutclient_get_device_variable_description.3 @@ -1 +1 @@ -.so libnutclient_variables.3 +.so man3/libnutclient_variables.3 diff --git a/docs/man/nutclient_get_device_variable_values.3 b/docs/man/nutclient_get_device_variable_values.3 index 087bc31..cfb1867 100644 --- a/docs/man/nutclient_get_device_variable_values.3 +++ b/docs/man/nutclient_get_device_variable_values.3 @@ -1 +1 @@ -.so libnutclient_variables.3 +.so man3/libnutclient_variables.3 diff --git a/docs/man/nutclient_get_device_variables.3 b/docs/man/nutclient_get_device_variables.3 index 087bc31..cfb1867 100644 --- a/docs/man/nutclient_get_device_variables.3 +++ b/docs/man/nutclient_get_device_variables.3 @@ -1 +1 @@ -.so libnutclient_variables.3 +.so man3/libnutclient_variables.3 diff --git a/docs/man/nutclient_get_devices.3 b/docs/man/nutclient_get_devices.3 index 95bc2dc..6499d7b 100644 --- a/docs/man/nutclient_get_devices.3 +++ b/docs/man/nutclient_get_devices.3 @@ -1 +1 @@ -.so libnutclient_devices.3 +.so man3/libnutclient_devices.3 diff --git a/docs/man/nutclient_has_device.3 b/docs/man/nutclient_has_device.3 index 95bc2dc..6499d7b 100644 --- a/docs/man/nutclient_has_device.3 +++ b/docs/man/nutclient_has_device.3 @@ -1 +1 @@ -.so libnutclient_devices.3 +.so man3/libnutclient_devices.3 diff --git a/docs/man/nutclient_has_device_command.3 b/docs/man/nutclient_has_device_command.3 index 36dc188..ae0e4eb 100644 --- a/docs/man/nutclient_has_device_command.3 +++ b/docs/man/nutclient_has_device_command.3 @@ -1 +1 @@ -.so libnutclient_commands.3 +.so man3/libnutclient_commands.3 diff --git a/docs/man/nutclient_has_device_variable.3 b/docs/man/nutclient_has_device_variable.3 index 087bc31..cfb1867 100644 --- a/docs/man/nutclient_has_device_variable.3 +++ b/docs/man/nutclient_has_device_variable.3 @@ -1 +1 @@ -.so libnutclient_variables.3 +.so man3/libnutclient_variables.3 diff --git a/docs/man/nutclient_logout.3 b/docs/man/nutclient_logout.3 index b7346a9..d2c6e59 100644 --- a/docs/man/nutclient_logout.3 +++ b/docs/man/nutclient_logout.3 @@ -1 +1 @@ -.so libnutclient_misc.3 +.so man3/libnutclient_misc.3 diff --git a/docs/man/nutclient_set_device_variable_value.3 b/docs/man/nutclient_set_device_variable_value.3 index 087bc31..cfb1867 100644 --- a/docs/man/nutclient_set_device_variable_value.3 +++ b/docs/man/nutclient_set_device_variable_value.3 @@ -1 +1 @@ -.so libnutclient_variables.3 +.so man3/libnutclient_variables.3 diff --git a/docs/man/nutclient_set_device_variable_values.3 b/docs/man/nutclient_set_device_variable_values.3 index 087bc31..cfb1867 100644 --- a/docs/man/nutclient_set_device_variable_values.3 +++ b/docs/man/nutclient_set_device_variable_values.3 @@ -1 +1 @@ -.so libnutclient_variables.3 +.so man3/libnutclient_variables.3 diff --git a/docs/man/nutclient_tcp_create_client.3 b/docs/man/nutclient_tcp_create_client.3 index 7df5982..350e176 100644 --- a/docs/man/nutclient_tcp_create_client.3 +++ b/docs/man/nutclient_tcp_create_client.3 @@ -1 +1 @@ -.so libnutclient_tcp.3 +.so man3/libnutclient_tcp.3 diff --git a/docs/man/nutclient_tcp_disconnect.3 b/docs/man/nutclient_tcp_disconnect.3 index 7df5982..350e176 100644 --- a/docs/man/nutclient_tcp_disconnect.3 +++ b/docs/man/nutclient_tcp_disconnect.3 @@ -1 +1 @@ -.so libnutclient_tcp.3 +.so man3/libnutclient_tcp.3 diff --git a/docs/man/nutclient_tcp_get_timeout.3 b/docs/man/nutclient_tcp_get_timeout.3 index 7df5982..350e176 100644 --- a/docs/man/nutclient_tcp_get_timeout.3 +++ b/docs/man/nutclient_tcp_get_timeout.3 @@ -1 +1 @@ -.so libnutclient_tcp.3 +.so man3/libnutclient_tcp.3 diff --git a/docs/man/nutclient_tcp_is_connected.3 b/docs/man/nutclient_tcp_is_connected.3 index 7df5982..350e176 100644 --- a/docs/man/nutclient_tcp_is_connected.3 +++ b/docs/man/nutclient_tcp_is_connected.3 @@ -1 +1 @@ -.so libnutclient_tcp.3 +.so man3/libnutclient_tcp.3 diff --git a/docs/man/nutclient_tcp_reconnect.3 b/docs/man/nutclient_tcp_reconnect.3 index 7df5982..350e176 100644 --- a/docs/man/nutclient_tcp_reconnect.3 +++ b/docs/man/nutclient_tcp_reconnect.3 @@ -1 +1 @@ -.so libnutclient_tcp.3 +.so man3/libnutclient_tcp.3 diff --git a/docs/man/nutclient_tcp_set_timeout.3 b/docs/man/nutclient_tcp_set_timeout.3 index 7df5982..350e176 100644 --- a/docs/man/nutclient_tcp_set_timeout.3 +++ b/docs/man/nutclient_tcp_set_timeout.3 @@ -1 +1 @@ -.so libnutclient_tcp.3 +.so man3/libnutclient_tcp.3 diff --git a/docs/man/nutdrv_atcl_usb.8 b/docs/man/nutdrv_atcl_usb.8 index 540c12e..31554a4 100644 --- a/docs/man/nutdrv_atcl_usb.8 +++ b/docs/man/nutdrv_atcl_usb.8 @@ -1,13 +1,13 @@ '\" t .\" Title: nutdrv_atcl_usb -.\" Author: [see the "AUTHORS" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/09/2016 +.\" Author: [see the "AUTHOR" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUTDRV_ATCL_USB" "8" "03/09/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUTDRV_ATCL_USB" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -34,7 +34,11 @@ nutdrv_atcl_usb \- Driver for \*(AqATCL FOR UPS\*(Aq equipment This man page only documents the specific features of the nutdrv_atcl_usb driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. .SH "SUPPORTED HARDWARE" .sp -This driver is for UPS hardware which identifies itself as USB idVendor 0001 and idProduct 0000, and iManufacturer ATCL FOR UPS\&. Known manufacturers include Kanji and Plexus\&. The UPS interface seems to be a generic USB\-to\-serial chip, and for hardware manufactured by Kanji and Plexus, the microcontroller appears to emulate a traditional contact\-closure interface\&. This translates into only three states in ups\&.status: \fBOL\fR, \fBOB\fR and \fBOB LB\fR (similar to \fBgenericups\fR(8)), with no other dynamic status values reported\&. Note that these USB identifiers (including the iManufacturer string) have also been seen on devices that are supported by the fuji subdriver of \fBnutdrv_qx\fR(8)\&. +This driver is for UPS hardware which identifies itself as USB idVendor 0001 and idProduct 0000, and iManufacturer ATCL FOR UPS\&. Known manufacturers include Kanji and Plexus\&. +.sp +The UPS interface seems to be a generic USB\-to\-serial chip, and for hardware manufactured by Kanji and Plexus, the microcontroller appears to emulate a traditional contact\-closure interface\&. This translates into only three states in ups\&.status: \fBOL\fR, \fBOB\fR and \fBOB LB\fR (similar to \fBgenericups\fR(8)), with no other dynamic status values reported\&. +.sp +Note that these USB identifiers (including the iManufacturer string) have also been seen on devices that are supported by the fuji subdriver of \fBnutdrv_qx\fR(8)\&. .SH "EXTRA ARGUMENTS" .sp This driver supports the following optional setting: @@ -49,12 +53,12 @@ devices, such as .RE .SH "BUGS" .sp -The UPS returns the same code for "load power is off" as for "on line power"\&. This condition will not be observed if the NUT master is powered by the UPS, but may be an issue if the UPS is monitored by a remote system\&. +The UPS returns the same code for "load power is off" as for "on line power"\&. This condition will not be observed if the NUT upsmon in primary mode runs on the box powered by the UPS, but may be an issue if the UPS is monitored by a remote (secondary) system\&. .sp The time between the shutdown command and removal of power seems to be fixed at 30 seconds\&. Ensure that the NUT shutdown script is invoked as late as possible in the shutdown procedure (in case some services take longer than others to clean up)\&. .sp -Most contact\-closure UPSes will not power down the load if the line power is present\&. This can create a race when using slave \fBupsmon\fR(8) systems\&. See the \fBupsmon\fR(8) man page for more information\&. The solution to this problem is to upgrade to a smart protocol UPS of some kind that allows detection and proper load cycling on command\&. -.SH "AUTHORS" +Most contact\-closure UPSes will not power down the load if the line power is present\&. This can create a race when using secondary \fBupsmon\fR(8) systems\&. See the \fBupsmon\fR(8) man page for more information\&. The solution to this problem is to upgrade to a smart protocol UPS of some kind that allows detection and proper load cycling on command\&. +.SH "AUTHOR" .sp Charles Lepple .SH "SEE ALSO" diff --git a/docs/man/nutdrv_atcl_usb.txt b/docs/man/nutdrv_atcl_usb.txt index 8443e4a..e955a01 100644 --- a/docs/man/nutdrv_atcl_usb.txt +++ b/docs/man/nutdrv_atcl_usb.txt @@ -3,24 +3,31 @@ NUTDRV_ATCL_USB(8) NAME ---- + nutdrv_atcl_usb - Driver for 'ATCL FOR UPS' equipment NOTE ---- -This man page only documents the specific features of the nutdrv_atcl_usb + +This man page only documents the specific features of the nutdrv_atcl_usb driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + This driver is for UPS hardware which identifies itself as USB idVendor 0001 and idProduct 0000, and iManufacturer +ATCL FOR UPS+. Known manufacturers -include Kanji and Plexus. The UPS interface seems to be a generic USB-to-serial -chip, and for hardware manufactured by Kanji and Plexus, the microcontroller +include Kanji and Plexus. + +The UPS interface seems to be a generic USB-to-serial chip, and for +hardware manufactured by Kanji and Plexus, the microcontroller appears to emulate a traditional contact-closure interface. This translates into only three states in ups.status: *OL*, *OB* and *OB LB* (similar to -linkman:genericups[8]), with no other dynamic status values reported. Note that -these USB identifiers (including the iManufacturer string) have also been seen -on devices that are supported by the `fuji` subdriver of linkman:nutdrv_qx[8]. +linkman:genericups[8]), with no other dynamic status values reported. + +Note that these USB identifiers (including the iManufacturer string) +have also been seen on devices that are supported by the `fuji` +subdriver of linkman:nutdrv_qx[8]. EXTRA ARGUMENTS --------------- @@ -35,23 +42,26 @@ devices, such as linkman:nutdrv_qx[8]. BUGS ---- + The UPS returns the same code for "load power is off" as for "on line power". -This condition will not be observed if the NUT master is powered by the UPS, -but may be an issue if the UPS is monitored by a remote system. +This condition will not be observed if the NUT `upsmon` in primary mode runs +on the box powered by the UPS, but may be an issue if the UPS is monitored +by a remote (secondary) system. The time between the shutdown command and removal of power seems to be fixed at 30 seconds. Ensure that the NUT shutdown script is invoked as late as possible in the shutdown procedure (in case some services take longer than others to clean up). -Most contact-closure UPSes will not power down the load if the line power -is present. This can create a race when using slave linkman:upsmon[8] systems. -See the linkman:upsmon[8] man page for more information. The solution to this -problem is to upgrade to a smart protocol UPS of some kind that allows -detection and proper load cycling on command. +Most contact-closure UPSes will not power down the load if the line power is +present. This can create a race when using secondary linkman:upsmon[8] +systems. See the linkman:upsmon[8] man page for more information. +The solution to this problem is to upgrade to a smart protocol UPS of some +kind that allows detection and proper load cycling on command. + +AUTHOR +------ -AUTHORS -------- Charles Lepple SEE ALSO @@ -59,16 +69,20 @@ SEE ALSO The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] The generic serial driver: ~~~~~~~~~~~~~~~~~~~~~~~~~~ + linkman:genericups[8] The Qx driver: ~~~~~~~~~~~~~~ + linkman:nutdrv_qx[8] (`fuji` subdriver) Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/nutdrv_qx.8 b/docs/man/nutdrv_qx.8 index 59e946f..1336d83 100644 --- a/docs/man/nutdrv_qx.8 +++ b/docs/man/nutdrv_qx.8 @@ -1,13 +1,13 @@ '\" t .\" Title: nutdrv_qx .\" Author: [see the "AUTHORS" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/09/2016 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUTDRV_QX" "8" "03/09/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUTDRV_QX" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -34,9 +34,11 @@ nutdrv_qx \- Driver for Q* protocol serial and USB based UPS equipment This man page only documents the hardware\-specific features of the \fBnutdrv_qx\fR driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. .SH "SUPPORTED HARDWARE" .sp -The \fBnutdrv_qx\fR driver is known to work with various UPSes from \fIBlazer\fR, \fIEnergy Sistem\fR, \fIFenton Technologies\fR, \fIGeneral Electric\fR, \fIMustek\fR, \fIVoltronic Power\fR (rebranded by many, many \- have I said many? \- others\&.\&. Long story short: if your UPS came with a software called \fIViewpower\fR, chances are high that it works with this driver with one of the \fIvoltronic*\fR protocols or with the \fImecer\fR one) and many others\&. +The \fBnutdrv_qx\fR driver is known to work with various UPSes from \fIArmac\fR, \fIBlazer\fR, \fIEnergy Sistem\fR, \fIFenton Technologies\fR, \fIGeneral Electric\fR, \fIHunnox\fR, \fIMasterguard\fR, \fIMustek\fR, \fIPowercool\fR, \fIVoltronic Power\fR (rebranded by many, many \- have I said many? \- others\&... .sp -The NUT compatibility table lists all the known supported models\&. Keep in mind, however, that other models not listed there may also be supported, but haven\(cqt been tested\&. +Long story short: if your UPS came with a software called \fIViewpower\fR, chances are high that it works with this driver with one of the \fIvoltronic*\fR protocols or with the \fImecer\fR one), and many others\&. +.sp +The NUT compatibility table lists all the known supported models\&. Keep in mind, however, that other models not listed there may also be supported, but haven\(cqt been tested or reported back\&. .sp All devices with a serial interface and many with a USB interface are supported\&. .SH "EXTRA ARGUMENTS" @@ -113,6 +115,8 @@ seconds (if mains meanwhile returned)\&. .RS 4 Skip autodetection of the protocol to use and only use the one specified\&. Supported values: \fIbestups\fR, +\fIhunnox\fR, +\fImasterguard\fR, \fImecer\fR, \fImegatec\fR, \fImegatec/old\fR, @@ -136,9 +140,16 @@ ones setting the (only one, or both)\&. .RE .PP -\fBpollfreq =\fR \fIvalue\fR +\fBpollfreq =\fR \fInum\fR .RS 4 -Set polling frequency, in seconds, to reduce the data flow\&. Between two polling requests the driver will do \(oqquick polls\(cq dealing just with ups\&.status\&. The default value is 30 (in seconds)\&. +Set polling interval for full updates, in seconds, to reduce the message traffic\&. Between two polling requests, the driver will do +\fIquick polls\fR +dealing just with +\fBups\&.status\fR +at an interval specified by the +\fBpollinterval\fR +driver option (details in +\fBups.conf\fR(5))\&. The default value is 30 (in seconds)\&. .RE .sp If your UPS doesn\(cqt report either \fBbattery\&.charge\fR or \fBbattery\&.runtime\fR you may want to add the following ones in order to have guesstimated values: @@ -259,6 +270,20 @@ on the UPS DB9 communication port (Per Best Power\(cqs EPS\-0059) to \fIvalue\fR [0\&.\&.6]\&. .RE +.SS "MASTERGUARD PROTOCOL" +.PP +\fBslave_addr =\fR \fIvalue\fR +.RS 4 +Make the claim function verify it\(cqs talking to the specified +\fIslave address\fR +(\fBups\&.id\fR)\&. Safeguard against talking to the wrong one of several identical UPSes on the same USB bus\&. Note that when changing +\fBups\&.id\fR +(through +\fBupsrw\fR(8)) the driver will continue to talk to the UPS with the new +\fIslave address\fR, but won\(cqt claim it again on restart until the +\fBslave_addr\fR +parameter is adjusted\&. +.RE .SS "Q1 PROTOCOL" .PP \fBondelay\fR @@ -347,7 +372,7 @@ and \fBinput\&.frequency\&.low\fR\&. .RE .sp -These UPSes can be fine\-tuned to suit your needs enabling or disabling the following options (the driver should tell you which one the UPS is capable of on startup: the settable ones will be reported either ar \fIenabled\fR or \fIdisabled\fR in the logs): +These UPSes can be fine\-tuned to suit your needs enabling or disabling the following options (the driver should tell you which one the UPS is capable of on startup: the settable ones will be reported either are \fIenabled\fR or \fIdisabled\fR in the logs): .PP \fBalarm_control =\fR \fIstring\fR .RS 4 @@ -477,7 +502,7 @@ Device grid working range for P31 UPSes [Appliance/UPS]\&. \fBTESTING\fR .RS 4 .sp -This protocol comes with a couple of functions that are not enabled by default because of the lack of knowledge of some part of the communication protocol used by these UPSes by your friendly neighborhood developer\&. Since these functions are supposed to be queries to the UPS for some kind of informations, they \fIshould\fR not make your UPS go boom\&. So if you are brave enough to risk your UPS and attached devices\*(Aq life to help the developers, this will be very appreciated\&.\&. \fBDo it at your own risk\fR\&. +This protocol comes with a couple of functions that are not enabled by default because of the lack of knowledge of some part of the communication protocol used by these UPSes by your friendly neighborhood developer\&. Since these functions are supposed to be queries to the UPS for some kind of information, they \fIshould\fR not make your UPS go boom\&. So if you are brave enough to risk your UPS and attached devices\*(Aq life to help the developers, this will be very appreciated\&.\&. \fBDo it at your own risk\fR\&. .PP \fBtesting\fR .RS 4 @@ -546,22 +571,34 @@ Examples: .PP \fBbus =\fR \fIregex\fR .RS 4 -Select a UPS on a specific USB bus or group of busses\&. The argument is a regular expression that must match the bus name where the UPS is connected (e\&.g\&. +Select a UPS on a specific USB bus or group of buses\&. The argument is a regular expression that must match the bus name where the UPS is connected (e\&.g\&. bus="002", bus="00[2\-3]")\&. .RE .PP +\fBdevice =\fR \fIregex\fR +.RS 4 +Select a UPS on a specific USB device or group of devices\&. The argument is a regular expression that must match the device name where the UPS is connected (e\&.g\&. +device="001", +device="00[1\-2]")\&. Note that device numbers are not guaranteed by the OS to be stable across re\-boots or device re\-plugging\&. +.RE +.PP \fBsubdriver =\fR \fIstring\fR .RS 4 Select a serial\-over\-USB subdriver to use\&. You have a choice between \fBcypress\fR, \fBfabula\fR, \fBfuji\fR, +\fBhunnox\fR, \fBippon\fR, \fBkrauler\fR, -\fBphoenix\fR +\fBphoenix\fR, +\fBphoenixtec\fR, +\fBsgs\fR, +\fBsnr\fR, +\fBarmac\fR and -\fBsgs\fR\&. When using this option, it is mandatory to also specify the +\fBablerex\fR\&. When using this option, it is mandatory to also specify the \fBvendorid\fR and \fBproductid\fR\&. @@ -577,6 +614,11 @@ subdriver\&. This is mandatory for some devices to work (LDLC, Dynamix and other or 0x4095), according to your device entry in NUT hardware compatibility list (HCL)\&. .RE +.PP +\fBnoscanlangid\fR +.RS 4 +If this flag is set, don\(cqt autoscan valid range for langid\&. +.RE .sp .it 1 an-trap .nr an-no-space-flag 1 @@ -586,6 +628,13 @@ or \fBIMPLEMENTATION NOTES\fR .RS 4 .PP +\fB\fIarmac\fR\fR\fB subdriver\fR +.RS 4 +The Armac communication subdriver reproduces a communication protocol used by an old release of "PowerManagerII" software, which doesn\(cqt seem to be Armac specific: its banner is "2004 Richcomm Technologies, Inc\&. Dec 27 2005 ver 1\&.1\&." Maybe other Richcomm UPSes would work with this \(em maybe better than with the older standalone +richcomm_usb +driver\&. +.RE +.PP \fB\fIfabula\fR\fR\fB subdriver\fR .RS 4 This subdriver, meant to be used with the @@ -601,6 +650,13 @@ command ignores the values set in and makes the UPS turn on the load as soon as power is back\&. .RE .PP +\fB\fIhunnox\fR\fR\fB subdriver\fR +.RS 4 +This protocol subdriver is closely related to +\fIfabula\fR +one, with a few tweaks for devices not directly supported by that driver\&. +.RE +.PP \fB\fIfuji\fR\fR\fB subdriver\fR .RS 4 This subdriver, meant to be used with the @@ -630,6 +686,19 @@ support the shutdown commands, i\&.e\&.: and \fBload\&.off\fR\&. .RE +.PP +\fB\fIsnr\fR\fR\fB subdriver\fR +.RS 4 +This subdriver, meant to be used with the +\fImegatec\fR +protocol, does +\fBnot\fR +support the shutdown commands, i\&.e\&.: +\fBshutdown\&.return\fR, +\fBshutdown\&.stayoff\fR +and +\fBload\&.off\fR\&. +.RE .RE .SH "UPS COMMANDS" .sp @@ -693,6 +762,34 @@ Perform a battery test for the duration of \fIvalue\fR seconds (truncated to 60 seconds) [60\&.\&.5940]\&. .RE +.SS "MASTERGUARD PROTOCOL" +.PP +\fBbeeper\&.enable\fR +.RS 4 +Enable the UPS beeper\&. +.RE +.PP +\fBbeeper\&.disable\fR +.RS 4 +Disable the UPS beeper\&. +.RE +.PP +\fBtest\&.battery\&.start\fR \fIvalue\fR +.RS 4 +Perform a battery test for the duration of +\fIvalue\fR +seconds (truncated to 60 seconds) [0\&.\&.5940]\&. This value is truncated to units of 6 seconds (less than 60 seconds) or 60 seconds (more than 60 seconds)\&. +.RE +.PP +\fBbypass\&.start\fR +.RS 4 +Put the UPS in bypass mode +.RE +.PP +\fBbypass\&.stop\fR +.RS 4 +Take the UPS in normal mode +.RE .sp .it 1 an-trap .nr an-no-space-flag 1 @@ -1060,6 +1157,9 @@ Both the \fBload\&.off\fR and \fBshutdown\&.stayoff\fR instant commands are mean Some models report a bogus value for the beeper status (will always be \fIenabled\fR or \fIdisabled\fR)\&. So, the \fBbeeper\&.toggle\fR command may appear to have no effect in the status reported by the driver when, in fact, it is working fine\&. .sp The temperature and load value is known to be bogus in some models\&. +.SS "MASTERGUARD UNITS" +.sp +The driver is supposed to support both "new" A series (A700/1000/2000/3000 and their \-19 cousins) and E series (E60/100/200) but was tested only on A due to lack of E hardware\&. .SS "VOLTRONIC\-QS UNITS" .sp Both \fBload\&.off\fR and \fBshutdown\&.stayoff\fR instant commands are known to work as expected (i\&.e\&. turn the load off indefinitely) only if mains is present, otherwise, as soon as mains returns the load will be powered\&. @@ -1075,9 +1175,11 @@ After issuing a \fBshutdown\&.return\fR instant command, the UPS won\(cqt wait \ .IP \(bu 2.3 .\} if the load has been previously (no matter how long before) powered off through -\fBload\&.off\fR/\fBshutdown\&.stayoff\fR\fIand\fR +\fBload\&.off\fR/\fBshutdown\&.stayoff\fR +\fIand\fR powered on through -\fBload\&.on\fR/\fBshutdown\&.stop\fR\fIand\fR +\fBload\&.on\fR/\fBshutdown\&.stop\fR +\fIand\fR .RE .sp .RS 4 @@ -1605,12 +1707,107 @@ T} .sp 1 .SH "AUTHORS" .sp -Daniele Pezzini , Arnaud Quette , John Stamp , Peter Selinger , Arjen de Korte , Alexander Gordeev +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Daniele Pezzini +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Arnaud Quette +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +John Stamp +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Peter Selinger +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Arjen de Korte +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Alexander Gordeev +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Edgar Fuß +.RE .SH "SEE ALSO" .sp \fBblazer_ser\fR(8), \fBblazer_usb\fR(8), \fBnutupsdrv\fR(8), \fBups.conf\fR(5), \fBupsc\fR(8), \fBupscmd\fR(8), \fBupsdrvctl\fR(8), \fBupsmon\fR(8), \fBupsrw\fR(8) .SS "Internet Resources:" .sp -The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The NUT (Network UPS Tools) home page: +http://www\&.networkupstools\&.org/ +.RE .sp -The NUT HCL: http://www\&.networkupstools\&.org/stable\-hcl\&.html +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The NUT HCL: +http://www\&.networkupstools\&.org/stable\-hcl\&.html +.RE diff --git a/docs/man/nutdrv_qx.txt b/docs/man/nutdrv_qx.txt index 5436131..905b561 100644 --- a/docs/man/nutdrv_qx.txt +++ b/docs/man/nutdrv_qx.txt @@ -17,12 +17,22 @@ For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ -The *nutdrv_qx* driver is known to work with various UPSes from 'Blazer', 'Energy Sistem', 'Fenton Technologies', 'General Electric', 'Mustek', 'Voltronic Power' (rebranded by many, many - have I said many? - others.. Long story short: if your UPS came with a software called 'Viewpower', chances are high that it works with this driver with one of the <<_extra_arguments,'voltronic*' protocols or with the 'mecer' one>>) and many others. +The *nutdrv_qx* driver is known to work with various UPSes from +'Armac', 'Blazer', 'Energy Sistem', 'Fenton Technologies', 'General Electric', +'Hunnox', 'Masterguard', 'Mustek', 'Powercool', 'Voltronic Power' +(rebranded by many, many - have I said many? - others... -The <<_internet_resources,NUT compatibility table>> lists all the known supported models. -Keep in mind, however, that other models not listed there may also be supported, but haven't been tested. +Long story short: if your UPS came with a software called 'Viewpower', +chances are high that it works with this driver with one of the +<<_extra_arguments,'voltronic*' protocols or with the 'mecer' one>>), +and many others. -All devices with a serial interface and many with a USB interface are supported. +The <<_internet_resources,NUT compatibility table>> lists all the known +supported models. Keep in mind, however, that other models not listed +there may also be supported, but haven't been tested or reported back. + +All devices with a serial interface and many with a USB interface are +supported. EXTRA ARGUMENTS @@ -52,13 +62,15 @@ If you set stayoff in linkman:ups.conf[5] when FSD arises the UPS will call a *s *protocol =* 'string':: Skip autodetection of the protocol to use and only use the one specified. -Supported values: 'bestups', 'mecer', 'megatec', 'megatec/old', 'mustek', 'q1', 'voltronic', 'voltronic-qs', 'voltronic-qs-hex' and 'zinto'. +Supported values: 'bestups', 'hunnox', 'masterguard', 'mecer', 'megatec', 'megatec/old', 'mustek', 'q1', 'voltronic', 'voltronic-qs', 'voltronic-qs-hex' and 'zinto'. + Note that if you end up using the 'q1' protocol, you may want to give a try to the 'mecer', 'megatec' and 'zinto' ones setting the <> (only one, or both). -*pollfreq =* 'value':: -Set polling frequency, in seconds, to reduce the data flow. -Between two polling requests the driver will do `quick polls' dealing just with ups.status. +*pollfreq =* 'num':: +Set polling interval for full updates, in seconds, to reduce the message traffic. +Between two polling requests, the driver will do 'quick polls' dealing just +with *ups.status* at an interval specified by the *pollinterval* driver option +(details in linkman:ups.conf[5]). The default value is 30 (in seconds). If your UPS doesn't report either *battery.charge* or *battery.runtime* you may want to add the following ones in order to have guesstimated values: @@ -140,7 +152,16 @@ The acceptable range is +60..599940+ seconds. The acceptable range is +12..5940+ seconds. *pins_shutdown_mode =* 'value':: -Set http://www.networkupstools.org/protocols/sola.html#_shutdown_set_command[shutdown mode functionality of Pin 1 and Pin 7] on the UPS DB9 communication port (Per Best Power’s EPS-0059) to 'value' [+0..6+]. +Set http://www.networkupstools.org/protocols/sola.html#_shutdown_set_command[shutdown mode functionality of Pin 1 and Pin 7] on the UPS DB9 communication port (Per Best Power's EPS-0059) to 'value' [+0..6+]. + + +MASTERGUARD PROTOCOL +~~~~~~~~~~~~~~~~~~~~ + +*slave_addr =* 'value':: +Make the claim function verify it's talking to the specified 'slave address' (*ups.id*). +Safeguard against talking to the wrong one of several identical UPSes on the same USB bus. +Note that when changing *ups.id* (through linkman:upsrw[8]) the driver will continue to talk to the UPS with the new 'slave address', but won't claim it again on restart until the *slave_addr* parameter is adjusted. Q1 PROTOCOL @@ -192,7 +213,7 @@ Reset capability options and their voltage and frequency limits to safe default + Note that setting this option will reset also *ups.start.auto*, *battery.protection*, *battery.energysave*, *ups.start.battery*, *outlet.0.switchable*, *input.transfer.high*, *input.transfer.low*, *input.frequency.high* and *input.frequency.low*. -These UPSes can be fine-tuned to suit your needs enabling or disabling the following options (the driver should tell you which one the UPS is capable of on startup: the settable ones will be reported either ar 'enabled' or 'disabled' in the logs): +These UPSes can be fine-tuned to suit your needs enabling or disabling the following options (the driver should tell you which one the UPS is capable of on startup: the settable ones will be reported either are 'enabled' or 'disabled' in the logs): *alarm_control =* 'string':: Enable or disable alarm (BEEP!) [+enabled+/+disabled+]. @@ -279,7 +300,7 @@ TESTING ^^^^^^^ This protocol comes with a couple of functions that are not enabled by default because of the lack of knowledge of some part of the communication protocol used by these UPSes by your friendly neighborhood developer. -Since these functions are supposed to be queries to the UPS for some kind of informations, they _should_ not make your UPS go boom. +Since these functions are supposed to be queries to the UPS for some kind of information, they _should_ not make your UPS go boom. So if you are brave enough to risk your UPS and attached devices' life to help the developers, this will be very appreciated.. *Do it at your own risk*. @@ -317,12 +338,17 @@ Examples: - `-x product=".*(Smart|Back)-?UPS.*"` *bus =* 'regex':: -Select a UPS on a specific USB bus or group of busses. +Select a UPS on a specific USB bus or group of buses. The argument is a regular expression that must match the bus name where the UPS is connected (e.g. +bus="002"+, +bus="00[2-3]"+). +*device =* 'regex':: +Select a UPS on a specific USB device or group of devices. +The argument is a regular expression that must match the device name where the UPS is connected (e.g. +device="001"+, +device="00[1-2]"+). +Note that device numbers are not guaranteed by the OS to be stable across re-boots or device re-plugging. + *subdriver =* 'string':: Select a serial-over-USB subdriver to use. -You have a choice between *cypress*, *fabula*, *fuji*, *ippon*, *krauler*, *phoenix* and *sgs*. +You have a choice between *cypress*, *fabula*, *fuji*, *hunnox*, *ippon*, *krauler*, *phoenix*, *phoenixtec*, *sgs*, *snr*, *armac* and *ablerex*. When using this option, it is mandatory to also specify the *vendorid* and *productid*. *langid_fix =* 'value':: @@ -330,14 +356,27 @@ Apply the language ID workaround to the *krauler* subdriver. This is mandatory for some devices to work (LDLC, Dynamix and others). You must provide *value* (+0x409+ or +0x4095+), according to your device entry in NUT hardware compatibility list (HCL). +*noscanlangid*:: +If this flag is set, don't autoscan valid range for langid. + IMPLEMENTATION NOTES ^^^^^^^^^^^^^^^^^^^^ +*'armac' subdriver*:: +The Armac communication subdriver reproduces a communication protocol used by +an old release of "PowerManagerII" software, which doesn't seem to be Armac +specific: its banner is "2004 Richcomm Technologies, Inc. Dec 27 2005 ver 1.1." +Maybe other Richcomm UPSes would work with this -- maybe better than with +the older standalone `richcomm_usb` driver. + *'fabula' subdriver*:: This subdriver, meant to be used with the 'megatec' protocol, does *not* support the various *test.battery* commands. Plus, the *shutdown.return* command ignores the values set in 'ups.delay.start'/*ondelay* and makes the UPS turn on the load as soon as power is back. +*'hunnox' subdriver*:: +This protocol subdriver is closely related to 'fabula' one, with a few tweaks for devices not directly supported by that driver. + *'fuji' subdriver*:: This subdriver, meant to be used with the 'megatec' protocol, does *not* support the *shutdown.stayoff* and *load.off* commands. Plus, the *shutdown.return* command ignores the values set in 'ups.delay.start'/*ondelay* and makes the UPS turn on the load as soon as power is back. @@ -345,6 +384,9 @@ Plus, the *shutdown.return* command ignores the values set in 'ups.delay.start'/ *'krauler' subdriver*:: This subdriver, meant to be used with the 'megatec' protocol, does *not* support the shutdown commands, i.e.: *shutdown.return*, *shutdown.stayoff* and *load.off*. +*'snr' subdriver*:: +This subdriver, meant to be used with the 'megatec' protocol, does *not* support the shutdown commands, i.e.: *shutdown.return*, *shutdown.stayoff* and *load.off*. + UPS COMMANDS ------------ @@ -392,6 +434,26 @@ BESTUPS, MECER, MEGATEC, MEGATEC/OLD, MUSTEK, Q1, ZINTO PROTOCOLS Perform a battery test for the duration of 'value' seconds (truncated to 60 seconds) [+60..5940+]. +MASTERGUARD PROTOCOL +~~~~~~~~~~~~~~~~~~~~ + +*beeper.enable*:: +Enable the UPS beeper. + +*beeper.disable*:: +Disable the UPS beeper. + +*test.battery.start* 'value':: +Perform a battery test for the duration of 'value' seconds (truncated to 60 seconds) [+0..5940+]. +This value is truncated to units of 6 seconds (less than 60 seconds) or 60 seconds (more than 60 seconds). + +*bypass.start*:: +Put the UPS in bypass mode + +*bypass.stop*:: +Take the UPS in normal mode + + VOLTRONIC POWER P98 UNITS (WITH MECER PROTOCOL) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -577,22 +639,22 @@ If disabled, the UPS will provide continuous power to programmable outlets until *max_eco_volt*:: -> *input.transfer.high* + Maximum voltage for ECO Mode (V). -If AC voltage is within acceptable range, ECO mode will be used (If the UPS is capable of and it’s enabled). +If AC voltage is within acceptable range, ECO mode will be used (If the UPS is capable of and it's enabled). *min_eco_volt*:: -> *input.transfer.low* + Minimum voltage for ECO Mode (V). -If AC voltage is within acceptable range, ECO mode will be used (If the UPS is capable of and it’s enabled). +If AC voltage is within acceptable range, ECO mode will be used (If the UPS is capable of and it's enabled). *max_eco_freq*:: -> *input.frequency.high* + Maximum frequency for ECO Mode (Hz). -If AC frequency is within acceptable range, ECO mode will be used (If the UPS is capable of and it’s enabled). +If AC frequency is within acceptable range, ECO mode will be used (If the UPS is capable of and it's enabled). *min_eco_freq*:: -> *input.frequency.low* + Minimum frequency for ECO Mode (Hz). -If AC frequency is within acceptable range, ECO mode will be used (If the UPS is capable of and it’s enabled). +If AC frequency is within acceptable range, ECO mode will be used (If the UPS is capable of and it's enabled). *outlet1_delay*:: -> *outlet.1.delay.shutdown* + @@ -631,6 +693,12 @@ So, the *beeper.toggle* command may appear to have no effect in the status repor The temperature and load value is known to be bogus in some models. +MASTERGUARD UNITS +~~~~~~~~~~~~~~~~~ + +The driver is supposed to support both "new" A series (A700/1000/2000/3000 and their -19 cousins) and E series (E60/100/200) but was tested only on A due to lack of E hardware. + + VOLTRONIC-QS UNITS ~~~~~~~~~~~~~~~~~~ @@ -727,12 +795,13 @@ If you want to know the explanation of that bit you can either watch the log or AUTHORS ------- -Daniele Pezzini , -Arnaud Quette , -John Stamp , -Peter Selinger , -Arjen de Korte , -Alexander Gordeev +* Daniele Pezzini +* Arnaud Quette +* John Stamp +* Peter Selinger +* Arjen de Korte +* Alexander Gordeev +* Edgar Fuß SEE ALSO @@ -752,7 +821,5 @@ linkman:upsrw[8] Internet Resources: ~~~~~~~~~~~~~~~~~~~ -The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ - -The NUT HCL: http://www.networkupstools.org/stable-hcl.html - +* The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ +* The NUT HCL: http://www.networkupstools.org/stable-hcl.html diff --git a/docs/man/nutdrv_siemens_sitop.8 b/docs/man/nutdrv_siemens_sitop.8 new file mode 100644 index 0000000..b2f5f74 --- /dev/null +++ b/docs/man/nutdrv_siemens_sitop.8 @@ -0,0 +1,269 @@ +'\" t +.\" Title: nutdrv_siemens_sitop +.\" Author: [see the "AUTHOR" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 +.\" Manual: NUT Manual +.\" Source: Network UPS Tools 2.8.0 +.\" Language: English +.\" +.TH "NUTDRV_SIEMENS_SITOP" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +nutdrv_siemens_sitop \- driver for the Siemens SITOP UPS500 series UPS +.SH "NOTE" +.sp +This man page only documents the hardware\-specific features of the \fBnutdrv_siemens_sitop\fR driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. +.SH "SUPPORTED HARDWARE" +.sp +\fBnutdrv_siemens_sitop\fR supports Siemens UPS models from the SITOP UPS500 series\&. Some models have a serial port, others have a USB port\&. The models with USB port actually contain a serial\-over\-USB chip, so as far as this driver is concerned, all models are serial models\&. This driver should work with all models in the SITOP UPS500 series, as long as your kernel has support for the serial port device (see section \fBUSB driver\fR below)\&. +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +This driver has only been tested with the SITOP UPS500S\-2\&.5 with USB port (Siemens product number 6EP1933\-2EC41)\&. +.sp .5v +.RE +.SH "DEVICE SETTINGS" +.sp +The UPS is configured via DIP\-switches\&. For correct functioning in combination with NUT, set the DIP\-switches to the following: +.PP +\fBswitch 1\-4\fR +.RS 4 +Choose whatever suits your situation\&. Any combination will work with NUT\&. +.RE +.PP +\fBswitch 5\fR (⇒ / t) +.RS 4 +Set to OFF (t)\&. This ensures that the UPS will not cut power unless NUT tells it to do so (or unless the batteries are exhausted)\&. +.RE +.PP +\fBswitch 6\-10\fR (delay) +.RS 4 +Set to OFF (minimum delay)\&. Setting a higher delay will actually also work, but any command from NUT will be delayed as well before being executed by the UPS\&. With the minimum setting, it will already take 5 seconds before a command from NUT is executed\&. +.RE +.PP +\fBswitch 11\fR (INTERR\&.) +.RS 4 +Set to ON (interrupt the output after the timer expires)\&. This ensures that the UPS briefly interrupts the output power in response to the shutdown\&.return command\&. See the section +\fBInstant Commands\fR +below\&. +.RE +.PP +\fBswitch 12\fR (ON/OFF) +.RS 4 +set to ON (enable the UPS functionality)\&. Without this, the UPS will never supply power from its batteries\&. +.RE +.SH "USB DRIVER" +.sp +The USB\-versions of the UPS contain an FTDI USB\-to\-serial converter chip\&. It is programmed with a non\-standard product ID (for example \fI0403:e0e3\fR), but can still be used with the normal ftdi_sio driver\&. +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +The following hints may be specific to GNU/Linux\&. +.sp .5v +.RE +.sp +Use \fBlsusb\fR to figure out which product ID is used in your model, and replace all occurrences of \fIe0e3\fR in the following examples with the actual Product ID\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf +modprobe ftdi_sio +echo 0403 e0e3 > /sys/bus/usb\-serial/drivers/ftdi_sio/new_id +.fi +.if n \{\ +.RE +.\} +.sp +If your system uses \fBudev\fR, this can be automated via a udev rule: +.sp +.if n \{\ +.RS 4 +.\} +.nf +ACTION=="add", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="e0e3", \e + RUN+="/sbin/modprobe ftdi_sio", \e + RUN+="/bin/sh \-c \*(Aqecho 0403 e0e3 > /sys/bus/usb\-serial/drivers/ftdi_sio/new_id\*(Aq" +.fi +.if n \{\ +.RE +.\} +.sp +You can use the following udev rule to obtain a predictable device name, for example \fI/dev/ttyUPS\fR: +.sp +.if n \{\ +.RS 4 +.\} +.nf +SUBSYSTEM=="tty" ATTRS{idVendor}=="0403", ATTRS{idProduct}=="e0e3" SYMLINK+="ttyUPS" +.fi +.if n \{\ +.RE +.\} +.SH "POLLING" +.sp +The UPS does not have a special \fIget status\fR command\&. Instead, it continuously sends out status update messages (tens of messages per second)\&. Every \fBpollinterval\fR, these messages are read from the serial port buffer\&. In order to react quickly on status changes from the UPS, and to prevent the serial buffer from overflowing, \fBpollinterval\fR should be set to a relatively low value\&. The recommended value is 1 (second)\&. +.SH "EXTRA ARGUMENTS" +.sp +This driver supports the following optional settings: +.PP +\fBmax_polls_without_data\fR=\fInum\fR +.RS 4 +The serial port is polled periodically for new data (see +\fBPolling\fR)\&. If there is no valid new data after +\fInum\fR +polls, it is assumed that communication with the UPS is lost\&. The default value is 2\&. Lower values may cause spurious +\fIData stale\fR +messages, especially at startup\&. +.RE +.SH "INSTANT COMMANDS" +.PP +\fBshutdown\&.return\fR +.RS 4 +The behavior of this command depends on the line state: +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBon line\fR: after 5 seconds (or longer, if DIP switches 6\-10 are not OFF), the UPS will shut off its output\&. After another 5 seconds, the output is activated again\&. +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBon battery\fR: after 5 seconds (or longer, if DIP switches 6\-10 are not OFF), the UPS will shut off its output\&. The output will stay off, until the line voltage has returned\&. +.RE +.RE +.PP +\fBshutdown\&.stayoff\fR +.RS 4 +The behavior of this command depends on the line state: +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBon line\fR: after 5 seconds (or longer, if DIP switches 6\-10 are not OFF), the UPS will shut off its output\&. The output stays off, until the line voltage has been removed for at least 1 second, and has been re\-applied\&. +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBon battery\fR: this command behaves the same as +\fBshutdown\&.return\fR\&. +.RE +.RE +.SH "INSTALLATION" +.sp +Make sure that your operating system has created a serial device for the UPS\&. See the section \fBUSB driver\fR for more information\&. +.sp +Next, make sure that NUT has access rights to this device file\&. For example, by creating a udev rule that grants permission to the NUT user, or by adding the NUT user to a user group that can access serial devices (e\&.g\&. the \fBdialout\fR group on Debian\-based systems)\&. +.SH "DIAGNOSTICS" +.sp +You can verify the correct functioning of the hardware, by monitoring the serial port with a terminal program, for example picocom: +.sp +.if n \{\ +.RS 4 +.\} +.nf +picocom \-b 9600 \-d 8 \-p n /dev/ttyUPS +.fi +.if n \{\ +.RE +.\} +.sp +NUT must not be running when you do this\&. You should now see a continuous stream of 5\-character texts coming in, for example: +.sp +.if n \{\ +.RS 4 +.\} +.nf +BUFRD +BA>85 +DC_OK +.fi +.if n \{\ +.RE +.\} +.sp +To exit picocom, use Ctrl\-A Ctrl\-X\&. +.SH "KNOWN ISSUES AND BUGS" +.PP +\fBUntested models\fR +.RS 4 +As mentioned under +\fBSupported hardware\fR, this driver has not been tested with all models in the SITOP UPS500 series\&. +.RE +.PP +\fBData stale messages\fR +.RS 4 +The firmware in these UPSes is quite buggy\&. After sending data to the UPS, it sometimes stops sending status updates\&. This driver tries to prevent this (e\&.g\&. by sending commands twice, and by sending additional LF characters after each command)\&. Once the UPS is in this state, communication can only be restored by rebooting the UPS, or by unplugging and reconnecting the USB cable\&. During normal operation, no commands are sent to the UPS at all (only at shutdown), so this issue is expected to have little impact on usability\&. It is not sure if the serial models are affected by this issue as well\&. +.RE +.SH "AUTHOR" +.sp +Matthijs H\&. ten Berge +.SH "SEE ALSO" +.SS "The core driver:" +.sp +\fBnutupsdrv\fR(8) +.SS "Internet resources:" +.sp +The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/nutdrv_siemens_sitop.txt b/docs/man/nutdrv_siemens_sitop.txt new file mode 100644 index 0000000..193f99d --- /dev/null +++ b/docs/man/nutdrv_siemens_sitop.txt @@ -0,0 +1,201 @@ +NUTDRV_SIEMENS_SITOP(8) +======================= + +NAME +---- + +nutdrv_siemens_sitop - driver for the Siemens SITOP UPS500 series UPS + +NOTE +---- + +This man page only documents the hardware-specific features of the +*nutdrv_siemens_sitop* driver. For information about the core driver, see +linkman:nutupsdrv[8]. + +SUPPORTED HARDWARE +------------------ + +*nutdrv_siemens_sitop* supports Siemens UPS models from the SITOP UPS500 series. +Some models have a serial port, others have a USB port. +The models with USB port actually contain a serial-over-USB chip, +so as far as this driver is concerned, all models are serial models. +This driver should work with all models in the SITOP UPS500 series, +as long as your kernel has support for the serial port device +(see section *USB driver* below). + +NOTE: This driver has only been tested with the SITOP UPS500S-2.5 +with USB port (Siemens product number 6EP1933-2EC41). + +DEVICE SETTINGS +--------------- + +The UPS is configured via DIP-switches. +For correct functioning in combination with NUT, set the DIP-switches +to the following: + +*switch 1-4*:: +Choose whatever suits your situation. Any combination will work with NUT. + +*switch 5* (=> / t):: +Set to OFF (t). This ensures that the UPS will not cut power unless NUT +tells it to do so (or unless the batteries are exhausted). + +*switch 6-10* (delay):: +Set to OFF (minimum delay). Setting a higher delay will actually also work, +but any command from NUT will be delayed as well before being executed +by the UPS. With the minimum setting, it will already take 5 seconds +before a command from NUT is executed. + +*switch 11* (INTERR.):: +Set to ON (interrupt the output after the timer expires). This ensures that +the UPS briefly interrupts the output power in response to the shutdown.return +command. See the section *Instant Commands* below. + +*switch 12* (ON/OFF):: +set to ON (enable the UPS functionality). Without this, the UPS will never +supply power from its batteries. + +USB driver +---------- + +The USB-versions of the UPS contain an FTDI USB-to-serial converter chip. +It is programmed with a non-standard product ID (for example _0403:e0e3_), +but can still be used with the normal ftdi_sio driver. + +NOTE: The following hints may be specific to GNU/Linux. + +Use *lsusb* to figure out which product ID is used in your model, and +replace all occurrences of _e0e3_ in the following examples with the actual +Product ID. + +.... +modprobe ftdi_sio +echo 0403 e0e3 > /sys/bus/usb-serial/drivers/ftdi_sio/new_id +.... + +If your system uses *udev*, this can be automated via a udev rule: + +---- +ACTION=="add", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="e0e3", \ + RUN+="/sbin/modprobe ftdi_sio", \ + RUN+="/bin/sh -c 'echo 0403 e0e3 > /sys/bus/usb-serial/drivers/ftdi_sio/new_id'" +---- + +You can use the following udev rule to obtain a predictable device name, +for example _/dev/ttyUPS_: +---- +SUBSYSTEM=="tty" ATTRS{idVendor}=="0403", ATTRS{idProduct}=="e0e3" SYMLINK+="ttyUPS" +---- + +POLLING +------- + +The UPS does not have a special 'get status' command. Instead, it continuously +sends out status update messages (tens of messages per second). +Every *pollinterval*, these messages are read from the serial port buffer. +In order to react quickly on status changes from the UPS, and to prevent the serial buffer +from overflowing, *pollinterval* should be set to a relatively low value. The recommended +value is 1 (second). + +EXTRA ARGUMENTS +--------------- + +This driver supports the following optional settings: + +*max_polls_without_data*='num':: +The serial port is polled periodically for new data (see *Polling*). +If there is no valid new data after 'num' polls, it is assumed that communication +with the UPS is lost. +The default value is 2. Lower values may cause spurious 'Data stale' messages, +especially at startup. + +INSTANT COMMANDS +---------------- + +*shutdown.return*:: +The behavior of this command depends on the line state: + +* *on line*: after 5 seconds (or longer, if DIP switches 6-10 are not OFF), +the UPS will shut off its output. After another 5 seconds, the output is +activated again. +* *on battery*: after 5 seconds (or longer, if DIP switches 6-10 are not OFF), +the UPS will shut off its output. The output will stay off, until the +line voltage has returned. + +*shutdown.stayoff*:: +The behavior of this command depends on the line state: + +* *on line*: after 5 seconds (or longer, if DIP switches 6-10 are not OFF), +the UPS will shut off its output. The output stays off, until the line voltage +has been removed for at least 1 second, and has been re-applied. +* *on battery*: this command behaves the same as *shutdown.return*. + +INSTALLATION +------------ + +Make sure that your operating system has created a serial device for the UPS. +See the section *USB driver* for more information. + +Next, make sure that NUT has access rights to this device file. +For example, by creating a udev rule that grants permission to the NUT user, +or by adding the NUT user to a user group that can access serial devices +(e.g. the *dialout* group on Debian-based systems). + +DIAGNOSTICS +----------- + +You can verify the correct functioning of the hardware, by monitoring the +serial port with a terminal program, for example picocom: + +.... +picocom -b 9600 -d 8 -p n /dev/ttyUPS +.... + +NUT must not be running when you do this. +You should now see a continuous stream of 5-character texts coming in, +for example: + +.... +BUFRD +BA>85 +DC_OK +.... +To exit picocom, use Ctrl-A Ctrl-X. + +KNOWN ISSUES AND BUGS +--------------------- + +*Untested models*:: +As mentioned under *Supported hardware*, this driver has not been tested +with all models in the SITOP UPS500 series. + +*Data stale messages*:: +The firmware in these UPSes is quite buggy. After sending data to the UPS, +it sometimes stops sending status updates. This driver tries to prevent this +(e.g. by sending commands twice, and by sending additional LF characters after +each command). +Once the UPS is in this state, communication can only be restored by rebooting +the UPS, or by unplugging and reconnecting the USB cable. +During normal operation, no commands are sent to the UPS at all +(only at shutdown), so this issue is expected to have little impact on +usability. +It is not sure if the serial models are affected by this issue as well. + +AUTHOR +------ + +Matthijs H. ten Berge + +SEE ALSO +-------- + +The core driver: +~~~~~~~~~~~~~~~~ + +linkman:nutupsdrv[8] + +Internet resources: +~~~~~~~~~~~~~~~~~~~ + +The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/nutscan.3 b/docs/man/nutscan.3 index 6b93089..22c4df4 100644 --- a/docs/man/nutscan.3 +++ b/docs/man/nutscan.3 @@ -1,13 +1,13 @@ '\" t .\" Title: nutscan -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUTSCAN" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUTSCAN" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -33,7 +33,7 @@ nutscan \- Network UPS Tools (NUT) device discovery library .sp The Network UPS Tools (NUT) \fBnutscan\fR library provides the same discovery related features that are also offered by \fBnut-scanner\fR(8)\&. .sp -It enables the discovery of supported NUT devices (USB, SNMP, Eaton XML/HTTP and IPMI) and NUT servers (using Avahi, or the classic connection method)\&. +It enables the discovery of supported NUT devices (USB, SNMP, Eaton XML/HTTP and IPMI) and NUT servers (either using Avahi, or the classic connection method)\&. .SH "DISCOVERY FUNCTIONS" .sp First, include the required header file: @@ -82,7 +82,7 @@ for supported SNMP agents, .sp -1 .IP \(bu 2.3 .\} -\fBnutscan_scan_xml_http\fR(3) +\fBnutscan_scan_xml_http_range\fR(3) for Eaton Network Management Card, .RE .sp @@ -95,7 +95,7 @@ for Eaton Network Management Card, .IP \(bu 2.3 .\} \fBnutscan_scan_nut\fR(3) -for NUT servers (upsd), using the classic method, +for NUT servers (upsd), using the classic method (search for port), .RE .sp .RS 4 @@ -154,4 +154,7 @@ for ups\&.conf style\&. There is currently no specific mechanism for error handling\&. .SH "SEE ALSO" .sp -\fBnut-scanner\fR(8), \fBnutscan_scan_usb\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_scan_xml_http\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_device_to_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_cidr_to_ip\fR(3), http://avahi\&.org/ +\fBnut-scanner\fR(8), \fBnutscan_scan_usb\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_scan_xml_http_range\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_device_to_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_cidr_to_ip\fR(3) +.SS "Internet resources:" +.sp +http://avahi\&.org/ diff --git a/docs/man/nutscan.txt b/docs/man/nutscan.txt index 90ac366..99cb247 100644 --- a/docs/man/nutscan.txt +++ b/docs/man/nutscan.txt @@ -13,7 +13,8 @@ The Network UPS Tools (NUT) *nutscan* library provides the same discovery related features that are also offered by linkman:nut-scanner[8]. It enables the discovery of supported NUT devices (USB, SNMP, Eaton XML/HTTP -and IPMI) and NUT servers (using Avahi, or the classic connection method). +and IPMI) and NUT servers (either using Avahi, or the classic connection +method). DISCOVERY FUNCTIONS @@ -27,14 +28,17 @@ Then, to discover new devices, use the appropriate function: - linkman:nutscan_scan_usb[3] for supported USB devices, - linkman:nutscan_scan_snmp[3] for supported SNMP agents, -- linkman:nutscan_scan_xml_http[3] for Eaton Network Management Card, -- linkman:nutscan_scan_nut[3] for NUT servers (upsd), using the classic method, -- linkman:nutscan_scan_avahi[3] for NUT servers (upsd), using the mDNS (Avahi) method, +- linkman:nutscan_scan_xml_http_range[3] for Eaton Network Management Card, +- linkman:nutscan_scan_nut[3] for NUT servers (upsd), using the classic + method (search for port), +- linkman:nutscan_scan_avahi[3] for NUT servers (upsd), using the mDNS + (Avahi) method, - linkman:nutscan_scan_ipmi[3] for supported IPMI PSU. -All of these functions return a list of devices found, using the nutscan_device_t -structure. This structure is described in linkman:nutscan_add_device_to_device[3]. +All of these functions return a list of devices found, using the +`nutscan_device_t` structure. This structure is described in +linkman:nutscan_add_device_to_device[3]. Helper functions are also provided to output data using standard formats: @@ -44,17 +48,24 @@ Helper functions are also provided to output data using standard formats: ERROR HANDLING -------------- + There is currently no specific mechanism for error handling. SEE ALSO -------- + linkman:nut-scanner[8], linkman:nutscan_scan_usb[3], linkman:nutscan_scan_snmp[3], -linkman:nutscan_scan_xml_http[3], linkman:nutscan_scan_nut[3], +linkman:nutscan_scan_xml_http_range[3], linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], linkman:nutscan_scan_ipmi[3], linkman:nutscan_display_parsable[3], linkman:nutscan_display_ups_conf[3], linkman:nutscan_new_device[3], linkman:nutscan_free_device[3], -linkman:nutscan_add_device_to_device[3], linkman:nutscan_add_option_to_device[3], -linkman:nutscan_cidr_to_ip[3], +linkman:nutscan_add_device_to_device[3], +linkman:nutscan_add_option_to_device[3], +linkman:nutscan_cidr_to_ip[3] + +Internet resources: +~~~~~~~~~~~~~~~~~~~ + http://avahi.org/ diff --git a/docs/man/nutscan_add_device_to_device.3 b/docs/man/nutscan_add_device_to_device.3 index 5f51677..d571750 100644 --- a/docs/man/nutscan_add_device_to_device.3 +++ b/docs/man/nutscan_add_device_to_device.3 @@ -1,13 +1,13 @@ '\" t .\" Title: nutscan_add_device_to_device -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUTSCAN_ADD_DEVICE_T" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUTSCAN_ADD_DEVICE_T" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -36,7 +36,9 @@ nutscan_add_device_to_device \- Concatenate two devices structure\&. .fi .sp .nf -nutscan_device_t * nutscan_add_device_to_device(nutscan_device_t * first, nutscan_device_t * second); +nutscan_device_t * nutscan_add_device_to_device( + nutscan_device_t * first, + nutscan_device_t * second); .fi .SH "DESCRIPTION" .sp @@ -59,10 +61,13 @@ struct nutscan_device * next; .sp This is a double linked list of device\&. Each device is described by its type, its driver name, its port and any number of optional data\&. .sp -The \fBnutscan_add_device_to_device()\fR concatenates \fIfirst\fR and \fIsecond\fR devices to a unique device\&. No new device is created, the two linked list are simply linked to each other\&. So \fIfirst\fR and \fIsecond\fR devices are likely to be modified by this function\&. +The \fBnutscan_add_device_to_device()\fR concatenates \fIfirst\fR and \fIsecond\fR devices to a unique device\&. No new device is created, the two linked lists are simply linked to each other\&. So \fIfirst\fR and \fIsecond\fR devices are likely to be modified by this function\&. .SH "RETURN VALUE" .sp -The \fBnutscan_add_device_to_device()\fR functions returns a pointer to a device containg both passed devices\&. Note that it\(cqs not a new device, so it is either \fIfirst\fR or \fIsecond\fR which is returned\&. +The \fBnutscan_add_device_to_device()\fR functions returns a pointer to a device containing both passed devices\&. Note that it\(cqs not a new device, so it is either \fIfirst\fR or \fIsecond\fR which is returned\&. +.SH "NOTES" +.sp +Technically, the function is currently defined in \fInutscan\-device\&.h\fR file\&. .SH "SEE ALSO" .sp -\fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3) +\fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http_range\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3) diff --git a/docs/man/nutscan_add_device_to_device.txt b/docs/man/nutscan_add_device_to_device.txt index 7ccc3c8..6f5aed6 100644 --- a/docs/man/nutscan_add_device_to_device.txt +++ b/docs/man/nutscan_add_device_to_device.txt @@ -11,7 +11,9 @@ SYNOPSIS #include - nutscan_device_t * nutscan_add_device_to_device(nutscan_device_t * first, nutscan_device_t * second); + nutscan_device_t * nutscan_add_device_to_device( + nutscan_device_t * first, + nutscan_device_t * second); DESCRIPTION @@ -20,25 +22,37 @@ DESCRIPTION The `nutscan_device_t` contains the following variables: nutscan_device_type_t type; - char * driver; - char * port; - nutscan_options_t opt; - struct nutscan_device * prev; - struct nutscan_device * next; + char * driver; + char * port; + nutscan_options_t opt; + struct nutscan_device * prev; + struct nutscan_device * next; -This is a double linked list of device. Each device is described by its `type`, its `driver` name, its `port` and any number of optional data. +This is a double linked list of device. Each device is described by its +`type`, its `driver` name, its `port` and any number of optional data. -The *nutscan_add_device_to_device()* concatenates 'first' and 'second' devices to a unique device. No new device is created, the two linked list are simply linked to each other. So 'first' and 'second' devices are likely to be modified by this function. +The *nutscan_add_device_to_device()* concatenates 'first' and 'second' +devices to a unique device. No new device is created, the two linked +lists are simply linked to each other. So 'first' and 'second' devices +are likely to be modified by this function. RETURN VALUE ------------ -The *nutscan_add_device_to_device()* functions returns a pointer to a device containg both passed devices. Note that it's not a new device, so it is either 'first' or 'second' which is returned. +The *nutscan_add_device_to_device()* functions returns a pointer to a +device containing both passed devices. Note that it's not a new device, +so it is either 'first' or 'second' which is returned. + +NOTES +----- + +Technically, the function is currently defined in 'nutscan-device.h' file. SEE ALSO -------- -linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http[3], -linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], + +linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http_range[3], +linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], linkman:nutscan_scan_ipmi[3], linkman:nutscan_scan_snmp[3], linkman:nutscan_display_ups_conf[3], linkman:nutscan_display_parsable[3], linkman:nutscan_new_device[3], linkman:nutscan_free_device[3], diff --git a/docs/man/nutscan_add_option_to_device.3 b/docs/man/nutscan_add_option_to_device.3 index 3db6a23..8599526 100644 --- a/docs/man/nutscan_add_option_to_device.3 +++ b/docs/man/nutscan_add_option_to_device.3 @@ -1,13 +1,13 @@ '\" t .\" Title: nutscan_add_option_to_device -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUTSCAN_ADD_OPTION_T" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUTSCAN_ADD_OPTION_T" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -36,7 +36,10 @@ nutscan_add_option_to_device \- Add option data to the specified device\&. .fi .sp .nf -void nutscan_add_option_to_device(nutscan_device_t * device,char * option_name, char * value); +void nutscan_add_option_to_device( + nutscan_device_t * device, + char * option_name, + char * value); .fi .SH "DESCRIPTION" .sp @@ -59,7 +62,10 @@ struct nutscan_device * next; .sp This is a double linked list of device\&. Each device is described by its type, its driver name, its port and any number of optional data\&. .sp -The \fBnutscan_add_option_to_device()\fR adds an optional data in the given devcie\&. Optional data are made of an \fIoption_name\fR and an associated \fIvalue\fR\&. Copies of \fIoption_name\fR and \fIvalue\fR are stored in the device, so the caller can safely free both of them\&. +The \fBnutscan_add_option_to_device()\fR adds an optional data in the given device\&. Optional data are made of an \fIoption_name\fR and an associated \fIvalue\fR\&. Copies of \fIoption_name\fR and \fIvalue\fR are stored in the device, so the caller can safely free both of the original strings used as arguments\&. +.SH "NOTES" +.sp +Technically, the function is currently defined in \fInutscan\-device\&.h\fR file\&. .SH "SEE ALSO" .sp -\fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_device_to_device\fR(3) +\fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http_range\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_device_to_device\fR(3) diff --git a/docs/man/nutscan_add_option_to_device.txt b/docs/man/nutscan_add_option_to_device.txt index 636f056..2dbf669 100644 --- a/docs/man/nutscan_add_option_to_device.txt +++ b/docs/man/nutscan_add_option_to_device.txt @@ -11,7 +11,10 @@ SYNOPSIS #include - void nutscan_add_option_to_device(nutscan_device_t * device,char * option_name, char * value); + void nutscan_add_option_to_device( + nutscan_device_t * device, + char * option_name, + char * value); DESCRIPTION @@ -20,20 +23,31 @@ DESCRIPTION The `nutscan_device_t` contains the following variables: nutscan_device_type_t type; - char * driver; - char * port; - nutscan_options_t opt; - struct nutscan_device * prev; - struct nutscan_device * next; + char * driver; + char * port; + nutscan_options_t opt; + struct nutscan_device * prev; + struct nutscan_device * next; -This is a double linked list of device. Each device is described by its `type`, its `driver` name, its `port` and any number of optional data. +This is a double linked list of device. Each device is described by +its `type`, its `driver` name, its `port` and any number of optional data. -The *nutscan_add_option_to_device()* adds an optional data in the given devcie. Optional data are made of an 'option_name' and an associated 'value'. Copies of 'option_name' and 'value' are stored in the device, so the caller can safely free both of them. +The *nutscan_add_option_to_device()* adds an optional data in the +given device. Optional data are made of an 'option_name' and an +associated 'value'. Copies of 'option_name' and 'value' are stored +in the device, so the caller can safely free both of the original +strings used as arguments. + +NOTES +----- + +Technically, the function is currently defined in 'nutscan-device.h' file. SEE ALSO -------- -linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http[3], -linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], + +linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http_range[3], +linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], linkman:nutscan_scan_ipmi[3], linkman:nutscan_scan_snmp[3], linkman:nutscan_display_ups_conf[3], linkman:nutscan_display_parsable[3], linkman:nutscan_new_device[3], linkman:nutscan_free_device[3], diff --git a/docs/man/nutscan_cidr_to_ip.3 b/docs/man/nutscan_cidr_to_ip.3 index c9f68c5..c572999 100644 --- a/docs/man/nutscan_cidr_to_ip.3 +++ b/docs/man/nutscan_cidr_to_ip.3 @@ -1,13 +1,13 @@ '\" t .\" Title: nutscan_cidr_to_ip -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUTSCAN_CIDR_TO_IP" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUTSCAN_CIDR_TO_IP" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -40,10 +40,15 @@ int nutscan_cidr_to_ip(const char * cidr, char ** start_ip, char ** stop_ip); .fi .SH "DESCRIPTION" .sp -The \fBnutscan_cidr_to_ip()\fR function converts a range of IP address in the CIDR format given as a string in \fIcidr\fR, to two IPs in strings pointed by \fIstart_ip\fR and \fIstop_ip\fR which can be used as input paramters in the scanning functions of the libnutscan API\&. It is the caller\(cqs responsability to free \fIstart_ip\fR and \fIstop_ip\fR strings\&. +The \fBnutscan_cidr_to_ip()\fR function converts a range of IP address in the CIDR format given as a string in \fIcidr\fR, to two IPs in strings pointed by \fIstart_ip\fR and \fIstop_ip\fR which can be used as input parameters in the scanning functions of the libnutscan API\&. +.sp +It is the caller\(cqs responsibility to free \fIstart_ip\fR and \fIstop_ip\fR strings\&. .SH "RETURN VALUE" .sp -The \fBnutscan_cidr_to_ip()\fR function returns 0 if an error occured (invalid \fIcidr\fR address) or 1 if successful\&. +The \fBnutscan_cidr_to_ip()\fR function returns 0 if an error occurred (invalid \fIcidr\fR address) or 1 if successful\&. +.SH "NOTES" +.sp +Technically, the function is currently defined in \fInutscan\-ip\&.h\fR file\&. .SH "SEE ALSO" .sp -\fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_display_ups_conf\fR(3) +\fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http_range\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_display_ups_conf\fR(3) diff --git a/docs/man/nutscan_cidr_to_ip.txt b/docs/man/nutscan_cidr_to_ip.txt index 6ebe237..5f18213 100644 --- a/docs/man/nutscan_cidr_to_ip.txt +++ b/docs/man/nutscan_cidr_to_ip.txt @@ -16,16 +16,28 @@ SYNOPSIS DESCRIPTION ----------- -The *nutscan_cidr_to_ip()* function converts a range of IP address in the CIDR format given as a string in 'cidr', to two IPs in strings pointed by 'start_ip' and 'stop_ip' which can be used as input paramters in the scanning functions of the libnutscan API. It is the caller's responsability to free 'start_ip' and 'stop_ip' strings. +The *nutscan_cidr_to_ip()* function converts a range of IP address in +the CIDR format given as a string in 'cidr', to two IPs in strings +pointed by 'start_ip' and 'stop_ip' which can be used as input +parameters in the scanning functions of the libnutscan API. + +It is the caller's responsibility to free 'start_ip' and 'stop_ip' strings. RETURN VALUE ------------ -The *nutscan_cidr_to_ip()* function returns 0 if an error occured (invalid 'cidr' address) or 1 if successful. +The *nutscan_cidr_to_ip()* function returns 0 if an error occurred +(invalid 'cidr' address) or 1 if successful. + +NOTES +----- + +Technically, the function is currently defined in 'nutscan-ip.h' file. SEE ALSO -------- -linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http[3], -linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], -linkman:nutscan_scan_ipmi[3], linkman:nutscan_scan_snmp[3], + +linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http_range[3], +linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], +linkman:nutscan_scan_ipmi[3], linkman:nutscan_scan_snmp[3], linkman:nutscan_display_parsable[3], linkman:nutscan_display_ups_conf[3] diff --git a/docs/man/nutscan_display_parsable.3 b/docs/man/nutscan_display_parsable.3 index 33f7ec9..3df0739 100644 --- a/docs/man/nutscan_display_parsable.3 +++ b/docs/man/nutscan_display_parsable.3 @@ -1,13 +1,13 @@ '\" t .\" Title: nutscan_display_parsable -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUTSCAN_DISPLAY_PARS" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUTSCAN_DISPLAY_PARS" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -42,9 +42,48 @@ void nutscan_display_parsable(nutscan_device_t * device); .sp The \fBnutscan_display_parsable()\fR function displays all NUT devices in \fIdevice\fR to stdout\&. It displays them in a way that can be easily parsed which is: .sp -:driver="",port=""[,="",="",\&...] +.if n \{\ +.RS 4 +.\} +.nf +:driver="",port=""[,="",="",\&.\&.\&.] +.fi +.if n \{\ +.RE +.\} .sp - may be one of USB, SNMP, XML, NUT, IPMI or AVAHI\&. is the name of the driver\(cqs binary corresponding to this device\&. and depend on , see the corresponding driver\(cqs man page\&. +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} + may be one of USB, SNMP, XML, NUT, IPMI or AVAHI\&. +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} + is the name of the driver\(cqs binary corresponding to this device\&. +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} + and depend on , see the corresponding driver\(cqs man page\&. +.RE .SH "SEE ALSO" .sp -\fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_add_device_to_device\fR(3), \fBnutscan_cidr_to_ip\fR(3) +\fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http_range\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_add_device_to_device\fR(3), \fBnutscan_cidr_to_ip\fR(3) diff --git a/docs/man/nutscan_display_parsable.txt b/docs/man/nutscan_display_parsable.txt index 7379d65..9e27515 100644 --- a/docs/man/nutscan_display_parsable.txt +++ b/docs/man/nutscan_display_parsable.txt @@ -4,7 +4,8 @@ NUTSCAN_DISPLAY_PARSABLE(3) NAME ---- -nutscan_display_parsable - Display the specified `nutscan_device_t` structure on stdout. +nutscan_display_parsable - Display the specified `nutscan_device_t` +structure on stdout. SYNOPSIS -------- @@ -16,19 +17,24 @@ SYNOPSIS DESCRIPTION ----------- -The *nutscan_display_parsable()* function displays all NUT devices in 'device' to stdout. It displays them in a way that can be easily parsed which is: +The *nutscan_display_parsable()* function displays all NUT devices in +'device' to stdout. It displays them in a way that can be easily parsed +which is: -:driver="",port=""[,="",="",...] + :driver="",port=""[,="",="",...] - may be one of USB, SNMP, XML, NUT, IPMI or AVAHI. - is the name of the driver's binary corresponding to this device. - and depend on , see the corresponding driver's man page. +* may be one of USB, SNMP, XML, NUT, IPMI or AVAHI. +* is the name of the driver's binary corresponding + to this device. +* and depend on , + see the corresponding driver's man page. SEE ALSO -------- -linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http[3], -linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], -linkman:nutscan_scan_ipmi[3], linkman:nutscan_scan_snmp[3], + +linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http_range[3], +linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], +linkman:nutscan_scan_ipmi[3], linkman:nutscan_scan_snmp[3], linkman:nutscan_display_ups_conf[3], linkman:nutscan_new_device[3], linkman:nutscan_free_device[3], linkman:nutscan_add_option_to_device[3], linkman:nutscan_add_device_to_device[3], linkman:nutscan_cidr_to_ip[3] diff --git a/docs/man/nutscan_display_ups_conf.3 b/docs/man/nutscan_display_ups_conf.3 index 0b1c6d5..955d042 100644 --- a/docs/man/nutscan_display_ups_conf.3 +++ b/docs/man/nutscan_display_ups_conf.3 @@ -1,13 +1,13 @@ '\" t .\" Title: nutscan_display_ups_conf -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUTSCAN_DISPLAY_UPS_" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUTSCAN_DISPLAY_UPS_" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -40,7 +40,7 @@ void nutscan_display_ups_conf(nutscan_device_t * device); .fi .SH "DESCRIPTION" .sp -The \fBnutscan_display_ups_conf()\fR function displays all NUT devices in \fIdevice\fR to stdout\&. It displays them in a way that it can be directly copied into the ups\&.conf file\&. +The \fBnutscan_display_ups_conf()\fR function displays all NUT devices in \fIdevice\fR to stdout\&. It displays them in a way that it can be directly copied into the \fIups\&.conf\fR file\&. .SH "SEE ALSO" .sp -\fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_add_device_to_device\fR(3), \fBnutscan_cidr_to_ip\fR(3) +\fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http_range\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_add_device_to_device\fR(3), \fBnutscan_cidr_to_ip\fR(3) diff --git a/docs/man/nutscan_display_ups_conf.txt b/docs/man/nutscan_display_ups_conf.txt index 8d95e07..b79c90f 100644 --- a/docs/man/nutscan_display_ups_conf.txt +++ b/docs/man/nutscan_display_ups_conf.txt @@ -4,7 +4,8 @@ NUTSCAN_DISPLAY_UPS_CONF(3) NAME ---- -nutscan_display_ups_conf - Display the specified `nutscan_device_t` structure on stdout. +nutscan_display_ups_conf - Display the specified `nutscan_device_t` +structure on stdout. SYNOPSIS -------- @@ -16,13 +17,16 @@ SYNOPSIS DESCRIPTION ----------- -The *nutscan_display_ups_conf()* function displays all NUT devices in 'device' to stdout. It displays them in a way that it can be directly copied into the ups.conf file. +The *nutscan_display_ups_conf()* function displays all NUT devices in +'device' to stdout. It displays them in a way that it can be directly +copied into the 'ups.conf' file. SEE ALSO -------- -linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http[3], -linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], -linkman:nutscan_scan_ipmi[3], linkman:nutscan_scan_snmp[3], + +linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http_range[3], +linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], +linkman:nutscan_scan_ipmi[3], linkman:nutscan_scan_snmp[3], linkman:nutscan_display_parsable[3], linkman:nutscan_new_device[3], linkman:nutscan_free_device[3], linkman:nutscan_add_option_to_device[3], linkman:nutscan_add_device_to_device[3], linkman:nutscan_cidr_to_ip[3] diff --git a/docs/man/nutscan_free_device.3 b/docs/man/nutscan_free_device.3 index af13c90..6c13797 100644 --- a/docs/man/nutscan_free_device.3 +++ b/docs/man/nutscan_free_device.3 @@ -1,13 +1,13 @@ '\" t .\" Title: nutscan_free_device -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUTSCAN_FREE_DEVICE" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUTSCAN_FREE_DEVICE" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -28,7 +28,7 @@ .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" -nutscan_free_device \- Free a nutscan_device_t structure created by nutscan_new_device\&. +nutscan_free_device \- Free a `nutscan_device_t` structure created by `nutscan_new_device`\&. .SH "SYNOPSIS" .sp .nf @@ -40,7 +40,10 @@ void nutscan_free_device(nutscan_device_t * device); .fi .SH "DESCRIPTION" .sp -The \fBnutscan_free_device()\fR function free a nutscan_device_type_t structure\&. Doing so, it free the whole linked list, not only the given device\&. +The \fBnutscan_free_device()\fR function can free a nutscan_device_type_t structure\&. Doing so, it frees the whole linked list, not only the given device\&. +.SH "NOTES" +.sp +Technically, the function is currently defined in \fInutscan\-device\&.h\fR file\&. .SH "SEE ALSO" .sp -\fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_add_device_to_device\fR(3) +\fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http_range\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_add_device_to_device\fR(3) diff --git a/docs/man/nutscan_free_device.txt b/docs/man/nutscan_free_device.txt index 062bb4b..4420f36 100644 --- a/docs/man/nutscan_free_device.txt +++ b/docs/man/nutscan_free_device.txt @@ -4,7 +4,8 @@ NUTSCAN_FREE_DEVICE(3) NAME ---- -nutscan_free_device - Free a nutscan_device_t structure created by nutscan_new_device. +nutscan_free_device - Free a `nutscan_device_t` structure created by +`nutscan_new_device`. SYNOPSIS -------- @@ -16,12 +17,20 @@ SYNOPSIS DESCRIPTION ----------- -The *nutscan_free_device()* function free a `nutscan_device_type_t` structure. Doing so, it free the whole linked list, not only the given device. +The *nutscan_free_device()* function can free a `nutscan_device_type_t` +structure. Doing so, it frees the whole linked list, not only the given +device. + +NOTES +----- + +Technically, the function is currently defined in 'nutscan-device.h' file. SEE ALSO -------- -linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http[3], -linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], + +linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http_range[3], +linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], linkman:nutscan_scan_ipmi[3], linkman:nutscan_scan_snmp[3], linkman:nutscan_display_ups_conf[3], linkman:nutscan_display_parsable[3], linkman:nutscan_new_device[3], linkman:nutscan_add_option_to_device[3], diff --git a/docs/man/nutscan_get_serial_ports_list.3 b/docs/man/nutscan_get_serial_ports_list.3 index 12fb92c..9758534 100644 --- a/docs/man/nutscan_get_serial_ports_list.3 +++ b/docs/man/nutscan_get_serial_ports_list.3 @@ -1,13 +1,13 @@ '\" t .\" Title: nutscan_get_serial_ports_list -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUTSCAN_GET_SERIAL_P" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUTSCAN_GET_SERIAL_P" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -40,7 +40,7 @@ char ** nutscan_get_serial_ports_list(const char *ports_range); .fi .SH "DESCRIPTION" .sp -The \fBnutscan_get_serial_ports_list()\fR function returns a null terminated array of string generated from a port range\&. \fIports_range\fR may be one of: +The \fBnutscan_get_serial_ports_list()\fR function returns a null terminated array of strings generated from a port range\&. \fIports_range\fR may be one of: .sp .RS 4 .ie n \{\ @@ -50,7 +50,7 @@ The \fBnutscan_get_serial_ports_list()\fR function returns a null terminated arr .sp -1 .IP \(bu 2.3 .\} -a single character from 0 to 9 or a to z representing a serial communication port depending on the operating system\&. For instance "0" is converted to /dev/ttyS0 and /dev/ttyUSB0 on Linux; "1" is converted to COM1 on Windows; "c" is converted to /dev/ttyc on solaris\&... +a single character from 0 to 9 or a to z representing a serial communication port depending on the operating system\&. For instance "0" is converted to /dev/ttyS0 and /dev/ttyUSB0 on Linux; "1" is converted to COM1 on Windows; "c" is converted to /dev/ttyc on Solaris\&... .RE .sp .RS 4 @@ -83,13 +83,16 @@ a single port name (/dev/ttyS5, COM4\&...)\&. .sp -1 .IP \(bu 2.3 .\} -a list of port names separated with comas : "/dev/ttyS0,/dev/ttyS2,/dev/ttyS4" or "COM1,COM3"\&... +a list of port names separated with commas: "/dev/ttyS0,/dev/ttyS2,/dev/ttyS4" or "COM1,COM3"\&... .RE .sp The returned array can be used in a call to \fBnutscan_scan_eaton_serial\fR to get the serial device on a system\&. .SH "RETURN VALUE" .sp -The \fBnutscan_get_serial_ports_list()\fR function returns NULL if an error occured (invalid port range) or a pointer to a nll terminated array of string on success\&. +The \fBnutscan_get_serial_ports_list()\fR function returns NULL if an error occurred (invalid port range) or a pointer to a null terminated array of strings on success\&. +.SH "NOTES" +.sp +Technically, the function is currently defined in \fInutscan\-serial\&.h\fR file\&. .SH "SEE ALSO" .sp -\fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_scan_eaton_serial\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_display_ups_conf\fR(3) +\fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http_range\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_scan_eaton_serial\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_display_ups_conf\fR(3) diff --git a/docs/man/nutscan_get_serial_ports_list.txt b/docs/man/nutscan_get_serial_ports_list.txt index dfe0d65..8b38bed 100644 --- a/docs/man/nutscan_get_serial_ports_list.txt +++ b/docs/man/nutscan_get_serial_ports_list.txt @@ -16,25 +16,44 @@ SYNOPSIS DESCRIPTION ----------- -The *nutscan_get_serial_ports_list()* function returns a null terminated array of string generated from a port range. +The *nutscan_get_serial_ports_list()* function returns a null +terminated array of strings generated from a port range. 'ports_range' may be one of: - - a single character from 0 to 9 or a to z representing a serial communication port depending on the operating system. For instance "0" is converted to /dev/ttyS0 and /dev/ttyUSB0 on Linux; "1" is converted to COM1 on Windows; "c" is converted to /dev/ttyc on solaris... - - a range of character in the form "X-Y". For instance "0-1" will be converted to /dev/ttyS0, /dev/ttyS1, /dev/ttyUSB0 and /dev/ttyUSB1 on Linux; "1-3" will be converted to COM1, COM2 and COM3 on Windows; "a-c" will be converted to /dev/ttya, /dev/ttyb and /dev/ttyc on Solaris. + - a single character from 0 to 9 or a to z representing a serial + communication port depending on the operating system. For instance + "0" is converted to /dev/ttyS0 and /dev/ttyUSB0 on Linux; + "1" is converted to COM1 on Windows; + "c" is converted to /dev/ttyc on Solaris... + - a range of character in the form "X-Y". For instance + "0-1" will be converted to /dev/ttyS0, /dev/ttyS1, /dev/ttyUSB0 + and /dev/ttyUSB1 on Linux; + "1-3" will be converted to COM1, COM2 and COM3 on Windows; + "a-c" will be converted to /dev/ttya, /dev/ttyb and /dev/ttyc on Solaris. - a single port name (/dev/ttyS5, COM4...). - - a list of port names separated with comas : "/dev/ttyS0,/dev/ttyS2,/dev/ttyS4" or "COM1,COM3"... + - a list of port names separated with commas: + "/dev/ttyS0,/dev/ttyS2,/dev/ttyS4" or "COM1,COM3"... -The returned array can be used in a call to *nutscan_scan_eaton_serial* to get the serial device on a system. +The returned array can be used in a call to *nutscan_scan_eaton_serial* +to get the serial device on a system. RETURN VALUE ------------ -The *nutscan_get_serial_ports_list()* function returns NULL if an error occured (invalid port range) or a pointer to a nll terminated array of string on success. +The *nutscan_get_serial_ports_list()* function returns NULL if an error +occurred (invalid port range) or a pointer to a null terminated array +of strings on success. + +NOTES +----- + +Technically, the function is currently defined in 'nutscan-serial.h' file. SEE ALSO -------- -linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http[3], -linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], -linkman:nutscan_scan_ipmi[3], linkman:nutscan_scan_snmp[3], + +linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http_range[3], +linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], +linkman:nutscan_scan_ipmi[3], linkman:nutscan_scan_snmp[3], linkman:nutscan_scan_eaton_serial[3], linkman:nutscan_display_parsable[3], linkman:nutscan_display_ups_conf[3] diff --git a/docs/man/nutscan_init.3 b/docs/man/nutscan_init.3 index bad6e1e..8afbfd1 100644 --- a/docs/man/nutscan_init.3 +++ b/docs/man/nutscan_init.3 @@ -1,13 +1,13 @@ '\" t .\" Title: nutscan_init -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUTSCAN_INIT" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUTSCAN_INIT" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -36,13 +36,15 @@ nutscan_init \- Initialize the nutscan library\&. .fi .sp .nf -void nutscan_init(); +void nutscan_init(void); .fi .SH "DESCRIPTION" .sp The \fBnutscan_init()\fR function must be called at least once before using any other function of the nutscan library\&. .sp -It updates the following global variables which can be used by nutscan library user to know which scan methods are available at run\-time\&. This depends on the libraries installed on the system: +It updates the following global variables which can be used by nutscan library user to know which scan methods are available at run\-time\&. +.sp +This depends on the libraries installed on the system: .sp .if n \{\ .RS 4 @@ -60,6 +62,9 @@ nutscan_avail_xml_http = 1 : XML HTTP method is available .\} .sp Note that if a method is reported as unavailable by those variables, the call to the corresponding nutscan_scan_* function will always return NULL\&. +.SH "NOTES" +.sp +Technically, the function is currently defined in \fInutscan\-init\&.h\fR file\&. .SH "SEE ALSO" .sp -\fBnutscan_init\fR(3), \fBnutscan_scan_usb\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_scan_xml_http\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_add_device_to_device\fR(3) +\fBnutscan_init\fR(3), \fBnutscan_scan_usb\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_scan_xml_http_range\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_add_device_to_device\fR(3) diff --git a/docs/man/nutscan_init.txt b/docs/man/nutscan_init.txt index 203eb63..17e6ddf 100644 --- a/docs/man/nutscan_init.txt +++ b/docs/man/nutscan_init.txt @@ -11,14 +11,18 @@ SYNOPSIS #include - void nutscan_init(); + void nutscan_init(void); DESCRIPTION ----------- -The *nutscan_init()* function must be called at least once before using any other function of the nutscan library. +The *nutscan_init()* function must be called at least once before using +any other function of the nutscan library. -It updates the following global variables which can be used by nutscan library user to know which scan methods are available at run-time. This depends on the libraries installed on the system: +It updates the following global variables which can be used by nutscan +library user to know which scan methods are available at run-time. + +This depends on the libraries installed on the system: nutscan_avail_avahi = 1 : AVAHI scan is available nutscan_avail_ipmi = 1 : IPMI scan is available @@ -27,14 +31,21 @@ It updates the following global variables which can be used by nutscan library u nutscan_avail_usb = 1 : USB method is available nutscan_avail_xml_http = 1 : XML HTTP method is available -Note that if a method is reported as unavailable by those variables, the call to the corresponding nutscan_scan_* function will always return NULL. +Note that if a method is reported as unavailable by those variables, the +call to the corresponding `nutscan_scan_*` function will always return NULL. + +NOTES +----- + +Technically, the function is currently defined in 'nutscan-init.h' file. SEE ALSO -------- + linkman:nutscan_init[3], linkman:nutscan_scan_usb[3], -linkman:nutscan_scan_snmp[3], linkman:nutscan_scan_xml_http[3], -linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], -linkman:nutscan_scan_ipmi[3], linkman:nutscan_display_ups_conf[3], +linkman:nutscan_scan_snmp[3], linkman:nutscan_scan_xml_http_range[3], +linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], +linkman:nutscan_scan_ipmi[3], linkman:nutscan_display_ups_conf[3], linkman:nutscan_display_parsable[3], linkman:nutscan_new_device[3], linkman:nutscan_free_device[3], linkman:nutscan_add_option_to_device[3], linkman:nutscan_add_device_to_device[3] diff --git a/docs/man/nutscan_new_device.3 b/docs/man/nutscan_new_device.3 index 1196eff..8ae2ecf 100644 --- a/docs/man/nutscan_new_device.3 +++ b/docs/man/nutscan_new_device.3 @@ -1,13 +1,13 @@ '\" t .\" Title: nutscan_new_device -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUTSCAN_NEW_DEVICE" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUTSCAN_NEW_DEVICE" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -36,14 +36,17 @@ nutscan_new_device \- Create a new nutscan_device_t structure\&. .fi .sp .nf -nutscan_device_t * nutscan_new_device(); +nutscan_device_t * nutscan_new_device(void); .fi .SH "DESCRIPTION" .sp The \fBnutscan_new_device()\fR function allocates a new nutscan_device_type_t structure\&. .SH "RETURN VALUE" .sp -The \fBnutscan_new_device()\fR function returns the newly allocated nutscan_device_type_t structure +The \fBnutscan_new_device()\fR function returns the newly allocated nutscan_device_type_t structure\&. +.SH "NOTES" +.sp +Technically, the function is currently defined in \fInutscan\-device\&.h\fR file\&. .SH "SEE ALSO" .sp -\fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_scan_snmp\fR(3) \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3) \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3) \fBnutscan_add_device_to_device\fR(3) +\fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http_range\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_scan_snmp\fR(3) \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3) \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3) \fBnutscan_add_device_to_device\fR(3) diff --git a/docs/man/nutscan_new_device.txt b/docs/man/nutscan_new_device.txt index 1b887cc..81cf26d 100644 --- a/docs/man/nutscan_new_device.txt +++ b/docs/man/nutscan_new_device.txt @@ -11,22 +11,30 @@ SYNOPSIS #include - nutscan_device_t * nutscan_new_device(); + nutscan_device_t * nutscan_new_device(void); DESCRIPTION ----------- -The *nutscan_new_device()* function allocates a new `nutscan_device_type_t` structure. +The *nutscan_new_device()* function allocates a new `nutscan_device_type_t` +structure. RETURN VALUE ------------ -The *nutscan_new_device()* function returns the newly allocated `nutscan_device_type_t` structure +The *nutscan_new_device()* function returns the newly allocated +`nutscan_device_type_t` structure. + +NOTES +----- + +Technically, the function is currently defined in 'nutscan-device.h' file. SEE ALSO -------- -linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http[3], -linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], + +linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http_range[3], +linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], linkman:nutscan_scan_ipmi[3], linkman:nutscan_scan_snmp[3] linkman:nutscan_display_ups_conf[3], linkman:nutscan_display_parsable[3] linkman:nutscan_free_device[3], linkman:nutscan_add_option_to_device[3] diff --git a/docs/man/nutscan_scan_avahi.3 b/docs/man/nutscan_scan_avahi.3 index 61ac99f..c7c52a9 100644 --- a/docs/man/nutscan_scan_avahi.3 +++ b/docs/man/nutscan_scan_avahi.3 @@ -1,13 +1,13 @@ '\" t .\" Title: nutscan_scan_avahi -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUTSCAN_SCAN_AVAHI" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUTSCAN_SCAN_AVAHI" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -33,10 +33,11 @@ nutscan_scan_avahi \- Scan network for NUT services via mDNS .sp .nf #include +#include /* useconds_t */ .fi .sp .nf -nutscan_device_t * nutscan_scan_avahi(long usec_timeout); +nutscan_device_t * nutscan_scan_avahi(useconds_t usec_timeout); .fi .SH "DESCRIPTION" .sp @@ -44,10 +45,15 @@ The \fBnutscan_scan_avahi()\fR function tries to detect the NUT service via mDNS .sp You MUST call \fBnutscan_init\fR(3) before using this function\&. .sp -This function waits up to \fIusec_timeout\fR microseconds before considering an IP address to be unresponsive\&. +This function can query perspective IP addresses using NUT protocol, and in this case it waits up to \fIusec_timeout\fR microseconds before considering an IP address to be unresponsive\&. .SH "RETURN VALUE" .sp -The \fBnutscan_scan_avahi()\fR function returns a pointer to a nutscan_device_t structure containing all found devices\&. It returns NULL if an error occurs, or if no device is found\&. +The \fBnutscan_scan_avahi()\fR function returns a pointer to a nutscan_device_t structure containing all found devices\&. +.sp +It returns NULL if an error occurs, or if no device is found\&. .SH "SEE ALSO" .sp -\fBnutscan_init\fR(3), \fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_add_device_to_device\fR(3), \fBnutscan_cidr_to_ip\fR(3), \fBnutscan_scan_eaton_serial\fR(3), http://avahi\&.org/ +\fBnutscan_init\fR(3), \fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http_range\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_add_device_to_device\fR(3), \fBnutscan_cidr_to_ip\fR(3), \fBnutscan_scan_eaton_serial\fR(3) +.SS "Internet resources:" +.sp +http://avahi\&.org/ diff --git a/docs/man/nutscan_scan_avahi.txt b/docs/man/nutscan_scan_avahi.txt index fe82e12..01f02e9 100644 --- a/docs/man/nutscan_scan_avahi.txt +++ b/docs/man/nutscan_scan_avahi.txt @@ -10,35 +10,43 @@ SYNOPSIS -------- #include + #include /* useconds_t */ - nutscan_device_t * nutscan_scan_avahi(long usec_timeout); + nutscan_device_t * nutscan_scan_avahi(useconds_t usec_timeout); DESCRIPTION ----------- -The *nutscan_scan_avahi()* function tries to detect the NUT service via mDNS, -and its associated devices. It uses the Avahi library to do so. +The *nutscan_scan_avahi()* function tries to detect the NUT service via +mDNS, and its associated devices. It uses the Avahi library to do so. You MUST call linkman:nutscan_init[3] before using this function. -This function waits up to 'usec_timeout' microseconds before considering an IP -address to be unresponsive. +This function can query perspective IP addresses using NUT protocol, and +in this case it waits up to 'usec_timeout' microseconds before considering +an IP address to be unresponsive. RETURN VALUE ------------ -The *nutscan_scan_avahi()* function returns a pointer to a `nutscan_device_t` -structure containing all found devices. It returns NULL if an error occurs, or -if no device is found. +The *nutscan_scan_avahi()* function returns a pointer to a +`nutscan_device_t` structure containing all found devices. + +It returns NULL if an error occurs, or if no device is found. SEE ALSO -------- + linkman:nutscan_init[3], -linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http[3], -linkman:nutscan_scan_nut[3], linkman:nutscan_scan_snmp[3], -linkman:nutscan_scan_ipmi[3], linkman:nutscan_display_ups_conf[3], +linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http_range[3], +linkman:nutscan_scan_nut[3], linkman:nutscan_scan_snmp[3], +linkman:nutscan_scan_ipmi[3], linkman:nutscan_display_ups_conf[3], linkman:nutscan_display_parsable[3], linkman:nutscan_new_device[3], linkman:nutscan_free_device[3], linkman:nutscan_add_option_to_device[3], linkman:nutscan_add_device_to_device[3], linkman:nutscan_cidr_to_ip[3], -linkman:nutscan_scan_eaton_serial[3], +linkman:nutscan_scan_eaton_serial[3] + +Internet resources: +~~~~~~~~~~~~~~~~~~~ + http://avahi.org/ diff --git a/docs/man/nutscan_scan_eaton_serial.3 b/docs/man/nutscan_scan_eaton_serial.3 index 8f5df50..c468577 100644 --- a/docs/man/nutscan_scan_eaton_serial.3 +++ b/docs/man/nutscan_scan_eaton_serial.3 @@ -1,13 +1,13 @@ '\" t .\" Title: nutscan_scan_eaton_serial -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUTSCAN_SCAN_EATON_S" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUTSCAN_SCAN_EATON_S" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -40,7 +40,9 @@ nutscan_device_t * nutscan_scan_eaton_serial(const char* ports_list); .fi .SH "DESCRIPTION" .sp -The \fBnutscan_scan_eaton_serial()\fR function tries to detect NUT devices which are compatible with Eaton\(cqs serial device protocols (SHUT, XCP and Q1 (aka blazer))\&. \fIports_list\fR is a NULL terminated array of pointers to strings containing serial device name (/dev/ttyS0, COM1, /dev/ttya\&...) +The \fBnutscan_scan_eaton_serial()\fR function tries to detect NUT devices which are compatible with Eaton\(cqs serial device protocols (SHUT, XCP and Q1 (aka blazer))\&. +.sp +\fIports_list\fR is a NULL terminated array of pointers to strings containing serial device name (/dev/ttyS0, COM1, /dev/ttya\&...) .sp You MUST call \fBnutscan_init\fR(3) before using this function\&. .SH "RETURN VALUE" @@ -48,4 +50,4 @@ You MUST call \fBnutscan_init\fR(3) before using this function\&. The \fBnutscan_scan_eaton_serial()\fR function returns a pointer to a nutscan_device_t structure containing all found devices or NULL if an error occurs or no device is found\&. .SH "SEE ALSO" .sp -\fBnutscan_init\fR(3), \fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_add_device_to_device\fR(3), \fBnutscan_get_serial_ports_list\fR(3) +\fBnutscan_init\fR(3), \fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http_range\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_add_device_to_device\fR(3), \fBnutscan_get_serial_ports_list\fR(3) diff --git a/docs/man/nutscan_scan_eaton_serial.txt b/docs/man/nutscan_scan_eaton_serial.txt index 7a38172..068db12 100644 --- a/docs/man/nutscan_scan_eaton_serial.txt +++ b/docs/man/nutscan_scan_eaton_serial.txt @@ -4,7 +4,8 @@ NUTSCAN_SCAN_EATON_SERIAL(3) NAME ---- -nutscan_scan_eaton_serial - Scan serial ports for Eaton devices (XCP, SHUT and Q1). +nutscan_scan_eaton_serial - Scan serial ports for Eaton devices (XCP, SHUT +and Q1). SYNOPSIS -------- @@ -16,8 +17,10 @@ SYNOPSIS DESCRIPTION ----------- -The *nutscan_scan_eaton_serial()* function tries to detect NUT devices which are -compatible with Eaton's serial device protocols (SHUT, XCP and Q1 (aka blazer)). +The *nutscan_scan_eaton_serial()* function tries to detect NUT devices +which are compatible with Eaton's serial device protocols (SHUT, XCP +and Q1 (aka blazer)). + 'ports_list' is a NULL terminated array of pointers to strings containing serial device name (/dev/ttyS0, COM1, /dev/ttya...) @@ -26,14 +29,17 @@ You MUST call linkman:nutscan_init[3] before using this function. RETURN VALUE ------------ -The *nutscan_scan_eaton_serial()* function returns a pointer to a `nutscan_device_t` structure containing all found devices or NULL if an error occurs or no device is found. +The *nutscan_scan_eaton_serial()* function returns a pointer to +a `nutscan_device_t` structure containing all found devices or +NULL if an error occurs or no device is found. SEE ALSO -------- + linkman:nutscan_init[3], -linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http[3], -linkman:nutscan_scan_snmp[3], linkman:nutscan_scan_avahi[3], -linkman:nutscan_scan_ipmi[3], linkman:nutscan_display_ups_conf[3], +linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http_range[3], +linkman:nutscan_scan_snmp[3], linkman:nutscan_scan_avahi[3], +linkman:nutscan_scan_ipmi[3], linkman:nutscan_display_ups_conf[3], linkman:nutscan_display_parsable[3], linkman:nutscan_new_device[3], linkman:nutscan_free_device[3], linkman:nutscan_add_option_to_device[3], linkman:nutscan_add_device_to_device[3], diff --git a/docs/man/nutscan_scan_ipmi.3 b/docs/man/nutscan_scan_ipmi.3 index 51a9f36..4d2d55d 100644 --- a/docs/man/nutscan_scan_ipmi.3 +++ b/docs/man/nutscan_scan_ipmi.3 @@ -1,13 +1,13 @@ '\" t .\" Title: nutscan_scan_ipmi -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUTSCAN_SCAN_IPMI" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUTSCAN_SCAN_IPMI" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -36,16 +36,26 @@ nutscan_scan_ipmi \- Scan local IPMI devices\&. .fi .sp .nf -nutscan_device_t * nutscan_scan_ipmi(void); +nutscan_device_t * nutscan_scan_ipmi( + const char * startIP, + const char * stopIP, + nutscan_ipmi_t * sec); .fi .SH "DESCRIPTION" .sp -The \fBnutscan_scan_ipmi()\fR function is not implemented yet\&. +The \fBnutscan_scan_ipmi()\fR function tries to detect IPMI manageable devices\&. +.sp +If \fIstart_ip\fR is NULL, the function searches for a local PSU\&. +.sp +Otherwise, it searches for remote hosts that would serve IPMI protocols, and would try to authenticate using the data in \fIsec\fR structure\&. It issues a NUT request on every IP ranging from \fIstartIP\fR to \fIstopIP\fR, where \fIstopIP\fR is optional\&. Those IP arguments may be either IPv4 or IPv6 addresses or host names\&. .sp You MUST call \fBnutscan_init\fR(3) before using this function\&. +.SH "BUGS" +.sp +Design or implementation of this function may be incomplete: until recently, this man page stated that it was not implemented yet\&. Source code is present, although some blocks are commented away or hidden with #if 0\&. .SH "RETURN VALUE" .sp The \fBnutscan_scan_ipmi()\fR function is not implemented yet\&. .SH "SEE ALSO" .sp -\fBnutscan_init\fR(3), \fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_add_device_to_device\fR(3), \fBnutscan_scan_eaton_serial\fR(3), \fBnutscan_cidr_to_ip\fR(3) +\fBnutscan_init\fR(3), \fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http_range\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_add_device_to_device\fR(3), \fBnutscan_scan_eaton_serial\fR(3), \fBnutscan_cidr_to_ip\fR(3) diff --git a/docs/man/nutscan_scan_ipmi.txt b/docs/man/nutscan_scan_ipmi.txt index a5ee61c..9d463f4 100644 --- a/docs/man/nutscan_scan_ipmi.txt +++ b/docs/man/nutscan_scan_ipmi.txt @@ -11,15 +11,34 @@ SYNOPSIS #include - nutscan_device_t * nutscan_scan_ipmi(void); + nutscan_device_t * nutscan_scan_ipmi( + const char * startIP, + const char * stopIP, + nutscan_ipmi_t * sec); DESCRIPTION ----------- -The *nutscan_scan_ipmi()* function is not implemented yet. +The *nutscan_scan_ipmi()* function tries to detect IPMI manageable devices. + +If 'start_ip' is NULL, the function searches for a local PSU. + +Otherwise, it searches for remote hosts that would serve IPMI protocols, +and would try to authenticate using the data in 'sec' structure. +It issues a NUT request on every IP ranging from 'startIP' to 'stopIP', +where 'stopIP' is optional. Those IP arguments may be either IPv4 or IPv6 +addresses or host names. You MUST call linkman:nutscan_init[3] before using this function. +BUGS +---- + +Design or implementation of this function may be incomplete: until +recently, this man page stated that it was not implemented yet. +Source code is present, although some blocks are commented away +or hidden with `#if 0`. + RETURN VALUE ------------ @@ -27,10 +46,11 @@ The *nutscan_scan_ipmi()* function is not implemented yet. SEE ALSO -------- + linkman:nutscan_init[3], -linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http[3], -linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], -linkman:nutscan_scan_snmp[3], linkman:nutscan_display_ups_conf[3], +linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http_range[3], +linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], +linkman:nutscan_scan_snmp[3], linkman:nutscan_display_ups_conf[3], linkman:nutscan_display_parsable[3], linkman:nutscan_new_device[3], linkman:nutscan_free_device[3], linkman:nutscan_add_option_to_device[3], linkman:nutscan_add_device_to_device[3], linkman:nutscan_scan_eaton_serial[3], diff --git a/docs/man/nutscan_scan_nut.3 b/docs/man/nutscan_scan_nut.3 index 68487e1..6dc3a4b 100644 --- a/docs/man/nutscan_scan_nut.3 +++ b/docs/man/nutscan_scan_nut.3 @@ -1,13 +1,13 @@ '\" t .\" Title: nutscan_scan_nut -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUTSCAN_SCAN_NUT" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUTSCAN_SCAN_NUT" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -33,14 +33,19 @@ nutscan_scan_nut \- Scan network for available NUT services\&. .sp .nf #include +#include /* useconds_t */ .fi .sp .nf -nutscan_device_t * nutscan_scan_nut(const char * startIP, const char * stopIP, const char * port, long usec_timeout); +nutscan_device_t * nutscan_scan_nut( + const char * startIP, + const char * stopIP, + const char * port, + useconds_t usec_timeout); .fi .SH "DESCRIPTION" .sp -The \fBnutscan_scan_nut()\fR function try to detect available NUT services and their associated devices\&. It issues a NUT request on every IP ranging from \fIstartIP\fR to \fIstopIP\fR\&. \fIstartIP\fR is mandatory, \fIstopIP\fR is optional\&. Those IP may be either IPv4 or IPv6 addresses or host names\&. +The \fBnutscan_scan_nut()\fR function try to detect available NUT services and their associated devices\&. It issues a NUT request on every IP ranging from \fIstartIP\fR to \fIstopIP\fR\&. \fIstartIP\fR is mandatory, \fIstopIP\fR is optional\&. Those IP arguments may be either IPv4 or IPv6 addresses or host names\&. .sp You MUST call \fBnutscan_init\fR(3) before using this function\&. .sp @@ -52,4 +57,4 @@ This function waits up to \fIusec_timeout\fR microseconds before considering an The \fBnutscan_scan_nut()\fR function returns a pointer to a nutscan_device_t structure containing all found devices or NULL if an error occurs or no device is found\&. .SH "SEE ALSO" .sp -\fBnutscan_init\fR(3), \fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_add_device_to_device\fR(3), \fBnutscan_scan_eaton_serial\fR(3), \fBnutscan_cidr_to_ip\fR(3) +\fBnutscan_init\fR(3), \fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http_range\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_add_device_to_device\fR(3), \fBnutscan_scan_eaton_serial\fR(3), \fBnutscan_cidr_to_ip\fR(3) diff --git a/docs/man/nutscan_scan_nut.txt b/docs/man/nutscan_scan_nut.txt index 367a819..7d0b543 100644 --- a/docs/man/nutscan_scan_nut.txt +++ b/docs/man/nutscan_scan_nut.txt @@ -10,31 +10,43 @@ SYNOPSIS -------- #include + #include /* useconds_t */ - nutscan_device_t * nutscan_scan_nut(const char * startIP, const char * stopIP, const char * port, long usec_timeout); + nutscan_device_t * nutscan_scan_nut( + const char * startIP, + const char * stopIP, + const char * port, + useconds_t usec_timeout); DESCRIPTION ----------- -The *nutscan_scan_nut()* function try to detect available NUT services and their associated devices. It issues a NUT request on every IP ranging from 'startIP' to 'stopIP'. 'startIP' is mandatory, 'stopIP' is optional. Those IP may be either IPv4 or IPv6 addresses or host names. +The *nutscan_scan_nut()* function try to detect available NUT services +and their associated devices. It issues a NUT request on every IP ranging +from 'startIP' to 'stopIP'. 'startIP' is mandatory, 'stopIP' is optional. +Those IP arguments may be either IPv4 or IPv6 addresses or host names. You MUST call linkman:nutscan_init[3] before using this function. A specific 'port' number may be passed, or NULL to use the default NUT port. -This function waits up to 'usec_timeout' microseconds before considering an IP address does not respond to NUT queries. +This function waits up to 'usec_timeout' microseconds before considering +an IP address does not respond to NUT queries. RETURN VALUE ------------ -The *nutscan_scan_nut()* function returns a pointer to a `nutscan_device_t` structure containing all found devices or NULL if an error occurs or no device is found. +The *nutscan_scan_nut()* function returns a pointer to a `nutscan_device_t` +structure containing all found devices or NULL if an error occurs or no +device is found. SEE ALSO -------- + linkman:nutscan_init[3], -linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http[3], -linkman:nutscan_scan_snmp[3], linkman:nutscan_scan_avahi[3], -linkman:nutscan_scan_ipmi[3], linkman:nutscan_display_ups_conf[3], +linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http_range[3], +linkman:nutscan_scan_snmp[3], linkman:nutscan_scan_avahi[3], +linkman:nutscan_scan_ipmi[3], linkman:nutscan_display_ups_conf[3], linkman:nutscan_display_parsable[3], linkman:nutscan_new_device[3], linkman:nutscan_free_device[3], linkman:nutscan_add_option_to_device[3], linkman:nutscan_add_device_to_device[3], linkman:nutscan_scan_eaton_serial[3], diff --git a/docs/man/nutscan_scan_snmp.3 b/docs/man/nutscan_scan_snmp.3 index 6db38fe..5b75a62 100644 --- a/docs/man/nutscan_scan_snmp.3 +++ b/docs/man/nutscan_scan_snmp.3 @@ -1,13 +1,13 @@ '\" t .\" Title: nutscan_scan_snmp -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUTSCAN_SCAN_SNMP" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUTSCAN_SCAN_SNMP" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -33,14 +33,19 @@ nutscan_scan_snmp \- Scan network for SNMP devices\&. .sp .nf #include +#include /* useconds_t */ .fi .sp .nf -nutscan_device_t * nutscan_scan_snmp(const char * start_ip,const char * stop_ip,long timeout, nutscan_snmp_t * sec); +nutscan_device_t * nutscan_scan_snmp( + const char * start_ip, + const char * stop_ip, + useconds_t timeout, + nutscan_snmp_t * sec); .fi .SH "DESCRIPTION" .sp -The \fBnutscan_scan_snmp()\fR function try to detect NUT compatible SNMP devices\&. It tries SNMP queries on every IP ranging from \fIstart_ip\fR to \fIstop_ip\fR\&. Those IP may be either IPv4 or IPv6 addresses or host names\&. +The \fBnutscan_scan_snmp()\fR function try to detect NUT compatible SNMP devices\&. It tries SNMP queries on every IP ranging from \fIstart_ip\fR to \fIstop_ip\fR\&. Those IP arguments may be either IPv4 or IPv6 addresses or host names\&. .sp You MUST call \fBnutscan_init\fR(3) before using this function\&. .sp @@ -86,4 +91,4 @@ If \fIprivProtocol\fR is NULL, DES protocol is used\&. Else you can set \fIprivP The \fBnutscan_scan_snmp()\fR function returns a pointer to a nutscan_device_t structure containing all found devices or NULL if an error occurs or no device is found\&. .SH "SEE ALSO" .sp -\fBnutscan_init\fR(3), \fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_add_device_to_device\fR(3), \fBnutscan_scan_eaton_serial\fR(3), \fBnutscan_cidr_to_ip\fR(3) +\fBnutscan_init\fR(3), \fBnutscan_scan_usb\fR(3), \fBnutscan_scan_xml_http_range\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_add_device_to_device\fR(3), \fBnutscan_scan_eaton_serial\fR(3), \fBnutscan_cidr_to_ip\fR(3) diff --git a/docs/man/nutscan_scan_snmp.txt b/docs/man/nutscan_scan_snmp.txt index 4dbec4b..ecc893f 100644 --- a/docs/man/nutscan_scan_snmp.txt +++ b/docs/man/nutscan_scan_snmp.txt @@ -10,21 +10,31 @@ SYNOPSIS -------- #include + #include /* useconds_t */ - nutscan_device_t * nutscan_scan_snmp(const char * start_ip,const char * stop_ip,long timeout, nutscan_snmp_t * sec); + nutscan_device_t * nutscan_scan_snmp( + const char * start_ip, + const char * stop_ip, + useconds_t timeout, + nutscan_snmp_t * sec); DESCRIPTION ----------- -The *nutscan_scan_snmp()* function try to detect NUT compatible SNMP devices. It tries SNMP queries on every IP ranging from 'start_ip' to 'stop_ip'. Those IP may be either IPv4 or IPv6 addresses or host names. +The *nutscan_scan_snmp()* function try to detect NUT compatible SNMP +devices. It tries SNMP queries on every IP ranging from 'start_ip' to +'stop_ip'. Those IP arguments may be either IPv4 or IPv6 addresses or +host names. You MUST call linkman:nutscan_init[3] before using this function. -This function waits up to 'timeout' microseconds before considering an IP address does not respond to SNMP queries. +This function waits up to 'timeout' microseconds before considering +an IP address does not respond to SNMP queries. A valid `nutscan_snmp_t` structure must be passed to this function. -The `nutscan_snmp_t` structure contains the following members which must be filled as described below: +The `nutscan_snmp_t` structure contains the following members which +must be filled as described below: char * 'community'; char * 'secLevel'; @@ -36,31 +46,43 @@ The `nutscan_snmp_t` structure contains the following members which must be fill If 'community' is not NULL, SNMP v1 request are sent using this 'community'. -If 'community' is NULL and 'secLevel' is NULL, SNMP v1 is selected and 'community' is set to "public". +If 'community' is NULL and 'secLevel' is NULL, SNMP v1 is selected +and 'community' is set to "public". -In the other cases, SNMP v3 is used. 'secLevel' may be one of `SNMP_SEC_LEVEL_NOAUTH`, `SNMP_SEC_LEVEL_AUTHNOPRIV` or `SNMP_SEC_LEVEL_AUTHPRIV`. 'secName' is the security name and must be non NULL. +In the other cases, SNMP v3 is used. 'secLevel' may be one +of `SNMP_SEC_LEVEL_NOAUTH`, `SNMP_SEC_LEVEL_AUTHNOPRIV` +or `SNMP_SEC_LEVEL_AUTHPRIV`. +'secName' is the security name and must be non NULL. -If 'secLevel' is set to `SNMP_SEC_LEVEL_AUTHNOPRIV`, 'authPassword' must be non NULL. +If 'secLevel' is set to `SNMP_SEC_LEVEL_AUTHNOPRIV`, 'authPassword' +must be non NULL. -If 'secLevel' is set to `SNMP_SEC_LEVEL_AUTHPRIV`, 'authPassword' and 'privPassword' must be non NULL. +If 'secLevel' is set to `SNMP_SEC_LEVEL_AUTHPRIV`, 'authPassword' +and 'privPassword' must be non NULL. -If 'authProtocol' is NULL, MD5 protocol is used. Else you can set 'authProtocol' to either "MD5" or "SHA". +If 'authProtocol' is NULL, MD5 protocol is used. +Else you can set 'authProtocol' to either "MD5" or "SHA". -If 'privProtocol' is NULL, DES protocol is used. Else you can set 'privProtocol' to either "AES" or "DES". +If 'privProtocol' is NULL, DES protocol is used. +Else you can set 'privProtocol' to either "AES" or "DES". -'peername' and 'handle' are used internally and do not need any initialization. +'peername' and 'handle' are used internally and do not need any +initialization. RETURN VALUE ------------ -The *nutscan_scan_snmp()* function returns a pointer to a `nutscan_device_t` structure containing all found devices or NULL if an error occurs or no device is found. +The *nutscan_scan_snmp()* function returns a pointer to a +`nutscan_device_t` structure containing all found devices +or NULL if an error occurs or no device is found. SEE ALSO -------- + linkman:nutscan_init[3], -linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http[3], -linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], -linkman:nutscan_scan_ipmi[3], linkman:nutscan_display_ups_conf[3], +linkman:nutscan_scan_usb[3], linkman:nutscan_scan_xml_http_range[3], +linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], +linkman:nutscan_scan_ipmi[3], linkman:nutscan_display_ups_conf[3], linkman:nutscan_display_parsable[3], linkman:nutscan_new_device[3], linkman:nutscan_free_device[3], linkman:nutscan_add_option_to_device[3], linkman:nutscan_add_device_to_device[3], linkman:nutscan_scan_eaton_serial[3], diff --git a/docs/man/nutscan_scan_usb.3 b/docs/man/nutscan_scan_usb.3 index d3c8fb9..e5fa2ce 100644 --- a/docs/man/nutscan_scan_usb.3 +++ b/docs/man/nutscan_scan_usb.3 @@ -1,13 +1,13 @@ '\" t .\" Title: nutscan_scan_usb -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUTSCAN_SCAN_USB" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUTSCAN_SCAN_USB" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -36,7 +36,7 @@ nutscan_scan_usb \- Scan NUT compatible USB devices\&. .fi .sp .nf -nutscan_device_t * nutscan_scan_usb(); +nutscan_device_t * nutscan_scan_usb(void); .fi .SH "DESCRIPTION" .sp @@ -48,4 +48,4 @@ You MUST call \fBnutscan_init\fR(3) before using this function\&. The \fBnutscan_scan_usb()\fR function returns a pointer to a nutscan_device_t structure containing all found devices or NULL if an error occurs or no device is found\&. .SH "SEE ALSO" .sp -\fBnutscan_init\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_scan_xml_http\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_add_device_to_device\fR(3), \fBnutscan_scan_eaton_serial\fR(3) +\fBnutscan_init\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_scan_xml_http_range\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_add_device_to_device\fR(3), \fBnutscan_scan_eaton_serial\fR(3) diff --git a/docs/man/nutscan_scan_usb.txt b/docs/man/nutscan_scan_usb.txt index a48009c..878c712 100644 --- a/docs/man/nutscan_scan_usb.txt +++ b/docs/man/nutscan_scan_usb.txt @@ -11,7 +11,7 @@ SYNOPSIS #include - nutscan_device_t * nutscan_scan_usb(); + nutscan_device_t * nutscan_scan_usb(void); DESCRIPTION ----------- @@ -23,14 +23,17 @@ You MUST call linkman:nutscan_init[3] before using this function. RETURN VALUE ------------ -The *nutscan_scan_usb()* function returns a pointer to a `nutscan_device_t` structure containing all found devices or NULL if an error occurs or no device is found. +The *nutscan_scan_usb()* function returns a pointer to a `nutscan_device_t` +structure containing all found devices or NULL if an error occurs or no +device is found. SEE ALSO -------- + linkman:nutscan_init[3], -linkman:nutscan_scan_snmp[3], linkman:nutscan_scan_xml_http[3], -linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], -linkman:nutscan_scan_ipmi[3], linkman:nutscan_display_ups_conf[3], +linkman:nutscan_scan_snmp[3], linkman:nutscan_scan_xml_http_range[3], +linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], +linkman:nutscan_scan_ipmi[3], linkman:nutscan_display_ups_conf[3], linkman:nutscan_display_parsable[3], linkman:nutscan_new_device[3], linkman:nutscan_free_device[3], linkman:nutscan_add_option_to_device[3], linkman:nutscan_add_device_to_device[3], linkman:nutscan_scan_eaton_serial[3] diff --git a/docs/man/nutscan_scan_xml_http.txt b/docs/man/nutscan_scan_xml_http.txt deleted file mode 100644 index 42bfe84..0000000 --- a/docs/man/nutscan_scan_xml_http.txt +++ /dev/null @@ -1,36 +0,0 @@ -NUTSCAN_SCAN_XML_HTTP(3) -======================== - -NAME ----- - -nutscan_scan_xml_http - Scan network for XML/HTTP devices. - -SYNOPSIS --------- - - #include - - nutscan_device_t * nutscan_scan_xml_http(long usec_timeout); - -DESCRIPTION ------------ - -The *nutscan_scan_xml_http()* function try to detect NUT compatible XML/HTTP devices. It does this by issuing a broadcast message on currently configured network interfaces. It waits up to 'usec_timeout' microseconds for a response from potential devices. - -You MUST call linkman:nutscan_init[3] before using this function. - -RETURN VALUE ------------- - -The *nutscan_scan_xml_http()* function returns a pointer to a `nutscan_device_t` structure containing all found devices or NULL if an error occurs or no device is found. - -SEE ALSO --------- -linkman:nutscan_init[3], -linkman:nutscan_scan_usb[3], linkman:nutscan_scan_snmp[3], -linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], -linkman:nutscan_scan_ipmi[3], linkman:nutscan_display_ups_conf[3], -linkman:nutscan_display_parsable[3], linkman:nutscan_new_device[3], -linkman:nutscan_free_device[3], linkman:nutscan_add_option_to_device[3], -linkman:nutscan_add_device_to_device[3], linkman:nutscan_scan_eaton_serial[3] diff --git a/docs/man/nutscan_scan_xml_http.3 b/docs/man/nutscan_scan_xml_http_range.3 similarity index 54% rename from docs/man/nutscan_scan_xml_http.3 rename to docs/man/nutscan_scan_xml_http_range.3 index 4a1161a..74ba7a3 100644 --- a/docs/man/nutscan_scan_xml_http.3 +++ b/docs/man/nutscan_scan_xml_http_range.3 @@ -1,13 +1,13 @@ '\" t -.\" Title: nutscan_scan_xml_http -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Title: nutscan_scan_xml_http_range +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUTSCAN_SCAN_XML_HTT" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUTSCAN_SCAN_XML_HTT" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -28,24 +28,35 @@ .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" -nutscan_scan_xml_http \- Scan network for XML/HTTP devices\&. +nutscan_scan_xml_http_range \- Scan network for XML/HTTP devices\&. .SH "SYNOPSIS" .sp .nf #include +#include /* useconds_t */ .fi .sp .nf -nutscan_device_t * nutscan_scan_xml_http(long usec_timeout); +nutscan_device_t * nutscan_scan_xml_http_range( + const char * start_ip, + const char * end_ip, + useconds_t usec_timeout, + nutscan_xml_t * sec) .fi .SH "DESCRIPTION" .sp -The \fBnutscan_scan_xml_http()\fR function try to detect NUT compatible XML/HTTP devices\&. It does this by issuing a broadcast message on currently configured network interfaces\&. It waits up to \fIusec_timeout\fR microseconds for a response from potential devices\&. +The \fBnutscan_scan_xml_http_range()\fR function tries to detect NUT compatible XML/HTTP devices\&. +.sp +If \fIstart_ip\fR is NULL, the function does this by issuing a broadcast message on currently configured network interfaces\&. +.sp +Otherwise, it queries every IP ranging from \fIstart_ip\fR to \fIstop_ip\fR\&. Those IP arguments may be either IPv4 or IPv6 addresses or host names\&. +.sp +It waits up to \fIusec_timeout\fR microseconds for a response from potential devices\&. .sp You MUST call \fBnutscan_init\fR(3) before using this function\&. .SH "RETURN VALUE" .sp -The \fBnutscan_scan_xml_http()\fR function returns a pointer to a nutscan_device_t structure containing all found devices or NULL if an error occurs or no device is found\&. +The \fBnutscan_scan_xml_http_range()\fR function returns a pointer to a nutscan_device_t structure containing all found devices or NULL if an error occurs or no device is found\&. .SH "SEE ALSO" .sp \fBnutscan_init\fR(3), \fBnutscan_scan_usb\fR(3), \fBnutscan_scan_snmp\fR(3), \fBnutscan_scan_nut\fR(3), \fBnutscan_scan_avahi\fR(3), \fBnutscan_scan_ipmi\fR(3), \fBnutscan_display_ups_conf\fR(3), \fBnutscan_display_parsable\fR(3), \fBnutscan_new_device\fR(3), \fBnutscan_free_device\fR(3), \fBnutscan_add_option_to_device\fR(3), \fBnutscan_add_device_to_device\fR(3), \fBnutscan_scan_eaton_serial\fR(3) diff --git a/docs/man/nutscan_scan_xml_http_range.txt b/docs/man/nutscan_scan_xml_http_range.txt new file mode 100644 index 0000000..15cb2af --- /dev/null +++ b/docs/man/nutscan_scan_xml_http_range.txt @@ -0,0 +1,54 @@ +NUTSCAN_SCAN_XML_HTTP_RANGE(3) +============================== + +NAME +---- + +nutscan_scan_xml_http_range - Scan network for XML/HTTP devices. + +SYNOPSIS +-------- + + #include + #include /* useconds_t */ + + nutscan_device_t * nutscan_scan_xml_http_range( + const char * start_ip, + const char * end_ip, + useconds_t usec_timeout, + nutscan_xml_t * sec) + +DESCRIPTION +----------- + +The *nutscan_scan_xml_http_range()* function tries to detect NUT compatible +XML/HTTP devices. + +If 'start_ip' is NULL, the function does this by issuing a broadcast message +on currently configured network interfaces. + +Otherwise, it queries every IP ranging from 'start_ip' to 'stop_ip'. +Those IP arguments may be either IPv4 or IPv6 addresses or host names. + +It waits up to 'usec_timeout' microseconds for a response from potential +devices. + +You MUST call linkman:nutscan_init[3] before using this function. + +RETURN VALUE +------------ + +The *nutscan_scan_xml_http_range()* function returns a pointer to +a `nutscan_device_t` structure containing all found devices +or NULL if an error occurs or no device is found. + +SEE ALSO +-------- + +linkman:nutscan_init[3], +linkman:nutscan_scan_usb[3], linkman:nutscan_scan_snmp[3], +linkman:nutscan_scan_nut[3], linkman:nutscan_scan_avahi[3], +linkman:nutscan_scan_ipmi[3], linkman:nutscan_display_ups_conf[3], +linkman:nutscan_display_parsable[3], linkman:nutscan_new_device[3], +linkman:nutscan_free_device[3], linkman:nutscan_add_option_to_device[3], +linkman:nutscan_add_device_to_device[3], linkman:nutscan_scan_eaton_serial[3] diff --git a/docs/man/nutupsdrv.8 b/docs/man/nutupsdrv.8 index daa4556..c331441 100644 --- a/docs/man/nutupsdrv.8 +++ b/docs/man/nutupsdrv.8 @@ -1,13 +1,13 @@ '\" t .\" Title: nutupsdrv -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "NUTUPSDRV" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "NUTUPSDRV" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -42,9 +42,11 @@ For information on the specific drivers, see their individual man pages\&. .sp UPS drivers provide a communication channel between the physical UPS hardware and the \fBupsd\fR(8) server\&. The driver is responsible for translating the native protocol of the UPS to the common format used by the rest of this package\&. .sp -The core has two modes of operation which are determined by the command line switches\&. In the normal mode, the driver will periodically poll the UPS for its state and parameters\&. The results of this command is presented to upsd\&. The driver will also handle setting variables and instant commands if available\&. +The core has three modes of operation which are determined by the command line switches\&. In the normal mode, the driver will periodically poll the UPS for its state and parameters, as per the \fBpollinterval\fR parameter in \fBups.conf\fR(5)\&. The results of this command are presented to upsd\&. The driver will also handle setting variables and instant commands if available\&. .sp -The driver can also instruct the UPS to shut down the load, possibly after some delay\&. This mode of operation is intended for cases when it is known that the UPS is running out of battery power and the systems attached must be turned off to ensure a proper reboot when power returns\&. +In the second mode, using \fB\-k\fR, the driver can instruct the UPS to shut down the load, possibly after some delay\&. This mode of operation is intended for cases when it is known that the UPS is running out of battery power and the systems attached must be turned off to ensure a proper reboot when power returns\&. +.sp +In the third mode, using \fB\-d\fR, the driver will exit after some update loops, dumping the data tree (in upsc\-like format) to stdout\&. This can be useful to complement the nut\-scanner to discover devices, along with in\-depth data\&. .if n \{\ .sp .\} @@ -79,13 +81,31 @@ section of \fBThis argument is mandatory when calling the driver directly\&.\fR .RE .PP +\fB\-s\fR \fIid\fR +.RS 4 +Configure this driver only with command line arguments instead of reading +\fBups.conf\fR(5)\&. To be used instead of +\fB\-a\fR +option when need to run a driver not present in driver configuration file\&. Instead, driver configuration have to be set with +\fB\-x\fR +options directly in the command line\&. As the driver instance cannot be controlled by +\fBupsdrvctl\fR(8), this option should be used for specific needs only\&. +.RE +.PP \fB\-D\fR .RS 4 -Raise the debugging level\&. Use this multiple times to see more details\&. Running a driver in debug mode will prevent it from backgrounding after startup\&. It will keep on logging information to the console until it receives a SIGINT (usually Ctrl\-C) or SIGTERM signal\&. +Raise the debugging level\&. Use this multiple times to see more details\&. Running a driver in debug mode will (by default) prevent it from backgrounding after startup\&. It will keep on logging information to the console until it receives a SIGINT (usually Ctrl\-C) or SIGTERM signal\&. .sp The level of debugging needed depends both on the driver and the problem you\(cqre trying to diagnose\&. Therefore, first explain the problem you have with a driver to a developer/maintainer, before sending them debugging output\&. More often than not, if you just pick a level, the output may be either too limited or too verbose to be of any use\&. .RE .PP +\fB\-d\fR \fIupdate_count\fR +.RS 4 +Dump the data tree (in upsc\-like format) to stdout after running the driver update loop for +\fIupdate_count\fR +times and exit\&. By default this prevents the driver process from backgrounding after startup\&. Note that the driver banner will be printed too, so when using this option in scripts, don\(cqt forget to trim the first line\&. +.RE +.PP \fB\-q\fR .RS 4 Raise log level threshold\&. Use this multiple times to log more details\&. @@ -93,9 +113,19 @@ Raise log level threshold\&. Use this multiple times to log more details\&. The debugging comment above also applies here\&. .RE .PP +\fB\-F\fR +.RS 4 +Enforce running the driver as a foreground process, regardless of debugging or data\-dumping settings\&. +.RE +.PP +\fB\-B\fR +.RS 4 +Enforce running the driver as a background process, regardless of debugging or data\-dumping settings\&. +.RE +.PP \fB\-i\fR \fIinterval\fR .RS 4 -Set the poll interval for the device\&. +Set the poll interval for the device\&. The default value is 2 (in seconds)\&. .RE .PP \fB\-V\fR @@ -105,7 +135,7 @@ Print only version information, then exit\&. .PP \fB\-L\fR .RS 4 -Print a parseable list of driver variables\&. Mostly useful for configuration wizard programs\&. +Print a parsable list of driver variables\&. Mostly useful for configuration wizard programs\&. .RE .PP \fB\-k\fR @@ -130,11 +160,27 @@ for this to work\&. The serial ports are opened before the chroot call, so you d .PP \fB\-u\fR \fIusername\fR .RS 4 -If started as root, the driver will setuid(2) to the user id associated with -\fIusername\fR\&. +Override the unprivileged username that the driver may use after startup\&. If started as root, after opening configuration files (and optionally calling chroot(2), as described in the previous option), the driver will look up +\fIusername\fR +in the +passwd +database, then change to the user and group identities associated with +\fIusername\fR\&. (If started with a nonzero UID or effective UID, the driver will silently ignore this option\&.) .sp -If you do not specify this value and start it as root, the driver will switch to the default value that was compiled into the code\&. This is typically -\fInobody\fR, and is far from ideal\&. +When compiling NUT from source, the default username is typically +nobody, and this may cause permission errors when the driver opens the UPS device node\&. You can use this option to temporarily override the defaults\&. For testing purposes, you can set this option to +root +to bypass permission errors, especially with USB\-based drivers\&. However, you will want to remove this option later in order to avoid permission conflicts between the driver and the unprivileged copy of +\fBupsd\fR(8)\&. +.RE +.PP +\fB\-g\fR \fIgroupname\fR +.RS 4 +Override the unprivileged group name that the driver may use after startup to set permissions for the filesystem socket so +upsd +may still access it if the run\-time +user +of the driver normally would deny that access\&. .RE .PP \fB\-x\fR \fIvar\fR=\fIval\fR @@ -164,19 +210,836 @@ ups\&.conf .RS 4 Required configuration file\&. This contains all details on which drivers to start and where the hardware is attached\&. .RE +.SH "ENVIRONMENT VARIABLES" +.sp +\fBNUT_CONFPATH\fR is the path name of the directory that contains upsd\&.conf and other configuration files\&. If this variable is not set, \fBupsd\fR uses a built\-in default, which is often /usr/local/ups/etc\&. +.sp +\fBNUT_STATEPATH\fR is the path name of the directory in which \fBupsd\fR keeps state information\&. If this variable is not set, \fBupsd\fR uses a built\-in default, which is often /var/state/ups\&. The \fBSTATEPATH\fR directive in \fBupsd.conf\fR(5) overrides this variable\&. +.sp +\fBNUT_ALTPIDPATH\fR is the path name of the directory in which \fBupsd\fR and drivers store \&.pid files\&. If this variable is not set, \fBupsd\fR and drivers use either \fBNUT_STATEPATH\fR if set, or ALTPIDPATH if set, or otherwise the built\-in default \fBSTATEPATH\fR\&. .SH "BUGS" .sp Some of the drivers may have bugs\&. See their manuals for more information\&. .SH "SEE ALSO" +.SS "Server:" .sp -Server: \fBupsd\fR(8) +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupsd\fR(8) +.RE +.SS "Clients:" .sp -Clients: \fBupsc\fR(8), \fBupscmd\fR(8), \fBupsrw\fR(8), \fBupslog\fR(8), \fBupsmon\fR(8) +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupsc\fR(8) +.RE .sp -CGI programs: \fBupsset.cgi\fR(8), \fBupsstats.cgi\fR(8), \fBupsimage.cgi\fR(8) +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupscmd\fR(8) +.RE .sp -Driver control: \fBupsdrvctl\fR(8) +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupsrw\fR(8) +.RE .sp -Drivers: \fBal175\fR(8) \fBapcsmart\fR(8), \fBbcmxcp\fR(8), \fBbcmxcp_usb\fR(8), \fBbelkin\fR(8), \fBbelkinunv\fR(8), \fBbestfcom\fR(8), \fBbestuferrups\fR(8), \fBbestups\fR(8), \fBblazer_ser\fR(8), \fBblazer_usb\fR(8), \fBcyberpower\fR(8), \fBdummy-ups\fR(8), \fBetapro\fR(8), \fBeverups\fR(8), \fBgamatronic\fR(8), \fBgenericups\fR(8), \fBisbmex\fR(8), \fBliebert\fR(8), \fBmasterguard\fR(8), \fBmetasys\fR(8), \fBmge-shut\fR(8), \fBmge-utalk\fR(8), \fBmge-xml\fR(8), \fBnewmge-shut\fR(8), \fBnitram\fR(8), \fBnutdrv_qx\fR(8), \fBoneac\fR(8), \fBoptiups\fR(8), \fBpowercom\fR(8), \fBpowerman-pdu\fR(8), \fBpowerpanel\fR(8), \fBrhino\fR(8), \fBrichcomm_usb\fR(8), \fBsafenet\fR(8), \fBsnmp-ups\fR(8), \fBsolis\fR(8), \fBtripplite\fR(8), \fBtripplitesu\fR(8), \fBtripplite_usb\fR(8), \fBusbhid-ups\fR(8), \fBupscode2\fR(8), \fBvictronups\fR(8) +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupslog\fR(8) +.RE .sp -Internet resources: The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupsmon\fR(8) +.RE +.SS "CGI programs:" +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupsset.cgi\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupsstats.cgi\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupsimage.cgi\fR(8) +.RE +.SS "Driver control:" +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBnut-driver-enumerator\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupsdrvctl\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupsdrvsvcctl\fR(8) +.RE +.SS "Drivers:" +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBadelsystem_cbi\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBal175\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBapcsmart-old\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBapcsmart\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBapcupsd-ups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBasem\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBbcmxcp\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBbcmxcp_usb\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBbelkin\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBbelkinunv\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBbestfcom\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBbestfortress\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBbestuferrups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBbestups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBblazer-common\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBblazer_ser\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBblazer_usb\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBclone\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBdummy-ups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBetapro\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBeverups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBgamatronic\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBgeneric_modbus\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBgenericups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBhuawei-ups2000\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBisbmex\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBivtscd\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBliebert-esp2\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBliebert\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBmacosx-ups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBmasterguard\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBmetasys\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBmge-shut\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBmge-utalk\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBmicrodowell\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBmicrosol-apc\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBnetxml-ups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBnut-ipmipsu\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBnutdrv_atcl_usb\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBnutdrv_qx\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBnutdrv_siemens_sitop\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBoneac\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBoptiups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBphoenixcontact_modbus\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBpijuice\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBpowercom\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBpowerman-pdu\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBpowerpanel\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBrhino\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBrichcomm_usb\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBriello_ser\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBriello_usb\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBsafenet\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBsnmp-ups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBsocomec_jbus\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBsolis\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBtripplite\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBtripplite_usb\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBtripplitesu\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupscode2\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBusbhid-ups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBvictronups\fR(8) +.RE +.SS "Internet resources:" +.sp +The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/nutupsdrv.txt b/docs/man/nutupsdrv.txt index 88878cd..01ddbf5 100644 --- a/docs/man/nutupsdrv.txt +++ b/docs/man/nutupsdrv.txt @@ -1,7 +1,7 @@ NUTUPSDRV(8) ============ -NAME +NAME ---- nutupsdrv - generic manual for unified NUT drivers @@ -27,16 +27,21 @@ hardware and the linkman:upsd[8] server. The driver is responsible for translating the native protocol of the UPS to the common format used by the rest of this package. -The core has two modes of operation which are determined by the +The core has three modes of operation which are determined by the command line switches. In the normal mode, the driver will periodically -poll the UPS for its state and parameters. The results of this command -is presented to upsd. The driver will also handle setting variables and -instant commands if available. +poll the UPS for its state and parameters, as per the *pollinterval* parameter +in linkman:ups.conf[5]. The results of this command are presented to upsd. +The driver will also handle setting variables and instant commands if available. -The driver can also instruct the UPS to shut down the load, possibly -after some delay. This mode of operation is intended for cases when it is -known that the UPS is running out of battery power and the systems -attached must be turned off to ensure a proper reboot when power returns. +In the second mode, using *-k*, the driver can instruct the UPS to shut down +the load, possibly after some delay. This mode of operation is intended for +cases when it is known that the UPS is running out of battery power and the +systems attached must be turned off to ensure a proper reboot when power +returns. + +In the third mode, using *-d*, the driver will exit after some update loops, +dumping the data tree (in upsc-like format) to stdout. This can be useful to +complement the nut-scanner to discover devices, along with in-depth data. NOTE: You probably don't want to use any of these options directly. You should use linkman:upsdrvctl[8] to control your drivers, and @@ -45,6 +50,7 @@ options and parameters that generally are not needed by normal users. OPTIONS ------- + *-h*:: Display a help message without doing anything else. This will also list possible values for '-x' in that driver, and other help text that the @@ -54,10 +60,18 @@ driver's author may have provided. Autoconfigure this driver using the 'id' section of linkman:ups.conf[5]. *This argument is mandatory when calling the driver directly.* +*-s* 'id':: +Configure this driver only with command line arguments instead of reading +linkman:ups.conf[5]. To be used instead of *-a* option when need to run +a driver not present in driver configuration file. Instead, driver +configuration have to be set with *-x* options directly in the command line. +As the driver instance cannot be controlled by linkman:upsdrvctl[8], +this option should be used for specific needs only. + *-D*:: Raise the debugging level. Use this multiple times to see more details. -Running a driver in debug mode will prevent it from backgrounding after -startup. It will keep on logging information to the console until it +Running a driver in debug mode will (by default) prevent it from backgrounding +after startup. It will keep on logging information to the console until it receives a SIGINT (usually Ctrl-C) or SIGTERM signal. + The level of debugging needed depends both on the driver and the @@ -66,19 +80,34 @@ have with a driver to a developer/maintainer, before sending them debugging output. More often than not, if you just pick a level, the output may be either too limited or too verbose to be of any use. +*-d* 'update_count':: +Dump the data tree (in upsc-like format) to stdout after running the driver +update loop for 'update_count' times and exit. +By default this prevents the driver process from backgrounding after startup. +Note that the driver banner will be printed too, so when using this option in +scripts, don't forget to trim the first line. + *-q*:: Raise log level threshold. Use this multiple times to log more details. + The debugging comment above also applies here. - + +*-F*:: +Enforce running the driver as a foreground process, regardless of debugging +or data-dumping settings. + +*-B*:: +Enforce running the driver as a background process, regardless of debugging +or data-dumping settings. + *-i* 'interval':: -Set the poll interval for the device. +Set the poll interval for the device. The default value is 2 (in seconds). *-V*:: Print only version information, then exit. *-L*:: -Print a parseable list of driver variables. Mostly useful for configuration +Print a parsable list of driver variables. Mostly useful for configuration wizard programs. *-k*:: @@ -98,17 +127,30 @@ opened before the chroot call, so you do not need to create them inside the jail. In fact, it is somewhat safer if you do not. *-u* 'username':: -If started as root, the driver will setuid(2) to the user id -associated with 'username'. +Override the unprivileged username that the driver may use after startup. If +started as root, after opening configuration files (and optionally calling +chroot(2), as described in the previous option), the driver will look up +'username' in the `passwd` database, then change to the user and group +identities associated with 'username'. (If started with a nonzero UID or +effective UID, the driver will silently ignore this option.) + -If you do not specify this value and start it as root, the driver will -switch to the default value that was compiled into the code. This is -typically 'nobody', and is far from ideal. +When compiling NUT from source, the default username is typically `nobody`, and +this may cause permission errors when the driver opens the UPS device node. You +can use this option to temporarily override the defaults. For testing purposes, +you can set this option to `root` to bypass permission errors, especially with +USB-based drivers. However, you will want to remove this option later in order +to avoid permission conflicts between the driver and the unprivileged copy of +linkman:upsd[8]. + +*-g* 'groupname':: +Override the unprivileged group name that the driver may use after startup +to set permissions for the filesystem socket so `upsd` may still access it +if the run-time `user` of the driver normally would deny that access. *-x* 'var'='val':: Define a variable called 'var' with the value of 'var' in the driver. This varies from driver to driver - see the specific man pages -for more information. +for more information. + This is like setting 'var'='val' in linkman:ups.conf[5], but *-x* overrides any settings from that file. @@ -130,10 +172,28 @@ production use. FILES ----- + ups.conf:: Required configuration file. This contains all details on which drivers to start and where the hardware is attached. +ENVIRONMENT VARIABLES +--------------------- + +*NUT_CONFPATH* is the path name of the directory that contains +`upsd.conf` and other configuration files. If this variable is not set, +*upsd* uses a built-in default, which is often `/usr/local/ups/etc`. + +*NUT_STATEPATH* is the path name of the directory in which +*upsd* keeps state information. If this variable is not set, +*upsd* uses a built-in default, which is often `/var/state/ups`. +The *STATEPATH* directive in linkman:upsd.conf[5] overrides this variable. + +*NUT_ALTPIDPATH* is the path name of the directory in which +*upsd* and drivers store .pid files. If this variable is not set, +*upsd* and drivers use either *NUT_STATEPATH* if set, or ALTPIDPATH if set, +or otherwise the built-in default *STATEPATH*. + BUGS ---- @@ -144,62 +204,37 @@ SEE ALSO -------- Server: -linkman:upsd[8] +~~~~~~~ + +- linkman:upsd[8] Clients: -linkman:upsc[8], linkman:upscmd[8], -linkman:upsrw[8], linkman:upslog[8], linkman:upsmon[8] +~~~~~~~~ + +- linkman:upsc[8] +- linkman:upscmd[8] +- linkman:upsrw[8] +- linkman:upslog[8] +- linkman:upsmon[8] CGI programs: -linkman:upsset.cgi[8], linkman:upsstats.cgi[8], linkman:upsimage.cgi[8] +~~~~~~~~~~~~~ + +- linkman:upsset.cgi[8] +- linkman:upsstats.cgi[8] +- linkman:upsimage.cgi[8] Driver control: -linkman:upsdrvctl[8] +~~~~~~~~~~~~~~~ + +include::{builddir}/linkman-drivertool-names.txt[] Drivers: -linkman:al175[8] -linkman:apcsmart[8], -linkman:bcmxcp[8], -linkman:bcmxcp_usb[8], -linkman:belkin[8], -linkman:belkinunv[8], -linkman:bestfcom[8], -linkman:bestuferrups[8], -linkman:bestups[8], -linkman:blazer_ser[8], -linkman:blazer_usb[8], -linkman:cyberpower[8], -linkman:dummy-ups[8], -linkman:etapro[8], -linkman:everups[8], -linkman:gamatronic[8], -linkman:genericups[8], -linkman:isbmex[8], -linkman:liebert[8], -linkman:masterguard[8], -linkman:metasys[8], -linkman:mge-shut[8], -linkman:mge-utalk[8], -linkman:mge-xml[8], -linkman:newmge-shut[8], -linkman:nitram[8], -linkman:nutdrv_qx[8], -linkman:oneac[8], -linkman:optiups[8], -linkman:powercom[8], -linkman:powerman-pdu[8], -linkman:powerpanel[8], -linkman:rhino[8], -linkman:richcomm_usb[8], -linkman:safenet[8], -linkman:snmp-ups[8], -linkman:solis[8], -linkman:tripplite[8], -linkman:tripplitesu[8], -linkman:tripplite_usb[8], -linkman:usbhid-ups[8], -linkman:upscode2[8], -linkman:victronups[8] +~~~~~~~~ + +include::{builddir}/linkman-driver-names.txt[] Internet resources: +~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/oneac.8 b/docs/man/oneac.8 index 3187817..8db799b 100644 --- a/docs/man/oneac.8 +++ b/docs/man/oneac.8 @@ -1,13 +1,13 @@ '\" t .\" Title: oneac -.\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [see the "AUTHORS" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "ONEAC" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "ONEAC" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -204,9 +204,29 @@ If your UPS supports writing battery\&.runtime\&.low, the new set value is to be If your UPS supports input\&.transfer\&.low and input\&.transfer\&.high, those values are used to create an allowable output range\&. The UPS will do what it can to keep the output voltage value within the defined range (for example: tap change or switch to inverter)\&. .sp .5v .RE -.SH "AUTHOR" +.SH "AUTHORS" .sp -Bill Elliot , Eric Lawson +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Bill Elliot +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Eric Lawson +.RE .SH "SEE ALSO" .SS "The core driver:" .sp diff --git a/docs/man/oneac.txt b/docs/man/oneac.txt index fe6c779..beb257e 100644 --- a/docs/man/oneac.txt +++ b/docs/man/oneac.txt @@ -28,6 +28,7 @@ linkman:genericups[8] driver. EXTRA ARGUMENTS --------------- + This driver supports the following optional settings in the linkman:ups.conf[5] file: @@ -39,6 +40,7 @@ Change shutdown delay time from 0 second default. INSTANT COMMANDS ---------------- + This driver supports the following Instant Commands. (See linkman:upscmd[8]) @@ -97,6 +99,7 @@ Mutes the UPS beeper/buzzer for the current alarm condition(s). Writable Variables ------------------ + See linkman:upsrw[8] to see what variables are writable for the UPS. NOTE: If your UPS supports writing battery.runtime.low, the new set value @@ -104,22 +107,25 @@ is to be entered in minutes (up to 99) but the reported value is reported in seconds (set value * 60). NOTE: If your UPS supports input.transfer.low and input.transfer.high, -those values are used to create an allowable output range. The UPS -will do what it can to keep the output voltage value within the +those values are used to create an allowable output range. The UPS +will do what it can to keep the output voltage value within the defined range (for example: tap change or switch to inverter). -AUTHOR ------- -Bill Elliot , -Eric Lawson +AUTHORS +------- + +* Bill Elliot +* Eric Lawson SEE ALSO -------- The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/optiups.8 b/docs/man/optiups.8 index 140e059..46e090d 100644 --- a/docs/man/optiups.8 +++ b/docs/man/optiups.8 @@ -1,13 +1,13 @@ '\" t .\" Title: optiups -.\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [see the "AUTHORS" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "OPTIUPS" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "OPTIUPS" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -86,9 +86,40 @@ Zinto D from ONLINE\-USV cannot be identified when switched to standby\&. Set th .SH "BUGS" .sp On the 420E, ups\&.serial and ups\&.temperature are unsupported features\&. This is not a bug in NUT or the NUT driver, just the way things are with this UPS\&. -.SH "AUTHOR" +.SH "AUTHORS" .sp -Russell Kroll, Scott Heavner, Matthias Goebl +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Russell Kroll +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Scott Heavner +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Matthias Goebl +.RE .SH "SEE ALSO" .SS "The core driver:" .sp diff --git a/docs/man/optiups.txt b/docs/man/optiups.txt index 25f7342..1e1d904 100644 --- a/docs/man/optiups.txt +++ b/docs/man/optiups.txt @@ -1,7 +1,7 @@ OPTIUPS(8) ========== -NAME +NAME ---- optiups - Driver for Opti-UPS (Viewsonic) UPS and Zinto D (ONLINE-USV) equipment @@ -10,7 +10,7 @@ NOTE ---- This man page only documents the hardware-specific features of the -optiups driver. For information about the core driver, see +optiups driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE @@ -56,13 +56,14 @@ sent to your system logs each time NUT polls the UPS. If you specify *fake_lowbatt*:: -This forces the low battery flag true. Without it, if you want to test your -UPS, you will have to unplug it and wait until the battery drops to a low/critical -voltage level before NUT will respond and power down your system. With the flag, -NUT should power down the system soon after you pull the plug. When you are done -testing, you should remove this flag. +This forces the low battery flag true. Without it, if you want to test +your UPS, you will have to unplug it and wait until the battery drops +to a low/critical voltage level before NUT will respond and power down +your system. With the flag, NUT should power down the system soon after +you pull the plug. When you are done testing, you should remove this flag. + -For basic shutdown configuration testing, the command 'upsmon -c fsd' is preferred. +For basic shutdown configuration testing, the command 'upsmon -c fsd' is +preferred. *powerup*:: @@ -73,20 +74,26 @@ This will also power-up your equipment connected to the UPS! BUGS ---- -On the 420E, `ups.serial` and `ups.temperature` are unsupported features. This -is not a bug in NUT or the NUT driver, just the way things are with this UPS. +On the 420E, `ups.serial` and `ups.temperature` are unsupported features. +This is not a bug in NUT or the NUT driver, just the way things are with +this UPS. -AUTHOR ------- -Russell Kroll, Scott Heavner, Matthias Goebl +AUTHORS +------- + +* Russell Kroll +* Scott Heavner +* Matthias Goebl SEE ALSO -------- The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/phoenixcontact_modbus.8 b/docs/man/phoenixcontact_modbus.8 new file mode 100644 index 0000000..c085453 --- /dev/null +++ b/docs/man/phoenixcontact_modbus.8 @@ -0,0 +1,254 @@ +'\" t +.\" Title: phoenixcontact_modbus +.\" Author: [see the "AUTHOR" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 +.\" Manual: NUT Manual +.\" Source: Network UPS Tools 2.8.0 +.\" Language: English +.\" +.TH "PHOENIXCONTACT_MODBU" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +phoenixcontact_modbus \- Driver for Phoenix Contact +.SH "SYNOPSIS" +.sp +\fBphoenixcontact_modbus\fR \-h +.sp +\fBphoenixcontact_modbus\fR \-a \fIDEVICE_NAME\fR [\fIOPTIONS\fR] +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +This man page only documents the hardware\-specific features of the phoenixcontact_modbus driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. +.sp .5v +.RE +.SH "SUPPORTED HARDWARE" +.sp +This driver should support the PhoenixContact QUINT\-UPS industrial DC UPS, model 2320461 and all compatible models\&. More information about this UPS can be found here: https://www\&.phoenixcontact\&.com/online/portal/us?uri=pxc\-oc\-itemdetail:pid=2320461 +.sp +phoenixcontact_modbus uses the libmodbus project, for Modbus implementation\&. +.SH "HOW TO CONFIGURE THE UPS" +.sp +Note: this UPS and its manual refers to Low\-Batt as "Shutdown Event"\&. +.sp +You need the "IFS\-RS232\-DATACABLE" to communicate with the UPS in Linux as the IFS\-USB cable doesn\(cqt seem to be supported\&. FYI communication parameters are: 115200,E,8,1\&. +.sp +You also need the UPS\-CONF Windows software (free; download from their site), to configure the UPS signals and timers\&. +.sp +.RS 4 +.ie n \{\ +\h'-04' 1.\h'+01'\c +.\} +.el \{\ +.sp -1 +.IP " 1." 4.2 +.\} +Run the UPS\-CONF +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04' 2.\h'+01'\c +.\} +.el \{\ +.sp -1 +.IP " 2." 4.2 +.\} +Go to Settings→Time Setting +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04' 3.\h'+01'\c +.\} +.el \{\ +.sp -1 +.IP " 3." 4.2 +.\} +Choose "state of charge shutdown delay" +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04' 4.\h'+01'\c +.\} +.el \{\ +.sp -1 +.IP " 4." 4.2 +.\} +Choose Remote starts PC\-Shutdown in Mains and Battery mode +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04' 5.\h'+01'\c +.\} +.el \{\ +.sp -1 +.IP " 5." 4.2 +.\} +On the PC\-Shutdown enter the maximum value (5 minutes) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04' 6.\h'+01'\c +.\} +.el \{\ +.sp -1 +.IP " 6." 4.2 +.\} +On the PC\-Restart delay enter the time you want the UPS to leave the output power off before restarting (e\&.g\&. 60 seconds), after mains power is restored\&. +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04' 7.\h'+01'\c +.\} +.el \{\ +.sp -1 +.IP " 7." 4.2 +.\} +On the UPS, turn the screw to the "PC\-MODE" position +.RE +.sp +Configuring the above way ensures that: +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +When power is lost, UPS constantly calculates remaining battery time +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +When remaining battery time is less than 5 minutes (PC\-Shutdown setting), it will raise the "Shutdown" event (seen as LOW\-BATT in NUT) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +From that moment even if input power is restored, the UPS will cut the output power to its load after 5 minutes +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +When the input power is restored, the UPS will restore output power after 60 seconds (PC\-RESTART delay setting)\&. +.RE +.sp +Meaning of settings: +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +PC\-Shutdown: How long before output cutoff the UPS will raise the "shutdown event" signal\&. Max value for this is 5 minutes\&. So PC should be able to shutdown within 5 minutes\&. +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +PC\-Restart: How long to delay output power after power is restored\&. Max is 60 seconds\&. +.RE +.SH "EXTRA ARGUMENTS" +.sp +This driver doesn\(cqt support any optional settings\&. +.SH "INSTALLATION" +.sp +This driver is not built by default\&. You can build it by installing libmodbus and running configure \-\-with\-modbus=yes\&. +.sp +You also need to give proper permissions on the local serial device file (/dev/ttyS0 for example) to allow the NUT user to access it\&. +.SH "INSTANT COMMANDS" +.sp +This driver doesn\(cqt support any instant commands\&. +.SH "AUTHOR" +.sp +Spiros Ioannou +.SH "SEE ALSO" +.SS "The core driver:" +.sp +\fBnutupsdrv\fR(8) +.SS "Internet resources:" +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The NUT (Network UPS Tools) home page: +http://www\&.networkupstools\&.org/ +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +libmodbus home page: +http://libmodbus\&.org +.RE diff --git a/docs/man/phoenixcontact_modbus.txt b/docs/man/phoenixcontact_modbus.txt new file mode 100644 index 0000000..e173089 --- /dev/null +++ b/docs/man/phoenixcontact_modbus.txt @@ -0,0 +1,107 @@ +PHOENIXCONTACT_MODBUS(8) +======================== + +NAME +---- + +phoenixcontact_modbus - Driver for Phoenix Contact + +SYNOPSIS +-------- + +*phoenixcontact_modbus* -h + +*phoenixcontact_modbus* -a 'DEVICE_NAME' ['OPTIONS'] + +NOTE: This man page only documents the hardware-specific features of the +phoenixcontact_modbus driver. For information about the core driver, see +linkman:nutupsdrv[8]. + +SUPPORTED HARDWARE +------------------ + +This driver should support the PhoenixContact QUINT-UPS industrial DC UPS, +model 2320461 and all compatible models. More information about this UPS +can be found here: +https://www.phoenixcontact.com/online/portal/us?uri=pxc-oc-itemdetail:pid=2320461 + +phoenixcontact_modbus uses the libmodbus project, for Modbus implementation. + +How to configure the UPS +------------------------ + +Note: this UPS and its manual refers to Low-Batt as "Shutdown Event". + +You need the "IFS-RS232-DATACABLE" to communicate with the UPS in Linux +as the IFS-USB cable doesn't seem to be supported. FYI communication +parameters are: 115200,E,8,1. + +You also need the UPS-CONF Windows software (free; download from their +site), to configure the UPS signals and timers. + +1. Run the UPS-CONF +2. Go to Settings->Time Setting +3. Choose "state of charge shutdown delay" +4. Choose Remote starts PC-Shutdown in Mains and Battery mode +5. On the PC-Shutdown enter the maximum value (5 minutes) +6. On the PC-Restart delay enter the time you want the UPS to leave + the output power off before restarting (e.g. 60 seconds), after + mains power is restored. +7. On the UPS, turn the screw to the "PC-MODE" position + +Configuring the above way ensures that: + + * When power is lost, UPS constantly calculates remaining battery time + * When remaining battery time is less than 5 minutes (PC-Shutdown setting), + it will raise the "Shutdown" event (seen as LOW-BATT in NUT) + * From that moment even if input power is restored, the UPS will cut the + output power to its load after 5 minutes + * When the input power is restored, the UPS will restore output power + after 60 seconds (PC-RESTART delay setting). + +Meaning of settings: + + * PC-Shutdown: How long before output cutoff the UPS will raise + the "shutdown event" signal. Max value for this is 5 minutes. + So PC should be able to shutdown within 5 minutes. + * PC-Restart: How long to delay output power after power is restored. + Max is 60 seconds. + + +EXTRA ARGUMENTS +--------------- + +This driver doesn't support any optional settings. + +INSTALLATION +------------ + +This driver is not built by default. You can build it by installing +libmodbus and running `configure --with-modbus=yes`. + +You also need to give proper permissions on the local serial device file +(/dev/ttyS0 for example) to allow the NUT user to access it. + +INSTANT COMMANDS +---------------- + +This driver doesn't support any instant commands. + +AUTHOR +------ + +Spiros Ioannou + +SEE ALSO +-------- + +The core driver: +~~~~~~~~~~~~~~~~ + +linkman:nutupsdrv[8] + +Internet resources: +~~~~~~~~~~~~~~~~~~~ + +* The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ +* libmodbus home page: http://libmodbus.org diff --git a/docs/man/pijuice.8 b/docs/man/pijuice.8 new file mode 100644 index 0000000..15af10a --- /dev/null +++ b/docs/man/pijuice.8 @@ -0,0 +1,167 @@ +'\" t +.\" Title: pijuice +.\" Author: [see the "AUTHORS" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 +.\" Manual: NUT Manual +.\" Source: Network UPS Tools 2.8.0 +.\" Language: English +.\" +.TH "PIJUICE" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +pijuice \- driver for UPS in PiJuice HAT +.SH "NOTE" +.sp +This man page only documents the hardware\-specific features of the \fBpijuice\fR driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +This manual page was hastily adapted from related asem driver manpage based on information from the original pull request, and so may not fully apply to PiJuice HAT, patches from experts are welcome\&. +.sp .5v +.RE +.SH "SUPPORTED HARDWARE" +.sp +The \fBpijuice\fR driver supports the portable PiJuice HAT UPS for Raspberry Pi embedded PCs\&. +.SH "EXTRA ARGUMENTS" +.sp +The required parameter for this driver is the I2C bus name: +.PP +\fBport\fR=\fIdev\-node\fR +.RS 4 +On the PiJuice HAT, this should be +/dev/i2c\-1\&. +.RE +.SH "INSTALLATION" +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +This section was copied from asem driver manpage and may not fully apply to PiJuice HAT, patches are welcome\&. +.sp .5v +.RE +.sp +This driver is specific to the Linux I2C API, and requires the lm_sensors libi2c\-dev or its equivalent to compile\&. +.sp +Beware that the SystemIO memory used by the I2C controller is reserved by ACPI\&. If only a native I2C driver (e\&.g\&. i2c_i801, as of 3\&.5\&.X Linux kernels) is available, then you\(cqll need to relax the ACPI resources check\&. For example, you can boot with the acpi_enforce_resources=lax option\&. +.SH "KNOWN ISSUES AND BUGS" +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +This section was copied from asem driver manpage and may not fully apply to PiJuice HAT, patches are welcome\&. +.sp .5v +.RE +.sp +The driver shutdown function is not implemented, so other arrangements must be made to turn off the UPS\&. +.SH "AUTHORS" +.sp +Andrew Anderson +.SH "SEE ALSO" +.SS "The core driver:" +.sp +\fBnutupsdrv\fR(8) +.SS "Internet resources:" +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Initial pull requests adding this driver: +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +https://github\&.com/networkupstools/nut/pull/730 +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +https://github\&.com/PiSupply/PiJuice/issues/124 +.RE +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Product home page: +https://uk\&.pi\-supply\&.com/products/pijuice\-standard +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The NUT (Network UPS Tools) home page: +http://www\&.networkupstools\&.org/ +.RE diff --git a/docs/man/pijuice.txt b/docs/man/pijuice.txt new file mode 100644 index 0000000..801646a --- /dev/null +++ b/docs/man/pijuice.txt @@ -0,0 +1,88 @@ +PIJUICE(8) +========== + +NAME +---- + +pijuice - driver for UPS in PiJuice HAT + +NOTE +---- + +This man page only documents the hardware-specific features of the +*pijuice* driver. For information about the core driver, see +linkman:nutupsdrv[8]. + +NOTE: This manual page was hastily adapted from related `asem` driver +manpage based on information from the original pull request, and so +may not fully apply to PiJuice HAT, patches from experts are welcome. + +SUPPORTED HARDWARE +------------------ + +The *pijuice* driver supports the portable PiJuice HAT UPS for Raspberry Pi +embedded PCs. + +EXTRA ARGUMENTS +--------------- + +The required parameter for this driver is the I2C bus name: + +*port*='dev-node':: +On the PiJuice HAT, this should be `/dev/i2c-1`. + +INSTALLATION +------------ + +NOTE: This section was copied from `asem` driver manpage and may not fully +apply to PiJuice HAT, patches are welcome. + +This driver is specific to the Linux I2C API, and requires the lm_sensors +libi2c-dev or its equivalent to compile. + +Beware that the SystemIO memory used by the I2C controller is reserved by ACPI. +If only a native I2C driver (e.g. i2c_i801, as of 3.5.X Linux kernels) is +available, then you'll need to relax the ACPI resources check. For example, you +can boot with the `acpi_enforce_resources=lax` option. + +////////////////////////////////////////// +Optional: use DIAGNOSTICS to describe troubleshooting techniques that are +longer than what can be conveniently described in the driver error messages. + +DIAGNOSTICS +----------- + +////////////////////////////////////////// + +KNOWN ISSUES AND BUGS +--------------------- + +NOTE: This section was copied from `asem` driver manpage and may not fully +apply to PiJuice HAT, patches are welcome. + +The driver shutdown function is not implemented, so other arrangements must be +made to turn off the UPS. + +AUTHORS +------- + +Andrew Anderson + +SEE ALSO +-------- + +The core driver: +~~~~~~~~~~~~~~~~ + +linkman:nutupsdrv[8] + +Internet resources: +~~~~~~~~~~~~~~~~~~~ + +* Initial pull requests adding this driver: +** https://github.com/networkupstools/nut/pull/730 +** https://github.com/PiSupply/PiJuice/issues/124 + +* Product home page: https://uk.pi-supply.com/products/pijuice-standard + +* The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/powercom.8 b/docs/man/powercom.8 index a90dfbe..9c5c801 100644 --- a/docs/man/powercom.8 +++ b/docs/man/powercom.8 @@ -1,13 +1,13 @@ '\" t .\" Title: powercom -.\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [see the "AUTHORS" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "POWERCOM" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "POWERCOM" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -129,6 +129,11 @@ or .RS 4 (Only for types KP625AP, Trust, Egys\&.) A quad that is used convert the raw voltage data to a human\-readable voltage reading using the function A*x+B\&. If the raw value x IS HALF the Voltage, then set A=2, B=0\&. The default is type\-dependent and is given below\&. Do note that the braces and commas are mandatory, as well as the lack of whitespace characters\&. .RE +.PP +\fBnobt\fR +.RS 4 +If this flag is present, the battery check on startup is skipped\&. This is useful for systems that tend to overload the UPS when testing the battery on system startup \(em just when the power consumption tends to be high\&. +.RE .SH "DEFAULT VALUES FOR THE EXTRA ARGUMENTS" .sp .if n \{\ @@ -274,9 +279,51 @@ shutdownArguments = {{1,30},y} .if n \{\ .RE .\} -.SH "AUTHOR" +.SH "AUTHORS" .sp -Peter Bieringer , Alexey Sidorov , Keven L\&. Ates +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Peter Bieringer +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Alexey Sidorov +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Keven L\&. Ates +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Rouben Tchakhmakhtchian +.RE .SH "SEE ALSO" .SS "The core driver:" .sp diff --git a/docs/man/powercom.txt b/docs/man/powercom.txt index 0657508..db7e936 100644 --- a/docs/man/powercom.txt +++ b/docs/man/powercom.txt @@ -1,19 +1,21 @@ POWERCOM(8) =========== -NAME +NAME ---- powercom - UPS driver for serial Powercom/Trust/Advice UPS equipment NOTE ---- + This man page only documents the hardware-specific features of the powercom driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + This driver supports many similar kinds of serial UPS hardware (as well as a few USB UPS models with USB-to-serial adapters). The most common ones are the Trust 425/625, Powercom, and Advice Partner/King PR750. Others using the same @@ -24,11 +26,12 @@ see the NUT Hardware Compatibility List (HCL). EXTRA ARGUMENTS --------------- -This driver supports the following optional settings in the + +This driver supports the following optional settings in the linkman:ups.conf[5] file: *linevoltage*='value':: -An integer specifying the line voltage. It can't be auto detected. Acceptable +An integer specifying the line voltage. It can't be auto detected. Acceptable values are in the range of 110-120 or 220-240. The default is '230'. *manufacturer*='name':: @@ -36,7 +39,7 @@ Specify the manufacturer name, which also can't be auto detected. This is a user defined string, so any name is acceptable. The default is 'PowerCom'. *modelname*='name':: -Specify the model name, which also can't be auto detected. This is a user +Specify the model name, which also can't be auto detected. This is a user defined string, so any name is acceptable. The default is 'Unknown'. *serialnumber*='value':: @@ -49,14 +52,14 @@ modelname that was coded with that protocol. The acceptable names are 'Trust', 'Egys', 'KP625AP', 'IMP', 'KIN', 'BNT', 'BNT-other' and 'OPTI'. The default is 'Trust'. + -'BNT-other' is a special type for other BNT models (such as the 1500A at 120V +'BNT-other' is a special type for other BNT models (such as the 1500A at 120V and can be used to override ALL models using ALL of the following values. *shutdownArguments*={{'minutes','seconds'},'whether_minutes_should_be_used'}:: -The minutes and seconds that the UPS should wait between receiving the +The minutes and seconds that the UPS should wait between receiving the shutdown command and actually shutting off. The other argument should be set -to the character 'n' only when the minutes value should be skipped and not -sent to the UPS. The default is type-dependent and is given below. The braces +to the character 'n' only when the minutes value should be skipped and not +sent to the UPS. The default is type-dependent and is given below. The braces and commas are mandatory. Note that there should be no whitespace characters. *numOfBytesFromUPS*='value':: @@ -65,13 +68,13 @@ is type-dependent and is given below. *methodOfFlowControl*='name':: The method of serial communication flow control that is engaged by the UPS. -The default is type-dependent and is given below. Acceptable names are +The default is type-dependent and is given below. Acceptable names are 'dtr0rts1', 'dtr1' or 'no_flow_control'. *validationSequence*={{'index1','value1'},{'index2','value2'},{'index3','value3'}}:: (Only for types KP625AP, Trust, Egys.) 3 pairs to be used for validating the UPS by comparing bytes of the raw data -with constant values. The index selects the byte from the UPS (see +with constant values. The index selects the byte from the UPS (see numOfBytesFromUPS) and the value is for matching to the byte. The default is type-dependent and is given below. The braces and commas are mandatory, as the lack of white space characters. @@ -80,7 +83,7 @@ the lack of white space characters. (Only for types KP625AP, Trust, Egys.) A pair to convert the raw frequency data to a human-readable frequency reading using the function 1/(A*x+B). If the raw value x IS the frequency, -then set A=1/(x^2) and B=0. The default is type-dependent and is given below. +then set A=1/(x^2) and B=0. The default is type-dependent and is given below. Do note that the braces and commas are mandatory as well, as the lack of whitespace characters. @@ -94,11 +97,11 @@ characters. *batteryPercentage*={'Battery1','Battery2','Battery3','Line4','Line5'}:: (Only for KP625AP, Trust, Egys.) -A 5 tuple to convert the raw battery and line data to a human-readable +A 5 tuple to convert the raw battery and line data to a human-readable battery and line percentage reading using the functions (Battery) A*x+B*y+C and (Line) D*x+E. If the raw value x IS the Battery Percent, then -set A=1, B=0, C=0, D=1, E=0. The default is type-dependent and is given below. -Do note that the braces and commas are mandatory, as the lack of white space +set A=1, B=0, C=0, D=1, E=0. The default is type-dependent and is given below. +Do note that the braces and commas are mandatory, as the lack of white space characters. *voltage*={'240A','240B','120A','120B'}:: @@ -109,8 +112,14 @@ then set A=2, B=0. The default is type-dependent and is given below. Do note that the braces and commas are mandatory, as well as the lack of whitespace characters. +*nobt*:: +If this flag is present, the battery check on startup is skipped. This is +useful for systems that tend to overload the UPS when testing the battery on +system startup -- just when the power consumption tends to be high. + DEFAULT VALUES FOR THE EXTRA ARGUMENTS -------------------------------------- + linevoltage = 230 manufacturer = PowerCom modelname = Unknown @@ -123,6 +132,7 @@ values for ALL models. Trust ~~~~~ + numOfBytesFromUPS = 11 methodOfFlowControl = dtr0rts1 validationSequence = {{5,0},{7,0},{8,0}} @@ -134,6 +144,7 @@ Trust KP625AP ~~~~~~~ + numOfBytesFromUPS = 16 methodOfFlowControl = dtr0rts1 validationSequence = {{5,0x80},{7,0},{8,0}} @@ -145,6 +156,7 @@ KP625AP Egys ~~~~ + numOfBytesFromUPS = 16 methodOfFlowControl = no_flow_control validationSequence = {{5,0x80},{7,0},{8,0}} @@ -156,6 +168,7 @@ Egys IMP ~~~ + numOfBytesFromUPS = 16 methodOfFlowControl = no_flow_control validationSequence = {{5,0xFF},{7,0},{8,0}} @@ -163,6 +176,7 @@ IMP KIN ~~~ + numOfBytesFromUPS = 16 methodOfFlowControl = no_flow_control validationSequence = {{11,0x4b},{8,0},{8,0}} @@ -170,6 +184,7 @@ KIN BNT ~~~ + numOfBytesFromUPS = 16 methodOfFlowControl = no_flow_control validationSequence = {{11,0x42},{8,0},{8,0}} @@ -177,6 +192,7 @@ BNT BNT-other ~~~~~~~~~ + numOfBytesFromUPS = 16 methodOfFlowControl = no_flow_control validationSequence = {{8,0},{8,0},{8,0}} @@ -188,24 +204,29 @@ BNT-other OPTI ~~~~ + numOfBytesFromUPS = 16 methodOfFlowControl = no_flow_control validationSequence = {{5,0xFF},{7,0},{8,0}} shutdownArguments = {{1,30},y} -AUTHOR ------- -Peter Bieringer , -Alexey Sidorov , -Keven L. Ates +AUTHORS +------- + +* Peter Bieringer +* Alexey Sidorov +* Keven L. Ates +* Rouben Tchakhmakhtchian SEE ALSO -------- The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/powerman-pdu.8 b/docs/man/powerman-pdu.8 index 6102f27..e0d59d5 100644 --- a/docs/man/powerman-pdu.8 +++ b/docs/man/powerman-pdu.8 @@ -1,13 +1,13 @@ '\" t .\" Title: powerman-pdu .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "POWERMAN\-PDU" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "POWERMAN\-PDU" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -108,6 +108,26 @@ Arnaud Quette \fBnutupsdrv\fR(8) .SS "Internet resources:" .sp -The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The NUT (Network UPS Tools) home page: +http://www\&.networkupstools\&.org/ +.RE .sp -The PowerMan home page: http://powerman\&.sourceforge\&.net/ +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The PowerMan home page: +https://github\&.com/chaos/powerman +.RE diff --git a/docs/man/powerman-pdu.txt b/docs/man/powerman-pdu.txt index a7b914d..0332ea6 100644 --- a/docs/man/powerman-pdu.txt +++ b/docs/man/powerman-pdu.txt @@ -1,4 +1,4 @@ -POWERMAN-PDU(8) +POWERMAN-PDU(8) =============== NAME @@ -38,6 +38,7 @@ This driver is not built by default. You can build it by using UPS COMMANDS ------------ + The following instant commands (see linkman:upscmd[8]) are available for each outlet of the PDU, with *X* standing for the outlet number: @@ -55,6 +56,7 @@ Cycle the outlet (power off then power on, possibly with a delay). IMPLEMENTATION -------------- + The hostname of the Powerman server is specified using the "port" value in *ups.conf*, i.e.: @@ -66,22 +68,26 @@ The port used to reach 'powermand' is optional if the default port is used. KNOWN ISSUES ------------ + In the current NUT version (2.4.1), ups.status is still exposed, with the value "WAIT". Some other values from the ups collection are also exposed. AUTHOR ------ + Arnaud Quette SEE ALSO -------- + The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ -The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ -The PowerMan home page: http://powerman.sourceforge.net/ +* The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ +* The PowerMan home page: https://github.com/chaos/powerman diff --git a/docs/man/powerpanel.8 b/docs/man/powerpanel.8 index baa7969..b10dffa 100644 --- a/docs/man/powerpanel.8 +++ b/docs/man/powerpanel.8 @@ -1,13 +1,13 @@ '\" t .\" Title: powerpanel .\" Author: [see the "AUTHORS" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "POWERPANEL" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "POWERPANEL" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -28,13 +28,15 @@ .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" -powerpanel \- Driver for PowerPanel Plus compatible UPS equipment +powerpanel \- Driver for serial PowerPanel Plus compatible UPS equipment .SH "NOTE" .sp This man page only documents the hardware\-specific features of the powerpanel driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. .SH "SUPPORTED HARDWARE" .sp This driver supports CyberPower BC1200, PR2200 and many other similar devices, both for the text and binary protocols\&. The driver will autodetect which protocol is used\&. +.sp +If your Cyber Power Systems UPS has a USB port, you may wish to use the \fBusbhid-ups\fR(8) driver\&. The \fBsnmp-ups\fR(8) driver supports several network cards via SNMP\&. .SH "EXTRA ARGUMENTS" .sp This driver supports the following optional settings in \fBups.conf\fR(5): @@ -167,6 +169,9 @@ Arjen de Korte , Doug Reynolds .SS "The core driver:" .sp \fBnutupsdrv\fR(8) +.SS "Other drivers:" +.sp +\fBusbhid-ups\fR(8), \fBsnmp-ups\fR(8) .SS "Internet resources:" .sp The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/powerpanel.txt b/docs/man/powerpanel.txt index 6ba2b6e..4e8450d 100644 --- a/docs/man/powerpanel.txt +++ b/docs/man/powerpanel.txt @@ -4,22 +4,29 @@ POWERPANEL(8) NAME ---- -powerpanel - Driver for PowerPanel Plus compatible UPS equipment +powerpanel - Driver for serial PowerPanel Plus compatible UPS equipment NOTE ---- + This man page only documents the hardware-specific features of the powerpanel driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + This driver supports CyberPower BC1200, PR2200 and many other similar devices, both for the text and binary protocols. The driver will autodetect which protocol is used. +If your Cyber Power Systems UPS has a USB port, you may wish to use the +linkman:usbhid-ups[8] driver. The linkman:snmp-ups[8] driver supports several +network cards via SNMP. + EXTRA ARGUMENTS --------------- + This driver supports the following optional settings in linkman:ups.conf[5]: *protocol=*['text,binary']:: @@ -47,6 +54,7 @@ seconds will be truncated to 6 seconds intervals, values above 60 seconds to VARIABLES --------- + Depending on the type of your UPS unit, some of the following variables may be changed with linkman:upsrw[8]. If the driver can't read a variable from the UPS, it will not be made available. @@ -68,6 +76,7 @@ writable: allow cold start from battery COMMANDS -------- + Depending on the type of your UPS unit, some of the following commands may be available. @@ -84,6 +93,7 @@ must verify that these work as expected (see <<_shutdown_issues,Shutdown Issues> SUPPORT STATUS -------------- + Vendor support is absent for this driver, so if you need some features that are currently not available, provide ample documentation on what the driver should sent to the UPS in order to make this work. If more information @@ -94,6 +104,7 @@ isn't willing to share this with us. SHUTDOWN ISSUES --------------- + If the *shutdown.return* command on your UPS doesn't seem to work, chances are that your UPS is an older model. Try a couple of different settings for 'offdelay'. If no value in the range 6..600 works, your @@ -110,6 +121,7 @@ supported through the text protocol are affected by this. KNOWN PROBLEMS -------------- + The CyberPower OP series don't offer direct voltage, charge, frequency and temperature readings. Instead, they will return a binary value that needs conversion to the actual value. @@ -124,6 +136,7 @@ instrument. AUTHORS ------- + Arjen de Korte , Doug Reynolds SEE ALSO @@ -131,8 +144,16 @@ SEE ALSO The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] +Other drivers: +~~~~~~~~~~~~~~ + +linkman:usbhid-ups[8], +linkman:snmp-ups[8] + Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/rhino.8 b/docs/man/rhino.8 index c1432dc..fd9eeba 100644 --- a/docs/man/rhino.8 +++ b/docs/man/rhino.8 @@ -1,13 +1,13 @@ '\" t .\" Title: rhino .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "RHINO" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "RHINO" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -34,7 +34,7 @@ rhino \- Driver for Brazilian Microsol RHINO UPS equipment This man page only documents the hardware\-specific features of the rhino driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. .SH "SUPPORTED HARDWARE" .sp -This driver has been tested with : +This driver has been tested with: .sp .RS 4 .ie n \{\ diff --git a/docs/man/rhino.txt b/docs/man/rhino.txt index e4638e2..bdb30f8 100644 --- a/docs/man/rhino.txt +++ b/docs/man/rhino.txt @@ -3,18 +3,21 @@ RHINO(8) NAME ---- + rhino - Driver for Brazilian Microsol RHINO UPS equipment NOTE ---- + This man page only documents the hardware-specific features of the rhino driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ -This driver has been tested with : - + +This driver has been tested with: + * Rhino 6000 VA * Rhino 7500 VA * Rhino 10000 VA @@ -45,6 +48,7 @@ COMMANDS AUTHOR ------ + Silvino B. Magalhães SEE ALSO @@ -52,8 +56,10 @@ SEE ALSO The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/richcomm_usb.8 b/docs/man/richcomm_usb.8 index 7d8e45c..5605e1b 100644 --- a/docs/man/richcomm_usb.8 +++ b/docs/man/richcomm_usb.8 @@ -1,13 +1,13 @@ '\" t .\" Title: richcomm_usb .\" Author: [see the "AUTHORS" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "RICHCOMM_USB" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "RICHCOMM_USB" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -37,12 +37,32 @@ This man page only documents the specific features of the richcomm_usb driver\&. The Richcomm dry\-contact to USB solution is a generic interface that is used to upgrade an existing (RS\-232) contact closure UPS interface to USB\&. As such, all the limitations of the underlying contact closure interface apply\&. This means that you will only get the essentials in ups\&.status: OL, OB, and LB\&. See also \fBgenericups\fR(8)\&. .SH "BUGS" .sp -Most contact\-closure UPSes will not power down the load if the line power is present\&. This can create a race when using slave \fBupsmon\fR(8) systems\&. See the \fBupsmon\fR(8) man page for more information\&. +Most contact\-closure UPSes will not power down the load if the line power is present\&. This can create a race when using secondary \fBupsmon\fR(8) systems\&. See the \fBupsmon\fR(8) man page for more information\&. .sp The solution to both of these problems is to upgrade to a smart protocol UPS of some kind that allows detection and proper load cycling on command\&. .SH "AUTHORS" .sp -Peter van Valderen , Dirk Teurlings +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Peter van Valderen +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Dirk Teurlings +.RE .SH "SEE ALSO" .SS "The core driver:" .sp diff --git a/docs/man/richcomm_usb.txt b/docs/man/richcomm_usb.txt index 3f52861..fe53b14 100644 --- a/docs/man/richcomm_usb.txt +++ b/docs/man/richcomm_usb.txt @@ -3,16 +3,19 @@ RICHCOMM_USB(8) NAME ---- + richcomm_usb - Driver UPS equipment using Richcomm dry-contact to USB solution NOTE ---- -This man page only documents the specific features of the richcomm_usb + +This man page only documents the specific features of the richcomm_usb driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + The Richcomm dry-contact to USB solution is a generic interface that is used to upgrade an existing (RS-232) contact closure UPS interface to USB. As such, all the limitations of the underlying contact closure interface @@ -21,30 +24,34 @@ OB, and LB. See also linkman:genericups[8]. BUGS ---- -Most contact-closure UPSes will not power down the load if the line power -is present. This can create a race when using slave linkman:upsmon[8] + +Most contact-closure UPSes will not power down the load if the line power +is present. This can create a race when using secondary linkman:upsmon[8] systems. See the linkman:upsmon[8] man page for more information. -The solution to both of these problems is to upgrade to a smart protocol +The solution to both of these problems is to upgrade to a smart protocol UPS of some kind that allows detection and proper load cycling on command. AUTHORS ------- -Peter van Valderen , -Dirk Teurlings +* Peter van Valderen +* Dirk Teurlings SEE ALSO -------- The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] The generic serial driver: ~~~~~~~~~~~~~~~~~~~~~~~~~~ + linkman:genericups[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/riello_ser.8 b/docs/man/riello_ser.8 index a8dcedc..d82d2bf 100644 --- a/docs/man/riello_ser.8 +++ b/docs/man/riello_ser.8 @@ -1,13 +1,13 @@ '\" t .\" Title: riello_ser .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "RIELLO_SER" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "RIELLO_SER" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/riello_ser.txt b/docs/man/riello_ser.txt index fddd5a5..cbc326b 100644 --- a/docs/man/riello_ser.txt +++ b/docs/man/riello_ser.txt @@ -1,5 +1,5 @@ -RIELLO_SER(8) -=========== +RIELLO_SER(8) +============= NAME ---- @@ -36,8 +36,10 @@ SEE ALSO The core driver ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources ~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/riello_usb.8 b/docs/man/riello_usb.8 index b3c64ed..4cbf52e 100644 --- a/docs/man/riello_usb.8 +++ b/docs/man/riello_usb.8 @@ -1,13 +1,13 @@ '\" t .\" Title: riello_usb .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "RIELLO_USB" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "RIELLO_USB" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/riello_usb.txt b/docs/man/riello_usb.txt index ced417a..1c4ffd6 100644 --- a/docs/man/riello_usb.txt +++ b/docs/man/riello_usb.txt @@ -1,5 +1,5 @@ -RIELLO_USB(8) -=========== +RIELLO_USB(8) +============= NAME ---- @@ -35,8 +35,10 @@ SEE ALSO The core driver ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources ~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/safenet.8 b/docs/man/safenet.8 index 1ef348b..da11c78 100644 --- a/docs/man/safenet.8 +++ b/docs/man/safenet.8 @@ -1,13 +1,13 @@ '\" t .\" Title: safenet .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "SAFENET" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "SAFENET" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -66,7 +66,7 @@ Time to wait before switching on the UPS (minutes)\&. Defaults to 1 minute\&. .RS 4 Time to wait before shutting down the UPS (seconds)\&. Defaults to 30 seconds\&. .RE -.SH "UPSCMD" +.SH "INSTANT COMMANDS" .sp This driver supports some instant commands (see \fBupscmd\fR(8)): .PP diff --git a/docs/man/safenet.txt b/docs/man/safenet.txt index f6f5a5a..00aa02f 100644 --- a/docs/man/safenet.txt +++ b/docs/man/safenet.txt @@ -3,21 +3,25 @@ SAFENET(8) NAME ---- + safenet - Driver for SafeNet compatible UPS equipment NOTE ---- + This man page only documents the hardware-specific features of the safenet driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + This driver supports UPS equipment which can be controlled via SafeNet v1.0 for Windows (serial interface only). EXTRA ARGUMENTS --------------- + This driver supports the following optional settings in the linkman:ups.conf[5] file: @@ -38,8 +42,9 @@ Time to wait before switching on the UPS (minutes). Defaults to 1 minute. *offdelay=*'value':: Time to wait before shutting down the UPS (seconds). Defaults to 30 seconds. -UPSCMD ------- +INSTANT COMMANDS +---------------- + This driver supports some instant commands (see linkman:upscmd[8]): *test.battery.start*:: @@ -73,6 +78,7 @@ and *ondelay*. KNOWN PROBLEMS -------------- + If you run the *shutdown.return* command with mains present, the output may stay on or switch off and not back on again. The *shutdown.reboot* command will unconditionally switch on the load again (with or without mains @@ -87,6 +93,7 @@ return when the power comes back. AUTHOR ------ + Arjen de Korte SEE ALSO @@ -94,8 +101,10 @@ SEE ALSO The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/skel.txt b/docs/man/skel.txt index 8bf885f..8e31094 100644 --- a/docs/man/skel.txt +++ b/docs/man/skel.txt @@ -3,10 +3,12 @@ SKEL(8) NAME ---- + skel - skeleton driver man page NOTE ---- + This man page only documents the hardware-specific features of the *skel* driver. For information about the core driver, see linkman:nutupsdrv[8]. @@ -15,7 +17,7 @@ linkman:nutupsdrv[8]. The following lines are comments. When copying this man page for your new driver, be sure to replace all -occurrances of "skel" and "SKEL" by your actual driver name. +occurrences of "skel" and "SKEL" by your actual driver name. If you have AsciiDoc installed, you can test the formatting of your man page by running: @@ -31,6 +33,7 @@ apropos(8) database is properly rebuilt. SUPPORTED HARDWARE ------------------ + *skel* supports ... ////////////////////////////////////////// @@ -44,11 +47,12 @@ CABLING EXTRA ARGUMENTS --------------- + This driver also supports the following optional settings: *option1*='num':: Set the value of ... to 'num'. Contrast with *option2*. - + *option2*='string':: Some other option. @@ -86,6 +90,7 @@ encountered when implementing the protocol for your UPS. KNOWN ISSUES AND BUGS --------------------- + *Got "EPERM: Operation not permitted" upon driver startup*:: You have forgotten to install the udev files, as explained @@ -100,6 +105,7 @@ some form of contact information so that users can report bugs. AUTHORS ------- + J Random User ////////////////////////////////////////// @@ -114,8 +120,10 @@ SEE ALSO The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/snmp-ups.8 b/docs/man/snmp-ups.8 index ceda716..b102ee4 100644 --- a/docs/man/snmp-ups.8 +++ b/docs/man/snmp-ups.8 @@ -1,13 +1,13 @@ '\" t .\" Title: snmp-ups .\" Author: [see the "AUTHORS" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "SNMP\-UPS" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "SNMP\-UPS" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -34,7 +34,7 @@ snmp-ups \- Multi\-MIB Driver for SNMP UPS equipment This man page only documents the hardware\-specific features of the snmp\-ups driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. .SH "SUPPORTED HARDWARE" .sp -The snmp\-ups driver automatically detects and supports a wide range of devices by loading various MIBS: +The snmp\-ups driver automatically detects and supports a wide range of devices by loading various MIBS, such as: .PP \fBietf\fR .RS 4 @@ -78,7 +78,12 @@ Eaton Powerware ePDU Managed .PP \fBraritan\fR .RS 4 -Various Raritan PDUs +Various Raritan PDUs (Dominion PX, PM, RPC) +.RE +.PP +\fBraritan\-px2\fR +.RS 4 +Various Raritan PDUs (Dominion PX2) .RE .PP \fBbaytech\fR @@ -100,18 +105,51 @@ Cyberpower RMCARD201\&. Should also support RMCARD100 (net version), RMCARD202 a .RS 4 Huawei UPS5000\-E, perhaps others .RE +.PP +\fBtripplite\fR +.RS 4 +TrippLite UPSes; at this time this is the IETF MIB mapping with just the Tripplite entry point OID to verify the device vendor, and a real hardware\-specific configuration will be added in the future development\&. +.RE +.sp +For a complete and up\-to\-date listing, you can query the driver by passing the \fBmibs=\-\-list\fR argument (see below)\&. .SH "EXTRA ARGUMENTS" .sp This driver supports the following optional settings in the \fBups.conf\fR(5): .PP +\fBport\fR=\fIhostname[:port]\fR +.RS 4 +Set SNMP hostname, or IP address, and port number of the peer SNMP agent\&. There is no default for the hostname, but the default port is 161\&. +.RE +.PP +\fBmibs\fR=\fI\-\-list\fR +.RS 4 +A special option which allows to list the currently known MIB\-to\-NUT mappings and exit the driver binary, intended for command\-line usage like this: +.RE +.sp +.if n \{\ +.RS 4 +.\} +.nf +$ snmp\-ups \-a snmp\-test \-x mibs=\-\-list +.fi +.if n \{\ +.RE +.\} +.PP \fBmibs\fR=\fIname\fR .RS 4 -Set MIB compliance (default=auto, allowed entries: refer to SUPPORTED HARDWARE above)\&. With "auto", the driver will try a select set of SNMP objects until it finds one that the device responds to\&. Note that since NUT 2\&.6\&.2, snmp\-ups has a new method that uses sysObjectID (which is a pointer to the prefered MIB of the device) to detect supported devices\&. This renders void the use of "mibs" option\&. +Set MIB compliance (default=auto, allowed entries: refer to SUPPORTED HARDWARE above)\&. +.sp +With "auto", the driver will try a select set of SNMP objects until it finds one that the device responds to\&. +.sp +Note that since NUT 2\&.6\&.2, snmp\-ups has a new method that uses sysObjectID (which is a pointer to the preferred MIB of the device) to detect supported devices\&. This renders void the +\fBrequirement\fR +to use the "mibs" option\&. .RE .PP \fBcommunity\fR=\fIname\fR .RS 4 -Set community name (default = public)\&. Note that a RW community name is required to change UPS settings (as for a powerdown)\&. +Set community name (default = public)\&. Note that a RW community name is required to change UPS settings and send commands (as for a powerdown)\&. .RE .PP \fBsnmp_version\fR=\fIversion\fR @@ -129,9 +167,15 @@ Specifies the number of Net\-SNMP retries to be used in the requests (default=5) Specifies the Net\-SNMP timeout in seconds between retries (default=1) .RE .PP -\fBpollfreq\fR=\fIvalue\fR +\fBsymmetrathreephase\fR .RS 4 -Set polling frequency in seconds, to reduce network flow (default=30) +Enable APCC three phase Symmetra quirks (use on APCC three phase Symmetras): Convert from three phase line\-to\-line voltage to line\-to\-neutral voltage (default: not enabled) +.RE +.PP +\fBpollfreq\fR=\fInum\fR +.RS 4 +Set polling interval for full updates, in seconds, to reduce SNMP network traffic relative to the quick updates performed every "pollinterval" (the latter option is described in +\fBups.conf\fR(5))\&. The default value is 30 (in seconds)\&. .RE .PP \fBnotransferoids\fR @@ -161,12 +205,16 @@ Set the privacy pass phrase used for encrypted SNMPv3 messages (no default) .PP \fBauthProtocol\fR=\fIvalue\fR .RS 4 -Set the authentication protocol (MD5 or SHA) used for authenticated SNMPv3 messages (default=MD5) +Set the authentication protocol (MD5, SHA, SHA256, SHA384 or SHA512) used for authenticated SNMPv3 messages (default=MD5)\&. Note that the exact protocol list depends on Net\-SNMP library capabilities; check help of the +snmp\-ups +binary program for the run\-time supported list\&. .RE .PP \fBprivProtocol\fR=\fIvalue\fR .RS 4 -Set the privacy protocol (DES or AES) used for encrypted SNMPv3 messages (default=DES) +Set the privacy protocol (DES, AES, AES192 or AES256) used for encrypted SNMPv3 messages (default=DES)\&. Note that the exact protocol list depends on Net\-SNMP library capabilities; check help of the +snmp\-ups +binary program for the run\-time supported list\&. .RE .SH "REQUIREMENTS" .sp @@ -182,51 +230,74 @@ The shutdown sequence should be tested before relying on NUT to send a shutdown This driver is only built if the Net\-SNMP development files are present at configuration time\&. You can also force it to be built by using configure \-\-with\-snmp=yes before calling make\&. .SH "EXAMPLES" .sp -The hostname of the UPS is specified with the "port" value in ups\&.conf: +The hostname of the UPS is specified with the "port" value in ups\&.conf, and may include a non\-standard (161) remote peer port: .sp .if n \{\ .RS 4 .\} .nf -[snmpv1] - driver = snmp\-ups - port = snmp\-ups\&.example\&.com - community = public - snmp_version = v1 - pollfreq = 15 - desc = "Example SNMP v1 device" -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -[snmpv3] - driver = snmp\-ups - port = 166\&.99\&.224\&.132 - snmp_version = v3 - secLevel = authPriv - secName = mysecurityname - authPassword = myauthenticationpassphrase - privPassword = myprivatepassphrase - desc = "Example SNMP v3 device, with the highest security level" + [snmpv1] + driver = snmp\-ups + port = snmp\-ups\&.example\&.com + community = public + snmp_version = v1 + pollfreq = 15 + desc = "Example SNMP v1 device" + + [snmpv3] + driver = snmp\-ups + port = 166\&.99\&.224\&.132:170 + snmp_version = v3 + secLevel = authPriv + secName = mysecurityname + authPassword = myauthenticationpassphrase + privPassword = myprivatepassphrase + desc = "Example SNMP v3 device, with the highest security level" .fi .if n \{\ .RE .\} .SH "AUTHORS" .sp -Arnaud Quette, Dmitry Frolov +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Arnaud Quette +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Dmitry Frolov +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Jim Klimov +.RE .SH "SEE ALSO" .SS "The core driver:" .sp \fBnutupsdrv\fR(8) .SS "NUT SNMP Protocols Library" .sp -Available at: http://www\&.networkupstools\&.org/protocols/snmp/ +Available at: http://www\&.networkupstools\&.org/ups\-protocols\&.html#_snmp .SS "Internet resources:" .sp The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/snmp-ups.txt b/docs/man/snmp-ups.txt index bdad553..f45462b 100644 --- a/docs/man/snmp-ups.txt +++ b/docs/man/snmp-ups.txt @@ -8,6 +8,7 @@ snmp-ups - Multi-MIB Driver for SNMP UPS equipment NOTE ---- + This man page only documents the hardware-specific features of the snmp-ups driver. For information about the core driver, see linkman:nutupsdrv[8]. @@ -15,16 +16,20 @@ linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ -The snmp-ups driver automatically detects and supports a wide range of devices by loading various MIBS: +The snmp-ups driver automatically detects and supports a wide range of +devices by loading various MIBS, such as: *ietf*:: -UPS that is RFC 1628 (UPS MIB) compliant, e.g. MGE UPS SYSTEMS, Liebert, perhaps others (default) +UPS that is RFC 1628 (UPS MIB) compliant, e.g. MGE UPS SYSTEMS, Liebert, +perhaps others (default) *mge*:: -MGE UPS SYSTEMS and MGE Office Protection Systems devices with SNMP cards (ref 66062, 66045, 66074 and 66244) +MGE UPS SYSTEMS and MGE Office Protection Systems devices with SNMP cards +(ref 66062, 66045, 66074 and 66244) *apcc*:: -APC AP9605, AP9606, AP9617, and AP9618 APC network management cards, as well as any others supporting the APC POWERNET MIB +APC AP9605, AP9606, AP9617, and AP9618 APC network management cards, +as well as any others supporting the APC POWERNET MIB *netvision*:: Socomec Sicon UPS with Netvision Web/SNMP management card/external box @@ -35,7 +40,6 @@ Powerware devices with ConnectUPS SNMP cards *pxgx_ups*:: Eaton devices with Power Xpert Gateway UPS Card - *aphel_genesisII*:: Eaton Powerware ePDU Monitored @@ -43,7 +47,10 @@ Eaton Powerware ePDU Monitored Eaton Powerware ePDU Managed *raritan*:: -Various Raritan PDUs +Various Raritan PDUs (Dominion PX, PM, RPC) + +*raritan-px2*:: +Various Raritan PDUs (Dominion PX2) *baytech*:: Various BayTech PDUs @@ -52,27 +59,52 @@ Various BayTech PDUs HP/Compaq AF401A management card, perhaps others *cyberpower*:: -Cyberpower RMCARD201. Should also support RMCARD100 (net version), RMCARD202 and RMCARD301 +Cyberpower RMCARD201. Should also support RMCARD100 (net version), +RMCARD202 and RMCARD301 *huawei*:: Huawei UPS5000-E, perhaps others +*tripplite*:: +TrippLite UPSes; at this time this is the IETF MIB mapping with just +the Tripplite entry point OID to verify the device vendor, and a real +hardware-specific configuration will be added in the future development. + +For a complete and up-to-date listing, you can query the driver by passing +the *mibs=--list* argument (see below). + EXTRA ARGUMENTS --------------- This driver supports the following optional settings in the linkman:ups.conf[5]: +*port*='hostname[:port]':: +Set SNMP hostname, or IP address, and port number of the peer SNMP agent. +There is no default for the hostname, but the default port is 161. + +*mibs*='--list':: +A special option which allows to list the currently known MIB-to-NUT mappings +and exit the driver binary, intended for command-line usage like this: +---- +$ snmp-ups -a snmp-test -x mibs=--list +---- + *mibs*='name':: -Set MIB compliance (default=auto, allowed entries: refer to SUPPORTED HARDWARE above). +Set MIB compliance (default=auto, allowed entries: refer to SUPPORTED +HARDWARE above). ++ With "auto", the driver will try a select set of SNMP objects until it finds -one that the device responds to. Note that since NUT 2.6.2, snmp-ups has a new -method that uses sysObjectID (which is a pointer to the prefered MIB of the -device) to detect supported devices. This renders void the use of "mibs" option. - +one that the device responds to. ++ +Note that since NUT 2.6.2, snmp-ups has a new method that uses sysObjectID +(which is a pointer to the preferred MIB of the device) to detect supported +devices. This renders void the *requirement* to use the "mibs" option. + *community*='name':: Set community name (default = public). -Note that a RW community name is required to change UPS settings (as for a powerdown). +Note that a RW community name is required to change UPS settings and +send commands (as for a powerdown). *snmp_version*='version':: Set SNMP version (default = v1, allowed: v2c, v3) @@ -83,8 +115,16 @@ Specifies the number of Net-SNMP retries to be used in the requests (default=5) *snmp_timeout*='timeout':: Specifies the Net-SNMP timeout in seconds between retries (default=1) -*pollfreq*='value':: -Set polling frequency in seconds, to reduce network flow (default=30) +*symmetrathreephase*:: +Enable APCC three phase Symmetra quirks (use on APCC three phase Symmetras): +Convert from three phase line-to-line voltage to line-to-neutral voltage +(default: not enabled) + +*pollfreq*='num':: +Set polling interval for full updates, in seconds, to reduce SNMP network +traffic relative to the quick updates performed every "pollinterval" (the +latter option is described in linkman:ups.conf[5]). +The default value is 30 (in seconds). *notransferoids*:: Disable the monitoring of the low and high voltage transfer OIDs in @@ -107,15 +147,20 @@ Set the authentication pass phrase used for authenticated SNMPv3 messages Set the privacy pass phrase used for encrypted SNMPv3 messages (no default) *authProtocol*='value':: -Set the authentication protocol (MD5 or SHA) used for authenticated SNMPv3 -messages (default=MD5) +Set the authentication protocol (MD5, SHA, SHA256, SHA384 or SHA512) used for +authenticated SNMPv3 messages (default=MD5). Note that the exact protocol list +depends on Net-SNMP library capabilities; check help of the `snmp-ups` binary +program for the run-time supported list. *privProtocol*='value':: -Set the privacy protocol (DES or AES) used for encrypted SNMPv3 messages -(default=DES) +Set the privacy protocol (DES, AES, AES192 or AES256) used for encrypted SNMPv3 +messages (default=DES). Note that the exact protocol list depends on Net-SNMP +library capabilities; check help of the `snmp-ups` binary program for the +run-time supported list. REQUIREMENTS ------------ + You will need to install the Net-SNMP package from http://www.net-snmp.org/ before building this driver. @@ -123,6 +168,7 @@ SNMP v3 also requires OpenSSL support from http://www.openssl.org. LIMITATIONS ----------- + Shutdown ~~~~~~~~ @@ -135,15 +181,18 @@ supported command. INSTALLATION ------------ + This driver is only built if the Net-SNMP development files are present at configuration time. You can also force it to be built by using +configure --with-snmp=yes+ before calling make. EXAMPLES -------- -The hostname of the UPS is specified with the "port" value in -`ups.conf`: +The hostname of the UPS is specified with the "port" value in +`ups.conf`, and may include a non-standard (161) remote peer port: + +------ [snmpv1] driver = snmp-ups port = snmp-ups.example.com @@ -154,30 +203,36 @@ The hostname of the UPS is specified with the "port" value in [snmpv3] driver = snmp-ups - port = 166.99.224.132 + port = 166.99.224.132:170 snmp_version = v3 secLevel = authPriv secName = mysecurityname authPassword = myauthenticationpassphrase privPassword = myprivatepassphrase desc = "Example SNMP v3 device, with the highest security level" +------ AUTHORS ------- -Arnaud Quette, Dmitry Frolov +* Arnaud Quette +* Dmitry Frolov +* Jim Klimov SEE ALSO -------- The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] NUT SNMP Protocols Library ~~~~~~~~~~~~~~~~~~~~~~~~~~ -Available at: http://www.networkupstools.org/protocols/snmp/ + +Available at: http://www.networkupstools.org/ups-protocols.html#_snmp Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/socomec_jbus.8 b/docs/man/socomec_jbus.8 new file mode 100644 index 0000000..624d94f --- /dev/null +++ b/docs/man/socomec_jbus.8 @@ -0,0 +1,196 @@ +'\" t +.\" Title: socomec_jbus +.\" Author: [see the "AUTHOR" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 +.\" Manual: NUT Manual +.\" Source: Network UPS Tools 2.8.0 +.\" Language: English +.\" +.TH "SOCOMEC_JBUS" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +socomec_jbus \- Driver for Socomec JBUS UPS with RS\-232 serial Modbus connection\&. +.SH "SYNOPSIS" +.sp +\fBsocomec_jbus\fR \-h +.sp +\fBsocomec_jbus\fR \-a \fIDEVICE_NAME\fR [\fIOPTIONS\fR] +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +This man page only documents the hardware\-specific features of the socomec_jbus driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. +.sp .5v +.RE +.SH "SUPPORTED HARDWARE" +.sp +This driver supports Socomec JBUS series, online (double conversion) UPS with the following characteristics\&. +.sp +.RS 4 +.ie n \{\ +\h'-04' 1.\h'+01'\c +.\} +.el \{\ +.sp -1 +.IP " 1." 4.2 +.\} +Single phase and 3\-phase UPS +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04' 2.\h'+01'\c +.\} +.el \{\ +.sp -1 +.IP " 2." 4.2 +.\} +Connection: RS\-232 +.RE +.sp +These are typically provided with a Netvision WEB/SNMP management card / external box that would be better served by the \fBsnmp-ups\fR(8) driver\&. In case netvision isn\(cqt available, you can hook up the UPS directly via the serial port and use this driver\&. +.sp +Currently, it has only been tested on the following model\&. +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +DIGYS 3/3 15kVA +.RE +.sp +In theory, any Socomec JBUS model should work\&. It should be discovered as \(lqUnknown Socomec JBUS\(rq with a numeric id that I\(cqll need to add it to the list of supported UPSs\&. +.sp +Sadly, Socomec document only mentions DELPHYS MX and DELPHYS MX elite and I have the id of my own DIGYS, so chances are, your model will not be recognized but will probably mostly work\&. Please report successful or unsuccessful results to the bug tracker or the mailing list\&. Make sure to include the full model number of your UPS manually in your report\&. +.sp +socomec_jbus uses the libmodbus project, for Modbus implementation\&. +.SH "CABLING" +.sp +The UPS has an RS\-232 port which should be connected with a NULL\-modem cable to a PC serial port\&. The UPS tested has a female DB9 connector, so if you construct the cable yourself, make note of the connector type to avoid using gender changers\&. +.sp +RS\-232 is supported on all operating systems, either via a built\-in serial port on your computer, or by using an external USB\-to\-RS\-232 converter\&. If you plan to use an USB\-to\-RS\-232 converter, make sure it\(cqs supported by your operating system\&. +.SH "INSTALLATION" +.sp +This driver should be built by default if libmodbus and development headers are available\&. You can force the configure script to build it with the following arguments: +.sp +.if n \{\ +.RS 4 +.\} +.nf +configure \-\-with\-serial=yes \-\-with\-modbus=yes +.fi +.if n \{\ +.RE +.\} +.sp +You also need to give proper (R/W) permissions on the local serial device file to allow the NUT driver run\-time user to access it\&. This may need additional setup for start\-up scripting, udev or upower rules, to apply the rights on every boot \(em especially if your device nodes are tracked by a virtual filesystem\&. +.sp +For example, a USB\-to\-serial converter can be identified as /dev/ttyACM0 or /dev/ttyUSB0 on Linux, or /dev/ttyU0 on FreeBSD (note the capital "U")\&. A built\-in serial port can be identified as /dev/ttyS0 on Linux or one of /dev/cua* names on FreeBSD\&. +.SH "INSTANT COMMANDS" +.sp +This driver does not (yet?) support sending commands to the UPS\&. +.SH "VARIABLES" +.sp +This driver does not support writable runtime variables (see \fBupsrw\fR(8)): for the same reasons\&. Both should be trivial to implement, but since I\(cqve already found one or two inconsistencies in the documentation, I\(cqm withholding from trying them\&. +.SH "KNOWN ISSUES AND BUGS" +.sp +Well, it is an alpha release at best, but so far appears to report the UPS status reliably\&. Mostly based on the work of Yifeng Li on the huawei\-ups2000 in that very same source tree\&. +.SS "Read failure on some JBUS addresses" +.sp +The driver polls all documented JBUS addresses and it is quite possible that your UPS model does not support one of them (e\&.g\&. the Digys does not support address 0x1020 which should provide the current UPS status)\&. This should be logged with LOG_ERR from modbus_read_input_registers() along with the address that produced the error\&. +.SS "Data stale" +.sp +Under certain circumstances, some registers can return invalid values and trigger a "data stale" error\&. Once a data stale error has occurred, you should see error messages similar to the example below in the system log\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf +socomec_jbus: modbus_read_input_registers(addr:XXXX, count:Z): + Illegal data address +upsd: Data for UPS [socomec] is stale \- check driver +upsd: UPS [socomec] data is no longer stale +.fi +.if n \{\ +.RE +.\} +.sp +So far all known problems have been fixed by the author, but an unknown one cannot be ruled out\&. If you have encountered "data stale" problems during normal uses, please file a bug report with full logs attached\&. +.sp +Before troubleshooting or reporting a problem, it\(cqs important to check your \fBdmesg\fR log for USB connect and disconnect events to avoid wasting time on the NUT driver when the actual problem is USB\&. For example, if someone yanks the cable out of the USB port, or if a new USB device is plugged into a USB host/hub that is struggling to power its ports (common on single\-board computers like Raspberry Pi), or if you have flaky cabling or EMI noise, the serial converter can get disconnected from USB, at least briefly\&. This creates a permanent data stale, the driver must be restarted (plugging the USB back won\(cqt fix it, since the driver is still using the nonexistent serial device)\&. These USB problems usually have nothing to do with NUT\&. If it\(cqs the case, you should solve the underlying USB problem \- check the cable, check the converter, try a powered USB hub, try a full\-speed USB isolator, etc\&. +.SH "AUTHOR" +.sp +Thanos Chatziathanassiou +.SH "SEE ALSO" +.SS "The core driver:" +.sp +\fBnutupsdrv\fR(8) +.SS "Internet resources:" +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The NUT (Network UPS Tools) home page: +http://www\&.networkupstools\&.org/ +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Socomec JBUS/Modbus Reference Guide: +https://www\&.socomec\&.com/files/live/sites/systemsite/files/GB\-JBUS\-MODBUS\-for\-Delphys\-MP\-and\-Delphys\-MX\-operating\-manual\&.pdf +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +libmodbus home page: +http://libmodbus\&.org +.RE diff --git a/docs/man/socomec_jbus.txt b/docs/man/socomec_jbus.txt new file mode 100644 index 0000000..bc192d6 --- /dev/null +++ b/docs/man/socomec_jbus.txt @@ -0,0 +1,166 @@ +SOCOMEC_JBUS(8) +=============== + +NAME +---- + +socomec_jbus - Driver for Socomec JBUS UPS with +RS-232 serial Modbus connection. + +SYNOPSIS +-------- + +*socomec_jbus* -h + +*socomec_jbus* -a 'DEVICE_NAME' ['OPTIONS'] + +NOTE: This man page only documents the hardware-specific features of the +socomec_jbus driver. For information about the core driver, see +linkman:nutupsdrv[8]. + +SUPPORTED HARDWARE +------------------ + +This driver supports Socomec JBUS series, online (double conversion) +UPS with the following characteristics. + +1. Single phase and 3-phase UPS + +2. Connection: RS-232 + +These are typically provided with a Netvision WEB/SNMP management +card / external box that would be better served by the linkman:snmp-ups[8] +driver. In case netvision isn't available, you can hook up the UPS directly +via the serial port and use this driver. + +Currently, it has only been tested on the following model. + +* DIGYS 3/3 15kVA + +In theory, any Socomec JBUS model should work. It should be discovered +as ``Unknown Socomec JBUS'' with a numeric id that I'll need to add it +to the list of supported UPSs. + +Sadly, Socomec document only mentions DELPHYS MX and DELPHYS MX elite and +I have the id of my own DIGYS, so chances are, your model will not be +recognized but will probably mostly work. Please report successful +or unsuccessful results to the bug tracker or the mailing list. +Make sure to include the full model number of your UPS manually +in your report. + +socomec_jbus uses the libmodbus project, for Modbus implementation. + +CABLING +------- + +The UPS has an RS-232 port which should be connected with a NULL-modem +cable to a PC serial port. The UPS tested has a female DB9 connector, +so if you construct the cable yourself, make note of the connector type to +avoid using gender changers. + +RS-232 is supported on all operating systems, either via a built-in serial +port on your computer, or by using an external USB-to-RS-232 converter. If +you plan to use an USB-to-RS-232 converter, make sure it's supported by your +operating system. + + +INSTALLATION +------------ + +This driver should be built by default if libmodbus and development headers +are available. You can force the `configure` script to build it with the +following arguments: + + configure --with-serial=yes --with-modbus=yes + +You also need to give proper (R/W) permissions on the local serial device +file to allow the NUT driver run-time user to access it. This may need +additional setup for start-up scripting, udev or upower rules, to apply +the rights on every boot -- especially if your device nodes are tracked +by a virtual filesystem. + +For example, a USB-to-serial converter can be identified as `/dev/ttyACM0` +or `/dev/ttyUSB0` on Linux, or `/dev/ttyU0` on FreeBSD (note the capital "U"). +A built-in serial port can be identified as `/dev/ttyS0` on Linux or one of +`/dev/cua*` names on FreeBSD. + +INSTANT COMMANDS +---------------- + +This driver does not (yet?) support sending commands to the UPS. + +VARIABLES +--------- + +This driver does not support writable runtime variables (see linkman:upsrw[8]): +for the same reasons. +Both should be trivial to implement, but since I've already found one or two +inconsistencies in the documentation, I'm withholding from trying them. + +KNOWN ISSUES AND BUGS +--------------------- + +Well, it is an alpha release at best, but so far appears to report the UPS +status reliably. Mostly based on the work of Yifeng Li on +the huawei-ups2000 in that very same source tree. + +Read failure on some JBUS addresses +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The driver polls all documented JBUS addresses and it is quite possible +that your UPS model does not support one of them (e.g. the Digys does not +support address 0x1020 which should provide the current UPS status). +This should be logged with LOG_ERR from modbus_read_input_registers() +along with the address that produced the error. + +Data stale +~~~~~~~~~~~ + +Under certain circumstances, some registers can return invalid values +and trigger a "data stale" error. Once a data stale error has occurred, +you should see error messages similar to the example below in the system +log. + + socomec_jbus: modbus_read_input_registers(addr:XXXX, count:Z): + Illegal data address + upsd: Data for UPS [socomec] is stale - check driver + upsd: UPS [socomec] data is no longer stale + +So far all known problems have been fixed by the author, but an unknown one +cannot be ruled out. If you have encountered "data stale" problems during +normal uses, please file a bug report with full logs attached. + +Before troubleshooting or reporting a problem, it's important to check +your *dmesg* log for USB connect and disconnect events to avoid wasting +time on the NUT driver when the actual problem is USB. For example, if +someone yanks the cable out of the USB port, or if a new USB device is +plugged into a USB host/hub that is struggling to power its ports +(common on single-board computers like Raspberry Pi), or if you have +flaky cabling or EMI noise, the serial converter can get disconnected +from USB, at least briefly. This creates a permanent data stale, the driver +must be restarted (plugging the USB back won't fix it, since the driver +is still using the nonexistent serial device). These USB problems usually +have nothing to do with NUT. If it's the case, you should solve the +underlying USB problem - check the cable, check the converter, try a +powered USB hub, try a full-speed USB isolator, etc. + +AUTHOR +------ + +Thanos Chatziathanassiou + +SEE ALSO +-------- + +The core driver: +~~~~~~~~~~~~~~~~ + +linkman:nutupsdrv[8] + +Internet resources: +~~~~~~~~~~~~~~~~~~~ + +* The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ +* Socomec JBUS/Modbus Reference Guide: + https://www.socomec.com/files/live/sites/systemsite/files/GB-JBUS-MODBUS-for-Delphys-MP-and-Delphys-MX-operating-manual.pdf +* libmodbus home page: http://libmodbus.org diff --git a/docs/man/solis.8 b/docs/man/solis.8 index 0893cd1..887f55c 100644 --- a/docs/man/solis.8 +++ b/docs/man/solis.8 @@ -1,13 +1,13 @@ '\" t .\" Title: solis .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "SOLIS" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "SOLIS" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -34,7 +34,7 @@ solis \- Driver for Brazilian Microsol SOLIS UPS equipment This man page only documents the hardware\-specific features of the solis driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. .SH "SUPPORTED HARDWARE" .sp -This driver has been tested with : +This driver has been tested with: .sp .RS 4 .ie n \{\ @@ -111,7 +111,7 @@ This driver support the following extra optional settings in the \fBups.conf\fR( .sp \fBbattext = n\fR \- (default = 0, no extra battery, where n = Ampere*hour ) .sp -\fBprgshut = 1\fR \- (default = 0, no programable shutdown ) +\fBprgshut = 1\fR \- (default = 0, no programmable shutdown ) .SH "COMMANDS" .sp .RS 4 diff --git a/docs/man/solis.txt b/docs/man/solis.txt index d009b60..532112b 100644 --- a/docs/man/solis.txt +++ b/docs/man/solis.txt @@ -15,8 +15,9 @@ linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ -This driver has been tested with : - + +This driver has been tested with: + * Solis 1000 VA * Solis 1500 VA * Solis 2000 VA @@ -37,7 +38,7 @@ linkman:ups.conf[5]. *battext = n* - (default = 0, no extra battery, where n = Ampere*hour ) -*prgshut = 1* - (default = 0, no programable shutdown ) +*prgshut = 1* - (default = 0, no programmable shutdown ) COMMANDS -------- @@ -55,6 +56,7 @@ connect to the UPS, but some values are read incorrectly. AUTHOR ------ + Silvino B. Magalhães SEE ALSO @@ -62,8 +64,10 @@ SEE ALSO The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/tripplite.8 b/docs/man/tripplite.8 index 65338cf..4a802dd 100644 --- a/docs/man/tripplite.8 +++ b/docs/man/tripplite.8 @@ -1,13 +1,13 @@ '\" t .\" Title: tripplite .\" Author: [see the "AUTHORS" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "TRIPPLITE" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "TRIPPLITE" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -58,7 +58,27 @@ Set the time that the UPS waits before it turns itself back on after a reboot co Battery charge information may not be correct for all UPSes\&. It is tuned to be correct for a SMART700SER\&. Other models may not provide correct information\&. Information from the manufacturer would be helpful\&. .SH "AUTHORS" .sp -Rickard E\&. (Rik) Faith, Nicholas Kain +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Rickard E\&. (Rik) Faith +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Nicholas Kain +.RE .SH "SEE ALSO" .SS "The core driver:" .sp diff --git a/docs/man/tripplite.txt b/docs/man/tripplite.txt index dc6f1c8..9ec37f2 100644 --- a/docs/man/tripplite.txt +++ b/docs/man/tripplite.txt @@ -3,23 +3,27 @@ TRIPPLITE(8) NAME ---- + tripplite - Driver for Tripp-Lite SmartPro UPS equipment NOTE ---- + This man page only documents the hardware-specific features of the tripplite driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + This driver should work on the SmartPro line, including the SMART700 and SMART700SER. It only supports SmartPro models that communicate using the serial port. EXTRA ARGUMENTS --------------- -This driver supports the following optional settings in the + +This driver supports the following optional settings in the linkman:ups.conf[5]: *offdelay*='num':: @@ -36,25 +40,31 @@ reboot command. The default value is 60 (in seconds). KNOWN ISSUES AND BUGS --------------------- + Battery charge information may not be correct for all UPSes. It is tuned to be correct for a SMART700SER. Other models may not provide correct information. Information from the manufacturer would be helpful. AUTHORS ------- -Rickard E. (Rik) Faith, Nicholas Kain + +* Rickard E. (Rik) Faith +* Nicholas Kain SEE ALSO -------- The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Other drivers for Tripp-Lite hardware: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + linkman:tripplitesu[8], linkman:tripplite_usb[8], linkman:usbhid-ups[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/tripplite_usb.8 b/docs/man/tripplite_usb.8 index 86714da..68efb1d 100644 --- a/docs/man/tripplite_usb.8 +++ b/docs/man/tripplite_usb.8 @@ -1,13 +1,13 @@ '\" t .\" Title: tripplite_usb -.\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [see the "AUTHORS" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "TRIPPLITE_USB" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "TRIPPLITE_USB" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -36,7 +36,11 @@ tripplite_usb \- Driver for older Tripp Lite USB UPSes (not PDC HID) \fBtripplite_usb\fR \-a \fIUPS_NAME\fR [\fIOPTIONS\fR] .SH "SUPPORTED HARDWARE" .sp -This driver should work with older Tripp Lite UPSes which are detected as USB HID\-class devices, but are not true HID Power\-Device Class devices\&. So far, the devices supported by tripplite_usb have product ID 0001, and the newer units (such as those with "LCD" in the model name) with product ID 2001 require the \fBusbhid-ups\fR(8) driver instead\&. Please report success or failure to the nut\-upsuser mailing list\&. A key piece of information is the protocol number, returned in ups\&.debug\&.0\&. Also, be sure to turn on debugging (\fI\-DDD\fR) for more informative log messages\&. If your Tripp Lite UPS uses a serial port, you may wish to investigate the \fBtripplite\fR(8) or \fBtripplite_su\fR(8) driver\&. +This driver should work with older Tripp Lite UPSes which are detected as USB HID\-class devices, but are not true HID Power\-Device Class devices\&. So far, the devices supported by tripplite_usb have product ID 0001, and the newer units (such as those with "LCD" in the model name) with product ID 2001 require the \fBusbhid-ups\fR(8) driver instead\&. +.sp +Please report success or failure to the nut\-upsuser mailing list\&. A key piece of information is the protocol number, returned in ups\&.firmware\&.aux\&. Also, be sure to turn on debugging (\fI\-DDD\fR) for more informative log messages\&. +.sp +If your Tripp Lite UPS uses a serial port, you may wish to investigate the \fBtripplite\fR(8) or \fBtripplitesu\fR(8) drivers\&. .sp This driver has been tested with the following models: .sp @@ -163,6 +167,17 @@ Protocol 2001 Protocol 3003 .RE .sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Protocol 3005 +.RE +.sp On the other hand, if the web page for your UPS on the Tripp\-Lite website says "HID\-compliant USB port also enables direct integration with built\-in power management and auto\-shutdown features of Windows and MAC OS X", then you should use the \fBusbhid-ups\fR(8) driver instead\&. .SH "EXTRA ARGUMENTS" .sp @@ -186,6 +201,13 @@ This regular expression is used to match the USB bus (as seen in or lsusb(8); including leading zeroes)\&. .RE .PP +\fBdevice\fR +.RS 4 +This regular expression is used to match the USB device (as seen in +/proc/bus/usb/devices +or lsusb(8); including leading zeroes)\&. Note that device numbers are not guaranteed by the OS to be stable across re\-boots or device re\-plugging\&. +.RE +.PP \fBproduct\fR .RS 4 A regular expression to match the product string for the UPS\&. This would be useful if you have two different Tripp Lite UPS models connected to the system, and you want to be sure that you shut them down in the correct order\&. @@ -253,14 +275,16 @@ in the variable name\&. Be sure to test this first \- there is no other way to b .sp The driver was not developed with any official documentation from Tripp Lite, so certain events may confuse the driver\&. If you observe any strange behavior, please re\-run the driver with \-DDD to increase the verbosity\&. .sp -So far, the Tripp Lite UPSes do not seem to have a serial number or other globally unique identifier accessible through USB\&. Thus, when monitoring several Tripp Lite USB UPSes, you should use either the \fIbus\fR or \fIproduct\fR configuration options to uniquely specify which UPS a given driver instance should control\&. +So far, the Tripp Lite UPSes do not seem to have a serial number or other globally unique identifier accessible through USB\&. Thus, when monitoring several Tripp Lite USB UPSes, you should use either the \fIbus\fR, \fIdevice\fR or \fIproduct\fR configuration options to uniquely specify which UPS a given driver instance should control\&. .sp -For instance, you can easily monitor an OMNIVS1000 and a SMART1500RM2U at the same time, since they have different USB Product ID strings\&. If you have two SMART1500RM2U units, you would have to find which USB bus number each unit is on (via lsusb(8)), which may result in ambiguities if the available USB ports are on the same bus\&. +For instance, you can easily monitor an OMNIVS1000 and a SMART1500RM2U at the same time, since they have different USB Product ID strings\&. If you have two SMART1500RM2U units, you would have to find which USB bus and device number each unit is on (via lsusb(8))\&. .sp Some of the SMART*2U models have an ID number, but because this ID is not exposed as a USB string descriptor, there is no easy way to use this ID to distinguish between multiple UPS units on a single machine\&. The UPS would need to be claimed by the driver in order to read this ID\&. -.SH "AUTHOR" +.SH "AUTHORS" .sp -Written by Charles Lepple, based on the \fBtripplite\fR(8) driver by Rickard E\&. (Rik) Faith and Nicholas Kain\&. Please do not email the authors directly \- use the nut\-upsdev mailing list\&. +Written by Charles Lepple, based on the \fBtripplite\fR(8) driver by Rickard E\&. (Rik) Faith and Nicholas Kain\&. +.sp +Please do not email the authors directly \- use the nut\-upsdev mailing list\&. .sp A Tripp Lite OMNIVS1000 was graciously donated to the NUT project by Bradley Feldman (http://www\&.bradleyloritheo\&.com) .SH "SEE ALSO" @@ -273,6 +297,6 @@ A Tripp Lite OMNIVS1000 was graciously donated to the NUT project by Bradley Fel .SS "Other tools:" .sp regex(7), lsusb(8) -.SH "INTERNET RESOURCES" +.SS "Internet resources:" .sp The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/tripplite_usb.txt b/docs/man/tripplite_usb.txt index 1d67caa..cad5a80 100644 --- a/docs/man/tripplite_usb.txt +++ b/docs/man/tripplite_usb.txt @@ -1,29 +1,34 @@ TRIPPLITE_USB(8) ================ - NAME ---- + tripplite_usb - Driver for older Tripp Lite USB UPSes (not PDC HID) SYNOPSIS -------- + *tripplite_usb* -h *tripplite_usb* -a 'UPS_NAME' ['OPTIONS'] SUPPORTED HARDWARE ------------------ -This driver should work with older Tripp Lite UPSes which are detected as USB -HID-class devices, but are not true HID Power-Device Class devices. So far, -the devices supported by tripplite_usb have product ID 0001, and the newer -units (such as those with "LCD" in the model name) with product ID 2001 require -the linkman:usbhid-ups[8] driver instead. Please report success or failure to -the nut-upsuser mailing list. A key piece of information is the protocol -number, returned in `ups.debug.0`. Also, be sure to turn on debugging ('-DDD') -for more informative log messages. If your Tripp Lite UPS uses a serial port, -you may wish to investigate the linkman:tripplite[8] or linkman:tripplite_su[8] -driver. + +This driver should work with older Tripp Lite UPSes which are detected +as USB HID-class devices, but are not true HID Power-Device Class devices. +So far, the devices supported by `tripplite_usb` have product ID 0001, +and the newer units (such as those with "LCD" in the model name) with +product ID 2001 require the linkman:usbhid-ups[8] driver instead. + +Please report success or failure to the nut-upsuser mailing list. +A key piece of information is the protocol number, returned in +`ups.firmware.aux`. Also, be sure to turn on debugging ('-DDD') +for more informative log messages. + +If your Tripp Lite UPS uses a serial port, you may wish to investigate +the linkman:tripplite[8] or linkman:tripplitesu[8] drivers. This driver has been tested with the following models: @@ -43,6 +48,7 @@ following protocols: * Protocol 1001 * Protocol 2001 * Protocol 3003 + * Protocol 3005 On the other hand, if the web page for your UPS on the Tripp-Lite website says "HID-compliant USB port also enables direct integration with built-in power @@ -74,6 +80,13 @@ problems. This regular expression is used to match the USB bus (as seen in `/proc/bus/usb/devices` or lsusb(8); including leading zeroes). +*device*:: + +This regular expression is used to match the USB device (as seen in +`/proc/bus/usb/devices` or lsusb(8); including leading zeroes). +Note that device numbers are not guaranteed by the OS to be stable across +re-boots or device re-plugging. + *product*:: A regular expression to match the product string for the UPS. This would be @@ -130,26 +143,27 @@ please re-run the driver with `-DDD` to increase the verbosity. So far, the Tripp Lite UPSes do not seem to have a serial number or other globally unique identifier accessible through USB. Thus, when monitoring -several Tripp Lite USB UPSes, you should use either the 'bus' or 'product' -configuration options to uniquely specify which UPS a given driver instance -should control. +several Tripp Lite USB UPSes, you should use either the 'bus', 'device' or +'product' configuration options to uniquely specify which UPS a given driver +instance should control. For instance, you can easily monitor an OMNIVS1000 and a SMART1500RM2U at the same time, since they have different USB Product ID strings. If you have two -SMART1500RM2U units, you would have to find which USB bus number each unit is -on (via lsusb(8)), which may result in ambiguities if the available USB ports -are on the same bus. +SMART1500RM2U units, you would have to find which USB bus and device number +each unit is on (via lsusb(8)). Some of the SMART*2U models have an ID number, but because this ID is not exposed as a USB string descriptor, there is no easy way to use this ID to distinguish between multiple UPS units on a single machine. The UPS would need to be claimed by the driver in order to read this ID. -AUTHOR ------- -Written by Charles Lepple, based on the linkman:tripplite[8] driver by Rickard E. (Rik) -Faith and Nicholas Kain. Please do not email the authors directly - use the -nut-upsdev mailing list. +AUTHORS +------- + +Written by Charles Lepple, based on the linkman:tripplite[8] driver +by Rickard E. (Rik) Faith and Nicholas Kain. + +Please do not email the authors directly - use the nut-upsdev mailing list. A Tripp Lite OMNIVS1000 was graciously donated to the NUT project by Bradley Feldman (http://www.bradleyloritheo.com) @@ -159,19 +173,20 @@ SEE ALSO The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Other drivers for Tripp-Lite hardware: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + linkman:tripplite[8], linkman:tripplitesu[8], linkman:usbhid-ups[8] Other tools: ~~~~~~~~~~~~ + regex(7), lsusb(8) - -INTERNET RESOURCES ------------------- +Internet resources: +~~~~~~~~~~~~~~~~~~~ The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ - diff --git a/docs/man/tripplitesu.8 b/docs/man/tripplitesu.8 index da3f79e..7e93983 100644 --- a/docs/man/tripplitesu.8 +++ b/docs/man/tripplitesu.8 @@ -1,13 +1,13 @@ '\" t .\" Title: tripplitesu .\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "TRIPPLITESU" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "TRIPPLITESU" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/tripplitesu.txt b/docs/man/tripplitesu.txt index 6416699..9194a12 100644 --- a/docs/man/tripplitesu.txt +++ b/docs/man/tripplitesu.txt @@ -3,20 +3,24 @@ TRIPPLITESU(8) NAME ---- + tripplitesu - Driver for Tripp-Lite SmartOnline (SU) UPS equipment NOTE ---- + This man page only documents the hardware-specific features of the tripplitesu driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + This driver supports the Tripp Lite SmartOnline family (via the serial port). EXTRA ARGUMENTS --------------- + This driver supports the following optional settings in the linkman:ups.conf[5]: @@ -27,6 +31,7 @@ until there are only a few seconds left. Common values are around 25--30. AUTHOR ------ + Allan N. Hessenflow SEE ALSO @@ -34,12 +39,15 @@ SEE ALSO The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Other drivers for Tripp-Lite hardware: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + linkman:tripplite[8], linkman:tripplite_usb[8], linkman:usbhid-ups[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/ups.conf.5 b/docs/man/ups.conf.5 index f76c73a..e75338b 100644 --- a/docs/man/ups.conf.5 +++ b/docs/man/ups.conf.5 @@ -1,13 +1,13 @@ '\" t .\" Title: ups.conf -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPS\&.CONF" "5" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPS\&.CONF" "5" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -94,6 +94,13 @@ is inserted between each attempt\&. Caution should be taken when using this opti The default is 1 attempt\&. .RE .PP +\fBnowait\fR +.RS 4 +Optional\&. Specify to upsdrvctl to not wait at all for the driver(s) to execute the request command\&. +.sp +The default (omission) is to wait\&. +.RE +.PP \fBretrydelay\fR .RS 4 Optional\&. Specify the delay between each restart attempt of the driver(s), as specified by @@ -105,12 +112,20 @@ The default is 5 seconds\&. \fBpollinterval\fR .RS 4 Optional\&. The status of the UPS will be refreshed after a maximum delay which is controlled by this setting\&. This is normally 2 seconds\&. This may be useful if the driver is creating too much of a load on your system or network\&. +.sp +Note that some drivers (such as +\fBusbhid-ups\fR(8), +\fBsnmp-ups\fR(8) +and +\fBnutdrv_qx\fR(8)) also have an option called +\fBpollfreq\fR +which controls how frequently some of the less critical parameters are polled\&. Details are provided in the respective driver man pages\&. .RE .PP \fBsynchronous\fR .RS 4 -Optional\&. The driver work by default in asynchronous mode (i\&.e -\fBsynchronous=no\fR)\&. This means that all data are pushed by the driver on the communication socket to upsd (Unix socket on Unix, Named pipe on Windows) without waiting for these data to be actually consumed\&. With some HW, such as ePDUs, that can produce a lot of data, asynchronous mode may cause some congestion, resulting in the socket to be full, and the driver to appear as not connected\&. In such case, the driver will provide the following debug message: +Optional\&. The drivers work by default in asynchronous mode initially but can fall back to synchronous mode if writes to server socket failed (i\&.e +\fBsynchronous=auto\fR)\&. This means that all data are pushed by the driver on the communication socket to upsd (Unix socket on Unix, Named pipe on Windows) without waiting for these data to be actually consumed\&. With some HW, such as ePDUs, that can produce a lot of data, asynchronous mode may cause some congestion, resulting in the socket to be full, and the driver to appear as not connected\&. In such case, the driver will provide the following debug message: .sp .if n \{\ .RS 4 @@ -127,15 +142,36 @@ By enabling the flag (value = \fIyes\fR), the driver will wait for data to be consumed by upsd, prior to publishing more\&. This can be enabled either globally or per driver\&. .sp -The default is +The default of +\fIauto\fR +acts like \fIno\fR -(i\&.e\&. asynchronous mode) for backward compatibility of the driver behavior\&. +(i\&.e\&. asynchronous mode) for backward compatibility of the driver behavior, until communications fail with a "Resource temporarily unavailable" condition, which happens when the driver has many data points to send in a burst, and the server can not handle that quickly enough so the buffer fills up\&. .RE .PP \fBuser\fR .RS 4 -Optional\&. If started as root, the driver will setuid(2) to the user id associated with -\fIusername\fR\&. +Optional\&. Overrides the compiled\-in default unprivileged username for all NUT device drivers\&. See the discussion of the +\-u +option in +\fBnutupsdrv\fR(8) +for details\&. +.RE +.PP +\fBgroup\fR +.RS 4 +Optional\&. Overrides the compiled\-in (and/or global\-section) default unprivileged group name for all NUT device drivers, used for the socket file access\&. See the discussion of the +\-g +option in +\fBnutupsdrv\fR(8) +for details\&. This may be specifically useful for ensuring access to dynamic device filesystem nodes, such as USB (or serial\-over\-USB) hot\-plug support, or with device filesystems re\-generated by an OS for every reboot\&. +.RE +.PP +\fBdebug_min\fR \fIINTEGER\fR +.RS 4 +Optional\&. Specify a minimum debug level for all driver daemons, e\&.g\&. for troubleshooting a deployment, without impacting foreground or background running mode directly\&. Command\-line option +\-D +can only increase this verbosity level\&. .RE .SH "UPS FIELDS" .PP @@ -153,6 +189,24 @@ Required\&. This is the serial port where the UPS is connected\&. On a Linux sys \fI/dev/cuaa0\fR\&. .RE .PP +\fBuser\fR +.RS 4 +Optional\&. Overrides the compiled\-in (and/or global\-section) default unprivileged username for a particular NUT device driver\&. See the discussion of the +\-u +option in +\fBnutupsdrv\fR(8) +for details\&. This may be specifically useful for ensuring access to dynamic device filesystem nodes, such as USB (or serial\-over\-USB) hot\-plug support, or with device filesystems re\-generated by an OS for every reboot\&. +.RE +.PP +\fBgroup\fR +.RS 4 +Optional\&. Overrides the compiled\-in (and/or global\-section) default unprivileged group name for a particular NUT device driver, used for the socket file access\&. See the discussion of the +\-g +option in +\fBnutupsdrv\fR(8) +for details\&. This may be specifically useful for ensuring access to dynamic device filesystem nodes, such as USB (or serial\-over\-USB) hot\-plug support, or with device filesystems re\-generated by an OS for every reboot\&. +.RE +.PP \fBsdorder\fR .RS 4 Optional\&. When you have multiple UPSes on your system, you usually need to turn them off in a certain order\&. upsdrvctl shuts down all the 0s, then the 1s, 2s, and so on\&. To exclude a UPS from the shutdown sequence, set this to \-1\&. @@ -176,7 +230,7 @@ This may be needed on Mac OS X systems\&. .PP \fBignorelb\fR .RS 4 -Optional\&. When you specify this, the driver ignores a low battery condition flag that is reported by the UPS (some devices will switch off almost immediately after setting this flag, or will report this as soons as the mains fails)\&. Instead it will use either of the following conditions to determine when the battery is low: +Optional\&. When you specify this, the driver ignores a low battery condition flag that is reported by the UPS (some devices will switch off almost immediately after setting this flag, or will report this as soon as the mains fails)\&. Instead it will use either of the following conditions to determine when the battery is low: .sp .if n \{\ .RS 4 @@ -264,6 +318,15 @@ Use with caution! This will only change the appearance of the variable to the ou .RE .sp All other fields are passed through to the hardware\-specific part of the driver\&. See those manuals for the list of what is allowed\&. +.PP +\fBdebug_min\fR \fIINTEGER\fR +.RS 4 +Optional\&. Specify a minimum debug level for this driver daemon, e\&.g\&. for troubleshooting a deployment, without impacting foreground or background running mode directly\&. If the global +debug_min +is also set, this driver\-level setting overrides it\&. Command\-line option +\-D +can only increase this verbosity level\&. +.RE .SH "INTEGRATION" .sp \fBupsdrvctl\fR(8) uses this file to start and stop the drivers\&. @@ -273,7 +336,7 @@ The drivers themselves also obtain configuration data from this file\&. Each dri \fBupsd\fR(8) learns about which UPSes are installed on this system by reading this file\&. If this system is called "doghouse" and you have defined a UPS in your \fBups\&.conf\fR called "snoopy", then you can monitor it from \fBupsc\fR(8) or similar as "snoopy@doghouse"\&. .SH "SEE ALSO" .sp -\fBupsd\fR(8), \fBnutupsdrv\fR(8), \fBupsdrvctl\fR(8) +\fBupsd\fR(8), \fBnutupsdrv\fR(8), \fBupsdrvctl\fR(8), \fBupsdrvsvcctl\fR(8) .SS "Internet resources" .sp The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/ups.conf.txt b/docs/man/ups.conf.txt index 235f015..10c0607 100644 --- a/docs/man/ups.conf.txt +++ b/docs/man/ups.conf.txt @@ -3,6 +3,7 @@ UPS.CONF(5) NAME ---- + ups.conf - UPS definitions for Network UPS Tools DESCRIPTION @@ -66,6 +67,12 @@ impact the time taken by your system to start. + The default is 1 attempt. +*nowait*:: +Optional. Specify to upsdrvctl to not wait at all for the driver(s) to +execute the request command. ++ +The default (omission) is to wait. + *retrydelay*:: Optional. Specify the delay between each restart attempt of the driver(s), as specified by 'maxretry'. Caution should be taken when using this option, @@ -79,11 +86,17 @@ Optional. The status of the UPS will be refreshed after a maximum delay which is controlled by this setting. This is normally 2 seconds. This may be useful if the driver is creating too much of a load on your system or network. ++ +Note that some drivers (such as linkman:usbhid-ups[8], linkman:snmp-ups[8] and +linkman:nutdrv_qx[8]) also have an option called *pollfreq* which controls how +frequently some of the less critical parameters are polled. Details are +provided in the respective driver man pages. *synchronous*:: -Optional. The driver work by default in asynchronous mode (i.e -*synchronous=no*). This means that all data are pushed by the driver +Optional. The drivers work by default in asynchronous mode initially +but can fall back to synchronous mode if writes to server socket failed +(i.e *synchronous=auto*). This means that all data are pushed by the driver on the communication socket to upsd (Unix socket on Unix, Named pipe on Windows) without waiting for these data to be actually consumed. With some HW, such as ePDUs, that can produce a lot of data, @@ -97,16 +110,38 @@ By enabling the 'synchronous' flag (value = 'yes'), the driver will wait for data to be consumed by upsd, prior to publishing more. This can be enabled either globally or per driver. + -The default is 'no' (i.e. asynchronous mode) for backward compatibility -of the driver behavior. +The default of 'auto' acts like 'no' (i.e. asynchronous mode) for backward +compatibility of the driver behavior, until communications fail with a +"Resource temporarily unavailable" condition, which happens when the +driver has many data points to send in a burst, and the server can not +handle that quickly enough so the buffer fills up. *user*:: -Optional. If started as root, the driver will setuid(2) to the user id -associated with 'username'. +Optional. Overrides the compiled-in default unprivileged username for +all NUT device drivers. See the discussion of the `-u` option in +linkman:nutupsdrv[8] for details. + +*group*:: + +Optional. Overrides the compiled-in (and/or global-section) default +unprivileged group name for all NUT device drivers, used for the +socket file access. See the discussion of the `-g` option in +linkman:nutupsdrv[8] for details. +This may be specifically useful for ensuring access to dynamic device +filesystem nodes, such as USB (or serial-over-USB) hot-plug support, +or with device filesystems re-generated by an OS for every reboot. + +*debug_min* 'INTEGER':: + +Optional. Specify a minimum debug level for all driver daemons, e.g. for +troubleshooting a deployment, without impacting foreground or background +running mode directly. Command-line option `-D` can only increase this +verbosity level. UPS FIELDS ---------- + *driver*:: Required. This specifies which program will be monitoring this UPS. You @@ -120,6 +155,25 @@ Required. This is the serial port where the UPS is connected. On a Linux system, the first serial port usually is '/dev/ttyS0'. On FreeBSD and similar systems, it probably will be '/dev/cuaa0'. +*user*:: + +Optional. Overrides the compiled-in (and/or global-section) default +unprivileged username for a particular NUT device driver. See the +discussion of the `-u` option in linkman:nutupsdrv[8] for details. +This may be specifically useful for ensuring access to dynamic device +filesystem nodes, such as USB (or serial-over-USB) hot-plug support, +or with device filesystems re-generated by an OS for every reboot. + +*group*:: + +Optional. Overrides the compiled-in (and/or global-section) default +unprivileged group name for a particular NUT device driver, used for +the socket file access. See the discussion of the `-g` option in +linkman:nutupsdrv[8] for details. +This may be specifically useful for ensuring access to dynamic device +filesystem nodes, such as USB (or serial-over-USB) hot-plug support, +or with device filesystems re-generated by an OS for every reboot. + *sdorder*:: Optional. When you have multiple UPSes on your system, you usually need to @@ -139,16 +193,16 @@ to clients that ask for a list of connected equipment. Optional. When you specify this, the driver skips the port locking routines every time it starts. This may allow other processes to seize the port if you start more than one accidentally. -+ ++ You should only use this if your system won't work without it. -+ ++ This may be needed on Mac OS X systems. *ignorelb*:: Optional. When you specify this, the driver ignores a low battery condition flag that is reported by the UPS (some devices will switch off almost -immediately after setting this flag, or will report this as soons as the +immediately after setting this flag, or will report this as soon as the mains fails). Instead it will use either of the following conditions to determine when the battery is low: @@ -214,6 +268,14 @@ the outside world, internally in the UPS the original value is used. All other fields are passed through to the hardware-specific part of the driver. See those manuals for the list of what is allowed. +*debug_min* 'INTEGER':: + +Optional. Specify a minimum debug level for this driver daemon, e.g. for +troubleshooting a deployment, without impacting foreground or background +running mode directly. If the global `debug_min` is also set, this +driver-level setting overrides it. Command-line option `-D` can only +increase this verbosity level. + INTEGRATION ----------- @@ -229,8 +291,11 @@ from linkman:upsc[8] or similar as "snoopy@doghouse". SEE ALSO -------- -linkman:upsd[8], linkman:nutupsdrv[8], linkman:upsdrvctl[8] + +linkman:upsd[8], linkman:nutupsdrv[8], linkman:upsdrvctl[8], +linkman:upsdrvsvcctl[8] Internet resources ~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/upsc.8 b/docs/man/upsc.8 index 49984ab..521794b 100644 --- a/docs/man/upsc.8 +++ b/docs/man/upsc.8 @@ -1,13 +1,13 @@ '\" t .\" Title: upsc -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSC" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSC" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -141,6 +141,6 @@ Earlier versions of this program used the \fIupsfetch\fR library and UDP sockets .SH "SEE ALSO" .sp \fBupsd\fR(8) -.SH "INTERNET RESOURCES" +.SS "Internet resources:" .sp The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/upsc.txt b/docs/man/upsc.txt index 1162886..2e89c50 100644 --- a/docs/man/upsc.txt +++ b/docs/man/upsc.txt @@ -1,13 +1,14 @@ UPSC(8) ======= - NAME ---- + upsc - example lightweight UPS client SYNOPSIS -------- + *upsc* -l | -L ['host'] *upsc* 'ups' ['variable'] @@ -23,6 +24,7 @@ want to include the full interface. OPTIONS ------- + *-l* 'host':: List all UPS names configured at 'host', one name per line. The hostname @@ -113,7 +115,7 @@ SEE ALSO linkman:upsd[8] -INTERNET RESOURCES ------------------- +Internet resources: +~~~~~~~~~~~~~~~~~~~ The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/upscli_add_host_cert.3 b/docs/man/upscli_add_host_cert.3 index 127473b..b3d08b2 100644 --- a/docs/man/upscli_add_host_cert.3 +++ b/docs/man/upscli_add_host_cert.3 @@ -1,13 +1,13 @@ '\" t .\" Title: upscli_add_host_cert -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSCLI_ADD_HOST_CERT" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSCLI_ADD_HOST_CERT" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -44,6 +44,8 @@ void upscli_add_host_cert(const char* hostname, const char* certname, The \fBupscli_add_host_cert()\fR function register a security rule associated to the \fIhostname\fR\&. All connections to this host use this rule\&. .sp The rule is composed of the certificate name \fIcertname \*(Aqexpected for the host, \*(Aqcertverify\fR if the certificate must be validated for the host and \fIforcessl\fR if a secured connection must be used to connect to the host\&. +.sp +Note: This call only functions if upsclient has been compiled with NSS support\&. If instead it was compiled with OpenSSL support, this function contains an empty definition and will take no action when called\&. .SH "RETURN VALUE" .sp \fBupscli_add_host_cert()\fR returns no value\&. diff --git a/docs/man/upscli_add_host_cert.txt b/docs/man/upscli_add_host_cert.txt index 96070e8..6d9050d 100644 --- a/docs/man/upscli_add_host_cert.txt +++ b/docs/man/upscli_add_host_cert.txt @@ -16,13 +16,17 @@ SYNOPSIS DESCRIPTION ----------- -The *upscli_add_host_cert()* function register a security rule associated + +The *upscli_add_host_cert()* function register a security rule associated to the 'hostname'. All connections to this host use this rule. The rule is composed of the certificate name 'certname 'expected for the host, 'certverify' if the certificate must be validated for the host and 'forcessl' if a secured connection must be used to connect to the host. +Note: This call only functions if upsclient has been compiled with NSS +support. If instead it was compiled with OpenSSL support, this function +contains an empty definition and will take no action when called. RETURN VALUE ------------ @@ -31,5 +35,6 @@ RETURN VALUE SEE ALSO -------- -linkman:upscli_init[3], linkman:upscli_connect[3], linkman:upscli_ssl[3], + +linkman:upscli_init[3], linkman:upscli_connect[3], linkman:upscli_ssl[3], linkman:upscli_strerror[3], linkman:upscli_upserror[3] diff --git a/docs/man/upscli_cleanup.3 b/docs/man/upscli_cleanup.3 index 22d6626..5edde88 100644 --- a/docs/man/upscli_cleanup.3 +++ b/docs/man/upscli_cleanup.3 @@ -1,13 +1,13 @@ '\" t .\" Title: upscli_cleanup -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSCLI_CLEANUP" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSCLI_CLEANUP" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -36,7 +36,7 @@ upscli_cleanup \- Clean\-up upsclient module after usage\&. .fi .sp .nf -int upscli_cleanup(); +int upscli_cleanup(void); .fi .SH "DESCRIPTION" .sp diff --git a/docs/man/upscli_cleanup.txt b/docs/man/upscli_cleanup.txt index cd88a51..60431ec 100644 --- a/docs/man/upscli_cleanup.txt +++ b/docs/man/upscli_cleanup.txt @@ -11,19 +11,22 @@ SYNOPSIS #include - int upscli_cleanup(); + int upscli_cleanup(void); DESCRIPTION ----------- + The *upscli_cleanup()* function flushes SSL caches and frees memory used internally in upsclient module. RETURN VALUE ------------ -The *upscli_cleanup()* function returns 1 on success, or -1 if an error occurs. +The *upscli_cleanup()* function returns 1 on success, or -1 if an error +occurs. SEE ALSO -------- + linkman:upscli_init[3], linkman:upscli_strerror[3], linkman:upscli_upserror[3] diff --git a/docs/man/upscli_connect.3 b/docs/man/upscli_connect.3 index 560f7a5..ed94a7e 100644 --- a/docs/man/upscli_connect.3 +++ b/docs/man/upscli_connect.3 @@ -1,13 +1,13 @@ '\" t .\" Title: upscli_connect -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSCLI_CONNECT" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSCLI_CONNECT" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -36,7 +36,7 @@ upscli_connect \- Open a connection to a NUT upsd .fi .sp .nf -int upscli_connect(UPSCONN_t *ups, const char *host, int port, int flags); +int upscli_connect(UPSCONN_t *ups, const char *host, uint16_t port, int flags); .fi .SH "DESCRIPTION" .sp @@ -44,6 +44,8 @@ The \fBupscli_connect()\fR function takes the pointer \fIups\fR to a UPSCONN_t s .sp \fIflags\fR may be either UPSCLI_CONN_TRYSSL to try a SSL connection, or UPSCLI_CONN_REQSSL to require a SSL connection\&. .sp +Introduced in version 2\&.7, an additional flag UPSCLI_CONN_CERTVERIF now exists to verify the signature offered during the SSL handshake\&. This flag should be used in conjunction with \fBupscli_init\fR(3) and/or \fBupscli_add_host_cert\fR(3) calls before connecting in order to define a CA certificate with which to verify\&. +.sp If SSL mode is required, this function will only return successfully if it is able to establish a SSL connection with the server\&. Possible reasons for failure include no SSL support on the server, and if \fBupsclient\fR itself hasn\(cqt been compiled with SSL support\&. .sp You must call \fBupscli_disconnect\fR(3) when finished with a connection, or your program will slowly leak memory and file descriptors\&. diff --git a/docs/man/upscli_connect.txt b/docs/man/upscli_connect.txt index d493dd0..c2e3dde 100644 --- a/docs/man/upscli_connect.txt +++ b/docs/man/upscli_connect.txt @@ -11,16 +11,23 @@ SYNOPSIS #include - int upscli_connect(UPSCONN_t *ups, const char *host, int port, int flags); + int upscli_connect(UPSCONN_t *ups, const char *host, uint16_t port, int flags); DESCRIPTION ----------- + The *upscli_connect()* function takes the pointer 'ups' to a `UPSCONN_t` state structure and opens a TCP connection to the 'host' on the given 'port'. 'flags' may be either `UPSCLI_CONN_TRYSSL` to try a SSL -connection, or `UPSCLI_CONN_REQSSL` to require a SSL connection. +connection, or `UPSCLI_CONN_REQSSL` to require a SSL connection. + +Introduced in version 2.7, an additional flag `UPSCLI_CONN_CERTVERIF` +now exists to verify the signature offered during the SSL handshake. +This flag should be used in conjunction with linkman:upscli_init[3] +and/or linkman:upscli_add_host_cert[3] calls before connecting in +order to define a CA certificate with which to verify. If SSL mode is required, this function will only return successfully if it is able to establish a SSL connection with the server. Possible @@ -39,7 +46,8 @@ returns 0 on success, or -1 if an error occurs. SEE ALSO -------- -linkman:upscli_disconnect[3], linkman:upscli_fd[3], -linkman:upscli_splitaddr[3], linkman:upscli_splitname[3], -linkman:upscli_ssl[3], linkman:upscli_strerror[3], + +linkman:upscli_disconnect[3], linkman:upscli_fd[3], +linkman:upscli_splitaddr[3], linkman:upscli_splitname[3], +linkman:upscli_ssl[3], linkman:upscli_strerror[3], linkman:upscli_upserror[3] diff --git a/docs/man/upscli_disconnect.3 b/docs/man/upscli_disconnect.3 index 7e28869..5857fa4 100644 --- a/docs/man/upscli_disconnect.3 +++ b/docs/man/upscli_disconnect.3 @@ -1,13 +1,13 @@ '\" t .\" Title: upscli_disconnect -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSCLI_DISCONNECT" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSCLI_DISCONNECT" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -40,7 +40,9 @@ int upscli_disconnect(UPSCONN_t *ups); .fi .SH "DESCRIPTION" .sp -The \fBupscli_disconnect()\fR function takes the pointer \fIups\fR to a UPSCONN_t state structure, shuts down the connection to the server, and frees dynamic memory used by the state structure\&. The UPSCONN_t structure is no longer valid after this function is called\&. +The \fBupscli_disconnect()\fR function takes the pointer \fIups\fR to a UPSCONN_t state structure, shuts down the connection to the server, and frees dynamic memory used by the state structure\&. +.sp +The UPSCONN_t structure is no longer valid after this function is called\&. .sp This function must be called, or your program will leak memory and file descriptors\&. .SH "RETURN VALUE" diff --git a/docs/man/upscli_disconnect.txt b/docs/man/upscli_disconnect.txt index 8c7d5ca..76a8e61 100644 --- a/docs/man/upscli_disconnect.txt +++ b/docs/man/upscli_disconnect.txt @@ -15,10 +15,12 @@ SYNOPSIS DESCRIPTION ----------- + The *upscli_disconnect()* function takes the pointer 'ups' to a -`UPSCONN_t` state structure, shuts down the connection to the server, and -frees dynamic memory used by the state structure. The `UPSCONN_t` structure -is no longer valid after this function is called. +`UPSCONN_t` state structure, shuts down the connection to the server, +and frees dynamic memory used by the state structure. + +The `UPSCONN_t` structure is no longer valid after this function is called. This function must be called, or your program will leak memory and file descriptors. @@ -31,5 +33,6 @@ error occurs. SEE ALSO -------- -linkman:upscli_connect[3], linkman:upscli_fd[3], + +linkman:upscli_connect[3], linkman:upscli_fd[3], linkman:upscli_strerror[3], linkman:upscli_upserror[3] diff --git a/docs/man/upscli_fd.3 b/docs/man/upscli_fd.3 index 27844c0..5bd0063 100644 --- a/docs/man/upscli_fd.3 +++ b/docs/man/upscli_fd.3 @@ -1,13 +1,13 @@ '\" t .\" Title: upscli_fd -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSCLI_FD" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSCLI_FD" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -45,7 +45,9 @@ The \fBupscli_fd()\fR function takes the pointer \fIups\fR to a UPSCONN_t state This may be useful for determining if the connection to \fBupsd\fR(8) has been lost\&. .SH "RETURN VALUE" .sp -The \fBupscli_fd()\fR function returns the file descriptor, which may be any non\-negative number\&. It returns \-1 if an error occurs\&. +The \fBupscli_fd()\fR function returns the file descriptor, which may be any non\-negative number\&. +.sp +It returns \-1 if an error occurs\&. .SH "SEE ALSO" .sp \fBupscli_connect\fR(3), \fBupscli_strerror\fR(3), \fBupscli_upserror\fR(3) diff --git a/docs/man/upscli_fd.txt b/docs/man/upscli_fd.txt index c42b098..1fd2971 100644 --- a/docs/man/upscli_fd.txt +++ b/docs/man/upscli_fd.txt @@ -16,9 +16,9 @@ SYNOPSIS DESCRIPTION ----------- -The *upscli_fd()* function takes the pointer 'ups' to a -`UPSCONN_t` state structure and returns the value of the file descriptor -for that connection, if any. +The *upscli_fd()* function takes the pointer 'ups' to a `UPSCONN_t` +state structure and returns the value of the file descriptor for +that connection, if any. This may be useful for determining if the connection to linkman:upsd[8] has been lost. @@ -27,7 +27,9 @@ RETURN VALUE ------------ The *upscli_fd()* function returns the file descriptor, which -may be any non-negative number. It returns -1 if an error occurs. +may be any non-negative number. + +It returns -1 if an error occurs. SEE ALSO -------- diff --git a/docs/man/upscli_get.3 b/docs/man/upscli_get.3 index fd8615f..c020a09 100644 --- a/docs/man/upscli_get.3 +++ b/docs/man/upscli_get.3 @@ -1,13 +1,13 @@ '\" t .\" Title: upscli_get -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSCLI_GET" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSCLI_GET" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -28,7 +28,7 @@ .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" -upscli_get \- retrieve data from a UPS +upscli_get \- retrieve data from an UPS .SH "SYNOPSIS" .sp .nf @@ -36,8 +36,8 @@ upscli_get \- retrieve data from a UPS .fi .sp .nf -int upscli_get(UPSCONN_t *ups, unsigned int numq, const char **query, - unsigned int *numa, char ***answer) +int upscli_get(UPSCONN_t *ups, size_t numq, const char **query, + size_t *numa, char ***answer) .fi .SH "DESCRIPTION" .sp @@ -46,7 +46,9 @@ The \fBupscli_get()\fR function takes the pointer \fIups\fR to a UPSCONN_t state Upon success, the response will be split into separate components\&. A pointer to those components will be returned in \fIanswer\fR\&. The number of usable answer components will be returned in \fInuma\fR\&. .SH "USES" .sp -This function implements the "GET" command in the protocol\&. As a result, you can use it to request many different things from the server\&. Some examples are: +This function implements the "GET" command in the protocol\&. As a result, you can use it to request many different things from the server\&. +.sp +Some examples are: .sp .RS 4 .ie n \{\ @@ -121,20 +123,12 @@ To generate a request for GET NUMLOGINS su700, you would populate query and numq .RS 4 .\} .nf -unsigned int numq; -const char *query[2]; -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -query[0] = "NUMLOGINS"; -query[1] = "su700"; -numq = 2; + size_t numq; + const char *query[2]; + + query[0] = "NUMLOGINS"; + query[1] = "su700"; + numq = 2; .fi .if n \{\ .RE @@ -143,26 +137,20 @@ numq = 2; All escaping of special characters and quoting of elements with spaces is handled for you inside this function\&. .SH "ANSWER FORMATTING" .sp -The raw response from upsd to the above query would be NUMLOGINS su700 1\&. Since this is split up for you, the values work out like this: +The raw response from upsd to the above query would be NUMLOGINS su700 1\&. +.sp +Since this is split up for you, the values work out like this: .sp .if n \{\ .RS 4 .\} .nf -unsigned int numa; -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -numa = 3; -answer[0] = "NUMLOGINS" -answer[1] = "su700" -answer[2] = "1" + size_t numa; + + numa = 3; + answer[0] = "NUMLOGINS" + answer[1] = "su700" + answer[2] = "1" .fi .if n \{\ .RE @@ -185,7 +173,9 @@ The array will be deleted after calling \fBupscli_disconnect\fR(3)\&. Any access .sp The \fBupscli_get()\fR function returns 0 on success, or \-1 if an error occurs\&. .sp -If \fBupsd\fR disconnects, you may need to handle or ignore SIGPIPE in order to prevent your program from terminating the next time that the library writes to the disconnected socket\&. The following code in your initialization function will allow the \fBupscli_get()\fR call to return an error in that case: +If \fBupsd\fR disconnects, you may need to handle or ignore SIGPIPE in order to prevent your program from terminating the next time that the library writes to the disconnected socket\&. +.sp +The following code in your initialization function will allow the \fBupscli_get()\fR call to return an error in that case: .sp .if n \{\ .RS 4 diff --git a/docs/man/upscli_get.txt b/docs/man/upscli_get.txt index 71cdf1a..0d524fe 100644 --- a/docs/man/upscli_get.txt +++ b/docs/man/upscli_get.txt @@ -3,32 +3,36 @@ UPSCLI_GET(3) NAME ---- -upscli_get - retrieve data from a UPS + +upscli_get - retrieve data from an UPS SYNOPSIS -------- #include - int upscli_get(UPSCONN_t *ups, unsigned int numq, const char **query, - unsigned int *numa, char ***answer) + int upscli_get(UPSCONN_t *ups, size_t numq, const char **query, + size_t *numa, char ***answer) DESCRIPTION ----------- + The *upscli_get()* function takes the pointer 'ups' to a `UPSCONN_t` state structure, and the pointer 'query' to an array of 'numq' query elements. It builds a properly-formatted request from those elements and transmits it to linkman:upsd[8]. -Upon success, the response will be split into separate components. A -pointer to those components will be returned in 'answer'. The -number of usable answer components will be returned in 'numa'. +Upon success, the response will be split into separate components. +A pointer to those components will be returned in 'answer'. +The number of usable answer components will be returned in 'numa'. USES ---- -This function implements the "GET" command in the protocol. As a -result, you can use it to request many different things from the server. +This function implements the "GET" command in the protocol. +As a result, you can use it to request many different things +from the server. + Some examples are: * GET NUMLOGINS @@ -40,38 +44,46 @@ Some examples are: QUERY FORMATTING ---------------- + To generate a request for `GET NUMLOGINS su700`, you would populate query and numq as follows: - unsigned int numq; +------ + size_t numq; const char *query[2]; query[0] = "NUMLOGINS"; query[1] = "su700"; numq = 2; +------ All escaping of special characters and quoting of elements with spaces is handled for you inside this function. ANSWER FORMATTING ----------------- -The raw response from upsd to the above query would be `NUMLOGINS su700 1`. + +The raw response from `upsd` to the above query would be `NUMLOGINS su700 1`. + Since this is split up for you, the values work out like this: - unsigned int numa; +------ + size_t numa; numa = 3; answer[0] = "NUMLOGINS" answer[1] = "su700" answer[2] = "1" +------ -Notice that the value which you seek typically starts at answer[numq]. +Notice that the value which you seek typically starts at `answer[numq]`. ERROR CHECKING -------------- + This function will check your query against the response from -linkman:upsd[8]. For example, if you send "VAR" "su700" "ups.status", it -will expect to see those at the beginning of the response. +linkman:upsd[8]. For example, if you send "VAR" "su700" "ups.status", +it will expect to see those at the beginning of the response. If the results from *upsd* do not pass this case-insensitive test against your request, this function will return an error. When this @@ -79,6 +91,7 @@ happens, linkman:upscli_upserror[3] will return 'UPSCLI_ERR_PROTOCOL'. ANSWER ARRAY LIFETIME --------------------- + The pointers contained within the 'answer' array are only valid until the next call to a 'upsclient' function which references them. If you need to use data from multiple calls, you must copy it somewhere @@ -90,18 +103,21 @@ which were returned by the most recent call. You also must not attempt to use more than 'numa' elements in 'answer'. Such behavior is undefined, and may yield bogus data or a crash. -The array will be deleted after calling linkman:upscli_disconnect[3]. Any -access after that point is also undefined. +The array will be deleted after calling linkman:upscli_disconnect[3]. +Any access after that point is also undefined. RETURN VALUE ------------ + The *upscli_get()* function returns 0 on success, or -1 if an error occurs. -If *upsd* disconnects, you may need to handle or ignore `SIGPIPE` in order to -prevent your program from terminating the next time that the library writes to -the disconnected socket. The following code in your initialization function -will allow the *upscli_get()* call to return an error in that case: +If *upsd* disconnects, you may need to handle or ignore `SIGPIPE` +in order to prevent your program from terminating the next time that +the library writes to the disconnected socket. + +The following code in your initialization function will allow the +*upscli_get()* call to return an error in that case: #include ... @@ -110,5 +126,6 @@ will allow the *upscli_get()* call to return an error in that case: SEE ALSO -------- + linkman:upscli_list_start[3], linkman:upscli_list_next[3], linkman:upscli_strerror[3], linkman:upscli_upserror[3] diff --git a/docs/man/upscli_init.3 b/docs/man/upscli_init.3 index 9e8712d..04fd0ce 100644 --- a/docs/man/upscli_init.3 +++ b/docs/man/upscli_init.3 @@ -1,13 +1,13 @@ '\" t .\" Title: upscli_init -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSCLI_INIT" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSCLI_INIT" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -43,7 +43,21 @@ int upscli_init(int certverify, const char *certpath, .sp The \fBupscli_init()\fR function initialize upsclient module and set many SSL\-related properties: \fIcertverify\fR to 1 makes certificate verification required for all SSL connections and \fIcertpath\fR is the location of certificate database\&. .sp -If compiled with OpenSSL, certpath refers to a \&.pem file containing certificates and if compiled with NSS, certpath refers to a directory containing database files\&. +If compiled with OpenSSL, certpath refers to directory containing certificates where the certificates must be named according to their hash values ending in a "\&.0" extension\&. If two certificates result in the same hash value (thus file name), the "\&.0" can be incremented to "\&.1" and so on, as needed\&. The bash command for creating links in this manner would be: +.sp +.if n \{\ +.RS 4 +.\} +.nf +ln \-s ca\&.pem \&./$(openssl x509 \-hash \-noout \-in ca\&.pem)\&.0 +.fi +.if n \{\ +.RE +.\} +.sp +Alternatively, the c_rehash utility (provided by openssl\-perl) can take a directory and iterate it to link all certificates found in that directory, in the manner described above\&. +.sp +If compiled with NSS, certpath refers to a directory containing database files\&. .sp If compiled with NSS and using SSL, you can specify \fIcertname\fR the name of the certificate to send to upsd and \fIcertpasswd\fR the password used to decrypt certificate private key\&. .sp diff --git a/docs/man/upscli_init.txt b/docs/man/upscli_init.txt index d07c7e7..16cd0e9 100644 --- a/docs/man/upscli_init.txt +++ b/docs/man/upscli_init.txt @@ -16,14 +16,27 @@ SYNOPSIS DESCRIPTION ----------- + The *upscli_init()* function initialize upsclient module and set many SSL-related properties: 'certverify' to 1 makes certificate verification required for all SSL connections and 'certpath' is the location of certificate database. -If compiled with OpenSSL, certpath refers to a .pem file containing -certificates and if compiled with NSS, certpath refers to a directory -containing database files. +If compiled with OpenSSL, certpath refers to directory containing +certificates where the certificates must be named according to their +hash values ending in a ".0" extension. If two certificates result in +the same hash value (thus file name), the ".0" can be incremented to ".1" +and so on, as needed. The bash command for creating links in this manner +would be: + + ln -s ca.pem ./$(openssl x509 -hash -noout -in ca.pem).0 + +Alternatively, the c_rehash utility (provided by openssl-perl) can take a +directory and iterate it to link all certificates found in that directory, +in the manner described above. + +If compiled with NSS, certpath refers to a directory containing database +files. If compiled with NSS and using SSL, you can specify 'certname' the name of the certificate to send to upsd and 'certpasswd' the password used @@ -41,8 +54,9 @@ The *upscli_init()* function returns 1 on success, or -1 if an error occurs. SEE ALSO -------- + linkman:upscli_add_host_cert[3], linkman:upscli_cleanup[3], -linkman:upscli_disconnect[3], linkman:upscli_fd[3], -linkman:upscli_splitaddr[3], linkman:upscli_splitname[3], -linkman:upscli_ssl[3], linkman:upscli_strerror[3], +linkman:upscli_disconnect[3], linkman:upscli_fd[3], +linkman:upscli_splitaddr[3], linkman:upscli_splitname[3], +linkman:upscli_ssl[3], linkman:upscli_strerror[3], linkman:upscli_upserror[3] diff --git a/docs/man/upscli_list_next.3 b/docs/man/upscli_list_next.3 index af8a324..f3a1ec4 100644 --- a/docs/man/upscli_list_next.3 +++ b/docs/man/upscli_list_next.3 @@ -1,13 +1,13 @@ '\" t .\" Title: upscli_list_next -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSCLI_LIST_NEXT" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSCLI_LIST_NEXT" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -36,8 +36,8 @@ upscli_list_next \- retrieve list items from a UPS .fi .sp .nf -int upscli_list_next(UPSCONN_t *ups, unsigned int numq, const char **query, - unsigned int *numa, char ***answer) +int upscli_list_next(UPSCONN_t *ups, size_t numq, const char **query, + size_t *numa, char ***answer) .fi .SH "DESCRIPTION" .sp diff --git a/docs/man/upscli_list_next.txt b/docs/man/upscli_list_next.txt index 20c1174..9612136 100644 --- a/docs/man/upscli_list_next.txt +++ b/docs/man/upscli_list_next.txt @@ -11,8 +11,8 @@ SYNOPSIS #include - int upscli_list_next(UPSCONN_t *ups, unsigned int numq, const char **query, - unsigned int *numa, char ***answer) + int upscli_list_next(UPSCONN_t *ups, size_t numq, const char **query, + size_t *numa, char ***answer) DESCRIPTION ----------- @@ -42,8 +42,8 @@ ANSWER FORMATTING ----------------- The contents of 'numa' and 'answer' work just like a call to -linkman:upscli_get[3]. The values returned by linkman:upsd[8] are identical to -a single item request, so this is not surprising. +linkman:upscli_get[3]. The values returned by linkman:upsd[8] are +identical to a single item request, so this is not surprising. ERROR CHECKING -------------- @@ -66,5 +66,6 @@ its first call in that case. SEE ALSO -------- + linkman:upscli_list_start[3], linkman:upscli_strerror[3], linkman:upscli_upserror[3] diff --git a/docs/man/upscli_list_start.3 b/docs/man/upscli_list_start.3 index e9022a1..da7a80d 100644 --- a/docs/man/upscli_list_start.3 +++ b/docs/man/upscli_list_start.3 @@ -1,13 +1,13 @@ '\" t .\" Title: upscli_list_start -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSCLI_LIST_START" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSCLI_LIST_START" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -36,7 +36,7 @@ upscli_list_start \- begin multi\-item retrieval from a UPS .fi .sp .nf -int upscli_list_start(UPSCONN_t *ups, unsigned int numq, const char **query) +int upscli_list_start(UPSCONN_t *ups, size_t numq, const char **query) .fi .SH "DESCRIPTION" .sp @@ -120,20 +120,12 @@ To see the list of variables on a UPS called \fIsu700\fR, the protocol command w .RS 4 .\} .nf -unsigned int numq; -const char *query[2]; -.fi -.if n \{\ -.RE -.\} -.sp -.if n \{\ -.RS 4 -.\} -.nf -query[0] = "VAR"; -query[1] = "su700"; -numq = 2; + size_t numq; + const char *query[2]; + + query[0] = "VAR"; + query[1] = "su700"; + numq = 2; .fi .if n \{\ .RE diff --git a/docs/man/upscli_list_start.txt b/docs/man/upscli_list_start.txt index e425f9e..c564c36 100644 --- a/docs/man/upscli_list_start.txt +++ b/docs/man/upscli_list_start.txt @@ -11,7 +11,7 @@ SYNOPSIS #include - int upscli_list_start(UPSCONN_t *ups, unsigned int numq, const char **query) + int upscli_list_start(UPSCONN_t *ups, size_t numq, const char **query) DESCRIPTION ----------- @@ -47,12 +47,14 @@ To see the list of variables on a UPS called 'su700', the protocol command would be `LIST VAR su700`. To start that list with this function, you would populate query and numq as follows: - unsigned int numq; +------ + size_t numq; const char *query[2]; query[0] = "VAR"; query[1] = "su700"; numq = 2; +------ All escaping of special characters and quoting of elements with spaces are handled for you inside this function. @@ -69,6 +71,7 @@ When this happens, linkman:upscli_upserror[3] will return RETURN VALUE ------------ + The *upscli_list_start()* function returns 0 on success, or -1 if an error occurs. @@ -79,4 +82,3 @@ linkman:upscli_fd[3], linkman:upscli_get[3], linkman:upscli_readline[3], linkman:upscli_sendline[3], linkman:upscli_ssl[3], linkman:upscli_strerror[3], linkman:upscli_upserror[3] - diff --git a/docs/man/upscli_readline.3 b/docs/man/upscli_readline.3 index 0846adf..6d2962a 100644 --- a/docs/man/upscli_readline.3 +++ b/docs/man/upscli_readline.3 @@ -1,13 +1,13 @@ '\" t .\" Title: upscli_readline -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSCLI_READLINE" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSCLI_READLINE" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -28,24 +28,32 @@ .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" -upscli_readline \- read a single response from a UPS +upscli_readline, upscli_readline_timeout \- read a single response from a UPS .SH "SYNOPSIS" .sp .nf #include +#include /* or on some platforms */ .fi .sp .nf int upscli_readline(UPSCONN_t *ups, char *buf, size_t buflen); .fi +.sp +.nf +int upscli_readline_timeout(UPSCONN_t *ups, char *buf, size_t buflen, + const time_t timeout); +.fi .SH "DESCRIPTION" .sp -The \fBupscli_readline()\fR function takes the pointer \fIups\fR to a UPSCONN_t state structure, receives a single line from the server, and copies up to \fIbuflen\fR bytes of the response into the buffer \fIbuf\fR\&. +The \fBupscli_readline()\fR and \fBupscli_readline_timeout()\fR functions take the pointer \fIups\fR to a UPSCONN_t state structure, receive a single line from the server, and copy up to \fIbuflen\fR bytes of the response into the buffer \fIbuf\fR\&. .sp Some parsing of the string occurs during reception\&. In particular, ERR messages from \fBupsd\fR(8) are detected and will cause this function to return \-1\&. +.sp +The difference between the two functions is that \fBupscli_readline_timeout()\fR lets the caller decide the amount of time (\fItimeout\fR seconds) after which it should give up and return, whereas \fBupscli_readline()\fR does not offer this freedom, and uses NUT default network timeout (5 seconds)\&. .SH "RETURN VALUE" .sp -The \fBupscli_readline()\fR function returns 0 on success, or \-1 if an error occurs\&. +The \fBupscli_readline()\fR and \fBupscli_readline_timeout()\fR functions return 0 on success, or \-1 if an error occurs\&. .SH "SEE ALSO" .sp \fBupscli_fd\fR(3), \fBupscli_get\fR(3), \fBupscli_readline\fR(3), \fBupscli_sendline\fR(3), \fBupscli_ssl\fR(3), \fBupscli_strerror\fR(3), \fBupscli_upserror\fR(3) diff --git a/docs/man/upscli_readline.txt b/docs/man/upscli_readline.txt index 52106ad..120ad21 100644 --- a/docs/man/upscli_readline.txt +++ b/docs/man/upscli_readline.txt @@ -4,31 +4,41 @@ UPSCLI_READLINE(3) NAME ---- -upscli_readline - read a single response from a UPS +upscli_readline, upscli_readline_timeout - read a single response from a UPS SYNOPSIS -------- #include + #include /* or on some platforms */ int upscli_readline(UPSCONN_t *ups, char *buf, size_t buflen); + int upscli_readline_timeout(UPSCONN_t *ups, char *buf, size_t buflen, + const time_t timeout); + DESCRIPTION ----------- -The *upscli_readline()* function takes the pointer 'ups' to a -`UPSCONN_t` state structure, receives a single line from the server, and -copies up to 'buflen' bytes of the response into the buffer -'buf'. + +The *upscli_readline()* and *upscli_readline_timeout()* functions take +the pointer 'ups' to a `UPSCONN_t` state structure, receive a single +line from the server, and copy up to 'buflen' bytes of the response +into the buffer 'buf'. Some parsing of the string occurs during reception. In particular, ERR messages from linkman:upsd[8] are detected and will cause this function to return -1. +The difference between the two functions is that *upscli_readline_timeout()* +lets the caller decide the amount of time ('timeout' seconds) after which it +should give up and return, whereas *upscli_readline()* does not offer this +freedom, and uses NUT default network timeout (5 seconds). + RETURN VALUE ------------ -The *upscli_readline()* function returns 0 on success, or -1 if an -error occurs. +The *upscli_readline()* and *upscli_readline_timeout()* functions +return 0 on success, or -1 if an error occurs. SEE ALSO -------- diff --git a/docs/man/upscli_readline_timeout.3 b/docs/man/upscli_readline_timeout.3 new file mode 100644 index 0000000..0e696de --- /dev/null +++ b/docs/man/upscli_readline_timeout.3 @@ -0,0 +1 @@ +.so man3/upscli_readline.3 diff --git a/docs/man/upscli_sendline.3 b/docs/man/upscli_sendline.3 index f9648a2..b94d952 100644 --- a/docs/man/upscli_sendline.3 +++ b/docs/man/upscli_sendline.3 @@ -1,13 +1,13 @@ '\" t .\" Title: upscli_sendline -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSCLI_SENDLINE" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSCLI_SENDLINE" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -28,24 +28,32 @@ .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" -upscli_sendline \- send a single command to a UPS +upscli_sendline, upscli_sendline_timeout \- send a single command to a UPS .SH "SYNOPSIS" .sp .nf #include +#include /* or on some platforms */ .fi .sp .nf int upscli_sendline(UPSCONN_t *ups, const char *buf, size_t buflen); .fi +.sp +.nf +int upscli_sendline_timeout(UPSCONN_t *ups, const char *buf, size_t buflen, + const time_t timeout); +.fi .SH "DESCRIPTION" .sp -The \fBupscli_sendline()\fR function takes the pointer \fIups\fR to a UPSCONN_t state structure and transmits a buffer \fIbuf\fR of size \fIbuflen\fR to the server\&. +The \fBupscli_sendline()\fR and \fBupscli_sendline_timeout()\fR functions take the pointer \fIups\fR to a UPSCONN_t state structure and transmit a buffer \fIbuf\fR of size \fIbuflen\fR to the server\&. .sp The data in \fIbuf\fR must be a fully formatted protocol command as no parsing of the buffer occurs within this function\&. +.sp +The difference between the two functions is that \fBupscli_sendline_timeout()\fR lets the caller decide the amount of time (\fItimeout\fR seconds) after which it should give up and return, whereas \fBupscli_sendline()\fR does not offer this freedom, and uses an immediate timeout (0 second)\&. .SH "RETURN VALUE" .sp -The \fBupscli_sendline()\fR function returns 0 on success, or \-1 if an error occurs\&. +The \fBupscli_sendline()\fR and \fBupscli_sendline_timeout()\fR functions return 0 on success, or \-1 if an error occurs\&. .SH "SEE ALSO" .sp \fBupscli_fd\fR(3), \fBupscli_get\fR(3), \fBupscli_readline\fR(3), \fBupscli_sendline\fR(3), \fBupscli_ssl\fR(3), \fBupscli_strerror\fR(3), \fBupscli_upserror\fR(3) diff --git a/docs/man/upscli_sendline.txt b/docs/man/upscli_sendline.txt index c449c6d..895f0ba 100644 --- a/docs/man/upscli_sendline.txt +++ b/docs/man/upscli_sendline.txt @@ -4,31 +4,39 @@ UPSCLI_SENDLINE(3) NAME ---- -upscli_sendline - send a single command to a UPS +upscli_sendline, upscli_sendline_timeout - send a single command to a UPS SYNOPSIS -------- - #include + #include /* or on some platforms */ int upscli_sendline(UPSCONN_t *ups, const char *buf, size_t buflen); + int upscli_sendline_timeout(UPSCONN_t *ups, const char *buf, size_t buflen, + const time_t timeout); + DESCRIPTION ----------- -The *upscli_sendline()* function takes the pointer 'ups' to a -`UPSCONN_t` state structure and transmits a buffer 'buf' of size -'buflen' to the server. +The *upscli_sendline()* and *upscli_sendline_timeout()* functions take the +pointer 'ups' to a `UPSCONN_t` state structure and transmit a buffer 'buf' +of size 'buflen' to the server. The data in 'buf' must be a fully formatted protocol command as no parsing of the buffer occurs within this function. +The difference between the two functions is that *upscli_sendline_timeout()* +lets the caller decide the amount of time ('timeout' seconds) after which it +should give up and return, whereas *upscli_sendline()* does not offer this +freedom, and uses an immediate timeout (0 second). + RETURN VALUE ------------ -The *upscli_sendline()* function returns 0 on success, or -1 if an -error occurs. +The *upscli_sendline()* and *upscli_sendline_timeout()* functions +return 0 on success, or -1 if an error occurs. SEE ALSO -------- diff --git a/docs/man/upscli_sendline_timeout.3 b/docs/man/upscli_sendline_timeout.3 new file mode 100644 index 0000000..ebd0d6c --- /dev/null +++ b/docs/man/upscli_sendline_timeout.3 @@ -0,0 +1 @@ +.so man3/upscli_sendline.3 diff --git a/docs/man/upscli_splitaddr.3 b/docs/man/upscli_splitaddr.3 index e04f0de..4fdc1c7 100644 --- a/docs/man/upscli_splitaddr.3 +++ b/docs/man/upscli_splitaddr.3 @@ -1,13 +1,13 @@ '\" t .\" Title: upscli_splitaddr -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSCLI_SPLITADDR" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSCLI_SPLITADDR" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/upscli_splitaddr.txt b/docs/man/upscli_splitaddr.txt index 4633762..b705493 100644 --- a/docs/man/upscli_splitaddr.txt +++ b/docs/man/upscli_splitaddr.txt @@ -9,7 +9,6 @@ upscli_splitaddr - split a listening address into its components SYNOPSIS -------- - #include int upscli_splitaddr(const char *buf, char **hostname, @@ -18,7 +17,7 @@ SYNOPSIS DESCRIPTION ----------- -The *upscli_splitaddr()* function takes a pointer to the raw UPS +The *upscli_splitaddr()* function takes a pointer to the raw UPS definition 'buf' and returns pointers to dynamically allocated memory in 'upsname' and 'hostname'. It also copies the port number into 'port'. diff --git a/docs/man/upscli_splitname.3 b/docs/man/upscli_splitname.3 index f802e98..cfa4e6b 100644 --- a/docs/man/upscli_splitname.3 +++ b/docs/man/upscli_splitname.3 @@ -1,13 +1,13 @@ '\" t .\" Title: upscli_splitname -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSCLI_SPLITNAME" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSCLI_SPLITNAME" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/upscli_splitname.txt b/docs/man/upscli_splitname.txt index 1b714c6..d40e642 100644 --- a/docs/man/upscli_splitname.txt +++ b/docs/man/upscli_splitname.txt @@ -11,13 +11,13 @@ SYNOPSIS #include - int upscli_splitname(const char *buf, char **upsname, + int upscli_splitname(const char *buf, char **upsname, char **hostname, int *port) DESCRIPTION ----------- -The *upscli_splitname()* function takes a pointer to the raw UPS +The *upscli_splitname()* function takes a pointer to the raw UPS definition 'buf' and returns pointers to dynamically allocated memory in 'upsname' and 'hostname'. It also copies the port number into 'port'. @@ -37,6 +37,7 @@ Definitions without an explicit port value receive the default value of MEMORY USAGE ------------ + You must *free*(3) the pointers to 'upsname' and 'hostname' when you are done with them to avoid memory leaks. diff --git a/docs/man/upscli_ssl.3 b/docs/man/upscli_ssl.3 index c185e09..6a7d151 100644 --- a/docs/man/upscli_ssl.3 +++ b/docs/man/upscli_ssl.3 @@ -1,13 +1,13 @@ '\" t .\" Title: upscli_ssl -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSCLI_SSL" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSCLI_SSL" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/upscli_strerror.3 b/docs/man/upscli_strerror.3 index 8e18095..9fb0805 100644 --- a/docs/man/upscli_strerror.3 +++ b/docs/man/upscli_strerror.3 @@ -1,13 +1,13 @@ '\" t .\" Title: upscli_strerror -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSCLI_STRERROR" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSCLI_STRERROR" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -36,7 +36,7 @@ upscli_strerror \- return string describing error condition .fi .sp .nf -char *upscli_strerror(UPSCONN_t *ups); +const char *upscli_strerror(UPSCONN_t *ups); .fi .SH "DESCRIPTION" .sp diff --git a/docs/man/upscli_strerror.txt b/docs/man/upscli_strerror.txt index fa6da66..b9b8462 100644 --- a/docs/man/upscli_strerror.txt +++ b/docs/man/upscli_strerror.txt @@ -11,7 +11,7 @@ SYNOPSIS #include - char *upscli_strerror(UPSCONN_t *ups); + const char *upscli_strerror(UPSCONN_t *ups); DESCRIPTION ----------- diff --git a/docs/man/upscli_upserror.3 b/docs/man/upscli_upserror.3 index ab54701..33f45b4 100644 --- a/docs/man/upscli_upserror.3 +++ b/docs/man/upscli_upserror.3 @@ -1,13 +1,13 @@ '\" t .\" Title: upscli_upserror -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSCLI_UPSERROR" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSCLI_UPSERROR" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/upscli_upserror.txt b/docs/man/upscli_upserror.txt index b8ac616..c4b5ac3 100644 --- a/docs/man/upscli_upserror.txt +++ b/docs/man/upscli_upserror.txt @@ -18,7 +18,7 @@ DESCRIPTION The *upscli_upserror*() function takes the pointer 'ups' to a `UPSCONN_t` state structure and returns the value of the internal error -number, if any. +number, if any. This is typically used to check for certain error values like `UPSCLI_ERR_UNKCOMMAND`. That specific error can be used for detecting diff --git a/docs/man/upsclient.3 b/docs/man/upsclient.3 index 570b8ce..600a2e7 100644 --- a/docs/man/upsclient.3 +++ b/docs/man/upsclient.3 @@ -1,13 +1,13 @@ '\" t .\" Title: upsclient -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSCLIENT" "3" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSCLIENT" "3" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/upsclient.txt b/docs/man/upsclient.txt index 5bfda67..0c2ac15 100644 --- a/docs/man/upsclient.txt +++ b/docs/man/upsclient.txt @@ -27,7 +27,7 @@ Before creating any connection, and in general using any upscli function, you must call linkman:upscli_init[3] with proper parameters to initialize upscli module. -To register specific host security policy, you must call +To register specific host security policy, you must call linkman:upscli_add_host_cert[3] before initialize connection to it. In the same way, just before exiting, and after all upscli usage, you must @@ -60,6 +60,7 @@ in memory and file descriptor leaks in your program. ERROR HANDLING -------------- + In the event of an error, linkman:upscli_strerror[3] will provide human-readable details on what happened. linkman:upscli_upserror[3] may also be used to retrieve the error number. These numbers are defined in @@ -67,12 +68,13 @@ also be used to retrieve the error number. These numbers are defined in SEE ALSO -------- + linkman:libupsclient-config[1], linkman:upscli_init[3], linkman:upscli_cleanup[3], linkman:upscli_add_host_cert[3], linkman:upscli_connect[3], linkman:upscli_disconnect[3], linkman:upscli_fd[3], -linkman:upscli_getvar[3], linkman:upscli_list_next[3], -linkman:upscli_list_start[3], linkman:upscli_readline[3], -linkman:upscli_sendline[3], -linkman:upscli_splitaddr[3], linkman:upscli_splitname[3], -linkman:upscli_ssl[3], linkman:upscli_strerror[3], +linkman:upscli_getvar[3], linkman:upscli_list_next[3], +linkman:upscli_list_start[3], linkman:upscli_readline[3], +linkman:upscli_sendline[3], +linkman:upscli_splitaddr[3], linkman:upscli_splitname[3], +linkman:upscli_ssl[3], linkman:upscli_strerror[3], linkman:upscli_upserror[3] diff --git a/docs/man/upscmd.8 b/docs/man/upscmd.8 index d673c33..a1122b3 100644 --- a/docs/man/upscmd.8 +++ b/docs/man/upscmd.8 @@ -1,13 +1,13 @@ '\" t .\" Title: upscmd -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSCMD" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSCMD" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -35,7 +35,7 @@ upscmd \- UPS administration program for instant commands .sp \fBupscmd\fR \-l \fIups\fR .sp -\fBupscmd\fR [\-u \fIusername\fR] [\-p \fIpassword\fR] \fIups\fR \fIcommand\fR +\fBupscmd\fR [\-u \fIusername\fR] [\-p \fIpassword\fR] [\-w] [\-t ] \fIups\fR \fIcommand\fR .SH "DESCRIPTION" .sp \fBupscmd\fR allows you to invoke "instant commands" in your UPS hardware\&. Not all hardware supports this, so check the list with \-l to see if anything will work on your equipment\&. @@ -63,6 +63,18 @@ Set the username for the connection to the server\&. This is optional, and you w Set the password to authenticate to the server\&. This is also optional like \-u, and you will be prompted for it if necessary\&. .RE .PP +\fB\-w\fR +.RS 4 +Wait for the completion of command execution by the driver and return its actual result from the device\&. Note that this feature requires that both upsd and the driver support TRACKING (NUT version 2\&.8\&.0 or higher) or it will otherwise fail\&. The command will also block until an actual result is provided from the driver, or the timeout is reached (see +\fB\-t\fR)\&. +.RE +.PP +\fB\-t\fR \fIseconds\fR +.RS 4 +Set a timeout when using +\fB\-w\fR\&. Defaults to 10 seconds\&. +.RE +.PP \fIups\fR .RS 4 Connect to this UPS\&. The format is @@ -85,12 +97,12 @@ This paranoia is entirely defined within the driver\&. upsd and upscmd have no c upscmd won\(cqt work unless you provide a valid username and password\&. If you get "access denied" errors, make sure that your \fBupsd.users\fR(5) has an entry for you, and that the username you are using has permissions to SET variables\&. .SH "BUGS" .sp -There is currently no way to tell the user when the driver requires confirmation to invoke a command such as load\&.off\&. Similarly, there is not yet a way to tell the user if a command succeeds or fails\&. +There is currently no way to tell the user when the driver requires confirmation to invoke a command such as load\&.off\&. .sp This is on the list of things to fix in the future, so don\(cqt despair\&. It involves magic cookies\&. .SH "SEE ALSO" .sp \fBupsd\fR(8), \fBupsrw\fR(8) -.SH "INTERNET RESOURCES" +.SS "Internet resources:" .sp The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/upscmd.txt b/docs/man/upscmd.txt index 8083fec..b8c80d8 100644 --- a/docs/man/upscmd.txt +++ b/docs/man/upscmd.txt @@ -3,15 +3,17 @@ UPSCMD(8) NAME ---- + upscmd - UPS administration program for instant commands SYNOPSIS -------- + *upscmd* -h *upscmd* -l 'ups' -*upscmd* [-u 'username'] [-p 'password'] 'ups' 'command' +*upscmd* [-u 'username'] [-p 'password'] [-w] [-t ] 'ups' 'command' DESCRIPTION ----------- @@ -39,9 +41,20 @@ Set the username for the connection to the server. This is optional, and you will be prompted for this when invoking a command if -u is not used. *-p* 'password':: -Set the password to authenticate to the server. This is also optional +Set the password to authenticate to the server. This is also optional like -u, and you will be prompted for it if necessary. +*-w*:: +Wait for the completion of command execution by the driver and return its +actual result from the device. Note that this feature requires that both upsd +and the driver support TRACKING (NUT version 2.8.0 or higher) or it will +otherwise fail. +The command will also block until an actual result is provided from the driver, +or the timeout is reached (see *-t*). + +*-t* 'seconds':: +Set a timeout when using *-w*. Defaults to 10 seconds. + 'ups':: Connect to this UPS. The format is `upsname[@hostname[:port]]`. The default hostname is "localhost". @@ -84,16 +97,17 @@ BUGS ---- There is currently no way to tell the user when the driver requires -confirmation to invoke a command such as `load.off`. Similarly, there is -not yet a way to tell the user if a command succeeds or fails. +confirmation to invoke a command such as `load.off`. This is on the list of things to fix in the future, so don't despair. It involves magic cookies. SEE ALSO -------- + linkman:upsd[8], linkman:upsrw[8] -INTERNET RESOURCES ------------------- +Internet resources: +~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/upscode2.8 b/docs/man/upscode2.8 index cadbfd4..43836a9 100644 --- a/docs/man/upscode2.8 +++ b/docs/man/upscode2.8 @@ -1,13 +1,13 @@ '\" t .\" Title: upscode2 -.\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [see the "AUTHORS" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSCODE2" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSCODE2" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -76,7 +76,7 @@ Flag to set if commands towards to UPS need to be introduced with an LF\&. A Com .RE .SH "COMMANDS" .sp -The driver supports the following commands for those UPSen that support them\&. The available commands are autodetected during initialization, so you should check availability with \fIupscmd \-l\fR\&. +The driver supports the following commands for those UPSes that support them\&. The available commands are autodetected during initialization, so you should check availability with \fIupscmd \-l\fR\&. .sp .RS 4 .ie n \{\ @@ -168,9 +168,29 @@ shutdown\&.reboot\&.graceful \- Shut down in 20 seconds and reboot after 1 minut .SH "NOTES" .sp The Powerware UPS models that this driver has been tested against until now have not returned a value for \fIbattery\&.charge\fR\&. Therefore, the driver will guestimate a value based on the nominal battery min/max and the current battery voltage\&. -.SH "AUTHOR" +.SH "AUTHORS" .sp -Håvard Lygre , Niels Baggesen +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Håvard Lygre +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Niels Baggesen +.RE .SH "SEE ALSO" .SS "The core driver:" .sp diff --git a/docs/man/upscode2.txt b/docs/man/upscode2.txt index 5e9cfda..21c7b02 100644 --- a/docs/man/upscode2.txt +++ b/docs/man/upscode2.txt @@ -3,22 +3,26 @@ UPSCODE2(8) NAME ---- + upscode2 - Driver for UPScode II compatible UPS equipment NOTE ---- + This man page only documents the hardware-specific features of the upscode2 driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + This driver supports UPS equipment which can be controlled via the UPScode II protocol. This is mainly Fiskars, Powerware equipment, but also some (probably OEM'ed) products from Compaq. EXTRA ARGUMENTS --------------- + This driver supports the following optional settings in the linkman:ups.conf[5]: @@ -54,7 +58,7 @@ A Compaq T1500h is known to need this. COMMANDS -------- -The driver supports the following commands for those UPSen that support them. +The driver supports the following commands for those UPSes that support them. The available commands are autodetected during initialization, so you should check availability with 'upscmd -l'. @@ -82,18 +86,21 @@ have not returned a value for 'battery.charge'. Therefore, the driver will guestimate a value based on the nominal battery min/max and the current battery voltage. -AUTHOR ------- -Håvard Lygre , -Niels Baggesen +AUTHORS +------- + +* Håvard Lygre +* Niels Baggesen SEE ALSO -------- The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/upsd.8 b/docs/man/upsd.8 index 1c6281e..3044797 100644 --- a/docs/man/upsd.8 +++ b/docs/man/upsd.8 @@ -1,13 +1,13 @@ '\" t .\" Title: upsd -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSD" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSD" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -64,9 +64,30 @@ stop process and exit .RE .RE .PP +\fB\-P\fR \fIpid\fR +.RS 4 +Send the command signal above using specified PID number, rather than consulting the PID file\&. This can help define service units which start +upsd +as a foreground process so it does not create a PID file\&. See also +\-FF +option as an alternative\&. +.RE +.PP \fB\-D\fR .RS 4 -Raise the debug level\&. Use this multiple times for additional details\&. +Raise the debugging level\&. upsd will run in the foreground by default, and will print information on stdout about the monitoring process\&. Use this option multiple times for more details\&. +.RE +.PP +\fB\-F\fR +.RS 4 +upsd will run in the foreground, regardless of debugging settings\&. Specify twice (\-FF +or +\-F \-F) to save the PID file even in this mode\&. +.RE +.PP +\fB\-B\fR +.RS 4 +upsd will run in the background, regardless of debugging settings\&. .RE .PP \fB\-h\fR @@ -104,9 +125,9 @@ Display the version of the program\&. .sp upsd can reload its configuration files without shutting down the process if you send it a SIGHUP or start it again with \-c reload\&. This only works if the background process is able to read those files\&. .sp -If you think that upsd can\(cqt reload, check your syslogs for error messages\&. If it\(cqs complaining about not being able to read the files, then you need to adjust your system to make it possible\&. Either change the permissions on the files, or run upsd as another user that will be able to read them\&. +If you think that upsd can\(cqt reload, check your syslog for error messages\&. If it\(cqs complaining about not being able to read the files, then you need to adjust your system to make it possible\&. Either change the permissions on the files, or run upsd as another user that will be able to read them\&. .sp -DO NOT make your upsd\&.conf or upsd\&.users world\-readable, as those files hold important authentication information\&. In the wrong hands, it could be used by some evil person to spoof your master upsmon and command your systems to shut down\&. +DO NOT make your upsd\&.conf or upsd\&.users world\-readable, as those files hold important authentication information\&. In the wrong hands, it could be used by some evil person to spoof your primary\-mode upsmon and command your systems to shut down\&. .SH "DIAGNOSTICS" .sp upsd expects the drivers to either update their status regularly or at least answer periodic queries, called pings\&. If a driver doesn\(cqt answer, upsd will declare it "stale" and no more information will be provided to the clients\&. @@ -125,16 +146,827 @@ The general upsd configuration file is \fBupsd.conf\fR(5)\&. The administrative \fBNUT_CONFPATH\fR is the path name of the directory that contains upsd\&.conf and other configuration files\&. If this variable is not set, \fBupsd\fR uses a built\-in default, which is often /usr/local/ups/etc\&. .sp \fBNUT_STATEPATH\fR is the path name of the directory in which \fBupsd\fR keeps state information\&. If this variable is not set, \fBupsd\fR uses a built\-in default, which is often /var/state/ups\&. The \fBSTATEPATH\fR directive in \fBupsd.conf\fR(5) overrides this variable\&. +.sp +\fBNUT_ALTPIDPATH\fR is the path name of the directory in which \fBupsd\fR and drivers store \&.pid files\&. If this variable is not set, \fBupsd\fR and drivers use either \fBNUT_STATEPATH\fR if set, or ALTPIDPATH if set, or otherwise the built\-in default \fBSTATEPATH\fR\&. .SH "SEE ALSO" .SS "Clients:" .sp -\fBupsc\fR(8), \fBupscmd\fR(8), \fBupsrw\fR(8), \fBupslog\fR(8), \fBupsmon\fR(8) +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupsc\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupscmd\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupsrw\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupslog\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupsmon\fR(8) +.RE .SS "CGI programs:" .sp -\fBupsset.cgi\fR(8), \fBupsstats.cgi\fR(8), \fBupsimage.cgi\fR(8) +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupsset.cgi\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupsstats.cgi\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupsimage.cgi\fR(8) +.RE +.SS "Driver control:" +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBnut-driver-enumerator\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupsdrvctl\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupsdrvsvcctl\fR(8) +.RE .SS "Drivers:" .sp -\fBnutupsdrv\fR(8), \fBapcsmart\fR(8), \fBbelkin\fR(8), \fBbelkinunv\fR(8), \fBbestuferrups\fR(8), \fBbestups\fR(8), \fBcyberpower\fR(8), \fBenergizerups\fR(8), \fBetapro\fR(8), \fBeverups\fR(8), \fBgenericups\fR(8), \fBisbmex\fR(8), \fBliebert\fR(8), \fBmasterguard\fR(8), \fBmge-shut\fR(8), \fBmge-utalk\fR(8), \fBoneac\fR(8), \fBpowercom\fR(8), \fBsafenet\fR(8), \fBsnmp-ups\fR(8), \fBtripplite\fR(8), \fBtripplitesu\fR(8), \fBvictronups\fR(8), +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBnutupsdrv\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBadelsystem_cbi\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBal175\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBapcsmart-old\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBapcsmart\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBapcupsd-ups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBasem\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBbcmxcp\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBbcmxcp_usb\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBbelkin\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBbelkinunv\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBbestfcom\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBbestfortress\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBbestuferrups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBbestups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBblazer-common\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBblazer_ser\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBblazer_usb\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBclone\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBdummy-ups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBetapro\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBeverups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBgamatronic\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBgeneric_modbus\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBgenericups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBhuawei-ups2000\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBisbmex\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBivtscd\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBliebert-esp2\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBliebert\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBmacosx-ups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBmasterguard\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBmetasys\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBmge-shut\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBmge-utalk\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBmicrodowell\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBmicrosol-apc\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBnetxml-ups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBnut-ipmipsu\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBnutdrv_atcl_usb\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBnutdrv_qx\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBnutdrv_siemens_sitop\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBoneac\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBoptiups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBphoenixcontact_modbus\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBpijuice\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBpowercom\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBpowerman-pdu\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBpowerpanel\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBrhino\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBrichcomm_usb\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBriello_ser\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBriello_usb\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBsafenet\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBsnmp-ups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBsocomec_jbus\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBsolis\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBtripplite\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBtripplite_usb\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBtripplitesu\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBupscode2\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBusbhid-ups\fR(8) +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\fBvictronups\fR(8) +.RE .SS "Internet resources:" .sp The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/upsd.conf.5 b/docs/man/upsd.conf.5 index a27a048..e5ef1ac 100644 --- a/docs/man/upsd.conf.5 +++ b/docs/man/upsd.conf.5 @@ -1,13 +1,13 @@ '\" t .\" Title: upsd.conf -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSD\&.CONF" "5" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSD\&.CONF" "5" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -41,6 +41,34 @@ upsd usually allows a driver to stop responding for up to 15 seconds before decl Most users should leave this at the default value\&. .RE .PP +"TRACKINGDELAY \fIseconds\fR" +.RS 4 +When instant commands and variables setting status tracking is enabled, status execution information are kept during this amount of time, and then cleaned up\&. This defaults to 3600 (1 hour)\&. +.RE +.PP +"ALLOW_NO_DEVICE \fIBoolean\fR" +.RS 4 +Normally upsd requires that at least one device section is defined in ups\&.conf when the daemon starts, to serve its data\&. For automatically managed services it may be preferred to have upsd always running, and reload the configuration when power devices become defined\&. +.sp +Boolean values +\fItrue\fR, +\fIyes\fR, +\fIon\fR +and +\fI1\fR +mean that the server would not refuse to start with zero device sections found in ups\&.conf\&. +.sp +Boolean values +\fIfalse\fR, +\fIno\fR, +\fIoff\fR +and +\fI0\fR +mean that the server should refuse to start if zero device sections were found in ups\&.conf\&. This is the default, unless the calling environment sets a same\-named variable to enforce a value for the current run\&. One way this can happen is somebody un\-commenting it in the +\fInut\&.conf\fR +file used by init\-scripts and service unit method scripts\&. +.RE +.PP "STATEPATH \fIpath\fR" .RS 4 Tell upsd to look for the driver state sockets in @@ -50,21 +78,28 @@ rather than the default that was compiled into the program\&. .PP "LISTEN \fIinterface\fR \fIport\fR" .RS 4 -Bind a listening port to the interface specified by its Internet address\&. This may be useful on hosts with multiple interfaces\&. You should not rely exclusively on this for security, as it can be subverted on many systems\&. +Bind a listening port to the interface specified by its Internet address or name\&. This may be useful on hosts with multiple interfaces\&. You should not rely exclusively on this for security, as it can be subverted on many systems\&. .sp -Listen on TCP port +Optionally listen on TCP port \fIport\fR instead of the default value which was compiled into the code\&. This overrides any value you may have set with \fIconfigure \-\-with\-port\fR\&. If you don\(cqt change it with configure or this value, upsd will listen on port 3493 for this interface\&. .sp Multiple LISTEN addresses may be specified\&. The default is to bind to 127\&.0\&.0\&.1 if no LISTEN addresses are specified (and ::1 if IPv6 support is compiled in)\&. .sp +To listen on all available interfaces, you may also use +\fI0\&.0\&.0\&.0\fR +for IPv4 and and +\fI::\fR +for IPv6\&. +.sp .if n \{\ .RS 4 .\} .nf LISTEN 127\&.0\&.0\&.1 LISTEN 192\&.168\&.50\&.1 +LISTEN myhostname\&.mydomain LISTEN ::1 LISTEN 2001:0db8:1234:08d3:1319:8a2e:0370:7344 .fi @@ -89,7 +124,7 @@ or the Security chapter of NUT user manual for more information on the SSL suppo .PP "CERTPATH \fIcertificate database\fR" .RS 4 -When compiled with SSL support with NSS backend, you can enter the certificate path here\&. Certificates are stored in a dedicated database (splitted in 3 files)\&. Specify the path of the database directory\&. +When compiled with SSL support with NSS backend, you can enter the certificate path here\&. Certificates are stored in a dedicated database (data split in 3 files)\&. Specify the path of the database directory\&. .RE .PP "CERTIDENT \fIcertificate name\fR \fIdatabase password\fR" @@ -138,9 +173,48 @@ to require to all clients a certificate to require to all clients a valid certificate .RE .RE +.PP +"DISABLE_WEAK_SSL \fIBOOLEAN\fR" +.RS 4 +Tell upsd to disable older/weak SSL/TLS protocols and ciphers\&. With relatively recent versions of OpenSSL or NSS it will be restricted to TLSv1\&.2 or better\&. Unless you have really ancient clients, you probably want to enable this\&. Currently disabled by default to ensure compatibility with existing setups\&. +.RE +.PP +"DEBUG_MIN \fIINTEGER\fR" +.RS 4 +Optionally specify a minimum debug level for +upsd +data daemon, e\&.g\&. for troubleshooting a deployment, without impacting foreground or background running mode directly\&. Command\-line option +\-D +can only increase this verbosity level\&. +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +if the running daemon receives a +reload +command, presence of the +DEBUG_MIN NUMBER +value in the configuration file can be used to tune debugging verbosity in the running service daemon (it is recommended to comment it away or set the minimum to explicit zero when done, to avoid huge journals and I/O system abuse)\&. Keep in mind that for this run\-time tuning, the +DEBUG_MIN +value +\fBpresent\fR +in +\fBreloaded\fR +configuration files is applied instantly and overrides any previously set value, from file or CLI options, regardless of older logging level being higher or lower than the newly found number; a missing (or commented away) value however does not change the previously active logging verbosity\&. +.sp .5v +.RE +.RE .SH "SEE ALSO" .sp \fBupsd\fR(8), \fBnutupsdrv\fR(8), \fBupsd.users\fR(5) -.SH "INTERNET RESOURCES" +.SS "Internet resources:" .sp The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/upsd.conf.txt b/docs/man/upsd.conf.txt index b1d5d24..410910e 100644 --- a/docs/man/upsd.conf.txt +++ b/docs/man/upsd.conf.txt @@ -26,6 +26,28 @@ to make upsd wait longer. + Most users should leave this at the default value. +"TRACKINGDELAY 'seconds'":: + +When instant commands and variables setting status tracking is enabled, status +execution information are kept during this amount of time, and then cleaned up. +This defaults to 3600 (1 hour). + +"ALLOW_NO_DEVICE 'Boolean'":: + +Normally upsd requires that at least one device section is defined in ups.conf +when the daemon starts, to serve its data. For automatically managed services +it may be preferred to have upsd always running, and reload the configuration +when power devices become defined. ++ +Boolean values 'true', 'yes', 'on' and '1' mean that the server would not +refuse to start with zero device sections found in ups.conf. ++ +Boolean values 'false', 'no', 'off' and '0' mean that the server should refuse +to start if zero device sections were found in ups.conf. This is the default, +unless the calling environment sets a same-named variable to enforce a value +for the current run. One way this can happen is somebody un-commenting it in +the 'nut.conf' file used by init-scripts and service unit method scripts. + "STATEPATH 'path'":: Tell upsd to look for the driver state sockets in 'path' rather @@ -33,22 +55,26 @@ than the default that was compiled into the program. "LISTEN 'interface' 'port'":: -Bind a listening port to the interface specified by its Internet -address. This may be useful on hosts with multiple interfaces. -You should not rely exclusively on this for security, as it can be -subverted on many systems. +Bind a listening port to the interface specified by its Internet address or +name. This may be useful on hosts with multiple interfaces. +You should not rely exclusively on this for security, as it can be subverted +on many systems. + -Listen on TCP port 'port' instead of the default value which was -compiled into the code. This overrides any value you may have set -with 'configure --with-port'. If you don't change it with configure -or this value, upsd will listen on port 3493 for this interface. +Optionally listen on TCP port 'port' instead of the default value which was +compiled into the code. This overrides any value you may have set with +'configure --with-port'. If you don't change it with configure or this value, +upsd will listen on port 3493 for this interface. + Multiple LISTEN addresses may be specified. The default is to bind to 127.0.0.1 if no LISTEN addresses are specified (and ::1 if IPv6 support is compiled in). ++ +To listen on all available interfaces, you may also use '0.0.0.0' for IPv4 and +and '::' for IPv6. LISTEN 127.0.0.1 LISTEN 192.168.50.1 + LISTEN myhostname.mydomain LISTEN ::1 LISTEN 2001:0db8:1234:08d3:1319:8a2e:0370:7344 + @@ -76,9 +102,9 @@ NUT user manual for more information on the SSL support in NUT. When compiled with SSL support with NSS backend, you can enter the certificate path here. -Certificates are stored in a dedicated database (splitted in 3 files). +Certificates are stored in a dedicated database (data split in 3 files). Specify the path of the database directory. - + "CERTIDENT 'certificate name' 'database password'":: When compiled with SSL support with NSS backend, you can specify the @@ -95,11 +121,38 @@ Possible values are : - '1' to require to all clients a certificate - '2' to require to all clients a valid certificate +"DISABLE_WEAK_SSL 'BOOLEAN'":: + +Tell upsd to disable older/weak SSL/TLS protocols and ciphers. +With relatively recent versions of OpenSSL or NSS it will be restricted +to TLSv1.2 or better. +Unless you have really ancient clients, you probably want to enable this. +Currently disabled by default to ensure compatibility with existing setups. + +"DEBUG_MIN 'INTEGER'":: + +Optionally specify a minimum debug level for `upsd` data daemon, e.g. for +troubleshooting a deployment, without impacting foreground or background +running mode directly. Command-line option `-D` can only increase this +verbosity level. ++ +NOTE: if the running daemon receives a `reload` command, presence of the +`DEBUG_MIN NUMBER` value in the configuration file can be used to tune +debugging verbosity in the running service daemon (it is recommended to +comment it away or set the minimum to explicit zero when done, to avoid +huge journals and I/O system abuse). Keep in mind that for this run-time +tuning, the `DEBUG_MIN` value *present* in *reloaded* configuration files +is applied instantly and overrides any previously set value, from file +or CLI options, regardless of older logging level being higher or lower +than the newly found number; a missing (or commented away) value however +does not change the previously active logging verbosity. + SEE ALSO -------- linkman:upsd[8], linkman:nutupsdrv[8], linkman:upsd.users[5] -INTERNET RESOURCES ------------------- +Internet resources: +~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/upsd.txt b/docs/man/upsd.txt index 64cff41..25d92ca 100644 --- a/docs/man/upsd.txt +++ b/docs/man/upsd.txt @@ -8,9 +8,10 @@ upsd - UPS information server SYNOPSIS -------- + *upsd* -h -*upsd* ['OPTIONS'] +*upsd* ['OPTIONS'] DESCRIPTION ----------- @@ -43,8 +44,23 @@ are: *reload*;; reread configuration files *stop*;; stop process and exit +*-P* 'pid':: +Send the command signal above using specified PID number, rather than +consulting the PID file. This can help define service units which +start `upsd` as a foreground process so it does not create a PID file. +See also `-FF` option as an alternative. + *-D*:: -Raise the debug level. Use this multiple times for additional details. +Raise the debugging level. upsd will run in the foreground by default, +and will print information on stdout about the monitoring process. +Use this option multiple times for more details. + +*-F*:: +upsd will run in the foreground, regardless of debugging settings. +Specify twice (`-FF` or `-F -F`) to save the PID file even in this mode. + +*-B*:: +upsd will run in the background, regardless of debugging settings. *-h*:: Display the help text. @@ -73,15 +89,15 @@ upsd can reload its configuration files without shutting down the process if you send it a SIGHUP or start it again with `-c reload`. This only works if the background process is able to read those files. -If you think that upsd can't reload, check your syslogs for error messages. +If you think that upsd can't reload, check your syslog for error messages. If it's complaining about not being able to read the files, then you need to adjust your system to make it possible. Either change the permissions on the files, or run upsd as another user that will be able to read them. DO NOT make your upsd.conf or upsd.users world-readable, as those files hold important authentication information. In the wrong hands, it could -be used by some evil person to spoof your master upsmon and command your -systems to shut down. +be used by some evil person to spoof your primary-mode upsmon and command +your systems to shut down. DIAGNOSTICS ----------- @@ -126,35 +142,47 @@ ENVIRONMENT VARIABLES `upsd.conf` and other configuration files. If this variable is not set, *upsd* uses a built-in default, which is often `/usr/local/ups/etc`. -*NUT_STATEPATH* is the path name of the directory in which +*NUT_STATEPATH* is the path name of the directory in which *upsd* keeps state information. If this variable is not set, *upsd* uses a built-in default, which is often `/var/state/ups`. The *STATEPATH* directive in linkman:upsd.conf[5] overrides this variable. +*NUT_ALTPIDPATH* is the path name of the directory in which +*upsd* and drivers store .pid files. If this variable is not set, +*upsd* and drivers use either *NUT_STATEPATH* if set, or ALTPIDPATH if set, +or otherwise the built-in default *STATEPATH*. + SEE ALSO -------- Clients: ~~~~~~~~ -linkman:upsc[8], linkman:upscmd[8], -linkman:upsrw[8], linkman:upslog[8], linkman:upsmon[8] + +- linkman:upsc[8] +- linkman:upscmd[8] +- linkman:upsrw[8] +- linkman:upslog[8] +- linkman:upsmon[8] CGI programs: ~~~~~~~~~~~~~ -linkman:upsset.cgi[8], linkman:upsstats.cgi[8], linkman:upsimage.cgi[8] + +- linkman:upsset.cgi[8] +- linkman:upsstats.cgi[8] +- linkman:upsimage.cgi[8] + +Driver control: +~~~~~~~~~~~~~~~ + +include::{builddir}/linkman-drivertool-names.txt[] Drivers: ~~~~~~~~ -linkman:nutupsdrv[8], -linkman:apcsmart[8], linkman:belkin[8], linkman:belkinunv[8], -linkman:bestuferrups[8], linkman:bestups[8], -linkman:cyberpower[8], linkman:energizerups[8], linkman:etapro[8], -linkman:everups[8], linkman:genericups[8], -linkman:isbmex[8], linkman:liebert[8], linkman:masterguard[8], -linkman:mge-shut[8], linkman:mge-utalk[8], linkman:oneac[8], -linkman:powercom[8], linkman:safenet[8], linkman:snmp-ups[8], -linkman:tripplite[8], linkman:tripplitesu[8], linkman:victronups[8], + +- linkman:nutupsdrv[8] +include::{builddir}/linkman-driver-names.txt[] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/upsd.users.5 b/docs/man/upsd.users.5 index 9373bb7..606a700 100644 --- a/docs/man/upsd.users.5 +++ b/docs/man/upsd.users.5 @@ -1,13 +1,13 @@ '\" t .\" Title: upsd.users -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSD\&.USERS" "5" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSD\&.USERS" "5" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -68,9 +68,9 @@ Here are some examples to get you started: .RS 4 .\} .nf -[monmaster] +[upswired] password = blah - upsmon master + upsmon primary .fi .if n \{\ .RE @@ -80,9 +80,9 @@ Here are some examples to get you started: .RS 4 .\} .nf -[monslave] +[observer] password = abcd - upsmon slave + upsmon secondary .fi .if n \{\ .RE @@ -126,13 +126,13 @@ file supplied with the distribution contains a list of most of the known command .PP \fBupsmon\fR .RS 4 -Add the necessary actions for a upsmon process to work\&. This is either set to "master" or "slave"\&. +Add the necessary actions for a upsmon process to work\&. This is either set to "primary" or "secondary"\&. .sp Do not attempt to assign actions to upsmon by hand, as you may miss something important\&. This method of designating a "upsmon user" was created so internal capabilities could be changed later on without breaking existing installations\&. .RE .SH "SEE ALSO" .sp \fBupsd\fR(8), \fBupsd.conf\fR(5) -.SH "INTERNET RESOURCES" +.SS "Internet resources:" .sp The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/upsd.users.txt b/docs/man/upsd.users.txt index 4f73ceb..6b287d0 100644 --- a/docs/man/upsd.users.txt +++ b/docs/man/upsd.users.txt @@ -3,6 +3,7 @@ UPSD.USERS(5) NAME ---- + upsd.users - Administrative user definitions for NUT upsd DESCRIPTION @@ -12,7 +13,7 @@ Administrative commands such as setting variables and the instant commands are powerful, and access to them needs to be restricted. This file defines who may access them, and what is available. -Each user gets its own section. The fields in that section set the +Each user gets its own section. The fields in that section set the parameters associated with that user's privileges. The section begins with the name of the user in brackets, and continues until the next user name in brackets or EOF. These users are independent of /etc/passwd. @@ -30,13 +31,13 @@ Here are some examples to get you started: instcmds = test.panel.start instcmds = test.panel.stop - [monmaster] + [upswired] password = blah - upsmon master + upsmon primary - [monslave] + [observer] password = abcd - upsmon slave + upsmon secondary FIELDS ------ @@ -53,7 +54,7 @@ actions are: SET;; change the value of certain variables in the UPS - FSD;; set the forced shutdown flag in the UPS. This is + FSD;; set the forced shutdown flag in the UPS. This is equivalent to an "on battery + low battery" situation for the purposes of monitoring. @@ -72,7 +73,7 @@ of most of the known command names. *upsmon*:: Add the necessary actions for a upsmon process to work. This is either -set to "master" or "slave". +set to "primary" or "secondary". + Do not attempt to assign actions to upsmon by hand, as you may miss something important. This method of designating a "upsmon user" was @@ -84,7 +85,8 @@ SEE ALSO linkman:upsd[8], linkman:upsd.conf[5] -INTERNET RESOURCES ------------------- +Internet resources: +~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/upsdrvctl.8 b/docs/man/upsdrvctl.8 index 1acb6d8..a3a2ccc 100644 --- a/docs/man/upsdrvctl.8 +++ b/docs/man/upsdrvctl.8 @@ -1,13 +1,13 @@ '\" t .\" Title: upsdrvctl -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSDRVCTL" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSDRVCTL" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -39,6 +39,8 @@ upsdrvctl \- UPS driver controller \fBupsdrvctl\fR provides a uniform interface for controlling your UPS drivers\&. You should use upsdrvctl instead of direct calls to the drivers whenever possible\&. .sp When used properly, upsdrvctl lets you maintain identical startup scripts across multiple systems with different UPS configurations\&. +.sp +Note: For operating systems with service management frameworks, such as Solaris SMF or Linux systemd, the \fBupsdrvsvcctl\fR may be a better choice\&. .SH "OPTIONS" .PP \fB\-h\fR @@ -78,6 +80,13 @@ This may be set in ups\&.conf with "user" in the global section\&. .RS 4 Raise the debug level\&. Use this multiple times for additional details\&. .RE +.PP +\fB\-d\fR +.RS 4 +Pass the selected debug level from +upsdrvctl +to launched drivers\&. +.RE .SH "COMMANDS" .sp upsdrvctl supports three commands \- start, stop and shutdown\&. They take an optional argument which is a UPS name from \fBups.conf\fR(5)\&. Without that argument, they operate on every UPS that is currently configured\&. @@ -118,6 +127,22 @@ Command the UPS driver(s) to run their shutdown sequence\&. Drivers are stopped this will probably power off your computers, so don\(cqt play around with this option\&. Only use it when your systems are prepared to lose power\&. .sp .5v .RE +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +refer to \fBups.conf\fR(5) for using the \fBnowait\fR parameter\&. +.sp .5v +.RE .SH "ENVIRONMENT VARIABLES" .sp \fBNUT_CONFPATH\fR is the path name of the directory that contains upsd\&.conf and other configuration files\&. If this variable is not set, \fBupsdrvctl\fR the driver use a built\-in default, which is often /usr/local/ups/etc\&. @@ -126,7 +151,7 @@ this will probably power off your computers, so don\(cqt play around with this o upsdrvctl will return a nonzero exit code if it encounters an error while performing the desired operation\&. This will also happen if a driver takes longer than the \fImaxstartdelay\fR period to enter the background\&. .SH "SEE ALSO" .sp -\fBnutupsdrv\fR(8), \fBupsd\fR(8), \fBups.conf\fR(5) +\fBupsdrvsvcctl\fR(8), \fBnutupsdrv\fR(8), \fBupsd\fR(8), \fBups.conf\fR(5) .SS "Internet resources:" .sp The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/upsdrvctl.txt b/docs/man/upsdrvctl.txt index 52e5509..46ec658 100644 --- a/docs/man/upsdrvctl.txt +++ b/docs/man/upsdrvctl.txt @@ -1,4 +1,4 @@ -UPSDRVCTL(8) +UPSDRVCTL(8) ============ NAME @@ -8,6 +8,7 @@ upsdrvctl - UPS driver controller SYNOPSIS -------- + *upsdrvctl* -h *upsdrvctl* ['OPTIONS'] {start | stop | shutdown} ['ups'] @@ -22,6 +23,9 @@ whenever possible. When used properly, upsdrvctl lets you maintain identical startup scripts across multiple systems with different UPS configurations. +Note: For operating systems with service management frameworks, such as +Solaris SMF or Linux systemd, the *upsdrvsvcctl* may be a better choice. + OPTIONS ------- @@ -54,6 +58,9 @@ This may be set in ups.conf with "user" in the global section. *-D*:: Raise the debug level. Use this multiple times for additional details. +*-d*:: +Pass the selected debug level from `upsdrvctl` to launched drivers. + COMMANDS -------- @@ -77,6 +84,8 @@ WARNING: this will probably power off your computers, so don't play around with this option. Only use it when your systems are prepared to lose power. +NOTE: refer to linkman:ups.conf[5] for using the *nowait* parameter. + ENVIRONMENT VARIABLES --------------------- @@ -95,8 +104,10 @@ background. SEE ALSO -------- -linkman:nutupsdrv[8], linkman:upsd[8], linkman:ups.conf[5] + +linkman:upsdrvsvcctl[8], linkman:nutupsdrv[8], linkman:upsd[8], linkman:ups.conf[5] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/upsdrvsvcctl.8 b/docs/man/upsdrvsvcctl.8 new file mode 100644 index 0000000..c436e6c --- /dev/null +++ b/docs/man/upsdrvsvcctl.8 @@ -0,0 +1,206 @@ +'\" t +.\" Title: upsdrvsvcctl +.\" Author: [see the "AUTHOR" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 +.\" Manual: NUT Manual +.\" Source: Network UPS Tools 2.8.0 +.\" Language: English +.\" +.TH "UPSDRVSVCCTL" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +upsdrvsvcctl \- UPS driver service instance controller +.SH "SYNOPSIS" +.sp +\fBupsdrvsvcctl\fR \-h +.sp +\fBupsdrvsvcctl\fR [\fIOPTIONS\fR] {start | stop } [\fIups\fR] +.SH "DESCRIPTION" +.sp +\fBupsdrvsvcctl\fR provides a uniform interface for controlling your UPS drivers wrapped into service instances on platforms which support that (currently this covers Linux distributions with systemd and systems derived from Solaris 10 codebase, including proprietary Sun/Oracle Solaris and numerous open\-source illumos distributions with SMF)\&. It may be not installed in packaging for other operating systems\&. +.sp +When used properly, upsdrvsvcctl lets you maintain identical startup scripts across multiple systems with different UPS configurations\&. +.sp +The goal of this solution is to allow the services of \fBupsd\fR data server to start up even if some of the power devices are currently not accessible, and for NUT drivers to be automatically restarted by the system in case of problems (driver bug, startup failure)\&. It also allows for faster startup of systems which monitor several devices, by letting each driver to start in parallel with others, and not with a sequential loop like was done previously\&. +.sp +Independent service instances for each NUT driver also allow one to configure further dependencies, such as that networking must be available for SNMP and similar drivers (but is not needed for local\-medium drivers such as serial or USB)\&. +.sp +The old monolithic "all or nothing" solution requiring that all drivers must be running, which sufficed for deployments with a few UPSes, did not really work well for monitoring larger deployments\&. It was also not easy to strike a pre\-packaged balance between early UPS protection for USB/serial home setups vs\&. waiting for network on larger ones\&. +.sp +\fBupsdrvsvcctl\fR is a script which mimics the operation of \fBupsdrvctl\fR program (where possible) to provide similar end\-user experience when manipulating drivers wrapped into service instances rather than as directly executed daemons\&. It relies on \fBnut\-driver\-enumerator\&.sh\fR for a large part of actual operations\&. +.sp +You should use upsdrvsvcctl instead of direct calls to the drivers and daemon\-based management with \fBupsdrvctl\fR whenever possible (that is, for "production" use on compatible OSes)\&. Otherwise (testing, other OSes) the \fBupsdrvctl\fR is a recommended option\&. +.SH "OPTIONS" +.PP +\fB\-h\fR +.RS 4 +Display the help text\&. +.RE +.PP +\fB\-t\fR +.RS 4 +Enable testing mode\&. Testing mode makes upsdrvsvcctl display the actions it would execute without actually doing them\&. +.RE +.SH "OPTIONS OF UPSDRVCTL NOT (CURRENTLY) APPLICABLE TO UPSDRVSVCCTL" +.sp +Options like \fI\-r\fR, \fI\-u\fR or \fI\-D\fR could be handled by properties of the service instances themselves, with this script helping to configure them (assuming proper privileges of the user who called it)\&. This is not a "production" use case, though, to change such options on a configured system \(em so for experiments and troubleshooting, it may be better to stop the service instance and play with \fBupsdrvctl\fR directly\&. +.PP +\fB\-r\fR \fIdirectory\fR +.RS 4 +If starting a driver, this value will direct it to +\fBchroot\fR(2) into +\fIdirectory\fR\&. This can be useful when securing systems\&. +.RE +.sp +This may be set in the ups\&.conf with "chroot" in the global section\&. +.PP +\fB\-u\fR \fIusername\fR +.RS 4 +If starting a driver, this value will direct it to +\fBsetuid\fR(2) to the user id associated with +\fIusername\fR\&. +.RE +.sp +If the driver is started as root without specifying this value, it will use the username that was compiled into the binary\&. This defaults to "nobody", and is far from ideal\&. +.sp +This may be set in ups\&.conf with "user" in the global section\&. +.PP +\fB\-D\fR +.RS 4 +Raise the driver debug level\&. Use this multiple times for additional details\&. +.RE +.SH "COMMANDS" +.sp +\fBupsdrvsvcctl\fR supports three of the commands processed by \fBupsdrvctl\fR \(em start, stop and shutdown\&. They take an optional argument which is a UPS name from \fBups.conf\fR(5)\&. Without that argument, they operate on every UPS that is currently configured\&. +.sp +Note: shutdown is currently supported by stopping the driver service instances to release the potentially held ports etc\&., calling the \fBupsdrvctl\fR directly for issuing the shutdown command, and restarting the driver service instances to reconnect when the device comes back online\&. +.PP +\fBstart\fR +.RS 4 +Start the UPS driver(s)\&. In case of failure, further attempts may be executed by using the +\fImaxretry\fR +and +\fIretrydelay\fR +options \- see +\fBups.conf\fR(5)\&. +.RE +.PP +\fBstop\fR +.RS 4 +Stop the UPS driver(s)\&. +.RE +.sp +\fBupsdrvsvcctl\fR also supports further operations for troubleshooting the mapping of NUT driver section names to the service instance names (which may differ due to limitations of various systems)\&. +.PP +\fBlist\fR +.RS 4 +list the currently active mapping of service instances to device sections +.RE +.PP +\fBresync\fR +.RS 4 +update the mapping of service instances for NUT drivers to device section names used in +\fIups\&.conf\fR +(register new instances, tear down obsoleted ones)\&. +.RE +.SH "COMMANDS OF UPSDRVCTL NOT (CURRENTLY) APPLICABLE TO UPSDRVSVCCTL" +.PP +\fBshutdown\fR +.RS 4 +Command the UPS driver(s) to run their shutdown sequence\&. Drivers are stopped according to their sdorder value \- see +\fBups.conf\fR(5)\&. +.RE +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBWarning\fR +.ps -1 +.br +.sp +this will probably power off your computers, so don\(cqt play around with this option\&. Only use it when your systems are prepared to lose power\&. +.sp .5v +.RE +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +.sp +refer to \fBups.conf\fR(5) for using the \fBnowait\fR parameter\&. +.sp .5v +.RE +.SH "ENVIRONMENT VARIABLES" +.sp +\fBNUT_CONFPATH\fR is the path name of the directory that contains upsd\&.conf and other configuration files\&. If this variable is not set, \fBupsdrvsvcctl\fR (or rather \fBnut\-driver\-enumerator\&.sh\fR) would use a built\-in default, which is often /usr/local/ups/etc\&. +.SH "DIAGNOSTICS" +.sp +upsdrvsvcctl will return a nonzero exit code if it encounters an error while performing the desired operation\&. This will also happen if a driver takes longer than the \fImaxstartdelay\fR period to enter the background\&. +.sp +Any messages issued by the \fBupsdrvctl\fR program used to start the NUT drivers as part of the service instances\*(Aq implementations, or by the drivers themselves, will be logged by the service management framework facilities and will not appear in your interactive terminal used to manage the driver\&. +.sp +Use upsdrvsvcctl list or upsdrvsvcctl list NUT\-device to find out the service instance name for the NUT driver (section name) you are interested in\&. Then look up the service logs (where the outputs of the service implementation program as well as the framework messages about this service are stored), as suggested below: +.PP +\fBLinux systemd\fR +.RS 4 +Messages will normally be kept in the service journal, so: +.sp +.if n \{\ +.RS 4 +.\} +.nf +journalctl \-lu nut\-driver@instance\-name +.fi +.if n \{\ +.RE +.\} +.RE +.sp +Note that your local system configuration may be impacted by such nuances as passing the journal data to a standard syslog server, and/or by having a small cache for locally stored journal messages (so older entries would disappear)\&. There may also be or not be a copy of the journals stored in the filesystem\&. +.PP +\fBSolaris SMF\fR +.RS 4 +Look for +/var/svc/log/system\-power\-nut\-driver:instance\-name\&.log +file\&. +.RE +.SH "AUTHOR" +.sp +Jim Klimov +.SH "SEE ALSO" +.sp +\fBupsdrvctl\fR(8), \fBnutupsdrv\fR(8), \fBupsd\fR(8), \fBnut-driver-enumerator\fR(8), \fBups.conf\fR(5) +.SS "Internet resources:" +.sp +The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ diff --git a/docs/man/upsdrvsvcctl.txt b/docs/man/upsdrvsvcctl.txt new file mode 100644 index 0000000..fdace1f --- /dev/null +++ b/docs/man/upsdrvsvcctl.txt @@ -0,0 +1,205 @@ +UPSDRVSVCCTL(8) +=============== + +NAME +---- + +upsdrvsvcctl - UPS driver service instance controller + +SYNOPSIS +-------- + +*upsdrvsvcctl* -h + +*upsdrvsvcctl* ['OPTIONS'] {start | stop } ['ups'] + +DESCRIPTION +----------- + +*upsdrvsvcctl* provides a uniform interface for controlling your UPS +drivers wrapped into service instances on platforms which support that +(currently this covers Linux distributions with systemd and systems +derived from Solaris 10 codebase, including proprietary Sun/Oracle +Solaris and numerous open-source illumos distributions with SMF). +It may be not installed in packaging for other operating systems. + +When used properly, upsdrvsvcctl lets you maintain identical startup +scripts across multiple systems with different UPS configurations. + +The goal of this solution is to allow the services of *upsd* data +server to start up even if some of the power devices are currently +not accessible, and for NUT drivers to be automatically restarted +by the system in case of problems (driver bug, startup failure). +It also allows for faster startup of systems which monitor several +devices, by letting each driver to start in parallel with others, +and not with a sequential loop like was done previously. + +Independent service instances for each NUT driver also allow one +to configure further dependencies, such as that networking must be +available for SNMP and similar drivers (but is not needed for +local-medium drivers such as serial or USB). + +The old monolithic "all or nothing" solution requiring that all +drivers must be running, which sufficed for deployments with a few +UPSes, did not really work well for monitoring larger deployments. +It was also not easy to strike a pre-packaged balance between early +UPS protection for USB/serial home setups vs. waiting for network +on larger ones. + +*upsdrvsvcctl* is a script which mimics the operation of *upsdrvctl* +program (where possible) to provide similar end-user experience when +manipulating drivers wrapped into service instances rather than as +directly executed daemons. It relies on *nut-driver-enumerator.sh* +for a large part of actual operations. + +You should use upsdrvsvcctl instead of direct calls to the drivers +and daemon-based management with *upsdrvctl* whenever possible (that +is, for "production" use on compatible OSes). Otherwise (testing, +other OSes) the *upsdrvctl* is a recommended option. + +OPTIONS +------- + +*-h*:: +Display the help text. + +*-t*:: +Enable testing mode. Testing mode makes upsdrvsvcctl display the actions +it would execute without actually doing them. + + + +OPTIONS OF UPSDRVCTL NOT (CURRENTLY) APPLICABLE TO UPSDRVSVCCTL +--------------------------------------------------------------- + +Options like '-r', '-u' or '-D' could be handled by properties of the +service instances themselves, with this script helping to configure +them (assuming proper privileges of the user who called it). This is +not a "production" use case, though, to change such options on a +configured system -- so for experiments and troubleshooting, it may +be better to stop the service instance and play with *upsdrvctl* +directly. + +*-r* 'directory':: +If starting a driver, this value will direct it to *chroot*(2) into +'directory'. This can be useful when securing systems. + +This may be set in the ups.conf with "chroot" in the global section. + +*-u* 'username':: +If starting a driver, this value will direct it to *setuid*(2) to +the user id associated with 'username'. + +If the driver is started as root without specifying this value, it will +use the username that was compiled into the binary. This defaults to +"nobody", and is far from ideal. + +This may be set in ups.conf with "user" in the global section. + +*-D*:: +Raise the driver debug level. Use this multiple times for additional +details. + +COMMANDS +-------- + +*upsdrvsvcctl* supports three of the commands processed by *upsdrvctl* -- +start, stop and shutdown. They take an optional argument which is a UPS +name from linkman:ups.conf[5]. Without that argument, they operate on +every UPS that is currently configured. + +Note: shutdown is currently supported by stopping the driver service +instances to release the potentially held ports etc., calling the +*upsdrvctl* directly for issuing the shutdown command, and restarting +the driver service instances to reconnect when the device comes back +online. + +*start*:: +Start the UPS driver(s). In case of failure, further attempts may be executed +by using the 'maxretry' and 'retrydelay' options - see linkman:ups.conf[5]. + +*stop*:: +Stop the UPS driver(s). + +*upsdrvsvcctl* also supports further operations for troubleshooting the +mapping of NUT driver section names to the service instance names (which +may differ due to limitations of various systems). + +*list*:: +list the currently active mapping of service instances to device sections + +*resync*:: +update the mapping of service instances for NUT drivers to device section +names used in 'ups.conf' (register new instances, tear down obsoleted ones). + + +COMMANDS OF UPSDRVCTL NOT (CURRENTLY) APPLICABLE TO UPSDRVSVCCTL +---------------------------------------------------------------- + +*shutdown*:: +Command the UPS driver(s) to run their shutdown sequence. Drivers are +stopped according to their sdorder value - see linkman:ups.conf[5]. + +WARNING: this will probably power off your computers, so don't +play around with this option. Only use it when your systems are prepared +to lose power. + +NOTE: refer to linkman:ups.conf[5] for using the *nowait* parameter. + +ENVIRONMENT VARIABLES +--------------------- + +*NUT_CONFPATH* is the path name of the directory that contains +`upsd.conf` and other configuration files. If this variable is not set, +*upsdrvsvcctl* (or rather *nut-driver-enumerator.sh*) would use a built-in +default, which is often `/usr/local/ups/etc`. + +DIAGNOSTICS +----------- + +upsdrvsvcctl will return a nonzero exit code if it encounters an error +while performing the desired operation. This will also happen if a +driver takes longer than the 'maxstartdelay' period to enter the +background. + +Any messages issued by the *upsdrvctl* program used to start the NUT +drivers as part of the service instances' implementations, or by the +drivers themselves, will be logged by the service management framework +facilities and will not appear in your interactive terminal used to +manage the driver. + +Use `upsdrvsvcctl list` or `upsdrvsvcctl list NUT-device` to find out +the service instance name for the NUT driver (section name) you are +interested in. Then look up the service logs (where the outputs of the +service implementation program as well as the framework messages about +this service are stored), as suggested below: + +*Linux systemd*:: +Messages will normally be kept in the service journal, so: + + journalctl -lu nut-driver@instance-name + +Note that your local system configuration may be impacted by such +nuances as passing the journal data to a standard syslog server, +and/or by having a small cache for locally stored journal messages +(so older entries would disappear). There may also be or not be a +copy of the journals stored in the filesystem. + +*Solaris SMF*:: +Look for `/var/svc/log/system-power-nut-driver:instance-name.log` file. + +AUTHOR +------ + +Jim Klimov + +SEE ALSO +-------- + +linkman:upsdrvctl[8], linkman:nutupsdrv[8], linkman:upsd[8], +linkman:nut-driver-enumerator[8], linkman:ups.conf[5] + +Internet resources: +~~~~~~~~~~~~~~~~~~~ + +The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/upsimage.cgi.8 b/docs/man/upsimage.cgi.8 index 601ebe5..629f573 100644 --- a/docs/man/upsimage.cgi.8 +++ b/docs/man/upsimage.cgi.8 @@ -1,13 +1,13 @@ '\" t .\" Title: upsimage.cgi -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSIMAGE\&.CGI" "8" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSIMAGE\&.CGI" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -64,6 +64,26 @@ upsstats will only talk to \fBupsd\fR(8) servers that have been defined in your \fBupsd\fR(8), \fBupsstats.cgi\fR(8) .SS "Internet resources:" .sp -The gd home page: http://libgd\&.bitbucket\&.org +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The NUT (Network UPS Tools) home page: +http://www\&.networkupstools\&.org/ +.RE .sp -The NUT (Network UPS Tools) home page: http://www\&.networkupstools\&.org/ +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +The gd home page: +http://libgd\&.bitbucket\&.org +.RE diff --git a/docs/man/upsimage.cgi.txt b/docs/man/upsimage.cgi.txt index 9ede74a..bdf23b8 100644 --- a/docs/man/upsimage.cgi.txt +++ b/docs/man/upsimage.cgi.txt @@ -45,6 +45,5 @@ linkman:upsd[8], linkman:upsstats.cgi[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ -The gd home page: http://libgd.bitbucket.org - -The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ +* The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ +* The gd home page: http://libgd.bitbucket.org diff --git a/docs/man/upslog.8 b/docs/man/upslog.8 index c0ecff4..976741f 100644 --- a/docs/man/upslog.8 +++ b/docs/man/upslog.8 @@ -1,13 +1,13 @@ '\" t .\" Title: upslog -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSLOG" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSLOG" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -115,7 +115,17 @@ library\&. .RS 4 Store the results in this file\&. .sp -You can use "\-" for stdout, but upslog will remain in the foreground\&. +You can use "\-" for stdout, but upslog will remain in the foreground by default\&. +.RE +.PP +\fB\-F\fR +.RS 4 +upslog will run in the foreground, regardless of logging target\&. +.RE +.PP +\fB\-B\fR +.RS 4 +upslog will run in the background, regardless of logging target\&. .RE .PP \fB\-s\fR \fIups\fR @@ -126,7 +136,7 @@ upsname[@hostname[:port]]\&. The default hostname is "localhost"\&. .PP \fB\-u\fR \fIusername\fR .RS 4 -If started as root, upsmon will +If started as root, upslog will \fBsetuid\fR(2) to the user id associated with \fIusername\fR for security\&. @@ -138,7 +148,7 @@ is not defined, it will use the value that was compiled into the program\&. This .SH "SERVICE DELAYS" .sp The interval value is merely the number given to \fBsleep\fR(3) after running through the format string\&. Therefore, a query will actually take slightly longer than the interval, depending on the speed of your system\&. -.SH "ON-DEMAND LOGGING" +.SH "ON\-DEMAND LOGGING" .sp Sending a USR1 signal to a running \fBupslog\fR process makes it wake from the current sleep and log immediately\&. This is useful when triggered from a \fBupssched\fR event trigger (e\&.g\&. AT ONBATT or AT ONLINE) to ensure that an entry always exists, even if the power goes away for a period of time shorter than that specified by the \-i argument\&. .SH "LOG ROTATION" diff --git a/docs/man/upslog.txt b/docs/man/upslog.txt index 4571cc3..f405104 100644 --- a/docs/man/upslog.txt +++ b/docs/man/upslog.txt @@ -37,7 +37,7 @@ within this string are: %TIME format%;; Insert the time with strftime formatting -%ETIME%;; Insert the number of seconds, ala time_t. This is now a +%ETIME%;; Insert the number of seconds, ala time_t. This is now a 10 digit number. %HOST%;; insert the local hostname @@ -50,8 +50,8 @@ within this string are: The default format string is: - %TIME @Y@m@d @H@M@S% %VAR battery.charge% %VAR input.voltage% - %VAR ups.load% [%VAR ups.status%] %VAR ups.temperature% + %TIME @Y@m@d @H@M@S% %VAR battery.charge% %VAR input.voltage% + %VAR ups.load% [%VAR ups.status%] %VAR ups.temperature% %VAR input.frequency% *-i* 'interval':: @@ -65,16 +65,23 @@ the linkman:upsclient[3] library. Store the results in this file. + -You can use "-" for stdout, but upslog will remain in the foreground. +You can use "-" for stdout, but upslog will remain in the foreground +by default. + +*-F*:: +upslog will run in the foreground, regardless of logging target. + +*-B*:: +upslog will run in the background, regardless of logging target. *-s* 'ups':: -Monitor this UPS. The format for this option is +Monitor this UPS. The format for this option is +upsname[@hostname[:port]]+. The default hostname is "localhost". *-u* 'username':: -If started as root, upsmon will *setuid*(2) to the user id -associated with 'username' for security. +If started as root, upslog will *setuid*(2) to the user id +associated with 'username' for security. + If 'username' is not defined, it will use the value that was compiled into the program. This defaults to "nobody", which is less than ideal. @@ -108,13 +115,16 @@ SEE ALSO Server: ~~~~~~~ + linkman:upsd[8] Clients: ~~~~~~~~ + linkman:upsc[8], linkman:upscmd[8], linkman:upsrw[8], linkman:upsmon[8], linkman:upssched[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/upsmon.8 b/docs/man/upsmon.8 index 9f21c21..aa222bb 100644 --- a/docs/man/upsmon.8 +++ b/docs/man/upsmon.8 @@ -1,13 +1,13 @@ '\" t .\" Title: upsmon -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSMON" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSMON" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -33,14 +33,14 @@ upsmon \- UPS monitor and shutdown controller .sp \fBupsmon\fR \-h .sp -\fBupsmon\fR \-c \fIcommand\fR +\fBupsmon\fR \-c \fIcommand\fR [\-P \fIpid\fR] .sp -\fBupsmon\fR [\-D] [\-K] [\-p] [\-u \fIuser\fR] +\fBupsmon\fR [\-D] [\-F | \-B] [\-K] [\-p] [\-u \fIuser\fR] .SH "DESCRIPTION" .sp \fBupsmon\fR is the client process that is responsible for the most important part of UPS monitoring\(emshutting down the system when the power goes out\&. It can call out to other helper programs for notification purposes during power events\&. .sp -upsmon can monitor multiple systems using a single process\&. Every UPS that is defined in the \fBupsmon.conf\fR(5) configuration file is assigned a power value and a type (\fBslave\fR or \fBmaster\fR)\&. +upsmon can monitor multiple systems using a single process\&. Every UPS that is defined in the \fBupsmon.conf\fR(5) configuration file is assigned a power value and a type (\fBprimary\fR or \fBsecondary\fR)\&. .SH "OPTIONS" .PP \fB\-h\fR @@ -56,7 +56,7 @@ to the existing upsmon process\&. Valid commands are: .PP \fBfsd\fR .RS 4 -shutdown all master UPSes (use with caution) +shutdown all primary\-mode UPSes (use with caution) .RE .PP \fBstop\fR @@ -72,9 +72,26 @@ configuration file\&. See "reloading nuances" below if this doesn\(cqt work\&. .RE .RE .PP +\fB\-P\fR \fIpid\fR +.RS 4 +Send the command signal above using specified PID number, rather than consulting the PID file\&. This can help define service units which start main +upsmon +as a foreground process so it does not have to rely on a PID file\&. +.RE +.PP \fB\-D\fR .RS 4 -Raise the debugging level\&. upsmon will run in the foreground and prints information on stdout about the monitoring process\&. Use this multiple times for more details\&. +Raise the debugging level\&. upsmon will run in the foreground by default, and will print information on stdout about the monitoring process\&. Use this option multiple times for more details\&. +.RE +.PP +\fB\-F\fR +.RS 4 +upsmon will run in the foreground, regardless of debugging settings\&. +.RE +.PP +\fB\-B\fR +.RS 4 +upsmon will run in the background, regardless of debugging settings\&. .RE .PP \fB\-K\fR @@ -155,7 +172,7 @@ The \fIpowervalue\fR refers to how many power supplies on this system are being .sp The \fIusername\fR is a section in your \fBupsd.users\fR(5) file\&. Whatever password you set in that section must match the \fIpassword\fR set in this file\&. .sp -The type set in that section must also match the \fItype\fR here\-\- \fBmaster\fR or \fBslave\fR\&. In general, a master process is one running on the system with the UPS actually plugged into a serial port, and a slave is drawing power from the UPS but can\(cqt talk to it directly\&. See the section on UPS types for more\&. +The type set in that section must also match the \fItype\fR here \(em \fBprimary\fR or \fBsecondary\fR\&. In general, a primary process is one running on the system with the UPS actually plugged into a serial port, and a secondary is drawing power from the UPS but can\(cqt talk to it directly\&. See the section on UPS types for more\&. .SH "NOTIFY EVENTS" .sp \fBupsmon\fR senses several events as it monitors each UPS\&. They are called notify events as they can be used to tell the users and admins about the change in status\&. See the additional NOTIFY\-related sections below for information on customizing the delivery of these messages\&. @@ -214,9 +231,9 @@ NOTIFYCMD "/usr/local/bin/notifyme" .sp Remember to wrap the path in "quotes" if it contains any spaces\&. .sp -The program you run as your NOTIFYCMD can use the environment variables NOTIFYTYPE and UPSNAME to know what has happened and on which UPS\&. It also receives the notification message (see below) as the first (and only) argument, so you can deliver a preformatted message too\&. +The program you run as your NOTIFYCMD can use the environment variables NOTIFYTYPE and UPSNAME to know what has happened and on which UPS\&. It also receives the notification message (see below) as the first (and only) argument, so you can deliver a pre\-formatted message too\&. .sp -Note that the NOTIFYCMD will only be called for a given event when you set the EXEC flag by using the notify flags, below: +Note that the NOTIFYCMD will only be called for a given event when you set the EXEC flag by using the notify flags, as detailed below\&. .SH "NOTIFY FLAGS" .sp By default, all notify events (see above) generate a global message (wall) to all users, plus they are logged via the syslog\&. You can change this with the NOTIFYFLAG directive in the configuration file: @@ -323,17 +340,17 @@ MONITOR \fIupsname\fR \fIpowervalue\fR \fIusername\fR \fIpassword\fR \fItype\fR .sp Normally, you only have one power supply, so it will be set to 1\&. .sp -MONITOR myups@myhost 1 username mypassword master +MONITOR myups@myhost 1 username mypassword primary .sp On a large server with redundant power supplies, the power value for a UPS may be greater than 1\&. You may also have more than one of them defined\&. .sp -MONITOR ups\-alpha@myhost 2 username mypassword master +MONITOR ups\-alpha@myhost 2 username mypassword primary .sp -MONITOR ups\-beta@myhost 2 username mypassword master +MONITOR ups\-beta@myhost 2 username mypassword primary .sp -You can also set the power value for a UPS to 0 if it does not supply any power to that system\&. This is generally used when you want to use the upsmon notification features for a UPS even though it\(cqs not actually running the system that hosts upsmon\&. Don\(cqt set this to "master" unless you really want to power this UPS off when this instance of upsmon needs to shut down for its own reasons\&. +You can also set the power value for a UPS to 0 if it does not supply any power to that system\&. This is generally used when you want to use the upsmon notification features for a UPS even though it\(cqs not actually running the system that hosts upsmon\&. Don\(cqt set this to "primary" unless you really want to power this UPS off when this instance of upsmon needs to shut down for its own reasons\&. .sp -MONITOR faraway@anotherbox 0 username mypassword slave +MONITOR faraway@anotherbox 0 username mypassword secondary .sp The "minimum power value" is the number of power supplies that must be receiving power in order to keep the computer running\&. .sp @@ -350,13 +367,13 @@ MINSUPPLIES 3 When the current overall power value drops below the minimum power value, upsmon starts the shutdown sequence\&. This design allows you to lose some of your power supplies in a redundant power environment without bringing down the entire system while still working properly for smaller systems\&. .SH "UPS TYPES" .sp -\fBupsmon\fR and \fBupsd\fR(8) don\(cqt always run on the same system\&. When they do, any UPSes that are directly attached to the upsmon host should be monitored in "master" mode\&. This makes upsmon take charge of that equipment, and it will wait for slaves to disconnect before shutting down the local system\&. This allows the distant systems (monitoring over the network) to shut down cleanly before upsdrvctl shutdown runs and turns them all off\&. +\fBupsmon\fR and \fBupsd\fR(8) don\(cqt always run on the same system\&. When they do, any UPSes that are directly attached to the upsmon host should be monitored in "primary" mode\&. This makes upsmon take charge of that equipment, and it will wait for the "secondary" systems to disconnect before shutting down the local system\&. This allows the distant systems (monitoring over the network) to shut down cleanly before upsdrvctl shutdown runs and turns them all off\&. .sp -When upsmon runs as a slave, it is relying on the distant system to tell it about the state of the UPS\&. When that UPS goes critical (on battery and low battery), it immediately invokes the local shutdown command\&. This needs to happen quickly\&. Once it disconnects from the distant \fBupsd\fR(8) server, the master upsmon will start its own shutdown process\&. Your slaves must all shut down before the master turns off the power or filesystem damage may result\&. +When upsmon runs as a secondary, it is relying on the distant system to tell it about the state of the UPS\&. When that UPS goes critical (on battery and low battery), it immediately invokes the local shutdown command\&. This needs to happen quickly\&. Once all secondaries disconnect from the distant \fBupsd\fR(8) server, its primary\-mode upsmon will start its own shutdown process\&. Your secondary systems must all quiesce and shut down before the primary turns off the shared power source, or filesystem damage may result\&. .sp -upsmon deals with slaves that get wedged, hang, or otherwise fail to disconnect from \fBupsd\fR(8) in a timely manner with the HOSTSYNC timer\&. During a shutdown situation, the master upsmon will give up after this interval and it will shut down anyway\&. This keeps the master from sitting there forever (which would endanger that host) if a slave should break somehow\&. This defaults to 15 seconds\&. +upsmon deals with secondaries that get wedged, hang, or otherwise fail to disconnect from \fBupsd\fR(8) in a timely manner with the HOSTSYNC timer\&. During a shutdown situation, the primary upsmon will give up after this interval and it will shut down anyway\&. This keeps the primary from sitting there forever (which would endanger that host) if a secondary should break somehow\&. This defaults to 15 seconds\&. .sp -If your master system is shutting down too quickly, set the FINALDELAY interval to something greater than the default 15 seconds\&. Don\(cqt set this too high, or your UPS battery may run out of power before the master upsmon process shuts down that system\&. +If your primary system is shutting down too quickly, set the FINALDELAY interval to something greater than the default 15 seconds\&. Don\(cqt set this too high, or your UPS battery may run out of power before the primary upsmon process shuts down that system\&. .SH "TIMED SHUTDOWNS" .sp For those rare situations where the shutdown process can\(cqt be completed between the time that low battery is signalled and the UPS actually powers off the load, use the \fBupssched\fR(8) helper program\&. You can use it along with upsmon to schedule a shutdown based on the "on battery" event\&. upssched can then come back to upsmon to initiate the shutdown once it has run on battery too long\&. @@ -375,14 +392,14 @@ When alpha goes on battery, your current overall power value will stay at 3, as However, if beta goes critical, subtracting its contribution will take the current overall value from 3 to 2\&. This is just high enough to satisfy the minimum, so the system will continue running as before\&. If beta returns later, it will be re\-added and the current value will go back to 3\&. This allows you to swap out UPSes, change a power configuration, or whatever, as long as you maintain the minimum power value at all times\&. .SH "MIXED OPERATIONS" .sp -Besides being able to monitor multiple UPSes, upsmon can also monitor them as different roles\&. If you have a system with multiple power supplies serviced by separate UPS batteries, it\(cqs possible to be a master on one and a slave on the other\&. This usually happens when you run out of serial ports and need to do the monitoring through another system nearby\&. +Besides being able to monitor multiple UPSes, upsmon can also monitor them as different roles\&. If you have a system with multiple power supplies serviced by separate UPS batteries, it\(cqs possible to be a primary on one UPS and a secondary on the other\&. This usually happens when you run out of serial or USB ports and need to do the monitoring through another system nearby\&. .sp This is also complicated, especially when it comes time to power down a UPS that has gone critical but doesn\(cqt supply the local system\&. You can do this with some scripting magic in your notify command script, but it\(cqs beyond the scope of this manual\&. .SH "FORCED SHUTDOWNS" .sp -When upsmon is forced to bring down the local system, it sets the "FSD" (forced shutdown) flag on any UPSes that it is running in master mode\&. This is used to synchronize slaves in the event that a master UPS that is otherwise OK needs to be brought down due to some pressing event on the master\&. +When upsmon is forced to bring down the local system, it sets the "FSD" (forced shutdown) flag on any UPSes that it is running in primary mode\&. This is used to synchronize secondary systems in the event that a primary which is otherwise OK needs to be brought down due to some pressing event on the UPS manager system\&. .sp -You can manually invoke this mode on the master upsmon by starting another copy with \-c fsd\&. This is useful when you want to initiate a shutdown before the critical stage through some external means, such as \fBupssched\fR(8)\&. +You can manually invoke this mode on the system with primary\-mode upsmon by starting another copy of the program with \-c fsd command line argument\&. This is useful when you want to initiate a shutdown before the critical stage through some external means, such as \fBupssched\fR(8)\&. .SH "DEAD UPSES" .sp In the event that upsmon can\(cqt reach \fBupsd\fR(8), it declares that UPS "dead" after some interval controlled by DEADTIME in the \fBupsmon.conf\fR(5)\&. If this happens while that UPS was last known to be on battery, it is assumed to have gone critical and no longer contributes to the overall power value\&. @@ -403,7 +420,9 @@ To test a synchronized shutdown without pulling the plug on your UPS(es), you ne .sp upsmon \-c fsd .sp -After that, the master and the slaves will do their usual shutdown sequence as if the battery had gone critical\&. This is much easier on your UPS equipment, and it beats crawling under a desk to find the plug\&. +After that, the primary and the secondary will do their usual shutdown sequence as if the battery had gone critical, while you can time how long it takes for them\&. This is much easier on your UPS equipment, and it beats crawling under a desk to find the plug\&. +.sp +Note you can also use a dummy SHUTDOWNCMD setting to just report that the systems would shut down at this point, without actually disrupting their work\&. .SH "FILES" .sp \fBupsmon.conf\fR(5) diff --git a/docs/man/upsmon.conf.5 b/docs/man/upsmon.conf.5 index 2323abb..7691751 100644 --- a/docs/man/upsmon.conf.5 +++ b/docs/man/upsmon.conf.5 @@ -1,13 +1,13 @@ '\" t .\" Title: upsmon.conf -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSMON\&.CONF" "5" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSMON\&.CONF" "5" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -49,7 +49,7 @@ Note: DEADTIME should be a multiple of POLLFREQ and POLLFREQALERT\&. Otherwise, .PP \fBFINALDELAY\fR \fIseconds\fR .RS 4 -When running in master mode, upsmon waits this long after sending the NOTIFY_SHUTDOWN to warn the users\&. After the timer elapses, it then runs your SHUTDOWNCMD\&. By default this is set to 5 seconds\&. +When running in primary mode, upsmon waits this long after sending the NOTIFY_SHUTDOWN to warn the users\&. After the timer elapses, it then runs your SHUTDOWNCMD\&. By default this is set to 5 seconds\&. .sp If you need to let your users do something in between those events, increase this number\&. Remember, at this point your UPS battery is almost depleted, so don\(cqt make this too big\&. .sp @@ -66,20 +66,20 @@ Alternatively, you can set this very low so you don\(cqt wait around when it\(cq \fBNote\fR .ps -1 .br -If FINALDELAY on the slave is greater than HOSTSYNC on the master, the master will give up waiting for the slave to disconnect\&. +If FINALDELAY on the secondary is greater than HOSTSYNC on the primary, the primary will give up waiting for that secondary upsmon to disconnect\&. .sp .5v .RE .RE .PP \fBHOSTSYNC\fR \fIseconds\fR .RS 4 -upsmon will wait up to this many seconds in master mode for the slaves to disconnect during a shutdown situation\&. By default, this is 15 seconds\&. +upsmon will wait up to this many seconds in primary mode for the secondaries to disconnect during a shutdown situation\&. By default, this is 15 seconds\&. .sp -When a UPS goes critical (on battery + low battery, or "FSD": forced shutdown), the slaves are supposed to disconnect and shut down right away\&. The HOSTSYNC timer keeps the master upsmon from sitting there forever if one of the slaves gets stuck\&. +When a UPS goes critical (on battery + low battery, or "FSD": forced shutdown), the secondary systems are supposed to disconnect and shut down right away\&. The HOSTSYNC timer keeps the primary upsmon from sitting there forever if one of the secondaries gets stuck\&. .sp -This value is also used to keep slave systems from getting stuck if the master fails to respond in time\&. After a UPS becomes critical, the slave will wait up to HOSTSYNC seconds for the master to set the FSD flag\&. If that timer expires, the slave will assume that the master is broken and will shut down anyway\&. +This value is also used to keep secondary systems from getting stuck if the primary fails to respond in time\&. After a UPS becomes critical, the secondary will wait up to HOSTSYNC seconds for the primary to set the FSD flag\&. If that timer expires, the secondary upsmon will assume that the primary (or communications path to it) is broken and will shut down anyway\&. .sp -This keeps the slaves from shutting down during a short\-lived status change to "OB LB" that the slaves see but the master misses\&. +This keeps the secondaries from shutting down during a short\-lived status change to "OB LB" and back that the secondaries see but the primary misses\&. .RE .PP \fBMINSUPPLIES\fR \fInum\fR @@ -135,9 +135,11 @@ on port "5678"\&. .sp You can set the \fIpowervalue\fR to 0 if you want to monitor a UPS that doesn\(cqt actually supply power to this system\&. This is useful when you want to have upsmon do notifications about status changes on a UPS without shutting down when it goes critical\&. .sp -The \fIusername\fR and \fIpassword\fR on this line must match an entry in that system\(cqs \fBupsd.users\fR(5)\&. If your username is "monmaster" and your password is "blah", the MONITOR line might look like this: +The \fIusername\fR and \fIpassword\fR on this line must match an entry in the upsd server system\(cqs \fBupsd.users\fR(5) file\&. .sp -MONITOR myups@bigserver 1 monmaster blah master +If your username is "observer" and your password is "abcd", the MONITOR line might look like this (likely on a remote secondary system): +.sp +MONITOR myups@bigserver 1 observer abcd secondary .sp Meanwhile, the upsd\&.users on bigserver would look like this: .sp @@ -145,15 +147,31 @@ Meanwhile, the upsd\&.users on bigserver would look like this: .RS 4 .\} .nf -[monmaster] - password = blah - upsmon master # (or slave) +[observer] + password = abcd + upsmon secondary .fi .if n \{\ .RE .\} .sp -The \fItype\fR refers to the relationship with \fBupsd\fR(8)\&. It can be either "master" or "slave"\&. See \fBupsmon\fR(8) for more information on the meaning of these modes\&. The mode you pick here also goes in the upsd\&.users file, as seen in the example above\&. +.if n \{\ +.RS 4 +.\} +.nf +[upswired] + password = blah + upsmon primary +.fi +.if n \{\ +.RE +.\} +.sp +And the copy of upsmon on that bigserver would run with the primary configuration: +.sp +MONITOR myups@bigserver 1 upswired blah primary +.sp +The \fItype\fR refers to the relationship with \fBupsd\fR(8)\&. It can be either "primary" or "secondary"\&. See \fBupsmon\fR(8) for more information on the meaning of these modes\&. The mode you pick here also goes in the upsd\&.users file, as seen in the example above\&. .PP \fBNOCOMMWARNTIME\fR \fIseconds\fR .RS 4 @@ -240,7 +258,7 @@ UPS is on battery and has a low battery (is critical) .PP FSD .RS 4 -UPS is being shutdown by the master (FSD = "Forced Shutdown") +UPS is being shutdown by the primary (FSD = "Forced Shutdown") .RE .PP COMMOK @@ -269,7 +287,7 @@ A UPS is unavailable (can\(cqt be contacted for monitoring) .RE .RE .PP -\fBNOTIFYFLAG\fR \fItype\fR \fIflag\fR[+\fIflag\fR][+\fIflag\fR]\&... +\fBNOTIFYFLAG\fR \fItype\fR \fIflag\fR[+\fIflag\fR]\&... .RS 4 By default, upsmon sends walls global messages to all logged in users) via /bin/wall and writes to the syslog when things happen\&. You can change this\&. .sp @@ -333,11 +351,11 @@ The warnings from the POLLFREQ entry about too\-high and too\-low values also ap .PP \fBPOWERDOWNFLAG\fR \fIfilename\fR .RS 4 -upsmon creates this file when running in master mode when the UPS needs to be powered off\&. You should check for this file in your shutdown scripts and call +upsmon creates this file when running in primary mode when the UPS needs to be powered off\&. You should check for this file in your shutdown scripts and call upsdrvctl shutdown if it exists\&. .sp -This is done to forcibly reset the slaves, so they don\(cqt get stuck at the "halted" stage even if the power returns during the shutdown process\&. This usually does not work well on contact\-closure UPSes that use the genericups driver\&. +This is done to forcibly reset the secondary systems, so they don\(cqt get stuck at the "halted" stage even if the power returns during the shutdown process\&. This usually does not work well on contact\-closure UPSes that use the genericups driver\&. .sp See the config\-notes\&.txt file in the docs subdirectory for more information\&. Refer to the section: @@ -368,9 +386,9 @@ This file should not be writable by the upsmon user, as it would be possible to .PP \fBSHUTDOWNCMD\fR \fIcommand\fR .RS 4 -upsmon runs this command when the system needs to be brought down\&. If it is a slave, it will do that immediately whenever the current overall power value drops below the MINSUPPLIES value above\&. +upsmon runs this command when the system needs to be brought down\&. If it is a secondary, it will do that immediately whenever the current overall power value drops below the MINSUPPLIES value above\&. .sp -When upsmon is a master, it will allow any slaves to log out before starting the local shutdown procedure\&. +When upsmon is a primary, it will allow any secondaries to log out before starting the local shutdown procedure\&. .sp Note that the command needs to be one element in the config file\&. If your shutdown command includes spaces, then put it in quotes to keep it together, i\&.e\&.: .sp @@ -391,7 +409,7 @@ When compiled with SSL support, you can enter the certificate path here\&. .PP With NSS: .RS 4 -Certificates are stored in a dedicated database (splitted in 3 files)\&. Specify the path of the database directory\&. +Certificates are stored in a dedicated database (data split in 3 files)\&. Specify the path of the database directory\&. .RE .PP With OpenSSL: @@ -418,7 +436,7 @@ When compiled with SSL support, make upsmon verify all connections with certific .sp Without this, there is no guarantee that the upsd is the right host\&. Enabling this greatly reduces the risk of man\-in\-the\-middle attacks\&. This effectively forces the use of SSL, so don\(cqt use this unless all of your upsd hosts are ready for SSL and have their certificates in order\&. .sp -When compiled with NSS support of SSL, can be overriden for host specified with a CERTHOST directive\&. +When compiled with NSS support of SSL, can be overridden for host specified with a CERTHOST directive\&. .RE .PP \fBFORCESSL\fR \fI0 | 1\fR @@ -428,7 +446,41 @@ When compiled with SSL, specify that a secured connection must be used to commun If you don\(cqt use \fICERTVERIFY 1\fR, then this will at least make sure that nobody can sniff your sessions without a large effort\&. Setting this will make upsmon drop connections if the remote upsd doesn\(cqt support SSL, so don\(cqt use it unless all of them have it running\&. .sp -When compiled with NSS support of SSL, can be overriden for host specified with a CERTHOST directive\&. +When compiled with NSS support of SSL, can be overridden for host specified with a CERTHOST directive\&. +.RE +.PP +\fBDEBUG_MIN\fR \fIINTEGER\fR +.RS 4 +Optionally specify a minimum debug level for +upsmon +daemon, e\&.g\&. for troubleshooting a deployment, without impacting foreground or background running mode directly\&. Command\-line option +\-D +can only increase this verbosity level\&. +.if n \{\ +.sp +.\} +.RS 4 +.it 1 an-trap +.nr an-no-space-flag 1 +.nr an-break-flag 1 +.br +.ps +1 +\fBNote\fR +.ps -1 +.br +if the running daemon receives a +reload +command, presence of the +DEBUG_MIN NUMBER +value in the configuration file can be used to tune debugging verbosity in the running service daemon (it is recommended to comment it away or set the minimum to explicit zero when done, to avoid huge journals and I/O system abuse)\&. Keep in mind that for this run\-time tuning, the +DEBUG_MIN +value +\fBpresent\fR +in +\fBreloaded\fR +configuration files is applied instantly and overrides any previously set value, from file or CLI options, regardless of older logging level being higher or lower than the newly found number; a missing (or commented away) value however does not change the previously active logging verbosity\&. +.sp .5v +.RE .RE .SH "SEE ALSO" .sp diff --git a/docs/man/upsmon.conf.txt b/docs/man/upsmon.conf.txt index fccf495..1bd18ab 100644 --- a/docs/man/upsmon.conf.txt +++ b/docs/man/upsmon.conf.txt @@ -25,25 +25,25 @@ CONFIGURATION DIRECTIVES upsmon allows a UPS to go missing for this many seconds before declaring it "dead". The default is 15 seconds. + -upsmon requires a UPS to provide status information every few seconds +upsmon requires a UPS to provide status information every few seconds (see POLLFREQ and POLLFREQALERT) to keep things updated. If the status -fetch fails, the UPS is marked stale. If it stays stale for more than +fetch fails, the UPS is marked stale. If it stays stale for more than DEADTIME seconds, the UPS is marked dead. + A dead UPS that was last known to be on battery is assumed to have -changed to a low battery condition. This may force a shutdown if it is +changed to a low battery condition. This may force a shutdown if it is providing a critical amount of power to your system. This seems disruptive, but the alternative is barreling ahead into oblivion and crashing when you run out of power. + -Note: DEADTIME should be a multiple of POLLFREQ and POLLFREQALERT. +Note: DEADTIME should be a multiple of POLLFREQ and POLLFREQALERT. Otherwise, you'll have "dead" UPSes simply because upsmon isn't polling them quickly enough. Rule of thumb: take the larger of the two POLLFREQ values, and multiply by 3. *FINALDELAY* 'seconds':: -When running in master mode, upsmon waits this long after sending the +When running in primary mode, upsmon waits this long after sending the NOTIFY_SHUTDOWN to warn the users. After the timer elapses, it then runs your SHUTDOWNCMD. By default this is set to 5 seconds. + @@ -51,32 +51,33 @@ If you need to let your users do something in between those events, increase this number. Remember, at this point your UPS battery is almost depleted, so don't make this too big. + -Alternatively, you can set this very low so you don't wait around when -it's time to shut down. Some UPSes don't give much warning for low +Alternatively, you can set this very low so you don't wait around when +it's time to shut down. Some UPSes don't give much warning for low battery and will require a value of 0 here for a safe shutdown. + -NOTE: If FINALDELAY on the slave is greater than HOSTSYNC on the master, -the master will give up waiting for the slave to disconnect. +NOTE: If FINALDELAY on the secondary is greater than HOSTSYNC on the +primary, the primary will give up waiting for that secondary upsmon +to disconnect. *HOSTSYNC* 'seconds':: -upsmon will wait up to this many seconds in master mode for the slaves +upsmon will wait up to this many seconds in primary mode for the secondaries to disconnect during a shutdown situation. By default, this is 15 seconds. + When a UPS goes critical (on battery + low battery, or "FSD": forced -shutdown), the slaves are supposed to disconnect and shut down right -away. The HOSTSYNC timer keeps the master upsmon from sitting there -forever if one of the slaves gets stuck. +shutdown), the secondary systems are supposed to disconnect and shut +down right away. The HOSTSYNC timer keeps the primary upsmon from sitting +there forever if one of the secondaries gets stuck. + -This value is also used to keep slave systems from getting stuck if -the master fails to respond in time. After a UPS becomes critical, -the slave will wait up to HOSTSYNC seconds for the master to set the -FSD flag. If that timer expires, the slave will assume that the master -is broken and will shut down anyway. +This value is also used to keep secondary systems from getting stuck if +the primary fails to respond in time. After a UPS becomes critical, the +secondary will wait up to HOSTSYNC seconds for the primary to set the +FSD flag. If that timer expires, the secondary upsmon will assume that the +primary (or communications path to it) is broken and will shut down anyway. + -This keeps the slaves from shutting down during a short-lived status -change to "OB LB" that the slaves see but the master misses. +This keeps the secondaries from shutting down during a short-lived status +change to "OB LB" and back that the secondaries see but the primary misses. *MINSUPPLIES* 'num':: @@ -126,22 +127,34 @@ doesn't actually supply power to this system. This is useful when you want to have upsmon do notifications about status changes on a UPS without shutting down when it goes critical. -The 'username' and 'password' on this line must match an entry -in that system's linkman:upsd.users[5]. If your username is "monmaster" -and your password is "blah", the MONITOR line might look like this: +The 'username' and 'password' on this line must match an entry in +the `upsd` server system's linkman:upsd.users[5] file. -+MONITOR myups@bigserver 1 monmaster blah master+ +If your username is "observer" and your password is "abcd", the MONITOR +line might look like this (likely on a remote secondary system): + ++MONITOR myups@bigserver 1 observer abcd secondary+ Meanwhile, the `upsd.users` on `bigserver` would look like this: - [monmaster] - password = blah - upsmon master # (or slave) + [observer] + password = abcd + upsmon secondary + + [upswired] + password = blah + upsmon primary + +And the copy of upsmon on that bigserver would run with the primary +configuration: + ++MONITOR myups@bigserver 1 upswired blah primary+ + The 'type' refers to the relationship with linkman:upsd[8]. It can -be either "master" or "slave". See linkman:upsmon[8] for more information -on the meaning of these modes. The mode you pick here also goes in -the `upsd.users` file, as seen in the example above. +be either "primary" or "secondary". See linkman:upsmon[8] for more +information on the meaning of these modes. The mode you pick here +also goes in the `upsd.users` file, as seen in the example above. *NOCOMMWARNTIME* 'seconds':: @@ -154,7 +167,7 @@ seconds. upsmon calls this to send messages when things happen. + -This command is called with the full text of the message as one +This command is called with the full text of the message as one argument. The environment string NOTIFYTYPE will contain the type string of whatever caused this event to happen. + @@ -201,7 +214,7 @@ ONBATT;; UPS is on battery LOWBATT;; UPS is on battery and has a low battery (is critical) -FSD;; UPS is being shutdown by the master (FSD = "Forced Shutdown") +FSD;; UPS is being shutdown by the primary (FSD = "Forced Shutdown") COMMOK;; Communications established with the UPS @@ -211,13 +224,13 @@ SHUTDOWN;; The system is being shutdown REPLBATT;; The UPS battery is bad and needs to be replaced -NOCOMM;; A UPS is unavailable (can't be contacted for monitoring) +NOCOMM;; A UPS is unavailable (can't be contacted for monitoring) -*NOTIFYFLAG* 'type' 'flag'[\+'flag'][+'flag']...:: +*NOTIFYFLAG* 'type' 'flag'[+'flag']...:: By default, upsmon sends walls global messages to all logged in users) via /bin/wall and writes to the syslog when things happen. You can -change this. +change this. + Examples: + @@ -266,17 +279,17 @@ also apply here. *POWERDOWNFLAG* 'filename':: -upsmon creates this file when running in master mode when the UPS needs +upsmon creates this file when running in primary mode when the UPS needs to be powered off. You should check for this file in your shutdown scripts and call `upsdrvctl shutdown` if it exists. + -This is done to forcibly reset the slaves, so they don't get stuck at -the "halted" stage even if the power returns during the shutdown +This is done to forcibly reset the secondary systems, so they don't get +stuck at the "halted" stage even if the power returns during the shutdown process. This usually does not work well on contact-closure UPSes that use the genericups driver. + See the config-notes.txt file in the docs subdirectory for more information. -Refer to the section: +Refer to the section: [[UPS_shutdown]] "Configuring automatic shutdowns for low battery events", or refer to the online version. @@ -306,17 +319,17 @@ privileges and an impossible password. Then, tell upsmon to run as that user, and make `upsmon.conf` readable by it. Your reloads will work, and your config file will stay secure. + -This file should not be writable by the upsmon user, as it would be +This file should not be writable by the upsmon user, as it would be possible to exploit a hole, change the SHUTDOWNCMD to something malicious, then wait for upsmon to be restarted. *SHUTDOWNCMD* 'command':: upsmon runs this command when the system needs to be brought down. If -it is a slave, it will do that immediately whenever the current overall -power value drops below the MINSUPPLIES value above. +it is a secondary, it will do that immediately whenever the current +overall power value drops below the MINSUPPLIES value above. + -When upsmon is a master, it will allow any slaves to log out before +When upsmon is a primary, it will allow any secondaries to log out before starting the local shutdown procedure. + Note that the command needs to be one element in the config file. If @@ -330,7 +343,7 @@ together, i.e.: When compiled with SSL support, you can enter the certificate path here. + With NSS:;; - Certificates are stored in a dedicated database (splitted in 3 files). + Certificates are stored in a dedicated database (data split in 3 files). Specify the path of the database directory. With OpenSSL:;; Directory containing CA certificates in PEM format, used to verify @@ -355,7 +368,7 @@ must be secure. *CERTVERIFY* '0 | 1':: -When compiled with SSL support, make upsmon verify all connections with +When compiled with SSL support, make upsmon verify all connections with certificates. + Without this, there is no guarantee that the upsd is the right host. @@ -364,7 +377,7 @@ This effectively forces the use of SSL, so don't use this unless all of your upsd hosts are ready for SSL and have their certificates in order. + -When compiled with NSS support of SSL, can be overriden for host +When compiled with NSS support of SSL, can be overridden for host specified with a CERTHOST directive. *FORCESSL* '0 | 1':: @@ -377,13 +390,33 @@ that nobody can sniff your sessions without a large effort. Setting this will make upsmon drop connections if the remote upsd doesn't support SSL, so don't use it unless all of them have it running. + -When compiled with NSS support of SSL, can be overriden for host +When compiled with NSS support of SSL, can be overridden for host specified with a CERTHOST directive. +*DEBUG_MIN* 'INTEGER':: + +Optionally specify a minimum debug level for `upsmon` daemon, e.g. for +troubleshooting a deployment, without impacting foreground or background +running mode directly. Command-line option `-D` can only increase this +verbosity level. ++ +NOTE: if the running daemon receives a `reload` command, presence of the +`DEBUG_MIN NUMBER` value in the configuration file can be used to tune +debugging verbosity in the running service daemon (it is recommended to +comment it away or set the minimum to explicit zero when done, to avoid +huge journals and I/O system abuse). Keep in mind that for this run-time +tuning, the `DEBUG_MIN` value *present* in *reloaded* configuration files +is applied instantly and overrides any previously set value, from file +or CLI options, regardless of older logging level being higher or lower +than the newly found number; a missing (or commented away) value however +does not change the previously active logging verbosity. + SEE ALSO -------- + linkman:upsmon[8], linkman:upsd[8], linkman:nutupsdrv[8]. Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/upsmon.txt b/docs/man/upsmon.txt index 077144d..cb202fc 100644 --- a/docs/man/upsmon.txt +++ b/docs/man/upsmon.txt @@ -11,9 +11,9 @@ SYNOPSIS *upsmon* -h -*upsmon* -c 'command' +*upsmon* -c 'command' [-P 'pid'] -*upsmon* [-D] [-K] [-p] [-u 'user'] +*upsmon* [-D] [-F | -B] [-K] [-p] [-u 'user'] DESCRIPTION ----------- @@ -25,7 +25,7 @@ power events. upsmon can monitor multiple systems using a single process. Every UPS that is defined in the linkman:upsmon.conf[5] configuration file is assigned -a power value and a type (*slave* or *master*). +a power value and a type (*primary* or *secondary*). OPTIONS ------- @@ -37,22 +37,34 @@ Display the help message. Send the command 'command' to the existing upsmon process. Valid commands are: -*fsd*;; shutdown all master UPSes (use with caution) +*fsd*;; shutdown all primary-mode UPSes (use with caution) *stop*;; stop monitoring and exit *reload*;; reread linkman:upsmon.conf[5] configuration file. See "reloading nuances" below if this doesn't work. +*-P* 'pid':: +Send the command signal above using specified PID number, rather than +consulting the PID file. This can help define service units which +start main `upsmon` as a foreground process so it does not have to +rely on a PID file. + *-D*:: -Raise the debugging level. upsmon will run in the foreground and prints -information on stdout about the monitoring process. Use this multiple -times for more details. +Raise the debugging level. upsmon will run in the foreground by default, +and will print information on stdout about the monitoring process. +Use this option multiple times for more details. + +*-F*:: +upsmon will run in the foreground, regardless of debugging settings. + +*-B*:: +upsmon will run in the background, regardless of debugging settings. *-K*:: Test for the shutdown flag. If it exists and contains the magic string from upsmon, then upsmon will exit with `EXIT_SUCCESS`. Any other condition -will make upsmon exit with `EXIT_FAILURE`. +will make upsmon exit with `EXIT_FAILURE`. + You can test for a successful exit from `upsmon -K` in your shutdown scripts to know when to call linkman:upsdrvctl[8] to shut down the UPS. @@ -93,7 +105,7 @@ examples follow: - "su700@mybox" means a UPS called "su700" on a system called "mybox". This is the normal form. - - "fenton@bigbox:5678" is a UPS called "fenton" on a system called + - "fenton@bigbox:5678" is a UPS called "fenton" on a system called "bigbox" which runs linkman:upsd[8] on port "5678". The 'powervalue' refers to how many power supplies on this system are @@ -102,13 +114,13 @@ on power values below. The 'username' is a section in your linkman:upsd.users[5] file. Whatever password you set in that section must match the 'password' -set in this file. +set in this file. -The type set in that section must also match the 'type' here-- -*master* or *slave*. In general, a master process is one +The type set in that section must also match the 'type' here -- +*primary* or *secondary*. In general, a primary process is one running on the system with the UPS actually plugged into a serial -port, and a slave is drawing power from the UPS but can't talk to it -directly. See the section on UPS types for more. +port, and a secondary is drawing power from the UPS but can't +talk to it directly. See the section on UPS types for more. NOTIFY EVENTS ------------- @@ -149,7 +161,7 @@ NOTIFY COMMAND -------------- In linkman:upsmon.conf[5], you can configure a program called the NOTIFYCMD -that will handle events that occur. +that will handle events that occur. +NOTIFYCMD+ "'path to program'" @@ -160,10 +172,10 @@ Remember to wrap the path in "quotes" if it contains any spaces. The program you run as your NOTIFYCMD can use the environment variables NOTIFYTYPE and UPSNAME to know what has happened and on which UPS. It also receives the notification message (see below) as the first (and -only) argument, so you can deliver a preformatted message too. +only) argument, so you can deliver a pre-formatted message too. Note that the NOTIFYCMD will only be called for a given event when you set -the EXEC flag by using the notify flags, below: +the EXEC flag by using the notify flags, as detailed below. NOTIFY FLAGS ------------ @@ -227,36 +239,36 @@ number. If a UPS is critical (on battery and low battery) or has been put into "forced shutdown" mode, it no longer contributes. A "power value" on a MONITOR line in the config file is the number of -power supplies that the UPS runs on the current system. +power supplies that the UPS runs on the current system. +MONITOR+ 'upsname' 'powervalue' 'username' 'password' 'type' -Normally, you only have one power supply, so it will be set to 1. +Normally, you only have one power supply, so it will be set to 1. -+MONITOR myups@myhost 1 username mypassword master+ ++MONITOR myups@myhost 1 username mypassword primary+ On a large server with redundant power supplies, the power value for a UPS may be greater than 1. You may also have more than one of them defined. -+MONITOR ups-alpha@myhost 2 username mypassword master+ ++MONITOR ups-alpha@myhost 2 username mypassword primary+ -+MONITOR ups-beta@myhost 2 username mypassword master+ ++MONITOR ups-beta@myhost 2 username mypassword primary+ You can also set the power value for a UPS to 0 if it does not supply any power to that system. This is generally used when you want to use the upsmon notification features for a UPS even though it's not actually -running the system that hosts upsmon. Don't set this to "master" unless +running the system that hosts upsmon. Don't set this to "primary" unless you really want to power this UPS off when this instance of upsmon needs to shut down for its own reasons. -+MONITOR faraway@anotherbox 0 username mypassword slave+ ++MONITOR faraway@anotherbox 0 username mypassword secondary+ The "minimum power value" is the number of power supplies that must be -receiving power in order to keep the computer running. +receiving power in order to keep the computer running. +MINSUPPLIES+ 'value' -Typical PCs only have 1, so most users will leave this at the default. +Typical PCs only have 1, so most users will leave this at the default. +MINSUPPLIES 1+ @@ -276,31 +288,31 @@ UPS TYPES *upsmon* and linkman:upsd[8] don't always run on the same system. When they do, any UPSes that are directly attached to the upsmon host should be -monitored in "master" mode. This makes upsmon take charge of that -equipment, and it will wait for slaves to disconnect before shutting +monitored in "primary" mode. This makes upsmon take charge of that equipment, +and it will wait for the "secondary" systems to disconnect before shutting down the local system. This allows the distant systems (monitoring over the network) to shut down cleanly before `upsdrvctl shutdown` runs and turns them all off. -When upsmon runs as a slave, it is relying on the distant system to tell +When upsmon runs as a secondary, it is relying on the distant system to tell it about the state of the UPS. When that UPS goes critical (on battery and low battery), it immediately invokes the local shutdown command. This -needs to happen quickly. Once it disconnects from the distant -linkman:upsd[8] server, the master upsmon will start its own shutdown -process. Your slaves must all shut down before the master turns off the -power or filesystem damage may result. +needs to happen quickly. Once all secondaries disconnect from the distant +linkman:upsd[8] server, its primary-mode upsmon will start its own shutdown +process. Your secondary systems must all quiesce and shut down before the +primary turns off the shared power source, or filesystem damage may result. -upsmon deals with slaves that get wedged, hang, or otherwise fail to +upsmon deals with secondaries that get wedged, hang, or otherwise fail to disconnect from linkman:upsd[8] in a timely manner with the HOSTSYNC -timer. During a shutdown situation, the master upsmon will give up after -this interval and it will shut down anyway. This keeps the master from -sitting there forever (which would endanger that host) if a slave should -break somehow. This defaults to 15 seconds. +timer. During a shutdown situation, the primary upsmon will give up after +this interval and it will shut down anyway. This keeps the primary from +sitting there forever (which would endanger that host) if a secondary +should break somehow. This defaults to 15 seconds. -If your master system is shutting down too quickly, set the FINALDELAY +If your primary system is shutting down too quickly, set the FINALDELAY interval to something greater than the default 15 seconds. Don't set this too high, or your UPS battery may run out of power before the -master upsmon process shuts down that system. +primary upsmon process shuts down that system. TIMED SHUTDOWNS --------------- @@ -353,9 +365,10 @@ MIXED OPERATIONS Besides being able to monitor multiple UPSes, upsmon can also monitor them as different roles. If you have a system with multiple power supplies -serviced by separate UPS batteries, it's possible to be a master on one -and a slave on the other. This usually happens when you run out of serial -ports and need to do the monitoring through another system nearby. +serviced by separate UPS batteries, it's possible to be a primary on one +UPS and a secondary on the other. This usually happens when you run +out of serial or USB ports and need to do the monitoring through another +system nearby. This is also complicated, especially when it comes time to power down a UPS that has gone critical but doesn't supply the local system. You can @@ -366,15 +379,15 @@ FORCED SHUTDOWNS ---------------- When upsmon is forced to bring down the local system, it sets the -"FSD" (forced shutdown) flag on any UPSes that it is running in master -mode. This is used to synchronize slaves in the event that a master UPS -that is otherwise OK needs to be brought down due to some pressing event -on the master. +"FSD" (forced shutdown) flag on any UPSes that it is running in primary +mode. This is used to synchronize secondary systems in the event that +a primary which is otherwise OK needs to be brought down due to some +pressing event on the UPS manager system. -You can manually invoke this mode on the master upsmon by starting another -copy with `-c fsd`. This is useful when you want to initiate a shutdown -before the critical stage through some external means, such as -linkman:upssched[8]. +You can manually invoke this mode on the system with primary-mode upsmon +by starting another copy of the program with `-c fsd` command line argument. +This is useful when you want to initiate a shutdown before the critical +stage through some external means, such as linkman:upssched[8]. DEAD UPSES ---------- @@ -419,9 +432,13 @@ by calling upsmon again to set the flag, i.e.: +upsmon -c fsd+ -After that, the master and the slaves will do their usual shutdown sequence -as if the battery had gone critical. This is much easier on your UPS -equipment, and it beats crawling under a desk to find the plug. +After that, the primary and the secondary will do their usual shutdown +sequence as if the battery had gone critical, while you can time how long +it takes for them. This is much easier on your UPS equipment, and it beats +crawling under a desk to find the plug. + +Note you can also use a dummy SHUTDOWNCMD setting to just report that the +systems would shut down at this point, without actually disrupting their work. FILES ----- @@ -433,17 +450,21 @@ SEE ALSO Server: ~~~~~~~ + linkman:upsd[8] Clients: ~~~~~~~~ + linkman:upsc[8], linkman:upscmd[8], linkman:upsrw[8], linkman:upsmon[8] CGI programs: ~~~~~~~~~~~~~ + linkman:upsset.cgi[8], linkman:upsstats.cgi[8], linkman:upsimage.cgi[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/upsrw.8 b/docs/man/upsrw.8 index 7c9343b..15fdc8d 100644 --- a/docs/man/upsrw.8 +++ b/docs/man/upsrw.8 @@ -1,13 +1,13 @@ '\" t .\" Title: upsrw -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/09/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSRW" "8" "03/09/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSRW" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -31,11 +31,11 @@ upsrw \- UPS variable administration tool .SH "SYNOPSIS" .sp -\fBupsrw\fR \fIups\fR +\fBupsrw\fR [\-l] \fIups\fR .sp \fBupsrw\fR \-h .sp -\fBupsrw\fR \-s \fIvariable\fR [\-u \fIusername\fR] [\-p \fIpassword\fR] \fIups\fR +\fBupsrw\fR \-s \fIvariable\fR [\-u \fIusername\fR] [\-p \fIpassword\fR] [\-w] [\-t ] \fIups\fR .SH "DESCRIPTION" .sp \fBupsrw\fR allows you to view and change the read/write variables inside your UPS\&. It sends commands via the server \fBupsd\fR(8) to your driver, which configures the hardware for you\&. @@ -67,6 +67,15 @@ Without this argument, upsrw will just display the list of the variables and the Some variables are strings, and can be set to any value within the length limit\&. Others are enumerated types and can only be set to one of those values\&. Others may be within an allowed range of values\&. Refer to the list to know what\(cqs available in your hardware\&. .RE .PP +\fB\-l\fR +.RS 4 +Just display the list of the variables and their possible values\&. +.sp +Same as default activity without +\fI\-s\fR +argument, provided for CLI similarity with other tools\&. +.RE +.PP \fB\-u\fR \fIusername\fR .RS 4 Set the NUT username for the connection to the server\&. This is optional, and you will be prompted for this when using the \-s option if you don\(cqt specify \-u on the command line\&. NUT usernames are defined in @@ -78,6 +87,18 @@ Set the NUT username for the connection to the server\&. This is optional, and y Set the password to authenticate to the server\&. This is also optional like \-u, and you will be prompted for it if necessary\&. .RE .PP +\fB\-w\fR +.RS 4 +Wait for the completion of setting execution by the driver and return its actual result from the device\&. Note that this feature requires that both upsd and the driver support TRACKING (NUT version 2\&.8\&.0 or higher) or it will otherwise fail\&. The command will also block until an actual result is provided from the driver, or the timeout is reached (see +\fB\-t\fR)\&. +.RE +.PP +\fB\-t\fR \fIseconds\fR +.RS 4 +Set a timeout when using +\fB\-w\fR\&. Defaults to 10 seconds\&. +.RE +.PP \fIups\fR .RS 4 View or change the settings on this UPS\&. The format for this option is @@ -95,7 +116,7 @@ Moreover, if you run this program inside a shell script or similar, you should o \fBupsrw\fR can\(cqt set variables on your UPS unless you provide a valid username and password\&. If you get "access denied" errors, make sure that your \fBupsd.users\fR(5) has an entry for you, and that the username you are using has permissions to SET variables\&. .SH "VALUE FORMAT" .sp -When using \fBupsrw\fR to modify a numeric float value, that values must be given using decimal (base 10) english\-based representation, so using a dot, in non\-scientific notation\&. So hexadecimal, exponents, and comma for thousands separator are forbiden\&. For example: "1200\&.20" is valid, while "1,200\&.20" and "1200,20" are invalid\&. +When using \fBupsrw\fR to modify a numeric float value, that values must be given using decimal (base 10) english\-based representation, so using a dot, in non\-scientific notation\&. So hexadecimal, exponents, and comma for thousands separator are forbidden\&. For example: "1200\&.20" is valid, while "1,200\&.20" and "1200,20" are invalid\&. .SH "HISTORY" .sp This program used to be called upsct2, which was ambiguous and confusing\&. diff --git a/docs/man/upsrw.txt b/docs/man/upsrw.txt index 0e3bfcf..ebcd205 100644 --- a/docs/man/upsrw.txt +++ b/docs/man/upsrw.txt @@ -9,11 +9,11 @@ upsrw - UPS variable administration tool SYNOPSIS -------- -*upsrw* 'ups' +*upsrw* [-l] 'ups' *upsrw* -h -*upsrw* -s 'variable' [-u 'username'] [-p 'password'] 'ups' +*upsrw* -s 'variable' [-u 'username'] [-p 'password'] [-w] [-t ] 'ups' DESCRIPTION ----------- @@ -48,6 +48,12 @@ length limit. Others are enumerated types and can only be set to one of those values. Others may be within an allowed range of values. Refer to the list to know what's available in your hardware. +*-l*:: +Just display the list of the variables and their possible values. ++ +Same as default activity without '-s' argument, provided for CLI similarity +with other tools. + *-u* 'username':: Set the NUT username for the connection to the server. This is optional, and you will be prompted for this when using the -s option if you don't @@ -56,7 +62,18 @@ linkman:upsd.users[5], and are not linked to system usernames. *-p* 'password':: Set the password to authenticate to the server. This is also optional -like -u, and you will be prompted for it if necessary. +like -u, and you will be prompted for it if necessary. + +*-w*:: +Wait for the completion of setting execution by the driver and return its +actual result from the device. Note that this feature requires that both upsd +and the driver support TRACKING (NUT version 2.8.0 or higher) or it will +otherwise fail. +The command will also block until an actual result is provided from the driver, +or the timeout is reached (see *-t*). + +*-t* 'seconds':: +Set a timeout when using *-w*. Defaults to 10 seconds. 'ups':: View or change the settings on this UPS. The format for this option is @@ -90,7 +107,7 @@ VALUE FORMAT When using *upsrw* to modify a numeric float value, that values must be given using decimal (base 10) english-based representation, so using a dot, in non-scientific notation. So hexadecimal, exponents, and comma for thousands -separator are forbiden. +separator are forbidden. For example: "1200.20" is valid, while "1,200.20" and "1200,20" are invalid. HISTORY @@ -101,8 +118,10 @@ confusing. SEE ALSO -------- + linkman:upsd[8], linkman:upscmd[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/upssched.8 b/docs/man/upssched.8 index 5bc9c56..0adceff 100644 --- a/docs/man/upssched.8 +++ b/docs/man/upssched.8 @@ -1,13 +1,13 @@ '\" t .\" Title: upssched -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSSCHED" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSSCHED" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/upssched.conf.5 b/docs/man/upssched.conf.5 index 7f5363b..102902e 100644 --- a/docs/man/upssched.conf.5 +++ b/docs/man/upssched.conf.5 @@ -1,13 +1,13 @@ '\" t .\" Title: upssched.conf -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSSCHED\&.CONF" "5" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSSCHED\&.CONF" "5" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -116,7 +116,7 @@ as an argument to your CMDSCRIPT\&. .sp Example: .sp -Start a timer that\(cqll execute when any UPS (*) has been gone for 10 seconds +Start a timer that will execute when any UPS (*) has been gone for 10 seconds .sp .if n \{\ .RS 4 diff --git a/docs/man/upssched.conf.txt b/docs/man/upssched.conf.txt index 96aea56..52a028c 100644 --- a/docs/man/upssched.conf.txt +++ b/docs/man/upssched.conf.txt @@ -67,7 +67,7 @@ CMDSCRIPT. + Example: + -Start a timer that'll execute when any UPS (*) has been +Start a timer that will execute when any UPS (*) has been gone for 10 seconds AT COMMBAD * START-TIMER upsgone 10 @@ -107,4 +107,5 @@ linkman:upssched[8], linkman:upsmon[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/upssched.txt b/docs/man/upssched.txt index 2e377be..0fb033b 100644 --- a/docs/man/upssched.txt +++ b/docs/man/upssched.txt @@ -8,6 +8,7 @@ upssched - Timer helper for scheduling events from upsmon SYNOPSIS -------- + *upssched* NOTE: *upssched* should be run from linkman:upsmon[8] via the NOTIFYCMD. @@ -66,7 +67,7 @@ If your UPS goes on and off battery frequently, you can use this program to reduce the number of pager messages that are sent out. Rather than sending pages directly from linkman:upsmon[8], use a short timer here. If the timer triggers with the UPS still on battery, then send the page. -If the power returns before then, the timer can be cancelled and no page +If the power returns before then, the timer can be cancelled and no page is necessary. BACKGROUND @@ -92,7 +93,7 @@ no timers are present in the queue, the background process exits. This means that you will only see upssched running when one of two things is happening: - - There's a timer of some sort currently running + - There's a timer of some sort currently running - upsmon just called it, and you managed to catch the brief instance The final optimization handles the possibility of trying to cancel a timer @@ -112,4 +113,5 @@ linkman:upsmon[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/upsset.cgi.8 b/docs/man/upsset.cgi.8 index c45c073..363ed14 100644 --- a/docs/man/upsset.cgi.8 +++ b/docs/man/upsset.cgi.8 @@ -1,13 +1,13 @@ '\" t .\" Title: upsset.cgi -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSSET\&.CGI" "8" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSSET\&.CGI" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/upsset.cgi.txt b/docs/man/upsset.cgi.txt index 3cb7410..78912dd 100644 --- a/docs/man/upsset.cgi.txt +++ b/docs/man/upsset.cgi.txt @@ -34,10 +34,10 @@ You should see a list of items with the descriptions on the left side and the possible options or input spaces on the right. After changing something, be sure to "Save changes" to update the values in your UPS. -If your UPS doesn't support any read/write variables, there will be +If your UPS doesn't support any read/write variables, there will be nothing to do on this page. -Setting values in read/write variables can also be done from the command +Setting values in read/write variables can also be done from the command line with linkman:upsrw[8]. INSTANT COMMANDS @@ -94,4 +94,5 @@ SEE ALSO Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/upsset.conf.5 b/docs/man/upsset.conf.5 index a1abd5f..dbf8982 100644 --- a/docs/man/upsset.conf.5 +++ b/docs/man/upsset.conf.5 @@ -1,13 +1,13 @@ '\" t .\" Title: upsset.conf -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSSET\&.CONF" "5" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSSET\&.CONF" "5" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/upsset.conf.txt b/docs/man/upsset.conf.txt index e04a927..02cd996 100644 --- a/docs/man/upsset.conf.txt +++ b/docs/man/upsset.conf.txt @@ -26,8 +26,8 @@ your linkman:upsd.conf[5] file, tcp-wrappers (if available when NUT was built), and hopefully local firewall settings in your OS. *upsset* runs on your web server, so upsd will see it as a connection from -a host on an internal network. It doesn't know that the connection is -actually coming from someone on the outside. This is why you must +a host on an internal network. It doesn't know that the connection is +actually coming from someone on the outside. This is why you must secure it. On Apache, you can use the .htaccess file or put the directives in your @@ -39,10 +39,10 @@ method: allow from your.network.addresses -You will probably have to set "AllowOverride Limit" for this directory +You will probably have to set "AllowOverride Limit" for this directory in your server-level configuration file as well. -If this doesn't make sense, then stop reading and leave this program +If this doesn't make sense, then stop reading and leave this program alone. It's not something you absolutely need to have anyway. Assuming you have all this done, and it actually works (test it!), then @@ -55,8 +55,10 @@ web server, don't blame me. SEE ALSO -------- + linkman:upsset.cgi[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/upsstats.cgi.8 b/docs/man/upsstats.cgi.8 index d627ee8..762ae85 100644 --- a/docs/man/upsstats.cgi.8 +++ b/docs/man/upsstats.cgi.8 @@ -1,13 +1,13 @@ '\" t .\" Title: upsstats.cgi -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSSTATS\&.CGI" "8" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSSTATS\&.CGI" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/docs/man/upsstats.cgi.txt b/docs/man/upsstats.cgi.txt index 141cfef..e79e539 100644 --- a/docs/man/upsstats.cgi.txt +++ b/docs/man/upsstats.cgi.txt @@ -59,4 +59,5 @@ linkman:upsimage.cgi[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/upsstats.html.5 b/docs/man/upsstats.html.5 index 34747ae..9ac3fbd 100644 --- a/docs/man/upsstats.html.5 +++ b/docs/man/upsstats.html.5 @@ -1,13 +1,13 @@ '\" t .\" Title: upsstats.html -.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 03/02/2016 +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "UPSSTATS\&.HTML" "5" "03/02/2016" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "UPSSTATS\&.HTML" "5" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -134,7 +134,7 @@ myups@localhost\&. .PP \fB@HOSTDESC@\fR .RS 4 -Insert the hout\(cqs description from +Insert the host\(cqs description from \fBhosts.conf\fR(5)\&. .RE .PP diff --git a/docs/man/upsstats.html.txt b/docs/man/upsstats.html.txt index d08c5d0..ec869f4 100644 --- a/docs/man/upsstats.html.txt +++ b/docs/man/upsstats.html.txt @@ -101,7 +101,7 @@ the current temperature scale. Insert the designation of the host being monitored, like `myups@localhost`. *@HOSTDESC@*:: -Insert the hout's description from linkman:hosts.conf[5]. +Insert the host's description from linkman:hosts.conf[5]. *@HOSTLINK@*:: Insert a link to upsstats.cgi with the "host" variable set to the @@ -143,7 +143,7 @@ status variables: ups.load;; UPS load - percentage - ups.temperature;; UPS temperature + ups.temperature;; UPS temperature 'extra' is where you can put additional definitions. Right now the valid definitions are colors for various parts of the bars drawn @@ -194,7 +194,7 @@ voltage trim/boost or "off" are yellow, and other events like being on battery or having a low battery are red. *@VAR* 'varname'*@*:: -Insert the current value of the status variable varname on the host being +Insert the current value of the status variable varname on the host being monitored, or "Not supported". *@RUNTIME@*:: @@ -232,4 +232,5 @@ linkman:upsstats.cgi[8], linkman:upsimage.cgi[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/usbhid-ups.8 b/docs/man/usbhid-ups.8 index e74427a..5efcc29 100644 --- a/docs/man/usbhid-ups.8 +++ b/docs/man/usbhid-ups.8 @@ -1,13 +1,13 @@ '\" t .\" Title: usbhid-ups .\" Author: [see the "AUTHORS" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "USBHID\-UPS" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "USBHID\-UPS" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -32,11 +32,9 @@ usbhid-ups \- Driver for USB/HID UPS equipment .SH "NOTE" .sp This man page only documents the hardware\-specific features of the usbhid\-ups driver\&. For information about the core driver, see \fBnutupsdrv\fR(8)\&. -.sp -This driver, formerly called \fInewhidups\fR, replaces the legacy \fIhidups\fR driver, which only supported Linux systems\&. .SH "SUPPORTED HARDWARE" .sp -\fBusbhid\-ups\fR brings USB/HID UPS monitoring to NUT on all platform supporting USB through libusb\&. It should detect any UPS that uses the HID power device class, but the amount of data will vary depending on the manufacturer and model\&. +\fBusbhid\-ups\fR brings USB/HID UPS monitoring to NUT on all platforms supporting USB through libusb\&. It should detect any UPS that uses the HID Power Device Class, but the amount of data will vary depending on the manufacturer and model\&. .sp At the present time, usbhid\-ups supports: .sp @@ -81,6 +79,17 @@ all Dell USB models, .sp -1 .IP \(bu 2.3 .\} +all AMETEK Powervar UPM models, +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} some APC models, .RE .sp @@ -125,10 +134,21 @@ some Powercom models, .sp -1 .IP \(bu 2.3 .\} +some PowerWalker models, +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} some TrippLite models\&. .RE .sp -For a more complete list, refer to the NUT hardware compatibility list, available in the source distribution as data/drivers\&.list, or on the NUT website\&. You may use the "explore" driver option to gather information from HID UPSes which are not yet supported; see below for details\&. +For a more complete list, refer to the NUT hardware compatibility list, available in the source distribution as data/driver\&.list, or on the NUT website\&. You may use the "explore" driver option to gather information from HID UPSes which are not yet supported; see below for details\&. .sp This driver is known to work on: .sp @@ -191,36 +211,50 @@ than \fIondelay\fR, but the driver will \fBnot\fR warn you upon startup if it isn\(cqt\&. +.sp +Note that many Cyber Power Systems (CPS) models tend to divide this delay by 60 and round down, so the minimum advisable value is 60 to avoid powering off immediately after NUT sends the shutdown command to the UPS\&. .RE .PP \fBondelay\fR=\fInum\fR .RS 4 -Set the timer for the UPS to switch on in case the power returns after the kill power command had been sent but before the actual switch off\&. This ensures the machines connected to the UPS are, in all cases, rebooted after a power failure\&. +Set the timer for the UPS to switch on in case the power returns after the kill power command had been sent, but before the actual switch off\&. This ensures the machines connected to the UPS are, in all cases, rebooted after a power failure\&. .sp The default value is 30 (in seconds)\&. Usually this \fBmust be greater\fR than offdelay, but the driver will \fBnot\fR -warn you upon startup if it isn\(cqt\&. Some UPS\(cqes will restart no matter what, even if the power is (still) out at the moment this timer elapses\&. In that case, you could try if setting -\fIondelay = \-1\fR +warn you upon startup if it isn\(cqt\&. Some UPSes will restart no matter what, even if the power is (still) out at the moment this timer elapses\&. In that case, you could see whether setting +ondelay = \-1 in \fBups\&.conf\fR helps\&. +.sp +Note that many CPS models tend to divide this delay by 60 and round down, so the minimum advisable value is 120 to allow a short delay between when the UPS shuts down, and when the power returns\&. .RE .PP \fBpollfreq\fR=\fInum\fR .RS 4 -Set polling frequency, in seconds, to reduce the USB data flow\&. Between two polling requests, the driver will wait for interrupts (aka UPS notifications), which are data changes returned by the UPS by itself\&. This mechanism allow to avoid or reduce staleness message, due to the UPS being temporarily overloaded with too much polling requests\&. The default value is 30 (in seconds)\&. +Set polling frequency for full updates, in seconds\&. Compared to the quick updates performed every "pollinterval" (the latter option is described in +\fBups.conf\fR(5)), the "pollfreq" interval is for polling the less\-critical variables\&. The default value is 30 (in seconds)\&. .RE .PP \fBpollonly\fR .RS 4 -If this flag is set, the driver will ignore interrupts it receives from the UPS (not recommended, but needed if these reports are broken on your UPS)\&. +If this flag is set, the driver will not use Interrupt In transfers during the shorter "pollinterval" cycles (not recommended, but needed if these reports are broken on your UPS)\&. +.RE +.PP +\fBonlinedischarge\fR +.RS 4 +If this flag is set, the driver will treat +OL+DISCHRG +status as offline\&. For most devices this combination means calibration or similar maintenance; however some UPS models (e\&.g\&. CyberPower UT series) emit +OL+DISCHRG +when wall power is lost \(em and need this option to handle shutdowns\&. .RE .PP \fBvendor\fR=\fIregex\fR, \fBproduct\fR=\fIregex\fR, \fBserial\fR=\fIregex\fR, \fBvendorid\fR=\fIregex\fR, \fBproductid\fR=\fIregex\fR .RS 4 -Select a specific UPS, in case there is more than one connected via USB Each option specifies an extended regular expression (see regex(7)) that must match the UPS\(cqs entire vendor/product/serial string (minus any surrounding whitespace), or the whole 4\-digit hexadecimal code for vendorid and productid\&. Try +Select a specific UPS, in case there is more than one connected via USB\&. Each option specifies an extended regular expression (see regex(7)) that must match the UPS\(cqs entire vendor/product/serial string (minus any surrounding whitespace), or the whole 4\-digit hexadecimal code for vendorid and productid\&. Try \fB\-DD\fR for finding out the strings to match\&. .sp @@ -263,7 +297,12 @@ Examples: .PP \fBbus\fR=\fIregex\fR .RS 4 -Select a UPS on a specific USB bus or group of busses\&. The argument is a regular expression that must match the bus name where the UPS is connected (e\&.g\&. bus="002", bus="00[2\-3]")\&. +Select a UPS on a specific USB bus or group of buses\&. The argument is a regular expression that must match the bus name where the UPS is connected (e\&.g\&. bus="002", bus="00[2\-3]")\&. +.RE +.PP +\fBdevice =\fR \fIregex\fR +.RS 4 +Select a UPS on a specific USB device or group of devices\&. The argument is a regular expression that must match the device name where the UPS is connected (e\&.g\&. device="001", device="00[1\-2]")\&. Note that device numbers are not guaranteed by the OS to be stable across re\-boots or device re\-plugging\&. .RE .PP \fBexplore\fR @@ -290,9 +329,8 @@ Limit the number of bytes to read from interrupt pipe\&. For some Powercom units This driver is not built by default\&. You can build it by using "configure \-\-with\-usb=yes"\&. Note that it will also install other USB drivers\&. .sp You also need to install manually the legacy hotplug files (libhidups and libhid\&.usermap, generally in /etc/hotplug/usb/), or the udev file (nut\-usbups\&.rules, generally in /etc/udev/rules\&.d/) to address the permission settings problem\&. For more information, refer to the README file in nut/scripts/hotplug or nut/scripts/udev\&. -.sp -On Linux with MGE equipment, you will need at least a 2\&.4\&.25 or 2\&.6\&.2 kernel as well as libusb\-0\&.1\&.8 or later to disable hiddev support and avoid conflict\&. .SH "IMPLEMENTATION" +.SS "Selecting a specific UPS" .sp The driver ignores the "port" value in \fBups\&.conf\fR\&. Unlike previous versions of this driver, it is now possible to control multiple UPS units simultaneously with this driver, provided they can be distinguished by setting some combination of the "vendor", "product", "serial", "vendorid", and "productid" options\&. For instance: .sp @@ -312,6 +350,11 @@ The driver ignores the "port" value in \fBups\&.conf\fR\&. Unlike previous versi .if n \{\ .RE .\} +.SS "USB Polling and Interrupt Transfers" +.sp +The \fBusbhid\-ups\fR driver has two polling intervals\&. The "pollinterval" configuration option controls what can be considered the "inner loop", where the driver polls and waits briefly for "interrupt" reports\&. The "pollfreq" option is for less frequent updates of a larger set of values, and as such, we recommend setting that interval to several times the value of "pollinterval"\&. +.sp +Many UPSes will respond to a USB Interrupt In transfer with HID reports corresponding to values which have changed\&. This saves the driver from having to poll each value individually with USB Control transfers\&. Since the OB and LB status flags are important for a clean shutdown, the driver also explicitly polls the HID paths corresponding to those status bits during the inner "pollinterval" time period\&. The "pollonly" option can be used to skip the Interrupt In transfers if they are known not to work\&. .SH "KNOWN ISSUES AND BUGS" .SS "Repetitive timeout and staleness" .sp @@ -329,7 +372,9 @@ ret \-110 .RE .\} .sp -In this case, simply modify the general parameter "pollinterval" to a higher value (like 10 for 10 seconds)\&. This should solve the issue\&. +In this case, simply modify the general parameter "pollinterval" to a higher value (such as 10 seconds)\&. This should solve the issue\&. +.sp +Note that if you increase "pollinterval" beyond 10 or 15 seconds, you might also want to increase "pollfreq" by the same factor\&. .SS "Got EPERM: Operation not permitted upon driver startup" .sp You have forgotten to install the hotplug files, as explained in the INSTALLATION section above\&. Don\(cqt forget to restart hotplug so that it applies these changes\&. @@ -338,9 +383,70 @@ You have forgotten to install the hotplug files, as explained in the INSTALLATIO The hardware which was used for development of this driver is almost certainly different from what you have, and not all manufacturers follow the USB HID Power Device Class specifications to the letter\&. You don\(cqt want to find out that yours has issues here when a power failure hits your server room and you\(cqre not around to manually restart your servers\&. .sp If you rely on the UPS to shutdown your systems in case of mains failure and to restart them when the power returns, you \fBmust\fR test this\&. You can do so by running \fIupsmon \-c fsd\fR\&. With the mains present, this should bring your systems down and then cycle the power to restart them again\&. If you do the same without mains present, it should do the same, but in this case, the outputs shall remain off until mains power is applied again\&. +.SS "UPS cuts power too soon" +.sp +Note that many Cyber Power Systems (CPS) models tend to divide offdelay by 60 and round down, so the minimum advisable value is 60 (seconds) to avoid powering off immediately after NUT sends the shutdown command to the UPS\&. +.SS "UPS does not set battery\&.charge\&.low but says OK" +.sp +Note that many Cyber Power Systems (CPS) models tend to allow only certain values for battery\&.charge\&.low and anything outside of the set of allowed values are rounded or ignored\&. +.sp +A shell loop like this can help you map out the allowed values: +.sp +.if n \{\ +.RS 4 +.\} +.nf +for i in `seq 90 \-1 0`; do echo "set to $i"; \e + upsrw \-s battery\&.charge\&.low=$i \-u * \-p * cps\-big; \e + sleep 1; upsc cps\-big battery\&.charge\&.low; echo ""; \e +done +.fi +.if n \{\ +.RE +.\} +.sp +For example, for CPS PR1000LCDRTXL2U model, the only allowed values are [60,55,50,45,40,35,30,25,20] and in some cases, your UPS may effectively not support a value of 10 for the battery\&.charge\&.low setting\&. +.SH "HISTORY" +.sp +This driver, formerly called \fInewhidups\fR, replaces the legacy \fIhidups\fR driver, which only supported Linux systems\&. .SH "AUTHORS" .sp -Originally sponsored by MGE UPS SYSTEMS\&. Now sponsored by Eaton http://opensource\&.eaton\&.com Arnaud Quette, Peter Selinger, Arjen de Korte +Originally sponsored by MGE UPS SYSTEMS\&. +.sp +Now sponsored by Eaton http://opensource\&.eaton\&.com +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Arnaud Quette +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Peter Selinger +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Arjen de Korte +.RE .SH "SEE ALSO" .SS "The core driver" .sp diff --git a/docs/man/usbhid-ups.txt b/docs/man/usbhid-ups.txt index a125837..bd5f7d1 100644 --- a/docs/man/usbhid-ups.txt +++ b/docs/man/usbhid-ups.txt @@ -1,4 +1,4 @@ -USBHID-UPS(8) +USBHID-UPS(8) ============= NAME @@ -13,15 +13,12 @@ This man page only documents the hardware-specific features of the usbhid-ups driver. For information about the core driver, see linkman:nutupsdrv[8]. -This driver, formerly called 'newhidups', replaces the legacy 'hidups' driver, -which only supported Linux systems. - SUPPORTED HARDWARE ------------------ -*usbhid-ups* brings USB/HID UPS monitoring to NUT on all platform supporting -USB through libusb. It should detect any UPS that uses the HID power device -class, but the amount of data will vary depending on the manufacturer and +*usbhid-ups* brings USB/HID UPS monitoring to NUT on all platforms supporting +USB through libusb. It should detect any UPS that uses the HID Power Device +Class, but the amount of data will vary depending on the manufacturer and model. At the present time, usbhid-ups supports: @@ -29,14 +26,16 @@ At the present time, usbhid-ups supports: - the newer Eaton USB models, - all MGE USB models, - all Dell USB models, + - all AMETEK Powervar UPM models, - some APC models, - some Belkin models, - some Cyber Power Systems models, - some Powercom models, + - some PowerWalker models, - some TrippLite models. For a more complete list, refer to the NUT hardware compatibility list, -available in the source distribution as data/drivers.list, or on the +available in the source distribution as data/driver.list, or on the NUT website. You may use the "explore" driver option to gather information from HID UPSes which are not yet supported; see below for details. @@ -59,30 +58,43 @@ sent (via the *-k* switch). + The default value is 20 (in seconds). Usually this *must be lower* than 'ondelay', but the driver will *not* warn you upon startup if it isn't. - ++ +Note that many Cyber Power Systems (CPS) models tend to divide this delay by +60 and round down, so the minimum advisable value is 60 to avoid powering off +immediately after NUT sends the shutdown command to the UPS. + *ondelay*='num':: Set the timer for the UPS to switch on in case the power returns after the -kill power command had been sent but before the actual switch off. This +kill power command had been sent, but before the actual switch off. This ensures the machines connected to the UPS are, in all cases, rebooted after a power failure. + The default value is 30 (in seconds). Usually this *must be greater* than offdelay, but the driver will *not* warn you upon startup if it -isn't. Some UPS'es will restart no matter what, even if the power is -(still) out at the moment this timer elapses. In that case, you could try -if setting 'ondelay = -1' in *ups.conf* helps. +isn't. Some UPSes will restart no matter what, even if the power is +(still) out at the moment this timer elapses. In that case, you could see +whether setting `ondelay = -1` in *ups.conf* helps. ++ +Note that many CPS models tend to divide this delay by 60 and round down, so +the minimum advisable value is 120 to allow a short delay between when the UPS +shuts down, and when the power returns. *pollfreq*='num':: -Set polling frequency, in seconds, to reduce the USB data flow. -Between two polling requests, the driver will wait for interrupts (aka UPS -notifications), which are data changes returned by the UPS by itself. -This mechanism allow to avoid or reduce staleness message, due to the UPS -being temporarily overloaded with too much polling requests. -The default value is 30 (in seconds). +Set polling frequency for full updates, in seconds. Compared to the quick +updates performed every "pollinterval" (the latter option is described in +linkman:ups.conf[5]), the "pollfreq" interval is for polling the less-critical +variables. The default value is 30 (in seconds). *pollonly*:: -If this flag is set, the driver will ignore interrupts it receives from the -UPS (not recommended, but needed if these reports are broken on your UPS). +If this flag is set, the driver will not use Interrupt In transfers during the +shorter "pollinterval" cycles (not recommended, but needed if these reports +are broken on your UPS). + +*onlinedischarge*:: +If this flag is set, the driver will treat `OL+DISCHRG` status as offline. +For most devices this combination means calibration or similar maintenance; +however some UPS models (e.g. CyberPower UT series) emit `OL+DISCHRG` when +wall power is lost -- and need this option to handle shutdowns. *vendor*='regex':: *product*='regex':: @@ -91,13 +103,13 @@ UPS (not recommended, but needed if these reports are broken on your UPS). *productid*='regex':: Select a specific UPS, in case there is more than one connected via -USB Each option specifies an extended regular expression (see +USB. Each option specifies an extended regular expression (see regex(7)) that must match the UPS's entire vendor/product/serial string (minus any surrounding whitespace), or the whole 4-digit hexadecimal code for vendorid and productid. Try *-DD* for finding out the strings to match. + -Examples: +Examples: - `-x vendor="Foo.Corporation.*"` - `-x vendorid=051d*` (APC) @@ -105,9 +117,17 @@ Examples: *bus*='regex':: -Select a UPS on a specific USB bus or group of busses. The argument is +Select a UPS on a specific USB bus or group of buses. The argument is a regular expression that must match the bus name where the UPS is -connected (e.g. bus="002", bus="00[2-3]"). +connected (e.g. bus="002", bus="00[2-3]"). + +*device =* 'regex':: + +Select a UPS on a specific USB device or group of devices. The argument is +a regular expression that must match the device name where the UPS is +connected (e.g. device="001", device="00[1-2]"). +Note that device numbers are not guaranteed by the OS to be stable across +re-boots or device re-plugging. *explore*:: With this option, the driver will connect to any device, including @@ -142,11 +162,12 @@ and libhid.usermap, generally in /etc/hotplug/usb/), or the udev file permission settings problem. For more information, refer to the README file in nut/scripts/hotplug or nut/scripts/udev. -On Linux with MGE equipment, you will need at least a 2.4.25 or 2.6.2 kernel as -well as libusb-0.1.8 or later to disable hiddev support and avoid conflict. - IMPLEMENTATION -------------- + +Selecting a specific UPS +~~~~~~~~~~~~~~~~~~~~~~~~ + The driver ignores the "port" value in *ups.conf*. Unlike previous versions of this driver, it is now possible to control multiple UPS units simultaneously with this driver, provided they can be distinguished @@ -162,6 +183,23 @@ by setting some combination of the "vendor", "product", "serial", port = auto vendorid = 09ae +USB Polling and Interrupt Transfers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The *usbhid-ups* driver has two polling intervals. The "pollinterval" +configuration option controls what can be considered the "inner loop", where +the driver polls and waits briefly for "interrupt" reports. The "pollfreq" +option is for less frequent updates of a larger set of values, and as such, we +recommend setting that interval to several times the value of "pollinterval". + +Many UPSes will respond to a USB Interrupt In transfer with HID reports +corresponding to values which have changed. This saves the driver from having +to poll each value individually with USB Control transfers. Since the `OB` and +`LB` status flags are important for a clean shutdown, the driver also +explicitly polls the HID paths corresponding to those status bits during the +inner "pollinterval" time period. The "pollonly" option can be used to skip +the Interrupt In transfers if they are known not to work. + KNOWN ISSUES AND BUGS --------------------- @@ -176,7 +214,10 @@ The result is that your system log will have lots of messages like: ret -110 In this case, simply modify the general parameter "pollinterval" to a higher -value (like 10 for 10 seconds). This should solve the issue. +value (such as 10 seconds). This should solve the issue. + +Note that if you increase "pollinterval" beyond 10 or 15 seconds, you might +also want to increase "pollfreq" by the same factor. Got EPERM: Operation not permitted upon driver startup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -202,20 +243,59 @@ If you do the same without mains present, it should do the same, but in this case, the outputs shall remain off until mains power is applied again. +UPS cuts power too soon +~~~~~~~~~~~~~~~~~~~~~~~ + +Note that many Cyber Power Systems (CPS) models tend to divide `offdelay` +by 60 and round down, so the minimum advisable value is 60 (seconds) to avoid +powering off immediately after NUT sends the shutdown command to the UPS. + +UPS does not set battery.charge.low but says OK +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Note that many Cyber Power Systems (CPS) models tend to allow only certain +values for `battery.charge.low` and anything outside of the set of allowed +values are rounded or ignored. + +A shell loop like this can help you map out the allowed values: + +==== + for i in `seq 90 -1 0`; do echo "set to $i"; \ + upsrw -s battery.charge.low=$i -u * -p * cps-big; \ + sleep 1; upsc cps-big battery.charge.low; echo ""; \ + done +==== + +For example, for CPS PR1000LCDRTXL2U model, the only allowed values are +`[60,55,50,45,40,35,30,25,20]` and in some cases, your UPS may effectively +not support a value of 10 for the `battery.charge.low` setting. + +HISTORY +------- + +This driver, formerly called 'newhidups', replaces the legacy 'hidups' driver, +which only supported Linux systems. + AUTHORS ------- Originally sponsored by MGE UPS SYSTEMS. + Now sponsored by Eaton -Arnaud Quette, Peter Selinger, Arjen de Korte + +* Arnaud Quette +* Peter Selinger +* Arjen de Korte SEE ALSO -------- The core driver ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources ~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/man/victronups.8 b/docs/man/victronups.8 index 5275d9c..1be425a 100644 --- a/docs/man/victronups.8 +++ b/docs/man/victronups.8 @@ -1,13 +1,13 @@ '\" t .\" Title: victronups -.\" Author: [see the "AUTHOR" section] -.\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 12/29/2015 +.\" Author: [see the "AUTHORS" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 04/26/2022 .\" Manual: NUT Manual -.\" Source: Network UPS Tools 2.7.3.1 +.\" Source: Network UPS Tools 2.8.0 .\" Language: English .\" -.TH "VICTRONUPS" "8" "12/29/2015" "Network UPS Tools 2\&.7\&.3\&." "NUT Manual" +.TH "VICTRONUPS" "8" "04/26/2022" "Network UPS Tools 2\&.8\&.0" "NUT Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -41,7 +41,27 @@ The Match Lite line may only report a handful of variables\&. This is usually no .sp If your Victron cable is broken or missing, use this diagram to build a clone: .sp -docs/cables/victron\&.txt +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +https://github\&.com/networkupstools/nut/blob/master/docs/cables/ge\-imv\-victron\&.txt +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +docs/cables/ge\-imv\-victron\&.txt +.RE .SH "EXTRA ARGUMENTS" .sp This driver supports the following optional setting in the \fBups.conf\fR(5): @@ -58,9 +78,29 @@ Set delay before shutdown on UPS .SH "BUGS" .sp The protocol for this UPS is not officially documented\&. -.SH "AUTHOR" +.SH "AUTHORS" .sp -Radek Benedikt , Daniel Prynych +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Radek Benedikt +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Daniel Prynych +.RE .SH "SEE ALSO" .SS "The core driver:" .sp diff --git a/docs/man/victronups.txt b/docs/man/victronups.txt index 7c8e98a..17be94d 100644 --- a/docs/man/victronups.txt +++ b/docs/man/victronups.txt @@ -1,18 +1,21 @@ VICTRONUPS(8) ============= -NAME +NAME ---- + victronups - Driver for IMV/Victron UPS unit Match, Match Lite, NetUps NOTE ---- + This man page only documents the hardware-specific features of the the -victronups driver. For information about the core driver, see +victronups driver. For information about the core driver, see linkman:nutupsdrv[8]. SUPPORTED HARDWARE ------------------ + The victronups driver should recognize all Victron models that use a serial protocol at 1200 bps. These include Match Lite, Match and the NetUps line. @@ -25,10 +28,12 @@ CABLING If your Victron cable is broken or missing, use this diagram to build a clone: -docs/cables/victron.txt +* https://github.com/networkupstools/nut/blob/master/docs/cables/ge-imv-victron.txt +* link:docs/cables/ge-imv-victron.txt[] EXTRA ARGUMENTS --------------- + This driver supports the following optional setting in the linkman:ups.conf[5]: @@ -41,20 +46,24 @@ Set delay before shutdown on UPS BUGS ---- + The protocol for this UPS is not officially documented. -AUTHOR ------- -Radek Benedikt , -Daniel Prynych +AUTHORS +------- + +* Radek Benedikt +* Daniel Prynych SEE ALSO -------- The core driver: ~~~~~~~~~~~~~~~~ + linkman:nutupsdrv[8] Internet resources: ~~~~~~~~~~~~~~~~~~~ + The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ diff --git a/docs/net-protocol.txt b/docs/net-protocol.txt index 17ecf09..0af9433 100644 --- a/docs/net-protocol.txt +++ b/docs/net-protocol.txt @@ -25,7 +25,7 @@ an older version of the software. Command reference ----------------- -Multi-word elements are contained within "quotes" for easier parsing. +Multi-word elements are contained within "quotes" for easier parsing. Embedded quotes are escaped with backslashes. Embedded backslashes are also escaped by representing them as \\. This protocol is intended to be interpreted with parseconf (NUT parser) or something similar. @@ -44,10 +44,16 @@ NUT network protocol, over the time: |1.1 |>= 1.5.0 |Original protocol (without old commands) .2+|1.2 .2+|>= 2.6.4 |Add "LIST CLIENTS" and "NETVER" commands |Add ranges of values for writable variables +.4+|1.3 .4+|>= 2.8.0 |Add "cmdparam" to "INSTCMD" + |Add "TRACKING" commands (GET, SET) + |Add "PRIMARY" as alias to older "MASTER" + (implementation tested to be backwards + compatible in `upsd` and `upsmon`) + |Add "PROTVER" as alias to older "NETVER" |=============================================================================== -NOTE: any new version of the protocol implies an update of NUT_NETVERSION -in *configure.in*. +NOTE: Any new version of the protocol implies an update of `NUT_NETVERSION` +in 'configure.ac' file. GET @@ -72,7 +78,7 @@ Response: NUMLOGINS su700 1 '' is the number of clients which have done LOGIN for this UPS. -This is used by the master upsmon to determine how many clients are +This is used by the upsmon in primary mode to determine how many clients are still connected when starting the shutdown process. This replaces the old "REQ NUMLOGINS" command. @@ -132,12 +138,14 @@ Response: - 'RW': this variable may be set to another value with SET - 'ENUM': an enumerated type, which supports a few specific values - 'STRING:n': this is a string of maximum length n -- 'RANGE': this is an numeric, either integer or float, comprised in the range (see LIST RANGE) +- 'RANGE': this is an numeric, either integer or float, comprised in the +range (see LIST RANGE) - 'NUMBER': this is a simple numeric value, either integer or float ENUM, STRING and RANGE are usually associated with RW, but not always. -The default , when omitted, is numeric, so either integer or float. Each -driver is then responsible for handling values as either integer or float. +The default , when omitted, is numeric, so either integer or float. +Each driver is then responsible for handling values as either integer or +float. Note that float values are expressed using decimal (base 10) english-based representation, so using a dot, in non-scientific notation. So hexadecimal, @@ -189,6 +197,26 @@ This is like DESC above, but it applies to the instant commands. This replaces the old "INSTCMDDESC" command. +TRACKING +~~~~~~~~ + +Form: + + GET TRACKING (activation status of TRACKING) + GET TRACKING (execution status of a command / setvar) + GET TRACKING 1bd31808-cb49-4aec-9d75-d056e6f018d2 + +Response: + + ON (TRACKING feature is enabled) + OFF (TRACKING feature is disabled) + PENDING (command execution is pending) + SUCCESS (command was successfully executed) + ERR UNKNOWN (command execution failed with unknown error) + ERR INVALID-ARGUMENT (command execution failed due to missing or invalid argument) + ERR FAILED (command execution failed) + + LIST ---- @@ -377,19 +405,54 @@ Response: SET --- +VAR +~~~ + Form: SET VAR "" SET VAR su700 ups.id "My UPS" +Response: + + OK (if TRACKING is not enabled) + OK TRACKING (if TRACKING is enabled) + ERR [...] (see Error responses) + + +TRACKING +~~~~~~~~ + +Form: + + SET TRACKING + SET TRACKING ON + SET TRACKING OFF + +Response: + + OK + ERR INVALID-ARGUMENT (if is not "ON" or "OFF") + ERR USERNAME-REQUIRED (if not yet authenticated) + ERR PASSWORD-REQUIRED (if not yet authenticated) + INSTCMD ------- Form: - INSTCMD + INSTCMD [] INSTCMD su700 test.panel.start + INSTCMD su700 load.off.delay 120 + +NOTE: is an additional and optional parameter for the command. + +Response: + + OK (if TRACKING is not enabled) + OK TRACKING (if TRACKING is enabled) + ERR [...] (see Error responses) LOGOUT @@ -420,18 +483,21 @@ Response: or <> -NOTE: This requires "upsmon slave" or "upsmon master" in upsd.users +NOTE: This requires "upsmon secondary" or "upsmon primary" in upsd.users Use this to log the fact that a system is drawing power from this UPS. -The upsmon master will wait until the count of attached systems reaches -1 - itself. This allows the slaves to shut down first. +The upsmon primary will wait until the count of attached systems reaches +1 -- itself. This allows the secondaries to shut down first. NOTE: You probably shouldn't send this command unless you are upsmon, or a upsmon replacement. -MASTER ------- +PRIMARY (since NUT 2.8.0) or MASTER (deprecated) +------------------------------------------------ + +NOTE: This command was renamed in NUT 2.8.0 to "PRIMARY" with the older +name "MASTER" kept as deprecated alias for compatibility. Form: @@ -439,14 +505,25 @@ Form: Response: - OK (upon success) + OK MASTER-GRANTED (upon success) + +Form: + + PRIMARY + +Response: + + OK PRIMARY-GRANTED (upon success) or <> -NOTE: This requires "upsmon master" in upsd.users +NOTE: This requires "upsmon primary" in upsd.users + +NOTE: Previously documented response was just `OK` -- clients checking +that server reply *starts with* that keyword would handle all cases. This function doesn't do much by itself. It is used by upsmon to make -sure that master-level functions like FSD are available if necessary. +sure that primary-mode functions like FSD are available if necessary. FSD @@ -462,22 +539,36 @@ Response: or <> -NOTE: This requires "upsmon master" in upsd.users, or "FSD" action +NOTE: This requires "upsmon primary" in upsd.users, or "FSD" action granted in upsd.users -upsmon in master mode is the primary user of this function. It sets this +upsmon in primary mode is the primary user of this function. It sets this "forced shutdown" flag on any UPS when it plans to power it off. This is -done so that slave systems will know about it and shut down before the +done so that secondary systems will know about it and shut down before the power disappears. Setting this flag makes "FSD" appear in a STATUS request for this UPS. Finding "FSD" in a status request should be treated just like a "OB LB". -It should be noted that FSD is currently a latch - once set, there is +It should be noted that FSD is currently a latch -- once set, there is no way to clear it short of restarting upsd or dropping then re-adding it in the ups.conf. This may cause issues when upsd is running on a system that is not shut down due to the UPS event. +Note also that certain drivers can propagate the "FSD" state declared by +the smarter UPSes themselves, e.g. when an UPS is charging after an outage +and its battery level is below the "safe for load" threshold configured on +the device itself. In this case the device usually does not power up its +outlets automatically, but it can be forced by the systems administrator. +The rationale behind such FSD during charging allows enough power to be +guaranteed for systems to both boot and shut down safely, if the wall +power disappears again, trading off prolonged unavailability of the shut +down servers for the safety of their data. In such cases, administrators +should be ready to disarm their upsmon clients until the batteries are +charged, to avoid quick shutdowns of quickly restored servers -- but only +if they are sure about the wall power being restored for good (e.g. outage +was due to maintenance). + PASSWORD -------- @@ -537,6 +628,7 @@ Other commands - HELP: lists the commands supported by this server - VER: shows the version of the server currently in use - NETVER: shows the version of the network protocol currently in use + (aliased as PROTVER since NUT v2.8.0, or formal protocol version 1.3) These three are not intended to be used directly by programs. Humans can make use of this program by using telnet or netcat. If you use @@ -587,13 +679,13 @@ sending a valid command like GET with an invalid subcommand. - 'INSTCMD-FAILED' + -upsd failed to deliver the instant command request to the driver. +upsd failed to deliver the instant command request to the driver. No further information is available to the client. This typically indicates a dead or broken driver. - 'SET-FAILED' + -upsd failed to deliver the set request to the driver. This is +upsd failed to deliver the set request to the driver. This is just like INSTCMD-FAILED above. - 'READONLY' @@ -622,7 +714,7 @@ start it again. - 'DRIVER-NOT-CONNECTED' + upsd can't perform the requested command, since the driver for that -UPS is not connected. This usually means that the driver is not +UPS is not connected. This usually means that the driver is not running, or if it is, the ups.conf is misconfigured. - 'DATA-STALE' @@ -643,7 +735,7 @@ There is presently a limit of one LOGIN record per connection. - 'INVALID-PASSWORD' + -The client sent an invalid PASSWORD - perhaps an empty one. +The client sent an invalid PASSWORD -- perhaps an empty one. - 'ALREADY-SET-PASSWORD' + @@ -679,7 +771,7 @@ receiving this response. - 'INVALID-VALUE' + -The value specified in the request is not valid. This usually +The value specified in the request is not valid. This usually applies to a SET of an ENUM type which is using a value which is not in the list of allowed values. @@ -696,13 +788,6 @@ For example, "LIST VARS +DESC" would return the current value like now, but it would also append the description of that variable. -Command status -~~~~~~~~~~~~~~ - -After sending an INSTCMD or SET, a client will eventually be able to -poll to see whether it was completed successfully by the driver. - - Get collection ~~~~~~~~~~~~~~ diff --git a/docs/new-clients.txt b/docs/new-clients.txt index 7b41364..1b07900 100644 --- a/docs/new-clients.txt +++ b/docs/new-clients.txt @@ -51,28 +51,86 @@ and commands with an object-oriented API in C++ and C. For more information, refer to the linkman:libnutclient[3] manual page. +------ #include + #include + #include + #include + using namespace nut; using namespace std; - - int main(int argc, char** argv) + + /* argv[1] is the mandatory NUT device name (@localhost), + * used to list variables from + * argv[2] is an optional command. When provided, it will be + * executed and possibly with status tracking enabled + */ + int main(int argc, char **argv) { + Client *client; try { // Connection - Client* client = new TcpClient("localhost", 3493); - Device mydev = client->getDevice("myups"); - cout << mydev.getDescription() << endl; - Variable var = mydev.getVariable("device.model"); - cout << var.getValue()[0] << endl; + client = new TcpClient("localhost", 3493); + + if (argc >= 2) + { + // Reading data from device + Device mydev = client->getDevice(argv[1]); + cout << "Description: " << mydev.getDescription() << endl; + Variable var = mydev.getVariable("device.model"); + cout << "Model: " << var.getValue()[0] << endl; + + if (argc >= 3) + { + // Authenticate to NUT server + const char *user = getenv("NUT_USER"); + const char *password = getenv("NUT_PASSWD"); + client->authenticate(user ? user : "", password ? password : ""); + + // Enable command tracking, if available + if (client->hasFeature(Client::TRACKING)) + { + cout << "Server can do command tracking" << std::endl; + client->setFeature(Client::TRACKING, true); + } + else + { + std::cout << "Server can't do command tracking" << std::endl; + } + + // Perform an asynchronous command + TrackingID id = mydev.executeCommand(argv[2]); + TrackingResult result; + do + { + sleep(1); + result = client->getTrackingResult(id); + } + while (result == PENDING); + + // Display result of command + const char *output = ""; + switch (result) + { + case SUCCESS: output = "SUCCESS"; break; + case FAILURE: output = "FAILURE"; break; + case UNKNOWN: output = "UNKNOWN"; break; + } + cout << "Command sent, result=" << output << endl; + } + } } - catch(NutException& ex) + catch (NutException &ex) { cerr << "Unexpected problem : " << ex.str() << endl; } + delete client; return 0; } +------ + Configuration helpers ~~~~~~~~~~~~~~~~~~~~~ @@ -88,7 +146,8 @@ Python The PyNUT module, contributed by David Goncalves, can be used for connecting a Python script to `upsd`. Note that this code (and the accompanying NUT-Monitor -application) is licensed under the GPL v3. +application, later separated into NUT-Monitor-py2gtk2 and NUT-Monitor-py3qt5, +suitable for two generations of Python ecosystem) is licensed under the GPL v3. The `PyNUTClient` class abstracts the connection to the server. In order to list the status variables for `ups1` on the local `upsd`, the following @@ -125,6 +184,7 @@ of the results. The Perl class instance encapsulates a single UPS, where the Python class instance represents a connection to the server (which may service multiple UPS units). +------ use UPS::Nut; $ups = new UPS::Nut( NAME => "myups", @@ -147,10 +207,10 @@ multiple UPS units). ; print $other_ups{MFR}, " ", $other_ups{MODEL}, "\n"; +------ Java ---- The NUT Java support has been externalized. It is available at https://github.com/networkupstools/jnut - diff --git a/docs/new-drivers.txt b/docs/new-drivers.txt index 3949a0b..7e17372 100644 --- a/docs/new-drivers.txt +++ b/docs/new-drivers.txt @@ -4,38 +4,55 @@ Creating a new driver to support another device This chapter will present the process of creating a new driver to support another device. -Since NUT already supports many major power devices protocols through +Since NUT already supports many major power device protocols through several generic drivers (genericups, usbhid-ups, snmp-ups, blazer_* and nutdrv_qx), creation of new drivers has become rare. -So most of the time, it will be limited to completing one of these +So most of the time, this process will be limited to completing one of these generic drivers. Smart vs. Contact-closure ------------------------- -If your UPS only does contact closure readings, then go straight to the -<> chapter for information on -adding support. It's a lot easier to add a few lines to a header file -than it is to create a whole new driver. +If your UPS only does contact closure readings over an RS-232 serial port, then +go straight to the <> chapter for +information on adding support. It's a lot easier to add a few lines to a +header file than it is to create a whole new driver. Serial vs. USB vs. SNMP and more -------------------------------- -If your UPS connects to your computer via a USB port, then go straight -to the <> chapter. You can probably add -support for your device by writing a new subdriver to the existing -usbhid-ups driver, which is easier than writing an entire new driver. +If your UPS connects to your computer via a USB port, then it most likely +appears as a USB HID device (this is the simplest way for the vendor to write +a Windows control program for it). What comes next depends on whether the +vendor implemented the HID PDC (Power Device Class) specification, or simply +used the HID protocol to transport serial data to the UPS microcontroller. + +A rough heuristic is to check the length of the HID Descriptor length +(`wDescriptorLength` in `lsusb -v` output). If it is less than 200 bytes long, +the UPS probably has a glorified USB-to-serial converter built in. Since the +query strings often start with the letter `Q`, this family of protocols is +often referred to as `Q*` in the NUT documentation. See the +<> chapter for more details. + +Otherwise, if the HID Descriptor is longer, you can go to the +<> chapter. You can probably add support for +your device by writing a new subdriver to the existing usbhid-ups driver, +which is easier (and more maintainable) than writing an entire new driver. + +If your USB UPS does not appear to fall into either of these two categories, +feel free to contact the `nut-upsdev` mailing list with details of your +device. Similarly, if your UPS connects to your computer via an SNMP network -card, you can probably add support for your device by writing a new +card, you can probably add support for your device by adding a new subdriver to the existing snmp-ups driver. Instructions are provided in the <> chapter. Overall concept --------------- -The basic design of drivers is simple. main.c handles most of the work +The basic design of drivers is simple. `main.c` handles most of the work for you. You don't have to worry about arguments, config files, or anything else like that. Your only concern is talking to the hardware and providing data to the outside world. @@ -43,8 +60,8 @@ and providing data to the outside world. Skeleton driver --------------- -Familiarize yourself with the design of skel.c in the drivers directory. -It shows a few examples of the functions that main will call to obtain +Familiarize yourself with the design of `skel.c` in the drivers directory. +It shows a few examples of the functions that `main.c` will call to obtain updated information from the hardware. Essential structure @@ -59,8 +76,9 @@ This structure tracks several description information about the driver: * *version*: the driver's own version. For sub driver information, refer below to sub_upsdrv_info. This value has the form "X.YZ", and is published by main as "driver.version.internal". - * *authors*: the driver's author(s) name. If multiple authors are listed, separate - them with a newline character so that it can be broken up by author if needed. + * *authors*: the driver's author(s) name. If multiple authors are listed, + separate them with a newline character so that it can be broken + up by author if needed. * *status*: the driver development status. The following values are allowed: - DRV_BROKEN: setting this value will cause main to print an error and exit. This is only used during conversions of the driver core @@ -72,10 +90,10 @@ This structure tracks several description information about the driver: doesn't take it for granted. - DRV_BETA: this value means that the driver is more stable and complete. But it is still not recommended for production systems. - - DRV_STABLE: the driver is suitable for production systems, but not - 100 % feature complete. - - DRV_COMPLETE: this is the gold level! It implies that 100 % of the - protocol is implemented, and a full QA pass. + - DRV_STABLE: the driver is suitable for production systems, but + not 100 % feature complete. + - DRV_COMPLETE: this is the gold level! It implies that 100 % of + the protocol is implemented, and a full QA pass. * *subdrv_info*: array of upsdrv_info_t for sub driver(s) information. For example, this is used by usbhid-ups. @@ -87,7 +105,7 @@ Essential functions upsdrv_initups ~~~~~~~~~~~~~~ -Open the port (device_path) and do any low-level things that it may need +Open the port (`device_path`) and do any low-level things that it may need to start using that port. If you have to set DTR or RTS on a serial port, do it here. @@ -102,14 +120,14 @@ possible for your hardware. If there is a way to detect that hardware and it doesn't appear to be connected, display an error and exit. This is the last time your driver is allowed to bail out. -This is usually a good place to create variables like ups.mfr, -ups.model, ups.serial, and other "one time only" items. +This is usually a good place to create variables like `ups.mfr`, +`ups.model`, `ups.serial`, and other "one time only" items. upsdrv_updateinfo ~~~~~~~~~~~~~~~~~ Poll the hardware, and update any variables that you care about -monitoring. Use dstate_setinfo() to store the new values. +monitoring. Use `dstate_setinfo()` to store the new values. Do at most one pass of the variables. You MUST return from this function or upsd will be unable to read data from your driver. main @@ -125,7 +143,7 @@ answer the next time it is called. You must never abort from upsdrv_updateinfo(), even when the UPS doesn't seem to be attached anymore. If the connection with the UPS is lost, the driver should retry to re-establish communication for as long as it is -running. Calling exit() or any of the fatal*() functions is specifically +running. Calling `exit()` or any of the `fatal*()` functions is specifically not allowed anymore. upsdrv_shutdown @@ -144,15 +162,15 @@ process. Data types ---------- -To be of any use, you must supply data in ups.status. That is the +To be of any use, you must supply data in `ups.status`. That is the minimum needed to let upsmon do its job. Whenever possible, you should also provide anything else that can be monitored by the driver. Some obvious things are the manufacturer name and model name, voltage data, and so on. -If you can't figure out some value automatically, use the ups.conf +If you can't figure out some value automatically, use the `ups.conf` options to let the user tell you. This can be useful when a driver -needs to support many similar hardware models but can't probe to see +needs to support many similar hardware models, but can't probe to see what is actually attached. Manipulating the data @@ -189,50 +207,50 @@ UPS status flags like on line (OL) and on battery (OB) live in ups.status. Don't manipulate this by hand. There are functions which will do this for you. - status_init() - before doing anything else + status_init() -- before doing anything else - status_set(val) - add a status word (OB, OL, etc) + status_set(val) -- add a status word (OB, OL, etc) - status_commit() - push out the update + status_commit() -- push out the update Possible values for status_set: - OL - On line (mains is present) - OB - On battery (mains is not present) - LB - Low battery - HB - High battery - RB - The battery needs to be replaced - CHRG - The battery is charging - DISCHRG - The battery is discharging (inverter is providing load power) - BYPASS - UPS bypass circuit is active - no battery protection is available - CAL - UPS is currently performing runtime calibration (on battery) - OFF - UPS is offline and is not supplying power to the load - OVER - UPS is overloaded - TRIM - UPS is trimming incoming voltage (called "buck" in some hardware) - BOOST - UPS is boosting incoming voltage - FSD - Forced Shutdown (restricted use, see the note below) + OL -- On line (mains is present) + OB -- On battery (mains is not present) + LB -- Low battery + HB -- High battery + RB -- The battery needs to be replaced + CHRG -- The battery is charging + DISCHRG -- The battery is discharging (inverter is providing load power) + BYPASS -- UPS bypass circuit is active -- no battery protection is available + CAL -- UPS is currently performing runtime calibration (on battery) + OFF -- UPS is offline and is not supplying power to the load + OVER -- UPS is overloaded + TRIM -- UPS is trimming incoming voltage (called "buck" in some hardware) + BOOST -- UPS is boosting incoming voltage + FSD -- Forced Shutdown (restricted use, see the note below) Anything else will not be recognized by the usual clients. Coordinate with the nut-upsdev list before creating something new, since there will be duplication and ugliness otherwise. [NOTE] -================================================================================ +============================================================================== -- upsd injects "FSD" by itself following that command by a master upsmon +- upsd injects `FSD` by itself following that command by a primary upsmon process. Drivers must not set that value, apart from specific cases (see below). -- As an exception, drivers may set "FSD" when an imminent shutdown has been +- As an exception, drivers may set `FSD` when an imminent shutdown has been detected. In this case, the "on battery + low battery" condition should not be -met. Otherwise, setting status to "OB LB" should be preferred. +met. Otherwise, setting status to `OB LB` should be preferred. -- the OL and OB flags are an indication of the input line status only. +- the `OL` and `OB` flags are an indication of the input line status only. -- the CHRG and DISCHRG flags are under replacement by battery.charger.status. -See the linkdoc:user-manual[NUT command and variable naming scheme,nut-names] -for more information. -================================================================================ +- the `CHRG` and `DISCHRG` flags are being replaced with +`battery.charger.status`. See the linkdoc:user-manual[NUT command and +variable naming scheme,nut-names] for more information. +============================================================================== UPS alarms ---------- @@ -240,11 +258,11 @@ UPS alarms These work like ups.status, and have three special functions which you must use to manage them. - alarm_init() - before doing anything else + alarm_init() -- before doing anything else - alarm_set() - add an alarm word + alarm_set() -- add an alarm word - alarm_commit() - push the value into ups.alarm + alarm_commit() -- push the value into ups.alarm NOTE: the ALARM flag in ups.status is automatically set whenever you use alarm_set. To remove that flag from ups.status, call alarm_init and @@ -259,6 +277,10 @@ flag in ups.status. There is no official list of alarm words as of this writing, so don't use these functions until you check with the upsdev list. +Also refer to the <> chapter +of the user manual and developer guide for information related to alarms +handling in daisychain mode. + Staleness control ----------------- @@ -269,7 +291,7 @@ else to ensure that it is really available. If the attempts to contact the UPS fail, you must call dstate_datastale() to inform the server and clients. -- dstate_dataok() +- dstate_dataok() + You must call this if polls are succeeding. A good place to call this is the bottom of upsdrv_updateinfo(). @@ -340,13 +362,14 @@ logic 1. This function unlocks the port if possible and closes the fd. You should call this in your upsdrv_cleanup handler. - - int ser_send_char(int fd, char ch) + - ssize_t ser_send_char(int fd, unsigned char ch) This attempts to write one character and returns the return value from write. You could call write directly, but using this function allows for future error handling in one place. - - int ser_send_pace(int fd, unsigned long d_usec, const char *fmt, ...) + - ssize_t ser_send_pace(int fd, useconds_t d_usec, + const char *fmt, ...) If you need to send a formatted buffer with an intercharacter delay, use this function. There are a number of UPS controllers which can't take @@ -357,21 +380,22 @@ one. The return value is the number of characters that was sent to the port, or -1 if something failed. - - int ser_send(int fd, const char *fmt, ...) + - ssize_t ser_send(int fd, const char *fmt, ...) Like ser_send_pace, but without a delay. Only use this if you're sure that your UPS can handle characters at the full line rate. - - int ser_send_buf(int fd, const char *buf, size_t buflen) + - ssize_t ser_send_buf(int fd, const void *buf, size_t buflen) This sends a raw buffer to the fd. It is typically used for binary transmissions. It returns the results of the call to write. - - int ser_send_buf_pace(int fd, unsigned long d_usec, const char *buf, size_t buflen) + - ssize_t ser_send_buf_pace(int fd, useconds_t d_usec, + const void *buf, size_t buflen) This is just ser_send_buf with an intercharacter delay. - - int ser_get_char(int fd, char *ch, long d_sec, long d_usec) + - ssize_t ser_get_char(int fd, void *ch, time_t d_sec, useconds_t d_usec) This will wait up to d_sec seconds + d_usec microseconds for one character to arrive, storing it at ch. It returns 1 on success, -1 @@ -382,7 +406,8 @@ back to the usual idle loop in main in time to answer the PINGs from upsd. That will cause an oscillation between staleness and normal behavior. - - int ser_get_buf(int fd, char *buf, size_t buflen, long d_sec, long d_usec) + - ssize_t ser_get_buf(int fd, void *buf, size_t buflen, + time_t d_sec, useconds_t d_usec) Like ser_get_char, but this one reads up to buflen bytes storing all of them in buf. The buffer is zeroed regardless of success or failure. It @@ -390,7 +415,8 @@ returns the number of bytes read, -1 on failure and 0 on a timeout. This is essentially a single read() function with a timeout. - - int ser_get_buf_len(int fd, char *buf, size_t buflen, long d_sec, long d_usec) + - ssize_t ser_get_buf_len(int fd, void *buf, size_t buflen, + time_t d_sec, useconds_t d_usec) Like ser_get_buf, but this one waits for buflen bytes to arrive, storing all of them in buf. The buffer is zeroed regardless of success @@ -400,8 +426,9 @@ and 0 on a timeout. This should only be used for binary reads. See ser_get_line for protocols that are terminated by characters like CR or LF. - - int ser_get_line(int fd, char *buf, size_t buflen, char endchar, - const char *ignset, long d_sec, long d_usec) + - ssize_t ser_get_line(int fd, void *buf, size_t buflen, + char endchar, const char *ignset, + time_t d_sec, useconds_t d_usec) This is the reading function you should use if your UPS tends to send responses like "OK\r" or "1234\n". It reads up to buflen bytes and @@ -413,26 +440,27 @@ failure and 0 on a timeout. If the character matches the ignset with strchr(), it will not be added to the buffer. If you don't need to ignore any characters, just pass it -an empty string - "". +an empty string -- `""`. -The buffer is always cleared and is always null-terminated. It does -this by reading at most (buflen - 1) bytes. +The buffer is always cleared and is always `null`-terminated. It does +this by reading at most `(buflen - 1)` bytes. NOTE: any other data which is read after the endchar in the serial -buffer will be lost forever. As a result, you should not use this +buffer will be lost forever. As a result, you should not use this unless your UPS uses a polled protocol. -Let's say your endchar is \n and your UPS sends "OK\n1234\nabcd\n". -This function will read() all of that, find the first \n, and stop -there. Your driver will get "OK", and the rest is gone forever. +Let's say your endchar is `\n` and your UPS sends `"OK\n1234\nabcd\n"`. +This function will `read()` all of that, find the first `\n`, and stop +there. Your driver will get `"OK"`, and the rest is gone forever. This also means that you should not "pipeline" commands to the UPS. Send a query, then read the response, then send the next query. - - - int ser_get_line_alert(int fd, char *buf, size_t buflen, - char endchar, const char *ignset, const char *alertset, - void handler(char ch), long d_sec, long d_usec) + - ssize_t ser_get_line_alert(int fd, void *buf, size_t buflen, + char endchar, const char *ignset, + const char *alertset, + void handler(char ch), + time_t d_sec, useconds_t d_usec) This is just like ser_get_line, but it allows you to specify a set of alert characters which may be received at any time. They are not added @@ -443,7 +471,7 @@ Implementation note: this function actually does all of the work, and ser_get_line is just a wrapper that sets an empty alertset and a NULL handler. - - int ser_flush_in(int fd, const char *ignset, int verbose) + - ssize_t ser_flush_in(int fd, const char *ignset, int verbose) This function will drain the input buffer. If verbose is set to a positive number, then it will announce the characters which have been @@ -454,7 +482,7 @@ This function returns the number of characters which were read, so you can check for extra bytes by looking for a nonzero return value. Zero will also be returned if the read fails for some reason. - - int set_flush_io(int fd) + - int ser_flush_io(int fd) This function drains both the in- and output buffers. Return zero on success. @@ -495,11 +523,15 @@ Drivers which use USB functions should include usb-common.h and use these: Structure and macro ~~~~~~~~~~~~~~~~~~~ - -You should us the usb_device_id structure, and the USB_DEVICE macro to + +You should use the usb_device_id_t structure, and the USB_DEVICE macro to declare the supported devices. This allows the automatic extraction of USB information, to generate the Hotplug, udev and UPower support files. +The structure allows to convey `uint16_t` values of VendorID and ProductID, +and an optional matching-function callback to interrogate the device in +more detail (constrain known supported firmware versions, OEM brands, etc.) + For example: -------------------------------------------------------------------------------- @@ -507,30 +539,36 @@ For example: #define SOMEVENDOR_VENDORID 0xXXXX /* USB IDs device table */ -static usb_device_id sv_usb_device_table [] = { +static usb_device_id_t sv_usb_device_table [] = { /* some models 1 */ { USB_DEVICE(SOMEVENDOR_VENDORID, 0xYYYY), NULL }, + /* various models */ { USB_DEVICE(SOMEVENDOR_VENDORID, 0xZZZZ), NULL }, { USB_DEVICE(SOMEVENDOR_VENDORID, 0xAAAA), NULL }, + /* Terminating entry */ - { -1, -1, NULL } + { 0, 0, NULL } }; -------------------------------------------------------------------------------- Function ~~~~~~~~ - - is_usb_device_supported(usb_device_id **usb_device_id_list, - int dev_VendorID, int dev_ProductID) + - is_usb_device_supported(usb_device_id_t *usb_device_id_list, + USBDevice_t *device) -Call this in your device opening / matching function. Pass your usb_device_id -structure, and a set of VendorID / DeviceID. +Call this in your device opening / matching function. Pass your usb_device_id_t +list structure, and a set of VendorID, DeviceID, as well as Vendor, Product and +Serial strings, possibly also Bus, bcdDevice (device release number) and Device +name on the bus strings, in the USBDevice_t fields describing the specific piece +of hardware you are inspecting. -This function returns one of the following value: +This function returns one of the following value: - NOT_SUPPORTED (0), -- POSSIBLY_SUPPORTED (1, returned when the VendorID is matched, but the DeviceID is unknown), +- POSSIBLY_SUPPORTED (1, returned when the VendorID is matched, but the +DeviceID is unknown), - or SUPPORTED (2). For implementation examples, refer to the various USB drivers, and search for @@ -570,15 +608,15 @@ function. Right now, there are only two possibilities: SET ~~~ -If your driver's function for handling variable set events is called +If your driver's function for handling variable set events is called my_ups_set(), then you'd do this to add the pointer: upsh.setvar = my_ups_set; my_ups_set() will receive two parameters: - const char * - the variable being changed - const char * - the new value + const char * -- the variable being changed + const char * -- the new value You should return either STAT_SET_HANDLED if your driver recognizes the command, or STAT_SET_UNKNOWN if it doesn't. Other possibilities will be @@ -594,8 +632,8 @@ arriving from the server. Your function will receive two args: - const char * - the command name - const char * - (reserved) + const char * -- the command name + const char * -- (reserved) You should return either STAT_INSTCMD_HANDLED or STAT_INSTCMD_UNKNOWN depending on whether your driver can handle the requested command. diff --git a/docs/nut-names.txt b/docs/nut-names.txt index d2e46c7..efe1ae2 100644 --- a/docs/nut-names.txt +++ b/docs/nut-names.txt @@ -1,21 +1,68 @@ ifndef::external_title[] -NUT command and variable naming scheme -====================================== +NUT variable names and instant commands +======================================= endif::external_title[] -This is a dump of the standard variables and command names used in NUT. -Don't use a name with any of the dstate functions unless it exists here. +[NOTE] +.RFC xxxx Recording Document +==== +This document is defined by (pending) RFC xxxx and is referenced as the +document of record for the variable names and the instant commands used +in the protocol described by the RFC. -If you need a new variable or command name, contact the Development Team -first. +On behalf of the RFC, this document records the names of variables +describing the abstracted state of an UPS or similar power distribution +device, and the instant commands sent to the UPS using command `INSTCMD`, +as used in commands and messages between the Attachment Daemon (the `upsd` +in case of NUT implementation of the standard) and the clients. +==== -Put another way: if you make up a name that's not in this list and it -gets into the tree, and then we come up with a better name later, clients -that use the undocumented variable will break when it is changed. +This document defines the standard names of NUT commands and variables. +Developers should use the names recorded here, with dstate functions and +data mappings provided in NUT drivers for interactions with power devices. -NOTE: "opaque" means programs should not attempt to parse the value for -that variable as it may vary greatly from one UPS to the next. These -strings are best handled directly by the user. +If you need to express a state which cannot be described by any existing +name, please make a request to the NUT developers' mailing list for +definition and assignment of a new name. Clients using unrecorded names +risk breaking at a future update. If you wish to experiment with new +concepts before obtaining your requested variable name, you should use +a name of the form `experimental.x.y` for those states. + +Put another way: if you make up a name that is not in this list and it +gets into the source code tree, and then the NUT community comes up with +a better name later, clients that already use the undocumented variable +will break when it is eventually changed. An explicitly "experimental" +data point is less surprising in this regard. + +NOTE: In the descriptions, "opaque" means programs should not attempt to +parse the value for that variable as it may vary greatly from one UPS +(or similar device) to the next. These strings are best handled directly +by the user. + + +Time and Date format +-------------------- + +When possible, dates should be expressed in ISO 8601 and RFC 3339 compatible +Calendar format, that is to say "YYYY-MM-DD", or otherwise a Combined Date +and Time representation (`T

- chroot to \n"); printf(" -u - switch to (if started as root)\n"); + printf(" -g - set pipe access to (if started as root)\n"); printf(" -x = - set driver variable to \n"); printf(" - example: -x cable=940-0095B\n\n"); @@ -255,6 +308,11 @@ static int main_arg(char *var, char *val) { /* flags for main */ + upsdebugx(3, "%s: var='%s' val='%s'", + __func__, + var ? var : "", /* null should not happen... but... */ + val ? val : ""); + if (!strcmp(var, "nolock")) { do_lock_port = 0; dstate_setinfo("driver.flag.nolock", "enabled"); @@ -268,7 +326,7 @@ static int main_arg(char *var, char *val) /* any other flags are for the driver code */ if (!val) - return 0; + return 0; /* unhandled, pass it through to the driver */ /* variables for main: port */ @@ -279,6 +337,39 @@ static int main_arg(char *var, char *val) return 1; /* handled */ } + /* user specified at the driver level overrides that on global level + * or the built-in default + */ + if (!strcmp(var, "user")) { + if (user_from_cmdline) { + upsdebugx(0, "User '%s' specified in driver section " + "was ignored due to '%s' specified on command line", + val, user); + } else { + upsdebugx(1, "Overriding previously specified user '%s' " + "with '%s' specified for driver section", + user, val); + free(user); + user = xstrdup(val); + } + return 1; /* handled */ + } + + if (!strcmp(var, "group")) { + if (group_from_cmdline) { + upsdebugx(0, "Group '%s' specified in driver section " + "was ignored due to '%s' specified on command line", + val, group); + } else { + upsdebugx(1, "Overriding previously specified group '%s' " + "with '%s' specified for driver section", + group, val); + free(group); + group = xstrdup(val); + } + return 1; /* handled */ + } + if (!strcmp(var, "sddelay")) { upslogx(LOG_INFO, "Obsolete value sddelay found in ups.conf"); return 1; /* handled */ @@ -288,6 +379,9 @@ static int main_arg(char *var, char *val) if (!strcmp(var, "synchronous")) { if (!strcmp(val, "yes")) do_synchronous=1; + else + if (!strcmp(val, "auto")) + do_synchronous=-1; else do_synchronous=0; @@ -302,13 +396,36 @@ static int main_arg(char *var, char *val) if (!strcmp(var, "desc")) return 1; /* handled */ + /* Allow each driver to specify its minimal debugging level - + * admins can set more with command-line args, but can't set + * less without changing config. Should help debug of services. */ + if (!strcmp(var, "debug_min")) { + int lvl = -1; // typeof common/common.c: int nut_debug_level + if ( str_to_int (val, &lvl, 10) && lvl >= 0 ) { + nut_debug_level_driver = lvl; + } else { + upslogx(LOG_INFO, "WARNING : Invalid debug_min value found in ups.conf for the driver"); + } + return 1; /* handled */ + } + return 0; /* unhandled, pass it through to the driver */ } static void do_global_args(const char *var, const char *val) { + upsdebugx(3, "%s: var='%s' val='%s'", + __func__, + var ? var : "", /* null should not happen... but... */ + val ? val : ""); + if (!strcmp(var, "pollinterval")) { - poll_interval = atoi(val); + int ipv = atoi(val); + if (ipv > 0) { + poll_interval = (time_t)ipv; + } else { + fatalx(EXIT_FAILURE, "Error: invalid pollinterval: %d", ipv); + } return; } @@ -318,17 +435,54 @@ static void do_global_args(const char *var, const char *val) } if (!strcmp(var, "user")) { - free(user); - user = xstrdup(val); + if (user_from_cmdline) { + upsdebugx(0, "User specified in global section '%s' " + "was ignored due to '%s' specified on command line", + val, user); + } else { + upsdebugx(1, "Overriding previously specified user '%s' " + "with '%s' specified in global section", + user, val); + free(user); + user = xstrdup(val); + } + } + + if (!strcmp(var, "group")) { + if (group_from_cmdline) { + upsdebugx(0, "Group specified in global section '%s' " + "was ignored due to '%s' specified on command line", + val, group); + } else { + upsdebugx(1, "Overriding previously specified group '%s' " + "with '%s' specified in global section", + group, val); + free(group); + group = xstrdup(val); + } } if (!strcmp(var, "synchronous")) { if (!strcmp(val, "yes")) do_synchronous=1; + else + if (!strcmp(val, "auto")) + do_synchronous=-1; else do_synchronous=0; } + /* Allow to specify its minimal debugging level for all drivers - + * admins can set more with command-line args, but can't set + * less without changing config. Should help debug of services. */ + if (!strcmp(var, "debug_min")) { + int lvl = -1; // typeof common/common.c: int nut_debug_level + if ( str_to_int (val, &lvl, 10) && lvl >= 0 ) { + nut_debug_level_global = lvl; + } else { + upslogx(LOG_INFO, "WARNING : Invalid debug_min value found in ups.conf global settings"); + } + } /* unrecognized */ } @@ -365,15 +519,38 @@ void do_upsconf_args(char *confupsname, char *var, char *val) /* don't let the user shoot themselves in the foot */ if (!strcmp(var, "driver")) { - if (strcmp(val, progname) != 0) + /* Accomodate for libtool wrapped developer iterations + * running e.g. `drivers/.libs/lt-dummy-ups` filenames + */ + size_t tmplen = strlen("lt-"); + if (strncmp("lt-", progname, tmplen) == 0 + && strcmp(val, progname + tmplen) == 0) { + /* debug level may be not initialized yet, and situation + * should not happen in end-user builds, so ok to yell: */ + upsdebugx(0, "Seems this driver binary %s is a libtool " + "wrapped build for driver %s", progname, val); + /* progname points to xbasename(argv[0]) in-place; + * roll the pointer forward a bit, we know we can: + */ + progname = progname + tmplen; + } + + if (strcmp(val, progname) != 0) { fatalx(EXIT_FAILURE, "Error: UPS [%s] is for driver %s, but I'm %s!\n", confupsname, val, progname); + } return; } /* allow per-driver overrides of the global setting */ if (!strcmp(var, "pollinterval")) { - poll_interval = atoi(val); + int ipv = atoi(val); + if (ipv > 0) { + poll_interval = (time_t)ipv; + } else { + fatalx(EXIT_FAILURE, "Error: UPS [%s]: invalid pollinterval: %d", + confupsname, ipv); + } return; } @@ -453,6 +630,7 @@ static void exit_cleanup(void) free(chroot_path); free(device_path); free(user); + free(group); if (pidfn) { unlink(pidfn); @@ -480,7 +658,14 @@ static void setup_signals(void) sigaction(SIGINT, &sa, NULL); sigaction(SIGQUIT, &sa, NULL); +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wstrict-prototypes" +#endif sa.sa_handler = SIG_IGN; +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES) +# pragma GCC diagnostic pop +#endif sigaction(SIGHUP, &sa, NULL); sigaction(SIGPIPE, &sa, NULL); } @@ -489,12 +674,16 @@ int main(int argc, char **argv) { struct passwd *new_uid = NULL; int i, do_forceshutdown = 0; + int update_count = 0; atexit(exit_cleanup); /* pick up a default from configure --with-user */ user = xstrdup(RUN_AS_USER); /* xstrdup: this gets freed at exit */ + /* pick up a default from configure --with-group */ + group = xstrdup(RUN_AS_GROUP); /* xstrdup: this gets freed at exit */ + progname = xbasename(argv[0]); open_syslog(progname); @@ -508,7 +697,7 @@ int main(int argc, char **argv) /* build the driver's extra (-x) variable table */ upsdrv_makevartable(); - while ((i = getopt(argc, argv, "+a:kDhx:Lqr:u:Vi:")) != -1) { + while ((i = getopt(argc, argv, "+a:s:kFBDd:hx:Lqr:u:g:Vi:")) != -1) { switch (i) { case 'a': upsname = optarg; @@ -519,11 +708,31 @@ int main(int argc, char **argv) fatalx(EXIT_FAILURE, "Error: Section %s not found in ups.conf", optarg); break; + case 's': + upsname = optarg; + upsname_found = 1; + break; + case 'F': + background_flag = 0; + break; + case 'B': + background_flag = 1; + break; case 'D': nut_debug_level++; break; - case 'i': - poll_interval = atoi(optarg); + case 'd': + dump_data = atoi(optarg); + break; + case 'i': { /* scope */ + int ipv = atoi(optarg); + if (ipv > 0) { + poll_interval = (time_t)ipv; + } else { + fatalx(EXIT_FAILURE, "Error: command-line: invalid pollinterval: %d", + ipv); + } + } break; case 'k': do_lock_port = 0; @@ -539,8 +748,36 @@ int main(int argc, char **argv) chroot_path = xstrdup(optarg); break; case 'u': + if (user_from_cmdline) { + upsdebugx(1, "Previously specified user for drivers '%s' " + "was ignored due to '%s' specified on command line" + " (again?)", + user, optarg); + } else { + upsdebugx(1, "Built-in default or configured user " + "for drivers '%s' was ignored due to '%s' " + "specified on command line", + user, optarg); + } free(user); user = xstrdup(optarg); + user_from_cmdline = 1; + break; + case 'g': + if (group_from_cmdline) { + upsdebugx(1, "Previously specified group for drivers '%s' " + "was ignored due to '%s' specified on command line" + " (again?)", + group, optarg); + } else { + upsdebugx(1, "Built-in default or configured group " + "for drivers '%s' was ignored due to '%s' " + "specified on command line", + group, optarg); + } + free(group); + group = xstrdup(optarg); + group_from_cmdline = 1; break; case 'V': /* already printed the banner, so exit */ @@ -557,6 +794,21 @@ int main(int argc, char **argv) } } + if (nut_debug_level > 0 || dump_data) { + if ( background_flag < 0 ) { + /* Only flop from default - stay foreground with debug on */ + background_flag = 0; + } else { + upsdebugx (0, + "Debug level is %d, dump data count is %s, " + "but backgrounding mode requested as %s", + nut_debug_level, + dump_data ? "on" : "off", + background_flag ? "on" : "off" + ); + } + } /* else: default remains `background_flag==-1` where nonzero is true */ + argc -= optind; argv += optind; @@ -567,15 +819,32 @@ int main(int argc, char **argv) if (!upsname_found) { fatalx(EXIT_FAILURE, - "Error: specifying '-a id' is now mandatory. Try -h for help."); + "Error: specifying '-a id' or '-s id' is now mandatory. Try -h for help."); } /* we need to get the port from somewhere */ if (!device_path) { fatalx(EXIT_FAILURE, - "Error: you must specify a port name in ups.conf. Try -h for help."); + "Error: you must specify a port name in ups.conf or in '-x port=...' argument.\n" + "Try -h for help."); } + /* CLI debug level can not be smaller than debug_min specified + * in ups.conf, and value specified for a driver config section + * overrides the global one. Note that non-zero debug_min does + * not impact foreground running mode. + */ + { + int nut_debug_level_upsconf = -1 ; + if ( nut_debug_level_global >= 0 && nut_debug_level_driver >= 0 ) { + nut_debug_level_upsconf = nut_debug_level_driver; + } else { + if ( nut_debug_level_global >= 0 ) nut_debug_level_upsconf = nut_debug_level_global; + if ( nut_debug_level_driver >= 0 ) nut_debug_level_upsconf = nut_debug_level_driver; + } + if ( nut_debug_level_upsconf > nut_debug_level ) + nut_debug_level = nut_debug_level_upsconf; + } upsdebugx(1, "debug level is '%d'", nut_debug_level); new_uid = get_user_pwent(user); @@ -585,13 +854,14 @@ int main(int argc, char **argv) become_user(new_uid); - /* Only switch to statepath if we're not powering off */ - /* This avoid case where ie /var is umounted */ - if ((!do_forceshutdown) && (chdir(dflt_statepath()))) + /* Only switch to statepath if we're not powering off + * or not just dumping data (for discovery) */ + /* This avoids case where ie /var is unmounted already */ + if ((!do_forceshutdown) && (!dump_data) && (chdir(dflt_statepath()))) fatal_with_errno(EXIT_FAILURE, "Can't chdir to %s", dflt_statepath()); /* Setup signals to communicate with driver once backgrounded. */ - if ((nut_debug_level == 0) && (!do_forceshutdown)) { + if ((background_flag != 0) && (!do_forceshutdown)) { char buffer[SMALLBUF]; setup_signals(); @@ -614,19 +884,26 @@ int main(int argc, char **argv) break; } - upslogx(LOG_WARNING, "Duplicate driver instance detected! Terminating other driver!"); + upslogx(LOG_WARNING, "Duplicate driver instance detected (PID file %s exists)! Terminating other driver!", buffer); /* Allow driver some time to quit */ sleep(5); } - pidfn = xstrdup(buffer); - writepid(pidfn); /* before backgrounding */ + /* Only write pid if we're not just dumping data, for discovery */ + if (!dump_data) { + pidfn = xstrdup(buffer); + writepid(pidfn); /* before backgrounding */ + } } /* clear out callback handler data */ memset(&upsh, '\0', sizeof(upsh)); + /* note: device.type is set early to be overridden by the driver + * when its a pdu! */ + dstate_setinfo("device.type", "ups"); + upsdrv_initups(); /* UPS is detected now, cleanup upon exit */ @@ -640,15 +917,19 @@ int main(int argc, char **argv) if (do_forceshutdown) forceshutdown(); - /* note: device.type is set early to be overriden by the driver - * when its a pdu! */ - dstate_setinfo("device.type", "ups"); - /* publish the top-level data: version numbers, driver name */ dstate_setinfo("driver.version", "%s", UPS_VERSION); dstate_setinfo("driver.version.internal", "%s", upsdrv_info.version); dstate_setinfo("driver.name", "%s", progname); + /* + * If we are not debugging, send the early startup logs generated by + * upsdrv_initinfo() and upsdrv_updateinfo() to syslog, not just stderr. + * Otherwise these logs are lost. + */ + if ((nut_debug_level == 0) && (!dump_data)) + syslogbit_set(); + /* get the base data established before allowing connections */ upsdrv_initinfo(); upsdrv_updateinfo(); @@ -676,14 +957,87 @@ int main(int argc, char **argv) } /* now we can start servicing requests */ - dstate_init(progname, upsname); + /* Only write pid if we're not just dumping data, for discovery */ + if (!dump_data) { + char * sockname = dstate_init(progname, upsname); + /* Normally we stick to the built-in account info, + * so if they were not over-ridden - no-op here: + */ + if (strcmp(group, RUN_AS_GROUP) + || strcmp(user, RUN_AS_USER) + ) { + int allOk = 1; + /* Tune group access permission to the pipe, + * so that upsd can access it (using the + * specified or retained default group): + */ + struct group *grp = getgrnam(group); + upsdebugx(1, "Group and/or user account for this driver " + "was customized ('%s:%s') compared to built-in " + "defaults. Fixing socket '%s' ownership/access.", + user, group, sockname); + + if (grp == NULL) { + upsdebugx(1, "WARNING: could not resolve " + "group name '%s': %s", + group, strerror(errno) + ); + allOk = 0; + } else { + struct stat statbuf; + mode_t mode; + if (chown(sockname, -1, grp->gr_gid)) { + upsdebugx(1, "WARNING: chown failed: %s", + strerror(errno) + ); + allOk = 0; + } + + if (stat(sockname, &statbuf)) { + /* Logically we'd fail chown above if file + * does not exist or is not accessible, but + * practically we only need stat for chmod + */ + upsdebugx(1, "WARNING: stat failed: %s", + strerror(errno) + ); + allOk = 0; + } else { + /* chmod g+rw sockname */ + mode = statbuf.st_mode; + mode |= S_IWGRP; + mode |= S_IRGRP; + if (chmod(sockname, mode)) { + upsdebugx(1, "WARNING: chmod failed: %s", + strerror(errno) + ); + allOk = 0; + } + } + } + + if (allOk) { + upsdebugx(1, "Group access for this driver successfully fixed"); + } else { + upsdebugx(0, "WARNING: Needed to fix group access " + "to filesystem socket of this driver, but failed; " + "run the driver with more debugging to see how exactly.\n" + "Consumers of the socket, such as upsd data server, " + "can fail to interact with the driver and represent " + "the device: %s", + sockname); + } + + } + free(sockname); + } /* The poll_interval may have been changed from the default */ - dstate_setinfo("driver.parameter.pollinterval", "%d", poll_interval); + dstate_setinfo("driver.parameter.pollinterval", "%jd", (intmax_t)poll_interval); /* The synchronous option may have been changed from the default */ dstate_setinfo("driver.parameter.synchronous", "%s", - (do_synchronous==1)?"yes":"no"); + (do_synchronous==1)?"yes":((do_synchronous==0)?"no":"auto")); /* remap the device.* info from ups.* for the transition period */ if (dstate_getinfo("ups.mfr") != NULL) @@ -693,7 +1047,7 @@ int main(int argc, char **argv) if (dstate_getinfo("ups.serial") != NULL) dstate_setinfo("device.serial", "%s", dstate_getinfo("ups.serial")); - if (nut_debug_level == 0) { + if (background_flag != 0) { background(); writepid(pidfn); /* PID changes when backgrounding */ } @@ -707,13 +1061,27 @@ int main(int argc, char **argv) upsdrv_updateinfo(); - while (!dstate_poll_fds(timeout, extrafd) && !exit_flag) { - /* repeat until time is up or extrafd has data */ + /* Dump the data tree (in upsc-like format) to stdout and exit */ + if (dump_data) { + /* Wait for 'dump_data' update loops to ensure data completion */ + if (update_count == dump_data) { + dstate_dump(); + exit_flag = 1; + } + else + update_count++; + } + else { + while (!dstate_poll_fds(timeout, extrafd) && !exit_flag) { + /* repeat until time is up or extrafd has data */ + } } } /* if we get here, the exit flag was set by a signal handler */ - upslogx(LOG_INFO, "Signal %d: exiting", exit_flag); + /* however, avoid to "pollute" data dump output! */ + if (!dump_data) + upslogx(LOG_INFO, "Signal %d: exiting", exit_flag); exit(EXIT_SUCCESS); } diff --git a/drivers/main.h b/drivers/main.h index 3e3e84e..523d908 100644 --- a/drivers/main.h +++ b/drivers/main.h @@ -1,5 +1,5 @@ -#ifndef MAIN_H -#define MAIN_H +#ifndef NUT_MAIN_H_SEEN +#define NUT_MAIN_H_SEEN #include "common.h" #include "upsconf.h" @@ -10,7 +10,7 @@ extern const char *progname, *upsname, *device_name; extern char *device_path; extern int upsfd, extrafd, broken_driver, experimental_driver, do_lock_port, exit_flag; -extern unsigned int poll_interval; +extern time_t poll_interval; /* functions & variables required in each driver */ void upsdrv_initups(void); /* open connection to UPS, fail if not found */ @@ -53,7 +53,7 @@ void addvar(int vartype, const char *name, const char *desc); /* subdriver description structure */ typedef struct upsdrv_info_s { - const char *name; /* driver full name, for banner printing, ... */ + const char *name; /* driver full name, for banner printing, ... */ const char *version; /* driver version */ const char *authors; /* authors name */ const int status; /* driver development status */ @@ -76,4 +76,4 @@ typedef struct upsdrv_info_s { /* public driver information from the driver file */ extern upsdrv_info_t upsdrv_info; -#endif /* MAIN_H */ +#endif /* NUT_MAIN_H_SEEN */ diff --git a/drivers/masterguard.c b/drivers/masterguard.c index 7edc899..46364f6 100644 --- a/drivers/masterguard.c +++ b/drivers/masterguard.c @@ -4,6 +4,11 @@ masterguard.c created on 15.8.2001 + OBSOLETION WARNING: Please to not base new development on this + codebase, instead create a new subdriver for nutdrv_qx which + generally covers all Megatec/Qx protocol family and aggregates + device support from such legacy drivers over time. + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or @@ -19,22 +24,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/******************************************************************** - * - * Please if you edit this code convert tabs to spaces and use - * four characters indent. - * If you don't know what this means use the vim editor. - * - * Have fun - * Michael - * - ********************************************************************/ #include "main.h" #include "serial.h" #define DRIVER_NAME "MASTERGUARD UPS driver" -#define DRIVER_VERSION "0.24" +#define DRIVER_VERSION "0.25" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -54,76 +48,76 @@ upsdrv_info_t upsdrv_info = { #define DEBUG 1 -int type; -char name[31]; -char firmware[6]; +static int type; +static char name[31]; +static char firmware[6]; /******************************************************************** * - * Helper function to split a sting into words by splitting at the + * Helper function to split a sting into words by splitting at the * SPACE character. * - * Adds up to maxlen characters to the char word. + * Adds up to maxlen characters to the char word. * Returns NULL on reaching the end of the string. - * + * ********************************************************************/ -static char *StringSplit( char *source, char *word, int maxlen ) +static char *StringSplit( char *source, char *word, size_t maxlen ) { - int i; - int len; - int wc=0; - - word[0] = '\0'; - len = strlen( source ); - for( i = 0; i < len; i++ ) - { - if( source[i] == ' ' ) - { - word[wc] = '\0'; - return source + i + 1; - } - word[wc] = source[i]; - wc++; - } - word[wc] = '\0'; - return NULL; + size_t i; + size_t len; + size_t wc=0; + + word[0] = '\0'; + len = strlen( source ); + for( i = 0; i < len && wc < maxlen; i++ ) + { + if( source[i] == ' ' ) + { + word[wc] = '\0'; + return source + i + 1; + } + word[wc] = source[i]; + wc++; + } + word[wc] = '\0'; + return NULL; } - + /******************************************************************** * * Helper function to drop all whitespaces within a string. - * + * * "word" must be large enought to hold "source", for the worst case * "word" has to be exacly the size of "source". - * + * ********************************************************************/ static void StringStrip( char *source, char *word ) { - int wc=0; - int i; - int len; + size_t wc=0; + size_t i; + size_t len; - word[0] = '\0'; - len = strlen( source ); - for( i = 0; i < len; i++ ) - { - if( source[i] == ' ' ) - continue; - if( source[i] == '\n' ) - continue; - if( source[i] == '\t' ) - continue; - word[wc] = source[i]; - wc++; - } - word[wc] = '\0'; + word[0] = '\0'; + len = strlen( source ); + for( i = 0; i < len; i++ ) + { + if( source[i] == ' ' ) + continue; + if( source[i] == '\n' ) + continue; + if( source[i] == '\t' ) + continue; + word[wc] = source[i]; + wc++; + } + word[wc] = '\0'; } /******************************************************************** * * Function parses the status flags which occure in the Q1 and Q3 * command. Sets the INFO_STATUS value ( OL, OB, ... ) - * + * ********************************************************************/ static void parseFlags( char *flags ) { @@ -143,7 +137,7 @@ static void parseFlags( char *flags ) /* this has no mapping */ #if 0 if( flags[3] == '1' ) - setinfo( INFO_ALRM_GENERAL, "1" ); + setinfo( INFO_ALRM_GENERAL, "1" ); #endif #if 0 @@ -157,195 +151,195 @@ static void parseFlags( char *flags ) status_commit(); - if( DEBUG ) - printf( "Status is %s\n", dstate_getinfo("ups.status")); + if( DEBUG ) + printf( "Status is %s\n", dstate_getinfo("ups.status")); } /******************************************************************** * * Function parses the response of the query1 ( "Q1" ) command. * Also sets various values (IPFreq ... ) - * + * ********************************************************************/ static void query1( char *buf ) { - #define WORDMAXLEN 255 - char value[WORDMAXLEN]; - char word[WORDMAXLEN]; - char *newPOS; - char *oldPOS; - int count = 0; + #define WORDMAXLEN 255 + char value[WORDMAXLEN]; + char word[WORDMAXLEN]; + char *newPOS; + char *oldPOS; + int count = 0; - if( DEBUG ) - printf( "Q1 Buffer is : %s\n" , buf + 1 ); - oldPOS = buf + 1; - newPOS = oldPOS; - - do - { - newPOS = StringSplit( oldPOS, word, WORDMAXLEN ); - StringStrip( word, value); - oldPOS = newPOS; + if( DEBUG ) + printf( "Q1 Buffer is : %s\n" , buf + 1 ); + oldPOS = buf + 1; + newPOS = oldPOS; - if( DEBUG ) - { - printf( "value=%s\n", value ); - fflush( stdout ); - } - switch( count ) - { - case 0: - /* IP Voltage */ - dstate_setinfo("input.voltage", "%s", value ); - break; - case 1: - /* IP Fault Voltage */ - break; - case 2: - /* OP Voltage */ - dstate_setinfo("output.voltage", "%s", value); - break; - case 3: - /* OP Load*/ - dstate_setinfo("ups.load", "%s", value ); - break; - case 4: - /* IP Frequency */ - dstate_setinfo("input.frequency", "%s", value); - break; - case 5: - /* Battery Cell Voltage */ - dstate_setinfo("battery.voltage", "%s", value); - break; - case 6: - /* UPS Temperature */ - dstate_setinfo("ups.temperature", "%s", value ); - break; - case 7: - /* Flags */ - parseFlags( value ); - break; - default: - /* Should never be reached */ - break; - } - count ++; - oldPOS = newPOS; - } - while( newPOS != NULL ); + do + { + newPOS = StringSplit( oldPOS, word, WORDMAXLEN ); + StringStrip( word, value); + oldPOS = newPOS; + + if( DEBUG ) + { + printf( "value=%s\n", value ); + fflush( stdout ); + } + switch( count ) + { + case 0: + /* IP Voltage */ + dstate_setinfo("input.voltage", "%s", value ); + break; + case 1: + /* IP Fault Voltage */ + break; + case 2: + /* OP Voltage */ + dstate_setinfo("output.voltage", "%s", value); + break; + case 3: + /* OP Load*/ + dstate_setinfo("ups.load", "%s", value ); + break; + case 4: + /* IP Frequency */ + dstate_setinfo("input.frequency", "%s", value); + break; + case 5: + /* Battery Cell Voltage */ + dstate_setinfo("battery.voltage", "%s", value); + break; + case 6: + /* UPS Temperature */ + dstate_setinfo("ups.temperature", "%s", value ); + break; + case 7: + /* Flags */ + parseFlags( value ); + break; + default: + /* Should never be reached */ + break; + } + count ++; + oldPOS = newPOS; + } + while( newPOS != NULL ); } /******************************************************************** * * Function parses the response of the query3 ( "Q3" ) command. * Also sets various values (IPFreq ... ) - * + * ********************************************************************/ static void query3( char *buf ) { - #define WORDMAXLEN 255 - char value[WORDMAXLEN]; - char word[WORDMAXLEN]; - char *newPOS; - char *oldPOS; - int count = 0; + #define WORDMAXLEN 255 + char value[WORDMAXLEN]; + char word[WORDMAXLEN]; + char *newPOS; + char *oldPOS; + int count = 0; - if( DEBUG ) - printf( "Q3 Buffer is : %s\n" , buf+1 ); - oldPOS = buf + 1; - newPOS = oldPOS; - - do - { - newPOS = StringSplit( oldPOS, word, WORDMAXLEN ); - StringStrip( word, value); - oldPOS = newPOS; + if( DEBUG ) + printf( "Q3 Buffer is : %s\n" , buf+1 ); + oldPOS = buf + 1; + newPOS = oldPOS; - /* Shortcut */ - if( newPOS == NULL ) - break; + do + { + newPOS = StringSplit( oldPOS, word, WORDMAXLEN ); + StringStrip( word, value); + oldPOS = newPOS; - if( DEBUG ) - { - printf( "value=%s\n", value ); - fflush( stdout ); - } - switch( count ) - { - case 0: - /* UPS ID */ - break; - case 1: - /* Input Voltage */ - dstate_setinfo("input.voltage", "%s", value ); - break; - case 2: - /* Input Fault Voltage */ - break; - case 3: - /* Output Voltage */ - dstate_setinfo("output.voltage", "%s", value); - break; - case 4: - /* Output Current */ - dstate_setinfo("output.current", "%s", value ); - break; - case 5: - /* Input Frequency */ - dstate_setinfo("input.frequency", "%s", value); - break; - case 6: - /* Battery Cell Voltage */ - dstate_setinfo("battery.voltage", "%s", value); - break; - case 7: - /* Temperature */ - dstate_setinfo("ups.temperature", "%s", value ); - break; - case 8: - /* Estimated Runtime */ - dstate_setinfo("battery.runtime", "%s", value); - break; - case 9: - /* Charge Status */ - dstate_setinfo("battery.charge", "%s", value); - break; - case 10: - /* Flags */ - parseFlags( value ); - break; - case 11: - /* Flags2 */ - break; - default: - /* This should never be reached */ - /* printf( "DEFAULT\n" ); */ - break; - } - count ++; - oldPOS = newPOS; - } - while( newPOS != NULL ); + /* Shortcut */ + if( newPOS == NULL ) + break; + + if( DEBUG ) + { + printf( "value=%s\n", value ); + fflush( stdout ); + } + switch( count ) + { + case 0: + /* UPS ID */ + break; + case 1: + /* Input Voltage */ + dstate_setinfo("input.voltage", "%s", value ); + break; + case 2: + /* Input Fault Voltage */ + break; + case 3: + /* Output Voltage */ + dstate_setinfo("output.voltage", "%s", value); + break; + case 4: + /* Output Current */ + dstate_setinfo("output.current", "%s", value ); + break; + case 5: + /* Input Frequency */ + dstate_setinfo("input.frequency", "%s", value); + break; + case 6: + /* Battery Cell Voltage */ + dstate_setinfo("battery.voltage", "%s", value); + break; + case 7: + /* Temperature */ + dstate_setinfo("ups.temperature", "%s", value ); + break; + case 8: + /* Estimated Runtime */ + dstate_setinfo("battery.runtime", "%s", value); + break; + case 9: + /* Charge Status */ + dstate_setinfo("battery.charge", "%s", value); + break; + case 10: + /* Flags */ + parseFlags( value ); + break; + case 11: + /* Flags2 */ + break; + default: + /* This should never be reached */ + /* printf( "DEFAULT\n" ); */ + break; + } + count ++; + oldPOS = newPOS; + } + while( newPOS != NULL ); } /******************************************************************** * * Function to parse the WhoAmI response of the UPS. Also sets the * values of the firmware version and the UPS identification. - * + * ********************************************************************/ static void parseWH( char *buf ) { - strncpy( name, buf + 16, 30 ); - name[30] = '\0'; - strncpy( firmware, buf + 4, 5 ); - firmware[5] = '\0'; - if( DEBUG ) - printf( "Name = %s, Firmware Version = %s\n", name, firmware ); + strncpy( name, buf + 16, 30 ); + name[30] = '\0'; + strncpy( firmware, buf + 4, 5 ); + firmware[5] = '\0'; + if( DEBUG ) + printf( "Name = %s, Firmware Version = %s\n", name, firmware ); } /******************************************************************** - * + * * Function to parse the old and possible broken WhoAmI response * and set the values for the firmware Version and the identification * of the UPS. @@ -353,97 +347,97 @@ static void parseWH( char *buf ) ********************************************************************/ static void parseOldWH( char *buf ) { - strncpy( name, buf + 4, 12 ); - name[12] = '\0'; - strncpy( firmware, buf, 4 ); - firmware[4] = '\0'; - if( DEBUG ) - printf( "Name = %s, Firmware Version = %s\n", name, firmware ); + strncpy( name, buf + 4, 12 ); + name[12] = '\0'; + strncpy( firmware, buf, 4 ); + firmware[4] = '\0'; + if( DEBUG ) + printf( "Name = %s, Firmware Version = %s\n", name, firmware ); } /******************************************************************** * * Function to fake a WhoAmI response of a UPS that returns NAK. - * + * ********************************************************************/ static void fakeWH(void) { - strcpy( name, "GenericUPS" ); - strcpy( firmware, "unkn" ); - if( DEBUG ) - printf( "Name = %s, Firmware Version = %s\n", name, firmware ); + strcpy( name, "GenericUPS" ); + strcpy( firmware, "unkn" ); + if( DEBUG ) + printf( "Name = %s, Firmware Version = %s\n", name, firmware ); } -static int ups_ident( void ) +static ssize_t ups_ident( void ) { - char buf[255]; - int ret; + char buf[255]; + ssize_t ret; - /* Check presence of Q1 */ - ret = ser_send_pace(upsfd, UPS_PACE, "%s", "Q1\x0D" ); - ret = ser_get_line(upsfd, buf, sizeof(buf), '\r', "", 3, 0); - ret = strlen( buf ); - if( ret != 46 ) - { - /* No Q1 response found */ - type = 0; - return -1; - } - else - { - if( DEBUG ) - printf( "Found Q1\n" ); - type = Q1; - } + /* Check presence of Q1 */ + ret = ser_send_pace(upsfd, UPS_PACE, "%s", "Q1\x0D" ); + ret = ser_get_line(upsfd, buf, sizeof(buf), '\r', "", 3, 0); + ret = (ssize_t)strlen( buf ); + if( ret != 46 ) + { + /* No Q1 response found */ + type = 0; + return -1; + } + else + { + if( DEBUG ) + printf( "Found Q1\n" ); + type = Q1; + } - /* Check presence of Q3 */ - ret = ser_send_pace(upsfd, UPS_PACE, "%s", "Q3\x0D" ); - ret = ser_get_line(upsfd, buf, sizeof(buf), '\r', "", 3, 0); - ret = strlen( buf ); - if( ret == 70 ) - { - if( DEBUG ) - printf( "Found Q3\n" ); - type = Q1 | Q3; - } - - /* Check presence of WH ( Who am I ) */ - ret = ser_send_pace(upsfd, UPS_PACE, "%s", "WH\x0D" ); - ret = ser_get_line(upsfd, buf, sizeof(buf), '\r', "", 3, 0); - ret = strlen( buf ); - if( ret == 112 ) - { - if( DEBUG ) - printf( "WH found\n" ); - parseWH( buf ); - } - else if( ret == 53 ) - { - if( DEBUG ) - printf( "Old (broken) WH found\n" ); - parseOldWH( buf ); - } - else if( ret == 3 && strcmp(buf, "NAK") == 0 ) - { - if( DEBUG ) - printf( "WH was NAKed\n" ); - fakeWH( ); - } - else if( ret > 0 ) - { - if( DEBUG ) - printf( "WH says <%s> with length %i\n", buf, ret ); - upslog_with_errno( LOG_INFO, - "New WH String found. Please report to maintainer\n" ); - } - return 1; -} + /* Check presence of Q3 */ + ret = ser_send_pace(upsfd, UPS_PACE, "%s", "Q3\x0D" ); + ret = ser_get_line(upsfd, buf, sizeof(buf), '\r', "", 3, 0); + ret = (ssize_t)strlen( buf ); + if( ret == 70 ) + { + if( DEBUG ) + printf( "Found Q3\n" ); + type = Q1 | Q3; + } + + /* Check presence of WH ( Who am I ) */ + ret = ser_send_pace(upsfd, UPS_PACE, "%s", "WH\x0D" ); + ret = ser_get_line(upsfd, buf, sizeof(buf), '\r', "", 3, 0); + ret = (ssize_t)strlen( buf ); + if( ret == 112 ) + { + if( DEBUG ) + printf( "WH found\n" ); + parseWH( buf ); + } + else if( ret == 53 ) + { + if( DEBUG ) + printf( "Old (broken) WH found\n" ); + parseOldWH( buf ); + } + else if( ret == 3 && strcmp(buf, "NAK") == 0 ) + { + if( DEBUG ) + printf( "WH was NAKed\n" ); + fakeWH( ); + } + else if( ret > 0 ) + { + if( DEBUG ) + printf( "WH says <%s> with length %zi\n", buf, ret ); + upslog_with_errno( LOG_INFO, + "New WH String found. Please report to maintainer\n" ); + } + return 1; +} /******************************************************************** * - * - * - * + * + * + * ********************************************************************/ void upsdrv_help( void ) { @@ -453,92 +447,92 @@ void upsdrv_help( void ) /******************************************************************** * * Function to initialize the fields of the ups driver. - * + * ********************************************************************/ void upsdrv_initinfo(void) { dstate_setinfo("ups.mfr", "MASTERGUARD"); dstate_setinfo("ups.model", "unknown"); - + /* dstate_addcmd("test.battery.stop"); dstate_addcmd("test.battery.start"); */ if( strlen( name ) > 0 ) - dstate_setinfo("ups.model", "%s", name); + dstate_setinfo("ups.model", "%s", name); if( strlen( firmware ) > 0 ) - dstate_setinfo("ups.firmware", "%s", firmware); + dstate_setinfo("ups.firmware", "%s", firmware); } /******************************************************************** * - * This is the main function. It gets called if the driver wants - * to update the ups status and the informations. - * + * This is the main function. It gets called if the driver wants + * to update the ups status and the information. + * ********************************************************************/ void upsdrv_updateinfo(void) { - char buf[255]; - int ret; - int lenRSP=0; + char buf[255]; + ssize_t ret; + int lenRSP=0; - if( DEBUG ) - printf( "update info\n" ); + if( DEBUG ) + printf( "update info\n" ); - /* Q3 found ? */ - if( type & Q3 ) - { - ser_send_pace(upsfd, UPS_PACE, "%s", "Q3\x0D" ); - lenRSP = 70; - } - /* Q1 found ? */ - else if( type & Q1 ) - { - ser_send_pace(upsfd, UPS_PACE, "%s", "Q1\x0D" ); - lenRSP = 46; - } - /* Should never be reached */ - else - { - fatalx(EXIT_FAILURE, "Error, no Query mode defined. Please file bug against driver."); - } + /* Q3 found ? */ + if( type & Q3 ) + { + ser_send_pace(upsfd, UPS_PACE, "%s", "Q3\x0D" ); + lenRSP = 70; + } + /* Q1 found ? */ + else if( type & Q1 ) + { + ser_send_pace(upsfd, UPS_PACE, "%s", "Q1\x0D" ); + lenRSP = 46; + } + /* Should never be reached */ + else + { + fatalx(EXIT_FAILURE, "Error, no Query mode defined. Please file bug against driver."); + } - sleep( UPSDELAY ); + sleep( UPSDELAY ); - buf[0] = '\0'; - ret = ser_get_line(upsfd, buf, sizeof(buf), '\r', "", 3, 0); - ret = strlen( buf ); + buf[0] = '\0'; + ret = ser_get_line(upsfd, buf, sizeof(buf), '\r', "", 3, 0); + ret = (ssize_t)strlen( buf ); - if( ret != lenRSP ) - { - if( DEBUG ) - printf( "buf = %s len = %i\n", buf, ret ); - upslog_with_errno( LOG_ERR, "Error in UPS response " ); - dstate_datastale(); - return; - } + if( ret != lenRSP ) + { + if( DEBUG ) + printf( "buf = %s len = %zi\n", buf, ret ); + upslog_with_errno( LOG_ERR, "Error in UPS response " ); + dstate_datastale(); + return; + } - /* Parse the response from the UPS */ - if( type & Q3 ) - { - query3( buf ); - dstate_dataok(); - return; - } - if( type & Q1 ) - { - query1( buf ); - dstate_dataok(); - return; - } + /* Parse the response from the UPS */ + if( type & Q3 ) + { + query3( buf ); + dstate_dataok(); + return; + } + if( type & Q1 ) + { + query1( buf ); + dstate_dataok(); + return; + } } /******************************************************************** * * Called if the driver wants to shutdown the UPS. * ( also used by the "-k" command line switch ) - * + * * This cuts the utility from the UPS after 20 seconds and restores * the utility one minute _after_ the utility to the UPS has restored * @@ -546,80 +540,79 @@ void upsdrv_updateinfo(void) void upsdrv_shutdown(void) { /* ups will come up within a minute if utility is restored */ - ser_send_pace(upsfd, UPS_PACE, "%s", "S.2R0001\x0D" ); + ser_send_pace(upsfd, UPS_PACE, "%s", "S.2R0001\x0D" ); } /******************************************************************** * * Populate the command line switches. - * + * * CS: Cancel the shutdown process - * + * ********************************************************************/ void upsdrv_makevartable(void) { - addvar( VAR_FLAG, "CS", "Cancel Shutdown" ); + addvar( VAR_FLAG, "CS", "Cancel Shutdown" ); } /******************************************************************** * * This is the first function called by the UPS driver. * Detects the UPS and handles the command line args. - * + * ********************************************************************/ void upsdrv_initups(void) { - int count = 0; - int fail = 0; - int good = 0; - - /* setup serial port */ - upsfd = ser_open(device_path); - ser_set_speed(upsfd, device_path, B2400); + int count = 0; + int fail = 0; + int good = 0; - name[0] = '\0'; - firmware[0] = '\0'; + upsdebugx(0, + "Please note that this driver is deprecated and will not receive\n" + "new development. If it works for managing your devices - fine,\n" + "but if you are running it to try setting up a new device, please\n" + "consider the newer nutdrv_qx instead, which should handle all 'Qx'\n" + "protocol variants for NUT. (Please also report if your device works\n" + "with this driver, but nutdrv_qx would not actually support it with\n" + "any subdriver!)\n"); + + /* setup serial port */ + upsfd = ser_open(device_path); + ser_set_speed(upsfd, device_path, B2400); + + name[0] = '\0'; + firmware[0] = '\0'; /* probe ups type */ - do - { - count++; + do + { + count++; - if( ups_ident( ) != 1 ) - fail++; - /* at least two good identifications */ - if( (count - fail) == 2 ) - { - good = 1; - break; - } - } while( (count=0 per check above */ +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) ) +/* Note for gating macros above: unsuffixed HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP + * means support of contexts both inside and outside function body, so the push + * above and pop below (outside this finction) are not used. + */ +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS +/* Note that the individual warning pragmas for use inside function bodies + * are named without a _INSIDEFUNC suffix, for simplicity and legacy reasons + */ +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE +# pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif + if (res < 7 || (unsigned long long int)res >= SIZE_MAX) +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) ) +# pragma GCC diagnostic pop +#endif + fatal_with_errno(EXIT_FAILURE, "Could not communicate with the ups"); + memcpy(serial, my_answer + 7, (size_t)(res - 7)); /* serial number start from the 8th byte */ - serial[12]=0; /* terminate string */ + serial[12]='\0'; /* terminate string */ dstate_setinfo("ups.serial", "%s", serial); - + /* get the ups firmware. The major number is in the 5th byte, the minor is in the 6th */ dstate_setinfo("ups.firmware", "%u.%u", my_answer[5], my_answer[6]); - printf("Detected %s [%s] v.%s on %s\n", dstate_getinfo("ups.model"), dstate_getinfo("ups.serial"), dstate_getinfo("ups.firmware"), device_path); - + printf("Detected %s [%s] v.%s on %s\n", + dstate_getinfo("ups.model"), dstate_getinfo("ups.serial"), + dstate_getinfo("ups.firmware"), device_path); + /* Add instant commands */ dstate_addcmd("shutdown.return"); dstate_addcmd("shutdown.stayoff"); @@ -563,17 +615,21 @@ void upsdrv_initinfo(void) upsh.instcmd = instcmd; return; } +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC) && (!defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_INSIDEFUNC) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC) ) +# pragma GCC diagnostic pop +#endif void upsdrv_updateinfo(void) { - int res, int_num; + int res; + uint16_t int_num; #ifdef EXTRADATA int day, hour, minute; #endif float float_num; - long int long_num; + uint32_t long_num; unsigned char my_answer[255]; - + /* GET Output data */ res = command_read_sequence(UPS_OUTPUT_DATA, my_answer); if (res < 0) { @@ -587,36 +643,36 @@ void upsdrv_updateinfo(void) dstate_setinfo("ups.load", "%2.1f", float_num); } else { dstate_setinfo("ups.load", "%s", "not available"); - } + } #ifdef EXTRADATA - dstate_setinfo("output.power", "%d", int_num); + dstate_setinfo("output.power", "%u", int_num); #endif /* voltage */ int_num = get_word(&my_answer[3]); - if (int_num > 0) dstate_setinfo("output.voltage", "%d", int_num); - if (int_num == -1) dstate_setinfo("output.voltage", "%s", "overrange"); - if (int_num == -2) dstate_setinfo("output.voltage", "%s", "not available"); + if ((int16_t)int_num > 0) dstate_setinfo("output.voltage", "%u", int_num); + if ((int16_t)int_num == -1) dstate_setinfo("output.voltage", "%s", "overrange"); + if ((int16_t)int_num == -2) dstate_setinfo("output.voltage", "%s", "not available"); /* current */ - float_num = get_word(&my_answer[5]); - if (float_num == -1) dstate_setinfo("output.current", "%s", "overrange"); - if (float_num == -2) dstate_setinfo("output.current", "%s", "not available"); + float_num = get_word_float(&my_answer[5]); + if (f_equal(float_num, -1.0)) dstate_setinfo("output.current", "%s", "overrange"); + if (f_equal(float_num, -2.0)) dstate_setinfo("output.current", "%s", "not available"); if (float_num > 0) { float_num = (float)(float_num/10); dstate_setinfo("output.current", "%2.2f", float_num); } #ifdef EXTRADATA /* peak current */ - float_num = get_word(&my_answer[7]); - if (float_num == -1) dstate_setinfo("output.current.peak", "%s", "overrange"); - if (float_num == -2) dstate_setinfo("output.current.peak", "%s", "not available"); + float_num = get_word_float(&my_answer[7]); + if (f_equal(float_num, -1.0)) dstate_setinfo("output.current.peak", "%s", "overrange"); + if (f_equal(float_num, -2.0)) dstate_setinfo("output.current.peak", "%s", "not available"); if (float_num > 0) { float_num = (float)(float_num/10); dstate_setinfo("output.current.peak", "%2.2f", float_num); } - + #endif } - + /* GET Input data */ res = command_read_sequence(UPS_INPUT_DATA, my_answer); if (res < 0){ @@ -626,18 +682,18 @@ void upsdrv_updateinfo(void) #ifdef EXTRADATA /* Active power */ int_num = get_word(&my_answer[1]); - if (int_num > 0) dstate_setinfo("input.power", "%d", int_num); - if (int_num == -1) dstate_setinfo("input.power", "%s", "overrange"); - if (int_num == -2) dstate_setinfo("input.power", "%s", "not available"); + if ((int16_t)int_num > 0) dstate_setinfo("input.power", "%u", int_num); + if ((int16_t)int_num == -1) dstate_setinfo("input.power", "%s", "overrange"); + if ((int16_t)int_num == -2) dstate_setinfo("input.power", "%s", "not available"); #endif /* voltage */ int_num = get_word(&my_answer[3]); - if (int_num > 0) dstate_setinfo("input.voltage", "%d", int_num); - if (int_num == -1) dstate_setinfo("input.voltage", "%s", "overrange"); - if (int_num == -2) dstate_setinfo("input.voltage", "%s", "not available"); + if ((int16_t)int_num > 0) dstate_setinfo("input.voltage", "%u", int_num); + if ((int16_t)int_num == -1) dstate_setinfo("input.voltage", "%s", "overrange"); + if ((int16_t)int_num == -2) dstate_setinfo("input.voltage", "%s", "not available"); #ifdef EXTRADATA /* current */ - float_num = get_word(&my_answer[5]); + float_num = get_word_float(&my_answer[5]); if (float_num == -1) dstate_setinfo("input.current", "%s", "overrange"); if (float_num == -2) dstate_setinfo("input.current", "%s", "not available"); if (float_num > 0) { @@ -645,7 +701,7 @@ void upsdrv_updateinfo(void) dstate_setinfo("input.current", "%2.2f", float_num); } /* peak current */ - float_num = get_word(&my_answer[7]); + float_num = get_word_float(&my_answer[7]); if (float_num == -1) dstate_setinfo("input.current.peak", "%s", "overrange"); if (float_num == -2) dstate_setinfo("input.current.peak", "%s", "not available"); if (float_num > 0) { @@ -654,8 +710,8 @@ void upsdrv_updateinfo(void) } #endif } - - + + /* GET Battery data */ res = command_read_sequence(UPS_BATTERY_DATA, my_answer); if (res < 0) { @@ -663,21 +719,21 @@ void upsdrv_updateinfo(void) dstate_datastale(); } else { /* Actual value */ - float_num = get_word(&my_answer[1]); + float_num = get_word_float(&my_answer[1]); float_num = (float)(float_num/10); dstate_setinfo("battery.voltage", "%2.2f", float_num); #ifdef EXTRADATA /* reserve threshold */ - float_num = get_word(&my_answer[3]); + float_num = get_word_float(&my_answer[3]); float_num = (float)(float_num/10); dstate_setinfo("battery.voltage.low", "%2.2f", float_num); /* exhaust threshold */ - float_num = get_word(&my_answer[5]); + float_num = get_word_float(&my_answer[5]); float_num = (float)(float_num/10); dstate_setinfo("battery.voltage.exhaust", "%2.2f", float_num); #endif } - + #ifdef EXTRADATA /* GET history data */ res = command_read_sequence(UPS_HISTORY_DATA, my_answer); @@ -693,8 +749,8 @@ void upsdrv_updateinfo(void) long_num -= (long)(hour*3600); minute = (int)(long_num / 60); long_num -= (minute*60); - dstate_setinfo("ups.total.runtime", "%d days %dh %dm %lds", day, hour, minute, long_num); - + dstate_setinfo("ups.total.runtime", "%d days %dh %dm %lus", day, hour, minute, long_num); + /* ups inverter runtime */ long_num = get_long(&my_answer[5]); day = (int)(long_num / 86400); @@ -703,22 +759,22 @@ void upsdrv_updateinfo(void) long_num -= (long)(hour*3600); minute = (int)(long_num / 60); long_num -= (minute*60); - dstate_setinfo("ups.inverter.runtime", "%d days %dh %dm %lds", day, hour, minute, long_num); + dstate_setinfo("ups.inverter.runtime", "%d days %dh %dm %lus", day, hour, minute, long_num); /* ups inverter interventions */ - dstate_setinfo("ups.inverter.interventions", "%d", get_word(&my_answer[9])); + dstate_setinfo("ups.inverter.interventions", "%u", get_word(&my_answer[9])); /* battery full discharges */ - dstate_setinfo("battery.full.discharges", "%d", get_word(&my_answer[11])); + dstate_setinfo("battery.full.discharges", "%u", get_word(&my_answer[11])); /* ups bypass / stabilizer interventions */ int_num = get_word(&my_answer[13]); - if (int_num == -2) dstate_setinfo("ups.bypass.interventions", "%s", "not avaliable"); - if (int_num >= 0) dstate_setinfo("ups.bypass.interventions", "%d", int_num); + if ((int16_t)int_num == -2) dstate_setinfo("ups.bypass.interventions", "%s", "not avaliable"); + if ((int16_t)int_num >= 0) dstate_setinfo("ups.bypass.interventions", "%u", int_num); /* ups overheatings */ int_num = get_word(&my_answer[15]); - if (int_num == -2) dstate_setinfo("ups.overheatings", "%s", "not avalilable"); - if (int_num >= 0) dstate_setinfo("ups.overheatings", "%d", int_num); + if ((int16_t)int_num == -2) dstate_setinfo("ups.overheatings", "%s", "not avalilable"); + if ((int16_t)int_num >= 0) dstate_setinfo("ups.overheatings", "%u", int_num); } #endif - + /* GET times on battery */ res = command_read_sequence(UPS_GET_TIMES_ON_BATTERY, my_answer); if (res < 0) { @@ -727,8 +783,8 @@ void upsdrv_updateinfo(void) } else { autorestart = my_answer[5]; } - - + + /* GET schedule */ res = command_read_sequence(UPS_GET_SCHEDULING, my_answer); if (res < 0) { @@ -737,21 +793,21 @@ void upsdrv_updateinfo(void) } else { /* time remaining to shutdown */ long_num = get_long(&my_answer[1]); - if (long_num == -1) { - dstate_setinfo("ups.delay.shutdown", "%d", 120); + if ((int32_t)long_num == -1) { + dstate_setinfo("ups.delay.shutdown", "%d", 120); } else { - dstate_setinfo("ups.delay.shutdown", "%ld", long_num); + dstate_setinfo("ups.delay.shutdown", "%lu", (unsigned long)long_num); } /* time remaining to restart */ long_num = get_long(&my_answer[5]); - if (long_num == -1) { - dstate_setinfo("ups.delay.start", "%d", 0); + if ((int32_t)long_num == -1) { + dstate_setinfo("ups.delay.start", "%d", 0); } else { - dstate_setinfo("ups.delay.start", "%ld", long_num); - } + dstate_setinfo("ups.delay.start", "%lu", (unsigned long)long_num); + } } - - + + /* GET ups status */ res = command_read_sequence(UPS_STATUS, my_answer); if (res < 0) { @@ -764,7 +820,7 @@ void upsdrv_updateinfo(void) dstate_setinfo("ups.temperature", "%d", my_answer[3]); } else { dstate_setinfo("ups.temperature", "%s", "not available"); - } + } /* Status */ status_init(); switch (my_answer[1]) { /* byte 1 = STATUS */ @@ -784,7 +840,7 @@ void upsdrv_updateinfo(void) default: printf("status unknown \n"); break; - } + } switch (my_answer[2]) { /* byte 2 = FAULTS */ case 0x00: /* all right */ break; @@ -815,22 +871,22 @@ void upsdrv_shutdown(void) unsigned char command[10], answer[10]; /* Ensure that the ups is configured for automatically - restart after a complete battery discharge + restart after a complete battery discharge and when the power comes back after a shutdown */ if (! autorestart) { command[0]=UPS_SET_TIMES_ON_BATTERY; - command[1]=0x00; /* max time on */ + command[1]=0x00; /* max time on */ command[2]=0x00; /* battery */ - + command[3]=0x00; /* max time after */ command[4]=0x00; /* battery reserve */ - + command[5]=0x01; /* autorestart after battery depleted enabled */ command_write_sequence(command, 6, answer); } /* shedule a shutdown in 120 seconds */ - command[0]=UPS_SET_SCHEDULING; + command[0]=UPS_SET_SCHEDULING; command[1]=0x96; /* remaining */ command[2]=0x00; /* time */ command[3]=0x00; /* to */ @@ -876,7 +932,7 @@ static int instcmd(const char *cmdname, const char *extra) /* Same stuff as upsdrv_shutdown() */ if (! autorestart) { command[0]=UPS_SET_TIMES_ON_BATTERY; - command[1]=0x00; /* max time on */ + command[1]=0x00; /* max time on */ command[2]=0x00; /* battery */ command[3]=0x00; /* max time after */ command[4]=0x00; /* battery reserve */ @@ -884,7 +940,7 @@ static int instcmd(const char *cmdname, const char *extra) command_write_sequence(command, 6, answer); } /* shedule a shutdown in 30 seconds */ - command[0]=UPS_SET_SCHEDULING; + command[0]=UPS_SET_SCHEDULING; command[1]=0x1e; /* remaining */ command[2]=0x00; /* time */ command[3]=0x00; /* to */ @@ -900,12 +956,12 @@ static int instcmd(const char *cmdname, const char *extra) if (!strcasecmp(cmdname, "shutdown.stayoff")) { /* shedule a shutdown in 30 seconds with no restart (-1) */ - command[0]=UPS_SET_SCHEDULING; + command[0]=UPS_SET_SCHEDULING; command[1]=0x1e; /* remaining */ command[2]=0x00; /* time */ command[3]=0x00; /* to */ command[4]=0x00; /* shutdown 150 secs */ - + command[5]=0xff; /* programmed */ command[6]=0xff; /* time */ command[7]=0xff; /* to */ @@ -916,12 +972,12 @@ static int instcmd(const char *cmdname, const char *extra) if (!strcasecmp(cmdname, "shutdown.stop")) { /* set shutdown and restart time to -1 (no shutdown, no restart) */ - command[0]=UPS_SET_SCHEDULING; + command[0]=UPS_SET_SCHEDULING; command[1]=0xff; /* remaining */ command[2]=0xff; /* time */ command[3]=0xff; /* to */ command[4]=0xff; /* shutdown -1 (no shutdown) */ - + command[5]=0xff; /* programmed */ command[6]=0xff; /* time */ command[7]=0xff; /* to */ @@ -932,8 +988,8 @@ static int instcmd(const char *cmdname, const char *extra) if (!strcasecmp(cmdname, "test.failure.start")) { /* force ups on battery power */ - command[0]=UPS_SET_BATTERY_TEST; - command[1]=0x01; + command[0]=UPS_SET_BATTERY_TEST; + command[1]=0x01; /* 0 = perform battery test 1 = force UPS on battery power 2 = restore standard mode (mains power) */ @@ -944,7 +1000,7 @@ static int instcmd(const char *cmdname, const char *extra) if (!strcasecmp(cmdname, "test.failure.stop")) { /* restore standard mode (mains power) */ command[0]=UPS_SET_BATTERY_TEST; - command[1]=0x02; + command[1]=0x02; /* 0 = perform battery test 1 = force UPS on battery power 2 = restore standard mode (mains power) */ @@ -954,8 +1010,8 @@ static int instcmd(const char *cmdname, const char *extra) if (!strcasecmp(cmdname, "test.battery.start")) { /* launch battery test */ - command[0]=UPS_SET_BATTERY_TEST; - command[1]=0x00; + command[0]=UPS_SET_BATTERY_TEST; + command[1]=0x00; /* 0 = perform battery test 1 = force UPS on battery power 2 = restore standard mode (mains power) */ @@ -966,22 +1022,22 @@ static int instcmd(const char *cmdname, const char *extra) case 0x00: /* all right */ dstate_setinfo("ups.test.result", "OK"); break; - case 0x01: + case 0x01: dstate_setinfo("ups.test.result", "Battery charge: 20%%"); break; - case 0x02: + case 0x02: dstate_setinfo("ups.test.result", "Battery charge: 40%%"); break; - case 0x03: + case 0x03: dstate_setinfo("ups.test.result", "Battery charge: 60%%"); break; - case 0x04: + case 0x04: dstate_setinfo("ups.test.result", "Battery charge: 80%%"); break; - case 0x05: + case 0x05: dstate_setinfo("ups.test.result", "Battery charge: 100%%"); break; - case 0xfe: + case 0xfe: dstate_setinfo("ups.test.result", "Bad battery pack: replace"); break; default: @@ -996,8 +1052,8 @@ static int instcmd(const char *cmdname, const char *extra) if (!strcasecmp(cmdname, "beeper.enable")) { /* set buzzer to not muted */ - command[0]=UPS_SET_BUZZER_MUTE; - command[1]=0x00; + command[0]=UPS_SET_BUZZER_MUTE; + command[1]=0x00; /* 0 = not muted 1 = muted 2 = read current status */ @@ -1007,8 +1063,8 @@ static int instcmd(const char *cmdname, const char *extra) if (!strcasecmp(cmdname, "beeper.mute")) { /* set buzzer to muted */ - command[0]=UPS_SET_BUZZER_MUTE; - command[1]=0x01; + command[0]=UPS_SET_BUZZER_MUTE; + command[1]=0x01; /* 0 = not muted 1 = muted 2 = read current status */ @@ -1016,7 +1072,7 @@ static int instcmd(const char *cmdname, const char *extra) return STAT_INSTCMD_HANDLED; } - upslogx(LOG_NOTICE, "instcmd: unknown command [%s]", cmdname); + upslogx(LOG_NOTICE, "instcmd: unknown command [%s] [%s]", cmdname, extra); return STAT_INSTCMD_UNKNOWN; } @@ -1038,12 +1094,12 @@ void upsdrv_makevartable(void) void upsdrv_initups(void) { - upsfd = ser_open(device_path); - ser_set_speed(upsfd, device_path, B2400); + upsfd = ser_open(device_path); + ser_set_speed(upsfd, device_path, B2400); send_zeros(); } void upsdrv_cleanup(void) { - ser_close(upsfd, device_path); + ser_close(upsfd, device_path); } diff --git a/drivers/mge-hid.c b/drivers/mge-hid.c index a3f10af..55d56cf 100644 --- a/drivers/mge-hid.c +++ b/drivers/mge-hid.c @@ -2,7 +2,7 @@ * * Copyright (C) * 2003 - 2015 Arnaud Quette - * 2015 Arnaud Quette + * 2015 - 2016 Eaton / Arnaud Quette * * Sponsored by MGE UPS SYSTEMS * @@ -36,8 +36,9 @@ #include "main.h" /* for getval() */ #include "usbhid-ups.h" #include "mge-hid.h" +#include "nut_float.h" -#define MGE_HID_VERSION "MGE HID 1.39" +#define MGE_HID_VERSION "MGE HID 1.46" /* (prev. MGE Office Protection Systems, prev. MGE UPS SYSTEMS) */ /* Eaton */ @@ -55,6 +56,14 @@ /* AEG */ #define AEG_VENDORID 0x2b2d +/* Note that normally this VID is handled by Liebert/Phoenixtec HID mapping, + * here it is just for for AEG PROTECT NAS devices: */ +/* Phoenixtec Power Co., Ltd */ +#define PHOENIXTEC 0x06da + +/* IBM */ +#define IBM_VENDORID 0x04b3 + #ifndef SHUT_MODE #include "usb-common.h" @@ -80,9 +89,13 @@ static usb_device_id_t mge_usb_device_table[] = { /* PROTECT B / NAS */ { USB_DEVICE(AEG_VENDORID, 0xffff), NULL }, + { USB_DEVICE(PHOENIXTEC, 0xffff), NULL }, + + /* 6000 VA LCD 4U Rack UPS; 5396-1Kx */ + { USB_DEVICE(IBM_VENDORID, 0x0001), NULL }, /* Terminating entry */ - { -1, -1, NULL } + { 0, 0, NULL } }; #endif @@ -110,7 +123,7 @@ typedef enum { } models_type_t; /* Default to line-interactive or online (ie, not offline). - * This is then overriden for offline, through mge_model_names */ + * This is then overridden for offline, through mge_model_names */ static models_type_t mge_type = MGE_DEFAULT; /* Countries definition, for region specific settings and features */ @@ -149,10 +162,10 @@ static char mge_scratch_buf[20]; * annunciate float mode until the charger power starts falling from the maximum * level indicating the battery is truly at the float voltage or in float mode. * The %charge level is based on battery voltage and the charge mode timer - * (should be 48 hours) and some UPSs add in a value that’s related to charger + * (should be 48 hours) and some UPSs add in a value that's related to charger * power output. So you can have UPS that enters float mode with anywhere * from 80% or greater battery capacity. - * float mode is not important from the software’s perspective, it’s there to + * float mode is not important from the software's perspective, it's there to * help determine if the charger is advancing correctly. * So in float mode, the charger is charging the battery, so by definition you * can assert the CHRG flag in NUT when in “float” mode or “charge” mode. @@ -184,8 +197,8 @@ static const char *eaton_abm_enabled_fun(double value) } static info_lkp_t eaton_abm_enabled_info[] = { - { 0, "dummy", eaton_abm_enabled_fun }, - { 0, NULL, NULL } + { 0, "dummy", eaton_abm_enabled_fun, NULL }, + { 0, NULL, NULL, NULL } }; /* Note 1: This point will need more clarification! */ @@ -202,8 +215,8 @@ static const char *eaton_abm_enabled_legacy_fun(double value) } static info_lkp_t eaton_abm_enabled_legacy_info[] = { - { 0, "dummy", eaton_abm_enabled_legacy_fun }, - { 0, NULL, NULL } + { 0, "dummy", eaton_abm_enabled_legacy_fun, NULL }, + { 0, NULL, NULL, NULL } }; #endif /* if 0 */ @@ -249,8 +262,8 @@ static const char *eaton_abm_status_fun(double value) } static info_lkp_t eaton_abm_status_info[] = { - { 1, "dummy", eaton_abm_status_fun }, - { 0, NULL, NULL } + { 1, "dummy", eaton_abm_status_fun, NULL }, + { 0, NULL, NULL, NULL } }; /* Used to process ABM flags, for ups.status (CHRG/DISCHRG/RB) */ @@ -283,8 +296,8 @@ static const char *eaton_abm_chrg_dischrg_fun(double value) } static info_lkp_t eaton_abm_chrg_dischrg_info[] = { - { 1, "dummy", eaton_abm_chrg_dischrg_fun }, - { 0, NULL, NULL } + { 1, "dummy", eaton_abm_chrg_dischrg_fun, NULL }, + { 0, NULL, NULL, NULL } }; /* ABM also implies that standard CHRG/DISCHRG are processed according @@ -297,7 +310,7 @@ static const char *eaton_abm_check_dischrg_fun(double value) { if (advanced_battery_monitoring == ABM_DISABLED) { - if (value == 1) { + if (d_equal(value, 1)) { snprintf(mge_scratch_buf, sizeof(mge_scratch_buf), "%s", "dischrg"); } else { @@ -315,15 +328,15 @@ static const char *eaton_abm_check_dischrg_fun(double value) } static info_lkp_t eaton_discharging_info[] = { - { 1, "dummy", eaton_abm_check_dischrg_fun }, - { 0, NULL, NULL } + { 1, "dummy", eaton_abm_check_dischrg_fun, NULL }, + { 0, NULL, NULL, NULL } }; static const char *eaton_abm_check_chrg_fun(double value) { if (advanced_battery_monitoring == ABM_DISABLED) { - if (value == 1) { + if (d_equal(value, 1)) { snprintf(mge_scratch_buf, sizeof(mge_scratch_buf), "%s", "chrg"); } else { @@ -341,8 +354,8 @@ static const char *eaton_abm_check_chrg_fun(double value) } static info_lkp_t eaton_charging_info[] = { - { 1, "dummy", eaton_abm_check_chrg_fun }, - { 0, NULL, NULL } + { 1, "dummy", eaton_abm_check_chrg_fun, NULL }, + { 0, NULL, NULL, NULL } }; /* The HID path 'UPS.PowerSummary.Time' reports Unix time (ie the number of @@ -351,8 +364,9 @@ static info_lkp_t eaton_charging_info[] = { static const char *mge_date_conversion_fun(double value) { time_t sec = value; + struct tm tmbuf; - if (strftime(mge_scratch_buf, sizeof(mge_scratch_buf), "%Y/%m/%d", localtime(&sec)) == 10) { + if (strftime(mge_scratch_buf, sizeof(mge_scratch_buf), "%Y/%m/%d", localtime_r(&sec, &tmbuf)) == 10) { return mge_scratch_buf; } @@ -363,8 +377,9 @@ static const char *mge_date_conversion_fun(double value) static const char *mge_time_conversion_fun(double value) { time_t sec = value; + struct tm tmbuf; - if (strftime(mge_scratch_buf, sizeof(mge_scratch_buf), "%H:%M:%S", localtime(&sec)) == 8) { + if (strftime(mge_scratch_buf, sizeof(mge_scratch_buf), "%H:%M:%S", localtime_r(&sec, &tmbuf)) == 8) { return mge_scratch_buf; } @@ -406,19 +421,23 @@ static double mge_time_conversion_nuf(const char *value) } static info_lkp_t mge_date_conversion[] = { - { 0, NULL, mge_date_conversion_fun, mge_date_conversion_nuf } + { 0, NULL, mge_date_conversion_fun, mge_date_conversion_nuf }, + { 0, NULL, NULL, NULL } }; static info_lkp_t mge_time_conversion[] = { - { 0, NULL, mge_time_conversion_fun, mge_time_conversion_nuf } + { 0, NULL, mge_time_conversion_fun, mge_time_conversion_nuf }, + { 0, NULL, NULL, NULL } }; #else static info_lkp_t mge_date_conversion[] = { - { 0, NULL, mge_date_conversion_fun, NULL } + { 0, NULL, mge_date_conversion_fun, NULL }, + { 0, NULL, NULL, NULL } }; static info_lkp_t mge_time_conversion[] = { - { 0, NULL, mge_time_conversion_fun, NULL } + { 0, NULL, mge_time_conversion_fun, NULL }, + { 0, NULL, NULL, NULL } }; #endif /* HAVE_STRPTIME */ @@ -448,7 +467,8 @@ static const char *mge_battery_voltage_nominal_fun(double value) } static info_lkp_t mge_battery_voltage_nominal[] = { - { 0, NULL, mge_battery_voltage_nominal_fun } + { 0, NULL, mge_battery_voltage_nominal_fun, NULL }, + { 0, NULL, NULL, NULL } }; /* The HID path 'UPS.PowerSummary.Voltage' only reports @@ -472,7 +492,8 @@ static const char *mge_battery_voltage_fun(double value) } static info_lkp_t mge_battery_voltage[] = { - { 0, NULL, mge_battery_voltage_fun } + { 0, NULL, mge_battery_voltage_fun, NULL }, + { 0, NULL, NULL, NULL } }; static const char *mge_powerfactor_conversion_fun(double value) @@ -482,7 +503,8 @@ static const char *mge_powerfactor_conversion_fun(double value) } static info_lkp_t mge_powerfactor_conversion[] = { - { 0, NULL, mge_powerfactor_conversion_fun } + { 0, NULL, mge_powerfactor_conversion_fun, NULL }, + { 0, NULL, NULL, NULL } }; static const char *mge_battery_capacity_fun(double value) @@ -492,65 +514,66 @@ static const char *mge_battery_capacity_fun(double value) } static info_lkp_t mge_battery_capacity[] = { - { 0, NULL, mge_battery_capacity_fun } + { 0, NULL, mge_battery_capacity_fun, NULL }, + { 0, NULL, NULL, NULL } }; -info_lkp_t eaton_enable_disable_info[] = { - { 0, "disabled", NULL }, - { 1, "enabled", NULL }, - { 0, NULL, NULL } +static info_lkp_t eaton_enable_disable_info[] = { + { 0, "disabled", NULL, NULL }, + { 1, "enabled", NULL, NULL }, + { 0, NULL, NULL, NULL } }; static info_lkp_t mge_upstype_conversion[] = { - { 1, "offline / line interactive", NULL }, - { 2, "online", NULL }, - { 3, "online - unitary/parallel", NULL }, - { 4, "online - parallel with hot standy", NULL }, - { 5, "online - hot standby redundancy", NULL }, - { 0, NULL, NULL } + { 1, "offline / line interactive", NULL, NULL }, + { 2, "online", NULL, NULL }, + { 3, "online - unitary/parallel", NULL, NULL }, + { 4, "online - parallel with hot standy", NULL, NULL }, + { 5, "online - hot standby redundancy", NULL, NULL }, + { 0, NULL, NULL, NULL } }; static info_lkp_t mge_sensitivity_info[] = { - { 0, "normal", NULL }, - { 1, "high", NULL }, - { 2, "low", NULL }, - { 0, NULL, NULL } + { 0, "normal", NULL, NULL }, + { 1, "high", NULL, NULL }, + { 2, "low", NULL, NULL }, + { 0, NULL, NULL, NULL } }; static info_lkp_t mge_emergency_stop[] = { - { 1, "Emergency stop!", NULL }, - { 0, NULL, NULL } + { 1, "Emergency stop!", NULL, NULL }, + { 0, NULL, NULL, NULL } }; static info_lkp_t mge_wiring_fault[] = { - { 1, "Wiring fault!", NULL }, - { 0, NULL, NULL } + { 1, "Wiring fault!", NULL, NULL }, + { 0, NULL, NULL, NULL } }; static info_lkp_t mge_config_failure[] = { - { 1, "Fatal EEPROM fault!", NULL }, - { 0, NULL, NULL } + { 1, "Fatal EEPROM fault!", NULL, NULL }, + { 0, NULL, NULL, NULL } }; static info_lkp_t mge_inverter_volthi[] = { - { 1, "Inverter AC voltage too high!", NULL }, - { 0, NULL, NULL } + { 1, "Inverter AC voltage too high!", NULL, NULL }, + { 0, NULL, NULL, NULL } }; static info_lkp_t mge_inverter_voltlo[] = { - { 1, "Inverter AC voltage too low!", NULL }, - { 0, NULL, NULL } + { 1, "Inverter AC voltage too low!", NULL, NULL }, + { 0, NULL, NULL, NULL } }; static info_lkp_t mge_short_circuit[] = { - { 1, "Output short circuit!", NULL }, - { 0, NULL, NULL } + { 1, "Output short circuit!", NULL, NULL }, + { 0, NULL, NULL, NULL } }; -info_lkp_t mge_onbatt_info[] = { - { 1, "!online", NULL }, - { 0, "online", NULL }, - { 0, NULL, NULL } +static info_lkp_t mge_onbatt_info[] = { + { 1, "!online", NULL, NULL }, + { 0, "online", NULL, NULL }, + { 0, NULL, NULL, NULL } }; /* allow limiting to ups.model = Protection Station, Ellipse Eco @@ -565,6 +588,7 @@ static const char *eaton_check_pegasus_fun(double value) /* Only consider non European models */ if (country_code != COUNTRY_EUROPE) break; + return NULL; default: return NULL; } @@ -574,10 +598,10 @@ static const char *eaton_check_pegasus_fun(double value) } static info_lkp_t pegasus_threshold_info[] = { - { 10, "10", eaton_check_pegasus_fun }, - { 25, "25", eaton_check_pegasus_fun }, - { 60, "60", eaton_check_pegasus_fun }, - { 0, NULL, NULL } + { 10, "10", eaton_check_pegasus_fun, NULL }, + { 25, "25", eaton_check_pegasus_fun, NULL }, + { 60, "60", eaton_check_pegasus_fun, NULL }, + { 0, NULL, NULL, NULL } }; /* allow limiting standard yes/no info (here, to enable ECO mode) to @@ -593,11 +617,12 @@ static const char *pegasus_yes_no_info_fun(double value) /* Only consider non European models */ if (country_code != COUNTRY_EUROPE) break; + return NULL; default: return NULL; } - return (value == 0) ? "no" : "yes"; + return (d_equal(value, 0)) ? "no" : "yes"; } /* Conversion back of yes/no info */ @@ -611,6 +636,7 @@ static double pegasus_yes_no_info_nuf(const char *value) /* Only consider non European models */ if (country_code != COUNTRY_EUROPE) break; + return 0; default: return 0; } @@ -621,10 +647,10 @@ static double pegasus_yes_no_info_nuf(const char *value) return 0; } -info_lkp_t pegasus_yes_no_info[] = { +static info_lkp_t pegasus_yes_no_info[] = { { 0, "no", pegasus_yes_no_info_fun, pegasus_yes_no_info_nuf }, { 1, "yes", pegasus_yes_no_info_fun, pegasus_yes_no_info_nuf }, - { 0, NULL, NULL } + { 0, NULL, NULL, NULL } }; /* Determine country using UPS.PowerSummary.Country. @@ -639,8 +665,42 @@ static const char *eaton_check_country_fun(double value) } static info_lkp_t eaton_check_country_info[] = { - { 0, "dummy", eaton_check_country_fun }, - { 0, NULL, NULL } + { 0, "dummy", eaton_check_country_fun, NULL }, + { 0, NULL, NULL, NULL } +}; + +/* When UPS.PowerConverter.Output.ActivePower is not present, + * compute a realpower approximation using available data */ +static const char *eaton_compute_realpower_fun(double value) +{ + NUT_UNUSED_VARIABLE(value); + const char *str_ups_load = dstate_getinfo("ups.load"); + const char *str_power_nominal = dstate_getinfo("ups.power.nominal"); + const char *str_powerfactor = dstate_getinfo("output.powerfactor"); + float powerfactor = 0.80; + int power_nominal = 0; + int ups_load = 0; + double realpower = 0; + if (str_power_nominal && str_ups_load) { + /* Extract needed values */ + ups_load = atoi(str_ups_load); + power_nominal = atoi(str_power_nominal); + if (str_powerfactor) + powerfactor = atoi(str_powerfactor); + /* Compute the value */ + realpower = round(ups_load * 0.01 * power_nominal * powerfactor); + snprintf(mge_scratch_buf, sizeof(mge_scratch_buf), "%.0f", realpower); + upsdebugx(1, "eaton_compute_realpower_fun(%s)", mge_scratch_buf); + return mge_scratch_buf; + } + /* else can't process */ + /* Return NULL, not to get the value published! */ + return NULL; +} + +static info_lkp_t eaton_compute_realpower_info[] = { + { 0, "dummy", eaton_compute_realpower_fun, NULL }, + { 0, NULL, NULL, NULL } }; /* Limit nominal output voltage according to HV or LV models */ @@ -687,6 +747,7 @@ static const char *nominal_output_voltage_fun(double value) case 240: if ((mge_type & 0xFF00) >= MGE_DEFAULT) break; + return NULL; default: return NULL; } @@ -709,10 +770,15 @@ static const char *nominal_output_voltage_fun(double value) * support both HV values */ if (country_code == COUNTRY_EUROPE_208) break; + /* explicit fallthrough: */ + goto fallthrough_value; + case 220: case 230: case 240: + fallthrough_value: break; + default: return NULL; } @@ -730,19 +796,35 @@ static info_lkp_t nominal_output_voltage_info[] = { /* line-interactive, starting with Evolution, support both HV values */ /* HV models */ /* 208V */ - { 200, "200", nominal_output_voltage_fun }, - { 208, "208", nominal_output_voltage_fun }, + { 200, "200", nominal_output_voltage_fun, NULL }, + { 208, "208", nominal_output_voltage_fun, NULL }, /* HV models */ /* 230V */ - { 220, "220", nominal_output_voltage_fun }, - { 230, "230", nominal_output_voltage_fun }, - { 240, "240", nominal_output_voltage_fun }, + { 220, "220", nominal_output_voltage_fun, NULL }, + { 230, "230", nominal_output_voltage_fun, NULL }, + { 240, "240", nominal_output_voltage_fun, NULL }, /* LV models */ - { 100, "100", nominal_output_voltage_fun }, - { 110, "110", nominal_output_voltage_fun }, - { 120, "120", nominal_output_voltage_fun }, - { 127, "127", nominal_output_voltage_fun }, - { 0, NULL, NULL } + { 100, "100", nominal_output_voltage_fun, NULL }, + { 110, "110", nominal_output_voltage_fun, NULL }, + { 120, "120", nominal_output_voltage_fun, NULL }, + { 127, "127", nominal_output_voltage_fun, NULL }, + { 0, NULL, NULL, NULL } +}; + +/* Limit reporting "online / !online" to when "!off" */ +static const char *eaton_converter_online_fun(double value) +{ + unsigned ups_status = ups_status_get(); + + if (ups_status & STATUS(OFF)) + return NULL; + else + return (d_equal(value, 0)) ? "!online" : "online"; +} + +static info_lkp_t eaton_converter_online_info[] = { + { 0, "dummy", eaton_converter_online_fun, NULL }, + { 0, NULL, NULL, NULL } }; /* --------------------------------------------------------------- */ @@ -1006,7 +1088,7 @@ static models_name_t mge_model_names [] = { "Eaton 5P", "850", EATON_5P, "5P 850" }, { "Eaton 5P", "1150", EATON_5P, "5P 1150" }, { "Eaton 5P", "1550", EATON_5P, "5P 1550" }, - + /* Pulsar M models */ { "PULSAR M", "2200", MGE_PULSAR_M_2200, NULL }, { "PULSAR M", "3000", MGE_PULSAR_M_3000, NULL }, @@ -1072,7 +1154,7 @@ static models_name_t mge_model_names [] = { "GALAXY", "3000_30", MGE_DEFAULT, "Galaxy 3000 30 kVA" }, /* end of structure. */ - { NULL } + { NULL, NULL, 0, NULL } }; @@ -1132,6 +1214,9 @@ static hid_info_t mge_hid2nut[] = { "ups.timer.reboot", 0, 0, "UPS.PowerSummary.DelayBeforeReboot", NULL, "%.0f", HU_FLAG_QUICK_POLL, NULL}, { "ups.test.result", 0, 0, "UPS.BatterySystem.Battery.Test", NULL, "%s", 0, test_read_info }, { "ups.test.interval", ST_FLAG_RW | ST_FLAG_STRING, 8, "UPS.BatterySystem.Battery.TestPeriod", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + /* Duplicate data for some units (such as 3S) that use a different path + * Only the first valid one will be used */ + { "ups.beeper.status", 0 ,0, "UPS.BatterySystem.Battery.AudibleAlarmControl", NULL, "%s", HU_FLAG_SEMI_STATIC, beeper_info }, { "ups.beeper.status", 0 ,0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "%s", HU_FLAG_SEMI_STATIC, beeper_info }, { "ups.temperature", 0, 0, "UPS.PowerSummary.Temperature", NULL, "%s", 0, kelvin_celsius_conversion }, { "ups.power", 0, 0, "UPS.PowerConverter.Output.ApparentPower", NULL, "%.0f", 0, NULL }, @@ -1140,6 +1225,9 @@ static hid_info_t mge_hid2nut[] = { "ups.L3.power", 0, 0, "UPS.PowerConverter.Output.Phase.[3].ApparentPower", NULL, "%.0f", 0, NULL }, { "ups.power.nominal", 0, 0, "UPS.Flow.[4].ConfigApparentPower", NULL, "%.0f", HU_FLAG_STATIC, NULL }, { "ups.realpower", 0, 0, "UPS.PowerConverter.Output.ActivePower", NULL, "%.0f", 0, NULL }, + /* When not available, process an approximation from other data, + * but map to apparent power to be called */ + { "ups.realpower", 0, 0, "UPS.Flow.[4].ConfigApparentPower", NULL, "-1", 0, eaton_compute_realpower_info }, { "ups.L1.realpower", 0, 0, "UPS.PowerConverter.Output.Phase.[1].ActivePower", NULL, "%.0f", 0, NULL }, { "ups.L2.realpower", 0, 0, "UPS.PowerConverter.Output.Phase.[2].ActivePower", NULL, "%.0f", 0, NULL }, { "ups.L3.realpower", 0, 0, "UPS.PowerConverter.Output.Phase.[3].ActivePower", NULL, "%.0f", 0, NULL }, @@ -1160,7 +1248,6 @@ static hid_info_t mge_hid2nut[] = /* Special case: boolean values that are mapped to ups.status and ups.alarm */ { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, online_info }, { "BOOL", 0, 0, "UPS.PowerConverter.Input.[3].PresentStatus.Used", NULL, NULL, 0, mge_onbatt_info }, - { "BOOL", 0, 0, "UPS.PowerConverter.Input.[1].PresentStatus.Used", NULL, NULL, 0, online_info }, /* These 2 ones are used when ABM is disabled */ { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, eaton_discharging_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, eaton_charging_info }, @@ -1182,6 +1269,9 @@ static hid_info_t mge_hid2nut[] = { "BOOL", 0, 0, "UPS.PowerConverter.Input.[1].PresentStatus.VoltageOutOfRange", NULL, NULL, 0, vrange_info }, { "BOOL", 0, 0, "UPS.PowerConverter.Input.[1].PresentStatus.FrequencyOutOfRange", NULL, NULL, 0, frange_info }, { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Good", NULL, NULL, 0, off_info }, + /* NOTE: UPS.PowerConverter.Input.[1].PresentStatus.Used" must only be considered when not "OFF", + * and must hence be after "UPS.PowerSummary.PresentStatus.Good" */ + { "BOOL", 0, 0, "UPS.PowerConverter.Input.[1].PresentStatus.Used", NULL, NULL, 0, eaton_converter_online_info }, { "BOOL", 0, 0, "UPS.PowerConverter.Input.[2].PresentStatus.Used", NULL, NULL, 0, bypass_auto_info }, /* Automatic bypass */ { "BOOL", 0, 0, "UPS.PowerConverter.Input.[4].PresentStatus.Used", NULL, NULL, 0, bypass_manual_info }, /* Manual bypass */ { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.FanFailure", NULL, NULL, 0, fanfail_info }, @@ -1328,8 +1418,13 @@ static hid_info_t mge_hid2nut[] = { "shutdown.reboot", 0, 0, "UPS.PowerSummary.DelayBeforeReboot", NULL, "10", HU_TYPE_CMD, NULL}, { "beeper.off", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "1", HU_TYPE_CMD, NULL }, { "beeper.on", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "2", HU_TYPE_CMD, NULL }, + /* Duplicate commands for some units (such as 3S) that use a different path + * Only the first valid one will be used */ + { "beeper.mute", 0, 0, "UPS.BatterySystem.Battery.AudibleAlarmControl", NULL, "3", HU_TYPE_CMD, NULL }, { "beeper.mute", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "3", HU_TYPE_CMD, NULL }, + { "beeper.disable", 0, 0, "UPS.BatterySystem.Battery.AudibleAlarmControl", NULL, "1", HU_TYPE_CMD, NULL }, { "beeper.disable", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "1", HU_TYPE_CMD, NULL }, + { "beeper.enable", 0, 0, "UPS.BatterySystem.Battery.AudibleAlarmControl", NULL, "2", HU_TYPE_CMD, NULL }, { "beeper.enable", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "2", HU_TYPE_CMD, NULL }, /* Command for the outlet collection */ @@ -1339,7 +1434,7 @@ static hid_info_t mge_hid2nut[] = { "outlet.2.load.on", 0, 0, "UPS.OutletSystem.Outlet.[3].DelayBeforeStartup", NULL, "0", HU_TYPE_CMD, NULL }, /* end of structure. */ - { NULL } + { NULL, 0, 0, NULL, NULL, NULL, 0, NULL } }; /* @@ -1381,7 +1476,31 @@ static char *get_model_name(const char *iProduct, const char *iModel) * model name by concatenation of iProduct and iModel */ char buf[SMALLBUF]; - snprintf(buf, sizeof(buf), "%s %s", iProduct, iModel); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION +#pragma GCC diagnostic ignored "-Wformat-truncation" +#endif + /* NOTE: We intentionally limit the amount of bytes reported */ + int len = snprintf(buf, sizeof(buf), "%s %s", iProduct, iModel); + + if (len < 0) { + upsdebugx(1, "%s: got an error while extracting iProduct+iModel value", __func__); + } + + /* NOTE: SMALLBUF here comes from mge_format_model() + * buffer definitions below + */ + if ((intmax_t)len > (intmax_t)sizeof(buf) + || (intmax_t)(strnlen(iProduct, SMALLBUF) + strnlen(iModel, SMALLBUF) + 1 + 1) + > (intmax_t)sizeof(buf) + ) { + upsdebugx(1, "%s: extracted iProduct+iModel value was truncated", __func__); + } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION +#pragma GCC diagnostic pop +#endif return strdup(buf); } @@ -1449,6 +1568,21 @@ static int mge_claim(HIDDevice_t *hd) { * not a UPS, so don't use possibly_supported here */ return 0; + + case PHOENIXTEC: + /* The vendorid 0x06da is primarily handled by + * liebert-hid, except for (maybe) AEG PROTECT NAS + * branded devices */ + if (hd->Vendor && strstr(hd->Vendor, "AEG")) { + return 1; + } + if (hd->Product && strstr(hd->Product, "AEG")) { + return 1; + } + + /* Let liebert-hid grab this */ + return 0; + default: /* Valid for Eaton */ /* by default, reject, unless the productid option is given */ if (getval("productid")) { @@ -1459,6 +1593,21 @@ static int mge_claim(HIDDevice_t *hd) { } case SUPPORTED: + + switch (hd->VendorID) + { + case PHOENIXTEC: /* see comments above */ + if (hd->Vendor && strstr(hd->Vendor, "AEG")) { + return 1; + } + if (hd->Product && strstr(hd->Product, "AEG")) { + return 1; + } + + /* Let liebert-hid grab this */ + return 0; + } + return 1; case NOT_SUPPORTED: @@ -1466,7 +1615,8 @@ static int mge_claim(HIDDevice_t *hd) { return 0; } #else - return 1; + NUT_UNUSED_VARIABLE(hd); + return 1; #endif } @@ -1478,4 +1628,5 @@ subdriver_t mge_subdriver = { mge_format_model, mge_format_mfr, mge_format_serial, + fix_report_desc, }; diff --git a/drivers/mge-mib.c b/drivers/mge-mib.c index 8dd2eeb..d0a844d 100644 --- a/drivers/mge-mib.c +++ b/drivers/mge-mib.c @@ -27,7 +27,7 @@ #include "mge-mib.h" -#define MGE_MIB_VERSION "0.5" +#define MGE_MIB_VERSION "0.55" /* TODO: * - MGE PDU MIB and sysOID (".1.3.6.1.4.1.705.2") */ @@ -38,117 +38,127 @@ #define MGE_OID_MODEL_NAME MGE_BASE_OID ".1.1.0" static info_lkp_t mge_lowbatt_info[] = { - { 1, "LB" }, - { 2, "" }, - { 0, NULL } + { 1, "LB", NULL, NULL }, + { 2, "", NULL, NULL }, + { 0, NULL, NULL, NULL } }; static info_lkp_t mge_onbatt_info[] = { - { 1, "OB" }, - { 2, "OL" }, - { 0, NULL } + { 1, "OB", NULL, NULL }, + { 2, "OL", NULL, NULL }, + { 0, NULL, NULL, NULL } }; static info_lkp_t mge_bypass_info[] = { - { 1, "BYPASS" }, - { 2, "" }, - { 0, NULL } + { 1, "BYPASS", NULL, NULL }, + { 2, "", NULL, NULL }, + { 0, NULL, NULL, NULL } }; static info_lkp_t mge_boost_info[] = { - { 1, "BOOST" }, - { 2, "" }, - { 0, NULL } + { 1, "BOOST", NULL, NULL }, + { 2, "", NULL, NULL }, + { 0, NULL, NULL, NULL } }; static info_lkp_t mge_trim_info[] = { - { 1, "TRIM" }, - { 2, "" }, - { 0, NULL } + { 1, "TRIM", NULL, NULL }, + { 2, "", NULL, NULL }, + { 0, NULL, NULL, NULL } }; static info_lkp_t mge_overload_info[] = { - { 1, "OVER" }, - { 2, "" }, - { 0, NULL } + { 1, "OVER", NULL, NULL }, + { 2, "", NULL, NULL }, + { 0, NULL, NULL, NULL } }; static info_lkp_t mge_replacebatt_info[] = { - { 1, "RB" }, - { 2, "" }, - { 0, NULL } + { 1, "RB", NULL, NULL }, + { 2, "", NULL, NULL }, + { 0, NULL, NULL, NULL } }; static info_lkp_t mge_output_util_off_info[] = { - { 1, "OFF" }, - { 2, "" }, - { 0, NULL } + { 1, "OFF", NULL, NULL }, + { 2, "", NULL, NULL }, + { 0, NULL, NULL, NULL } }; static info_lkp_t mge_transfer_reason_info[] = { - { 1, "" }, - { 2, "input voltage out of range" }, - { 3, "input frequency out of range" }, - { 4, "utility off" }, - { 0, NULL } + { 1, "", NULL, NULL }, + { 2, "input voltage out of range", NULL, NULL }, + { 3, "input frequency out of range", NULL, NULL }, + { 4, "utility off", NULL, NULL }, + { 0, NULL, NULL, NULL } }; -static info_lkp_t ietf_test_result_info[] = { - { 1, "done and passed" }, - { 2, "done and warning" }, - { 3, "done and error" }, - { 4, "aborted" }, - { 5, "in progress" }, - { 6, "no test initiated" }, - { 0, NULL } +static info_lkp_t mge_test_result_info[] = { + { 1, "done and passed", NULL, NULL }, + { 2, "done and warning", NULL, NULL }, + { 3, "done and error", NULL, NULL }, + { 4, "aborted", NULL, NULL }, + { 5, "in progress", NULL, NULL }, + { 6, "no test initiated", NULL, NULL }, + { 0, NULL, NULL, NULL } }; -static info_lkp_t ietf_beeper_status_info[] = { - { 1, "disabled" }, - { 2, "enabled" }, - { 3, "muted" }, - { 0, NULL } +static info_lkp_t mge_beeper_status_info[] = { + { 1, "disabled", NULL, NULL }, + { 2, "enabled", NULL, NULL }, + { 3, "muted", NULL, NULL }, + { 0, NULL, NULL, NULL } }; -static info_lkp_t ietf_yes_no_info[] = { - { 1, "yes" }, - { 2, "no" }, - { 0, NULL } +static info_lkp_t mge_yes_no_info[] = { + { 1, "yes", NULL, NULL }, + { 2, "no", NULL, NULL }, + { 0, NULL, NULL, NULL } }; /* FIXME: the below may introduce status redundancy, that needs to be - * adressed by the driver, as for usbhid-ups! */ -static info_lkp_t ietf_power_source_info[] = { - { 1, "" /* other */ }, - { 2, "OFF" /* none */ }, + * addressed by the driver, as for usbhid-ups! */ +static info_lkp_t mge_power_source_info[] = { + { 1, "" /* other */, NULL, NULL }, + { 2, "OFF" /* none */, NULL, NULL }, #if 0 - { 3, "OL" /* normal */ }, + { 3, "OL" /* normal */, NULL, NULL }, #endif - { 4, "BYPASS" /* bypass */ }, - { 5, "OB" /* battery */ }, - { 6, "BOOST" /* booster */ }, - { 7, "TRIM" /* reducer */ }, - { 0, NULL } + { 4, "BYPASS" /* bypass */, NULL, NULL }, + { 5, "OB" /* battery */, NULL, NULL }, + { 6, "BOOST" /* booster */, NULL, NULL }, + { 7, "TRIM" /* reducer */, NULL, NULL }, + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t mge_ambient_drycontacts_info[] = { + { -1, "unknown", NULL, NULL }, + { 1, "closed", NULL, NULL }, + { 2, "opened", NULL, NULL }, + { 0, NULL, NULL, NULL } }; /* Parameters default values */ -#define STR_DEFAULT_ONDELAY "30" /* Delay between return of utility power */ +#define DEFAULT_ONDELAY "30" /* Delay between return of utility power */ /* and powering up of load, in seconds */ /* CAUTION: ondelay > offdelay */ -#define DEFAULT_ONDELAY 30 -#define STR_DEFAULT_OFFDELAY "20" /* Delay before power off, in seconds */ -#define DEFAULT_OFFDELAY 20 +#define DEFAULT_OFFDELAY "20" /* Delay before power off, in seconds */ -#define MGE_NOTHING_VALUE 1 -#define MGE_START_VALUE 2 -#define MGE_STOP_VALUE 3 +#define MGE_NOTHING_VALUE "1" +#define MGE_START_VALUE "2" +#define MGE_STOP_VALUE "3" /* TODO: PowerShare (per plug .1, .2, .3) and deals with delays */ /* Snmp2NUT lookup table */ static snmp_info_t mge_mib[] = { + /* standard MIB items */ + { "device.description", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.1.0", NULL, SU_FLAG_OK, NULL }, + { "device.contact", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.4.0", NULL, SU_FLAG_OK, NULL }, + { "device.location", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.6.0", NULL, SU_FLAG_OK, NULL }, + /* UPS page */ { "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "Eaton", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, { "ups.model", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.1.1.0", "Generic SNMP UPS", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, @@ -156,17 +166,17 @@ static snmp_info_t mge_mib[] = { { "ups.firmware", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.1.4.0", "", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, { "ups.firmware.aux", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.12.12.0", "", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, { "ups.load", 0, 1, ".1.3.6.1.4.1.705.1.7.2.1.4.1", "", SU_OUTPUT_1, NULL }, - { "ups.beeper.status", ST_FLAG_STRING, SU_INFOSIZE, "1.3.6.1.2.1.33.1.9.8.0", "", 0, ietf_beeper_status_info }, + { "ups.beeper.status", ST_FLAG_STRING, SU_INFOSIZE, "1.3.6.1.2.1.33.1.9.8.0", "", 0, mge_beeper_status_info }, { "ups.L1.load", 0, 1, ".1.3.6.1.4.1.705.1.7.2.1.4.1", "", SU_OUTPUT_3, NULL }, { "ups.L2.load", 0, 1, ".1.3.6.1.4.1.705.1.7.2.1.4.2", "", SU_OUTPUT_3, NULL }, { "ups.L3.load", 0, 1, ".1.3.6.1.4.1.705.1.7.2.1.4.3", "", SU_OUTPUT_3, NULL }, - { "ups.test.result", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.2.1.33.1.7.3.0", "", 0, ietf_test_result_info }, - { "ups.delay.shutdown", ST_FLAG_STRING | ST_FLAG_RW, 6, "1.3.6.1.2.1.33.1.8.2.0", STR_DEFAULT_OFFDELAY, SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, - { "ups.delay.start", ST_FLAG_STRING | ST_FLAG_RW, 6, "1.3.6.1.2.1.33.1.8.3.0", STR_DEFAULT_ONDELAY, SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, + { "ups.test.result", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.2.1.33.1.7.3.0", "", 0, mge_test_result_info }, + { "ups.delay.shutdown", ST_FLAG_STRING | ST_FLAG_RW, 6, "1.3.6.1.2.1.33.1.8.2.0", DEFAULT_OFFDELAY, SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, + { "ups.delay.start", ST_FLAG_STRING | ST_FLAG_RW, 6, "1.3.6.1.2.1.33.1.8.3.0", DEFAULT_ONDELAY, SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, { "ups.timer.shutdown", 0, 1, "1.3.6.1.2.1.33.1.8.2.0", "", SU_FLAG_OK, NULL }, { "ups.timer.start", 0, 1, "1.3.6.1.2.1.33.1.8.3.0", "", SU_FLAG_OK, NULL }, { "ups.timer.reboot", 0, 1, "1.3.6.1.2.1.33.1.8.4.0", "", SU_FLAG_OK, NULL }, - { "ups.start.auto", ST_FLAG_RW, 1, "1.3.6.1.2.1.33.1.8.5.0", "", SU_FLAG_OK, ietf_yes_no_info }, + { "ups.start.auto", ST_FLAG_RW, 1, "1.3.6.1.2.1.33.1.8.5.0", "", SU_FLAG_OK, mge_yes_no_info }, /* status data */ { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.5.11.0", "", SU_FLAG_OK | SU_STATUS_BATT, mge_replacebatt_info }, { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.5.14.0", "", SU_FLAG_OK | SU_STATUS_BATT, mge_lowbatt_info }, @@ -177,7 +187,7 @@ static snmp_info_t mge_mib[] = { { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.7.8.0", "", SU_FLAG_OK | SU_STATUS_BATT, mge_boost_info }, { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.7.10.0", "", SU_FLAG_OK | SU_STATUS_BATT, mge_overload_info }, { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.7.12.0", "", SU_FLAG_OK | SU_STATUS_BATT, mge_trim_info }, - { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.2.1.33.1.4.1.0", "", SU_STATUS_PWR | SU_FLAG_OK, ietf_power_source_info }, + { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.2.1.33.1.4.1.0", "", SU_STATUS_PWR | SU_FLAG_OK, mge_power_source_info }, /* FIXME: Alarms * - upsmgBatteryChargerFault (.1.3.6.1.4.1.705.1.5.15.0), yes (1), no (2) @@ -193,7 +203,7 @@ static snmp_info_t mge_mib[] = { */ /* Input page */ - { "input.phases", 0, 1.0, ".1.3.6.1.4.1.705.1.6.1.0", "", SU_FLAG_SETINT, NULL, &input_phases }, + { "input.phases", 0, 1.0, ".1.3.6.1.4.1.705.1.6.1.0", "", 0, NULL }, { "input.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.2.1", "", SU_INPUT_1, NULL }, { "input.L1-N.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.2.1", "", SU_INPUT_3, NULL }, { "input.L2-N.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.2.2", "", SU_INPUT_3, NULL }, @@ -217,7 +227,7 @@ static snmp_info_t mge_mib[] = { { "input.transfer.reason", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.6.4.0", "", SU_FLAG_OK, mge_transfer_reason_info }, /* Output page */ - { "output.phases", 0, 1.0, ".1.3.6.1.4.1.705.1.7.1.0", "", SU_FLAG_SETINT, NULL, &output_phases }, + { "output.phases", 0, 1.0, ".1.3.6.1.4.1.705.1.7.1.0", "", 0, NULL }, { "output.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.7.2.1.2.1", "", SU_OUTPUT_1, NULL }, { "output.L1-N.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.7.2.1.2.1", "", SU_OUTPUT_3, NULL }, { "output.L2-N.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.7.2.1.2.2", "", SU_OUTPUT_3, NULL }, @@ -241,13 +251,17 @@ static snmp_info_t mge_mib[] = { /* Ambient page: Environment Sensor (ref 66 846) */ { "ambient.temperature", 0, 0.1, ".1.3.6.1.4.1.705.1.8.1.0", "", SU_TYPE_INT | SU_FLAG_OK, NULL }, { "ambient.humidity", 0, 0.1, ".1.3.6.1.4.1.705.1.8.2.0", "", SU_TYPE_INT | SU_FLAG_OK, NULL }, + /* upsmgEnvironmentInput1State.1 */ + { "ambient.contacts.1.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.8.7.1.9.1", "", SU_TYPE_INT | SU_FLAG_OK, mge_ambient_drycontacts_info }, + /* upsmgEnvironmentInput1State.1 */ + { "ambient.contacts.2.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.8.7.1.10.1", "", SU_TYPE_INT | SU_FLAG_OK, mge_ambient_drycontacts_info }, /* Outlet page */ { "outlet.id", 0, 1, NULL, "0", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, { "outlet.desc", ST_FLAG_RW | ST_FLAG_STRING, 20, NULL, "Main Outlet", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, /* instant commands. */ - { "test.battery.start", 0, MGE_START_VALUE, ".1.3.6.1.4.1.705.1.10.4.0", "", SU_TYPE_CMD | SU_FLAG_OK, NULL }, + { "test.battery.start", 0, 1, ".1.3.6.1.4.1.705.1.10.4.0", MGE_START_VALUE, SU_TYPE_CMD | SU_FLAG_OK, NULL }, /* Also use IETF OIDs * { "test.battery.stop", 0, 0, "1.3.6.1.2.1.33.1.7.1.0", "1.3.6.1.2.1.33.1.7.7.2", SU_TYPE_CMD, NULL }, * { "test.battery.start", 0, 0, "1.3.6.1.2.1.33.1.7.1.0", "1.3.6.1.2.1.33.1.7.7.3", SU_TYPE_CMD, NULL }, @@ -255,20 +269,21 @@ static snmp_info_t mge_mib[] = { * { "test.battery.start.deep", 0, 0, "1.3.6.1.2.1.33.1.7.1.0", "1.3.6.1.2.1.33.1.7.7.5", SU_TYPE_CMD, NULL }, */ - /* { "load.off", 0, MGE_START_VALUE, ".1.3.6.1.4.1.705.1.9.1.1.6.1", "", SU_TYPE_CMD | SU_FLAG_OK, NULL }, - * { "load.on", 0, MGE_START_VALUE, ".1.3.6.1.4.1.705.1.9.1.1.3.1", "", SU_TYPE_CMD | SU_FLAG_OK, NULL }, - * { "shutdown.return", 0, MGE_START_VALUE, ".1.3.6.1.4.1.705.1.9.1.1.9.1", "", SU_TYPE_CMD | SU_FLAG_OK, NULL }, + /* { "load.off", 0, 1, ".1.3.6.1.4.1.705.1.9.1.1.6.1", MGE_START_VALUE, SU_TYPE_CMD | SU_FLAG_OK, NULL }, + * { "load.on", 0, 1, ".1.3.6.1.4.1.705.1.9.1.1.3.1", MGE_START_VALUE, SU_TYPE_CMD | SU_FLAG_OK, NULL }, + * { "shutdown.return", 0, 1, ".1.3.6.1.4.1.705.1.9.1.1.9.1", MGE_START_VALUE, SU_TYPE_CMD | SU_FLAG_OK, NULL }, */ /* IETF MIB fallback */ - { "beeper.disable", 0, 1, "1.3.6.1.2.1.33.1.9.8.0", "", SU_TYPE_CMD, NULL }, - { "beeper.enable", 0, 2, "1.3.6.1.2.1.33.1.9.8.0", "", SU_TYPE_CMD, NULL }, - { "beeper.mute", 0, 3, "1.3.6.1.2.1.33.1.9.8.0", "", SU_TYPE_CMD, NULL }, - /* Use ST_FLAG_STRING to get default value from ->dfl instead of info_len */ - { "load.off.delay", 0, DEFAULT_OFFDELAY, "1.3.6.1.2.1.33.1.8.2.0", "", SU_TYPE_CMD, NULL }, - { "load.on.delay", 0, DEFAULT_ONDELAY, "1.3.6.1.2.1.33.1.8.3.0", "", SU_TYPE_CMD, NULL }, + { "beeper.disable", 0, 1, "1.3.6.1.2.1.33.1.9.8.0", "1", SU_TYPE_CMD, NULL }, + { "beeper.enable", 0, 1, "1.3.6.1.2.1.33.1.9.8.0", "2", SU_TYPE_CMD, NULL }, + { "beeper.mute", 0, 1, "1.3.6.1.2.1.33.1.9.8.0", "3", SU_TYPE_CMD, NULL }, + /*{ "load.off", 0, 1, "1.3.6.1.2.1.33.1.8.2.0", DEFAULT_OFFDELAY, SU_TYPE_CMD, NULL }, + { "load.on", 0, 1, "1.3.6.1.2.1.33.1.8.3.0", DEFAULT_ONDELAY, SU_TYPE_CMD, NULL },*/ + { "load.off.delay", 0, 1, "1.3.6.1.2.1.33.1.8.2.0", NULL, SU_TYPE_CMD, NULL }, + { "load.on.delay", 0, 1, "1.3.6.1.2.1.33.1.8.3.0", NULL, SU_TYPE_CMD, NULL }, /* end of structure. */ { NULL, 0, 0, NULL, NULL, 0, NULL } }; -mib2nut_info_t mge = { "mge", MGE_MIB_VERSION, NULL, MGE_OID_MODEL_NAME, mge_mib, MGE_SYSOID }; +mib2nut_info_t mge = { "mge", MGE_MIB_VERSION, NULL, MGE_OID_MODEL_NAME, mge_mib, MGE_SYSOID, NULL }; diff --git a/drivers/mge-shut.c b/drivers/mge-shut.c deleted file mode 100644 index 06398ed..0000000 --- a/drivers/mge-shut.c +++ /dev/null @@ -1,1455 +0,0 @@ -/* mge-shut.c - monitor MGE UPS for NUT with SHUT protocol - * - * Copyright (C) 2002 - 2012 - * Arnaud Quette - * - * Sponsored by MGE UPS SYSTEMS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include - -#include "config.h" -#include "main.h" -#include "serial.h" -#include "timehead.h" -#include "mge-shut.h" -#include "hidparser.h" -#include "hidtypes.h" -#include "common.h" /* for upsdebugx() etc */ - -/* --------------------------------------------------------------- */ -/* Define "technical" constants */ -/* --------------------------------------------------------------- */ - -#define DRIVER_NAME "Eaton / SHUT driver" -#define DRIVER_VERSION "0.70" - -/* driver description structure */ -upsdrv_info_t upsdrv_info = { - DRIVER_NAME, - DRIVER_VERSION, - "Arnaud Quette ", - DRV_STABLE, - { NULL } -}; - -#define MAX_TRY 4 - -/* global variables */ -int commstatus = 0; -int lowbatt = -1; -int ondelay = DEFAULT_ONDELAY; -int offdelay = DEFAULT_OFFDELAY; -int notification = DEFAULT_NOTIFICATION; - -#define SD_RETURN 0 -#define SD_STAYOFF 1 - -int sdtype = SD_RETURN; - -#define BYTESWAP(in) (((in & 0xFF) << 8) + ((in & 0xFF00) >> 8)) - -/* realign packet data according to Endianess */ -static void align_request(hid_packet_t *sd) -{ -#if WORDS_BIGENDIAN - /* Sparc/Mips/... are big endian, USB/SHUT little endian */ - (*sd).wValue = BYTESWAP((*sd).wValue); - (*sd).wIndex = BYTESWAP((*sd).wIndex); - (*sd).wLength = BYTESWAP((*sd).wLength); -#endif -} - -/* --------------------------------------------------------------- */ -/* Global structures */ -/* --------------------------------------------------------------- */ - -hid_desc_data_t hid_descriptor; -device_desc_data_t device_descriptor; -static long hValue; -static HIDDesc_t *pDesc = NULL; /* parsed Report Descriptor */ -u_char raw_buf[4096]; - -/* --------------------------------------------------------------- */ -/* Function prototypes */ -/* --------------------------------------------------------------- */ - -float expo(int a, int b); -extern long FormatValue(long Value, u_char Size); -static const char *hu_find_infoval(info_lkp_t *hid2info, long value); - -/* --------------------------------------------------------------- */ -/* UPS Driver Functions */ -/* --------------------------------------------------------------- */ - -void upsdrv_initinfo (void) -{ - mge_info_item_t *item; - - upsdebugx(2, "entering initinfo()\n"); - - /* Get complete Model information */ - shut_identify_ups (); - - printf("Detected %s [%s] on %s\n", dstate_getinfo("ups.model"), - dstate_getinfo("ups.serial"), device_path); - - /* Device capabilities enumeration ----------------------------- */ - for ( item = mge_info ; item->type != NULL ; item++ ) { - - /* Check if we are asked to stop (reactivity++) */ - if (exit_flag != 0) - return; - - /* avoid redundancy when multiple defines (RO/RW) */ - if (dstate_getinfo(item->type) != NULL) - continue; - - /* Special case for handling server side variables */ - if (item->shut_flags & SHUT_FLAG_ABSENT) { - /* Check if exists (if necessary) before creation */ - if (item->item_path != NULL) - { - if (hid_get_value(item->item_path) != 1 ) - continue; - } - else - { - /* Simply set the default value */ - dstate_setinfo(item->type, "%s", item->dfl); - dstate_setflags(item->type, item->flags); - continue; - } - - dstate_setinfo(item->type, "%s", item->dfl); - dstate_setflags(item->type, item->flags); - - /* Set max length for strings, if needed */ - if (item->flags & ST_FLAG_STRING) - dstate_setaux(item->type, item->length); - - /* disable reading now - item->shut_flags &= ~SHUT_FLAG_OK;*/ - } else { - if (hid_get_value(item->item_path) != 0 ) { - - item->shut_flags &= SHUT_FLAG_OK; - dstate_setinfo(item->type, item->fmt, hValue); - dstate_setflags(item->type, item->flags); - /* Set max length for strings */ - if (item->flags & ST_FLAG_STRING) - dstate_setaux(item->type, item->length); - } - else { - item->shut_flags &= ~SHUT_FLAG_OK; - } - } - } - - /* commands ----------------------------------------------- */ - dstate_addcmd("load.off"); - dstate_addcmd("load.on"); - dstate_addcmd("shutdown.return"); - dstate_addcmd("shutdown.stayoff"); - dstate_addcmd("test.battery.start"); - dstate_addcmd("test.battery.stop"); - - /* install handlers */ - upsh.setvar = hid_set_value; /* setvar; */ - upsh.instcmd = instcmd; - - /* check if low battery level has been given to set it */ - if (lowbatt != -1) { - hid_set_value("battery.charge.low", getval ("lowbatt")); - } -} - -/* --------------------------------------------------------------- */ - -void upsdrv_updateinfo (void) -{ - mge_info_item_t *item; - const char *nutvalue; - - upsdebugx(2, "entering upsdrv_updateinfo()"); - - if (commstatus == 0) { - if (shut_ups_start () != 0) { - upsdebugx(2, "No communication with UPS, retrying"); - dstate_datastale(); - return; - } else { - upsdebugx(2, "Communication with UPS established"); - } - } - - shut_ups_status(); - - /* Device data walk ----------------------------- */ - for ( item = mge_info ; item->type != NULL; item++ ) { - - /* Check if we are asked to stop (reactivity++) */ - if (exit_flag != 0) - return; - - if (item->shut_flags & SHUT_FLAG_ABSENT) - continue; - - if (item->shut_flags & SHUT_FLAG_OK) { - - if(hid_get_value(item->item_path) != 0 ) { - upsdebugx(3, "%s: hValue = %ld", item->item_path, hValue); - /* upsdebugx(3, "%s: hValue = %ld (%ld)", - item->item_path, hValue, hData.LogMax); */ - - /* need lookup'ed translation */ - if (item->hid2info != NULL) - { - nutvalue = hu_find_infoval(item->hid2info, (long)hValue); - if (nutvalue != NULL) - dstate_setinfo(item->type, "%s", nutvalue); - else - dstate_setinfo(item->type, item->fmt, hValue); - } - else - dstate_setinfo(item->type, item->fmt, hValue); - - dstate_dataok(); - } else { - if (shut_ups_start () != 0) - dstate_datastale(); - } - } - } -} - -/* --------------------------------------------------------------- */ - -void upsdrv_shutdown (void) -{ - char val[5]; - - if (sdtype == SD_RETURN) { - /* set DelayBeforeStartup */ - snprintf(val, sizeof(val), "%d", ondelay); - hid_set_value("ups.timer.start", val); - } - - /* set DelayBeforeShutdown */ - snprintf(val, sizeof(val), "%d", offdelay); - hid_set_value("ups.timer.shutdown", val); -} - -/* --------------------------------------------------------------- */ - -void upsdrv_help (void) -{ - upsdebugx(2, "entering upsdrv_help"); -} - -/* --------------------------------------------------------------- */ - -/* list flags and values that you want to receive via -x */ -void upsdrv_makevartable (void) -{ - char msg[MAX_STRING]; - - upsdebugx (2, "entering upsdrv_makevartable()"); - - snprintf(msg, sizeof(msg), "Set low battery level, in %% (default=%d).", - DEFAULT_LOWBATT); - addvar (VAR_VALUE, "lowbatt", msg); - - snprintf(msg, sizeof(msg), "Set shutdown delay, in seconds (default=%d).", - DEFAULT_OFFDELAY); - addvar (VAR_VALUE, "offdelay", msg); - - snprintf(msg, sizeof(msg), "Set startup delay, in ten seconds units (default=%d).", - DEFAULT_ONDELAY); - addvar (VAR_VALUE, "ondelay", msg); - - snprintf(msg, sizeof(msg), "Set notification type, 1 = no, 2 = light, 3 = yes (default=%d).", - DEFAULT_NOTIFICATION); - addvar (VAR_VALUE, "notification", msg); -} - -/* --------------------------------------------------------------- */ - -void upsdrv_initups (void) -{ - upsdebugx(2, "entering upsdrv_initups()"); - - /* initialize serial port */ - upsfd = ser_open(device_path); - ser_set_speed(upsfd, device_path, B2400); - setline (1); - - /* get battery lowlevel */ - if (getval ("lowbatt")) - lowbatt = atoi (getval ("lowbatt")); - - /* on delay */ - if (getval ("ondelay")) - ondelay = atoi (getval ("ondelay")); - - /* shutdown delay */ - if (getval ("offdelay")) - offdelay = atoi (getval ("offdelay")); - - /* notification type */ - if (getval ("notification")) - notification = atoi (getval ("notification")); - - /* initialise communication */ - if (shut_ups_start () != 0) - fatalx(EXIT_FAILURE, "No communication with UPS"); - else - upsdebugx(2, "Communication with UPS established"); - - /* initialise HID communication */ - if(hid_init_device() != 0) - fatalx(EXIT_FAILURE, "Can't initialise HID device"); -} - -/* --------------------------------------------------------------- */ - -void upsdrv_cleanup(void) -{ - ser_close(upsfd, device_path); -} - -/* --------------------------------------------------------------- */ - -int instcmd(const char *cmdname, const char *extra) -{ - /* Shutdown UPS and return when power is restored */ - if (!strcasecmp(cmdname, "shutdown.return")) { - sdtype = SD_RETURN; - upsdrv_shutdown(); - return STAT_INSTCMD_HANDLED; - } - - /* Shutdown UPS and stay off when power is restored */ - if (!strcasecmp(cmdname, "shutdown.stayoff")) { - sdtype = SD_STAYOFF; - upsdrv_shutdown(); - return STAT_INSTCMD_HANDLED; - } - - /* Power off the load immediatly */ - if (!strcasecmp(cmdname, "load.off")) { - /* set DelayBeforeShutdown to 0 */ - hid_set_value("ups.timer.shutdown", "0"); - return STAT_INSTCMD_HANDLED; - } - - /* Power on the load immediatly */ - if (!strcasecmp(cmdname, "load.on")) { - /* set DelayBeforeStartup to 0 */ - hid_set_value("ups.timer.start", "0"); - return STAT_INSTCMD_HANDLED; - } - - /* Start battery test */ - if (!strcasecmp(cmdname, "test.battery.start")) { - /* set Test to 1 (Quick test) */ - hid_set_value("ups.test.result", "1"); - return STAT_INSTCMD_HANDLED; - } - - /* Stop battery test */ - if (!strcasecmp(cmdname, "test.battery.stop")) { - /* set Test to 3 (Abort test) */ - hid_set_value("ups.test.result", "3"); - return STAT_INSTCMD_HANDLED; - } - - upslogx(LOG_NOTICE, "instcmd: unknown command [%s]", cmdname); - return STAT_INSTCMD_UNKNOWN; -} - - -/***************************************************************************** - * shut_ups_start () - * - * initiate communication with the UPS - * - * return 0 on success, -1 on failure - * - *****************************************************************************/ -int shut_ups_start () -{ - u_char c = SHUT_SYNC, r[1]; - int try; - - upsdebugx (2, "entering shut_ups_start()\n"); - r[0] = '\0'; - - switch (notification) { - case OFF_NOTIFICATION: - c = SHUT_SYNC_OFF; - break; - case LIGHT_NOTIFICATION: - c = SHUT_SYNC_LIGHT; - break; - default: - case COMPLETE_NOTIFICATION: - c = SHUT_SYNC; - break; - } - - /* Sync with the UPS using Complete, Off or light notification */ - for (try = 0; try < MAX_TRY; try++) { - if ((shut_token_send(c)) == -1) { - upsdebugx (3, "Communication error while writing to port"); - return -1; - } - serial_read (1000, &r[0]); - if (r[0] == c) { - commstatus = 1; - upsdebugx (3, "Syncing and notification setting done"); - return 0; - } - } - commstatus = 0; - return -1; -} - -/********************************************************************** - * shut_identify_ups () - * - * Get SHUT device complete name - * - * return 0 on success, -1 on failure - * - *********************************************************************/ -int shut_identify_ups () -{ - char string[MAX_STRING]; - char model[MAX_STRING]; - const char *finalname = NULL; - int retcode, tries=MAX_TRY; - - if (commstatus == 0) - return -1; - - upsdebugx (2, "entering shut_identify_ups(0x%04x, 0x%04x)\n", - device_descriptor.dev_desc.iManufacturer, - device_descriptor.dev_desc.iProduct); - - /* Get strings iModel and iProduct */ - while (tries > 0) - { - if (shut_get_string(device_descriptor.dev_desc.iProduct, string, 0x25) > 0) - { - strcpy(model, string); - - if(hid_get_value("UPS.PowerSummary.iModel") != 0 ) - { - if((shut_get_string(hValue, string, 0x25)) > 0) - { - finalname = get_model_name(model, string); - upsdebugx (2, "iModel = %s", string); - tries = 0; - } - } - else - { - /* Try with "UPS.Flow.[4].ConfigApparentPower" */ - if(hid_get_value("UPS.Flow.[4].ConfigApparentPower") != 0 ) - { - snprintf(string, sizeof(string), "%i", (int)hValue); - finalname = get_model_name(model, string); - } - else - finalname = get_model_name(model, NULL); - - tries = 0; - } - - dstate_setinfo("ups.model", "%s", finalname); - } - else - tries--; - } - - /* Get strings iSerialNumber */ - if (((retcode = shut_get_string(device_descriptor.dev_desc.iSerialNumber, string, 0x25)) > 0) - && strcmp(string, "") && string[0] != '\t') { - - dstate_setinfo("ups.serial", "%s", string); - } - else - dstate_setinfo("ups.serial", "unknown"); - - /* all went fine */ - return 1; -} - -/********************************************************************** - * shut_wait_ack() - * - * wait for an ACK packet - * - * returns 0 on success, -1 on error, -2 on NACK, -3 on NOTIFICATION - * - *********************************************************************/ -int shut_wait_ack (void) -{ - u_char c[1]; - - c[0] = '\0'; - - serial_read (DEFAULT_TIMEOUT, &c[0]); - if (c[0] == SHUT_OK) { - upsdebugx (2, "shut_wait_ack(): ACK received"); - return 0; - } - else if (c[0] == SHUT_NOK) { - upsdebugx (2, "shut_wait_ack(): NACK received"); - return -2; - } - else if ((c[0] & 0x0f) == SHUT_TYPE_NOTIFY) { - upsdebugx (2, "shut_wait_ack(): NOTIFY received"); - return -3; - } - upsdebugx (2, "shut_wait_ack(): Nothing received"); - return -1; -} - -/********************************************************************** - * char_read (char *bytes, int size, int read_timeout) - * - * reads size bytes from the serial port - * - * bytes - buffer to store the data - * size - size of the data to get - * read_timeout - serial timeout (in milliseconds) - * - * return -1 on error, -2 on timeout, nb_bytes_readen on success - * - *********************************************************************/ -static int char_read (char *bytes, int size, int read_timeout) -{ - struct timeval serial_timeout; - fd_set readfs; - int readen = 0; - int rc = 0; - - FD_ZERO (&readfs); - FD_SET (upsfd, &readfs); - - serial_timeout.tv_usec = (read_timeout % 1000) * 1000; - serial_timeout.tv_sec = (read_timeout / 1000); - - rc = select (upsfd + 1, &readfs, NULL, NULL, &serial_timeout); - if (0 == rc) - return -2; /* timeout */ - - if (FD_ISSET (upsfd, &readfs)) { - int now = read (upsfd, bytes, size - readen); - - if (now < 0) { - return -1; - } - else { - bytes += now; - readen += now; - } - } - else { - return -1; - } - return readen; -} - -/********************************************************************** - * serial_read (int read_timeout) - * - * return data one byte at a time - * - * read_timeout - serial timeout (in milliseconds) - * - * returns 0 on success, -1 on error, -2 on timeout - * - **********************************************************************/ -int serial_read (int read_timeout, u_char *readbuf) -{ - static u_char cache[512]; - static u_char *cachep = cache; - static u_char *cachee = cache; - int recv; - *readbuf = '\0'; - - /* if still data in cache, get it */ - if (cachep < cachee) { - *readbuf = *cachep++; - return 0; - /* return (int) *cachep++; */ - } - recv = char_read ((char *)cache, 1, read_timeout); - - if ((recv == -1) || (recv == -2)) - return recv; - - cachep = cache; - cachee = cache + recv; - cachep = cache; - cachee = cache + recv; - - if (recv) { - upsdebugx(5,"received: %02x", *cachep); - *readbuf = *cachep++; - return 0; - } - return -1; -} - -/********************************************************************** - * serial_send (char *buf, int len) - * - * write the content of buf to the serial port - * - * buf - data to send - * len - lenght of data to send - * - * returns number of bytes written on success, -1 on error - * - **********************************************************************/ -int serial_send (u_char *buf, int len) -{ - tcflush (upsfd, TCIFLUSH); - upsdebug_hex (3, "sent", (u_char *)buf, len); - return write (upsfd, buf, len); -} - -/* - * Serial HID UPS Transfer (SHUT) functions - *********************************************************************/ -/* Get and parse UPS status */ -void shut_ups_status(void) -{ - int try = 0, retcode = 0; - - /* clear status buffer before begining */ - status_init(); - - /* Ensure to have at least basic status */ - while (try < MAX_TRY) { - if((retcode = hid_get_value("UPS.PowerSummary.PresentStatus.ACPresent")) != 0 ) { - try = MAX_TRY; - if(hValue == 1){ - status_set("OL"); - } else { - status_set("OB"); - } - } else { /* retry to get data */ - try++; - } - } - - if(hid_get_value("UPS.PowerSummary.PresentStatus.Discharging") != 0 ) { - if(hValue == 1) - status_set("DISCHRG"); - } - - if(hid_get_value("UPS.PowerSummary.PresentStatus.Charging") != 0 ) { - if(hValue == 1) - status_set("CHRG"); - } - - if(hid_get_value("UPS.PowerSummary.PresentStatus.ShutdownImminent") != 0 ) { - if(hValue == 1) - status_set("LB"); - } - - if(hid_get_value("UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit") != 0 ) { - if(hValue == 1) - status_set("LB"); - } - - if(hid_get_value("UPS.PowerSummary.PresentStatus.Overload") != 0 ) { - if(hValue == 1) - status_set("OVER"); - } - - if(hid_get_value("UPS.PowerSummary.PresentStatus.NeedReplacement") != 0 ) { - if(hValue == 1) - status_set("RB"); - } - - if(hid_get_value("UPS.PowerSummary.PresentStatus.Good") != 0 ) { - if(hValue == 0) - status_set("OFF"); - } - - /* FIXME: extend ups.status for BYPASS: */ - /* Manual bypass */ - if(hid_get_value("UPS.PowerConverter.Input.[4].PresentStatus.Used") != 0 ) { - if(hValue == 1) - status_set("BYPASS"); - } - /* Automatic bypass */ - if(hid_get_value("UPS.PowerConverter.Input.[2].PresentStatus.Used") != 0 ) { - if(hValue == 1) - status_set("BYPASS"); - } - - status_commit(); -} - -/* Calculate the SHUT checksum for the packet "buf" */ -u_char shut_checksum(const u_char *buf, int bufsize) -{ - int i; - u_char chk=0; - - for(i=0; i0 && Retry>0) - { - Size=(datalen>=8) ? 8 : datalen; - - /* Packets need only to be sent once - * NACK handling should take care of the rest */ - if (Retry == 1) { - - /* Forge SHUT Frame */ - SHUTRequest.bType = SHUT_TYPE_REQUEST + token; - SHUTRequest.bLength = (Size<<4) + Size; - SHUTRequest.data = *hdata; - /* memcpy(&SHUTRequest.data.raw_pkt, hdata->raw_pkt, Size); */ - - sdata.shut_pkt = SHUTRequest; - sdata.raw_pkt[(Size+3) - 1] = shut_checksum(sdata.shut_pkt.data.raw_pkt, Size); - - upsdebugx (4, "shut_checksum = %2x", sdata.raw_pkt[(Size+3)-1]); - - serial_send (sdata.raw_pkt, Size+3); - } - i = shut_wait_ack (); - if (i == 0) { - datalen-=Size; - Retry=5; - - upsdebugx (4, "received ACK"); - break; - } else if ((i == -1) || (i == -3)) { - /* retry a finite number of times if something wrong happened while - * sending like a notification or a NACK */ - if (Retry >= MAX_TRY) { - upsdebugx(2, "Max tries reached while waiting for ACK, still getting errors"); - return i; - } else { - upsdebugx(4, "Retry = %i", Retry); - /* Send a NACK to get a resend from the UPS */ - shut_token_send(SHUT_NOK); - Retry++; - } - } - } - return (datalen==0); -} - -int shut_packet_recv (u_char *Buf, int datalen) -{ - u_char Start[2]; - u_char Frame[8]; - u_char Chk[1]; - u_short Size=8; - u_short Pos=0; - u_char Retry=0; - int recv; - - upsdebugx (4, "entering shut_packet_recv (%i)", datalen); - - while(datalen>0 && Retry<3) - { - if(serial_read (DEFAULT_TIMEOUT, &Start[0]) >= 0) - { - if(Start[0]==SHUT_SYNC) - { - upsdebugx (4, "received SYNC token"); - memcpy(Buf, Start, 1); - return 1; - } - else - { - /* if(((Start[1] = serial_read (DEFAULT_TIMEOUT)) >= 0) && */ - if((serial_read (DEFAULT_TIMEOUT, &Start[1]) >= 0) && - ((Start[1]>>4)==(Start[1]&0x0F))) - { - upsdebug_hex(3, "Receive", Start, 2); - Size=Start[1]&0x0F; - for(recv=0;recv OK", Chk[0]); - memcpy(Buf, Frame, Size); - datalen-=Size; - Buf+=Size; - Pos+=Size; - Retry=0; - - shut_token_send(SHUT_OK); - - - /* Check if there are more data to receive */ - if((Start[0] & 0xf0) == SHUT_PKT_LAST) { - /* Check if it's a notification */ - if ((Start[0] & 0x0f) == SHUT_TYPE_NOTIFY) { - /* TODO: process notification (dropped for now) */ - upsdebugx (4, "=> notification"); - datalen+=Pos; - Pos=0; - } - else - return Pos; - } - else - upsdebugx (4, "need more data (%i)!", datalen); - } - else - { - upsdebugx (4, "shut_checksum: %02x => NOK", Chk[0]); - shut_token_send(SHUT_NOK); - Retry++; - } - } - else - return 0; - } - } - else - Retry++; - } /* while */ - return 0; -} - -/* - * Human Interface Device (HID) functions - *********************************************************************/ - -/********************************************************************** - * shut_get_descriptor(int desctype, u_char *pkt) - * - * get descriptor specified by DescType and return it in Buf - * - * desctype - from shutdataType - * pkt - where to store the report received - * - * return 0 on success, -1 on failure, -2 on NACK - * - *********************************************************************/ -int shut_get_descriptor(int desctype, u_char *pkt, int reportlen) -{ - hid_packet_t HIDRequest; - hid_data_t data; - int retcode; - - upsdebugx (2, "entering shut_get_descriptor(n %02x, %i)", - desctype, reportlen); - - HIDRequest.bmRequestType = REQUEST_TYPE_USB+(desctype>=HID_DESCRIPTOR?1:0); - HIDRequest.bRequest = 0x06; - HIDRequest.wValue = (desctype<<8); - HIDRequest.wIndex = 0x0000; - HIDRequest.wLength = reportlen; - - align_request(&HIDRequest); - - data.hid_pkt = HIDRequest; - -/* if((retcode = shut_packet_send (&data, sizeof(data), SHUT_PKT_LAST)) > 0) */ - if((retcode = shut_packet_send (&data, 8, SHUT_PKT_LAST)) > 0) - { - if((retcode = shut_packet_recv (pkt, reportlen)) > 0) - { - upsdebug_hex(3, "shut_get_descriptor", pkt, retcode); - return retcode; - } - else - return retcode; - } - return retcode; -} - -/********************************************************************** - * shut_get_string(int index, u_char *pkt, int reportlen) - * - * get descriptor specified by DescType and return it in Buf - * - * index - from shutdataType - * string - where to store the string received - * strlen - length of string - * - * return string size on success, -1 on failure, -2 on NACK - * - *********************************************************************/ -int shut_get_string(int strindex, char *string, int stringlen) -{ - hid_packet_t HIDRequest; - hid_data_t data; - int retcode; - u_char buf[MAX_STRING]; - - upsdebugx (2, "entering shut_get_string(%02x)", strindex); - - HIDRequest.bmRequestType = REQUEST_TYPE_USB; - HIDRequest.bRequest = 0x06; - HIDRequest.wValue = strindex+(STRING_DESCRIPTOR<<8); - HIDRequest.wIndex = 0x0000; - HIDRequest.wLength = (stringlen<<8); /* (reportlen&0xFF)&(reportlen>>8); */ - - align_request(&HIDRequest); - - data.hid_pkt = HIDRequest; - - if((retcode = shut_packet_send (&data, 8, SHUT_PKT_LAST)) >0) - { - upsdebug_hex(3, "shut_get_string", data.raw_pkt, 8); - if((retcode = shut_packet_recv (buf, stringlen)) > 0) - { - upsdebug_hex(3, "shut_get_string", buf, retcode); - make_string(buf, retcode, string); - upsdebugx(2, "string: %s", string); - return strlen(string); - } - else - return retcode; - } - return 0; -} - -/********************************************************************** - * shut_get_report(int id, u_char *pkt, int reportlen) - * - * get report specified by id and return it in pkt - * - * id - from shutdataType - * pkt - where to store the string received - * strlen - length of string - * - * return report size on success, -1 on failure, -2 on NACK - * - *********************************************************************/ -int shut_get_report(int id, u_char *pkt, int reportlen) -{ - hid_packet_t HIDRequest; - hid_data_t data; - int retcode; - - upsdebugx (2, "entering shut_get_report(id: %02x, len: %02x)", id, reportlen); - - HIDRequest.bmRequestType = REQUEST_TYPE_GET_REPORT; - HIDRequest.bRequest = 0x01; - HIDRequest.wValue = id+(HID_REPORT_TYPE_FEATURE<<8); - HIDRequest.wIndex = 0x0000; - HIDRequest.wLength = reportlen; - - align_request(&HIDRequest); - - data.hid_pkt = HIDRequest; - -/* if((retcode = shut_packet_send (&data, sizeof(data), SHUT_PKT_LAST)) > 0) */ - if((retcode = shut_packet_send (&data, 8, SHUT_PKT_LAST)) > 0) - { - if((retcode = shut_packet_recv (pkt, reportlen)) > 0) - { - upsdebug_hex(3, "shut_get_report", pkt, retcode); - return retcode; - } - else - return retcode; - } - return retcode; -} - -/********************************************************************** - * shut_set_report(int id, u_char *pkt, int reportlen) - * - * set report specified by id using pkt as value - * - * id - from shutdataType - * pkt - what to put in report - * strlen - length of report - * - * return string size on success, -1 on failure, -2 on NACK - * - *********************************************************************/ -int shut_set_report(int id, u_char *pkt, int reportlen) -{ - hid_packet_t HIDRequest; - hid_data_t data; - int retcode; - - upsdebugx (2, "entering shut_set_report(id: %02x, len: %02x)", id, reportlen); - - HIDRequest.bmRequestType = REQUEST_TYPE_SET_REPORT; - HIDRequest.bRequest = 0x09; - HIDRequest.wValue = id+(HID_REPORT_TYPE_FEATURE<<8); - HIDRequest.wIndex = 0x0000; - HIDRequest.wLength = reportlen; - - align_request(&HIDRequest); - - data.hid_pkt = HIDRequest; - - /* first packet to instruct a set command */ - if((retcode = shut_packet_send (&data, sizeof(data), 0x0)) > 0) - { - /* second packet to give the actual data */ - memcpy(&data.raw_pkt, pkt, reportlen); - upsdebug_hex(3, "Set2", pkt, reportlen); - - retcode = shut_packet_send (&data, reportlen, SHUT_PKT_LAST); - } - - return retcode; -} - -/********************************************************************** - * hid_init_device() - * - * Get Device/HID/Report descriptors from device and initialise - * HID Parser for further actions - * - * return 0 on success, -1 on failure - * - *********************************************************************/ -int hid_init_device() -{ - int retcode; - - /* Get HID descriptor */ - if((retcode = shut_get_descriptor(HID_DESCRIPTOR, hid_descriptor.raw_desc, 0x09)) > 0) - { - upsdebug_hex(3, "shut_get_descriptor(hid)", hid_descriptor.raw_desc, retcode); - - /* WORKAROUND: need to be fixed */ - hid_descriptor.hid_desc.wDescriptorLength = hid_descriptor.raw_desc[7] + - (hid_descriptor.raw_desc[8]<<8); - - upsdebugx(3, "HID Descriptor: \nbLength: \t\t0x%02x\nbDescriptorType: \t0x%02x\n", - hid_descriptor.hid_desc.bLength, - hid_descriptor.hid_desc.bDescriptorType); - - upsdebugx(3, "bcdHID: \t\t0x%04x\nbCountryCode: \t\t0x%02x\nbNumDescriptors: \t0x%02x\n", - hid_descriptor.hid_desc.bcdHID, - hid_descriptor.hid_desc.bCountryCode, - hid_descriptor.hid_desc.bNumDescriptors); - - upsdebugx(3, "bReportDescriptorType: \t0x%02x\nwDescriptorLength: \t0x%04x", - hid_descriptor.hid_desc.bReportDescriptorType, - hid_descriptor.hid_desc.wDescriptorLength); - - /* Get Device descriptor */ - if((retcode = shut_get_descriptor(DEVICE_DESCRIPTOR, device_descriptor.raw_desc, 0x12)) > 0) - { - upsdebug_hex(3, "shut_get_descriptor(device)", device_descriptor.raw_desc, retcode); - - upsdebugx(2, "Device Descriptor: \nbLength: \t\t0x%02x\nbDescriptorType:\ - \t0x%02x\nbcdUSB: \t\t0x%04x\nbDeviceClass: \t\t0x%02x\nbDeviceSubClass:\ - \t0x%02x\nbDeviceProtocol: \t0x%02x\nbMaxPacketSize0:\ - \t0x%02x\nidVendor: \t\t0x%04x\nidProduct: \t\t0x%04x\nbcdDevice:\ - \t\t0x%04x\niManufacturer: \t\t0x%02x\niProduct:\ - \t\t0x%02x\niSerialNumber: \t\t0x%02x\nbNumConfigurations: \t0x%02x\n", - device_descriptor.dev_desc.bLength, - device_descriptor.dev_desc.bDescriptorType, - device_descriptor.dev_desc.bcdUSB, - device_descriptor.dev_desc.bDeviceClass, - device_descriptor.dev_desc.bDeviceSubClass, - device_descriptor.dev_desc.bDeviceProtocol, - device_descriptor.dev_desc.bMaxPacketSize0, - device_descriptor.dev_desc.idVendor, - device_descriptor.dev_desc.idProduct, - device_descriptor.dev_desc.bcdDevice, - device_descriptor.dev_desc.iManufacturer, - device_descriptor.dev_desc.iProduct, - device_descriptor.dev_desc.iSerialNumber, - device_descriptor.dev_desc.bNumConfigurations); - - /* Get Report descriptor */ - if((retcode = shut_get_descriptor(REPORT_DESCRIPTOR, raw_buf, - hid_descriptor.hid_desc.wDescriptorLength)) > 0) { - - upsdebug_hex(3, "shut_get_descriptor(report)", raw_buf, retcode); - - /* Parse Report Descriptor */ - Free_ReportDesc(pDesc); - pDesc = Parse_ReportDesc(raw_buf, retcode); - if (!pDesc) { - fatalx(EXIT_FAILURE, "Failed to parse report descriptor: %s", strerror(errno)); - } - } - else - fatalx(EXIT_FAILURE, "Unable to get Report Descriptor"); - } - else - fatalx(EXIT_FAILURE, "Unable to get Device Descriptor"); - } - else - fatalx(EXIT_FAILURE, "Unable to get HID Descriptor"); - - return 0; -} - -/* translate HID string path to numeric path and return path depth */ -ushort lookup_path(const char *HIDpath, HIDData_t *data) -{ - ushort i = 0, cond = 1; - int cur_usage; - char buf[MAX_STRING]; - char *start, *end; - - strncpy(buf, HIDpath, strlen(HIDpath)); - buf[strlen(HIDpath)] = '\0'; - start = end = buf; - - upsdebugx(3, "entering lookup_path(%s)", buf); - - while (cond) { - - if ((end = strchr(start, '.')) == NULL) { - cond = 0; - } - else - *end = '\0'; - - upsdebugx(4, "parsing %s", start); - - /* lookup code */ - if ((cur_usage = hid_lookup_usage(start)) == -1) { - upsdebugx(4, "%s wasn't found", start); - return 0; - } - else { - data->Path.Node[i] = cur_usage; - i++; - } - - if(cond) - start = end +1 ; - } - data->Path.Size = i; - return i; -} - -/* Lookup this usage name to find its code (page + index) */ -int hid_lookup_usage(char *name) -{ - int i; - - upsdebugx(4, "Looking up %s", name); - - if (name[0] == '[') /* manage indexed collection */ - return (0x00FF0000 + atoi(&name[1])); - else { - for (i = 0; (usage_lkp[i].usage_code != 0x0); i++) - { - if (!strcmp(usage_lkp[i].usage_name, name)) - { - upsdebugx(4, "hid_lookup_usage: found %04x", - usage_lkp[i].usage_code); - return usage_lkp[i].usage_code; - } - } - } - return -1; -} - -/* Get an item value from a HID path */ -int hid_get_value(const char *item_path) -{ - int i, retcode; - HIDData_t hData; - - upsdebugx(3, "entering hid_get_value(%s)", item_path); - - /* Prepare path of HID object */ - hData.Type = ITEM_FEATURE; - hData.ReportID = 0; - - if((retcode = lookup_path(item_path, &hData)) > 0) { - upsdebugx(3, "Path depth = %i\n", retcode); - - for (i = 0; i 0) { - GetValue((const u_char *) raw_buf, &hData, &hValue); - upsdebug_hex(3, "Object's report", raw_buf, 10); - upsdebugx(3, "Value = %ld", hValue); - return 1; - } - else - shut_ups_start(); - } - else { - upsdebugx(3, "Can't find object"); - return 0; - } - } - else { - upsdebugx(3, "Can't lookup object's path"); - return 0; - } - - return 0; -} - - /* - * Internal functions - ****************************************************************************/ - -/* - * Filter and reformat HID strings (suppress space - * between each letter) - * Note: string format in HID String Descriptor is - * Byte1: Size of descriptor(=>string) - * Byte2: String descriptor type (always 0x03) - * Byte3 to byteN: UNICODE string (in US: xx 00 for a letter) - */ -void make_string(u_char *buf, int datalen, char *string) -{ - int i, /* Skip size and type */ - j=0; - - upsdebugx(4, "String descriptor: size = 0x%02x, type = 0x%02x", buf[0], buf[1]); - - /* TODO: add clean support for UNICODE */ - for(i=2;i0) - return (float) a * expo(a,b-1); - if (b<0) - return (float)((float)(1/(float)a) * (float) expo(a,b+1)); - - /* not reached */ - return -1; -} - -/* Format model names */ -const char *get_model_name(char *iProduct, char *iModel) -{ - models_name_t *model = NULL; - - upsdebugx(2, "get_model_name(%s, %s)\n", iProduct, iModel); - - /* Search for formatting rules */ - for ( model = models_names ; model->iProduct != NULL ; model++ ) - { - upsdebugx(2, "comparing with: %s", model->finalname); - if ( (!strncmp(iProduct, model->iProduct, strlen(model->iProduct))) - && (!strncmp(iModel, model->iModel, strlen(model->iModel))) ) - { - upsdebugx(2, "Found %s\n", model->finalname); - break; - } - } - /* FIXME: if we end up with model->iProduct == NULL - * then process name in a generic way (not yet supported models!) - */ - return model->finalname; -} - -/* set r/w INFO_ element to a value. */ -int hid_set_value(const char *varname, const char *val) -{ - int retcode, i, replen; - mge_info_item_t *shut_info_p; - HIDData_t hData; - - upsdebugx(2, "============== entering hid_set_value(%s, %s) ==============", varname, val); - - /* 1) retrieve and check netvar & item_path */ - shut_info_p = shut_find_info(varname); - - if (shut_info_p == NULL || shut_info_p->type == NULL || - !(shut_info_p->flags & SHUT_FLAG_OK)) - { - upsdebugx(2, "hid_ups_set: info element unavailable %s", varname); - return STAT_SET_UNKNOWN; - } - - /* Checking item writability and HID Path */ - if (!shut_info_p->flags & ST_FLAG_RW) { - upsdebugx(2, "hid_ups_set: not writable %s", varname); - return STAT_SET_UNKNOWN; - } - - /* handle server side variable */ - if (shut_info_p->shut_flags & SHUT_FLAG_ABSENT) { - upsdebugx(2, "hid_ups_set: setting server side variable %s", varname); - dstate_setinfo(shut_info_p->type, "%s", val); - return STAT_SET_HANDLED; - } else { - /* SHUT_FLAG_ABSENT is the only case of HID Path == NULL */ - if (shut_info_p->item_path == NULL) { - upsdebugx(2, "hid_ups_set: ID Path is NULL for %s", varname); - return STAT_SET_UNKNOWN; - } - } - - /* Prepare path of HID object */ - hData.Type = ITEM_FEATURE; - hData.ReportID = 0; - - if((retcode = lookup_path(shut_info_p->item_path, &hData)) > 0) { - upsdebugx(3, "Path depth = %i\n", retcode); - - for (i = 0; i disabled for now - if (shut_get_report(hData.ReportID, raw_buf, MAX_REPORT_SIZE) > 0) { - GetValue((const u_char *) raw_buf, &hData, &hValue); - upsdebugx(3, "Value = %d", hValue); - - if (hValue != atol(val)) - upsdebugx(3, "FAILED"); - else - upsdebugx(3, "SUCCEED"); - } else - upsdebugx(3, "FAILED"); - */ - return STAT_SET_HANDLED; - } - else - upsdebugx(3, "Object is constant"); - } - else - upsdebugx(3, "Can't find object"); - } - else - upsdebugx(3, "Can't lookup object's path"); - - return STAT_SET_UNKNOWN; -} - -/* find info element definition in my info array. */ -mge_info_item_t *shut_find_info(const char *varname) -{ - mge_info_item_t *shut_info_p; - - for (shut_info_p = &mge_info[0]; shut_info_p->type != NULL; shut_info_p++) - if (!strcasecmp(shut_info_p->type, varname)) - return shut_info_p; - - fatalx(EXIT_FAILURE, "shut_find_info: unknown info type: %s", varname); - return NULL; -} - -/* find the NUT value matching that HID Item value */ -static const char *hu_find_infoval(info_lkp_t *hid2info, long value) -{ - info_lkp_t *info_lkp; - - upsdebugx(3, "hu_find_infoval: searching for value = %ld\n", value); - - for (info_lkp = hid2info; (info_lkp != NULL) && - (strcmp(info_lkp->nut_value, "NULL")); info_lkp++) { - - if (info_lkp->hid_value == value) { - upsdebugx(3, "hu_find_infoval: found %s (value: %ld)\n", - info_lkp->nut_value, value); - - return info_lkp->nut_value; - } - } - upsdebugx(3, "hu_find_infoval: no matching INFO_* value for this HID value (%ld)\n", value); - return NULL; -} diff --git a/drivers/mge-shut.h b/drivers/mge-shut.h deleted file mode 100644 index 850be4d..0000000 --- a/drivers/mge-shut.h +++ /dev/null @@ -1,523 +0,0 @@ -/* mge-shut.h - monitor MGE UPS for NUT with SHUT protocol - * - * Copyright (C) 2002 - 2005 - * Arnaud Quette & - * Philippe Marzouk - * - * Sponsored by MGE UPS SYSTEMS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "hidparser.h" -#include "hidtypes.h" - -#define DEFAULT_TIMEOUT 3000 -#define MAX_STRING 64 - -#define DEFAULT_LOWBATT 30 /* low battery level, in % */ -#define DEFAULT_ONDELAY 3 /* delay between return of utility power - and powering up of load, in 10 seconds units */ -#define DEFAULT_OFFDELAY 20 /* delay befor power off, in seconds */ -#define OFF_NOTIFICATION 1 /* notification off */ - -#define LIGHT_NOTIFICATION 2 /* light notification */ -#define COMPLETE_NOTIFICATION 3 /* complete notification for UPSs which do - * not support disabling it like some early - * Ellipse models */ -#define DEFAULT_NOTIFICATION COMPLETE_NOTIFICATION - -/* HID definitions */ - -#define HID_REPORT_TYPE_INPUT 0x01 -#define HID_REPORT_TYPE_OUTPUT 0x02 -#define HID_REPORT_TYPE_FEATURE 0x03 - -#define REQUEST_TYPE_USB 0x80 -#define REQUEST_TYPE_HID 0x81 -#define REQUEST_TYPE_GET_REPORT 0xa1 -#define REQUEST_TYPE_SET_REPORT 0x21 - -#define DEVICE_DESCRIPTOR 0x0001 -#define CONFIG_DESCRIPTOR 0x0002 -#define STRING_DESCRIPTOR 0x0003 -#define INTERFACE_DESCRIPTOR 0x0004 -#define ENDPOINT_DESCRIPTOR 0x0005 -#define HID_DESCRIPTOR 0x0021 -#define REPORT_DESCRIPTOR 0x0022 - -#define MAX_REPORT_SIZE 0x1800 - -/* SHUT definitions - From Simplified SHUT spec */ - -#define SHUT_TYPE_REQUEST 0x01 -#define SHUT_TYPE_RESPONSE 0x04 -#define SHUT_TYPE_NOTIFY 0x05 -#define SHUT_OK 0x06 -#define SHUT_NOK 0x15 -#define SHUT_SYNC 0x16 /* complete notifications - not yet managed - but needed for some early Ellipse models */ -#define SHUT_SYNC_LIGHT 0x17 /* partial notifications */ -#define SHUT_SYNC_OFF 0x18 /* disable notifications - only do polling */ -#define SHUT_PKT_LAST 0x80 - -/* From SHUT specifications */ - -typedef struct hid_packet { - unsigned char bmRequestType; - unsigned char bRequest; - unsigned short wValue; - unsigned short wIndex; - unsigned short wLength; -/* unsigned char padding[8]; for use with shut_set_report */ -} hid_packet_t; - -typedef union hid_data_u { - hid_packet_t hid_pkt; - unsigned char raw_pkt[8]; /* max report lengh, was 8 */ -} hid_data_t; - -typedef struct shut_packet { - unsigned char bType; - unsigned char bLength; - hid_data_t data; - unsigned char bChecksum; -} shut_packet_t; - -typedef union shut_data_u { - shut_packet_t shut_pkt; - unsigned char raw_pkt[11]; -} shut_data_t; - -/* From USB/HID specifications */ - -typedef struct hid_descriptor { - unsigned char bLength; - unsigned char bDescriptorType; - unsigned short bcdHID; - unsigned char bCountryCode; - unsigned char bNumDescriptors; - unsigned char bReportDescriptorType; - unsigned short wDescriptorLength; -} hid_descriptor_t; - -typedef union hid_desc_data_u { - hid_descriptor_t hid_desc; - unsigned char raw_desc[9]; /* max report lengh, aws 9 */ -} hid_desc_data_t; - -typedef struct device_descriptor { - unsigned char bLength; - unsigned char bDescriptorType; - unsigned short bcdUSB; - unsigned char bDeviceClass; - unsigned char bDeviceSubClass; - unsigned char bDeviceProtocol; - unsigned char bMaxPacketSize0; - unsigned short idVendor; - unsigned short idProduct; - unsigned short bcdDevice; - unsigned char iManufacturer; - unsigned char iProduct; - unsigned char iSerialNumber; - unsigned char bNumConfigurations; -} device_descriptor_t; - -typedef union device_desc_data_u { - device_descriptor_t dev_desc; - unsigned char raw_desc[18]; -} device_desc_data_t; - -/* --------------------------------------------------------------- */ -/* Explicit Booleans */ -/* --------------------------------------------------------------- */ - -#define SHUT_FLAG_OK (1 << 0) /* show element to upsd. */ -#define SHUT_FLAG_STATIC (1 << 1) /* retrieve info only once. */ -#define SHUT_FLAG_ABSENT (1 << 2) /* data is absent in the device, - use default value. */ -#define SHUT_FLAG_STALE (1 << 3) /* data stale, don't try too often. */ -#define SHUT_FLAG_DELAY (1 << 4) /* delay type value: formated differently. */ - -/* --------------------------------------------------------------- */ -/* Model Name formating entries */ -/* --------------------------------------------------------------- */ -typedef struct { - const char *iProduct; - const char *iModel; - const char *finalname; -} models_name_t; - -models_name_t models_names [] = - { - /* Ellipse models */ - { "ELLIPSE", "300", "ellipse 300" }, - { "ELLIPSE", "500", "ellipse 500" }, - { "ELLIPSE", "650", "ellipse 650" }, - { "ELLIPSE", "800", "ellipse 800" }, - { "ELLIPSE", "1200", "ellipse 1200" }, - /* Ellipse Premium models */ - { "ellipse", "PR500", "ellipse premium 500" }, - { "ellipse", "PR650", "ellipse premium 650" }, - { "ellipse", "PR800", "ellipse premium 800" }, - { "ellipse", "PR1200", "ellipse premium 1200" }, - /* Ellipse "Pro" */ - { "ELLIPSE", "600", "Ellipse 600" }, - { "ELLIPSE", "750", "Ellipse 750" }, - { "ELLIPSE", "1000", "Ellipse 1000" }, - { "ELLIPSE", "1500", "Ellipse 1500" }, - /* Ellipse "MAX" */ - { "Ellipse MAX", "600", "Ellipse MAX 600" }, - { "Ellipse MAX", "850", "Ellipse MAX 850" }, - { "Ellipse MAX", "1100", "Ellipse MAX 1100" }, - { "Ellipse MAX", "1500", "Ellipse MAX 1500" }, - /* Protection Center */ - { "PROTECTIONCENTER", "420", "Protection Center 420" }, - { "PROTECTIONCENTER", "500", "Protection Center 500" }, - { "PROTECTIONCENTER", "675", "Protection Center 675" }, - /* Pulsar Evolution models */ - { "Evolution", "500", "Pulsar Evolution 500" }, - { "Evolution", "800", "Pulsar Evolution 800" }, - { "Evolution", "1100", "Pulsar Evolution 1100" }, - { "Evolution", "1500", "Pulsar Evolution 1500" }, - { "Evolution", "2200", "Pulsar Evolution 2200" }, - { "Evolution", "3000", "Pulsar Evolution 3000" }, - { "Evolution", "3000XL", "Pulsar Evolution 3000 XL" }, - /* Newer Evolution models */ - { "Evolution", "650", "Evolution 650" }, - { "Evolution", "850", "Evolution 850" }, - { "Evolution", "1150", "Evolution 1150" }, - { "Evolution", "S 1250", "Evolution S 1250" }, - { "Evolution", "1550", "Evolution 1550" }, - { "Evolution", "S 1750", "Evolution S 1750" }, - { "Evolution", "2000", "Evolution 2000" }, - { "Evolution", "S 2500", "Evolution S 2500" }, - { "Evolution", "S 3000", "Evolution S 3000" }, - /* Pulsar M models */ - { "PULSAR M", "2200", "Pulsar M 2200" }, - { "PULSAR M", "3000", "Pulsar M 3000" }, - { "PULSAR M", "3000 XL", "Pulsar M 3000 XL" }, - /* Eaton'ified names */ - { "EX", "2200", "EX 2200" }, - { "EX", "3000", "EX 3000" }, - { "EX", "3000 XL", "EX 3000 XL" }, - /* Pulsar models */ - { "Pulsar", "700", "Pulsar 700" }, - { "Pulsar", "1000", "Pulsar 1000" }, - { "Pulsar", "1500", "Pulsar 1500" }, - { "Pulsar", "1000 RT2U", "Pulsar 1000 RT2U" }, - { "Pulsar", "1500 RT2U", "Pulsar 1500 RT2U" }, - /* Eaton'ified names */ - { "EX", "700", "EX 700" }, - { "EX", "1000", "EX 1000" }, - { "EX", "1500", "EX 1500" }, - { "EX", "1000 RT2U", "EX 1000 RT2U" }, - { "EX", "1500 RT2U", "EX 1500 RT2U" }, - /* Pulsar MX models */ - { "PULSAR", "MX4000", "Pulsar MX 4000 RT" }, - { "PULSAR", "MX5000", "Pulsar MX 5000 RT" }, - /* NOVA models */ - { "NOVA AVR", "600", "NOVA 600 AVR" }, - { "NOVA AVR", "625", "Nova AVR 625" }, - { "NOVA AVR", "1100", "NOVA 1100 AVR" }, - { "NOVA AVR", "1250", "Nova AVR 1250" }, - /* EXtreme C (EMEA) */ - { "EXtreme", "700C", "Pulsar EXtreme 700C" }, - { "EXtreme", "1000C", "Pulsar EXtreme 1000C" }, - { "EXtreme", "1500C", "Pulsar EXtreme 1500C" }, - { "EXtreme", "1500CCLA", "Pulsar EXtreme 1500C CLA" }, - { "EXtreme", "2200C", "Pulsar EXtreme 2200C" }, - { "EXtreme", "3200C", "Pulsar EXtreme 3200C" }, - /* EXtreme C (USA, aka "EX RT") */ - { "EX", "700RT", "Pulsar EX 700 RT" }, - { "EX", "1000RT", "Pulsar EX 1000 RT" }, - { "EX", "1500RT", "Pulsar EX 1500 RT" }, - { "EX", "2200RT", "Pulsar EX 2200 RT" }, - { "EX", "3200RT", "Pulsar EX 3200 RT" }, - /* Comet EX RT three phased */ - { "EX", "5RT31", "EX 5 RT 3:1" }, - { "EX", "7RT31", "EX 7 RT 3:1" }, - { "EX", "11RT31", "EX 11 RT 3:1" }, - /* Comet EX RT single phased */ - { "EX", "5RT", "EX 5 RT" }, - { "EX", "7RT", "EX 7 RT" }, - { "EX", "11RT", "EX 11 RT" }, - /* Galaxy 3000 */ - { "GALAXY", "3000_10", "Galaxy 3000 10 kVA" }, - { "GALAXY", "3000_15", "Galaxy 3000 15 kVA" }, - { "GALAXY", "3000_20", "Galaxy 3000 20 kVA" }, - { "GALAXY", "3000_30", "Galaxy 3000 30 kVA" }, - - /* FIXME: To be completed (Comet, Galaxy, Esprit, ...) */ - - /* end of structure. */ - { NULL, NULL, "Generic SHUT model" } -}; -/* for lookup between HID values and NUT values*/ -typedef struct { - long hid_value; /* HID value */ - const char *nut_value; /* NUT value */ -} info_lkp_t; - -/* Actual value lookup tables => should be fine for all Mfrs (TODO: validate it!) */ -/* --------------------------------------------------------------- */ -/* Lookup values between NUT and HID */ -/* --------------------------------------------------------------- */ -info_lkp_t onbatt_info[] = { - { 0, "OB" }, - { 1, "OL" }, - { 0, "NULL" } -}; -info_lkp_t discharging_info[] = { - { 1, "DISCHRG" }, - { 0, "NULL" } -}; -info_lkp_t charging_info[] = { - { 1, "CHRG" }, - { 0, "NULL" } -}; -info_lkp_t lowbatt_info[] = { - { 1, "LB" }, - { 0, "NULL" } -}; -info_lkp_t overbatt_info[] = { - { 1, "OVER" }, - { 0, "NULL" } -}; -info_lkp_t replacebatt_info[] = { - { 1, "RB" }, - { 0, "NULL" } -}; -info_lkp_t shutdownimm_info[] = { - { 1, "LB" }, - { 0, "NULL" } -}; -info_lkp_t trim_info[] = { - { 1, "TRIM" }, - { 0, "NULL" } -}; -info_lkp_t boost_info[] = { - { 1, "BOOST" }, - { 0, "NULL" } -}; -/* TODO: add BYPASS, OFF, CAL */ - -info_lkp_t test_write_info[] = { - { 0, "No test" }, - { 1, "Quick test" }, - { 2, "Deep test" }, - { 3, "Abort test" }, - { 0, "NULL" } -}; -info_lkp_t test_read_info[] = { - { 1, "Done and passed" }, - { 2, "Done and warning" }, - { 3, "Done and error" }, - { 4, "Aborted" }, - { 5, "In progress" }, - { 6, "No test initiated" }, - { 0, "NULL" } -}; - -/* --------------------------------------------------------------- */ -/* Query Commands and their Mapping to INFO_ Variables */ -/* --------------------------------------------------------------- */ - -/* Structure defining how to query UPS for a variable and write - information to INFO structure. -*/ -typedef struct { - const char *type; /* INFO_* element */ - int flags; /* INFO-element flags to set in addinfo */ - int length; /* INFO-element length of strings */ - const char *item_path; /* HID object (fully qualified string path) */ - const char *fmt; /* printf format string for INFO entry */ - const char *dfl; /* default value */ - unsigned long shut_flags; /* specific SHUT flags */ - info_lkp_t *hid2info; /* lookup table between HID and NUT values */ -} mge_info_item_t; - -/* Array containing information to translate between UTalk and NUT info - * NOTE: - * - Array is terminated by element with type NULL. - * - Essential INFO items (ups.{mfr, model, firmware, status} are - * handled separately. - * - Array is NOT const, since "shut_flags" can be changed. - */ - -/* FIXME: should be shared with mgehid.h */ -static mge_info_item_t mge_info[] = { - /* Battery page */ - { "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", "%i", NULL, SHUT_FLAG_OK, NULL }, - { "battery.charge.low", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerSummary.RemainingCapacityLimitSetting", - "%ld", NULL, SHUT_FLAG_OK, NULL }, /* RW, to be caught first if exists... */ - { "battery.charge.low", ST_FLAG_STRING, 5, "UPS.PowerSummary.RemainingCapacityLimit", - "%ld", NULL, SHUT_FLAG_OK, NULL }, /* ... or Read only */ - { "battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", "%.0d", NULL, SHUT_FLAG_OK, NULL }, - /* UPS page */ - { "ups.mfr", ST_FLAG_STRING, 20, NULL, "%s", "MGE UPS SYSTEMS", SHUT_FLAG_ABSENT | SHUT_FLAG_OK, NULL }, - { "ups.load", 0, 0, "UPS.PowerSummary.PercentLoad", "%i", NULL, SHUT_FLAG_OK, NULL }, - { "ups.timer.shutdown", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerSummary.DelayBeforeShutdown", - "%ld", NULL, SHUT_FLAG_OK | SHUT_FLAG_DELAY, NULL }, - { "ups.timer.reboot", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerSummary.DelayBeforeReboot", - "%ld", NULL, SHUT_FLAG_OK | SHUT_FLAG_DELAY, NULL }, - { "ups.timer.start", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.PowerSummary.DelayBeforeStartup", - "%ld", NULL, SHUT_FLAG_OK | SHUT_FLAG_DELAY, NULL }, - /* FIXME: miss ups.power */ - { "ups.power.nominal", ST_FLAG_STRING, 5, "UPS.Flow.[4].ConfigApparentPower", - "%i", NULL, SHUT_FLAG_OK, NULL }, - { "ups.test.interval", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.BatterySystem.Battery.TestPeriod", - "%i", NULL, SHUT_FLAG_OK, NULL }, - { "ups.test.result", ST_FLAG_STRING, 5, "UPS.BatterySystem.Battery.Test", - "%i", NULL, SHUT_FLAG_OK, &test_read_info[0] }, - - /* Output page */ - { "output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", "%i", NULL, SHUT_FLAG_OK, NULL }, - { "output.voltage.nominal", 0, 0, "UPS.PowerSummary.ConfigVoltage", "%i", NULL, SHUT_FLAG_OK, NULL }, - { "output.current", 0, 0, "UPS.PowerSummary.Output.Current", "%i", NULL, SHUT_FLAG_OK, NULL }, - { "output.frequency", 0, 0, "UPS.PowerConverter.Output.Frequency", "%i", NULL, SHUT_FLAG_OK, NULL }, - - /* Outlet page (using MGE UPS SYSTEMS - PowerShare technology) */ - /* TODO: add an iterative semantic [%x] to factorise outlets */ - { "outlet.id", 0, 0, "UPS.OutletSystem.Outlet.[1].OutletID", "%i", NULL, SHUT_FLAG_OK, NULL }, - { "outlet.desc", ST_FLAG_RW | ST_FLAG_STRING, 20, "UPS.OutletSystem.Outlet.[1].OutletID", - "%s", "Main Outlet", SHUT_FLAG_ABSENT | SHUT_FLAG_OK, NULL }, - { "outlet.switchable", 0, 0, "UPS.OutletSystem.Outlet.[1].PresentStatus.Switchable", - "%i", NULL, SHUT_FLAG_OK, NULL }, - { "outlet.1.id", 0, 0, "UPS.OutletSystem.Outlet.[2].OutletID", "%i", NULL, SHUT_FLAG_OK, NULL }, - { "outlet.1.desc", ST_FLAG_RW | ST_FLAG_STRING, 20, "UPS.OutletSystem.Outlet.[2].OutletID", - "%s", "PowerShare Outlet 1", SHUT_FLAG_ABSENT | SHUT_FLAG_OK, NULL }, - { "outlet.1.switchable", 0, 0, "UPS.OutletSystem.Outlet.[2].PresentStatus.Switchable", - "%i", NULL, SHUT_FLAG_OK, NULL }, - { "outlet.1.switch", ST_FLAG_RW | ST_FLAG_STRING, 2, "UPS.OutletSystem.Outlet.[2].PresentStatus.SwitchOn/Off", - "%i", NULL, SHUT_FLAG_OK, NULL }, - { "outlet.1.autoswitch.charge.low", ST_FLAG_RW | ST_FLAG_STRING, 3, - "UPS.OutletSystem.Outlet.[2].RemainingCapacityLimit", "%i", NULL, SHUT_FLAG_OK, NULL }, - { "outlet.1.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING, 5, - "UPS.OutletSystem.Outlet.[2].DelayBeforeShutdown", "%i", NULL, SHUT_FLAG_OK, NULL }, - { "outlet.1.delay.start", ST_FLAG_RW | ST_FLAG_STRING, 5, "UPS.OutletSystem.Outlet.[2].DelayBeforeStartup", "%i", NULL, SHUT_FLAG_OK, NULL }, - { "outlet.2.id", 0, 0, "UPS.OutletSystem.Outlet.[3].OutletID", "%i", NULL, SHUT_FLAG_OK, NULL }, - { "outlet.2.desc", ST_FLAG_RW | ST_FLAG_STRING, 20, "UPS.OutletSystem.Outlet.[3].OutletID", - "%s", "PowerShare Outlet 2", SHUT_FLAG_ABSENT | SHUT_FLAG_OK, NULL }, - { "outlet.2.switchable", 0, 0, "UPS.OutletSystem.Outlet.[3].PresentStatus.Switchable", - "%i", NULL, SHUT_FLAG_OK, NULL }, - { "outlet.2.switch", ST_FLAG_RW | ST_FLAG_STRING, 2, "UPS.OutletSystem.Outlet.[3].PresentStatus.SwitchOn/Off", - "%i", NULL, SHUT_FLAG_OK, NULL }, - { "outlet.2.autoswitch.charge.low", ST_FLAG_RW | ST_FLAG_STRING, 3, - "UPS.OutletSystem.Outlet.[3].RemainingCapacityLimit", "%i", NULL, SHUT_FLAG_OK, NULL }, - { "outlet.2.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING, 5, - "UPS.OutletSystem.Outlet.[3].DelayBeforeShutdown", "%i", NULL, SHUT_FLAG_OK, NULL }, - { "outlet.2.delay.start", ST_FLAG_RW | ST_FLAG_STRING, 5, - "UPS.OutletSystem.Outlet.[3].DelayBeforeStartup", "%i", NULL, SHUT_FLAG_OK, NULL }, - - /* Input page */ - { "input.voltage", 0, 0, "UPS.PowerConverter.Input.[1].Voltage", "%i", NULL, SHUT_FLAG_OK, NULL }, - { "input.frequency", 0, 0, "UPS.PowerConverter.Input.[1].Frequency", "%i", NULL, SHUT_FLAG_OK, NULL }, - - /* terminating element */ - { NULL, 0, 0, "\0", "\0", NULL, 0, NULL } -}; - -/* temporary usage code lookup */ -typedef struct { - const char *usage_name; - const uint32_t usage_code; -} usage_lkp_t; - -/* FIXME: share this data structure with libhid.c */ -static usage_lkp_t usage_lkp[] = { - /* Power Device Page */ - { "PresentStatus", 0x00840002 }, - { "UPS", 0x00840004 }, - { "BatterySystem", 0x00840010 }, - { "Battery", 0x00840012 }, - { "BatteryID", 0x00840013 }, - { "PowerConverter", 0x00840016 }, - { "OutletSystem", 0x00840018 }, - { "Input", 0x0084001a }, - { "Output", 0x0084001c }, - { "Outlet", 0x00840020 }, - { "OutletID", 0x00840021 }, - { "PowerSummary", 0x00840024 }, - { "Voltage", 0x00840030 }, - { "Current", 0x00840031 }, - { "Frequency", 0x00840032 }, - { "PercentLoad", 0x00840035 }, - { "ConfigVoltage", 0x00840040 }, - { "ConfigCurrent", 0x00840041 }, - { "ConfigFrequency", 0x00840042 }, - { "ConfigApparentPower", 0x00840043 }, - { "LowVoltageTransfer", 0x00840053 }, - { "HighVoltageTransfer", 0x00840054 }, - { "DelayBeforeReboot", 0x00840055 }, - { "DelayBeforeStartup", 0x00840056 }, - { "DelayBeforeShutdown", 0x00840057 }, - { "Test", 0x00840058 }, - { "Good", 0x00840061 }, - { "Overload", 0x00840065 }, /* sic */ - { "SwitchOn/Off", 0x0084006b }, - { "Switchable", 0x0084006c }, - { "Used", 0x0084006d }, - { "Flow", 0x0084001e }, - /* Battery System Page */ - { "RemainingCapacityLimit", 0x00850029 }, - { "BelowRemainingCapacityLimit", 0x00850042 }, - { "RemainingCapacity", 0x00850066 }, - { "RunTimeToEmpty", 0x00850068 }, - { "ACPresent", 0x008500d0 }, - { "Charging", 0x00850044 }, - { "Discharging", 0x00850045 }, - { "NeedReplacement", 0x0085004b }, - /* MGE UPS SYSTEMS Page */ - { "iModel", 0xffff00f0 }, - { "RemainingCapacityLimitSetting", 0xffff004d }, - { "TestPeriod", 0xffff0001 }, - - { "\0", 0x0 } -}; - -/* SHUT / HID functions Prototypes */ - -int shut_ups_start(void); -u_char shut_checksum(const u_char *buf, int bufsize); -int shut_token_send(u_char token); -int shut_packet_send (hid_data_t *hdata, int datalen, u_char token); -int shut_packet_recv (u_char *Buf, int datalen); - -int shut_get_descriptor(int desctype, u_char *pkt, int reportlen); -int shut_get_string(int strindex, char *string, int stringlen); -int shut_get_report(int id, u_char *pkt, int reportlen); -int shut_set_report(int id, u_char *pkt, int reportlen); -int shut_identify_ups (void); -int shut_wait_ack (void); -void shut_ups_status(void); - -int hid_init_device(void); -const char *get_model_name(char *iProduct, char *iModel); -int hid_lookup_usage(char *name); -int hid_get_value(const char *item_path); -int hid_set_value(const char *varname, const char *val); -u_short lookup_path(const char *HIDpath, HIDData_t *data); - -int instcmd(const char *cmdname, const char *extra); -void setline(int set); -int serial_read (int read_timeout, u_char *readbuf); -int serial_send(u_char *buf, int len); - -void make_string(u_char *buf, int datalen, char *string); - - -mge_info_item_t *shut_find_info(const char *varname); diff --git a/drivers/mge-utalk.c b/drivers/mge-utalk.c index 2935e91..86d272f 100644 --- a/drivers/mge-utalk.c +++ b/drivers/mge-utalk.c @@ -30,41 +30,44 @@ /* * IMPLEMENTATION DETAILS - * + * * Not all UTalk models provide all possible information, settings and commands. * mge-utalk checks on startup which variables and commands are available from * the UPS, and re-reads these regularly. Thus, startup is a bit slow, but this * should not matter much. - * + * * mge-utalk.h defines a struct array that tells the driver how to read * variables from the UPS and publish them as NUT data. - * + * * "ups.status" variable is not included in this array, since it contains * information that requires several calls to the UPS and more advanced analysis * of the reponses. The function get_ups_status does this job. - * + * * Note that MGE enumerates the status "bits" from right to left, * i.e., if buf[] contains the reponse to command "Ss" (read system status), * then buf[0] contains "bit" Ss.1.7 (General alarm), while buf[7] contains - * "bit" Ss.1.0 (Load unprotected). - * + * "bit" Ss.1.0 (Load unprotected). + * * enable_ups_comm() is called before each attempt to read/write data * from/to the UPS to re synchronise the communication. */ +#include "config.h" /* must be the first header */ + #include #include #include "timehead.h" #include "main.h" #include "serial.h" #include "mge-utalk.h" +#include "nut_stdint.h" /* --------------------------------------------------------------- */ /* Define "technical" constants */ /* --------------------------------------------------------------- */ #define DRIVER_NAME "MGE UPS SYSTEMS/U-Talk driver" -#define DRIVER_VERSION "0.93" +#define DRIVER_VERSION "0.94" /* driver description structure */ @@ -96,12 +99,12 @@ upsdrv_info_t upsdrv_info = { #define MGE_REPLY_IGNCHAR "\r\n" #define MAXTRIES 10 /* max number of connect tries */ -#define BUFFLEN 256 +#define BUFFLEN 256 #define SD_RETURN 0 #define SD_STAYOFF 1 -int sdtype = SD_RETURN; +static int sdtype = SD_RETURN; static time_t lastpoll; /* Timestamp the last polling */ /* --------------------------------------------------------------- */ @@ -124,12 +127,12 @@ static int instcmd(const char *cmdname, const char *extra); static int setvar(const char *varname, const char *val); static void enable_ups_comm(void); static void disable_ups_comm(void); -static void extract_info(const char *buf, const mge_info_item_t *mge, - char *infostr, int infolen); +static void extract_info(const char *buf, const mge_info_item_t *mge, + char *infostr, size_t infolen); static const char *info_variable_cmd(const char *type); static bool_t info_variable_ok(const char *type); static int get_ups_status(void); -static int mge_command(char *reply, int replylen, const char *fmt, ...); +static ssize_t mge_command(char *reply, size_t replylen, const char *fmt, ...); /* --------------------------------------------------------------- */ /* UPS Driver Functions */ @@ -139,17 +142,17 @@ void upsdrv_makevartable(void) { char temp[BUFFLEN]; - snprintf(temp, sizeof(temp), - "Low battery level, in %% (default = %3d)", + snprintf(temp, sizeof(temp), + "Low battery level, in %% (default = %3d)", DEFAULT_LOWBATT); addvar (VAR_VALUE, "LowBatt", temp); - snprintf(temp, sizeof(temp), + snprintf(temp, sizeof(temp), "Delay before startup, in minutes (default = %3d)", DEFAULT_ONDELAY); addvar (VAR_VALUE, "OnDelay", temp); - snprintf(temp, sizeof(temp), + snprintf(temp, sizeof(temp), "Delay before shutdown, in seconds (default = %3d)", DEFAULT_OFFDELAY); addvar (VAR_VALUE, "OffDelay", temp); @@ -163,14 +166,14 @@ void upsdrv_initups(void) { char buf[BUFFLEN]; int RTS = TIOCM_RTS; - + upsfd = ser_open(device_path); ser_set_speed(upsfd, device_path, B2400); /* read command line/conf variable that affect comm. */ if (testvar ("oldmac")) RTS = ~TIOCM_RTS; - + /* Init serial line */ ioctl(upsfd, TIOCMBIC, &RTS); enable_ups_comm(); @@ -224,18 +227,18 @@ void upsdrv_initinfo(void) int table; int tries; int status_ok = 0; - int bytes_rcvd; + ssize_t bytes_rcvd; int si_data1 = 0; int si_data2 = 0; mge_info_item_t *item; models_name_t *model_info; mge_model_info_t *legacy_model; char infostr[32]; - int chars_rcvd; + ssize_t chars_rcvd; /* manufacturer -------------------------------------------- */ dstate_setinfo("ups.mfr", "MGE UPS SYSTEMS"); - + /* loop until we have at status */ tries = 0; do { @@ -320,13 +323,13 @@ void upsdrv_initinfo(void) } } - if ( firmware && strcmp(firmware, "")) + if (firmware && firmware[0] != '\0') dstate_setinfo("ups.firmware", "%s", firmware); else dstate_setinfo("ups.firmware", "unknown"); - + /* multiplier table */ - /* */ + /* */ bytes_rcvd = mge_command(buf, sizeof(buf), "Ai"); if (bytes_rcvd > 0 && buf[0] != '?') { @@ -341,7 +344,7 @@ void upsdrv_initinfo(void) /* status --- try only system status, to get the really important * information (OL, OB, LB); all else is added later by updateinfo */ status_ok = get_ups_status(); - + } while ( (!status_ok) && (tries++ < MAXTRIES) && (exit_flag != 1) ); if ( tries == MAXTRIES && !status_ok ) @@ -359,7 +362,7 @@ void upsdrv_initinfo(void) /* send request, read answer */ chars_rcvd = mge_command(buf, sizeof(buf), item->cmd); - + if ( chars_rcvd < 1 || buf[0] == '?' ) { item->ok = FALSE; upsdebugx(1, "initinfo: %s unavailable", item->type); @@ -404,7 +407,7 @@ void upsdrv_updateinfo(void) char buf[BUFFLEN]; char infostr[32]; int status_ok; - int bytes_rcvd; + ssize_t bytes_rcvd; mge_info_item_t *item; /* make sure that communication is enabled */ @@ -425,7 +428,7 @@ void upsdrv_updateinfo(void) } /* Don't overload old units (at startup) */ - if ( (unsigned int)time(NULL) <= (unsigned int)(lastpoll + poll_interval) ) + if ( time(NULL) <= (lastpoll + poll_interval) ) return; /* update all other ok variables */ @@ -437,7 +440,7 @@ void upsdrv_updateinfo(void) if ( item->ok ) { /* send request, read answer */ bytes_rcvd = mge_command(buf, sizeof(buf), item->cmd); - + if ( bytes_rcvd > 0 && buf[0] != '?' ) { extract_info(buf, item, infostr, sizeof(infostr)); dstate_setinfo(item->type, "%s", infostr); @@ -468,10 +471,10 @@ void upsdrv_shutdown(void) if (sdtype == SD_RETURN) { /* enable automatic restart */ mge_command(buf, sizeof(buf), "Sx 5"); - + upslogx(LOG_INFO, "UPS response to Automatic Restart was %s", buf); } - + /* Only call the effective shutoff if restart is ok */ /* or if we need only a stayoff... */ if (!strcmp(buf, "OK") || (sdtype == SD_STAYOFF)) { @@ -506,7 +509,7 @@ int instcmd(const char *cmdname, const char *extra) { mge_command(temp, sizeof(temp), "Bx 1"); upsdebugx(2, "UPS response to %s was %s", cmdname, temp); - + if(strcmp(temp, "OK")) return STAT_INSTCMD_UNKNOWN; else @@ -518,7 +521,7 @@ int instcmd(const char *cmdname, const char *extra) { mge_command(temp, sizeof(temp), "Sx 129"); upsdebugx(2, "UPS response to %s was %s", cmdname, temp); - + if(strcmp(temp, "OK")) return STAT_INSTCMD_UNKNOWN; else @@ -531,13 +534,13 @@ int instcmd(const char *cmdname, const char *extra) sdtype = SD_STAYOFF; upsdrv_shutdown(); } - + if (!strcasecmp(cmdname, "shutdown.return")) { sdtype = SD_RETURN; upsdrv_shutdown(); } - + /* Power Off [all] plugs */ if (!strcasecmp(cmdname, "load.off")) { @@ -550,10 +553,10 @@ int instcmd(const char *cmdname, const char *extra) else { mge_command(temp, sizeof(temp), "Wx 0"); - upsdebugx(2, "UPS response to %s was %s", cmdname, temp); + upsdebugx(2, "UPS response to %s was %s", cmdname, temp); if(strcmp(temp, "OK")) return STAT_INSTCMD_UNKNOWN; - else + else return STAT_INSTCMD_HANDLED; } } @@ -570,16 +573,16 @@ int instcmd(const char *cmdname, const char *extra) else { mge_command(temp, sizeof(temp), "Wx 1"); - upsdebugx(2, "UPS response to %s was %s", cmdname, temp); + upsdebugx(2, "UPS response to %s was %s", cmdname, temp); if(strcmp(temp, "OK")) return STAT_INSTCMD_UNKNOWN; - else + else return STAT_INSTCMD_HANDLED; } } /* Switch on/off Maintenance Bypass */ - if ((!strcasecmp(cmdname, "bypass.start")) + if ((!strcasecmp(cmdname, "bypass.start")) || (!strcasecmp(cmdname, "bypass.stop"))) { /* TODO: add control on bypass value */ @@ -596,17 +599,17 @@ int instcmd(const char *cmdname, const char *extra) /* Enable Maintenance Bypass */ mge_command(temp, sizeof(temp), "Px 3"); } - + upsdebugx(2, "UPS response to %s was %s", cmdname, temp); - + if(strcmp(temp, "OK")) return STAT_INSTCMD_UNKNOWN; else return STAT_INSTCMD_HANDLED; } } - - upslogx(LOG_NOTICE, "instcmd: unknown command [%s]", cmdname); + + upslogx(LOG_NOTICE, "instcmd: unknown command [%s] [%s]", cmdname, extra); return STAT_INSTCMD_UNKNOWN; } @@ -617,9 +620,9 @@ int setvar(const char *varname, const char *val) { char temp[BUFFLEN]; char cmd[15]; - + /* TODO : add some controls */ - + if(info_variable_ok(varname)) { /* format command */ @@ -631,7 +634,7 @@ int setvar(const char *varname, const char *val) upslogx(LOG_INFO, "setvar: UPS response to Set %s to %s was %s", varname, val, temp); } else upsdebugx(1, "setvar: Variable %s not supported by UPS", varname); - + return STAT_SET_UNKNOWN; } @@ -651,7 +654,7 @@ static void disable_ups_comm(void) static void enable_ups_comm(void) { char buf[8]; - + /* send Z twice --- speeds up re-connect */ mge_command(NULL, 0, "Z"); mge_command(NULL, 0, "Z"); @@ -661,7 +664,7 @@ static void enable_ups_comm(void) mge_command(NULL, 0, "Ax 1"); usleep(MGE_CONNECT_DELAY); } - + ser_flush_in(upsfd, "?\r\n", nut_debug_level); } @@ -670,16 +673,25 @@ static void enable_ups_comm(void) /* extract information from buffer in: buf : reply from UPS item : INFO item queried - out: infostr: to be placed in INFO_ variable + out: infostr: to be placed in INFO_ variable NOTE: buf="?" must be handled before calling extract_info buf is changed inspite of const !!!!! */ -static void extract_info(const char *buf, const mge_info_item_t *item, - char *infostr, int infolen) +static void extract_info(const char *buf, const mge_info_item_t *item, + char *infostr, size_t infolen) { /* initialize info string */ infostr[0] = '\0'; +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif /* write into infostr with proper formatting */ if ( strpbrk(item->fmt, "feEgG") ) { /* float */ snprintf(infostr, infolen, item->fmt, @@ -690,6 +702,9 @@ static void extract_info(const char *buf, const mge_info_item_t *item, } else { snprintf(infostr, infolen, item->fmt, buf); } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif } @@ -699,9 +714,9 @@ static void extract_info(const char *buf, const mge_info_item_t *item, /* get system status, at least: OB, OL, LB calls set_status appropriately tries MAXTRIES times - returns non-nil if successful + returns non-nil if successful - NOTE: MGE counts bytes/chars the opposite way as C, + NOTE: MGE counts bytes/chars the opposite way as C, see mge-utalk manpage. If status commands send two data items, these are separated by a space, so the elements of the second item are in buf[16..9]. @@ -709,13 +724,13 @@ static void extract_info(const char *buf, const mge_info_item_t *item, static int get_ups_status(void) { - char buf[BUFFLEN]; + char buf[BUFFLEN]; int rb_set= FALSE; /* has RB flag been set ? */ int over_set= FALSE; /* has OVER flag been set ? */ int tries = 0; int ok = FALSE; - int bytes_rcvd = 0; - + ssize_t bytes_rcvd = 0; + do { /* Check if we are asked to stop (reactivity++) */ if (exit_flag != 0) @@ -745,7 +760,7 @@ static int get_ups_status(void) if (buf[3] == '1') { rb_set = TRUE; - status_set("RB"); + status_set("RB"); } /* buf[2] not used */ if (buf[1] == '1') @@ -762,10 +777,10 @@ static int get_ups_status(void) if ( strlen(buf) > 7 ) { if ( !rb_set && ( buf[7] == '1' || buf[3] == '1' ) ) status_set("RB"); - + if (buf[1] == '1') status_set("CHRG"); - + if (buf[0] == '1') status_set("DISCHRG"); } /* if strlen */ @@ -795,7 +810,7 @@ static int get_ups_status(void) /* This is not the OFF status! if ( !(buf[8] == '1') ) status_set("OFF"); */ - } /* if strlen */ + } /* if strlen */ /* Bypass status */ mge_command(buf, sizeof(buf), "Ps"); @@ -809,39 +824,39 @@ static int get_ups_status(void) if (buf[6] == '1') status_set("BYPASS"); } /* if strlen */ - + } while ( !ok && tries++ < MAXTRIES ); status_commit(); - + return ok; } /* --------------------------------------------------------------- */ /* return proper variable "ok" given INFO_ type */ - -static bool_t info_variable_ok(const char *type) + +static bool_t info_variable_ok(const char *type) { mge_info_item_t *item = mge_info ; - + while ( strcasecmp(item->type, type )) item++; - + return item->ok; } /* --------------------------------------------------------------- */ /* return proper variable "cmd" given INFO_ type */ - -static const char *info_variable_cmd(const char *type) + +static const char *info_variable_cmd(const char *type) { mge_info_item_t *item = mge_info ; - + while ( strcasecmp(item->type, type )) item++; - + return item->cmd; } @@ -855,60 +870,69 @@ static const char *info_variable_cmd(const char *type) returns : no of chars received, -1 if error */ -static int mge_command(char *reply, int replylen, const char *fmt, ...) +static ssize_t mge_command(char *reply, size_t replylen, const char *fmt, ...) { const char *p; char command[BUFFLEN]; - int bytes_sent = 0; - int bytes_rcvd = 0; + ssize_t bytes_sent = 0; + ssize_t bytes_rcvd = 0; int ret; va_list ap; /* build command string */ va_start(ap, fmt); - +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif ret = vsnprintf(command, sizeof(command), fmt, ap); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif if ((ret < 1) || (ret >= (int) sizeof(command))) upsdebugx(4, "mge_command: command truncated"); - + va_end(ap); /* Delay a bit to avoid overlap of a previous answer (500 ms), as per * http://old.networkupstools.org/protocols/mge/9261zwfa.pdf § 6.1. Timings */ usleep(500000); - + /* flush received, unread data */ tcflush(upsfd, TCIFLUSH); - + /* send command */ for (p = command; *p; p++) { - if ( isprint(*p & 0xFF) ) + if ( isprint((unsigned char)*p & 0xFF) ) upsdebugx(4, "mge_command: sending [%c]", *p); else upsdebugx(4, "mge_command: sending [%02X]", *p); if (write(upsfd, p, 1) != 1) return -1; - + bytes_sent++; usleep(MGE_CHAR_DELAY); } /* send terminating string */ - if (MGE_COMMAND_ENDCHAR) { - for (p = MGE_COMMAND_ENDCHAR; *p; p++) { - if ( isprint(*p & 0xFF) ) - upsdebugx(4, "mge_command: sending [%c]", *p); - else - upsdebugx(4, "mge_command: sending [%02X]", *p); + for (p = MGE_COMMAND_ENDCHAR; *p; p++) { + if ( isprint((unsigned char)*p & 0xFF) ) + upsdebugx(4, "mge_command: sending [%c]", *p); + else + upsdebugx(4, "mge_command: sending [%02X]", *p); - if (write(upsfd, p, 1) != 1) - return -1; + if (write(upsfd, p, 1) != 1) + return -1; - bytes_sent++; - usleep(MGE_CHAR_DELAY); - } + bytes_sent++; + usleep(MGE_CHAR_DELAY); } if ( !reply ) @@ -919,7 +943,7 @@ static int mge_command(char *reply, int replylen, const char *fmt, ...) bytes_rcvd = ser_get_line(upsfd, reply, replylen, MGE_REPLY_ENDCHAR, MGE_REPLY_IGNCHAR, 3, 0); - upsdebugx(4, "mge_command: received %d byte(s)", bytes_rcvd); + upsdebugx(4, "mge_command: received %zd byte(s)", bytes_rcvd); return bytes_rcvd; } diff --git a/drivers/mge-utalk.h b/drivers/mge-utalk.h index 4720cd3..67b1135 100644 --- a/drivers/mge-utalk.h +++ b/drivers/mge-utalk.h @@ -28,6 +28,9 @@ * */ +#ifndef NUT_MGE_UTALK_H_SEEN +#define NUT_MGE_UTALK_H_SEEN 1 + /* --------------------------------------------------------------- */ /* Default Values for UPS Variables */ /* --------------------------------------------------------------- */ @@ -36,7 +39,7 @@ /* delay between return of utility power and powering up of load (in MINUTES) */ #define DEFAULT_ONDELAY 1 -#define DEFAULT_OFFDELAY 20 /* delay before power off, in SECONDS */ +#define DEFAULT_OFFDELAY 20 /* delay before power off, in SECONDS */ #define MIN_CONFIRM_TIME 3 /* shutdown must be confirmed in */ #define MAX_CONFIRM_TIME 15 /* this interval */ @@ -49,7 +52,7 @@ typedef struct { const char *finalname; } models_name_t; -models_name_t Si1_models_names [] = +static models_name_t Si1_models_names [] = { /* Pulsar EX */ { "Pulsar EX7", "Pulsar EX 7" }, @@ -142,10 +145,10 @@ static mge_model_info_t mge_model[] = { /* Multiplier Tables */ /* --------------------------------------------------------------- */ -/* First index : Table number, fetched with "Ai" command - * Second index: unit, as in enum above +/* First index : Table number, fetched with "Ai" command + * Second index: unit, as in enum above * NOTE: - * - to make the table index the same as the MGE table number, + * - to make the table index the same as the MGE table number, * dummy table row multiplier[0][] is inserted * - unit MIN2SEC is used to convert values in minutes sent by * the UPS (WAKEDELAY) to seconds @@ -153,11 +156,11 @@ static mge_model_info_t mge_model[] = { */ /* units in multiplier table */ -typedef enum eunits +typedef enum eunits { VOLT = 0, AMPERE, HERTZ, VOLTAMP, WATT, DEGCELS, MIN2SEC, NONE } units_t; static const double multiplier[4][8] = { -/* V A Hz VA W C MIN2SEC NONE */ +/* V A Hz VA W C MIN2SEC NONE */ { 1 , 1 , 1 , 1, 1, 1, 60, 1 }, { 1 , 1 , 0.1 , 1000, 1000, 1, 60, 1 }, { 0.01, 0.01, 1 , 1, 1, 1, 60, 1 }, @@ -188,7 +191,7 @@ typedef enum ebool { FALSE=0, TRUE } bool_t; typedef struct { const char *type; /* INFO_* element */ int flags; /* INFO-element flags to set in addinfo */ - int length; /* INFO-element length of strings */ + int length; /* INFO-element length of strings */ const char *cmd; /* UPS command string to requets element */ const char *fmt; /* printf format string for INFO entry */ units_t unit; /* unit of measurement, or NONE */ @@ -196,7 +199,7 @@ typedef struct { } mge_info_item_t; /* Array containing information to translate between UTalk and NUT info - * NOTE: + * NOTE: * - Array is terminated by element with type NULL. * - Essential INFO items (_MFR, _MODEL, _FIRMWARE, _STATUS) are * handled separately. @@ -231,5 +234,7 @@ static mge_info_item_t mge_info[] = { { "input.transfer.high", ST_FLAG_RW | ST_FLAG_STRING, 5, "Eu ?", "%05.1f", VOLT, TRUE }, { "input.transfer.trim.high", ST_FLAG_RW | ST_FLAG_STRING, 5, "Eu ?", "%05.1f", VOLT, TRUE }, /* terminating element */ - { NULL, 0, 0, "\0", "\0", NONE, FALSE } + { NULL, 0, 0, "\0", "\0", NONE, FALSE } }; + +#endif /* NUT_MGE_UTALK_H_SEEN */ diff --git a/drivers/mge-xml.c b/drivers/mge-xml.c index 8ca4dd3..4177b69 100644 --- a/drivers/mge-xml.c +++ b/drivers/mge-xml.c @@ -2,7 +2,8 @@ Copyright (C) 2008-2009 Arjen de Korte - 2009 Arnaud Quette + 2009-2021 Eaton (author: Arnaud Quette ) + 2017 Eaton (author: Jim Klimov ) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,6 +20,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "config.h" /* must be the first header */ + #include #include #include @@ -30,18 +33,29 @@ #include "netxml-ups.h" #include "mge-xml.h" +#include "main.h" /* for testvar() */ + +#define MGE_XML_VERSION "MGEXML/0.36" -#define MGE_XML_VERSION "MGEXML/0.25" #define MGE_XML_INITUPS "/" #define MGE_XML_INITINFO "/mgeups/product.xml /product.xml /ws/product.xml" #define ST_FLAG_RW 0x0001 #define ST_FLAG_STATIC 0x0002 -extern int shutdown_duration; - static int mge_ambient_value = 0; +/* The number of phases is not present in XML data as a separate node, + * but we can infer it from presence of non-zero data on several + * per-line nodes. */ +static int + inited_phaseinfo_in = 0, + inited_phaseinfo_bypass = 0, + inited_phaseinfo_out = 0, + num_inphases = -1, + num_bypassphases = -1, + num_outphases = -1; + static char mge_scratch_buf[256]; static char var[128]; @@ -49,6 +63,9 @@ static char val[128]; static int mge_shutdown_pending = 0; +/* This flag flips to 0 when/if we post the detailed deprecation message */ +static int mge_report_deprecation__convert_deci = 1; + typedef enum { ROOTPARENT = NE_XML_STATEROOT, @@ -114,9 +131,9 @@ typedef struct { NULL if no further processing is required) */ } xml_info_t; -static const char *online_info(const char *val) +static const char *online_info(const char *arg_val) { - if (val[0] == '1') { + if (arg_val[0] == '1') { STATUS_SET(ONLINE); } else { STATUS_CLR(ONLINE); @@ -125,9 +142,9 @@ static const char *online_info(const char *val) return NULL; } -static const char *discharging_info(const char *val) +static const char *discharging_info(const char *arg_val) { - if (val[0] == '1') { + if (arg_val[0] == '1') { STATUS_SET(DISCHRG); /* Workaround NMC bug: both charging and discharging set to 1 */ if(STATUS_BIT(CHRG)) { @@ -140,9 +157,9 @@ static const char *discharging_info(const char *val) return NULL; } -static const char *charging_info(const char *val) +static const char *charging_info(const char *arg_val) { - if (val[0] == '1') { + if (arg_val[0] == '1') { STATUS_SET(CHRG); } else { STATUS_CLR(CHRG); @@ -151,9 +168,9 @@ static const char *charging_info(const char *val) return NULL; } -static const char *lowbatt_info(const char *val) +static const char *lowbatt_info(const char *arg_val) { - if (val[0] == '1') { + if (arg_val[0] == '1') { STATUS_SET(LOWBATT); } else { STATUS_CLR(LOWBATT); @@ -162,9 +179,9 @@ static const char *lowbatt_info(const char *val) return NULL; } -static const char *overload_info(const char *val) +static const char *overload_info(const char *arg_val) { - if (val[0] == '1') { + if (arg_val[0] == '1') { STATUS_SET(OVERLOAD); } else { STATUS_CLR(OVERLOAD); @@ -173,9 +190,9 @@ static const char *overload_info(const char *val) return NULL; } -static const char *replacebatt_info(const char *val) +static const char *replacebatt_info(const char *arg_val) { - if (val[0] == '1') { + if (arg_val[0] == '1') { STATUS_SET(REPLACEBATT); } else { STATUS_CLR(REPLACEBATT); @@ -184,9 +201,9 @@ static const char *replacebatt_info(const char *val) return NULL; } -static const char *trim_info(const char *val) +static const char *trim_info(const char *arg_val) { - if (val[0] == '1') { + if (arg_val[0] == '1') { STATUS_SET(TRIM); } else { STATUS_CLR(TRIM); @@ -195,9 +212,9 @@ static const char *trim_info(const char *val) return NULL; } -static const char *boost_info(const char *val) +static const char *boost_info(const char *arg_val) { - if (val[0] == '1') { + if (arg_val[0] == '1') { STATUS_SET(BOOST); } else { STATUS_CLR(BOOST); @@ -206,9 +223,9 @@ static const char *boost_info(const char *val) return NULL; } -static const char *bypass_aut_info(const char *val) +static const char *bypass_aut_info(const char *arg_val) { - if (val[0] == '1') { + if (arg_val[0] == '1') { STATUS_SET(BYPASSAUTO); } else { STATUS_CLR(BYPASSAUTO); @@ -217,9 +234,9 @@ static const char *bypass_aut_info(const char *val) return NULL; } -static const char *bypass_man_info(const char *val) +static const char *bypass_man_info(const char *arg_val) { - if (val[0] == '1') { + if (arg_val[0] == '1') { STATUS_SET(BYPASSMAN); } else { STATUS_CLR(BYPASSMAN); @@ -228,9 +245,9 @@ static const char *bypass_man_info(const char *val) return NULL; } -static const char *off_info(const char *val) +static const char *off_info(const char *arg_val) { - if (val[0] == '0') { + if (arg_val[0] == '0') { STATUS_SET(OFF); } else { STATUS_CLR(OFF); @@ -242,9 +259,9 @@ static const char *off_info(const char *val) /* note: this value is reverted (0=set, 1=not set). We report "battery not installed" rather than "battery installed", so that devices that don't implement this variable have a battery by default */ -static const char *nobattery_info(const char *val) +static const char *nobattery_info(const char *arg_val) { - if (val[0] == '0') { + if (arg_val[0] == '0') { STATUS_SET(NOBATTERY); } else { STATUS_CLR(NOBATTERY); @@ -253,9 +270,9 @@ static const char *nobattery_info(const char *val) return NULL; } -static const char *fanfail_info(const char *val) +static const char *fanfail_info(const char *arg_val) { - if (val[0] == '1') { + if (arg_val[0] == '1') { STATUS_SET(FANFAIL); } else { STATUS_CLR(FANFAIL); @@ -265,9 +282,9 @@ static const char *fanfail_info(const char *val) } #if 0 -static const char *shutdownimm_info(const char *val) +static const char *shutdownimm_info(const char *arg_val) { - if (val[0] == '1') { + if (arg_val[0] == '1') { STATUS_SET(SHUTDOWNIMM); } else { STATUS_CLR(SHUTDOWNIMM); @@ -277,9 +294,9 @@ static const char *shutdownimm_info(const char *val) } #endif -static const char *overheat_info(const char *val) +static const char *overheat_info(const char *arg_val) { - if (val[0] == '1') { + if (arg_val[0] == '1') { STATUS_SET(OVERHEAT); } else { STATUS_CLR(OVERHEAT); @@ -288,9 +305,9 @@ static const char *overheat_info(const char *val) return NULL; } -static const char *commfault_info(const char *val) +static const char *commfault_info(const char *arg_val) { - if (val[0] == '1') { + if (arg_val[0] == '1') { STATUS_SET(COMMFAULT); } else { STATUS_CLR(COMMFAULT); @@ -299,9 +316,9 @@ static const char *commfault_info(const char *val) return NULL; } -static const char *internalfailure_info(const char *val) +static const char *internalfailure_info(const char *arg_val) { - if (val[0] == '1') { + if (arg_val[0] == '1') { STATUS_SET(INTERNALFAULT); } else { STATUS_CLR(INTERNALFAULT); @@ -310,9 +327,9 @@ static const char *internalfailure_info(const char *val) return NULL; } -static const char *battvoltlo_info(const char *val) +static const char *battvoltlo_info(const char *arg_val) { - if (val[0] == '1') { + if (arg_val[0] == '1') { STATUS_SET(BATTVOLTLO); } else { STATUS_CLR(BATTVOLTLO); @@ -321,9 +338,9 @@ static const char *battvoltlo_info(const char *val) return NULL; } -static const char *battvolthi_info(const char *val) +static const char *battvolthi_info(const char *arg_val) { - if (val[0] == '1') { + if (arg_val[0] == '1') { STATUS_SET(BATTVOLTHI); } else { STATUS_CLR(BATTVOLTHI); @@ -332,9 +349,9 @@ static const char *battvolthi_info(const char *val) return NULL; } -static const char *chargerfail_info(const char *val) +static const char *chargerfail_info(const char *arg_val) { - if ((val[0] == '1') || !strncasecmp(val, "Yes", 3)) { + if ((arg_val[0] == '1') || !strncasecmp(arg_val, "Yes", 3)) { STATUS_SET(CHARGERFAIL); } else { STATUS_CLR(CHARGERFAIL); @@ -343,9 +360,9 @@ static const char *chargerfail_info(const char *val) return NULL; } -static const char *vrange_info(const char *val) +static const char *vrange_info(const char *arg_val) { - if ((val[0] == '1') || !strncasecmp(val, "Yes", 3)) { + if ((arg_val[0] == '1') || !strncasecmp(arg_val, "Yes", 3)) { STATUS_SET(VRANGE); } else { STATUS_CLR(VRANGE); @@ -354,9 +371,9 @@ static const char *vrange_info(const char *val) return NULL; } -static const char *frange_info(const char *val) +static const char *frange_info(const char *arg_val) { - if ((val[0] == '1') || !strncasecmp(val, "Yes", 3)) { + if ((arg_val[0] == '1') || !strncasecmp(arg_val, "Yes", 3)) { STATUS_SET(FRANGE); } else { STATUS_CLR(FRANGE); @@ -365,9 +382,9 @@ static const char *frange_info(const char *val) return NULL; } -static const char *fuse_fault_info(const char *val) +static const char *fuse_fault_info(const char *arg_val) { - if (val[0] == '1') { + if (arg_val[0] == '1') { STATUS_SET(FUSEFAULT); } else { STATUS_CLR(FUSEFAULT); @@ -376,88 +393,112 @@ static const char *fuse_fault_info(const char *val) return NULL; } -static const char *yes_no_info(const char *val) +static const char *yes_no_info(const char *arg_val) { - switch(val[0]) + switch(arg_val[0]) { case '1': return "yes"; case '0': return "no"; default: - upsdebugx(2, "%s: unexpected value [%s]", __func__, val); + upsdebugx(2, "%s: unexpected value [%s]", __func__, arg_val); return ""; } } -static const char *on_off_info(const char *val) +static const char *on_off_info(const char *arg_val) { - switch(val[0]) + switch(arg_val[0]) { case '1': return "on"; case '0': return "off"; default: - upsdebugx(2, "%s: unexpected value [%s]", __func__, val); + upsdebugx(2, "%s: unexpected value [%s]", __func__, arg_val); return ""; } } -static const char *convert_deci(const char *val) +static const char *convert_deci(const char *arg_val) { - snprintf(mge_scratch_buf, sizeof(mge_scratch_buf), "%.1f", 0.1 * (float)atoi(val)); + /* Note: this routine was needed for original MGE devices, before the company + * was bought out and split in 2007 between Eaton (1ph devices) and Schneider + * (3ph devices). Those firmwares back when the driver was written apparently + * served 10x the measured values. Not sure if any such units are in service + * now (with same FW, and with no upgrade path). Reign of XML/PDC is waning. + * For currently known NetXML servers, the value served is good without more + * conversions. If older devices pop up in the field, we can add an estimation + * by e.g. reported voltage and amps (to be an order of magnitude for power). + * Alternately we can look at model names and/or firmware versions or release + * dates, if we get those and if we know enough to map them to either logic. */ - return mge_scratch_buf; + if (testvar("do_convert_deci")) { + /* Old code for old devices: */ + if (mge_report_deprecation__convert_deci) { + upslogx(LOG_NOTICE, "%s() is now deprecated, so values from XML are normally not decimated. This driver instance has however configured do_convert_deci in your ups.conf, so this behavior for old MGE NetXML-capable devices is preserved.", __func__); + mge_report_deprecation__convert_deci = 0; + } + snprintf(mge_scratch_buf, sizeof(mge_scratch_buf), "%.1f", 0.1 * (float)(atoi(arg_val))); + return mge_scratch_buf; + } + + if (mge_report_deprecation__convert_deci) { + upslogx(LOG_NOTICE, "%s() is now deprecated, so values from XML are not decimated. If you happen to have an old MGE NetXML-capable device that now shows measurements 10x too big, and a firmware update does not solve this, please inform NUT devs via the issue tracker at %s with details about your hardware and firmware versions. Also try to enable do_convert_deci in your ups.conf", __func__, PACKAGE_BUGREPORT ); + mge_report_deprecation__convert_deci = 0; + } + upsdebugx(5, "%s() is now deprecated, so value '%s' is not decimated. If this change broke your setup, please see details logged above.", __func__, arg_val); + return arg_val; } /* Ignore a zero value if the UPS is not switched off */ -static const char *ignore_if_zero(const char *val) +static const char *ignore_if_zero(const char *arg_val) { - if (atoi(val) == 0) { + if (atoi(arg_val) == 0) { return NULL; } - return convert_deci(val); + return convert_deci(arg_val); } /* Set the 'ups.date' from the combined value * (ex. 2008/03/01 15:23:26) and return the time */ -static const char *split_date_time(const char *val) +static const char *split_date_time(const char *arg_val) { char *last = NULL; - snprintf(mge_scratch_buf, sizeof(mge_scratch_buf), "%s", val); + snprintf(mge_scratch_buf, sizeof(mge_scratch_buf), "%s", arg_val); dstate_setinfo("ups.date", "%s", strtok_r(mge_scratch_buf, " -", &last)); return strtok_r(NULL, " ", &last); } -static const char *url_convert(const char *val) +static const char *url_convert(const char *arg_val) { char buf[256], *last = NULL; - snprintf(buf, sizeof(buf), "%s", val); + snprintf(buf, sizeof(buf), "%s", arg_val); snprintf(mge_scratch_buf, sizeof(mge_scratch_buf), "/%s", strtok_r(buf, " \r\n\t", &last)); return mge_scratch_buf; } -static const char *mge_battery_capacity(const char *val) +static const char *mge_battery_capacity(const char *arg_val) { - snprintf(mge_scratch_buf, sizeof(mge_scratch_buf), "%.2f", (float)atoi(val) / 3600); + snprintf(mge_scratch_buf, sizeof(mge_scratch_buf), "%.2f", (float)(atoi(arg_val)) / 3600.0); return mge_scratch_buf; } -static const char *mge_powerfactor_conversion(const char *val) +static const char *mge_powerfactor_conversion(const char *arg_val) { - snprintf(mge_scratch_buf, sizeof(mge_scratch_buf), "%.2f", (float)atoi(val) / 100); + snprintf(mge_scratch_buf, sizeof(mge_scratch_buf), "%.2f", (float)(atoi(arg_val)) / 100.0); return mge_scratch_buf; } -static const char *mge_beeper_info(const char *val) +static const char *mge_beeper_info(const char *arg_val) { - switch (atoi(val)) + switch (atoi(arg_val)) { case 1: return "disabled"; @@ -469,9 +510,9 @@ static const char *mge_beeper_info(const char *val) return NULL; } -static const char *mge_upstype_conversion(const char *val) +static const char *mge_upstype_conversion(const char *arg_val) { - switch (atoi(val)) + switch (atoi(arg_val)) { case 1: return "offline / line interactive"; @@ -487,9 +528,9 @@ static const char *mge_upstype_conversion(const char *val) return NULL; } -static const char *mge_sensitivity_info(const char *val) +static const char *mge_sensitivity_info(const char *arg_val) { - switch (atoi(val)) + switch (atoi(arg_val)) { case 0: return "normal"; @@ -501,9 +542,10 @@ static const char *mge_sensitivity_info(const char *val) return NULL; } -static const char *mge_test_result_info(const char *val) +static const char *mge_test_result_info(const char *arg_val) { - switch (atoi(val)) + STATUS_CLR(CAL); + switch (atoi(arg_val)) { case 1: return "done and passed"; @@ -514,6 +556,7 @@ static const char *mge_test_result_info(const char *val) case 4: return "aborted"; case 5: + STATUS_SET(CAL); return "in progress"; case 6: return "no test initiated"; @@ -523,12 +566,31 @@ static const char *mge_test_result_info(const char *val) return NULL; } -static const char *mge_ambient_info(const char *val) +static const char *mge_ambient_info(const char *arg_val) { switch (mge_ambient_value) { case 1: - return val; + return arg_val; + default: + return NULL; + } +} + +static const char *mge_drycontact_info(const char *arg_val) +{ + /* these values should theoretically be obtained through + * Environment.Input[1].State[x].Description + * Examples: + * open + * closed + */ + switch (atoi(arg_val)) + { + case 0: + return "opened"; + case 1: + return "closed"; default: return NULL; } @@ -552,9 +614,9 @@ static const char *mge_timer_shutdown(const char *delay_before_shutoff) return val; } -static const char *mge_shutdown_imminent(const char *val) +static const char *mge_shutdown_imminent(const char *arg_val) { - const int shutdown_delay = atoi(val); + const int shutdown_delay = atoi(arg_val); /* shutdown is already managed by mge_timer_shutdown, give up */ if(mge_shutdown_pending) { @@ -563,7 +625,7 @@ static const char *mge_shutdown_imminent(const char *val) /* We may have "NONE" or "-1" or ?? as value * We also double check both the string and numeric values to be zero!*/ - if ((val) && (val[0] == '0') && (shutdown_delay == 0)) { + if ((arg_val) && (arg_val[0] == '0') && (shutdown_delay == 0)) { STATUS_SET(SHUTDOWNIMM); } else { STATUS_CLR(SHUTDOWNIMM); @@ -885,12 +947,10 @@ static xml_info_t mge_xml2nut[] = { { "battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", 0, 0, NULL }, { "battery.runtime.low", ST_FLAG_RW, 0, "System.RunTimeToEmptyLimit", 0, 0, NULL }, { "battery.temperature", 0, 0, "UPS.BatterySystem.Battery.Temperature", 0, 0, NULL }, + { "battery.packs.external", 0, 0, "UPS.BatterySystem.Battery.Count", 0, 0, NULL }, { "battery.type", ST_FLAG_STATIC, 0, "UPS.PowerSummary.iDeviceChemistry", 0, 0, NULL }, { "battery.type", ST_FLAG_STATIC, 0, "UPS.PowerSummary.iDeviceChemistery", 0, 0, NULL }, /* [sic] */ - { "battery.voltage", 0, 0, "UPS.PowerSummary.Voltage", 0, 0, NULL }, { "battery.voltage.nominal", ST_FLAG_STATIC, 0, "UPS.BatterySystem.ConfigVoltage", 0, 0, NULL }, - { "battery.voltage.nominal", ST_FLAG_STATIC, 0, "UPS.PowerSummary.ConfigVoltage", 0, 0, NULL }, /* mge_battery_voltage_nominal */ - { "battery.current", 0, 0, "UPS.PowerSummary.Current", 0, 0, NULL }, { "battery.protection", 0, 0, "UPS.BatterySystem.Battery.DeepDischargeProtection", 0, 0, yes_no_info }, { "battery.energysave", 0, 0, "UPS.PowerConverter.Input[3].EnergySaving", 0, 0, yes_no_info }, @@ -911,7 +971,7 @@ static xml_info_t mge_xml2nut[] = { { "ups.delay.shutdown", ST_FLAG_RW, 0, "System.ShutdownDuration", 0, 0, NULL }, { "ups.timer.start", ST_FLAG_RW, 0, "UPS.PowerSummary.DelayBeforeStartup", 0, 0, NULL}, { "ups.timer.shutdown", ST_FLAG_RW, 0, "UPS.PowerSummary.DelayBeforeShutdown", 0, 0, mge_timer_shutdown }, - /* Catch shutdown imminent criteria, keep it after + /* Catch shutdown imminent criteria, keep it after UPS.PowerSummary.DelayBeforeShutdown managment */ { NULL, 0, 0, "System.RunTimeToShutdown", 0, 0, mge_shutdown_imminent }, { "ups.timer.reboot", 0, 0, "UPS.PowerSummary.DelayBeforeReboot", 0, 0, NULL }, @@ -920,15 +980,15 @@ static xml_info_t mge_xml2nut[] = { { "ups.beeper.status", 0 ,0, "UPS.BatterySystem.Battery.AudibleAlarmControl", 0, 0, mge_beeper_info }, { "ups.beeper.status", 0 ,0, "UPS.PowerSummary.AudibleAlarmControl", 0, 0, mge_beeper_info }, { "ups.temperature", 0, 0, "UPS.PowerSummary.Temperature", 0, 0, NULL }, - { "ups.power", 0, 0, "UPS.PowerConverter.Output.ApparentPower", 0, 0, NULL }, - { "ups.L1.power", 0, 0, "UPS.PowerConverter.Output.Phase[1].ApparentPower", 0, 0, ignore_if_zero }, - { "ups.L2.power", 0, 0, "UPS.PowerConverter.Output.Phase[2].ApparentPower", 0, 0, ignore_if_zero }, - { "ups.L3.power", 0, 0, "UPS.PowerConverter.Output.Phase[3].ApparentPower", 0, 0, ignore_if_zero }, { "ups.power.nominal", ST_FLAG_STATIC, 0, "UPS.Flow[4].ConfigApparentPower", 0, 0, NULL }, + { "ups.power", 0, 0, "UPS.PowerConverter.Output.ApparentPower", 0, 0, NULL }, + { "ups.L1.power", 0, 0, "UPS.PowerConverter.Output.Phase[1].ApparentPower", 0, 0, NULL }, + { "ups.L2.power", 0, 0, "UPS.PowerConverter.Output.Phase[2].ApparentPower", 0, 0, NULL }, + { "ups.L3.power", 0, 0, "UPS.PowerConverter.Output.Phase[3].ApparentPower", 0, 0, NULL }, { "ups.realpower", 0, 0, "UPS.PowerConverter.Output.ActivePower", 0, 0, NULL }, - { "ups.L1.realpower", 0, 0, "UPS.PowerConverter.Output.Phase[1].ActivePower", 0, 0, ignore_if_zero }, - { "ups.L2.realpower", 0, 0, "UPS.PowerConverter.Output.Phase[2].ActivePower", 0, 0, ignore_if_zero }, - { "ups.L3.realpower", 0, 0, "UPS.PowerConverter.Output.Phase[3].ActivePower", 0, 0, ignore_if_zero }, + { "ups.L1.realpower", 0, 0, "UPS.PowerConverter.Output.Phase[1].ActivePower", 0, 0, NULL }, + { "ups.L2.realpower", 0, 0, "UPS.PowerConverter.Output.Phase[2].ActivePower", 0, 0, NULL }, + { "ups.L3.realpower", 0, 0, "UPS.PowerConverter.Output.Phase[3].ActivePower", 0, 0, NULL }, { "ups.realpower.nominal", ST_FLAG_STATIC, 0, "UPS.Flow[4].ConfigActivePower", 0, 0, NULL }, { "ups.start.auto", 0, 0, "UPS.PowerConverter.Input[1].AutomaticRestart", 0, 0, yes_no_info }, { "ups.start.battery", 0, 0, "UPS.PowerConverter.Input[3].StartOnBattery", 0, 0, yes_no_info }, @@ -1018,6 +1078,8 @@ static xml_info_t mge_xml2nut[] = { { "ambient.temperature.low", ST_FLAG_RW, 0, "Environment.Temperature.LowThreshold", 0, 0, NULL }, { "ambient.temperature.maximum", 0, 0, "Environment.PresentStatus.HighTemperature", 0, 0, mge_ambient_info }, { "ambient.temperature.minimum", 0, 0, "Environment.PresentStatus.LowTemperature", 0, 0, mge_ambient_info }, + { "ambient.contacts.1.status", 0, 0, "Environment.Input[1].PresentStatus.State", 0, 0, mge_drycontact_info }, + { "ambient.contacts.2.status", 0, 0, "Environment.Input[2].PresentStatus.State", 0, 0, mge_drycontact_info }, /* Outlet page (using MGE UPS SYSTEMS - PowerShare technology) */ { "outlet.id", 0, 0, "UPS.OutletSystem.Outlet[1].OutletID", 0, 0, NULL }, @@ -1077,6 +1139,8 @@ static xml_info_t mge_xml2nut[] = { static int mge_xml_startelm_cb(void *userdata, int parent, const char *nspace, const char *name, const char **atts) { int state = _UNEXPECTED; + NUT_UNUSED_VARIABLE(userdata); + NUT_UNUSED_VARIABLE(nspace); switch(parent) { @@ -1085,6 +1149,7 @@ static int mge_xml_startelm_cb(void *userdata, int parent, const char *nspace, c /* name="Network Management Card" type="Mosaic M" version="BA" */ /* name="Network Management Card" type="Transverse" version="GB (SN 49EH29101)" */ /* name="Monitored ePDU" type="Monitored ePDU" version="Version Upgrade" */ + /* name="PDU Network Management Card" type="SCOB" version="02.00.0036" signature="34008876" protocol="XML.V4" */ int i; for (i = 0; atts[i] && atts[i+1]; i += 2) { if (!strcasecmp(atts[i], "name")) { @@ -1108,6 +1173,13 @@ static int mge_xml_startelm_cb(void *userdata, int parent, const char *nspace, c } dstate_setinfo("ups.firmware.aux", "%s", val); } + /* netxml-ups currently only supports XML version 3 (for UPS), + * and not version 4 (for UPS and PDU)! */ + if (!strcasecmp(atts[i], "protocol")) { + if (!strcasecmp(atts[i+1], "XML.V4")) { + fatalx(EXIT_FAILURE, "XML v4 protocol is not supported!"); + } + } } state = PRODUCT_INFO; break; @@ -1310,8 +1382,12 @@ static int mge_xml_startelm_cb(void *userdata, int parent, const char *nspace, c state = XC_GENERAL; break; } + /* FIXME? Is the fall-through to handling "GENERAL" intended? + * was so in legacy code before the goto below... */ + goto fallthrough_case_general; case XC_GENERAL: + fallthrough_case_general: if (!strcasecmp(name, "STARTUP")) { /* config="CENTRALIZED" */ state = XC_STARTUP; @@ -1345,6 +1421,8 @@ static int mge_xml_startelm_cb(void *userdata, int parent, const char *nspace, c /* Character data callback; may return non-zero to abort the parse. */ static int mge_xml_cdata_cb(void *userdata, int state, const char *cdata, size_t len) { + NUT_UNUSED_VARIABLE(userdata); + /* skip empty lines */ if ((len == 1) && (cdata[0] == '\n')) { upsdebugx(3, "%s: cdata ignored (state = %d)", __func__, state); @@ -1373,6 +1451,8 @@ static int mge_xml_endelm_cb(void *userdata, int state, const char *nspace, cons { xml_info_t *info; const char *value; + NUT_UNUSED_VARIABLE(userdata); + NUT_UNUSED_VARIABLE(nspace); /* ignore objects for which no value was set */ if (strlen(val) == 0) { @@ -1400,6 +1480,7 @@ static int mge_xml_endelm_cb(void *userdata, int state, const char *nspace, cons if (info->convert) { value = info->convert(val); + upsdebugx(4, "-> XML variable %s [%s] which maps to NUT variable %s was converted to value %s for the NUT driver state", var, val, info->nutname, value); } else { value = val; } @@ -1413,6 +1494,25 @@ static int mge_xml_endelm_cb(void *userdata, int state, const char *nspace, cons upsdebugx(3, "-> XML variable %s [%s] doesn't map to any NUT variable", var, val); break; + + case PI_GET_OBJECT: + case GET_OBJECT: + /* We've just got a snapshot of all runtime data, saved well into + * dstate's already, so can estimate missing values if needed. */ + + /* For phase setup, we assume it does not change during run-time. + * Essentially this means that once we've detected it is N-phase, + * it stays this way for the rest of the driver run/life-time. */ + /* To change this behavior just flip the maychange flag to "1" */ + + dstate_detect_phasecount("input.", 1, + &inited_phaseinfo_in, &num_inphases, 0); + dstate_detect_phasecount("input.bypass.", 1, + &inited_phaseinfo_bypass, &num_bypassphases, 0); + dstate_detect_phasecount("output.", 1, + &inited_phaseinfo_out, &num_outphases, 0); + + break; } return 0; diff --git a/drivers/mge-xml.h b/drivers/mge-xml.h index 27d4d1e..97a30d6 100644 --- a/drivers/mge-xml.h +++ b/drivers/mge-xml.h @@ -1,4 +1,4 @@ -/* mge-xml.h Model specific data for MGE XML protocol UPSes +/* mge-xml.h Model specific data for MGE XML protocol UPSes Copyright (C) 2008 Arjen de Korte diff --git a/drivers/microdowell.c b/drivers/microdowell.c index a1d6605..846764e 100644 --- a/drivers/microdowell.c +++ b/drivers/microdowell.c @@ -26,15 +26,14 @@ anything else is mandatory */ -#define ENTERPRISE_PROTOCOL - -#include "microdowell.h" - #include "main.h" #include "serial.h" #include #include "timehead.h" +#include "nut_stdint.h" +#define ENTERPRISE_PROTOCOL +#include "microdowell.h" #define MAX_START_DELAY 999999 #define MAX_SHUTDOWN_DELAY 32767 @@ -43,7 +42,7 @@ #define MAX_SHUTDOWN_DELAY_LEN 5 #define DRIVER_NAME "MICRODOWELL UPS driver" -#define DRIVER_VERSION "0.01" +#define DRIVER_VERSION "0.02" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -54,39 +53,41 @@ upsdrv_info_t upsdrv_info = { { NULL } }; -ENT_STRUCT ups ; +static ENT_STRUCT ups ; + +/* common driver routines */ int instcmd(const char *cmdname, const char *extra); int setvar(const char *varname, const char *val); /* he knew... macros should evaluate their arguments only once */ #define CLAMP(x, min, max) (((x) < (min)) ? (min) : (((x) > (max)) ? (max) : (x))) -static int CheckDataChecksum(unsigned char *Buff, int Len) +static int CheckDataChecksum(unsigned char *Buff, size_t Len) { - int i, Idx ; - unsigned char Xor ; + size_t i, Idx ; + unsigned char Xor ; - ups.FramePointer = Xor = 0 ; - for (Idx=0 ; Idx < Len ; Idx++) - if (Buff[Idx] == STX_CHAR) - break ; + ups.FramePointer = Xor = 0 ; + for (Idx=0 ; Idx < Len ; Idx++) + if (Buff[Idx] == STX_CHAR) + break ; ups.FramePointer = Idx ; /* Memorise start point. */ - /* Check that the message is not to short... */ - if ( (Idx > (Len-4)) || (Idx+Buff[Idx+1]+2 > Len) ) - return(ERR_MSG_TOO_SHORT) ; /* To short message! */ + /* Check that the message is not to short... */ + if ( (Idx > (Len-4)) || (Idx+Buff[Idx+1]+2 > Len) ) + return(ERR_MSG_TOO_SHORT) ; /* Too short a message! */ - /* Calculate checksum */ - for (i=Idx+1 ; i < Idx+Buff[Idx+1]+2 ; i++) - Xor ^= Buff[i] ; + /* Calculate checksum */ + for (i=Idx+1 ; i < Idx+Buff[Idx+1]+2 ; i++) + Xor ^= Buff[i] ; - /* if Xor != then checksum error */ - if (Xor != Buff[i]) - return(ERR_MSG_CHECKSUM) ; /* error in checksum */ + /* if Xor != then checksum error */ + if (Xor != Buff[i]) + return(ERR_MSG_CHECKSUM) ; /* error in checksum */ - /* If checksum OK: return */ - return(0) ; + /* If checksum OK: return */ + return(0) ; } @@ -115,13 +116,13 @@ static const char *ErrMessages[] = { /* */ "" } ; -const char *PrintErr(int ErrCode) +static const char *PrintErr(int ErrCode) { int msgIndex = 0 ; /* The default 'msgIndex' is 0 (error code not defined) */ switch (ErrCode) { - case ERR_NO_ERROR : msgIndex = 19 ; break ; + case ERR_NO_ERROR : msgIndex = 19 ; break ; case ERR_I2C_BUSY : msgIndex = 1 ; break ; case ERR_CMD_CHECKSUM : msgIndex = 2 ; break ; @@ -142,21 +143,21 @@ const char *PrintErr(int ErrCode) case ERR_COM_NO_CHARS : msgIndex = 16 ; break ; case ERR_MSG_TOO_SHORT : msgIndex = 17 ; break ; case ERR_MSG_CHECKSUM : msgIndex = 18 ; break ; - default: msgIndex = 0 ; break ; + + default : msgIndex = 0 ; break ; } return(ErrMessages[msgIndex]) ; } - -int CheckErrCode(unsigned char * Buff) +static int CheckErrCode(unsigned char * Buff) { - auto int Ret ; + auto int Ret ; - switch (Buff[2]) { - /* I have found an error */ - case CMD_NACK : - Ret = Buff[3] ; - break ; + switch (Buff[2]) { + /* I have found an error */ + case CMD_NACK : + Ret = Buff[3] ; + break ; case CMD_ACK : case CMD_GET_STATUS : @@ -175,19 +176,19 @@ int CheckErrCode(unsigned char * Buff) case CMD_SET_EEP_BLOCK : case CMD_GET_EEP_SEED : case CMD_INIT : - Ret = 0 ; - break ; + Ret = 0 ; + break ; - /* command not recognized */ - default: - Ret = ERR_CMD_UNRECOG ; - break ; - } - return(Ret) ; + /* command not recognized */ + default: + Ret = ERR_CMD_UNRECOG ; + break ; + } + return(Ret) ; } -void SendCmdToSerial(unsigned char *Buff, int Len) +static void SendCmdToSerial(unsigned char *Buff, size_t Len) { int i; unsigned char Tmp[20], Xor ; @@ -208,22 +209,19 @@ void SendCmdToSerial(unsigned char *Buff, int Len) ser_send_buf(upsfd, Tmp, Len+3) ; /* send data to the UPS */ } - - - -unsigned char * CmdSerial(unsigned char *OutBuffer, int Len, unsigned char *RetBuffer) +static unsigned char * CmdSerial(unsigned char *OutBuffer, size_t Len, unsigned char *RetBuffer) { #define TMP_BUFF_LEN 1024 - unsigned char InpBuff[TMP_BUFF_LEN+1] ; + unsigned char InpBuff[TMP_BUFF_LEN+1] ; unsigned char TmpBuff[3] ; - int i, ErrCode ; - unsigned char *p ; - int BuffLen ; + int i, ErrCode ; + unsigned char *p ; + size_t BuffLen ; /* The default error code (no received character) */ ErrCode = ERR_COM_NO_CHARS ; - SendCmdToSerial(OutBuffer, Len) ; + SendCmdToSerial(OutBuffer, Len) ; usleep(10000) ; /* small delay (1/100 s) */ /* get chars until timeout */ @@ -273,8 +271,6 @@ unsigned char * CmdSerial(unsigned char *OutBuffer, int Len, unsigned char *RetB return(NULL) ; /* There have been errors in the reading of the data */ } - - static int detect_hardware(void) { unsigned char OutBuff[20] ; @@ -282,6 +278,7 @@ static int detect_hardware(void) unsigned char *p ; int i, retries ; struct tm *Time ; + struct tm tmbuf; time_t lTime ; ups.ge_2kVA = 0 ; @@ -296,7 +293,7 @@ static int detect_hardware(void) { /* got UPS model */ for (i=0 ; i<8 ; i++) - ups.UpsModel[i] = p[i+5] ; + ups.UpsModel[i] = (char)p[i+5] ; ups.UpsModel[8] = '\0' ; upsdebugx(2, "get 'UPS model': %s", PrintErr(ups.ErrCode)); break ; /* UPS identified: exit from ' for' LOOP */ @@ -321,7 +318,7 @@ static int detect_hardware(void) { /* got UPS serial # */ for (i=0 ; i<8 ; i++) - ups.SerialNumber[i] = p[i+5] ; + ups.SerialNumber[i] = (char)p[i+5] ; ups.SerialNumber[8] = '\0' ; upsdebugx(2, "get 'UPS Serial #': %s", PrintErr(ups.ErrCode)); } @@ -379,6 +376,7 @@ static int detect_hardware(void) return -1; } + /* Get working time (battery+normal)) */ OutBuff[0] = CMD_GET_EEP_BLOCK ; /* get EEPROM data */ OutBuff[1] = EEP_MIN_VBATT ; /* working time */ @@ -414,6 +412,7 @@ static int detect_hardware(void) return -1; } + /* Get the THRESHOLD table (1) */ OutBuff[0] = CMD_GET_EEP_BLOCK ; /* get EEPROM data */ OutBuff[1] = EEP_THRESHOLD_1 ; /* Thresholds table 0 */ @@ -431,6 +430,7 @@ static int detect_hardware(void) return -1; } + /* Get the THRESHOLD table (2) */ OutBuff[0] = CMD_GET_EEP_BLOCK ; /* get EEPROM data */ OutBuff[1] = EEP_THRESHOLD_2 ; /* Thresholds table 0 */ @@ -469,7 +469,6 @@ static int detect_hardware(void) } - /* Get UPS sensitivity (fault points) */ OutBuff[0] = CMD_GET_EEP_BLOCK ; /* get EEPROM data */ OutBuff[1] = EEP_FAULT_POINTS ; /* Number of fault points (sensitivity)) */ @@ -493,15 +492,16 @@ static int detect_hardware(void) return -1; } + /* Set internal UPS clock */ time(&lTime) ; - Time = localtime(&lTime) ; + Time = localtime_r(&lTime, &tmbuf); OutBuff[0] = CMD_SET_TIMER ; /* set UPS internal timer */ OutBuff[1] = (Time->tm_wday+6) % 7 ; /* week day (0=monday) */ - OutBuff[2] = Time->tm_hour ; /* hours */ - OutBuff[3] = Time->tm_min ; /* minutes */ - OutBuff[4] = Time->tm_sec; /* seconds */ + OutBuff[2] = (unsigned char)Time->tm_hour ; /* hours */ + OutBuff[3] = (unsigned char)Time->tm_min ; /* minutes */ + OutBuff[4] = (unsigned char)Time->tm_sec ; /* seconds */ if ((p = CmdSerial(OutBuff, LEN_SET_TIMER, InpBuff)) != NULL) { upsdebugx(2, "set 'UPS internal clock': %s", PrintErr(ups.ErrCode)); @@ -535,10 +535,14 @@ void upsdrv_updateinfo(void) status_init(); /* reset status flags */ /* store last UPS status */ - ups.StatusUPS = (int)p[0] | ((int)p[1]<<8) | ((int)p[2]<<16) | ((int)p[3]<<24) ; - ups.ShortStatus = (int)p[0] | ((int)p[1]<<8) ; - upsdebugx(1, "ups.StatusUPS: %08lX", ups.StatusUPS); - upsdebugx(1, "ups.ShortStatus: %04X", ups.ShortStatus); + ups.StatusUPS = (uint32_t)p[0] ; + ups.StatusUPS |= ((uint32_t)p[1]<<8) ; + ups.StatusUPS |= ((uint32_t)p[2]<<16) ; + ups.StatusUPS |= ((uint32_t)p[3]<<24) ; + ups.ShortStatus = (uint16_t)p[0]; + ups.ShortStatus |= ((uint16_t)p[1]<<8) ; + upsdebugx(1, "ups.StatusUPS: %08" PRIX32, ups.StatusUPS); + upsdebugx(1, "ups.ShortStatus: %04" PRIX16, ups.ShortStatus); /* on battery? */ if (p[0] & 0x01) @@ -642,8 +646,6 @@ void upsdrv_updateinfo(void) /* ========================= */ - - int instcmd(const char *cmdname, const char *extra) { unsigned char OutBuff[20] ; @@ -771,52 +773,115 @@ int instcmd(const char *cmdname, const char *extra) return STAT_INSTCMD_UNKNOWN; } +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC) && (!defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_INSIDEFUNC) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC) || defined (HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_COMPARE_BESIDEFUNC) ) +# pragma GCC diagnostic push +#endif +#if (!defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_INSIDEFUNC) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC) +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif +#if (!defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_INSIDEFUNC) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC) +# pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif +#if (!defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_INSIDEFUNC) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_COMPARE_BESIDEFUNC) +# pragma GCC diagnostic ignored "-Wtautological-compare" +#endif int setvar(const char *varname, const char *val) { - int delay; + unsigned int delay; - if (sscanf(val, "%d", &delay) != 1) + if (sscanf(val, "%u", &delay) != 1) { return STAT_SET_UNKNOWN; } if (strcasecmp(varname, "ups.delay.start") == 0) { +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) || defined (HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_COMPARE) ) +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE +# pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_COMPARE +# pragma GCC diagnostic ignored "-Wtautological-compare" +#endif +/* Older CLANG (e.g. clang-3.4) seems to not support the GCC pragmas above */ +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wtautological-compare" +#pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif delay = CLAMP(delay, 0, MAX_START_DELAY); - upsdebugx(1, "set 'WUDELAY': %d/%d", delay, ups.WakeUpDelay); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) || defined (HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_COMPARE) ) +# pragma GCC diagnostic pop +#endif + upsdebugx(1, "set 'WUDELAY': %u/%u", delay, ups.WakeUpDelay); ups.WakeUpDelay = delay ; - dstate_setinfo("ups.delay.start", "%d", ups.WakeUpDelay); + dstate_setinfo("ups.delay.start", "%u", ups.WakeUpDelay); dstate_dataok(); return STAT_SET_HANDLED; } if (strcasecmp(varname, "ups.delay.shutdown") == 0) { +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) || defined (HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_COMPARE) ) +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE +# pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_COMPARE +# pragma GCC diagnostic ignored "-Wtautological-compare" +#endif +/* Older CLANG (e.g. clang-3.4) seems to not support the GCC pragmas above */ +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wtautological-compare" +#pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif delay = CLAMP(delay, 0, MAX_SHUTDOWN_DELAY); - upsdebugx(1, "set 'SDDELAY': %d/%d", delay, ups.ShutdownDelay); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) || defined (HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_COMPARE) ) +# pragma GCC diagnostic pop +#endif + upsdebugx(1, "set 'SDDELAY': %u/%u", delay, ups.ShutdownDelay); ups.ShutdownDelay = delay; - dstate_setinfo("ups.delay.shutdown", "%d", ups.ShutdownDelay); + dstate_setinfo("ups.delay.shutdown", "%u", ups.ShutdownDelay); dstate_dataok(); return STAT_SET_HANDLED; } return STAT_SET_UNKNOWN; } - - +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC) && (!defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_INSIDEFUNC) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC) || defined (HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_COMPARE_BESIDEFUNC) ) +# pragma GCC diagnostic pop +#endif void upsdrv_initinfo(void) { /* Get vars from ups.conf */ if (getval("ups.delay.shutdown")) { - ups.ShutdownDelay = CLAMP(atoi(getval("ups.delay.shutdown")), 0, MAX_SHUTDOWN_DELAY); + int ipv = atoi(getval("ups.delay.shutdown")); + ups.ShutdownDelay = (unsigned int) CLAMP(ipv, 0, MAX_SHUTDOWN_DELAY); } else { ups.ShutdownDelay = 120; /* Shutdown delay in seconds */ } if (getval("ups.delay.start")) { - ups.WakeUpDelay = CLAMP(atoi(getval("ups.delay.start")), 0, MAX_START_DELAY); + int ipv = atoi(getval("ups.delay.start")); + ups.WakeUpDelay = (unsigned int) CLAMP(ipv, 0, MAX_START_DELAY); } else { ups.WakeUpDelay = 10; /* WakeUp delay in seconds */ @@ -862,23 +927,19 @@ void upsdrv_initinfo(void) dstate_addcmd("shutdown.return"); dstate_addcmd("shutdown.stayoff"); - /* Register the available instant commands. */ -/* dstate_addcmd("test.battery.start"); +/* + dstate_addcmd("test.battery.start"); dstate_addcmd("test.battery.stop"); dstate_addcmd("shutdown.stop"); dstate_addcmd("beeper.toggle"); - */ +*/ /* set handlers */ upsh.instcmd = instcmd ; upsh.setvar = setvar; } - - - - void upsdrv_shutdown(void) { unsigned char OutBuff[20] ; @@ -894,10 +955,14 @@ void upsdrv_shutdown(void) status_init(); /* reset status flags */ /* store last UPS status */ - ups.StatusUPS = (int)p[0] | ((int)p[1]<<8) | ((int)p[2]<<16) | ((int)p[3]<<24) ; - ups.ShortStatus = (int)p[0] | ((int)p[1]<<8) ; - upsdebugx(1, "ups.StatusUPS: %08lX", ups.StatusUPS); - upsdebugx(1, "ups.ShortStatus: %04X", ups.ShortStatus); + ups.StatusUPS = (uint32_t)p[0] ; + ups.StatusUPS |= ((uint32_t)p[1]<<8) ; + ups.StatusUPS |= ((uint32_t)p[2]<<16) ; + ups.StatusUPS |= ((uint32_t)p[3]<<24) ; + ups.ShortStatus = (uint16_t)p[0] ; + ups.ShortStatus |= ((uint16_t)p[1]<<8) ; + upsdebugx(1, "ups.StatusUPS: %08" PRIX32, ups.StatusUPS); + upsdebugx(1, "ups.ShortStatus: %04" PRIX16, ups.ShortStatus); /* on battery? */ if (p[0] & 0x01) diff --git a/drivers/microdowell.h b/drivers/microdowell.h index af5185c..1750027 100644 --- a/drivers/microdowell.h +++ b/drivers/microdowell.h @@ -4,324 +4,322 @@ #ifdef ENTERPRISE_PROTOCOL #include +#include "nut_stdint.h" + +#define STX_CHAR '[' +#define ERR_COM_NO_CHARS -999 /* nessun carattere dalla porta seriale */ +#define ERR_MSG_TOO_SHORT -998 /* messaggio troppo breve: non arriva sino al Checksum */ +#define ERR_MSG_CHECKSUM -997 /* checksum non valido */ +#define ERR_COM_TIMEOUT -996 /* timeout in lettura */ +#define ERR_CLR_RX_BUFF -900 /* bisogna cancellare il buffer (non è un errore!) */ +#define COMMAND_NOT_VALID -50 /* comando non valido */ +#define PARAMETER_NOT_VALID -51 /* parametro non valido */ +#define ERR_UPS_NOT_FOUND -10 /* non trovo un UPS */ +#define ERR_COM_PORT_OPEN -11 /* impossibile aprire la porta di comunicazione */ +#define ERR_COM_SET_PORT -12 /* impossibile configurare la porta di comunicazione */ +#define ERR_COM_UNDEF_PORT -20 /* porta non valida o non esistente */ +#define ERR_USB_DRIVER -13 /* impossibile aprire il driver USB */ +#define ERR_USB_COMM_KO -14 /* interfaccia USB OK: gruppo spento o guasto */ +#define ERR_UPS_UNKNOWN -30 /* impossibile identificare l'UPS */ +#define ERR_PRG_THREAD -40 /* impossibile creare uno thread */ +#define ERR_PRG_INVALID_DATA -60 /* dati non validi */ + +#define ERR_NO_ERROR 0x00 /* no errors */ +#define ERR_I2C_BUSY 0x01 /* I2C bus busy (e2prom) */ +#define ERR_CMD_CHECKSUM 0x10 /* Checksum not valid */ +#define ERR_CMD_UNRECOG 0x11 /* unrecognized command */ +#define ERR_EEP_NOBLOCK 0x08 /* WRITE: eeprom address not multiple of 8 */ +#define ERR_EEP_OOBOUND 0x09 /* READ: eeprom address out of bound (with size) */ +#define ERR_EEP_WADDR1 0x28 /* error writing e2prom address */ +#define ERR_EEP_WSADDR1 0x29 /* error writing e2prom subaddress */ +#define ERR_EEP_RDATA 0x2A /* error reading e2prom data */ +#define ERR_EEP_WADDR2 0x50 /* error writing e2prom address */ +#define ERR_EEP_WSADDR2 0x51 /* error reading e2prom subaddress */ +#define ERR_EEP_WDATA 0x52 /* error writing e2prom data */ +#define ERR_EEP_WADDRVER 0x53 /* error writing e2prom address during data verification */ +#define ERR_EEP_WDATAVER 0x54 /* error verification e2prom data */ +#define ERR_EEP_VERIFY 0x55 /* e2prom data are different from those in the write buffer */ +#define ERR_EEP_CHECKSUM 0x90 /* e2prom checksum error */ -#define STX_CHAR '[' -#define ERR_COM_NO_CHARS -999 // nessun carattere dalla porta seriale -#define ERR_MSG_TOO_SHORT -998 // messaggio troppo breve: non arriva sino al Checksum -#define ERR_MSG_CHECKSUM -997 // checksum non valido -#define ERR_COM_TIMEOUT -996 // timeout in lettura -#define ERR_CLR_RX_BUFF -900 // bisogna cancellare il buffer (non è un errore!) -#define COMMAND_NOT_VALID -50 // comando non valido -#define PARAMETER_NOT_VALID -51 // parametro non valido -#define ERR_UPS_NOT_FOUND -10 // non trovo un UPS -#define ERR_COM_PORT_OPEN -11 // impossibile aprire la porta di comunicazione -#define ERR_COM_SET_PORT -12 // impossibile configurare la porta di comunicazione -#define ERR_COM_UNDEF_PORT -20 // porta non valida o non esistente -#define ERR_USB_DRIVER -13 // impossibile aprire il driver USB -#define ERR_USB_COMM_KO -14 // interfaccia USB OK: gruppo spento o guasto -#define ERR_UPS_UNKNOWN -30 // impossibile identificare l'UPS -#define ERR_PRG_THREAD -40 // impossibile creare uno thread -#define ERR_PRG_INVALID_DATA -60 // dati non validi +#define CMD_ACK 0x06 /* ACK */ +#define CMD_NACK 0x15 /* NACK */ -#define ERR_NO_ERROR 0x00 // no errors -#define ERR_I2C_BUSY 0x01 // I2C bus busy (e2prom) -#define ERR_CMD_CHECKSUM 0x10 // Checksum not valid -#define ERR_CMD_UNRECOG 0x11 // unrecognized command -#define ERR_EEP_NOBLOCK 0x08 // WRITE: eeprom address not multiple of 8 -#define ERR_EEP_OOBOUND 0x09 // READ: eeprom address out of bound (with size) -#define ERR_EEP_WADDR1 0x28 // error writing e2prom address -#define ERR_EEP_WSADDR1 0x29 // error writing e2prom subaddress -#define ERR_EEP_RDATA 0x2A // error reading e2prom data -#define ERR_EEP_WADDR2 0x50 // error writing e2prom address -#define ERR_EEP_WSADDR2 0x51 // error reading e2prom subaddress -#define ERR_EEP_WDATA 0x52 // error writing e2prom data -#define ERR_EEP_WADDRVER 0x53 // error writing e2prom address during data verification -#define ERR_EEP_WDATAVER 0x54 // error verification e2prom data -#define ERR_EEP_VERIFY 0x55 // e2prom data are different from those in the write buffer -#define ERR_EEP_CHECKSUM 0x90 // e2prom checksum error +#define CMD_GET_STATUS 0x00 /* comando di acquisizione STATUS */ +#define CMD_GET_MEASURES 0x01 /* comando di acquisizione MISURE */ +#define CMD_GET_CONFIG 0x02 /* comando di acquisizione CONFIGURAZIONE */ +#define CMD_GET_BATT_STAT 0x03 /* comando di acquisizione Battery+Load Status */ +#define CMD_GET_BAT_LD 0x03 /* comando di acquisizione Battery+Load Status */ +#define CMD_GET_MASK 0x07 /* comando di acquisizione MASCHERA PUNTI */ +#define CMD_SET_TIMER 0x20 /* comando di CONFIGURAZIONE TIMER */ +#define CMD_BATT_TEST 0x21 /* comando di CONFIGURAZIONE TEST BATTERIA */ +#define CMD_GET_BATT_TEST 0x22 /* comando di LETTURA TEST BATTERIA */ +#define CMD_SD_ONESHOT 0x40 /* comando di SCRITTURA SHUTDOWN ONESHOT */ +#define CMD_GET_SD_ONESHOT 0x41 /* comando di LETTURA SHUTDOWN ONESHOT */ +#define CMD_SET_SCHEDULE 0x42 /* comando di SCRITTURA SCHEDULE */ +#define CMD_GET_SCHEDULE 0x43 /* comando di LETTURA SCHEDULE */ +#define CMD_GET_EEP_BLOCK 0x50 /* comando di LETTURA BLOCCO EEPROM */ +#define CMD_SET_EEP_BLOCK 0x51 /* comando di SCRITTURA BLOCCO EEPROM */ +#define CMD_GET_EEP_SEED 0x52 /* comando di acquisizione SEME PROGR. EEPROM */ +#define CMD_INIT 0xF0 /* comando di REINIZIALIZZAZIONE UPS */ +#define LEN_ACK 1 /* ACK */ +#define LEN_NACK 2 /* NACK */ -#define CMD_ACK 0x06 // ACK -#define CMD_NACK 0x15 // NACK - -#define CMD_GET_STATUS 0x00 // comando di acquisizione STATUS -#define CMD_GET_MEASURES 0x01 // comando di acquisizione MISURE -#define CMD_GET_CONFIG 0x02 // comando di acquisizione CONFIGURAZIONE -#define CMD_GET_BATT_STAT 0x03 // comando di acquisizione Battery+Load Status -#define CMD_GET_BAT_LD 0x03 // comando di acquisizione Battery+Load Status -#define CMD_GET_MASK 0x07 // comando di acquisizione MASCHERA PUNTI -#define CMD_SET_TIMER 0x20 // comando di CONFIGURAZIONE TIMER -#define CMD_BATT_TEST 0x21 // comando di CONFIGURAZIONE TEST BATTERIA -#define CMD_GET_BATT_TEST 0x22 // comando di LETTURA TEST BATTERIA -#define CMD_SD_ONESHOT 0x40 // comando di SCRITTURA SHUTDOWN ONESHOT -#define CMD_GET_SD_ONESHOT 0x41 // comando di LETTURA SHUTDOWN ONESHOT -#define CMD_SET_SCHEDULE 0x42 // comando di SCRITTURA SCHEDULE -#define CMD_GET_SCHEDULE 0x43 // comando di LETTURA SCHEDULE -#define CMD_GET_EEP_BLOCK 0x50 // comando di LETTURA BLOCCO EEPROM -#define CMD_SET_EEP_BLOCK 0x51 // comando di SCRITTURA BLOCCO EEPROM -#define CMD_GET_EEP_SEED 0x52 // comando di acquisizione SEME PROGR. EEPROM -#define CMD_INIT 0xF0 // comando di REINIZIALIZZAZIONE UPS +#define LEN_GET_STATUS 1 /* comando di acquisizione STATUS */ +#define LEN_GET_MEASURES 1 /* comando di acquisizione MISURE */ +#define LEN_GET_CONFIG 1 /* comando di acquisizione CONFIGURAZIONE */ +#define LEN_GET_BATT_STAT 1 /* comando di acquisizione Battery+Load Status */ +#define LEN_GET_BAT_LD 1 /* comando di acquisizione Battery+Load Status */ +#define LEN_GET_MASK 1 /* comando di acquisizione MASCHERA PUNTI */ +#define LEN_SET_TIMER 5 /* comando di CONFIGURAZIONE TIMER */ +#define LEN_BATT_TEST 4 /* comando di CONFIGURAZIONE TEST BATTERIA */ +#define LEN_GET_BATT_TEST 1 /* comando di LETTURA TEST BATTERIA */ +#define LEN_SD_ONESHOT 8 /* comando di SCRITTURA SHUTDOWN ONESHOT */ +#define LEN_GET_SD_ONESHOT 1 /* comando di LETTURA SHUTDOWN ONESHOT */ +#define LEN_SET_SCHEDULE 8 /* comando di SCRITTURA SCHEDULE */ +#define LEN_GET_SCHEDULE 2 /* comando di LETTURA SCHEDULE */ +#define LEN_GET_EEP_BLOCK 3 /* comando di SCRITTURA BLOCCO EEPROM */ +#define LEN_SET_EEP_BLOCK 12 /* comando di SCRITTURA BLOCCO EEPROM */ +#define LEN_GET_EEP_SEED 1 /* comando di acquisizione SEME PROGR. EEPROM */ +#define LEN_INIT 1 /* comando di REINIZIALIZZAZIONE UPS */ -#define LEN_ACK 1 // ACK -#define LEN_NACK 2 // NACK - -#define LEN_GET_STATUS 1 // comando di acquisizione STATUS -#define LEN_GET_MEASURES 1 // comando di acquisizione MISURE -#define LEN_GET_CONFIG 1 // comando di acquisizione CONFIGURAZIONE -#define LEN_GET_BATT_STAT 1 // comando di acquisizione Battery+Load Status -#define LEN_GET_BAT_LD 1 // comando di acquisizione Battery+Load Status -#define LEN_GET_MASK 1 // comando di acquisizione MASCHERA PUNTI -#define LEN_SET_TIMER 5 // comando di CONFIGURAZIONE TIMER -#define LEN_BATT_TEST 4 // comando di CONFIGURAZIONE TEST BATTERIA -#define LEN_GET_BATT_TEST 1 // comando di LETTURA TEST BATTERIA -#define LEN_SD_ONESHOT 8 // comando di SCRITTURA SHUTDOWN ONESHOT -#define LEN_GET_SD_ONESHOT 1 // comando di LETTURA SHUTDOWN ONESHOT -#define LEN_SET_SCHEDULE 8 // comando di SCRITTURA SCHEDULE -#define LEN_GET_SCHEDULE 2 // comando di LETTURA SCHEDULE -#define LEN_GET_EEP_BLOCK 3 // comando di SCRITTURA BLOCCO EEPROM -#define LEN_SET_EEP_BLOCK 12 // comando di SCRITTURA BLOCCO EEPROM -#define LEN_GET_EEP_SEED 1 // comando di acquisizione SEME PROGR. EEPROM -#define LEN_INIT 1 // comando di REINIZIALIZZAZIONE UPS +/* non completamente definiti! */ +#define RET_GET_STATUS 10 /* comando di acquisizione STATUS */ +#define RET_GET_MEASURES 15 /* comando di acquisizione MISURE */ +#define RET_GET_CONFIG 11 /* comando di acquisizione CONFIGURAZIONE */ +#define RET_GET_BATT_STAT 10 /* comando di acquisizione Battery+Load Status */ +#define RET_GET_BAT_LD 10 /* comando di acquisizione Battery+Load Status */ +#define RET_GET_MASK 1 /* comando di acquisizione MASCHERA PUNTI */ +#define RET_SET_TIMER 5 /* comando di CONFIGURAZIONE TIMER */ +#define RET_BATT_TEST 4 /* comando di CONFIGURAZIONE TEST BATTERIA */ +#define RET_GET_BATT_TEST 1 /* comando di LETTURA TEST BATTERIA */ +#define RET_SD_ONESHOT 8 /* comando di SCRITTURA SHUTDOWN ONESHOT */ +#define RET_GET_SD_ONESHOT 1 /* comando di LETTURA SHUTDOWN ONESHOT */ +#define RET_SET_SCHEDULE 8 /* comando di SCRITTURA SCHEDULE */ +#define RET_GET_SCHEDULE 8 /* comando di LETTURA SCHEDULE */ +#define RET_GET_EEP_BLOCK 11 /* comando di SCRITTURA BLOCCO EEPROM */ +#define RET_SET_EEP_BLOCK 12 /* comando di SCRITTURA BLOCCO EEPROM */ +#define RET_GET_EEP_SEED 1 /* comando di acquisizione SEME PROGR. EEPROM */ +#define RET_INIT 1 /* comando di REINIZIALIZZAZIONE UPS */ -// non completamente definiti! -#define RET_GET_STATUS 10 // comando di acquisizione STATUS -#define RET_GET_MEASURES 15 // comando di acquisizione MISURE -#define RET_GET_CONFIG 11 // comando di acquisizione CONFIGURAZIONE -#define RET_GET_BATT_STAT 10 // comando di acquisizione Battery+Load Status -#define RET_GET_BAT_LD 10 // comando di acquisizione Battery+Load Status -#define RET_GET_MASK 1 // comando di acquisizione MASCHERA PUNTI -#define RET_SET_TIMER 5 // comando di CONFIGURAZIONE TIMER -#define RET_BATT_TEST 4 // comando di CONFIGURAZIONE TEST BATTERIA -#define RET_GET_BATT_TEST 1 // comando di LETTURA TEST BATTERIA -#define RET_SD_ONESHOT 8 // comando di SCRITTURA SHUTDOWN ONESHOT -#define RET_GET_SD_ONESHOT 1 // comando di LETTURA SHUTDOWN ONESHOT -#define RET_SET_SCHEDULE 8 // comando di SCRITTURA SCHEDULE -#define RET_GET_SCHEDULE 8 // comando di LETTURA SCHEDULE -#define RET_GET_EEP_BLOCK 11 // comando di SCRITTURA BLOCCO EEPROM -#define RET_SET_EEP_BLOCK 12 // comando di SCRITTURA BLOCCO EEPROM -#define RET_GET_EEP_SEED 1 // comando di acquisizione SEME PROGR. EEPROM -#define RET_INIT 1 // comando di REINIZIALIZZAZIONE UPS +/* ======================================================= */ +/* Indirizzi delle variabili memorizzate nella EEPROM: // */ +/* ======================================================= */ +#define EEP_OPT_BYTE_BLK 0x00 /* Option Bytes block */ +#define EEP_MAGIC 0x00 /* magic number: deve essere a 0xAA */ +#define EEP_CHECKSUM 0x01 /* XOR longitudinale da 0x?? a 0x?? */ +#define EEP_OUT_CONFIG 0x02 /* vedi documentazione */ +#define EEP_OPT_BYTE_0 0x02 /* vedi documentazione */ +#define EEP_OPT_BYTE_1 0x03 /* vedi documentazione */ +#define EEP_STATUS 0x04 /* Status UPS */ + +#define EEP_THRESHOLD_0 0x08 /* Blocco 0 con gli threshold */ +#define EEP_MEAN_MIN 0x08 /* UPS minimum AC voltage intervention point */ +#define EEP_MEAN_MAX 0x0A /* UPS maximum AC voltage intervention point */ +#define EEP_AVR_MIN 0x0C /* AVR minimum AC voltage intervention point */ +#define EEP_AVR_MAX 0x0E /* AVR maximum AC voltage intervention point */ + +#define EEP_THRESHOLD_1 0x10 /* Blocco 1 con gli threshold */ +#define EEP_BLOW_VALUE 0x10 /* Battery LOW threshold voltage */ +#define EEP_BEND_VALUE 0x12 /* Battery END threshold voltage */ +#define EEP_VMETER_0 0x14 /* Led 0 Voltage indicator threshold */ +#define EEP_VMETER_1 0x16 /* Led 1 Voltage indicator threshold */ + +#define EEP_THRESHOLD_2 0x18 /* Blocco 2 con gli threshold */ +#define EEP_VMETER_2 0x18 /* Led 2 Voltage indicator threshold */ +#define EEP_VMETER_3 0x1A /* Led 3 Voltage indicator threshold */ +#define EEP_VMETER_4 0x1C /* Led 4 Voltage indicator threshold */ + +#define EEP_FAULT_POINTS 0x20 /* number of fault points (in an half sine wave) after which USP enter battery mode */ +#define EEP_CHARGER_MIN 0x21 /* Threshold voltage for battery charger */ + +#define EEP_TEMP_MAX 0x28 /* Maximum temperature: over this value an alarm will be generated */ +#define EEP_TEMP_FAULT 0x2A /* Fault temperature: over this value, UPS will shut down immediately */ +#define EEP_FANSPEED_0 0x2C /* Temperature for fan activation (low speed) */ +#define EEP_FANSPEED_1 0x2E /* Temperature for fan activation (medium speed) */ + +#define EEP_FANSPEED_2 0x30 /* Temperature for fan activation (high speed) */ + +#define EEP_IOUT 0x38 /* */ +#define EEP_IOUT_OVRLD 0x38 /* Maximum current: over this value an alarm will be generated */ +#define EEP_IOUT_FAULT 0x3A /* Fault current: over this value, UPS will shut down immediately */ +#define EEP_PWRMTR_0 0x3C /* Led 0 Power indicator threshold */ +#define EEP_PWRMTR_1 0x3E /* Led 1 Power indicator threshold */ + +#define EEP_PWRMTR_2 0x40 /* Led 2 Power indicator threshold */ +#define EEP_PWRMTR_3 0x42 /* Led 3 Power indicator threshold */ +#define EEP_PWRMTR_4 0x44 /* Led 4 Power indicator threshold */ +#define EEP_PWRMTR_5 0x46 /* Between "Full power" and "Overload" Power indicator level */ + +#define EEP_INPUT_MASK_0 0x48 /* Half sine input mask (0-7 of 10 points) */ +#define EEP_INPUT_MASK_8 0x50 /* Half sine input mask (8-9 of 10 points) */ + +#define EEP_MIN_VBATT 0x60 /* Minimum battery voltaged reached from the last power-on */ +#define EEP_RUNTIME_H 0x62 /* Working time in minutes (max ~=32 years) (MSB first) */ +#define EEP_BAT_TIME_M 0x65 /* Time in Battery mode: seconds*2 (max ~=390 days). (MSB first) */ -//======================================================= -// Indirizzi delle variabili memorizzate nella EEPROM: // -//======================================================= -#define EEP_OPT_BYTE_BLK 0x00 // Option Bytes block -#define EEP_MAGIC 0x00 // magic number: deve essere a 0xAA -#define EEP_CHECKSUM 0x01 // XOR longitudinale da 0x?? a 0x?? -#define EEP_OUT_CONFIG 0x02 // vedi documentazione -#define EEP_OPT_BYTE_0 0x02 // vedi documentazione -#define EEP_OPT_BYTE_1 0x03 // vedi documentazione -#define EEP_STATUS 0x04 // Status UPS +#define EEP_UPS_MODEL 0x80 /* Model of the UPS in ASCII. For the Enterprise line, the structure is: */ + /* ENTxxyyy */ + /* where: xx = Power rating in watts/100 (zero padded at left) */ + /* yyy = model variants (if not defined, space padded to the right) */ -#define EEP_THRESHOLD_0 0x08 // Blocco 0 con gli threshold -#define EEP_MEAN_MIN 0x08 // UPS minimum AC voltage intervention point -#define EEP_MEAN_MAX 0x0A // UPS maximum AC voltage intervention point -#define EEP_AVR_MIN 0x0C // AVR minimum AC voltage intervention point -#define EEP_AVR_MAX 0x0E // AVR maximum AC voltage intervention point +#define EEP_NETWRK_ID 0x88 /* Network ID in ASCII (not used) - space padded */ +#define EEP_NETWRK_NAME 0x90 /* Network Name in ASCII (not used) - space padded */ +#define EEP_SERIAL_NUM 0x98 /* Serial Number in ASCII - zero padded (at left) */ -#define EEP_THRESHOLD_1 0x10 // Blocco 1 con gli threshold -#define EEP_BLOW_VALUE 0x10 // Battery LOW threshold voltage -#define EEP_BEND_VALUE 0x12 // Battery END threshold voltage -#define EEP_VMETER_0 0x14 // Led 0 Voltage indicator threshold -#define EEP_VMETER_1 0x16 // Led 1 Voltage indicator threshold - -#define EEP_THRESHOLD_2 0x18 // Blocco 2 con gli threshold -#define EEP_VMETER_2 0x18 // Led 2 Voltage indicator threshold -#define EEP_VMETER_3 0x1A // Led 3 Voltage indicator threshold -#define EEP_VMETER_4 0x1C // Led 4 Voltage indicator threshold - -#define EEP_FAULT_POINTS 0x20 // number of fault points (in an half sine wave) after which USP enter battery mode -#define EEP_CHARGER_MIN 0x21 // Threshold voltage for battery charger - -#define EEP_TEMP_MAX 0x28 // Maximum temperature: over this value an alarm will be generated -#define EEP_TEMP_FAULT 0x2A // Fault temperature: over this value, UPS will shut down immediately -#define EEP_FANSPEED_0 0x2C // Temperature for fan activation (low speed) -#define EEP_FANSPEED_1 0x2E // Temperature for fan activation (medium speed) - -#define EEP_FANSPEED_2 0x30 // Temperature for fan activation (high speed) - -#define EEP_IOUT 0x38 // -#define EEP_IOUT_OVRLD 0x38 // Maximum current: over this value an alarm will be generated -#define EEP_IOUT_FAULT 0x3A // Fault current: over this value, UPS will shut down immediately -#define EEP_PWRMTR_0 0x3C // Led 0 Power indicator threshold -#define EEP_PWRMTR_1 0x3E // Led 1 Power indicator threshold - -#define EEP_PWRMTR_2 0x40 // Led 2 Power indicator threshold -#define EEP_PWRMTR_3 0x42 // Led 3 Power indicator threshold -#define EEP_PWRMTR_4 0x44 // Led 4 Power indicator threshold -#define EEP_PWRMTR_5 0x46 // Between "Full power" and "Overload" Power indicator level - -#define EEP_INPUT_MASK_0 0x48 // Half sine input mask (0-7 of 10 points) -#define EEP_INPUT_MASK_8 0x50 // Half sine input mask (8-9 of 10 points) - -#define EEP_MIN_VBATT 0x60 // Minimum battery voltaged reached from the last power-on -#define EEP_RUNTIME_H 0x62 // Working time in minutes (max ~=32 years) (MSB first) -#define EEP_BAT_TIME_M 0x65 // Time in Battery mode: seconds*2 (max ~=390 days). (MSB first) +#define EEP_PROD_DATE 0xA0 /* */ +#define EEP_PROD_YEAR 0xA0 /* Year of production (add 2000) */ +#define EEP_PROD_WEEK 0xA1 /* Week of production [0-51] */ +#define EEP_PROD_HW_VER 0xA2 /* Hardware version: 2 nibbles ? Major and Minor number. */ +#define EEP_PROD_BRD_VER 0xA3 /* Board version: 2 nibbles ? Major and Minor number. */ +#define EEP_PROD_FW_VER 0xA4 /* Firmware version: 2 nibbles ? Major and Minor number. */ +#define EEP_PROD_FW_SVER 0xA5 /* Firmware SUBversion: 2 nibbles ? Major and Minor number. */ +#define EEP_PROD_BTTRS 0xA6 /* number of batteries installed in the UPS */ -#define EEP_UPS_MODEL 0x80 // Model of the UPS in ASCII. For the Enterprise line, the structure is: - // ENTxxyyy - // where: xx = Power rating in watts/100 (zero padded at left) - // yyy = model variants (if not defined, space padded to the right) - -#define EEP_NETWRK_ID 0x88 // Network ID in ASCII (not used) - space padded -#define EEP_NETWRK_NAME 0x90 // Network Name in ASCII (not used) - space padded -#define EEP_SERIAL_NUM 0x98 // Serial Number in ASCII - zero padded (at left) - -#define EEP_PROD_DATE 0xA0 // -#define EEP_PROD_YEAR 0xA0 // Year of production (add 2000) -#define EEP_PROD_WEEK 0xA1 // Week of production [0-51] -#define EEP_PROD_HW_VER 0xA2 // Hardware version: 2 nibbles ? Major and Minor number. -#define EEP_PROD_BRD_VER 0xA3 // Board version: 2 nibbles ? Major and Minor number. -#define EEP_PROD_FW_VER 0xA4 // Firmware version: 2 nibbles ? Major and Minor number. -#define EEP_PROD_FW_SVER 0xA5 // Firmware SUBversion: 2 nibbles ? Major and Minor number. -#define EEP_PROD_BTTRS 0xA6 // number of batteries installed in the UPS +#define EEP_BATT_SUBST 0xA8 /* battery replacement block */ +#define EEP_BATT_YEAR_0 0xA8 /* Year of 1st battery replacement (add 2000) */ +#define EEP_BATT_WEEK_0 0xA9 /* Week of 1st battery replacement */ +#define EEP_BATT_YEAR_1 0xAA /* Year of 2nd battery replacement (add 2000) */ +#define EEP_BATT_WEEK_1 0xAB /* Week of 2nd battery replacement */ +#define EEP_BATT_YEAR_2 0xAC /* Year of 3rd battery replacement (add 2000) */ +#define EEP_BATT_WEEK_2 0xAD /* Week of 3rd battery replacement */ +#define EEP_BATT_YEAR_3 0xAE /* Year of 4th battery replacement (add 2000) */ +#define EEP_BATT_WEEK_3 0xAF /* Week of 4th battery replacement */ -#define EEP_BATT_SUBST 0xA8 // battery replacement block -#define EEP_BATT_YEAR_0 0xA8 // Year of 1st battery replacement (add 2000) -#define EEP_BATT_WEEK_0 0xA9 // Week of 1st battery replacement -#define EEP_BATT_YEAR_1 0xAA // Year of 2nd battery replacement (add 2000) -#define EEP_BATT_WEEK_1 0xAB // Week of 2nd battery replacement -#define EEP_BATT_YEAR_2 0xAC // Year of 3rd battery replacement (add 2000) -#define EEP_BATT_WEEK_2 0xAD // Week of 3rd battery replacement -#define EEP_BATT_YEAR_3 0xAE // Year of 4th battery replacement (add 2000) -#define EEP_BATT_WEEK_3 0xAF // Week of 4th battery replacement +#define EEP_SCHEDULE 0xC8 /* Start of SCHEDULING table */ +#define EEP_SCHEDULE_0 0xC8 /* 1st Scheduling slot */ +#define EEP_SCHEDULE_1 0xD0 /* 2nd Scheduling slot */ +#define EEP_SCHEDULE_2 0xD8 /* 3rd Scheduling slot */ +#define EEP_SCHEDULE_3 0xE0 /* 4th Scheduling slot */ +#define EEP_SCHEDULE_4 0xE8 /* 5th Scheduling slot */ +#define EEP_SCHEDULE_5 0xF0 /* 6th Scheduling slot */ -#define EEP_SCHEDULE 0xC8 // Start of SCHEDULING table -#define EEP_SCHEDULE_0 0xC8 // 1st Scheduling slot -#define EEP_SCHEDULE_1 0xD0 // 2nd Scheduling slot -#define EEP_SCHEDULE_2 0xD8 // 3rd Scheduling slot -#define EEP_SCHEDULE_3 0xE0 // 4th Scheduling slot -#define EEP_SCHEDULE_4 0xE8 // 5th Scheduling slot -#define EEP_SCHEDULE_5 0xF0 // 6th Scheduling slot - - -#define BIT_NO_COMM_UPS 0x0001 // Event 2 - communications with the UPS lost -#define BIT_COMM_OK 0x0002 // Event 3 - communications with the UPS reestablished -#define BIT_BATTERY_MODE 0x0004 // Event 5 - the UPS is in Battery mode -#define BIT_BATTERY_LOW 0x0008 // Event 6 - the UPS has a LOW battery level -#define BIT_MAINS_OK 0x0010 // Event 7 - return of the mains -#define BIT_OVERLOAD 0x0020 // Event 8 - the UPS is overloaded -#define BIT_HIGH_TEMPERATURE 0x0040 // Event 9 - the UPS is in overtemperature -#define BIT_GENERIC_FAULT 0x0080 // Event 11 - there is a generic fault -#define BIT_SYSTEM_SHUTDOWN 0x0100 // Event 14 - the UPS will shut down IMMEDIATELY -#define BIT_STANDBY 0x0200 // Event 32 - the UPS went in STANDBY MODE -#define BIT_BATTERY_END 0x0400 // Event 33 - the UPS went in battery END -#define BIT_EVENT_0 0x1000 // evento ?? -#define BIT_EVENT_1 0x2000 // evento ?? -#define BIT_FIRST_TIME 0x4000 // se è la prima volta che chiamo la funzione -#define BIT_POLL_RESTART 0x8000 // se riesco ad identificare l'UPS dopo lo scollegamento, reinvio i dati +#define BIT_NO_COMM_UPS 0x0001 /* Event 2 - communications with the UPS lost */ +#define BIT_COMM_OK 0x0002 /* Event 3 - communications with the UPS reestablished */ +#define BIT_BATTERY_MODE 0x0004 /* Event 5 - the UPS is in Battery mode */ +#define BIT_BATTERY_LOW 0x0008 /* Event 6 - the UPS has a LOW battery level */ +#define BIT_MAINS_OK 0x0010 /* Event 7 - return of the mains */ +#define BIT_OVERLOAD 0x0020 /* Event 8 - the UPS is overloaded */ +#define BIT_HIGH_TEMPERATURE 0x0040 /* Event 9 - the UPS is in overtemperature */ +#define BIT_GENERIC_FAULT 0x0080 /* Event 11 - there is a generic fault */ +#define BIT_SYSTEM_SHUTDOWN 0x0100 /* Event 14 - the UPS will shut down IMMEDIATELY */ +#define BIT_STANDBY 0x0200 /* Event 32 - the UPS went in STANDBY MODE */ +#define BIT_BATTERY_END 0x0400 /* Event 33 - the UPS went in battery END */ +#define BIT_EVENT_0 0x1000 /* evento ?? */ +#define BIT_EVENT_1 0x2000 /* evento ?? */ +#define BIT_FIRST_TIME 0x4000 /* se è la prima volta che chiamo la funzione */ +#define BIT_POLL_RESTART 0x8000 /* se riesco ad identificare l'UPS dopo lo scollegamento, reinvio i dati */ typedef struct - { - int Port ; // porta a cui è collegato l' UPS: - // 0 = USB - // n = COMn - char Opened ; // BOOL flag che identifica se la porta è aperta - int ErrCode ; // ultimo codice di errore in fase di lettura - int ErrCount ; // conteggio degli errori - unsigned char PollFlag ; // identifica se posso accedere all'UPS - // 0x01: se TRUE, polling abilitato - // 0x02: se TRUE, la routine di polling dati è attiva: devo attendere - // 0x04: se TRUE, bisogna rileggere la configurazione del gruppo - //------------------------------------------------------------------------ - unsigned long Counter ; // contatore: viene incrementato ad ogni nuovo POLL - unsigned char CommStatus ; // stato delle comunicazioni - unsigned char FramePointer ; // puntatore al carattere di START dei dati ricevuti - //------------------------------------------------------------------------ - char UpsModel[9] ; // modello UPS (8 caratteri) - unsigned char ge_2kVA ; // if more or equal to 2KVA - char SerialNumber[9] ; // numero di serie dell'UPS +{ + int Port ; /* porta a cui è collegato l' UPS: */ + /* 0 = USB */ + /* n = COMn */ + char Opened ; /* BOOL flag che identifica se la porta è aperta */ + int ErrCode ; /* ultimo codice di errore in fase di lettura */ + int ErrCount ; /* conteggio degli errori */ + unsigned char PollFlag ; /* identifica se posso accedere all'UPS */ + /* 0x01: se TRUE, polling abilitato */ + /* 0x02: se TRUE, la routine di polling dati è attiva: devo attendere */ + /* 0x04: se TRUE, bisogna rileggere la configurazione del gruppo */ + /* ------------------------------------------------------------------------ */ + unsigned long Counter ; /* contatore: viene incrementato ad ogni nuovo POLL */ + unsigned char CommStatus ; /* stato delle comunicazioni */ + /* unsigned char FramePointer ; */ + size_t FramePointer ; /* puntatore al carattere di START dei dati ricevuti */ + /* ------------------------------------------------------------------------ */ + char UpsModel[9] ; /* modello UPS (8 caratteri) */ + unsigned char ge_2kVA ; /* if more or equal to 2KVA */ + char SerialNumber[9] ; /* numero di serie dell'UPS */ - unsigned short int YearOfProd ; // anno di produzione dell'UPS - unsigned char MonthOfProd ; // Mese di produzione dell'UPS - unsigned char DayOfProd ; // Giorno di produzione dell'UPS - unsigned char HW_MajorVersion ; // Hardware: Major version - unsigned char HW_MinorVersion ; // Hardware: Minor version - unsigned char BR_MajorVersion ; // BoardHardware: Major version - unsigned char BR_MinorVersion ; // BoardHardware: Minor version - unsigned char FW_MajorVersion ; // Firmware: Major version - unsigned char FW_MinorVersion ; // Firmware: Minor version - unsigned char FW_SubVersion ; // Firmware: SUBVERSION (special releases - // for particular customers) + unsigned short int YearOfProd ; /* anno di produzione dell'UPS */ + unsigned char MonthOfProd ; /* Mese di produzione dell'UPS */ + unsigned char DayOfProd ; /* Giorno di produzione dell'UPS */ + unsigned char HW_MajorVersion ; /* Hardware: Major version */ + unsigned char HW_MinorVersion ; /* Hardware: Minor version */ + unsigned char BR_MajorVersion ; /* BoardHardware: Major version */ + unsigned char BR_MinorVersion ; /* BoardHardware: Minor version */ + unsigned char FW_MajorVersion ; /* Firmware: Major version */ + unsigned char FW_MinorVersion ; /* Firmware: Minor version */ + unsigned char FW_SubVersion ; /* Firmware: SUBVERSION (special releases */ + /* for particular customers) */ - unsigned char BatteryNumber ; // number of batteries in UPS - //------------------------------------------------------------------------ - unsigned long StatusUPS ; // flag di stato dell'UPS 4 byte): 1=TRUE - // bit 0 => BATTERY_MODE - // bit 1 => BATTERY_LOW - // bit 2 => BATTERY_END - // bit 3 => ONLINE (funzionamento in rete) - // bit 4 => MAINS_ON (rete di ingresso presente) - // bit 5 => STANDBY (UPS in modo Standby) - // bit 6 => WAIT_MAINS (UPS in fase di INIT + attesa rete) - // bit 7 => INIT (UPS in fase di inizializzazione) - // ------ - // bit 8 => MASK_OK (semionda OK) - // bit 9 => MEAN_OK (media tensione di ingresso OK) - // bit 10 => SYNC_OK (sincronizzazione semionda OK) - // bit 11 => FAULT (generico) - // bit 12 => TEMP_MAX (superato livello critico di temperatura) - // bit 13 => TEMP_FAULT (Fault da temperatura: UPS si spegne) - // bit 14 => LOAD_MAX (soglia overload superata) - // bit 15 => LOAD_FAULT (Fault da carico: UPS si spegne) - // ------ - // bit 16 => INV_FAULT (Fault dell'inverter) - // bit 17 => IINV_MAX (eccessiva corrente sull'inverter) - // bit 18 => IINV_FAULT (Fault sulla corrente inverter: l'UPS si spegne) - // bit 19 => 50_60Hz (1=60Hz) - // bit 20 => EEP_FAULT (problemi con la EEPROM) - // bit 21 => VOUT_FAULT (tensione uscita troppo bassa) - // bit 22 => - non definito - - // bit 23 => - non definito - - // ------ - // bit 24 to 31 => - NON DEFINITI - + unsigned char BatteryNumber ; /* number of batteries in UPS */ + /* ------------------------------------------------------------------------ */ + uint32_t StatusUPS ; /* flag di stato dell'UPS 4 byte): 1=TRUE */ + /* bit 0 => BATTERY_MODE */ + /* bit 1 => BATTERY_LOW */ + /* bit 2 => BATTERY_END */ + /* bit 3 => ONLINE (funzionamento in rete) */ + /* bit 4 => MAINS_ON (rete di ingresso presente) */ + /* bit 5 => STANDBY (UPS in modo Standby) */ + /* bit 6 => WAIT_MAINS (UPS in fase di INIT + attesa rete) */ + /* bit 7 => INIT (UPS in fase di inizializzazione) */ + /* ------ */ + /* bit 8 => MASK_OK (semionda OK) */ + /* bit 9 => MEAN_OK (media tensione di ingresso OK) */ + /* bit 10 => SYNC_OK (sincronizzazione semionda OK) */ + /* bit 11 => FAULT (generico) */ + /* bit 12 => TEMP_MAX (superato livello critico di temperatura) */ + /* bit 13 => TEMP_FAULT (Fault da temperatura: UPS si spegne) */ + /* bit 14 => LOAD_MAX (soglia overload superata) */ + /* bit 15 => LOAD_FAULT (Fault da carico: UPS si spegne) */ + /* ------ */ + /* bit 16 => INV_FAULT (Fault dell'inverter) */ + /* bit 17 => IINV_MAX (eccessiva corrente sull'inverter) */ + /* bit 18 => IINV_FAULT (Fault sulla corrente inverter: l'UPS si spegne) */ + /* bit 19 => 50_60Hz (1=60Hz) */ + /* bit 20 => EEP_FAULT (problemi con la EEPROM) */ + /* bit 21 => VOUT_FAULT (tensione uscita troppo bassa) */ + /* bit 22 => - non definito - */ + /* bit 23 => - non definito - */ + /* ------ */ + /* bit 24 to 31 => - NON DEFINITI - */ - unsigned short int ShortStatus ; // the LSB 2 bytes of the status - unsigned char OutConfig ; // stato uscite UPS - float Vinput ; // tensione di INPUT in 1/10 di Volt - float Voutput ; // tensione di OUTPUT in 1/10 di Volt - float Temp ; // temperatura in 1/10 di grado - float InpFreq ; // Frequenza di INPUT in 1/10 di Hz - float OutFreq ; // Frequenza di OUTPUT in 1/10 di Hz - float OutCurrent ; // Corrente di Output in 1/10 di A - unsigned char LoadPerc ; // Percentuale di carico - unsigned short int LoadVA ; // Carico in VA - float ChgCurrent ; // corrente carica batterie + uint16_t ShortStatus ; /* the LSB 2 bytes of the status */ + unsigned char OutConfig ; /* stato uscite UPS */ + float Vinput ; /* tensione di INPUT in 1/10 di Volt */ + float Voutput ; /* tensione di OUTPUT in 1/10 di Volt */ + float Temp ; /* temperatura in 1/10 di grado */ + float InpFreq ; /* Frequenza di INPUT in 1/10 di Hz */ + float OutFreq ; /* Frequenza di OUTPUT in 1/10 di Hz */ + float OutCurrent ; /* Corrente di Output in 1/10 di A */ + unsigned char LoadPerc ; /* Percentuale di carico */ + unsigned short int LoadVA ; /* Carico in VA */ + float ChgCurrent ; /* corrente carica batterie */ - float Vbatt ; // tensione delle batterie in 1/10 di Volt - unsigned char PercBatt ; // percentuale di carica della batteria - unsigned short int RtimeEmpty; // minuti alla scarica della batteria - unsigned char PercEmpty ; // percentuale alla scarica: 0%=scarica, 100%=carica - unsigned char OutStatus ; // stato delle uscite + float Vbatt ; /* tensione delle batterie in 1/10 di Volt */ + unsigned char PercBatt ; /* percentuale di carica della batteria */ + unsigned short int RtimeEmpty; /* minuti alla scarica della batteria */ + unsigned char PercEmpty ; /* percentuale alla scarica: 0%=scarica, 100%=carica */ + unsigned char OutStatus ; /* stato delle uscite */ - unsigned char Year ; // - unsigned char Month ; // - unsigned char Day ; // - unsigned char WeekDay ; // Giorno della settimana - unsigned char Hour ; // Ora - unsigned char Min ; // minuti - unsigned char Sec ; // secondi + unsigned char Year ; /* */ + unsigned char Month ; /* */ + unsigned char Day ; /* */ + unsigned char WeekDay ; /* Giorno della settimana */ + unsigned char Hour ; /* Ora */ + unsigned char Min ; /* minuti */ + unsigned char Sec ; /* secondi */ - unsigned char BattLowPerc ; // percentuale carica batteria quando va in BLOW - unsigned long Rtime ; // numero di minuti di accensione dell'UPS - unsigned long RtimeBatt ; // numero di secondi*2 in modalità batteria dall'accensione - //------------------------------------------------------------------------ - unsigned int ShutdownDelay ; // Shutdown delay in seconds - unsigned int WakeUpDelay ; // WakeUp delay in seconds - } ENT_STRUCT ; + unsigned char BattLowPerc ; /* percentuale carica batteria quando va in BLOW */ + unsigned long Rtime ; /* numero di minuti di accensione dell'UPS */ + unsigned long RtimeBatt ; /* numero di secondi*2 in modalità batteria dall'accensione */ + /* ------------------------------------------------------------------------ */ + unsigned int ShutdownDelay ; /* Shutdown delay in seconds */ + unsigned int WakeUpDelay ; /* WakeUp delay in seconds */ +} ENT_STRUCT ; - - -#endif // ENTERPRISE_PROTOCOL +#endif /* ENTERPRISE_PROTOCOL */ #endif diff --git a/drivers/microsol-apc.c b/drivers/microsol-apc.c new file mode 100644 index 0000000..20e0cd3 --- /dev/null +++ b/drivers/microsol-apc.c @@ -0,0 +1,188 @@ +/* microsol-apc.c - APC Back-UPS BR series UPS driver + + Copyright (C) 2004 Silvino B. Magalhães + 2019 Roberto Panerai Velloso + 2021 Ygor A. S. Regados + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + 2021/03/19 - Version 0.70 - Initial release, based on solis driver + +*/ + +#include "config.h" /* must be first */ + +#include +#include +#include "main.h" +#include "serial.h" +#include "nut_float.h" +#include "timehead.h" + +#include "microsol-common.h" +#include "microsol-apc.h" + +#define DRIVER_NAME "APC Back-UPS BR series UPS driver" +#define DRIVER_VERSION "0.69" + +/* driver description structure */ +upsdrv_info_t upsdrv_info = { + DRIVER_NAME, + DRIVER_VERSION, + "Silvino B. Magalhães " + "Roberto Panerai Velloso " + "Ygor A. S. Regados ", + DRV_STABLE, + { NULL } +}; + +#define false 0 +#define true 1 +#define RESP_END 0xFE +#define ENDCHAR 13 /* replies end with CR */ +/* solis commands */ +#define CMD_UPSCONT 0xCC +#define CMD_SHUT 0xDD +#define CMD_SHUTRET 0xDE +#define CMD_EVENT 0xCE +#define CMD_DUMP 0xCD + +/** Check if UPS model is available here. */ +bool_t ups_model_defined(void) +{ + unsigned int model_index; + + for (model_index = 0; MODELS[model_index] != ups_model; model_index++); + if (model_index == MODEL_COUNT) { + return 0; + } else { + return 1; + } +} + +/** Set UPS model name. */ +void set_ups_model(void) +{ + switch (ups_model) { + case 183: + model_name = "BZ2200I-BR"; + break; + case 190: + model_name = "BZ1500-BR"; + break; + case 191: + model_name = "BZ2200BI-BR"; + break; + default: + model_name = "Unknown UPS"; + } +} + +/** + * Parse received packet with UPS instantaneous data. + * This function parses model-specific values, such as voltage and battery times. + */ +void scan_received_pack_model_specific(void) +{ + unsigned int relay_state; + unsigned int model_index; + float real_power_curve_1, real_power_curve_2, real_power_curve_3; + float power_difference_1, power_difference_2, power_difference_3; + bool_t recharging; + + /* Extract unprocessed data from packet */ + input_voltage = received_packet[2]; + output_voltage = received_packet[1]; + output_current = received_packet[5]; + battery_voltage = received_packet[3]; + + relay_state = (received_packet[6] & 0x28) >> 3; + + /* Find array indexes for detected UPS model */ + for (model_index = 0; MODELS[model_index] != ups_model && model_index < MODEL_COUNT - 1; model_index++); + if (MODELS[model_index] != ups_model) { + upslogx(LOG_NOTICE, "UPS model not found, using fallback option."); + } + + /* Start processing according to model */ + nominal_power = NOMINAL_POWER[model_index]; + + input_voltage = INPUT_VOLTAGE_MULTIPLIER_A[model_index][output_220v] * input_voltage + INPUT_VOLTAGE_MULTIPLIER_B[model_index][output_220v]; + + battery_voltage = BATTERY_VOLTAGE_MULTIPLIER_A[model_index] * battery_voltage + BATTERY_VOLTAGE_MULTIPLIER_B[model_index]; + + output_current = OUTPUT_CURRENT_MULTIPLIER_A[model_index][line_unpowered] * output_current + OUTPUT_CURRENT_MULTIPLIER_B[model_index][line_unpowered]; + + if (ups_model == 190 && line_unpowered) { + /* Special calculation for BZ1500 on battery */ + output_voltage = battery_voltage * sqrt(output_voltage / 64.0) * OUTPUT_VOLTAGE_MULTIPLIER_A[model_index][line_unpowered][relay_state] + - output_current * OUTPUT_VOLTAGE_MULTIPLIER_B[model_index][line_unpowered][relay_state]; + output_voltage = 1.5091 * output_voltage + 1.5823; + + if (output_current > 4.0) + output_voltage += output_current * 4.0; + + if (output_current > 3.0) + output_voltage += output_current * 2.0; + else if (output_voltage > 0.9) + output_voltage += output_current / 3.0; + else + output_voltage -= 5.0; + + if (output_voltage < 100.0) + output_voltage = 100; + } else { + output_voltage = OUTPUT_VOLTAGE_MULTIPLIER_A[model_index][line_unpowered][relay_state] * output_voltage + OUTPUT_VOLTAGE_MULTIPLIER_B[model_index][line_unpowered][relay_state]; + } + + if (line_unpowered) { + input_frequency = 0; + output_frequency = 60; + } else { + input_frequency = 0.37 * (257 - ((received_packet[21] + received_packet[22] * 256) >> 8)); + output_frequency = input_frequency; + } + + apparent_power = output_current * output_voltage; + + real_power = received_packet[7] + 256 * received_packet[8]; + real_power_curve_1 = REAL_POWER_CURVE_SELECTOR_A1[model_index][relay_state] * real_power + REAL_POWER_CURVE_SELECTOR_B1[model_index][relay_state]; + real_power_curve_2 = REAL_POWER_CURVE_SELECTOR_A2[model_index][relay_state] * real_power + REAL_POWER_CURVE_SELECTOR_B2[model_index][relay_state]; + real_power_curve_3 = REAL_POWER_CURVE_SELECTOR_A3[model_index][relay_state] * real_power + REAL_POWER_CURVE_SELECTOR_B3[model_index][relay_state]; + + power_difference_1 = fabs(real_power_curve_1 - apparent_power); + power_difference_2 = fabs(real_power_curve_2 - apparent_power); + power_difference_3 = fabs(real_power_curve_3 - apparent_power); + + if (power_difference_1 < power_difference_2 && power_difference_1 < power_difference_3) { + real_power = REAL_POWER_MULTIPLIER_A1[model_index][relay_state] * real_power + REAL_POWER_MULTIPLIER_B1[model_index][relay_state]; + } else if (power_difference_2 < power_difference_3) { + real_power = REAL_POWER_MULTIPLIER_A2[model_index][relay_state] * real_power + REAL_POWER_MULTIPLIER_B2[model_index][relay_state]; + } else { + real_power = REAL_POWER_MULTIPLIER_A3[model_index][relay_state] * real_power + REAL_POWER_MULTIPLIER_B3[model_index][relay_state]; + } + + /* If real power is greater than apparent power, invert values */ + if (apparent_power < real_power) { + apparent_power = apparent_power + real_power; + real_power = apparent_power - real_power; + apparent_power = apparent_power - real_power; + } + + input_current = 1.1 * apparent_power / input_voltage; + + recharging = (0x02 & received_packet[20]) == 0x02; + battery_charge = (100.0 * (battery_voltage - MIN_BATTERY_VOLTAGE[model_index])) / (MAX_BATTERY_VOLTAGE[model_index][recharging] - MIN_BATTERY_VOLTAGE[model_index]); +} diff --git a/drivers/microsol-apc.h b/drivers/microsol-apc.h new file mode 100644 index 0000000..6f38d28 --- /dev/null +++ b/drivers/microsol-apc.h @@ -0,0 +1,230 @@ +/* microsol-apc.h - APC Back-UPS BR series UPS driver + + Copyright (C) 2004 Silvino B. Magalhaes + 2019 Roberto Panerai Velloso + 2021 Ygor A. S. Regados + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + 2021/03/19 - Version 0.70 - Initial release, based on solis driver + +*/ + +#ifndef INCLUDED_MICROSOL_APC_H +#define INCLUDED_MICROSOL_APC_H + +#define MODEL_COUNT 3 + +/* Supported UPS models */ +static const unsigned int MODELS[MODEL_COUNT] = { + 183 /* APC Back-UPS BZ2200I-BR */ , + 190 /* APC Back-UPS BZ1500-BR */ , + 191 /* APC Back-UPS BZ2200BI-BR */ +}; + +/* Note: int type here is aligned with the "nominal_power" + * variable in microsol-common.h and many related drivers. + */ +static const int NOMINAL_POWER[MODEL_COUNT] = { + 2200 /* Model 183 */ , + 1500 /* Model 190 */ , + 2200 /* Model 191 */ +}; + +/* Curves for output voltage (depends on relay state and battery state) + * Second index: On-line (0) or On-battery (1) + * Third index: Electric relay state + */ +/* For on-line UPS */ +static const float OUTPUT_VOLTAGE_MULTIPLIER_A[MODEL_COUNT][2][8] = { + { + { 1.831, 1.831, 1.831, 1.831, 1.831, 1.831, 1.831, 1.831}, + { 0.1566, 0.1566, 0.1566, 0.1566, 0.1566, 0.1566, 0.1566, 0.1566} + } /* Model 183 */ , + { + { 0.9266, 0.9266, 0.9266, 0.9266, 0.9266, 0.9266, 0.9266, 0.9266}, + { 5.59, 9.47, 13.7, 0.0, 0.0, 0.0, 0.0, 0.0} + } /* Model 190 */ , + { + { 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00}, + { 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26, 1.26} + } /* Model 191 */ +}; + +static const float OUTPUT_VOLTAGE_MULTIPLIER_B[MODEL_COUNT][2][8] = { + { + { -2.1374, -2.1374, -2.1374, -2.1374, -2.1374, -2.1374, -2.1374, -2.1374}, + { 204.93, 204.93, 204.93, 204.93, 204.93, 204.93, 204.93, 204.93} + } /* Model 183 */ , + { + { 5.0694, 5.0694, 5.0694, 5.0694, 5.0694, 5.0694, 5.0694, 5.0694}, + { 5.4, 6.5, 17.6, 0.0, 0.0, 0.0, 0.0, 0.0} + } /* Model 190 */ , + { + { 20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0, 20.0}, + { -5.91, -5.91, -5.91, -5.91, -5.91, -5.91, -5.91, -5.91} + } /* Model 191 */ +}; + +/* Curves for output current + * Second index: On-line (0) or On-battery (1) + */ +static const float OUTPUT_CURRENT_MULTIPLIER_A[MODEL_COUNT][2] = { + { + 0.0892999991774559, + 0.09070000052452087 } /* Model 183 */ , + { + 0.1264, + 0.1303 } /* Model 190 */ , + { + 0.13819999992847443, + 0.08959999680519104 } /* Model 191 */ , +}; + +static const float OUTPUT_CURRENT_MULTIPLIER_B[MODEL_COUNT][2] = { + { + 0.09350000321865082, + 0.14550000429153442 } /* Model 183 */ , + { + 0.522, + 0.468 } /* Model 190 */ , + { + 0.12999999523162842, + 0.1881999969482422 } /* Model 191 */ +}; + +/* Curves for input voltage (depends on nominal output voltage) + * Second index: Nominal output voltage = 220V (1) or 115V (0). + */ +static const float INPUT_VOLTAGE_MULTIPLIER_A[MODEL_COUNT][2] = { + { 1.7937, 1.7937 } /* Model 183 */ , + { 1.8, 1.8 } /* Model 190 */ , + { 1.4825, 1.4952 } /* Model 191 */ +}; + +static const float INPUT_VOLTAGE_MULTIPLIER_B[MODEL_COUNT][2] = { + { 1.854, 1.854 } /* Model 183 */ , + { 2.224, 2.224 } /* Model 190 */ , + { 0.0853, -2.4241 } /* Model 191 */ +}; + +/* Curves for battery voltage */ +static const float BATTERY_VOLTAGE_MULTIPLIER_A[MODEL_COUNT] = { + 0.1551 /* Model 183 */ , + 0.1513 /* Model 190 */ , + 0.1543 /* Model 191 */ +}; + +static const float BATTERY_VOLTAGE_MULTIPLIER_B[MODEL_COUNT] = { + 0.0654 /* Model 183 */ , + 0.7153 /* Model 190 */ , + 0.1414 /* Model 191 */ +}; + +/* Real power estimation curves (depends on relay state) */ +/* + * Remarks: + * - Model 190 use a direct real power determination (no need for curve selectors) + */ +static const float REAL_POWER_CURVE_SELECTOR_A1[MODEL_COUNT][8] = { + { 0.24, 0.26, 0.0, 0.0, 0.24, 0.26, 0.0, 0.28 } /* Model 183 */ , + { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 } /* Model 190 */ , + { 0.24, 0.26, 0.0, 0.0, 0.24, 0.26, 0.0, 0.28 } /* Model 191 */ +}; + +static const float REAL_POWER_CURVE_SELECTOR_B1[MODEL_COUNT][8] = { + { 83.15, 81.23, 0.0, 0.0, 83.49, 79.05, 0.0, 85.67 } /* Model 183 */ , + { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 } /* Model 190 */ , + { 83.15, 81.23, 0.0, 0.0, 83.49, 79.05, 0.0, 85.67 } /* Model 191 */ +}; + +static const float REAL_POWER_CURVE_SELECTOR_A2[MODEL_COUNT][8] = { + { 0.0763, 0.081, 0.0919, 0.0, 0.0741, 0.0828, 0.0, 0.0938 } /* Model 183 */ , + { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 } /* Model 190 */ , + { 0.0763, 0.081, 0.0919, 0.0, 0.0741, 0.0828, 0.0, 0.0938 } /* Model 191 */ +}; + +static const float REAL_POWER_CURVE_SELECTOR_B2[MODEL_COUNT][8] = { + { 81.732, 94.459, 86.686, 0.0, 84.657, 84.999, 0.0, 78.097 } /* Model 183 */ , + { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 } /* Model 190 */ , + { 81.732, 94.459, 86.686, 0.0, 84.657, 84.999, 0.0, 78.097 } /* Model 191 */ +}; + +static const float REAL_POWER_CURVE_SELECTOR_A3[MODEL_COUNT][8] = { + { 0.0744, 0.0808, 0.0885, 0.0, 0.0732, 0.084, 0.0, 0.0955 } /* Model 183 */ , + { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 } /* Model 190 */ , + { 0.0744, 0.0808, 0.0885, 0.0, 0.0732, 0.084, 0.0, 0.0955 } /* Model 191 */ +}; + +static const float REAL_POWER_CURVE_SELECTOR_B3[MODEL_COUNT][8] = { + { 122.06, 122.9, 125.75, 0.0, 120.39, 108.52, 0.0, 92.239 } /* Model 183 */ , + { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 } /* Model 190 */ , + { 122.06, 122.9, 125.75, 0.0, 120.39, 108.52, 0.0, 92.239 } /* Model 191 */ +}; + +static const float REAL_POWER_MULTIPLIER_A1[MODEL_COUNT][8] = { + { 0.08040007075206226, 0.0894, 0.0999, 0.0, 0.0813, 0.0905, 0.0, 0.1005 } /* Model 183 */ , + { 0.1127, 0.1127, 0.1127, 0.1127, 0.1127, 0.1127, 0.1127, 0.1127 } /* Model 190 */ , + { 0.08040007075206226, 0.0894, 0.0999, 0.0, 0.0813, 0.0905, 0.0, 0.1005 } /* Model 191 */ +}; + +static const float REAL_POWER_MULTIPLIER_B1[MODEL_COUNT][8] = { + { 45.292, 41.928, 41.727, 0.0, 40.269, 41.81, 0.0, 43.458 } /* Model 183 */ , + { 50.031, 50.031, 50.031, 50.031, 50.031, 50.031, 50.031, 50.031 } /* Model 190 */ , + { 45.292, 41.928, 41.727, 0.0, 40.269, 41.81, 0.0, 43.458 } /* Model 191 */ +}; + +static const float REAL_POWER_MULTIPLIER_A2[MODEL_COUNT][8] = { + { 0.08630063689870031, 0.0946, 0.1068, 0.0, 0.086, 0.0967, 0.0, 0.1088 } /* Model 183 */ , + { 0.1127, 0.1127, 0.1127, 0.1127, 0.1127, 0.1127, 0.1127, 0.1127 } /* Model 190 */ , + { 0.08630063689870031, 0.0946, 0.1068, 0.0, 0.086, 0.0967, 0.0, 0.1088 } /* Model 191 */ +}; + +static const float REAL_POWER_MULTIPLIER_B2[MODEL_COUNT][8] = { + { 8.3927, 9.2393, 8.2852, 0.0, 8.301, 6.7636, 0.0, 8.2842 } /* Model 183 */ , + { 50.031, 50.031, 50.031, 50.031, 50.031, 50.031, 50.031, 50.031 } /* Model 190 */ , + { 8.3927, 9.2393, 8.2852, 0.0, 8.301, 6.7636, 0.0, 8.2842 } /* Model 191 */ +}; + +static const float REAL_POWER_MULTIPLIER_A3[MODEL_COUNT][8] = { + { 0.0896001146881468, 0.0991, 0.1116, 0.0, 0.0967, 0.1068, 0.0, 0.1169 } /* Model 183 */ , + { 0.1127, 0.1127, 0.1127, 0.1127, 0.1127, 0.1127, 0.1127, 0.1127 } /* Model 190 */ , + { 0.0896001146881468, 0.0991, 0.1116, 0.0, 0.0967, 0.1068, 0.0, 0.1169 } /* Model 191 */ +}; + +static const float REAL_POWER_MULTIPLIER_B3[MODEL_COUNT][8] = { + { -31.115, -33.777, -33.826, 0.0, -59.513, -57.729, 0.0, -41.333 } /* Model 183 */ , + { 50.031, 50.031, 50.031, 50.031, 50.031, 50.031, 50.031, 50.031 } /* Model 190 */ , + { -31.115, -33.777, -33.826, 0.0, -59.513, -57.729, 0.0, -41.333 } /* Model 191 */ +}; + +/** + * Maximum battery voltage, used to estimate battery charge + * Second index: Recharging battery flag: charging (1) or charged/discharging (0) + */ +static const float MAX_BATTERY_VOLTAGE[MODEL_COUNT][2] = { + { 27.0, 29.5 } /* Model 183 */ , + { 27.0, 29.5 } /* Model 190 */ , + { 27.0, 29.5 } /* Model 191 */ +}; + +/** Minimum battery voltage, used to estimate battery charge */ +static const float MIN_BATTERY_VOLTAGE[MODEL_COUNT] = { + 20 /* Model 183 */ , + 20 /* Model 190 */ , + 20 /* Model 191 */ +}; + +#endif /* INCLUDED_MICROSOL_APC_H */ diff --git a/drivers/microsol-common.c b/drivers/microsol-common.c new file mode 100644 index 0000000..84ed6fe --- /dev/null +++ b/drivers/microsol-common.c @@ -0,0 +1,809 @@ +/* microsol-common.c - common framework for Microsol Solis-based UPS hardware + + Copyright (C) 2004 Silvino B. Magalhães + 2019 Roberto Panerai Velloso + 2021 Ygor A. S. Regados + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + 2021/03/19 - Version 0.70 - Initial release, based on solis driver + +*/ + +#include "main.h" /* Includes "config.h", must be first */ + +#include +#include +#include +#include "serial.h" +#include "nut_float.h" +#include "nut_stdint.h" +#include "microsol-common.h" +#include "timehead.h" + +#define false 0 +#define true 1 +#define RESP_END 0xFE +#define ENDCHAR 13 /* replies end with CR */ +/* solis commands */ +#define CMD_UPSCONT 0xCC +#define CMD_SHUT 0xDD +#define CMD_SHUTRET 0xDE +#define CMD_EVENT 0xCE +#define CMD_DUMP 0xCD + +#define M_UNKN "Unknown solis model" +#define NO_SOLIS "Solis not detected! aborting ..." +#define UPS_DATE "UPS Date %4d/%02d/%02d" +#define SYS_DATE "System Date %4d/%02d/%02d day of week %s" +#define ERR_PACK "Wrong package" +#define NO_EVENT "No events" +#define UPS_TIME "UPS internal Time %0d:%02d:%02d" +#define PRG_DAYS "Programming Shutdown Sun Mon Tue Wed Thu Fri Sat" +#define PRG_ONON "External shutdown programming active" +#define PRG_ONOU "Internal shutdown programming active" +#define TIME_OFF "UPS Time power off %02d:%02d" +#define TIME_ON "UPS Time power on %02d:%02d" +#define PRG_ONOF "Shutdown programming not activated" +#define TODAY_DD "Shutdown today at %02d:%02d" +#define SHUT_NOW "Shutdown now!" + +#define FMT_DAYS " %d %d %d %d %d %d %d" + +/* Date, time and programming group */ +static int const BASE_YEAR = 1998; /* Note: code below uses relative "unsigned char" years */ +static int device_day, device_month, device_year; +static int device_hour, device_minute, device_second; +static int power_off_hour, power_off_minute; +static int power_on_hour, power_on_minute; +static uint8_t device_days_on = 0, device_days_off = 0, days_to_shutdown = 0; + +static int isprogram = 0, progshut = 0, prgups = 0; +static int hourshut, minshut; + +static int host_year, host_month, host_day; +static int host_week; +static int host_hour, host_minute, host_second; + +/* buffers */ +unsigned char received_packet[PACKET_SIZE]; + +/* Identification */ +const char *model_name; +unsigned int ups_model; +bool_t input_220v, output_220v; + +/* logical */ +bool_t detected = 0; +bool_t line_unpowered, overheat; +bool_t overload, critical_battery, inverter_working; +static bool_t recharging; +static bool_t packet_parsed = false; + +double input_voltage, input_current, input_frequency; +double output_voltage, output_current, output_frequency; + +double input_low_limit, input_high_limit; + +int battery_extension; +double battery_voltage, battery_charge; +double temperature; + +double apparent_power, real_power, ups_load; +int load_power_factor, nominal_power; + +/** + * Convert standard days string to firmware format + * This is needed because UPS sends binary date rotated + * from current week day (first bit = current day) + */ +static char *convert_days(char *cop) +{ + static char alt[8]; + + int ish, fim; + /* FIXME? Are range-checks needed for values more than 6? wire noise etc? */ + if (host_week == 6) + ish = 0; + else + ish = 1 + host_week; + + fim = 7 - ish; + /* rotate left only 7 bits */ + + if (fim > 0) { + memcpy(alt, &cop[ish], (size_t)fim); + } else { + fatalx(EXIT_FAILURE, "%s: value out of range: %d (%d)", + __func__, fim, ish); + } + + if (ish > 0) + memcpy(&alt[fim], cop, (size_t)ish); + + alt[7] = 0; /* string terminator */ + + return alt; +} + +/** Convert bitstring (e.g. 1100101) to binary */ +static uint8_t bitstring_to_binary(char *binStr) +{ + uint8_t result = 0; + unsigned int i; + + for (i = 0; i < 7; ++i) { + char ch = binStr[i]; + if (ch == '1' || ch == '0') + result += ((ch - '0') << (6 - i)); + else + return 0; + } + + return result; +} + +/** + * Revert firmware format to standard string binary days + * This is needed because UPS sends binary date rotated + * from current week day (first bit = current day) + */ +static uint8_t revert_days(unsigned char firmware_week) +{ + char ordered_week[8]; + int i; + + for (i = 0; i < (6 - host_week); ++i) + ordered_week[i] = (firmware_week >> (5 - host_week - i)) & 0x01; + + for (i = 0; i < host_week + 1; ++i) + ordered_week[i + (6 - host_week)] = (firmware_week >> (6 - i)) & 0x01; + + for (i = 0; i < 7; i++) + ordered_week[i] += '0'; + + ordered_week[7] = 0; /* string terminator */ + + return bitstring_to_binary(ordered_week); +} + +/** Parse time string from parameters and store their values */ +static bool_t set_schedule_time(char *hour, bool_t off_time) +{ + int string_hour, string_minute; + + if ((strlen(hour) != 5) || (sscanf(hour, "%d:%d", &string_hour, &string_minute) != 2)) + return 0; + + if (off_time) { + power_off_hour = string_hour; + power_off_minute = string_minute; + } else { + power_on_hour = string_hour; + power_on_minute = string_minute; + } + return 1; +} + +/** Send immediate shutdown command to UPS */ +static void send_shutdown(void) +{ + unsigned int i; + + for (i = 0; i < 10; i++) + ser_send_char(upsfd, CMD_SHUT); + + upslogx(LOG_NOTICE, "UPS shutdown command sent"); +} + +/** Store clock updates and shutdown schedules to UPS */ +static void save_ups_config(void) +{ + unsigned int i; + int checksum = 0; + unsigned char configuration_packet[12]; + + /* Prepare configuration packet */ + /* FIXME? Check for overflows with int => char truncations? */ + configuration_packet[0] = (unsigned char)0xCF; + configuration_packet[1] = (unsigned char)host_hour; + configuration_packet[2] = (unsigned char)host_minute; + configuration_packet[3] = (unsigned char)host_second; + configuration_packet[4] = (unsigned char)power_on_hour; + configuration_packet[5] = (unsigned char)power_on_minute; + configuration_packet[6] = (unsigned char)power_off_hour; + configuration_packet[7] = (unsigned char)power_off_minute; + configuration_packet[8] = (unsigned char)(host_week << 5); + configuration_packet[8] = (unsigned char)configuration_packet[8] | (unsigned char)host_day; + configuration_packet[9] = (unsigned char)(host_month << 4); + configuration_packet[9] = (unsigned char)configuration_packet[9] | (unsigned char)(host_year - BASE_YEAR); + configuration_packet[10] = (unsigned char)device_days_off; + + /* MSB zero */ + configuration_packet[10] = configuration_packet[10] & (~(0x80)); + + /* Calculate packet content checksum */ + for (i = 0; i < 11; i++) { + checksum += configuration_packet[i]; + } + /* FIXME? Does truncation to char have same effect as %256 ? */ + configuration_packet[11] = (unsigned char)(checksum % 256); + + /* Send final packet and checksum to serial port */ + for (i = 0; i < 12; i++) { + ser_send_char(upsfd, configuration_packet[i]); + } +} + +/** Log shut-down schedule data stored in UPS */ +static void print_info(void) +{ + /* sunday, monday, tuesday, wednesday, thursday, friday, saturday */ + char week_days[7] = { 0, 0, 0, 0, 0, 0, 0 }; + unsigned int i; + + upslogx(LOG_NOTICE, UPS_DATE, device_year, device_month, device_day); + upslogx(LOG_NOTICE, UPS_TIME, device_hour, device_minute, device_second); + + if (prgups > 0) { + /* this is the string to binary standard */ + for (i = 0; i < 7; i++) { + week_days[i] = (days_to_shutdown >> (6 - i)) & 0x01; + } + + if (prgups == 3) + upslogx(LOG_NOTICE, PRG_ONOU); + else + upslogx(LOG_NOTICE, PRG_ONON); + + upslogx(LOG_NOTICE, TIME_ON, power_on_hour, power_on_minute); + upslogx(LOG_NOTICE, TIME_OFF, power_off_hour, power_off_minute); + + upslogx(LOG_NOTICE, PRG_DAYS); + + upslogx(LOG_NOTICE, FMT_DAYS, week_days[0], week_days[1], week_days[2], week_days[3], week_days[4], week_days[5], week_days[6]); + } else { + upslogx(LOG_NOTICE, PRG_ONOF); + } +} + +/** Parses received packet with UPS readings and configuration. */ +static void scan_received_pack(void) +{ + /* UPS internal time */ + device_year = (received_packet[19] & 0x0F) + BASE_YEAR; + device_month = (received_packet[19] & 0xF0) >> 4; + device_day = (received_packet[18] & 0x1F); + + device_hour = received_packet[11]; + device_minute = received_packet[10]; + device_second = received_packet[9]; + + /* UPS power cycle schedule if in programmed shutdown mode */ + if (prgups == 3) { + device_days_on = received_packet[17]; + days_to_shutdown = revert_days(device_days_on); + + /* Automatic UPS power-off time */ + power_off_hour = received_packet[15]; + power_off_minute = received_packet[16]; + + /* Automatic UPS power-on time */ + power_on_hour = received_packet[13]; + power_on_minute = received_packet[14]; + } + + /* These UPS have 110V- or 220V-output models */ + if ((0x01 & received_packet[20]) == 0x01) { + output_220v = 1; + } + + /* UPS state flags */ + critical_battery = (0x04 & received_packet[20]) == 0x04; + inverter_working = (0x08 & received_packet[20]) == 0x08; + overheat = (0x10 & received_packet[20]) == 0x10; + line_unpowered = (0x20 & received_packet[20]) == 0x20; + overload = (0x80 & received_packet[20]) == 0x80; + + recharging = (0x02 & received_packet[20]) == 0x02; + if (line_unpowered) { + recharging = false; + } + + /* Check if input voltage is 110V or 220V */ + if ((0x40 & received_packet[20]) == 0x40) { + input_220v = 1; + } else { + input_220v = 0; + } + + /* Internal battery temperature */ + temperature = 0x7F & received_packet[4]; + if (0x80 & received_packet[4]) { + temperature -= 128; + } + + /* Parse model-specific data (current and voltages). + * Doing it here as these values are used for the next calculations. */ + scan_received_pack_model_specific(); + + ups_load = (apparent_power / nominal_power) * 100.0; + + if (battery_charge > 100.0) { + battery_charge = 100.0; + } else if (battery_charge < 0.0) { + battery_charge = 0.0; + } + + output_frequency = 60; + if (!inverter_working) { + output_voltage = 0; + output_frequency = 0; + } + + if (!line_unpowered && inverter_working) + output_frequency = input_frequency; + + if (apparent_power < 0) + load_power_factor = 0; + else { + if (d_equal(apparent_power, 0)) + load_power_factor = 100; + else + load_power_factor = ((real_power / apparent_power) * 100); + + if (load_power_factor > 100) { + load_power_factor = 100; + } + } + + /* input 110V or 220v */ + if (input_220v == 0) { + input_low_limit = 75; + input_high_limit = 150; + } else { + input_low_limit = 150; + input_high_limit = 300; + } +} + +/** + * Start processing of received packets + * + * Packet format: 25-bytes binary structure + * Byte 1: Packet type/UPS model + * Byte 2: Output voltage data + * Byte 3: Input voltage data + * Byte 4: Battery voltage data + * Byte 5: UPS temperature data + * Byte 6: Output current data + * Byte 7: Electrical relay setup + * Byte 8-9: Real power data + * Byte 10: UPS clock - seconds + * Byte 11: UPS clock - minutes + * Byte 12: UPS clock - hours + * Byte 13: Zero + * Byte 14: UPS scheduler - power-on hour + * Byte 15: UPS scheduler - power-on minute + * Byte 16: UPS scheduler - power-off hour + * Byte 17: UPS scheduler - power-off minute + * Byte 18: UPS scheduler - weekdays + * Byte 19: UPS clock - day of month + * Byte 20: UPS clock - year (since 1998) (left 4 bits) and month (right 4 bits) + * Byte 21: UPS flags (power status, battery status, overload, overheat, nominal input voltage, nominal output voltage) + * Byte 22-23: Input frequency data + * Byte 24: Packet checksum + * Byte 25: Packet delimiter, always 0xFE + */ +static void comm_receive(const unsigned char *bufptr, size_t size) +{ + size_t i; + + if (size == PACKET_SIZE) { + int checksum = 0; + + upsdebug_hex(3, "comm_receive: bufptr", bufptr, size); + + /* Calculate packet checksum */ + for (i = 0; i < PACKET_SIZE - 2; i++) { + checksum += bufptr[i]; + } + checksum = checksum % 256; + upsdebugx(4, "%s: calculated checksum = 0x%02x, bufptr[23] = 0x%02x", __func__, checksum, bufptr[23]); + + /* Only proceed if checksum matches and packet delimiter is found */ + if (checksum == bufptr[23] && bufptr[24] == 254) { + upsdebugx(4, "%s: valid packet received", __func__); + memcpy(received_packet, bufptr, PACKET_SIZE); + + if ((received_packet[0] & 0xF0) == 0xA0 || (received_packet[0] & 0xF0) == 0xB0) { + /* If UPS still not detected, compare with available lists */ + if (!detected) { + ups_model = received_packet[0]; + + detected = true; + } + + if (!ups_model_defined()) { + upslogx(LOG_DEBUG, M_UNKN); + } + + scan_received_pack(); + } + } + } +} + +/** Refresh host time variables */ +static void refresh_host_time(void) +{ + const time_t epoch = time(NULL); + struct tm now; + + localtime_r(&epoch, &now); + host_year = now.tm_year + 1900; + host_month = now.tm_mon + 1; + host_day = now.tm_mday; + host_week = now.tm_wday; + host_hour = now.tm_hour; + host_minute = now.tm_min; + host_second = now.tm_sec; +} + +/** Query shut-down schedule configuration */ +static void setup_poweroff_schedule(void) +{ + bool_t i1 = 0, i2 = 0; + char *daysoff; + + refresh_host_time(); + + if (testvar("prgshut")) { + prgups = atoi(getval("prgshut")); + } + + if (prgups > 0 && prgups < 3) { + if (testvar("daysweek")) { + device_days_on = bitstring_to_binary(convert_days(getval("daysweek"))); + } + + if (testvar("daysoff")) { + daysoff = getval("daysoff"); + days_to_shutdown = bitstring_to_binary(daysoff); + device_days_off = bitstring_to_binary(convert_days(daysoff)); + } + + if (testvar("houron")) { + i1 = set_schedule_time(getval("houron"), 0); + } + + if (testvar("houroff")) { + i2 = set_schedule_time(getval("houroff"), 1); + } + + if (i1 && i2 && (device_days_on > 0)) { + isprogram = 1; + + /* If configured to shut-down UPS, push schedule to internal configuration */ + if (prgups == 2) { + save_ups_config(); + } + } else { + if (i2 == 1 && device_days_off > 0) { + isprogram = 1; + device_days_on = device_days_off; + } + } + } +} + +/** Check shut-down schedule and sets system to shut down if needed */ +static void check_shutdown_schedule(void) +{ + bool_t is_shutdown_day = 0; + + if (isprogram || prgups == 3) { + refresh_host_time(); + + is_shutdown_day = (days_to_shutdown >> (6 - host_week)) & 0x01; + + if (is_shutdown_day) { + upslogx(LOG_NOTICE, TODAY_DD, hourshut, minshut); + + if (host_hour == hourshut && host_minute >= minshut) { + upslogx(LOG_NOTICE, SHUT_NOW); + progshut = 1; + } + } + } +} + +/** Resynchronizes packet boundaries */ +static void resynchronize_packet(void) { + unsigned char sync_received_byte = 0; + unsigned short i; + + /* Flush serial port buffers */ + ser_flush_io(upsfd); + + upsdebugx(3, "%s: Synchronizing packet boundaries...", __func__); + + /* + * - Read until end-of-response character (0xFE): + * read up to 3 packets in size before giving up + * synchronizing with the device. + */ + for (i = 0; i < PACKET_SIZE * 3 && sync_received_byte != RESP_END; i++) { + ser_get_char(upsfd, &sync_received_byte, 3, 0); + } + + /* If no packet boundary was found, terminate communication */ + if (sync_received_byte != RESP_END) { + fatalx(EXIT_FAILURE, NO_SOLIS); + } +} + +/** Synchronize packet receiving and setup basic variables */ +static void get_base_info(void) +{ + unsigned char packet[PACKET_SIZE]; + ssize_t tam; + + if (testvar("battext")) { + battery_extension = atoi(getval("battext")); + } + + setup_poweroff_schedule(); + + /* dummy read attempt to sync - throw it out */ + upsdebugx(3, "%s: sending CMD_UPSCONT and ENDCHAR", __func__); + ser_send(upsfd, "%c%c", CMD_UPSCONT, ENDCHAR); + + resynchronize_packet (); + + upsdebugx(4, "%s: requesting %d bytes from ser_get_buf_len()", __func__, PACKET_SIZE); + tam = ser_get_buf_len(upsfd, packet, PACKET_SIZE, 3, 0); + upsdebugx(2, "%s: received %zd bytes from ser_get_buf_len()", __func__, tam); + if (tam > 0 && nut_debug_level >= 4) { + upsdebug_hex(4, "received from ser_get_buf_len()", packet, (size_t)tam); + } + comm_receive(packet, (size_t)tam); + + if (!detected) { + fatalx(EXIT_FAILURE, NO_SOLIS); + } + + set_ups_model(); + + /* Setup power-off times */ + if (prgups != 0) { + if (prgups == 1) { + /* If only this host is meant to be powered off, use proper time. */ + hourshut = power_off_hour; + minshut = power_off_minute; + } else { + /* If the UPS is to be powered off too, give + * a 5-minute grace time to shutdown hosts */ + if (power_off_minute < 5) { + if (power_off_hour > 1) + hourshut = power_off_hour - 1; + else + hourshut = 23; + + minshut = 60 - (5 - power_off_minute); + } else { + hourshut = power_off_hour; + minshut = power_off_minute - 5; + } + } + } + + /* manufacturer */ + dstate_setinfo("ups.mfr", "%s", "APC"); + + dstate_setinfo("ups.model", "%s", model_name); + dstate_setinfo("input.transfer.low", "%03.1f", input_low_limit); + dstate_setinfo("input.transfer.high", "%03.1f", input_high_limit); + + dstate_addcmd("shutdown.return"); /* CMD_SHUTRET */ + dstate_addcmd("shutdown.stayoff"); /* CMD_SHUT */ + + upslogx(LOG_NOTICE, "Detected %s on %s", dstate_getinfo("ups.model"), device_path); + + print_info(); +} + +/** Retrieves new packet from serial connection and parses it */ +static void get_updated_info(void) +{ + unsigned char temp[256]; + ssize_t tam; + + check_shutdown_schedule(); + + /* get update package */ + temp[0] = 0; /* flush temp buffer */ + + upsdebugx(3, "%s: requesting %d bytes from ser_get_buf_len()", __func__, PACKET_SIZE); + tam = ser_get_buf_len(upsfd, temp, PACKET_SIZE, 3, 0); + + upsdebugx(2, "%s: received %zd bytes from ser_get_buf_len()", __func__, tam); + if (tam > 0 && nut_debug_level >= 4) + upsdebug_hex(4, "received from ser_get_buf_len()", temp, (size_t)tam); + + packet_parsed = false; + if (temp[24] == RESP_END) { + /* Packet boundary found, process packet */ + comm_receive(temp, (size_t)tam); + + packet_parsed = true; + } else { + /* Malformed packet received, possible boundary desynchronization. */ + upsdebugx(3, "%s: Malformed packet received, trying to resynchronize...", __func__); + + resynchronize_packet (); + } +} + +static int instcmd(const char *cmdname, const char *extra) +{ + /* Power-cycle UPS */ + if (!strcasecmp(cmdname, "shutdown.return")) { + ser_send_char(upsfd, CMD_SHUTRET); /* 0xDE */ + return STAT_INSTCMD_HANDLED; + } + + /* Power-off UPS */ + if (!strcasecmp(cmdname, "shutdown.stayoff")) { + ser_send_char(upsfd, CMD_SHUT); /* 0xDD */ + return STAT_INSTCMD_HANDLED; + } + + upslogx(LOG_NOTICE, "instcmd: unknown command [%s] [%s]", cmdname, extra); + return STAT_INSTCMD_UNKNOWN; +} + +void upsdrv_initinfo(void) +{ + get_base_info(); + + upsh.instcmd = instcmd; +} + +void upsdrv_updateinfo(void) +{ + get_updated_info(); + + if (packet_parsed) { + dstate_setinfo("battery.charge", "%03.1f", battery_charge); + dstate_setinfo("battery.voltage", "%02.1f", battery_voltage); + + dstate_setinfo("input.frequency", "%2.1f", input_frequency); + dstate_setinfo("input.voltage", "%03.1f", input_voltage); + + dstate_setinfo("output.current", "%03.1f", output_current); + dstate_setinfo("output.power", "%03.1f", apparent_power); + dstate_setinfo("output.powerfactor", "%0.2f", load_power_factor / 100.0); + dstate_setinfo("output.realpower", "%03.1f", real_power); + dstate_setinfo("output.voltage", "%03.1f", output_voltage); + + dstate_setinfo("ups.temperature", "%2.2f", temperature); + dstate_setinfo("ups.load", "%03.1f", ups_load); + + status_init(); + + if (!line_unpowered) { + status_set("OL"); /* On line */ + } else { + status_set("OB"); /* On battery */ + } + + if (overload) { + status_set("OVER"); /* Overload */ + } + + if (overheat) { + status_set("OVERHEAT"); /* Overheat */ + } + + if (recharging) { + status_set("CHRG"); /* Charging battery */ + } + + if (critical_battery) { + status_set("LB"); /* Critically low battery */ + } + + if (progshut) { + /* Software-based shutdown now */ + if (prgups == 2) + send_shutdown(); /* Send command to shutdown UPS in 4-5 minutes */ + + /* Workaround for triggering servers' power-off before UPS power-off */ + status_set("LB"); + } + + status_commit(); + + dstate_dataok(); + } else { + /* + * If no packet was processed, report data as stale. + * Most likely to be fixed on next received packet. + */ + dstate_datastale (); + } +} + +/*! @brief Power down the attached load immediately. + * Basic idea: find out line status and send appropriate command. + * - on battery: send normal shutdown, UPS will return by itself on utility + * - on line: send shutdown+return, UPS will cycle and return soon. + */ +void upsdrv_shutdown(void) +{ + if (!line_unpowered) { /* on line */ + upslogx(LOG_NOTICE, "On line, sending power cycle command..."); + ser_send_char(upsfd, CMD_SHUTRET); + } else { + upslogx(LOG_NOTICE, "On battery, sending power off command..."); + ser_send_char(upsfd, CMD_SHUT); + } +} + +void upsdrv_help(void) +{ + printf("\nAPC/Microsol options\n\n"); + printf(" Battery extension (AH)\n"); + printf(" battext = 80\n\n"); + printf(" Scheduled UPS power on/off\n"); + printf(" prgshut = 0 (default, no scheduled shutdown)\n"); + printf(" prgshut = 1 (software-based shutdown schedule without UPS power-off)\n"); + printf(" prgshut = 2 (software-based shutdown schedule with UPS power-off)\n"); + printf(" prgshut = 3 (internal UPS shutdown schedule)\n\n"); + printf(" Schedule configuration:\n"); + printf(" daysweek = 1010101 (power on days)\n"); + printf(" daysoff = 1010101 (power off days)\n"); + printf(" where each digit is a day from sun...sat with 0 = off and 1 = on\n\n"); + printf(" houron = hh:mm hh = hour 0-23 mm = minute 0-59 separated with :\n"); + printf(" houroff = hh:mm hh = hour 0-23 mm = minute 0-59 separated with :\n"); + printf(" where houron is power-on hour and houroff is shutdown and power-off hour\n\n"); + printf(" Use daysweek and houron to programming and save UPS power on/off\n"); + printf(" These are valid only if prgshut = 2 or 3\n"); +} + +void upsdrv_makevartable(void) +{ + addvar(VAR_VALUE, "battext", "Battery extension (0-80AH)"); + addvar(VAR_VALUE, "prgshut", "Scheduled power-off mode (0-3)"); + addvar(VAR_VALUE, "daysweek", "Days of week for UPS shutdown"); + addvar(VAR_VALUE, "daysoff", "Days of week for driver-induced shutdown"); + addvar(VAR_VALUE, "houron", "Power on hour (hh:mm)"); + addvar(VAR_VALUE, "houroff", "Power off hour (hh:mm)"); +} + +void upsdrv_initups(void) +{ + upsfd = ser_open(device_path); + ser_set_speed(upsfd, device_path, B9600); + + ser_set_dtr(upsfd, 1); + ser_set_rts(upsfd, 0); +} + +void upsdrv_cleanup(void) +{ + ser_close(upsfd, device_path); +} diff --git a/drivers/microsol-common.h b/drivers/microsol-common.h new file mode 100644 index 0000000..8381b13 --- /dev/null +++ b/drivers/microsol-common.h @@ -0,0 +1,67 @@ +/* microsol-common.h - common framework for Microsol Solis-based UPS hardware + + Copyright (C) 2004 Silvino B. Magalhaes + 2019 Roberto Panerai Velloso + 2021 Ygor A. S. Regados + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + 2021/03/19 - Version 0.70 - Initial release, based on solis driver + +*/ + +#ifndef INCLUDED_MICROSOL_COMMON_H +#define INCLUDED_MICROSOL_COMMON_H + +typedef unsigned int bool_t; + +#define PACKET_SIZE 25 + +/* buffers */ +extern unsigned char received_packet[PACKET_SIZE]; + +/* Identification */ +extern const char *model_name; +extern unsigned int ups_model; +extern bool_t input_220v, output_220v; + +/* logical */ +extern bool_t detected; +extern bool_t line_unpowered, overheat, overload; +extern bool_t critical_battery, inverter_working; +/*extern bool_t recharging;*/ /* microsol-apc.c has its own copy */ + +/* Input group */ +extern double input_voltage, input_current, input_frequency; +extern double input_minimum_voltage, input_maximum_voltage, input_nominal_voltage; +extern double input_low_limit, input_high_limit; + +/* Output group */ +extern double output_voltage, output_current, output_frequency; + +/* Battery group */ +extern int battery_extension; +extern double battery_voltage, battery_charge; +extern double temperature; + +/* Power group */ +extern double apparent_power, real_power, ups_load; +extern int load_power_factor, nominal_power, ups_power_factor; + +extern void scan_received_pack_model_specific(void); +extern void set_ups_model(void); +extern bool_t ups_model_defined(void); + +#endif /* INCLUDED_MICROSOL_COMMON_H */ diff --git a/drivers/netvision-mib.c b/drivers/netvision-mib.c index 0640163..51f4073 100644 --- a/drivers/netvision-mib.c +++ b/drivers/netvision-mib.c @@ -25,7 +25,7 @@ #include "netvision-mib.h" -#define NETVISION_MIB_VERSION "0.4" +#define NETVISION_MIB_VERSION "0.44" #define NETVISION_SYSOID ".1.3.6.1.4.1.4555.1.1.1" @@ -39,19 +39,19 @@ /* UPS Battery */ #define NETVISION_OID_BATTERYSTATUS ".1.3.6.1.4.1.4555.1.1.1.1.2.1.0" static info_lkp_t netvision_batt_info[] = { - { 2, "" }, /* battery normal */ - { 3, "LB" }, /* battery low */ - { 4, "LB" }, /* battery depleted */ - { 5, "DISCHRG" }, /* battery discharging */ - { 6, "RB" }, /* battery failure */ - { 0, NULL } + { 2, "", NULL, NULL }, /* battery normal */ + { 3, "LB", NULL, NULL }, /* battery low */ + { 4, "LB", NULL, NULL }, /* battery depleted */ + { 5, "DISCHRG", NULL, NULL }, /* battery discharging */ + { 6, "RB", NULL, NULL }, /* battery failure */ + { 0, NULL, NULL, NULL } }; /* Battery status: upsAlarmOnBattery */ static info_lkp_t netvision_onbatt_info[] = { - { 0, "OL" }, /* Online */ - { 1, "OB" }, /* On battery */ - { 0, NULL } + { 0, "OL", NULL, NULL }, /* Online */ + { 1, "OB", NULL, NULL }, /* On battery */ + { 0, NULL, NULL, NULL } }; #define NETVISION_OID_SECONDSONBATTERY ".1.3.6.1.4.1.4555.1.1.1.1.2.2.0" @@ -101,20 +101,26 @@ static info_lkp_t netvision_onbatt_info[] = { #define NETVISION_OID_CONTROL_SHUTDOWN_DELAY ".1.3.6.1.4.1.4555.1.1.1.1.8.2" static info_lkp_t netvision_output_info[] = { - { 1, "" }, /* output source other */ - { 2, "" }, /* output source none */ - { 3, "OL" }, /* output source normal */ - { 4, "OL BYPASS" }, /* output source bypass */ - { 5, "OB" }, /* output source battery */ - { 6, "OL BOOST" }, /* output source booster */ - { 7, "OL TRIM" }, /* output source reducer */ - { 8, "OL" }, /* output source standby */ - { 9, "" }, /* output source ecomode */ - { 0, NULL } + { 1, "", NULL, NULL }, /* output source other */ + { 2, "", NULL, NULL }, /* output source none */ + { 3, "OL", NULL, NULL }, /* output source normal */ + { 4, "OL BYPASS", NULL, NULL }, /* output source bypass */ + { 5, "OB", NULL, NULL }, /* output source battery */ + { 6, "OL BOOST", NULL, NULL }, /* output source booster */ + { 7, "OL TRIM", NULL, NULL }, /* output source reducer */ + { 8, "OL", NULL, NULL }, /* output source standby */ + { 9, "", NULL, NULL }, /* output source ecomode */ + { 0, NULL, NULL, NULL } }; /* Snmp2NUT lookup table */ static snmp_info_t netvision_mib[] = { + + /* standard MIB items */ + { "device.description", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.1.0", NULL, SU_FLAG_OK, NULL }, + { "device.contact", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.4.0", NULL, SU_FLAG_OK, NULL }, + { "device.location", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.6.0", NULL, SU_FLAG_OK, NULL }, + { "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, NETVISION_OID_UPSIDENTAGENTSWVERSION, "SOCOMEC SICON UPS", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, { "ups.model", ST_FLAG_STRING, SU_INFOSIZE, NETVISION_OID_UPSIDENTMODEL, @@ -135,42 +141,42 @@ static snmp_info_t netvision_mib[] = { { "ups.load", 0, 1, NETVISION_OID_OUT_LOAD_PCT_P1, 0, SU_INPUT_1, NULL }, /*ups input,output voltage, output frquency phase 1 */ - { "input.phases", 0, 1.0, NETVISION_OID_INPUT_NUM_LINES, 0, SU_FLAG_SETINT, NULL, &input_phases }, - { "input.frequency", 0, 0.1, NETVISION_OID_INPUT_FREQ, 0, SU_FLAG_OK, NULL }, - { "input.voltage", 0, 0.1, NETVISION_OID_IN_VOLTAGE_P1, 0, SU_INPUT_1, NULL }, - { "input.current", 0, 0.1, NETVISION_OID_IN_CURRENT_P1, 0, SU_INPUT_1, NULL }, - { "input.L1-N.voltage", 0, 0.1, NETVISION_OID_IN_VOLTAGE_P1, 0, SU_INPUT_3, NULL }, - { "input.L1.current", 0, 0.1, NETVISION_OID_IN_CURRENT_P1, 0, SU_INPUT_3, NULL }, - { "input.L2-N.voltage", 0, 0.1, NETVISION_OID_IN_VOLTAGE_P2, 0, SU_INPUT_3, NULL }, - { "input.L2.current", 0, 0.1, NETVISION_OID_IN_CURRENT_P2, 0, SU_INPUT_3, NULL }, - { "input.L3-N.voltage", 0, 0.1, NETVISION_OID_IN_VOLTAGE_P3, 0, SU_INPUT_3, NULL }, - { "input.L3.current", 0, 0.1, NETVISION_OID_IN_CURRENT_P3, 0, SU_INPUT_3, NULL }, + { "input.phases", 0, 1.0, NETVISION_OID_INPUT_NUM_LINES, NULL, 0, NULL }, + { "input.frequency", 0, 0.1, NETVISION_OID_INPUT_FREQ, NULL, SU_FLAG_OK, NULL }, + { "input.voltage", 0, 0.1, NETVISION_OID_IN_VOLTAGE_P1, NULL, SU_INPUT_1, NULL }, + { "input.current", 0, 0.1, NETVISION_OID_IN_CURRENT_P1, NULL, SU_INPUT_1, NULL }, + { "input.L1-N.voltage", 0, 0.1, NETVISION_OID_IN_VOLTAGE_P1, NULL, SU_INPUT_3, NULL }, + { "input.L1.current", 0, 0.1, NETVISION_OID_IN_CURRENT_P1, NULL, SU_INPUT_3, NULL }, + { "input.L2-N.voltage", 0, 0.1, NETVISION_OID_IN_VOLTAGE_P2, NULL, SU_INPUT_3, NULL }, + { "input.L2.current", 0, 0.1, NETVISION_OID_IN_CURRENT_P2, NULL, SU_INPUT_3, NULL }, + { "input.L3-N.voltage", 0, 0.1, NETVISION_OID_IN_VOLTAGE_P3, NULL, SU_INPUT_3, NULL }, + { "input.L3.current", 0, 0.1, NETVISION_OID_IN_CURRENT_P3, NULL, SU_INPUT_3, NULL }, - { "output.phases", 0, 1.0, NETVISION_OID_OUTPUT_NUM_LINES, 0, SU_FLAG_SETINT, NULL, &output_phases }, - { "output.frequency", 0, 0.1, NETVISION_OID_OUTPUT_FREQ, 0, SU_FLAG_OK, NULL }, - { "output.voltage", 0, 0.1, NETVISION_OID_OUT_VOLTAGE_P1, 0, SU_OUTPUT_1, NULL }, - { "output.current", 0, 0.1, NETVISION_OID_OUT_CURRENT_P1, 0, SU_OUTPUT_1, NULL }, - { "output.load", 0, 1.0, NETVISION_OID_OUT_LOAD_PCT_P1, 0, SU_OUTPUT_1, NULL }, - { "output.L1-N.voltage", 0, 0.1, NETVISION_OID_OUT_VOLTAGE_P1, 0, SU_OUTPUT_3, NULL }, - { "output.L1.current", 0, 0.1, NETVISION_OID_OUT_CURRENT_P1, 0, SU_OUTPUT_3, NULL }, - { "output.L1.power.percent", 0, 1.0, NETVISION_OID_OUT_LOAD_PCT_P1, 0, SU_OUTPUT_3, NULL }, - { "output.L2-N.voltage", 0, 0.1, NETVISION_OID_OUT_VOLTAGE_P2, 0, SU_OUTPUT_3, NULL }, - { "output.L2.current", 0, 0.1, NETVISION_OID_OUT_CURRENT_P2, 0, SU_OUTPUT_3, NULL }, - { "output.L2.power.percent", 0, 1.0, NETVISION_OID_OUT_LOAD_PCT_P2, 0, SU_OUTPUT_3, NULL }, - { "output.L3-N.voltage", 0, 0.1, NETVISION_OID_OUT_VOLTAGE_P3, 0, SU_OUTPUT_3, NULL }, - { "output.L3.current", 0, 0.1, NETVISION_OID_OUT_CURRENT_P3, 0, SU_OUTPUT_3, NULL }, - { "output.L3.power.percent", 0, 1.0, NETVISION_OID_OUT_LOAD_PCT_P3, 0, SU_OUTPUT_3, NULL }, + { "output.phases", 0, 1.0, NETVISION_OID_OUTPUT_NUM_LINES, NULL, 0, NULL }, + { "output.frequency", 0, 0.1, NETVISION_OID_OUTPUT_FREQ, NULL, SU_FLAG_OK, NULL }, + { "output.voltage", 0, 0.1, NETVISION_OID_OUT_VOLTAGE_P1, NULL, SU_OUTPUT_1, NULL }, + { "output.current", 0, 0.1, NETVISION_OID_OUT_CURRENT_P1, NULL, SU_OUTPUT_1, NULL }, + { "output.load", 0, 1.0, NETVISION_OID_OUT_LOAD_PCT_P1, NULL, SU_OUTPUT_1, NULL }, + { "output.L1-N.voltage", 0, 0.1, NETVISION_OID_OUT_VOLTAGE_P1, NULL, SU_OUTPUT_3, NULL }, + { "output.L1.current", 0, 0.1, NETVISION_OID_OUT_CURRENT_P1, NULL, SU_OUTPUT_3, NULL }, + { "output.L1.power.percent", 0, 1.0, NETVISION_OID_OUT_LOAD_PCT_P1, NULL, SU_OUTPUT_3, NULL }, + { "output.L2-N.voltage", 0, 0.1, NETVISION_OID_OUT_VOLTAGE_P2, NULL, SU_OUTPUT_3, NULL }, + { "output.L2.current", 0, 0.1, NETVISION_OID_OUT_CURRENT_P2, NULL, SU_OUTPUT_3, NULL }, + { "output.L2.power.percent", 0, 1.0, NETVISION_OID_OUT_LOAD_PCT_P2, NULL, SU_OUTPUT_3, NULL }, + { "output.L3-N.voltage", 0, 0.1, NETVISION_OID_OUT_VOLTAGE_P3, NULL, SU_OUTPUT_3, NULL }, + { "output.L3.current", 0, 0.1, NETVISION_OID_OUT_CURRENT_P3, NULL, SU_OUTPUT_3, NULL }, + { "output.L3.power.percent", 0, 1.0, NETVISION_OID_OUT_LOAD_PCT_P3, NULL, SU_OUTPUT_3, NULL }, - { "input.bypass.phases", 0, 1.0, NETVISION_OID_BYPASS_NUM_LINES, 0, SU_FLAG_SETINT, NULL, &bypass_phases }, - { "input.bypass.frequency", 0, 0.1, NETVISION_OID_BYPASS_FREQ, 0, SU_FLAG_OK, NULL }, - { "input.bypass.voltage", 0, 0.1, NETVISION_OID_BY_VOLTAGE_P1, 0, SU_BYPASS_1, NULL }, - { "input.bypass.current", 0, 0.1, NETVISION_OID_BY_CURRENT_P1, 0, SU_BYPASS_1, NULL }, - { "input.bypass.L1-N.voltage", 0, 0.1, NETVISION_OID_BY_VOLTAGE_P1, 0, SU_BYPASS_3, NULL }, - { "input.bypass.L1.current", 0, 0.1, NETVISION_OID_BY_CURRENT_P1, 0, SU_BYPASS_3, NULL }, - { "input.bypass.L2-N.voltage", 0, 0.1, NETVISION_OID_BY_VOLTAGE_P2, 0, SU_BYPASS_3, NULL }, - { "input.bypass.L2.current", 0, 0.1, NETVISION_OID_BY_CURRENT_P2, 0, SU_BYPASS_3, NULL }, - { "input.bypass.L3-N.voltage", 0, 0.1, NETVISION_OID_BY_VOLTAGE_P3, 0, SU_BYPASS_3, NULL }, - { "input.bypass.L3.current", 0, 0.1, NETVISION_OID_BY_CURRENT_P3, 0, SU_BYPASS_3, NULL }, + { "input.bypass.phases", 0, 1.0, NETVISION_OID_BYPASS_NUM_LINES, NULL, 0, NULL }, + { "input.bypass.frequency", 0, 0.1, NETVISION_OID_BYPASS_FREQ, NULL, SU_FLAG_OK, NULL }, + { "input.bypass.voltage", 0, 0.1, NETVISION_OID_BY_VOLTAGE_P1, NULL, SU_BYPASS_1, NULL }, + { "input.bypass.current", 0, 0.1, NETVISION_OID_BY_CURRENT_P1, NULL, SU_BYPASS_1, NULL }, + { "input.bypass.L1-N.voltage", 0, 0.1, NETVISION_OID_BY_VOLTAGE_P1, NULL, SU_BYPASS_3, NULL }, + { "input.bypass.L1.current", 0, 0.1, NETVISION_OID_BY_CURRENT_P1, NULL, SU_BYPASS_3, NULL }, + { "input.bypass.L2-N.voltage", 0, 0.1, NETVISION_OID_BY_VOLTAGE_P2, NULL, SU_BYPASS_3, NULL }, + { "input.bypass.L2.current", 0, 0.1, NETVISION_OID_BY_CURRENT_P2, NULL, SU_BYPASS_3, NULL }, + { "input.bypass.L3-N.voltage", 0, 0.1, NETVISION_OID_BY_VOLTAGE_P3, NULL, SU_BYPASS_3, NULL }, + { "input.bypass.L3.current", 0, 0.1, NETVISION_OID_BY_CURRENT_P3, NULL, SU_BYPASS_3, NULL }, /* battery info */ { "battery.charge", 0, 1, NETVISION_OID_BATT_CHARGE, "", SU_FLAG_OK, NULL }, @@ -181,4 +187,4 @@ static snmp_info_t netvision_mib[] = { { NULL, 0, 0, NULL, NULL, 0, NULL } }; -mib2nut_info_t netvision = { "netvision", NETVISION_MIB_VERSION, NULL, NETVISION_OID_UPSIDENTMODEL, netvision_mib, NETVISION_SYSOID }; +mib2nut_info_t netvision = { "netvision", NETVISION_MIB_VERSION, NULL, NETVISION_OID_UPSIDENTMODEL, netvision_mib, NETVISION_SYSOID, NULL }; diff --git a/drivers/netxml-ups.c b/drivers/netxml-ups.c index 2568ff0..330104a 100644 --- a/drivers/netxml-ups.c +++ b/drivers/netxml-ups.c @@ -1,4 +1,4 @@ -/* netxml-ups.c Driver routines for network XML UPS units +/* netxml-ups.c Driver routines for network XML UPS units Copyright (C) 2008-2009 Arjen de Korte @@ -39,8 +39,10 @@ #include #include +#include "nut_stdint.h" + #define DRIVER_NAME "network XML UPS" -#define DRIVER_VERSION "0.40" +#define DRIVER_VERSION "0.44" /** *_OBJECT query multi-part body boundary */ #define FORM_POST_BOUNDARY "NUT-NETXML-UPS-OBJECTS" @@ -174,7 +176,7 @@ static object_entry_t *set_object_add( /** * \brief SET_OBJECT: RAW POST mode implementation * - * \brief req SET_OBJECT request + * \param req SET_OBJECT request * * \return Response to the request */ @@ -184,7 +186,7 @@ static object_query_t *set_object_raw(object_query_t *req); /** * \brief SET_OBJECT: FORM POST mode implementation * - * \brief req SET_OBJECT request + * \param req SET_OBJECT request * * \return \c NULL (FORM POST mode resp. is ignored by specification) */ @@ -194,7 +196,7 @@ static object_query_t *set_object_form(object_query_t *req); /** * \brief SET_OBJECT: implementation * - * \brief req SET_OBJECT request + * \param req SET_OBJECT request * * \return Response to the request */ @@ -222,19 +224,20 @@ static ne_buffer *set_object_serialise_form(object_query_t *handle); /* FIXME: - * "built with neon library %s" LIBNEON_VERSION + * "built with neon library %s" LIBNEON_VERSION * subdrivers (limited to MGE only ATM) */ /* Global vars */ uint32_t ups_status = 0; static int timeout = 5; -int shutdown_duration = 120; +int shutdown_duration = 120; static int shutdown_timer = 0; static time_t lastheard = 0; static subdriver_t *subdriver = &mge_xml_subdriver; static ne_session *session = NULL; static ne_socket *sock = NULL; static ne_uri uri; +static char *product_page = NULL; /* Support functions */ static void netxml_alarm_set(void); @@ -261,7 +264,7 @@ void upsdrv_initinfo(void) { char *page, *last = NULL; char buf[SMALLBUF]; - + snprintf(buf, sizeof(buf), "%s", subdriver->initinfo); for (page = strtok_r(buf, " ", &last); page != NULL; page = strtok_r(NULL, " ", &last)) { @@ -269,6 +272,8 @@ void upsdrv_initinfo(void) if (netxml_get_page(page) != NE_OK) { continue; } + /* store product page, for later use */ + product_page = xstrdup(page); dstate_setinfo("driver.version.data", "%s", subdriver->version); @@ -292,7 +297,8 @@ void upsdrv_initinfo(void) void upsdrv_updateinfo(void) { - int ret, errors = 0; + ssize_t ret; + int errors = 0; /* We really should be dealing with alarms through a separate callback, so that we can keep the * processing of alarms and polling for data separated. Currently, this isn't supported by the @@ -308,7 +314,7 @@ void upsdrv_updateinfo(void) /* alarm message received */ ne_xml_parser *parser = ne_xml_create(); - upsdebugx(2, "%s: ne_sock_read(%d bytes) => %s", __func__, ret, buf); + upsdebugx(2, "%s: ne_sock_read(%zd bytes) => %s", __func__, ret, buf); ne_xml_push_handler(parser, subdriver->startelm_cb, subdriver->cdata_cb, subdriver->endelm_cb, NULL); ne_xml_parse(parser, buf, strlen(buf)); ne_xml_destroy(parser); @@ -324,7 +330,7 @@ void upsdrv_updateinfo(void) upslogx(LOG_ERR, "NSM connection with '%s' lost", uri.host); - upsdebugx(2, "%s: ne_sock_read(%d) => %s", __func__, ret, ne_sock_error(sock)); + upsdebugx(2, "%s: ne_sock_read(%zd) => %s", __func__, ret, ne_sock_error(sock)); ne_sock_close(sock); if (netxml_alarm_subscribe(subdriver->subscribe) == NE_OK) { @@ -350,6 +356,12 @@ void upsdrv_updateinfo(void) errors++; } + /* also refresh the product information, at least for firmware information */ + ret = netxml_get_page(product_page); + if (ret != NE_OK) { + errors++; + } + if (errors > 1) { dstate_datastale(); return; @@ -436,9 +448,9 @@ static int instcmd(const char *cmdname, const char *extra) ser_send_buf(upsfd, ...); return STAT_INSTCMD_HANDLED; } - */ - upslogx(LOG_NOTICE, "%s: unknown command [%s]", __func__, cmdname); + + upslogx(LOG_NOTICE, "%s: unknown command [%s] [%s]", __func__, cmdname, extra); return STAT_INSTCMD_UNKNOWN; } @@ -513,6 +525,9 @@ void upsdrv_makevartable(void) snprintf(buf, sizeof(buf), "shutdown timer in second (default: none)"); } addvar(VAR_VALUE, "shutdown_timer", buf); + + /* Legacy MGE-XML conversion from 2000's, not needed in modern firmwares */ + addvar(VAR_FLAG, "do_convert_deci", "enable legacy convert_deci() for certain measurements 10x too large"); } void upsdrv_initups(void) @@ -556,7 +571,7 @@ void upsdrv_initups(void) shutdown_timer = atoi(val); if (shutdown_timer < 0) { - fatalx(EXIT_FAILURE, "shutdwon timer must be greater than or equal to 0"); + fatalx(EXIT_FAILURE, "shutdown timer must be greater than or equal to 0"); } } @@ -575,7 +590,7 @@ void upsdrv_initups(void) if (uri.scheme == NULL) { uri.scheme = strdup("http"); } - + if (uri.host == NULL) { uri.host = strdup(device_path); } @@ -587,7 +602,7 @@ void upsdrv_initups(void) upsdebugx(1, "using %s://%s port %d", uri.scheme, uri.host, uri.port); session = ne_session_create(uri.scheme, uri.host, uri.port); - + /* timeout if we can't (re)connect to the UPS */ #ifdef HAVE_NE_SET_CONNECT_TIMEOUT ne_set_connect_timeout(session, timeout); @@ -638,6 +653,7 @@ void upsdrv_cleanup(void) free(subdriver->summary); free(subdriver->getobject); free(subdriver->setobject); + free(product_page); if (sock) { ne_sock_close(sock); @@ -656,33 +672,36 @@ void upsdrv_cleanup(void) static int netxml_get_page(const char *page) { - int ret; + int ret = NE_ERROR; ne_request *request; ne_xml_parser *parser; - upsdebugx(2, "%s: %s", __func__, page); + upsdebugx(2, "%s: %s", __func__, (page != NULL)?page:"(null)"); - request = ne_request_create(session, "GET", page); + if (page != NULL) { + request = ne_request_create(session, "GET", page); - parser = ne_xml_create(); + parser = ne_xml_create(); - ne_xml_push_handler(parser, subdriver->startelm_cb, subdriver->cdata_cb, subdriver->endelm_cb, NULL); + ne_xml_push_handler(parser, subdriver->startelm_cb, subdriver->cdata_cb, subdriver->endelm_cb, NULL); - ret = netxml_dispatch_request(request, parser); + ret = netxml_dispatch_request(request, parser); - if (ret) { - upsdebugx(2, "%s: %s", __func__, ne_get_error(session)); + if (ret) { + upsdebugx(2, "%s: %s", __func__, ne_get_error(session)); + } + + ne_xml_destroy(parser); + ne_request_destroy(request); } - - ne_xml_destroy(parser); - ne_request_destroy(request); - return ret; } static int netxml_alarm_subscribe(const char *page) { - int ret, port = -1, secret = -1; + ssize_t ret; + int secret = -1; + unsigned int port = 0; char buf[LARGEBUF], *s; ne_request *request; ne_sock_addr *addr; @@ -759,18 +778,37 @@ static int netxml_alarm_subscribe(const char *page) /* due to different formats used by the various NMCs, we need to\ break up the reply in lines and parse each one separately */ for (s = strtok(resp_buf, "\r\n"); s != NULL; s = strtok(NULL, "\r\n")) { + long long int tmp_port = -1, tmp_secret = -1; upsdebugx(2, "%s: parsing %s", __func__, s); - if (!strncasecmp(s, "", 6) && (sscanf(s+6, "%u", &port) != 1)) { + if (!strncasecmp(s, "", 6) && (sscanf(s+6, "%lli", &tmp_port) != 1)) { return NE_RETRY; } - if (!strncasecmp(s, "", 8) && (sscanf(s+8, "%u", &secret) != 1)) { + /* FIXME? Does a port==0 make sense here? Or should the test below be for port<1? + * Legacy code until a fix here used sscanf() above to get a '%u' value... + */ + if (tmp_port < 0 || tmp_port > UINT_MAX) { + upsdebugx(2, "%s: parsing initial subcription failed, bad port value", __func__); return NE_RETRY; } + + if (!strncasecmp(s, "", 8) && (sscanf(s+8, "%lli", &tmp_secret) != 1)) { + return NE_RETRY; + } + + if (tmp_secret < 0 || tmp_secret > UINT_MAX) { + upsdebugx(2, "%s: parsing initial subcription failed, bad secret value", __func__); + return NE_RETRY; + } + + /* Range of valid values constrained above */ + port = (unsigned int)tmp_port; + secret = (int)tmp_secret; + } - if ((port == -1) || (secret == -1)) { + if ((port < 1) || (secret == -1)) { upsdebugx(2, "%s: parsing initial subcription failed", __func__); return NE_RETRY; } @@ -874,6 +912,8 @@ static int netxml_dispatch_request(ne_request *request, ne_xml_parser *parser) /* Supply the 'login' and 'password' when authentication is required */ static int netxml_authenticate(void *userdata, const char *realm, int attempt, char *username, char *password) { + NUT_UNUSED_VARIABLE(userdata); + char *val; upsdebugx(2, "%s: realm = [%s], attempt = %d", __func__, realm, attempt); @@ -980,6 +1020,9 @@ static void netxml_status_set(void) if (STATUS_BIT(SHUTDOWNIMM)) { status_set("FSD"); /* shutdown imminent */ } + if (STATUS_BIT(CAL)) { + status_set("CAL"); /* calibrating */ + } } @@ -1030,7 +1073,7 @@ static void set_object_req_destroy(set_object_req_t *req) { /** * \brief SET_OBJECT response list entry destructor * - * \param req SET_OBJECT response list entry + * \param resp SET_OBJECT response list entry */ static void set_object_resp_destroy(set_object_resp_t *resp) { assert(NULL != resp); @@ -1199,8 +1242,8 @@ static object_entry_t *set_object_add( * \param buff Buffer * \param entry SET_OBJECT request entry * - * \retval OBJECT_OK on success - * \retval OBJECT_ERROR otherwise + * \return OBJECT_OK on success + * \return OBJECT_ERROR otherwise */ static object_query_status_t set_object_serialise_entries(ne_buffer *buff, object_entry_t *entry) { object_query_status_t status = OBJECT_OK; @@ -1480,6 +1523,9 @@ static int set_object_raw_resp_end_element( const char *nspace, const char *name) { + NUT_UNUSED_VARIABLE(userdata); + NUT_UNUSED_VARIABLE(nspace); + /* OBJECT (as a SET_OBJECT child) */ if (NE_XML_STATEROOT + 2 == state) { assert(0 == strcasecmp(name, "OBJECT")); @@ -1538,9 +1584,9 @@ static object_query_t *set_object_deserialise_raw(ne_buffer *buff) { * * The function creates HTTP request, sends it and reads-out the response. * - * \param[in] session HTTP session + * \param[in] argsession HTTP session * \param[in] method Request method - * \param[in] uri Request URI + * \param[in] arguri Request URI * \param[in] ct Request content type (optional, \c NULL accepted) * \param[in] req_body Request body (optional, \c NULL is accepted) * \param[out] resp_body Response body (optional, \c NULL is accepted) @@ -1548,9 +1594,9 @@ static object_query_t *set_object_deserialise_raw(ne_buffer *buff) { * \return HTTP status code if response was sent, 0 on send error */ static int send_http_request( - ne_session *session, + ne_session *argsession, const char *method, - const char *uri, + const char *arguri, const char *ct, ne_buffer *req_body, ne_buffer *resp_body) @@ -1560,7 +1606,7 @@ static int send_http_request( ne_request *req = NULL; /* Create request */ - req = ne_request_create(session, method, uri); + req = ne_request_create(argsession, method, arguri); /* Neon claims that request creation is always successful */ assert(NULL != req); @@ -1606,7 +1652,7 @@ static int send_http_request( break; if (NULL != resp_body) - ne_buffer_append(resp_body, buff, read); + ne_buffer_append(resp_body, buff, (size_t)read); } if (NE_OK != status) { diff --git a/drivers/netxml-ups.h b/drivers/netxml-ups.h index 4729b7a..555dc02 100644 --- a/drivers/netxml-ups.h +++ b/drivers/netxml-ups.h @@ -1,4 +1,4 @@ -/* netxml-ups.h Driver data/defines for network XML UPS units +/* netxml-ups.h Driver data/defines for network XML UPS units Copyright (C) 2008-2009 Arjen de Korte @@ -67,9 +67,11 @@ typedef enum { CHARGERFAIL, /* battery charger failure */ VRANGE, /* voltage out of range */ FRANGE, /* frequency out of range */ - FUSEFAULT /* fuse fault */ + FUSEFAULT, /* fuse fault */ + CAL /* calibrating */ } status_bit_t; extern uint32_t ups_status; +extern int shutdown_duration; #endif /* NETXML_UPS_H */ diff --git a/drivers/nut-ipmi.h b/drivers/nut-ipmi.h index 0cd0deb..669eb92 100644 --- a/drivers/nut-ipmi.h +++ b/drivers/nut-ipmi.h @@ -29,6 +29,14 @@ typedef enum { PSU_POWER_FAILURE /* = status OFF */ } psu_status_t; +#ifdef HAVE_FREEIPMI_11X_12X + /* args 8, 9, 10, 11 of ipmi_fru_multirecord_power_supply_information() */ + typedef int input_voltage_range_t; +#else + /* args 8, 9, 10, 11 of ipmi_fru_parse_multirecord_power_supply_information() */ + typedef unsigned int input_voltage_range_t; +#endif + /* Abstract structure to store information */ typedef struct IPMIDevice_s { int ipmi_id; /* FRU ID */ @@ -38,8 +46,8 @@ typedef struct IPMIDevice_s { char* part; /* Part Number */ char* date; /* Manufacturing Date/Time */ int overall_capacity; /* realpower.nominal? */ - int input_minvoltage; - int input_maxvoltage; + input_voltage_range_t input_minvoltage; + input_voltage_range_t input_maxvoltage; int input_minfreq; int input_maxfreq; int voltage; /* psu.voltage or device.voltage */ @@ -56,8 +64,7 @@ typedef struct IPMIDevice_s { /* Generic functions, to implement in the backends */ int nut_ipmi_open(int ipmi_id, IPMIDevice_t *ipmi_dev); void nut_ipmi_close(void); -int nut_ipmi_monitoring_init(); +int nut_ipmi_monitoring_init(void); int nut_ipmi_get_sensors_status(IPMIDevice_t *ipmi_dev); #endif /* NUT_IPMI_H */ - diff --git a/drivers/nut-ipmipsu.c b/drivers/nut-ipmipsu.c index 2991cfc..c0dd658 100644 --- a/drivers/nut-ipmipsu.c +++ b/drivers/nut-ipmipsu.c @@ -27,7 +27,7 @@ #include "nut-ipmi.h" #define DRIVER_NAME "IPMI PSU driver" -#define DRIVER_VERSION "0.30" +#define DRIVER_VERSION "0.31" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -47,11 +47,11 @@ upsdrv_info_t upsdrv_info = { /* Abstract structure to allow different IPMI implementation * We currently use FreeIPMI, but OpenIPMI and others are serious - * candidates! */ -IPMIDevice_t ipmi_dev; + * candidates! */ +static IPMIDevice_t ipmi_dev; /* Currently used to store FRU ID, but will probably evolve... */ -int ipmi_id = -1; +static int ipmi_id = -1; void upsdrv_initinfo(void) { @@ -87,10 +87,17 @@ void upsdrv_initinfo(void) if (ipmi_dev.overall_capacity != -1) dstate_setinfo("ups.realpower.nominal", "%i", ipmi_dev.overall_capacity); + /* FIXME: Did older FreeIPMI with "unsigned int" voltage ranges + * have a way to report invalid readings? + */ +#ifdef HAVE_FREEIPMI_11X_12X if (ipmi_dev.input_minvoltage != -1) +#endif dstate_setinfo("input.voltage.minimum", "%i", ipmi_dev.input_minvoltage); +#ifdef HAVE_FREEIPMI_11X_12X if (ipmi_dev.input_maxvoltage != -1) +#endif dstate_setinfo("input.voltage.maximum", "%i", ipmi_dev.input_maxvoltage); if (ipmi_dev.input_minfreq != -1) @@ -136,6 +143,9 @@ void upsdrv_updateinfo(void) */ } +void upsdrv_shutdown(void) + __attribute__((noreturn)); + void upsdrv_shutdown(void) { fatalx(EXIT_FAILURE, "shutdown not supported"); @@ -181,7 +191,7 @@ void upsdrv_makevartable(void) "Authentication type to use during lan session activation"); addvar(VAR_VALUE, "type", "Type of the device to match ('psu' for \"Power Supply\")"); - + addvar(VAR_VALUE, "serial", "Serial number to match a specific device"); addvar(VAR_VALUE, "fruid", "FRU identifier to match a specific device"); */ } @@ -197,7 +207,7 @@ void upsdrv_initups(void) * - out of band * "id?@host" * "host" => requires serial or ... - */ + */ if (!strncmp( device_path, "id", 2)) { ipmi_id = atoi(device_path+2); diff --git a/drivers/nut-libfreeipmi.c b/drivers/nut-libfreeipmi.c index 06e955e..b37f58f 100644 --- a/drivers/nut-libfreeipmi.c +++ b/drivers/nut-libfreeipmi.c @@ -39,6 +39,8 @@ */ +#include "config.h" /* must be first */ + #include #include #include "timehead.h" @@ -49,6 +51,7 @@ #include #endif #include "nut-ipmi.h" +#include "nut_stdint.h" #include "dstate.h" /* FreeIPMI defines */ @@ -58,21 +61,21 @@ #define IPMI_FRU_CUSTOM_FIELDS 64 /* FreeIPMI contexts and configuration*/ -ipmi_ctx_t ipmi_ctx = NULL; -ipmi_monitoring_ctx_t mon_ctx = NULL; -struct ipmi_monitoring_ipmi_config ipmi_config; +static ipmi_ctx_t ipmi_ctx = NULL; +static ipmi_monitoring_ctx_t mon_ctx = NULL; +/* static struct ipmi_monitoring_ipmi_config ipmi_config; */ /* SDR management API has changed with 1.1.X and later */ #ifdef HAVE_FREEIPMI_11X_12X - ipmi_sdr_ctx_t sdr_ctx = NULL; - ipmi_fru_ctx_t fru_ctx = NULL; + static ipmi_sdr_ctx_t sdr_ctx = NULL; + static ipmi_fru_ctx_t fru_ctx = NULL; #define SDR_PARSE_CTX sdr_ctx #define NUT_IPMI_SDR_CACHE_DEFAULTS IPMI_SDR_CACHE_CREATE_FLAGS_DEFAULT #else - ipmi_sdr_cache_ctx_t sdr_ctx = NULL; - ipmi_sdr_parse_ctx_t sdr_parse_ctx = NULL; + static ipmi_sdr_cache_ctx_t sdr_ctx = NULL; + static ipmi_sdr_parse_ctx_t sdr_parse_ctx = NULL; #define SDR_PARSE_CTX sdr_parse_ctx - ipmi_fru_parse_ctx_t fru_ctx = NULL; + static ipmi_fru_parse_ctx_t fru_ctx = NULL; /* Functions remapping */ #define ipmi_sdr_ctx_create ipmi_sdr_cache_ctx_create #define ipmi_sdr_ctx_destroy ipmi_sdr_cache_ctx_destroy @@ -112,7 +115,7 @@ struct ipmi_monitoring_ipmi_config ipmi_config; static const char* libfreeipmi_getfield (uint8_t language_code, ipmi_fru_field_t *field); -static void libfreeipmi_cleanup(); +static void libfreeipmi_cleanup(void); static int libfreeipmi_get_psu_info (const void *areabuf, uint8_t area_length, IPMIDevice_t *ipmi_dev); @@ -135,6 +138,16 @@ int nut_ipmi_open(int ipmi_id, IPMIDevice_t *ipmi_dev) upsdebugx(1, "nut-libfreeipmi: nutipmi_open()..."); + /* FIXME? Check arg types for ipmi_fru_open_device_id() in configure? + * At this time it is uint8_t for libfreeipmi implementation of IPMI. + */ + if (ipmi_id > (int)UINT8_MAX) { + libfreeipmi_cleanup(); + fatal_with_errno(EXIT_FAILURE, + "nut_ipmi_open: ipmi_id %d is too large for libfreeipmi", + ipmi_id); + } + /* Initialize the FreeIPMI library. */ if (!(ipmi_ctx = ipmi_ctx_create ())) { @@ -171,7 +184,7 @@ int nut_ipmi_open(int ipmi_id, IPMIDevice_t *ipmi_dev) libfreeipmi_cleanup(); fatal_with_errno(EXIT_FAILURE, "ipmi_fru_ctx_create()"); } - + /* lots of motherboards calculate checksums incorrectly */ if (ipmi_fru_ctx_set_flags (fru_ctx, IPMI_FRU_FLAGS_SKIP_CHECKSUM_CHECKS) < 0) { @@ -181,7 +194,7 @@ int nut_ipmi_open(int ipmi_id, IPMIDevice_t *ipmi_dev) } /* Now open the requested (local) PSU */ - if (ipmi_fru_open_device_id (fru_ctx, ipmi_id) < 0) + if (ipmi_fru_open_device_id (fru_ctx, (uint8_t)ipmi_id) < 0) { libfreeipmi_cleanup(); fatalx(EXIT_FAILURE, "ipmi_fru_open_device_id: %s\n", @@ -206,19 +219,27 @@ int nut_ipmi_open(int ipmi_id, IPMIDevice_t *ipmi_dev) IPMI_FRU_AREA_SIZE_MAX) < 0) { libfreeipmi_cleanup(); - fatal_with_errno(EXIT_FAILURE, + fatal_with_errno(EXIT_FAILURE, "ipmi_fru_read_data_area: %s\n", ipmi_fru_ctx_errormsg (fru_ctx)); } if (area_length) { + + if (area_length > (int)UINT8_MAX) { + libfreeipmi_cleanup(); + fatal_with_errno(EXIT_FAILURE, + "nut_ipmi_open: got area_length %d is too large for libfreeipmi", + area_length); + } + switch (area_type) { /* get generic board information */ case IPMI_FRU_AREA_TYPE_BOARD_INFO_AREA: - if(libfreeipmi_get_board_info (areabuf, area_length, + if(libfreeipmi_get_board_info (areabuf, (uint8_t)area_length, ipmi_dev) < 0) { upsdebugx(1, "Can't retrieve board information"); @@ -227,7 +248,7 @@ int nut_ipmi_open(int ipmi_id, IPMIDevice_t *ipmi_dev) /* get specific PSU information */ case IPMI_FRU_AREA_TYPE_MULTIRECORD_POWER_SUPPLY_INFORMATION: - if(libfreeipmi_get_psu_info (areabuf, area_length, ipmi_dev) < 0) + if(libfreeipmi_get_psu_info (areabuf, (uint8_t)area_length, ipmi_dev) < 0) { upsdebugx(1, "Can't retrieve PSU information"); } @@ -344,18 +365,18 @@ static int libfreeipmi_get_psu_info (const void *areabuf, { /* FIXME: directly use ipmi_dev fields */ unsigned int overall_capacity; - int low_end_input_voltage_range_1; - int high_end_input_voltage_range_1; + input_voltage_range_t low_end_input_voltage_range_1; + input_voltage_range_t high_end_input_voltage_range_1; unsigned int low_end_input_frequency_range; unsigned int high_end_input_frequency_range; - unsigned int voltage_1; + unsigned int voltage_1; /* code for conversion into a float */ /* FIXME: check for the interest and capability to use these data */ unsigned int peak_va; unsigned int inrush_current; unsigned int inrush_interval; - int low_end_input_voltage_range_2; - int high_end_input_voltage_range_2; + input_voltage_range_t low_end_input_voltage_range_2; + input_voltage_range_t high_end_input_voltage_range_2; unsigned int ac_dropout_tolerance; unsigned int predictive_fail_support; unsigned int power_factor_correction; @@ -400,16 +421,36 @@ static int libfreeipmi_get_psu_info (const void *areabuf, ipmi_fru_ctx_errormsg (fru_ctx)); } - ipmi_dev->overall_capacity = overall_capacity; + if (overall_capacity > (int)INT_MAX) + { + fatalx(EXIT_FAILURE, "ipmi_fru_multirecord_power_supply_information: overall_capacity exceeds expected range: %u", + overall_capacity); + } + ipmi_dev->overall_capacity = (int)overall_capacity; /* Voltages are in mV! */ ipmi_dev->input_minvoltage = low_end_input_voltage_range_1 / 1000; ipmi_dev->input_maxvoltage = high_end_input_voltage_range_1 / 1000; - ipmi_dev->input_minfreq = low_end_input_frequency_range; - ipmi_dev->input_maxfreq = high_end_input_frequency_range; + if (low_end_input_frequency_range > (int)INT_MAX) + { + fatalx(EXIT_FAILURE, "ipmi_fru_multirecord_power_supply_information: low_end_input_frequency_range exceeds expected range: %u", + low_end_input_frequency_range); + } + if (high_end_input_frequency_range > (int)INT_MAX) + { + fatalx(EXIT_FAILURE, "ipmi_fru_multirecord_power_supply_information: high_end_input_frequency_range exceeds expected range: %u", + high_end_input_frequency_range); + } + ipmi_dev->input_minfreq = (int)low_end_input_frequency_range; + ipmi_dev->input_maxfreq = (int)high_end_input_frequency_range; - ipmi_dev->voltage = libfreeipmi_get_voltage(voltage_1); + if (voltage_1 > (int)UINT8_MAX) + { + fatalx(EXIT_FAILURE, "ipmi_fru_multirecord_power_supply_information: voltage_1 code exceeds expected range: %u", + voltage_1); + } + ipmi_dev->voltage = libfreeipmi_get_voltage((uint8_t)voltage_1); upsdebugx(1, "libfreeipmi_get_psu_info() retrieved successfully"); @@ -462,7 +503,6 @@ static int libfreeipmi_get_board_info (const void *areabuf, ipmi_fru_ctx_errormsg (fru_ctx)); } - if (IPMI_FRU_LANGUAGE_CODE_VALID (language_code)) { upsdebugx (5, "FRU Board Language: %s", ipmi_fru_language_codes[language_code]); } @@ -474,7 +514,39 @@ static int libfreeipmi_get_board_info (const void *areabuf, * 'struct tm', thus passing 'struct tm' between functions could * have issues. So we need to memset */ memset (&mfg_date_time_tm, '\0', sizeof (struct tm)); - timetmp = mfg_date_time; + + /* Without a standard TIME_MAX, signedness may suffer; + * but we can at least check the number should fit */ +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic ignored "-Wunreachable-code" +#endif +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" +#endif + /* Stay ahead of possible redefinitions... */ + if (sizeof(mfg_date_time) > sizeof(timetmp)) + { + libfreeipmi_cleanup(); + fatalx(EXIT_FAILURE, "libfreeipmi_get_board_info: mfg_date_time type too large to process into a time_t"); + } + /* NOTE: Code until the end of method would also be "unreachable" + * for compilers or static analyzers that care about this, if the + * sizeof() check above fails on some architecture; build warnings + * should expose that so we look for a fix - so do not just blindly + * move the closing pragmas to end of method ;) + */ +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic pop +#endif + + timetmp = (time_t)mfg_date_time; localtime_r (&timetmp, &mfg_date_time_tm); memset (mfg_date_time_buf, '\0', IPMI_FRU_STR_BUFLEN + 1); strftime (mfg_date_time_buf, IPMI_FRU_STR_BUFLEN, "%D - %T", &mfg_date_time_tm); @@ -518,7 +590,7 @@ static int libfreeipmi_get_sensors_info (IPMIDevice_t *ipmi_dev) uint16_t record_count; int found_device_id = 0; uint16_t record_id; - uint8_t entity_id, entity_instance; + uint8_t entity_id = 0, entity_instance = 0; int i; if (ipmi_ctx == NULL) @@ -597,7 +669,7 @@ static int libfreeipmi_get_sensors_info (IPMIDevice_t *ipmi_dev) } if (ipmi_sdr_parse_record_id_and_type (SDR_PARSE_CTX, sdr_record, - sdr_record_len, + (unsigned int)sdr_record_len, NULL, &record_type) < 0) { @@ -615,7 +687,7 @@ static int libfreeipmi_get_sensors_info (IPMIDevice_t *ipmi_dev) if (ipmi_sdr_parse_fru_device_locator_parameters (SDR_PARSE_CTX, sdr_record, - sdr_record_len, + (unsigned int)sdr_record_len, NULL, &logical_fru_device_device_slave_address, NULL, @@ -638,7 +710,7 @@ static int libfreeipmi_get_sensors_info (IPMIDevice_t *ipmi_dev) if (ipmi_sdr_parse_fru_entity_id_and_instance (SDR_PARSE_CTX, sdr_record, - sdr_record_len, + (unsigned int)sdr_record_len, &entity_id, &entity_instance) < 0) { @@ -661,7 +733,7 @@ static int libfreeipmi_get_sensors_info (IPMIDevice_t *ipmi_dev) if (ipmi_sdr_cache_first (sdr_ctx) < 0) { - fprintf (stderr, "ipmi_sdr_cache_first: %s\n", + fprintf (stderr, "ipmi_sdr_cache_first: %s\n", ipmi_sdr_ctx_errormsg (sdr_ctx)); goto cleanup; } @@ -684,7 +756,7 @@ static int libfreeipmi_get_sensors_info (IPMIDevice_t *ipmi_dev) if (ipmi_sdr_parse_record_id_and_type (SDR_PARSE_CTX, sdr_record, - sdr_record_len, + (unsigned int)sdr_record_len, &record_id, &record_type) < 0) { @@ -703,7 +775,7 @@ static int libfreeipmi_get_sensors_info (IPMIDevice_t *ipmi_dev) if (ipmi_sdr_parse_entity_id_instance_type (SDR_PARSE_CTX, sdr_record, - sdr_record_len, + (unsigned int)sdr_record_len, &tmp_entity_id, &tmp_entity_instance, NULL) < 0) @@ -738,7 +810,11 @@ cleanup: } #endif /* HAVE_FREEIPMI_11X_12X */ - return ipmi_dev->sensors_count; + if (ipmi_dev->sensors_count > INT_MAX) { + upsdebugx(1, "%s: Found %i sensors which is too many", + __func__, ipmi_dev->sensors_count); + } + return (int)ipmi_dev->sensors_count; } @@ -861,7 +937,7 @@ int nut_ipmi_get_sensors_status(IPMIDevice_t *ipmi_dev) * if ((sensor_state = ipmi_monitoring_sensor_read_sensor_state (mon_ctx)) < 0) * ... */ - if ((sensor_reading = ipmi_monitoring_sensor_read_sensor_reading (mon_ctx)) < 0) + if ((sensor_reading = ipmi_monitoring_sensor_read_sensor_reading (mon_ctx)) == NULL) { upsdebugx (1, "ipmi_monitoring_sensor_read_sensor_reading() error: %s", ipmi_monitoring_ctx_errormsg (mon_ctx)); @@ -881,7 +957,7 @@ int nut_ipmi_get_sensors_status(IPMIDevice_t *ipmi_dev) continue; } - if ((sensor_bitmask_strings = ipmi_monitoring_sensor_read_sensor_bitmask_strings (mon_ctx)) < 0) + if ((sensor_bitmask_strings = ipmi_monitoring_sensor_read_sensor_bitmask_strings (mon_ctx)) == NULL) { upsdebugx (1, "ipmi_monitoring_sensor_read_sensor_bitmask_strings() error: %s", ipmi_monitoring_ctx_errormsg (mon_ctx)); @@ -989,7 +1065,7 @@ int nut_ipmi_get_sensors_status(IPMIDevice_t *ipmi_dev) break; } } - + /* Process status if needed */ if (psu_status != PSU_STATUS_UNKNOWN) { @@ -1011,7 +1087,7 @@ int nut_ipmi_get_sensors_status(IPMIDevice_t *ipmi_dev) retval = 0; break; } - + status_commit(); } #endif /* HAVE_FREEIPMI_MONITORING */ diff --git a/drivers/nut_libusb.h b/drivers/nut_libusb.h new file mode 100644 index 0000000..20473d3 --- /dev/null +++ b/drivers/nut_libusb.h @@ -0,0 +1,111 @@ +/*! + * @file nut_libusb.h + * @brief HID Library - Generic USB backend for Generic HID Access (using MGE HIDParser) + * + * @author Copyright (C) + * 2003 - 2016 Arnaud Quette + * 2005 Peter Selinger + * 2021 Jim Klimov + * + * This program is sponsored by MGE UPS SYSTEMS - opensource.mgeups.com + * + * The logic of this file is ripped from mge-shut driver (also from + * Arnaud Quette), which is a "HID over serial link" UPS driver for + * Network UPS Tools + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * -------------------------------------------------------------------------- */ + +#ifndef NUT_LIBUSB_H_SEEN +#define NUT_LIBUSB_H_SEEN 1 + +#include "main.h" /* for subdrv_info_t */ +#include "usb-common.h" /* for USBDevice_t and USBDeviceMatcher_t, + * and for libusb headers and 0.1/1.0 mapping */ + +/* Used in drivers/libusb*.c sources: */ +#define LIBUSB_DEFAULT_INTERFACE 0 +#define LIBUSB_DEFAULT_DESC_INDEX 0 +#define LIBUSB_DEFAULT_HID_EP_IN 1 +#define LIBUSB_DEFAULT_HID_EP_OUT 1 + +extern upsdrv_info_t comm_upsdrv_info; + +/*! + * usb_communication_subdriver_s: structure to describe the communication routines + * @name: can be either "shut" for Serial HID UPS Transfer (from MGE) or "usb" + */ +typedef struct usb_communication_subdriver_s { + const char *name; /* name of this subdriver */ + const char *version; /* version of this subdriver */ + + int (*open)(usb_dev_handle **sdevp, /* try to open the next available */ + USBDevice_t *curDevice, /* device matching USBDeviceMatcher_t */ + USBDeviceMatcher_t *matcher, + int (*callback)(usb_dev_handle *udev, USBDevice_t *hd, + usb_ctrl_charbuf rdbuf, usb_ctrl_charbufsize rdlen)); + + void (*close)(usb_dev_handle *sdev); + + int (*get_report)(usb_dev_handle *sdev, usb_ctrl_repindex ReportId, + usb_ctrl_charbuf raw_buf, usb_ctrl_charbufsize ReportSize); + + int (*set_report)(usb_dev_handle *sdev, usb_ctrl_repindex ReportId, + usb_ctrl_charbuf raw_buf, usb_ctrl_charbufsize ReportSize); + + int (*get_string)(usb_dev_handle *sdev, + usb_ctrl_strindex StringIdx, char *buf, usb_ctrl_charbufsize buflen); + + int (*get_interrupt)(usb_dev_handle *sdev, + usb_ctrl_charbuf buf, usb_ctrl_charbufsize bufsize, + usb_ctrl_timeout_msec timeout); + + /* Used for Powervar UPS or similar cases to make sure + * we use the right interface in the Composite device. + * In a few cases our libusb*.c sets the value for specific + * VID/PID combinations, in others the subdrivers do so. + * FIXME: The numeric value here seems to fit and + * gets used in several contexts, it may be cleaner + * to separate them eventually. Usages in NUT were + * seen as following libusb API (1.0 and 0.1) args, + * along with some hints from libusb sources/headers: + * libusb-1.0: + * libusb_claim_interface - "int interface_number" + * libusb_detach_kernel_driver - "int interface_number" + * libusb_get_config_descriptor - "uint8_t config_index" ("the index of the configuration you wish to retrieve") + * libusb_control_transfer - "uint16_t wIndex" ("the index field for the setup packet"; "should be given in host-endian byte order") + * libusb-0.1: // The parameters mirror the types of the same name in the USB specification + * usb_claim_interface - "int interface" + * usb_control_msg - "int index" + * (_np = non-portable => only on some systems, like FreeBSD) + * usb_detach_kernel_driver_np - "int interface" + */ + usb_ctrl_repindex hid_rep_index; /* number of the interface we use in a composite USB device; see comments above */ + + /* All devices use HID descriptor at index 0. + * However, some UPS like newer Eaton units have + * a light HID descriptor at index 0, and + * the full version is at index 1 (in which + * case, bcdDevice == 0x0202) + */ + usb_ctrl_descindex hid_desc_index; /* HID descriptor is at this index (non-trivial for composite USB devices); see comments above */ + usb_ctrl_endpoint hid_ep_in; /* Input interrupt endpoint. Default is 1 */ + usb_ctrl_endpoint hid_ep_out; /* Output interrupt endpoint. Default is 1 */ +} usb_communication_subdriver_t; + +extern usb_communication_subdriver_t usb_subdriver; + +#endif /* NUT_LIBUSB_H_SEEN */ diff --git a/drivers/nutdrv_atcl_usb.c b/drivers/nutdrv_atcl_usb.c index 7424493..4d51a4b 100644 --- a/drivers/nutdrv_atcl_usb.c +++ b/drivers/nutdrv_atcl_usb.c @@ -2,6 +2,7 @@ * nutdrv_atcl_usb.c - driver for generic-brand "ATCL FOR UPS" * * Copyright (C) 2013-2014 Charles Lepple + * Copyright (C) 2016 Eaton * * Loosely based on richcomm_usb.c, * Copyright (C) 2007 Peter van Valderen @@ -27,7 +28,7 @@ /* driver version */ #define DRIVER_NAME "'ATCL FOR UPS' USB driver" -#define DRIVER_VERSION "1.1" +#define DRIVER_VERSION "1.16" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -56,8 +57,8 @@ static usb_device_id_t atcl_usb_id[] = { /* ATCL FOR UPS */ { USB_DEVICE(0x0001, 0x0000), NULL }, - /* end of list */ - {-1, -1, NULL} + /* Terminating entry */ + { 0, 0, NULL } }; static usb_dev_handle *udev = NULL; @@ -67,10 +68,12 @@ static unsigned int comm_failures = 0; static int device_match_func(USBDevice_t *device, void *privdata) { char *requested_vendor; + NUT_UNUSED_VARIABLE(privdata); + switch (is_usb_device_supported(atcl_usb_id, device)) { case SUPPORTED: - if(!device->Vendor) { + if(!device->Vendor) { upsdebugx(1, "Couldn't retrieve USB string descriptor for vendor. Check permissions?"); requested_vendor = getval("vendor"); if(requested_vendor) { @@ -78,7 +81,7 @@ static int device_match_func(USBDevice_t *device, void *privdata) upsdebugx(3, "Matched device with NULL vendor string."); return 1; } - } + } upsdebugx(1, "To keep trying (in case your device does not have a vendor string), use vendor=NULL"); return 0; } @@ -94,16 +97,18 @@ static int device_match_func(USBDevice_t *device, void *privdata) upsdebugx(3, "Matched device with vendor='%s'.", requested_vendor); return 1; } else { - upsdebugx(2, "idVendor=%04x and idProduct=%04x, but provided vendor '%s' does not match device: '%s'.", + upsdebugx(2, "idVendor=%04x and idProduct=%04x, " + "but provided vendor '%s' does not match device: '%s'.", device->VendorID, device->ProductID, requested_vendor, device->Vendor); return 0; } } /* TODO: automatic way of suggesting other drivers? */ - upsdebugx(2, "idVendor=%04x and idProduct=%04x, but device vendor string '%s' does not match expected string '%s'. " - "Have you tried the nutdrv_qx driver?", - device->VendorID, device->ProductID, device->Vendor, USB_VENDOR_STRING); + upsdebugx(2, "idVendor=%04x and idProduct=%04x, " + "but device vendor string '%s' does not match expected string '%s'. " + "Have you tried the nutdrv_qx driver?", + device->VendorID, device->ProductID, device->Vendor, USB_VENDOR_STRING); return 0; case POSSIBLY_SUPPORTED: @@ -123,14 +128,15 @@ static int query_ups(char *reply) { int ret; - ret = usb_interrupt_read(udev, STATUS_ENDPOINT, reply, STATUS_PACKETSIZE, ATCL_USB_TIMEOUT); + ret = usb_interrupt_read(udev, STATUS_ENDPOINT, (usb_ctrl_charbuf)reply, STATUS_PACKETSIZE, ATCL_USB_TIMEOUT); if (ret <= 0) { - upsdebugx(2, "status interrupt read: %s", ret ? usb_strerror() : "timeout"); + upsdebugx(2, "status interrupt read: %s", ret ? nut_usb_strerror(ret) : "timeout"); return ret; } - upsdebug_hex(3, "read", reply, ret); + assert ((uintmax_t)ret < (uintmax_t)SIZE_MAX); + upsdebug_hex(3, "read", reply, (size_t)ret); return ret; } @@ -163,7 +169,19 @@ static void usb_comm_fail(const char *fmt, ...) } va_start(ap, fmt); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif ret = vsnprintf(why, sizeof(why), fmt, ap); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif va_end(ap); if ((ret < 1) || (ret >= (int) sizeof(why))) { @@ -179,7 +197,7 @@ static void usb_comm_good(void) return; } - upslogx(LOG_NOTICE, "Communications with UPS re-established"); + upslogx(LOG_NOTICE, "Communications with UPS re-established"); comm_failures = 0; } @@ -192,13 +210,16 @@ static void usb_comm_good(void) */ static int driver_callback(usb_dev_handle *handle, USBDevice_t *device) { - if (usb_set_configuration(handle, 1) < 0) { - upslogx(LOG_WARNING, "Can't set USB configuration: %s", usb_strerror()); + int ret; + NUT_UNUSED_VARIABLE(device); + + if ((ret = usb_set_configuration(handle, 1)) < 0) { + upslogx(LOG_WARNING, "Can't set USB configuration: %s", nut_usb_strerror(ret)); return -1; } - if (usb_claim_interface(handle, 0) < 0) { - upslogx(LOG_WARNING, "Can't claim USB interface: %s", usb_strerror()); + if ((ret = usb_claim_interface(handle, 0)) < 0) { + upslogx(LOG_WARNING, "Can't claim USB interface: %s", nut_usb_strerror(ret)); return -1; } @@ -209,31 +230,73 @@ static int driver_callback(usb_dev_handle *handle, USBDevice_t *device) static int usb_device_close(usb_dev_handle *handle) { + int ret = 0; + if (!handle) { return 0; } /* usb_release_interface() sometimes blocks and goes - into uninterruptible sleep. So don't do it. */ + * into uninterruptible sleep. So don't do it. + */ /* usb_release_interface(handle, 0); */ - return usb_close(handle); + +#if WITH_LIBUSB_1_0 + libusb_close(handle); + libusb_exit(NULL); +#else + ret = usb_close(handle); +#endif + + return ret; } static int usb_device_open(usb_dev_handle **handlep, USBDevice_t *device, USBDeviceMatcher_t *matcher, int (*callback)(usb_dev_handle *handle, USBDevice_t *device)) { - struct usb_bus *bus; + int ret = 0; + uint8_t iManufacturer = 0, iProduct = 0, iSerialNumber = 0; /* libusb base init */ +#if WITH_LIBUSB_1_0 + if (libusb_init(NULL) < 0) { + libusb_exit(NULL); + fatal_with_errno(EXIT_FAILURE, "Failed to init libusb 1.0"); + } +#else /* => WITH_LIBUSB_0_1 */ usb_init(); usb_find_busses(); usb_find_devices(); +#endif /* WITH_LIBUSB_1_0 */ #ifndef __linux__ /* SUN_LIBUSB (confirmed to work on Solaris and FreeBSD) */ /* Causes a double free corruption in linux if device is detached! */ - usb_device_close(*handlep); + /* usb_device_close(*handlep); */ + if (*handlep) + usb_close(*handlep); #endif +#if WITH_LIBUSB_1_0 + libusb_device **devlist; + ssize_t devcount = 0; + libusb_device_handle *handle; + struct libusb_device_descriptor dev_desc; + uint8_t bus; + int i; + + devcount = libusb_get_device_list(NULL, &devlist); + if (devcount <= 0) + fatal_with_errno(EXIT_FAILURE, "No USB device found"); + + for (i = 0; i < devcount; i++) { + + USBDeviceMatcher_t *m; + libusb_device *dev = devlist[i]; + libusb_get_device_descriptor(dev, &dev_desc); + ret = libusb_open(dev, &handle); + *handlep = handle; +#else /* => WITH_LIBUSB_0_1 */ + struct usb_bus *bus; for (bus = usb_busses; bus; bus = bus->next) { struct usb_device *dev; @@ -241,18 +304,22 @@ static int usb_device_open(usb_dev_handle **handlep, USBDevice_t *device, USBDev for (dev = bus->devices; dev; dev = dev->next) { - int i, ret; + int i; USBDeviceMatcher_t *m; - upsdebugx(3, "Checking USB device [%04x:%04x] (%s/%s)", dev->descriptor.idVendor, - dev->descriptor.idProduct, bus->dirname, dev->filename); - + upsdebugx(3, "Checking USB device [%04x:%04x] (%s/%s)", + dev->descriptor.idVendor, + dev->descriptor.idProduct, + bus->dirname, dev->filename); + /* supported vendors are now checked by the supplied matcher */ /* open the device */ *handlep = handle = usb_open(dev); +#endif /* WITH_LIBUSB_1_0 */ + if (!handle) { - upsdebugx(4, "Failed to open USB device, skipping: %s", usb_strerror()); + upsdebugx(4, "Failed to open USB device, skipping: %s", nut_usb_strerror(ret)); continue; } @@ -269,34 +336,70 @@ static int usb_device_open(usb_dev_handle **handlep, USBDevice_t *device, USBDev memset(device, 0, sizeof(*device)); +#if WITH_LIBUSB_1_0 + device->VendorID = dev_desc.idVendor; + device->ProductID = dev_desc.idProduct; + bus = libusb_get_bus_number(dev); + device->Bus = (char *)malloc(4); + if (device->Bus == NULL) { + libusb_free_device_list(devlist, 1); + fatal_with_errno(EXIT_FAILURE, "Out of memory"); + } + sprintf(device->Bus, "%03d", bus); + iManufacturer = dev_desc.iManufacturer; + iProduct = dev_desc.iProduct; + iSerialNumber = dev_desc.iSerialNumber; +#else /* => WITH_LIBUSB_0_1 */ device->VendorID = dev->descriptor.idVendor; device->ProductID = dev->descriptor.idProduct; - device->Bus = strdup(bus->dirname); - - if (dev->descriptor.iManufacturer) { + device->Bus = xstrdup(bus->dirname); + iManufacturer = dev->descriptor.iManufacturer; + iProduct = dev->descriptor.iProduct; + iSerialNumber = dev->descriptor.iSerialNumber; +#endif /* WITH_LIBUSB_1_0 */ + + if (iManufacturer) { char buf[SMALLBUF]; - ret = usb_get_string_simple(handle, dev->descriptor.iManufacturer, - buf, sizeof(buf)); + ret = usb_get_string_simple(handle, iManufacturer, + (usb_ctrl_charbuf)buf, sizeof(buf)); if (ret > 0) { device->Vendor = strdup(buf); + if (device->Vendor == NULL) { +#if WITH_LIBUSB_1_0 + libusb_free_device_list(devlist, 1); +#endif /* WITH_LIBUSB_1_0 */ + fatal_with_errno(EXIT_FAILURE, "Out of memory"); + } } } - if (dev->descriptor.iProduct) { + if (iProduct) { char buf[SMALLBUF]; - ret = usb_get_string_simple(handle, dev->descriptor.iProduct, - buf, sizeof(buf)); + ret = usb_get_string_simple(handle, iProduct, + (usb_ctrl_charbuf)buf, sizeof(buf)); if (ret > 0) { device->Product = strdup(buf); + if (device->Product == NULL) { +#if WITH_LIBUSB_1_0 + libusb_free_device_list(devlist, 1); +#endif /* WITH_LIBUSB_1_0 */ + fatal_with_errno(EXIT_FAILURE, "Out of memory"); + } } } - if (dev->descriptor.iSerialNumber) { + if (iSerialNumber) { char buf[SMALLBUF]; - ret = usb_get_string_simple(handle, dev->descriptor.iSerialNumber, - buf, sizeof(buf)); + ret = usb_get_string_simple(handle, iSerialNumber, + (usb_ctrl_charbuf)buf, sizeof(buf)); if (ret > 0) { device->Serial = strdup(buf); + if (device->Serial == NULL) { +#if WITH_LIBUSB_1_0 + libusb_free_device_list(devlist, 1); +#endif /* WITH_LIBUSB_1_0 */ + fatal_with_errno(EXIT_FAILURE, "Out of memory"); + } } } @@ -308,49 +411,106 @@ static int usb_device_open(usb_dev_handle **handlep, USBDevice_t *device, USBDev upsdebugx(4, "- Bus : %s", device->Bus ? device->Bus : "unknown"); for (m = matcher; m; m = m->next) { - + switch (m->match_function(device, m->privdata)) { case 0: upsdebugx(4, "Device does not match - skipping"); goto next_device; case -1: +#if WITH_LIBUSB_1_0 + libusb_free_device_list(devlist, 1); +#endif /* WITH_LIBUSB_1_0 */ fatal_with_errno(EXIT_FAILURE, "matcher"); +#ifndef HAVE___ATTRIBUTE__NORETURN +# if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunreachable-code" +# endif goto next_device; +# if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) +# pragma GCC diagnostic pop +# endif +#endif case -2: upsdebugx(4, "matcher: unspecified error"); goto next_device; } } +#ifdef HAVE_LIBUSB_SET_AUTO_DETACH_KERNEL_DRIVER + /* First, try the auto-detach kernel driver method + * This function is not available on FreeBSD 10.1-10.3 */ + if ((ret = libusb_set_auto_detach_kernel_driver (udev, 1)) < 0) + upsdebugx(2, "failed to auto detach kernel driver from USB device: %s", + nut_usb_strerror((enum libusb_error)ret)); + else + upsdebugx(2, "auto detached kernel driver from USB device"); +#endif /* HAVE_LIBUSB_SET_AUTO_DETACH_KERNEL_DRIVER */ for (i = 0; i < 3; i++) { ret = callback(handle, device); if (ret >= 0) { upsdebugx(3, "USB device [%04x:%04x] opened", device->VendorID, device->ProductID); +#if WITH_LIBUSB_1_0 + libusb_free_device_list(devlist, 1); +#endif /* WITH_LIBUSB_1_0 */ return ret; } -#ifdef HAVE_USB_DETACH_KERNEL_DRIVER_NP + +#if WITH_LIBUSB_0_1 && (defined HAVE_USB_DETACH_KERNEL_DRIVER_NP) /* this method requires at least libusb 0.1.8: * it forces device claiming by unbinding * attached driver... From libhid */ - if (usb_detach_kernel_driver_np(handle, 0) < 0) { - upsdebugx(1, "failed to detach kernel driver from USB device: %s", usb_strerror()); + if ((ret = usb_detach_kernel_driver_np(handle, 0)) < 0) { + upsdebugx(1, + "failed to detach kernel driver from USB device: %s", + nut_usb_strerror(ret)); } else { upsdebugx(4, "detached kernel driver from USB device..."); } -#endif +#else +# ifdef HAVE_LIBUSB_DETACH_KERNEL_DRIVER + if ((ret = libusb_detach_kernel_driver(udev, 0)) < 0) { + upsdebugx(4, + "failed to detach kernel driver from USB device: %s", + nut_usb_strerror(ret)); + } else { + upsdebugx(4, "detached kernel driver from USB device..."); + } +# else +# ifdef HAVE_LIBUSB_DETACH_KERNEL_DRIVER_NP + if ((ret = libusb_detach_kernel_driver_np(udev, 0)) < 0) { + upsdebugx(4, + "failed to detach kernel driver from USB device: %s", + nut_usb_strerror(ret)); + } else { + upsdebugx(4, "detached kernel driver from USB device..."); + } +# endif /* HAVE_LIBUSB_DETACH_KERNEL_DRIVER_NP */ +# endif /* HAVE_LIBUSB_DETACH_KERNEL_DRIVER */ +#endif /* HAVE_USB_DETACH_KERNEL_DRIVER_NP or HAVE_LIBUSB_DETACH_KERNEL_DRIVER or HAVE_LIBUSB_DETACH_KERNEL_DRIVER_NP */ } - fatalx(EXIT_FAILURE, "USB device [%04x:%04x] matches, but driver callback failed: %s", - device->VendorID, device->ProductID, usb_strerror()); +#if WITH_LIBUSB_1_0 + libusb_free_device_list(devlist, 1); +#endif /* WITH_LIBUSB_1_0 */ + fatalx(EXIT_FAILURE, + "USB device [%04x:%04x] matches, but driver callback failed: %s", + device->VendorID, device->ProductID, + nut_usb_strerror(ret)); next_device: usb_close(handle); +#if (!WITH_LIBUSB_1_0) /* => WITH_LIBUSB_0_1 */ } +#endif /* WITH_LIBUSB_1_0 */ } *handlep = NULL; +#if WITH_LIBUSB_1_0 + libusb_free_device_list(devlist, 1); +#endif /* WITH_LIBUSB_1_0 */ upsdebugx(3, "No matching USB device found"); return -1; @@ -446,8 +606,12 @@ void upsdrv_updateinfo(void) case 2: upsdebugx(2, "reply[0] = 0x%02x -> LB", reply[0]); status_set("LB"); + goto fallthrough_LB_means_OB; + /* Note: the comment below existed for years, so wondering + * if this device CAN set independently LB and OB? */ /* fall through */ case 1: + fallthrough_LB_means_OB: upsdebugx(2, "reply[0] = 0x%02x -> OB", reply[0]); status_set("OB"); break; @@ -466,24 +630,37 @@ void upsdrv_updateinfo(void) */ void upsdrv_shutdown(void) { - const char shutdown_packet[SHUTDOWN_PACKETSIZE] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + /* Not "const" because this mismatches arg type of usb_interrupt_write() */ + char shutdown_packet[SHUTDOWN_PACKETSIZE] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; int ret; - upslogx(LOG_DEBUG, "%s: attempting to call usb_interrupt_write(01 00 00 00 00 00 00 00)", __func__); + upslogx(LOG_DEBUG, + "%s: attempting to call usb_interrupt_write(01 00 00 00 00 00 00 00)", + __func__); - ret = usb_interrupt_write(udev, SHUTDOWN_ENDPOINT, (char *)shutdown_packet, SHUTDOWN_PACKETSIZE, ATCL_USB_TIMEOUT); + ret = usb_interrupt_write(udev, + SHUTDOWN_ENDPOINT, (usb_ctrl_charbuf)shutdown_packet, + SHUTDOWN_PACKETSIZE, ATCL_USB_TIMEOUT); if (ret <= 0) { - upslogx(LOG_NOTICE, "%s: first usb_interrupt_write() failed: %s", __func__, ret ? usb_strerror() : "timeout"); + upslogx(LOG_NOTICE, + "%s: first usb_interrupt_write() failed: %s", + __func__, + ret ? nut_usb_strerror(ret) : "timeout"); } /* Totally guessing from the .pcap file here. TODO: configurable delay? */ usleep(170*1000); - ret = usb_interrupt_write(udev, SHUTDOWN_ENDPOINT, (char *)shutdown_packet, SHUTDOWN_PACKETSIZE, ATCL_USB_TIMEOUT); + ret = usb_interrupt_write(udev, + SHUTDOWN_ENDPOINT, (usb_ctrl_charbuf)shutdown_packet, + SHUTDOWN_PACKETSIZE, ATCL_USB_TIMEOUT); if (ret <= 0) { - upslogx(LOG_ERR, "%s: second usb_interrupt_write() failed: %s", __func__, ret ? usb_strerror() : "timeout"); + upslogx(LOG_ERR, + "%s: second usb_interrupt_write() failed: %s", + __func__, + ret ? nut_usb_strerror(ret) : "timeout"); } } diff --git a/drivers/nutdrv_qx.c b/drivers/nutdrv_qx.c index bb52660..337b42a 100644 --- a/drivers/nutdrv_qx.c +++ b/drivers/nutdrv_qx.c @@ -2,6 +2,7 @@ * * Copyright (C) * 2013 Daniele Pezzini + * 2016 Eaton * Based on: * usbhid-ups.c - Copyright (C) * 2003-2012 Arnaud Quette @@ -16,6 +17,10 @@ * blazer_usb.c - Copyright (C) * 2003-2009 Arjen de Korte * 2011-2012 Arnaud Quette + * Masterguard additions + * 2020-2021 Edgar Fuß, Mathematisches Institut der Universität Bonn + * Armac (Richcomm-variant) additions + * 2021 Tomasz Fortuna * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,16 +38,17 @@ * */ -#define DRIVER_VERSION "0.28" +#define DRIVER_VERSION "0.32" +#include "config.h" #include "main.h" - -#include +#include "attribute.h" +#include "nut_float.h" +#include "nut_stdint.h" /* note: QX_USB/QX_SERIAL set through Makefile */ #ifdef QX_USB - #include "libusb.h" - #include "usb-common.h" + #include "nut_libusb.h" /* also includes "usb-common.h" */ #ifdef QX_SERIAL #define DRIVER_NAME "Generic Q* USB/Serial driver" @@ -63,6 +69,7 @@ /* == Subdrivers == */ /* Include all known subdrivers */ #include "nutdrv_qx_bestups.h" +#include "nutdrv_qx_hunnox.h" #include "nutdrv_qx_mecer.h" #include "nutdrv_qx_megatec.h" #include "nutdrv_qx_megatec-old.h" @@ -72,8 +79,10 @@ #include "nutdrv_qx_voltronic-qs.h" #include "nutdrv_qx_voltronic-qs-hex.h" #include "nutdrv_qx_zinto.h" +#include "nutdrv_qx_masterguard.h" +#include "nutdrv_qx_ablerex.h" -/* Master list of available subdrivers */ +/* Reference list of available non-USB subdrivers */ static subdriver_t *subdriver_list[] = { &voltronic_subdriver, &voltronic_qs_subdriver, @@ -84,6 +93,9 @@ static subdriver_t *subdriver_list[] = { &mecer_subdriver, &megatec_subdriver, &zinto_subdriver, + &masterguard_subdriver, + &hunnox_subdriver, + &ablerex_subdriver, /* Fallback Q1 subdriver */ &q1_subdriver, NULL @@ -98,7 +110,8 @@ upsdrv_info_t upsdrv_info = { "Arnaud Quette " \ "John Stamp " \ "Peter Selinger " \ - "Arjen de Korte ", + "Arjen de Korte " \ + "Edgar Fuß ", DRV_BETA, #ifdef QX_USB { &comm_upsdrv_info, NULL } @@ -107,7 +120,6 @@ upsdrv_info_t upsdrv_info = { #endif /* QX_USB */ }; - /* == Data walk modes == */ typedef enum { QX_WALKMODE_INIT = 0, @@ -120,12 +132,16 @@ typedef enum { /* Pointer to the active subdriver object (changed in subdriver_matcher() function) */ static subdriver_t *subdriver = NULL; -static int pollfreq = DEFAULT_POLLFREQ; -static int ups_status = 0; +static long pollfreq = DEFAULT_POLLFREQ; +static unsigned int ups_status = 0; static bool_t data_has_changed = FALSE; /* for SEMI_STATIC data polling */ static time_t lastpoll; /* Timestamp the last polling */ +#if defined(QX_USB) && !defined(TESTING) +static int hunnox_step = 0; +#endif /* QX_USB && !TESTING */ + #if defined(QX_USB) && defined(QX_SERIAL) static int is_usb = 0; /* Whether the device is connected through USB (1) or serial (0) */ #endif /* QX_USB && QX_SERIAL */ @@ -138,8 +154,8 @@ static struct { /* == Support functions == */ static int subdriver_matcher(void); -static int qx_command(const char *cmd, char *buf, size_t buflen); -static int qx_process_answer(item_t *item, const int len); +static ssize_t qx_command(const char *cmd, char *buf, size_t buflen); +static int qx_process_answer(item_t *item, const size_t len); /* returns just 0 or -1 */ static bool_t qx_ups_walk(walkmode_t mode); static void ups_status_set(void); static void ups_alarm_set(void); @@ -148,8 +164,8 @@ static void qx_set_var(item_t *item); /* == Struct & data for status processing == */ typedef struct { - const char *status_str; /* UPS status string */ - const int status_mask; /* UPS status mask */ + const char *status_str; /* UPS status string */ + const unsigned int status_mask; /* UPS status mask */ } status_lkp_t; static status_lkp_t status_info[] = { @@ -206,7 +222,8 @@ static struct { static time_t battery_lastpoll = 0; -/* Fill batt.volt.act and guesstimate the battery charge if it isn't already available. */ +/* Fill batt.volt.act and guesstimate the battery charge + * if it isn't already available. */ static int qx_battery(void) { const char *val = dstate_getinfo("battery.voltage"); @@ -218,7 +235,7 @@ static int qx_battery(void) batt.volt.act = batt.packs * strtod(val, NULL); - if (batt.chrg.act == -1 && batt.volt.low > 0 && batt.volt.high > batt.volt.low) { + if (d_equal(batt.chrg.act, -1) && batt.volt.low > 0 && batt.volt.high > batt.volt.low) { batt.chrg.act = 100 * (batt.volt.act - batt.volt.low) / (batt.volt.high - batt.volt.low); @@ -280,8 +297,10 @@ static void qx_initbattery(void) batt.volt.nom = strtod(val, NULL); } - /* If no values are available for both battery.voltage.{low,high} either from the UPS or provided by the user in ups.conf, try to guesstimate them, but announce it! */ - if (batt.volt.nom != -1 && (batt.volt.low == -1 || batt.volt.high == -1)) { + /* If no values are available for both battery.voltage.{low,high} + * either from the UPS or provided by the user in ups.conf, + * try to guesstimate them, but announce it! */ + if ( (!d_equal(batt.volt.nom, -1)) && (d_equal(batt.volt.low, -1) || d_equal(batt.volt.high, -1))) { upslogx(LOG_INFO, "No values for battery high/low voltages"); @@ -293,7 +312,8 @@ static void qx_initbattery(void) dstate_setinfo("battery.voltage.low", "%.2f", batt.volt.low); dstate_setinfo("battery.voltage.high", "%.2f", batt.volt.high); - upslogx(LOG_INFO, "Using 'guesstimation' (low: %f, high: %f)!", batt.volt.low, batt.volt.high); + upslogx(LOG_INFO, "Using 'guesstimation' (low: %f, high: %f)!", + batt.volt.low, batt.volt.high); } @@ -303,13 +323,15 @@ static void qx_initbattery(void) } else { /* qx_battery -> batt.volt.act */ - if (!qx_battery() && batt.volt.nom != -1) { + if (!qx_battery() && (!d_equal(batt.volt.nom, -1))) { const double packs[] = { 120, 100, 80, 60, 48, 36, 30, 24, 18, 12, 8, 6, 4, 3, 2, 1, 0.5, -1 }; int i; - /* The battery voltage will quickly return to at least the nominal value after discharging them. - * For overlapping battery.voltage.low/high ranges therefor choose the one with the highest multiplier. */ + /* The battery voltage will quickly return to + * at least the nominal value after discharging them. + * For overlapping battery.voltage.low/high ranges + * therefore choose the one with the highest multiplier. */ for (i = 0; packs[i] > 0; i++) { if (packs[i] * batt.volt.act > 1.2 * batt.volt.nom) { @@ -317,7 +339,9 @@ static void qx_initbattery(void) } if (packs[i] * batt.volt.act < 0.8 * batt.volt.nom) { - upslogx(LOG_INFO, "Can't autodetect number of battery packs [%.0f/%.2f]", batt.volt.nom, batt.volt.act); + upslogx(LOG_INFO, + "Can't autodetect number of battery packs [%.0f/%.2f]", + batt.volt.nom, batt.volt.act); break; } @@ -327,7 +351,9 @@ static void qx_initbattery(void) } } else { - upslogx(LOG_INFO, "Can't autodetect number of battery packs [%.0f/%.2f]", batt.volt.nom, batt.volt.act); + upslogx(LOG_INFO, + "Can't autodetect number of battery packs [%.0f/%.2f]", + batt.volt.nom, batt.volt.act); } } @@ -355,20 +381,23 @@ static void qx_initbattery(void) } batt.runt.exp = log(rl / rh) / log(lh / ll); - upsdebugx(2, "%s: battery runtime exponent: %.3f", __func__, batt.runt.exp); + upsdebugx(2, "%s: battery runtime exponent: %.3f", + __func__, batt.runt.exp); batt.runt.nom = rh * pow(lh / 100, batt.runt.exp); - upsdebugx(2, "%s: battery runtime nominal: %.1f", __func__, batt.runt.nom); + upsdebugx(2, "%s: battery runtime nominal: %.1f", + __func__, batt.runt.nom); } else { - upslogx(LOG_INFO, "Battery runtime will not be calculated (runtimecal not set)"); + upslogx(LOG_INFO, "Battery runtime will not be calculated " + "(runtimecal not set)"); return; } val = dstate_getinfo("battery.charge"); - if (!val && batt.volt.nom != -1) { + if (!val && (!d_equal(batt.volt.nom, -1))) { batt.volt.low = batt.volt.nom; batt.volt.high = 1.15 * batt.volt.nom; @@ -380,7 +409,8 @@ static void qx_initbattery(void) if (val) { batt.runt.est = batt.runt.nom * strtod(val, NULL) / 100; - upsdebugx(2, "%s: battery runtime estimate: %.1f", __func__, batt.runt.est); + upsdebugx(2, "%s: battery runtime estimate: %.1f", + __func__, batt.runt.est); } else { fatalx(EXIT_FAILURE, "Initial battery charge undetermined"); } @@ -393,9 +423,13 @@ static void qx_initbattery(void) fatalx(EXIT_FAILURE, "Charge time out of range [1..s]"); } - upsdebugx(2, "%s: battery charge time: %ld", __func__, batt.chrg.time); + upsdebugx(2, "%s: battery charge time: %ld", + __func__, batt.chrg.time); } else { - upslogx(LOG_INFO, "No charge time specified, using built in default [%ld seconds]", batt.chrg.time); + upslogx(LOG_INFO, + "No charge time specified, " + "using built in default [%ld seconds]", + batt.chrg.time); } val = getval("idleload"); @@ -406,9 +440,13 @@ static void qx_initbattery(void) fatalx(EXIT_FAILURE, "Idle load out of range [0..100]"); } - upsdebugx(2, "%s: minimum load used (idle): %.3f", __func__, load.low); + upsdebugx(2, + "%s: minimum load used (idle): %.3f", + __func__, load.low); } else { - upslogx(LOG_INFO, "No idle load specified, using built in default [%.1f %%]", 100 * load.low); + upslogx(LOG_INFO, + "No idle load specified, using built in default [%.1f %%]", + 100 * load.low); } } } @@ -429,21 +467,33 @@ static int (*subdriver_command)(const char *cmd, char *buf, size_t buflen) = NUL static int cypress_command(const char *cmd, char *buf, size_t buflen) { char tmp[SMALLBUF]; - int ret; + int ret = 0; size_t i; + if (buflen > INT_MAX) { + upsdebugx(3, "%s: requested to read too much (%zu), " + "reducing buflen to (INT_MAX-1)", + __func__, buflen); + buflen = (INT_MAX - 1); + } + /* Send command */ memset(tmp, 0, sizeof(tmp)); snprintf(tmp, sizeof(tmp), "%s", cmd); - for (i = 0; i < strlen(tmp); i += ret) { + for (i = 0; i < strlen(tmp); i += (size_t)ret) { /* Write data in 8-byte chunks */ /* ret = usb->set_report(udev, 0, (unsigned char *)&tmp[i], 8); */ - ret = usb_control_msg(udev, USB_ENDPOINT_OUT + USB_TYPE_CLASS + USB_RECIP_INTERFACE, 0x09, 0x200, 0, &tmp[i], 8, 5000); + ret = usb_control_msg(udev, + USB_ENDPOINT_OUT + USB_TYPE_CLASS + USB_RECIP_INTERFACE, + 0x09, 0x200, 0, + (usb_ctrl_charbuf)&tmp[i], 8, 5000); if (ret <= 0) { - upsdebugx(3, "send: %s (%d)", ret ? usb_strerror() : "timeout", ret); + upsdebugx(3, "send: %s (%d)", + ret ? nut_usb_strerror(ret) : "timeout", + ret); return ret; } @@ -454,51 +504,76 @@ static int cypress_command(const char *cmd, char *buf, size_t buflen) /* Read reply */ memset(buf, 0, buflen); - for (i = 0; (i <= buflen-8) && (memchr(buf, '\r', buflen) == NULL); i += ret) { + for (i = 0; (i <= buflen-8) && (memchr(buf, '\r', buflen) == NULL); i += (size_t)ret) { /* Read data in 8-byte chunks */ /* ret = usb->get_interrupt(udev, (unsigned char *)&buf[i], 8, 1000); */ - ret = usb_interrupt_read(udev, 0x81, &buf[i], 8, 1000); + ret = usb_interrupt_read(udev, + 0x81, + (usb_ctrl_charbuf)&buf[i], 8, 1000); - /* Any errors here mean that we are unable to read a reply (which will happen after successfully writing a command to the UPS) */ + /* Any errors here mean that we are unable to read a reply + * (which will happen after successfully writing a command + * to the UPS) */ if (ret <= 0) { - upsdebugx(3, "read: %s (%d)", ret ? usb_strerror() : "timeout", ret); + upsdebugx(3, "read: %s (%d)", + ret ? nut_usb_strerror(ret) : "timeout", + ret); return ret; } snprintf(tmp, sizeof(tmp), "read [% 3d]", (int)i); - upsdebug_hex(5, tmp, &buf[i], ret); + upsdebug_hex(5, tmp, &buf[i], (size_t)ret); } upsdebugx(3, "read: %.*s", (int)strcspn(buf, "\r"), buf); - return i; + + if (i > INT_MAX) { + upsdebugx(3, "%s: read too much (%zu)", __func__, i); + return -1; + } + return (int)i; } /* SGS communication subdriver */ static int sgs_command(const char *cmd, char *buf, size_t buflen) { char tmp[SMALLBUF]; - int ret; + int ret = 0; size_t cmdlen, i; + if (buflen > INT_MAX) { + upsdebugx(3, "%s: requested to read too much (%zu), " + "reducing buflen to (INT_MAX-1)", + __func__, buflen); + buflen = (INT_MAX - 1); + } + /* Send command */ cmdlen = strlen(cmd); - for (i = 0; i < cmdlen; i += ret) { + for (i = 0; i < cmdlen; i += (size_t)ret) { memset(tmp, 0, sizeof(tmp)); - ret = (cmdlen - i) < 7 ? (cmdlen - i) : 7; + /* i and cmdlen are size_t nominally, but diff is not large */ + ret = (int)((cmdlen - i) < 7 ? (cmdlen - i) : 7); - tmp[0] = ret; - memcpy(&tmp[1], &cmd[i], ret); + /* ret is between 0 and 7 */ + tmp[0] = (char)ret; + memcpy(&tmp[1], &cmd[i], (unsigned char)ret); /* Write data in 8-byte chunks */ - ret = usb_control_msg(udev, USB_ENDPOINT_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0x09, 0x200, 0, tmp, 8, 5000); + ret = usb_control_msg(udev, + USB_ENDPOINT_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, + 0x09, 0x200, 0, + (usb_ctrl_charbuf)tmp, 8, 5000); if (ret <= 0) { - upsdebugx(3, "send: %s (%d)", ret ? usb_strerror() : "timeout", ret); + upsdebugx(3, "send: %s (%d)", + ret ? nut_usb_strerror(ret) : "timeout", + ret); return ret; } @@ -511,20 +586,27 @@ static int sgs_command(const char *cmd, char *buf, size_t buflen) /* Read reply */ memset(buf, 0, buflen); - for (i = 0; i <= buflen - 8; i += ret) { + for (i = 0; i <= buflen - 8; i += (size_t)ret) { memset(tmp, 0, sizeof(tmp)); /* Read data in 8-byte chunks */ - ret = usb_interrupt_read(udev, 0x81, tmp, 8, 1000); + ret = usb_interrupt_read(udev, + 0x81, + (usb_ctrl_charbuf)tmp, 8, 1000); /* No error!!! */ - if (ret == -110) + /* if (ret == -110) */ + if (ret == ERROR_TIMEOUT) break; - /* Any errors here mean that we are unable to read a reply (which will happen after successfully writing a command to the UPS) */ + /* Any errors here mean that we are unable to read a reply + * (which will happen after successfully writing a command + * to the UPS) */ if (ret <= 0) { - upsdebugx(3, "read: %s (%d)", ret ? usb_strerror() : "timeout", ret); + upsdebugx(3, "read: %s (%d)", + ret ? nut_usb_strerror(ret) : "timeout", + ret); return ret; } @@ -533,15 +615,30 @@ static int sgs_command(const char *cmd, char *buf, size_t buflen) ret = tmp[0] <= 7 ? tmp[0] : 7; if (ret > 0) - memcpy(&buf[i], &tmp[1], ret); + memcpy(&buf[i], &tmp[1], (unsigned char)ret); snprintf(tmp, sizeof(tmp), "read [% 3d]", (int)i); - upsdebug_hex(5, tmp, &buf[i], ret); + upsdebug_hex(5, tmp, &buf[i], (size_t)ret); } + /* If the reply lacks the expected terminating CR, add it (if there's enough space) */ + if (i && memchr(buf, '\r', i) == NULL) { + upsdebugx(4, "%s: the reply lacks the expected terminating CR.", __func__); + if (i < buflen - 1) { + upsdebugx(4, "%s: adding missing terminating CR.", __func__); + buf[i++] = '\r'; + buf[i] = 0; + } + } + upsdebugx(3, "read: %.*s", (int)strcspn(buf, "\r"), buf); - return i; + + if (i > INT_MAX) { + upsdebugx(3, "%s: read too much (%zu)", __func__, i); + return -1; + } + return (int)i; } /* Phoenix communication subdriver */ @@ -551,28 +648,42 @@ static int phoenix_command(const char *cmd, char *buf, size_t buflen) int ret; size_t i; + if (buflen > INT_MAX) { + upsdebugx(3, "%s: requested to read too much (%zu), " + "reducing buflen to (INT_MAX-1)", + __func__, buflen); + buflen = (INT_MAX - 1); + } + for (i = 0; i < 8; i++) { /* Read data in 8-byte chunks */ /* ret = usb->get_interrupt(udev, (unsigned char *)tmp, 8, 1000); */ - ret = usb_interrupt_read(udev, 0x81, tmp, 8, 1000); + ret = usb_interrupt_read(udev, + 0x81, + (usb_ctrl_charbuf)tmp, 8, 1000); /* This USB to serial implementation is crappy. - * In order to read correct replies we need to flush the output buffers of the converter until we get no more data (ie, it times out). */ + * In order to read correct replies we need to flush the + * output buffers of the converter until we get no more + * data (e.g. it times out). */ switch (ret) { - case -EPIPE: /* Broken pipe */ + case ERROR_PIPE: /* Broken pipe */ usb_clear_halt(udev, 0x81); - case -ETIMEDOUT: /* Connection timed out */ + break; + + case ERROR_TIMEOUT: /* Connection timed out */ break; } if (ret < 0) { - upsdebugx(3, "flush: %s (%d)", usb_strerror(), ret); + upsdebugx(3, "flush: %s (%d)", + nut_usb_strerror(ret), ret); break; } - upsdebug_hex(4, "dump", tmp, ret); + upsdebug_hex(4, "dump", tmp, (size_t)ret); } @@ -580,14 +691,17 @@ static int phoenix_command(const char *cmd, char *buf, size_t buflen) memset(tmp, 0, sizeof(tmp)); snprintf(tmp, sizeof(tmp), "%s", cmd); - for (i = 0; i < strlen(tmp); i += ret) { + for (i = 0; i < strlen(tmp); i += (size_t)ret) { /* Write data in 8-byte chunks */ /* ret = usb->set_report(udev, 0, (unsigned char *)&tmp[i], 8); */ - ret = usb_control_msg(udev, USB_ENDPOINT_OUT + USB_TYPE_CLASS + USB_RECIP_INTERFACE, 0x09, 0x200, 0, &tmp[i], 8, 1000); + ret = usb_control_msg(udev, + USB_ENDPOINT_OUT + USB_TYPE_CLASS + USB_RECIP_INTERFACE, + 0x09, 0x200, 0, (usb_ctrl_charbuf)&tmp[i], 8, 1000); if (ret <= 0) { - upsdebugx(3, "send: %s (%d)", ret ? usb_strerror() : "timeout", ret); + upsdebugx(3, "send: %s (%d)", + ret ? nut_usb_strerror(ret) : "timeout", ret); return ret; } @@ -598,25 +712,35 @@ static int phoenix_command(const char *cmd, char *buf, size_t buflen) /* Read reply */ memset(buf, 0, buflen); - for (i = 0; (i <= buflen-8) && (memchr(buf, '\r', buflen) == NULL); i += ret) { + for (i = 0; (i <= buflen-8) && (memchr(buf, '\r', buflen) == NULL); i += (size_t)ret) { /* Read data in 8-byte chunks */ /* ret = usb->get_interrupt(udev, (unsigned char *)&buf[i], 8, 1000); */ - ret = usb_interrupt_read(udev, 0x81, &buf[i], 8, 1000); + ret = usb_interrupt_read(udev, + 0x81, + (usb_ctrl_charbuf)&buf[i], 8, 1000); - /* Any errors here mean that we are unable to read a reply (which will happen after successfully writing a command to the UPS) */ + /* Any errors here mean that we are unable to read a reply + * (which will happen after successfully writing a command + * to the UPS) */ if (ret <= 0) { - upsdebugx(3, "read: %s (%d)", ret ? usb_strerror() : "timeout", ret); + upsdebugx(3, "read: %s (%d)", + ret ? nut_usb_strerror(ret) : "timeout", ret); return ret; } snprintf(tmp, sizeof(tmp), "read [% 3d]", (int)i); - upsdebug_hex(5, tmp, &buf[i], ret); + upsdebug_hex(5, tmp, &buf[i], (size_t)ret); } upsdebugx(3, "read: %.*s", (int)strcspn(buf, "\r"), buf); - return i; + + if (i > INT_MAX) { + upsdebugx(3, "%s: read too much (%zu)", __func__, i); + return -1; + } + return (int)i; } /* Ippon communication subdriver */ @@ -626,16 +750,27 @@ static int ippon_command(const char *cmd, char *buf, size_t buflen) int ret; size_t i, len; + if (buflen > INT_MAX) { + upsdebugx(3, "%s: requested to read too much (%zu), " + "reducing buflen to (INT_MAX-1)", + __func__, buflen); + buflen = (INT_MAX - 1); + } + /* Send command */ snprintf(tmp, sizeof(tmp), "%s", cmd); - for (i = 0; i < strlen(tmp); i += ret) { + for (i = 0; i < strlen(tmp); i += (size_t)ret) { /* Write data in 8-byte chunks */ - ret = usb_control_msg(udev, USB_ENDPOINT_OUT + USB_TYPE_CLASS + USB_RECIP_INTERFACE, 0x09, 0x2, 0, &tmp[i], 8, 1000); + ret = usb_control_msg(udev, + USB_ENDPOINT_OUT + USB_TYPE_CLASS + USB_RECIP_INTERFACE, + 0x09, 0x2, 0, (usb_ctrl_charbuf)&tmp[i], 8, 1000); if (ret <= 0) { - upsdebugx(3, "send: %s (%d)", (ret != -ETIMEDOUT) ? usb_strerror() : "Connection timed out", ret); + upsdebugx(3, "send: %s (%d)", + (ret != ERROR_TIMEOUT) ? nut_usb_strerror(ret) : "Connection timed out", + ret); return ret; } @@ -644,16 +779,25 @@ static int ippon_command(const char *cmd, char *buf, size_t buflen) upsdebugx(3, "send: %.*s", (int)strcspn(tmp, "\r"), tmp); /* Read all 64 bytes of the reply in one large chunk */ - ret = usb_interrupt_read(udev, 0x81, tmp, sizeof(tmp), 1000); + ret = usb_interrupt_read(udev, + 0x81, + (usb_ctrl_charbuf)tmp, sizeof(tmp), 1000); - /* Any errors here mean that we are unable to read a reply (which will happen after successfully writing a command to the UPS) */ + /* Any errors here mean that we are unable to read a reply + * (which will happen after successfully writing a command + * to the UPS) */ if (ret <= 0) { - upsdebugx(3, "read: %s (%d)", (ret != -ETIMEDOUT) ? usb_strerror() : "Connection timed out", ret); + upsdebugx(3, "read: %s (%d)", + (ret != ERROR_TIMEOUT) ? nut_usb_strerror(ret) : "Connection timed out", + ret); return ret; } - /* As Ippon will always return 64 bytes in response, we have to calculate and return length of actual response data here. - * Empty response will look like 0x00 0x0D, otherwise it will be data string terminated by 0x0D. */ + /* As Ippon will always return 64 bytes in response, + * we have to calculate and return length of actual + * response data here. + * Empty response will look like 0x00 0x0D, otherwise + * it will be data string terminated by 0x0D. */ for (i = 0, len = 0; i < (size_t)ret; i++) { @@ -669,7 +813,7 @@ static int ippon_command(const char *cmd, char *buf, size_t buflen) if (!len) len = strlen(tmp); - upsdebug_hex(5, "read", tmp, (int)len); + upsdebug_hex(5, "read", tmp, (size_t)len); upsdebugx(3, "read: %.*s", (int)strcspn(tmp, "\r"), tmp); len = len < buflen ? len : buflen - 1; @@ -677,9 +821,76 @@ static int ippon_command(const char *cmd, char *buf, size_t buflen) memset(buf, 0, buflen); memcpy(buf, tmp, len); + /* If the reply lacks the expected terminating CR, add it (if there's enough space) */ + if (len && memchr(buf, '\r', len) == NULL) { + upsdebugx(4, "%s: the reply lacks the expected terminating CR.", __func__); + if (len < buflen - 1) { + upsdebugx(4, "%s: adding missing terminating CR.", __func__); + buf[len++] = '\r'; + buf[len] = 0; + } + } + + if (len > INT_MAX) { + upsdebugx(3, "%s: read too much (%zu)", __func__, len); + return -1; + } return (int)len; } +static int hunnox_protocol(int asking_for) +{ + char buf[1030]; + + int langid_fix_local = 0x0409; + + if (langid_fix != -1) { + langid_fix_local = langid_fix; + } + + switch (hunnox_step) { + case 0: + upsdebugx(3, "asking for: %02X", 0x00); + usb_get_string(udev, 0x00, + langid_fix_local, (usb_ctrl_charbuf)buf, 1026); + usb_get_string(udev, 0x00, + langid_fix_local, (usb_ctrl_charbuf)buf, 1026); + usb_get_string(udev, 0x01, + langid_fix_local, (usb_ctrl_charbuf)buf, 1026); + usleep(10000); + break; + case 1: + if (asking_for != 0x0d) { + upsdebugx(3, "asking for: %02X", 0x0d); + usb_get_string(udev, 0x0d, + langid_fix_local, (usb_ctrl_charbuf)buf, 102); + } + break; + case 2: + if (asking_for != 0x03) { + upsdebugx(3, "asking for: %02X", 0x03); + usb_get_string(udev, 0x03, + langid_fix_local, (usb_ctrl_charbuf)buf, 102); + } + break; + case 3: + if (asking_for != 0x0c) { + upsdebugx(3, "asking for: %02X", 0x0c); + usb_get_string(udev, 0x0c, + langid_fix_local, (usb_ctrl_charbuf)buf, 102); + } + break; + default: + hunnox_step = 0; + } + hunnox_step++; + if (hunnox_step > 3) { + hunnox_step = 1; + } + + return 0; +} + /* Krauler communication subdriver */ static int krauler_command(const char *cmd, char *buf, size_t buflen) { @@ -699,13 +910,20 @@ static int krauler_command(const char *cmd, char *buf, size_t buflen) { "Q\r", 0x07, '\r' }, { "C\r", 0x0b, '\r' }, { "CT\r", 0x0b, '\r' }, - { NULL } + { NULL, 0, '\0' } }; int i; upsdebugx(3, "send: %.*s", (int)strcspn(cmd, "\r"), cmd); + if (buflen > INT_MAX) { + upsdebugx(3, "%s: requested to read too much (%zu), " + "reducing buflen to (INT_MAX-1)", + __func__, buflen); + buflen = (INT_MAX - 1); + } + for (i = 0; command[i].str; i++) { int retry; @@ -720,13 +938,18 @@ static int krauler_command(const char *cmd, char *buf, size_t buflen) if (langid_fix != -1) { /* Apply langid_fix value */ - ret = usb_get_string(udev, command[i].index, langid_fix, buf, buflen); + ret = usb_get_string(udev, + command[i].index, langid_fix, + (usb_ctrl_charbuf)buf, buflen); } else { - ret = usb_get_string_simple(udev, command[i].index, buf, buflen); + ret = usb_get_string_simple(udev, + command[i].index, + (usb_ctrl_charbuf)buf, buflen); } if (ret <= 0) { - upsdebugx(3, "read: %s (%d)", ret ? usb_strerror() : "timeout", ret); + upsdebugx(3, "read: %s (%d)", + ret ? nut_usb_strerror(ret) : "timeout", ret); return ret; } @@ -744,7 +967,7 @@ static int krauler_command(const char *cmd, char *buf, size_t buflen) /* Simple unicode -> ASCII inplace conversion * FIXME: this code is at least shared with mge-shut/libshut * Create a common function? */ - unsigned int di, si, size = buf[0]; + unsigned int di, si, size = (unsigned int)buf[0]; for (di = 0, si = 2; si < size; si += 2) { if (di >= (buflen - 1)) @@ -757,8 +980,19 @@ static int krauler_command(const char *cmd, char *buf, size_t buflen) } + /* Note: effective range of di should be unsigned char */ buf[di] = 0; - ret = di; + ret = (int)di; + } + + /* If the reply lacks the expected terminating CR, add it (if there's enough space) */ + if (ret && memchr(buf, '\r', ret) == NULL) { + upsdebugx(4, "%s: the reply lacks the expected terminating CR.", __func__); + if ((size_t)ret < buflen - 1) { + upsdebugx(4, "%s: adding missing terminating CR.", __func__); + buf[ret++] = '\r'; + buf[ret] = 0; + } } /* "UPS No Ack" has a special meaning */ @@ -773,7 +1007,7 @@ static int krauler_command(const char *cmd, char *buf, size_t buflen) /* Replace the first byte of what we received with the correct one */ buf[0] = command[i].prefix; - upsdebug_hex(5, "read", buf, ret); + upsdebug_hex(5, "read", buf, (size_t)ret); upsdebugx(3, "read: %.*s", (int)strcspn(buf, "\r"), buf); return ret; @@ -801,12 +1035,19 @@ static int fabula_command(const char *cmd, char *buf, size_t buflen) { "I\r", 0x0c, }, /* Vendor infos */ { "Q\r", 0x07, }, /* Beeper toggle */ { "C\r", 0x0a, }, /* Cancel shutdown/Load on [0x(0..F)A]*/ - { NULL } + { NULL, 0 } }; int i, ret, index = 0; upsdebugx(3, "send: %.*s", (int)strcspn(cmd, "\r"), cmd); + if (buflen > INT_MAX) { + upsdebugx(3, "%s: requested to read too much (%zu), " + "reducing buflen to (INT_MAX-1)", + __func__, buflen); + buflen = (INT_MAX - 1); + } + for (i = 0; commands[i].str; i++) { if (strcmp(cmd, commands[i].str)) @@ -831,8 +1072,10 @@ static int fabula_command(const char *cmd, char *buf, size_t buflen) double delay; /* 0x(1+)0 -> shutdown.stayoff (SnR0000) - * 0x(1+)8 -> shutdown.return (Sn[Rm], m != 0) [delay before restart is always 10 seconds] - * +0x10 (16dec) = next megatec delay (min .5 = hex 0x1*; max 10 = hex 0xF*) -> n < 1 ? -> n += .1; n >= 1 ? -> n += 1 */ + * 0x(1+)8 -> shutdown.return (Sn[Rm], m != 0) + * [delay before restart is always 10 seconds] + * +0x10 (16dec) = next megatec delay + * (min .5 = hex 0x1*; max 10 = hex 0xF*) -> n < 1 ? -> n += .1; n >= 1 ? -> n += 1 */ /* delay: [.5..10] (-> seconds: [30..600]) */ delay = val1 < .5 ? .5 : val1 > 10 ? 10 : val1; @@ -860,22 +1103,204 @@ static int fabula_command(const char *cmd, char *buf, size_t buflen) upsdebugx(4, "command index: 0x%02x", index); /* Send command/Read reply */ - ret = usb_get_string_simple(udev, index, buf, buflen); + ret = usb_get_string_simple(udev, index, (usb_ctrl_charbuf)buf, buflen); if (ret <= 0) { - upsdebugx(3, "read: %s (%d)", ret ? usb_strerror() : "timeout", ret); + upsdebugx(3, "read: %s (%d)", + ret ? nut_usb_strerror(ret) : "timeout", ret); return ret; } - upsdebug_hex(5, "read", buf, ret); + /* If the reply lacks the expected terminating CR, add it (if there's enough space) */ + if (memchr(buf, '\r', ret) == NULL) { + upsdebugx(4, "%s: the reply lacks the expected terminating CR.", __func__); + if ((size_t)ret < buflen - 1) { + upsdebugx(4, "%s: adding missing terminating CR.", __func__); + buf[ret++] = '\r'; + buf[ret] = 0; + } + } + + upsdebug_hex(5, "read", buf, (size_t)ret); upsdebugx(3, "read: %.*s", (int)strcspn(buf, "\r"), buf); - /* The UPS always replies "UPS No Ack" when a supported command is issued (either if it fails or if it succeeds).. */ + /* The UPS always replies "UPS No Ack" when a supported command + * is issued (either if it fails or if it succeeds).. */ if ( strcspn(buf, "\r") == 10 && !strncasecmp(buf, "UPS No Ack", 10) ) { - /* ..because of that, always return 0 (with buf empty, as if it was a timeout): queries will see it as a failure, instant commands ('megatec' protocol) as a success */ + /* ..because of that, always return 0 (with buf empty, + * as if it was a timeout): queries will see it as a failure, + * instant commands ('megatec' protocol) as a success */ + memset(buf, 0, buflen); + return 0; + } + + return ret; +} + +/* Hunnox communication subdriver, based on Fabula code above so repeats + * much of it currently. Possible future optimization is to refactor shared + * code into new routines to be called from both (or more) methods.*/ +static int hunnox_command(const char *cmd, char *buf, size_t buflen) +{ + /* The hunnox_patch was an argument in initial implementation of PR #638 + * which added "hunnox" support; keeping it fixed here helps to visibly + * track the modifications compared to original fabula_command() e.g. to + * facilitate refactoring commented above, in the future. + */ +/* char hunnox_patch = 1; */ + const struct { + const char *str; /* Megatec command */ + const int index; /* Fabula string index for this command */ + } commands[] = { + { "Q1\r", 0x03, }, /* Status */ + { "F\r", 0x0d, }, /* Ratings */ + { "I\r", 0x0c, }, /* Vendor infos */ + { "Q\r", 0x07, }, /* Beeper toggle */ + { "C\r", 0x0a, }, /* Cancel shutdown/Load on [0x(0..F)A]*/ + { NULL, 0 } + }; + int i, ret, index = 0; + + upsdebugx(3, "send: %.*s", (int)strcspn(cmd, "\r"), cmd); + + if (buflen > INT_MAX) { + upsdebugx(3, "%s: requested to read too much (%zu), " + "reducing buflen to (INT_MAX-1)", + __func__, buflen); + buflen = (INT_MAX - 1); + } + + for (i = 0; commands[i].str; i++) { + + if (strcmp(cmd, commands[i].str)) + continue; + + index = commands[i].index; + break; + + } + + if (!index) { + + int val2 = -1; + double val1 = -1; + + /* Shutdowns */ + if ( + sscanf(cmd, "S%lfR%d\r", &val1, &val2) == 2 || + sscanf(cmd, "S%lf\r", &val1) == 1 + ) { + + double delay; + + /* 0x(1+)0 -> shutdown.stayoff (SnR0000) + * 0x(1+)8 -> shutdown.return (Sn[Rm], m != 0) + * [delay before restart is always 10 seconds] + * +0x10 (16dec) = next megatec delay + * (min .5 = hex 0x1*; max 10 = hex 0xF*) -> n < 1 ? -> n += .1; n >= 1 ? -> n += 1 */ + + /* delay: [.5..10] (-> seconds: [30..600]) */ + delay = val1 < .5 ? .5 : val1 > 10 ? 10 : val1; + + if (delay < 1) + index = 16 + round((delay - .5) * 10) * 16; + else + index = 96 + (delay - 1) * 16; + + /* shutdown.return (Sn[Rm], m != 0) */ + if (val2) + index += 8; + + /* Unknown commands */ + } else { + + /* Echo the unknown command back */ + upsdebugx(3, "read: %.*s", (int)strcspn(cmd, "\r"), cmd); + return snprintf(buf, buflen, "%s", cmd); + + } + + } + + upsdebugx(4, "command index: 0x%02x", index); + +/* if (hunnox_patch) { */ + /* Enable lock-step protocol for Hunnox */ + if (hunnox_protocol(index) != 0) { + return 0; + } + + /* Seems that if we inform a large buffer, the USB locks. + * This value was captured from the Windows "official" client. + * Note this should not be a problem programmatically: it just + * means that the caller reserved a longer buffer that we need + * in practice to write a response into. + */ + if (buflen > 102) { + buflen = 102; + } +/* } */ + + /* Send command/Read reply */ + if (langid_fix != -1) { + ret = usb_get_string(udev, + index, langid_fix, (usb_ctrl_charbuf)buf, buflen); + } else { + ret = usb_get_string_simple(udev, + index, (usb_ctrl_charbuf)buf, buflen); + } + + if (ret <= 0) { + upsdebugx(3, "read: %s (%d)", + ret ? nut_usb_strerror(ret) : "timeout", + ret); + return ret; + } + +/* if (hunnox_patch) { */ + if (langid_fix != -1) { + /* Limit this check, at least for now */ + /* Invalid receive size - message corrupted */ + if (ret != buf[0]) { + upsdebugx(1, "size mismatch: %d / %d", ret, buf[0]); + return 0; + } + + /* Simple unicode -> ASCII inplace conversion + * FIXME: this code is at least shared with mge-shut/libshut + * Create a common function? */ + unsigned int di, si, size = (unsigned int)buf[0]; + for (di = 0, si = 2; si < size; si += 2) { + if (di >= (buflen - 1)) + break; + + if (buf[si + 1]) /* high byte */ + buf[di++] = '?'; + else + buf[di++] = buf[si]; + } + + /* Note: effective range of di should be unsigned char */ + buf[di] = 0; + ret = (int)di; + } +/* } */ + + upsdebug_hex(5, "read", buf, (size_t)ret); + upsdebugx(3, "read: %.*s", (int)strcspn(buf, "\r"), buf); + + /* The UPS always replies "UPS No Ack" when a supported command + * is issued (either if it fails or if it succeeds).. */ + if ( + strcspn(buf, "\r") == 10 && + !strncasecmp(buf, "UPS No Ack", 10) + ) { + /* ..because of that, always return 0 (with buf empty, + * as if it was a timeout): queries will see it as a failure, + * instant commands ('megatec' protocol) as a success */ memset(buf, 0, buflen); return 0; } @@ -889,21 +1314,31 @@ static int fuji_command(const char *cmd, char *buf, size_t buflen) unsigned char tmp[8]; char command[SMALLBUF] = "", read[SMALLBUF] = ""; - int ret, answer_len, val2; + int ret, val2; + unsigned char answer_len; double val1; size_t i; const struct { const char *command; /* Megatec command */ - const int answer_len; /* Expected length of the answer to the ongoing query */ + const unsigned char answer_len; /* Expected length of the answer + * to the ongoing query */ } query[] = { { "Q1", 47 }, { "F", 22 }, { "I", 39 }, - { NULL } + { NULL, 0 } }; + if (buflen > INT_MAX) { + upsdebugx(3, "%s: requested to read too much (%zu), " + "reducing buflen to (INT_MAX-1)", + __func__, buflen); + buflen = (INT_MAX - 1); + } + /* - * Queries (b1..b8) sent (as a 8-bytes interrupt) to the UPS adopt the following scheme: + * Queries (b1..b8) sent (as a 8-bytes interrupt) to the UPS + * adopt the following scheme: * * b1: 0x80 * b2: 0x06 @@ -917,9 +1352,12 @@ static int fuji_command(const char *cmd, char *buf, size_t buflen) * Length (in Hex) of the command (without the trailing CR) + 1 * Command/query (without the trailing CR) * [] 0x00 padding to the 7th byte - * Expected length (in Hex) of the answer to the ongoing query (0 when no reply is expected, i.e. commands) + * Expected length (in Hex) of the answer to the ongoing + * query (0 when no reply is expected, i.e. commands) * - * Replies to queries (commands are followed by action without any reply) are sent from the UPS (in 8-byte chunks) with 0x00 padding after the trailing CR to full 8 bytes. + * Replies to queries (commands are followed by action without + * any reply) are sent from the UPS (in 8-byte chunks) with + * 0x00 padding after the trailing CR to full 8 bytes. * */ @@ -928,9 +1366,13 @@ static int fuji_command(const char *cmd, char *buf, size_t buflen) /* Remove the CR */ snprintf(command, sizeof(command), "%.*s", (int)strcspn(cmd, "\r"), cmd); - /* Length of the command that will be sent to the UPS can be at most: 8 - 5 (0x80, 0x06, , 0x03, ) = 3. - * As a consequence also 'SnRm' commands (shutdown.{return,stayoff} and load.off) are not supported. - * So, map all the 'SnRm' shutdown.returns (m != 0) as the corresponding 'Sn' commands, meanwhile ignoring ups.delay.start and making the UPS turn on the load as soon as power is back. */ + /* Length of the command that will be sent to the UPS can be + * at most: 8 - 5 (0x80, 0x06, , 0x03, ) = 3. + * As a consequence also 'SnRm' commands (shutdown.{return,stayoff} + * and load.off) are not supported. + * So, map all the 'SnRm' shutdown.returns (m != 0) as the + * corresponding 'Sn' commands, meanwhile ignoring ups.delay.start + * and making the UPS turn on the load as soon as power is back. */ if (sscanf(cmd, "S%lfR%d\r", &val1, &val2) == 2 && val2) { upsdebugx(4, "%s: trimming '%s' to '%.*s'", __func__, command, 3, command); command[3] = 0; @@ -942,7 +1384,8 @@ static int fuji_command(const char *cmd, char *buf, size_t buflen) return snprintf(buf, buflen, "%s", cmd); } - /* Expected length of the answer to the ongoing query (0 when no reply is expected, i.e. commands) */ + /* Expected length of the answer to the ongoing query + * (0 when no reply is expected, i.e. commands) */ answer_len = 0; for (i = 0; query[i].command; i++) { @@ -960,8 +1403,8 @@ static int fuji_command(const char *cmd, char *buf, size_t buflen) tmp[0] = 0x80; /* 0x06 */ tmp[1] = 0x06; - /* */ - tmp[2] = strlen(command) + 1; + /* ; per above under 3 */ + tmp[2] = (unsigned char)strlen(command) + 1; /* 0x03 */ tmp[3] = 0x03; /* */ @@ -972,10 +1415,14 @@ static int fuji_command(const char *cmd, char *buf, size_t buflen) upsdebug_hex(4, "command", (char *)tmp, 8); /* Write data */ - ret = usb_interrupt_write(udev, USB_ENDPOINT_OUT | 2, (char *)tmp, 8, USB_TIMEOUT); + ret = usb_interrupt_write(udev, + USB_ENDPOINT_OUT | 2, + (const usb_ctrl_charbuf)tmp, + 8, USB_TIMEOUT); if (ret <= 0) { - upsdebugx(3, "send: %s (%d)", ret ? usb_strerror() : "timeout", ret); + upsdebugx(3, "send: %s (%d)", + ret ? nut_usb_strerror(ret) : "timeout", ret); return ret; } @@ -985,19 +1432,24 @@ static int fuji_command(const char *cmd, char *buf, size_t buflen) memset(buf, 0, buflen); - for (i = 0; (i <= buflen - 8) && (memchr(buf, '\r', buflen) == NULL); i += ret) { + for (i = 0; (i <= buflen - 8) && (memchr(buf, '\r', buflen) == NULL); i += (size_t)ret) { /* Read data in 8-byte chunks */ - ret = usb_interrupt_read(udev, USB_ENDPOINT_IN | 1, &buf[i], 8, 1000); + ret = usb_interrupt_read(udev, + USB_ENDPOINT_IN | 1, + (usb_ctrl_charbuf)&buf[i], 8, 1000); - /* Any errors here mean that we are unable to read a reply (which will happen after successfully writing a command to the UPS) */ + /* Any errors here mean that we are unable to read a reply + * (which will happen after successfully writing a command + * to the UPS) */ if (ret <= 0) { - upsdebugx(3, "read: %s (%d)", ret ? usb_strerror() : "timeout", ret); + upsdebugx(3, "read: %s (%d)", + ret ? nut_usb_strerror(ret) : "timeout", ret); return ret; } snprintf(read, sizeof(read), "read [%3d]", (int)i); - upsdebug_hex(5, read, &buf[i], ret); + upsdebug_hex(5, read, &buf[i], (size_t)ret); } @@ -1007,48 +1459,503 @@ static int fuji_command(const char *cmd, char *buf, size_t buflen) return (int)strlen(buf); } +/* Phoenixtec (Masterguard) communication subdriver */ +static int phoenixtec_command(const char *cmd, char *buf, size_t buflen) +{ + int ret; + char *p, *e = NULL; + char *l[] = { "T", "TL", "S", "C", "CT", "M", "N", "O", "SRC", "FCLR", "SS", "TUD", "SSN", NULL }; /* commands that don't return an answer */ + char **lp; + size_t cmdlen = strlen(cmd); + + if (cmdlen > INT_MAX) { + upsdebugx(3, "%s: requested command is too long (%zu)", + __func__, cmdlen); + return 0; + } + + if (buflen > INT_MAX) { + upsdebugx(3, "%s: requested to read too much (%zu), " + "reducing buflen to (INT_MAX-1)", + __func__, buflen); + buflen = (INT_MAX - 1); + } + + if ((ret = usb_control_msg(udev, + USB_ENDPOINT_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT, + 0x0d, 0, 0, (usb_ctrl_charbuf)cmd, (int)cmdlen, 1000)) <= 0 + ) { + upsdebugx(3, "send: %s (%d)", + ret ? nut_usb_strerror(ret) : "timeout", + ret); + *buf = '\0'; + return ret; + } + + for (lp = l; *lp != NULL; lp++) { + const char *q; + int b; + + p = *lp; q = cmd; b = 1; + while (*p != '\0') { + if (*p++ != *q++) { + b = 0; + break; + } + } + if (b && *q >= 'A' && *q <= 'Z') b = 0; /* "M" not to match "MSO" */ + if (b) { + upsdebugx(4, "command %s returns no answer", *lp); + *buf = '\0'; + return 0; + } + } + + for (p = buf; p < buf + buflen; p += ret) { + /* buflen constrained to INT_MAX above, so we can cast: */ + if ((ret = usb_interrupt_read(udev, + USB_ENDPOINT_IN | 1, + (usb_ctrl_charbuf)p, (int)(buf + buflen - p), 1000)) <= 0 + ) { + upsdebugx(3, "read: %s (%d)", + ret ? nut_usb_strerror(ret) : "timeout", + ret); + *buf = '\0'; + return ret; + } + if ((e = memchr(p, '\r', (size_t)ret)) != NULL) break; + } + if (e != NULL && ++e < buf + buflen) { + *e = '\0'; + /* buflen constrained to INT_MAX above, so we can cast: */ + return (int)(e - buf); + } else { + upsdebugx(3, "read: buflen %zu too small", buflen); + *buf = '\0'; + return 0; + } +} + +/* SNR communication subdriver */ +static int snr_command(const char *cmd, char *buf, size_t buflen) +{ + /*ATTENTION: This subdriver uses short buffer with length 102 byte*/ + const struct { + const char *str; /* Megatec command */ + const int index; /* String index for this command */ + const char prefix; /* Character to replace the first byte in reply */ + } command[] = { + { "Q1\r", 0x03, '(' }, + { "F\r", 0x0d, '#' }, + { "I\r", 0x0c, '#' }, + { NULL, 0, '\0' } + }; + + int i; + + upsdebugx(3, "send: %.*s", (int)strcspn(cmd, "\r"), cmd); + + if (buflen > INT_MAX) { + upsdebugx(3, "%s: requested to read too much (%zu), " + "reducing buflen to (INT_MAX-1)", + __func__, buflen); + buflen = (INT_MAX - 1); + } + + if (buflen < 102) { + upsdebugx(4, "size of buf less than 102 byte!"); + return 0; + } + + /* Prepare SNR-UPS for communication. + * Without the interrupt UPS returns zeros for some time, + * and afterwards NUT returns a communications error. + */ + usb_interrupt_read(udev, + 0x81, + (usb_ctrl_charbuf)buf, 102, 1000); + + for (i = 0; command[i].str; i++) { + + int retry; + + if (strcmp(cmd, command[i].str)) { + continue; + } + + for (retry = 0; retry < 10; retry++) { + + int ret; + + ret = usb_get_string(udev, + command[i].index, langid_fix, + (usb_ctrl_charbuf)buf, 102); + + if (ret <= 0) { + upsdebugx(3, "read: %s (%d)", + ret ? nut_usb_strerror(ret) : "timeout", + ret); + return ret; + } + + /* This may serve in the future */ + upsdebugx(1, "received %d (%d)", ret, buf[0]); + + + if (ret != buf[0]) { + upsdebugx(1, "size mismatch: %d / %d", ret, buf[0]); + continue; + } + + /* Simple unicode -> ASCII inplace conversion + * FIXME: this code is at least shared with mge-shut/libshut + * Create a common function? */ + unsigned int di, si, size = (unsigned int)buf[0]; + for (di = 0, si = 2; si < size; si += 2) { + + if (di >= (buflen - 1)) + break; + + if (buf[si + 1]) /* high byte */ + buf[di++] = '?'; + else + buf[di++] = buf[si]; + + } + + /* Note: effective range of di should be unsigned char */ + buf[di] = 0; + ret = (int)di; + + /* "UPS No Ack" has a special meaning */ + if ( + strcspn(buf, "\r") == 10 && + !strncasecmp(buf, "UPS No Ack", 10) + ) { + upsdebugx(3, "read: %.*s", (int)strcspn(buf, "\r"), buf); + continue; + } + + /* Replace the first byte of what we received with the correct one */ + buf[0] = command[i].prefix; + + upsdebug_hex(5, "read", buf, (size_t)ret); + upsdebugx(3, "read: %.*s", (int)strcspn(buf, "\r"), buf); + + return ret; + + } + + return 0; + + } + + /* Echo the unknown command back */ + upsdebugx(3, "read: %.*s", (int)strcspn(cmd, "\r"), cmd); + return snprintf(buf, buflen, "%s", cmd); +} + +static int ablerex_command(const char *cmd, char *buf, size_t buflen) +{ + int iii; + int len; + int idx; + char tmp[64]; + char tmpryy[64]; + + upsdebugx(3, "send: %.*s", (int)strcspn(cmd, "\r"), cmd); + + if (buflen > INT_MAX) { + upsdebugx(3, "%s: requested to read too much (%zu), reducing buflen to (INT_MAX-1)", + __func__, buflen); + buflen = (INT_MAX - 1); + } + + int retry; + + for (retry = 0; retry < 3; retry++) { + int ret; + + memset(buf, 0, buflen); + tmp[0] = 0x05; + tmp[1] = 0; + tmp[2] = 1 + (char)strcspn(cmd, "\r"); + + for (iii = 0 ; iii < tmp[2] ; iii++) + { + tmp[3+iii] = cmd[iii]; + } + + ret = usb_control_msg(udev, + 0x21, + 0x09, 0x305, 0, + (usb_ctrl_charbuf)tmp, 47, 1000); + + upsdebugx(3, "R11 read: %s", ret ? nut_usb_strerror(ret) : "timeout"); + + usleep(500000); + tmpryy[0] = 0x05; + ret = usb_control_msg(udev, + 0xA1, + 0x01, 0x305, 0, + (usb_ctrl_charbuf)tmpryy, 47, 1000); + upsdebugx(3, "R2 read%d: %.*s", ret, ret, tmpryy); + + len = 0; + for (idx = 0 ; idx < 47 ; idx++) + { + buf[idx] = tmpryy[idx]; + if (tmpryy[idx] == '\r') + { + len = idx; + break; + } + } + upsdebugx(3, "R3 read%d: %.*s", len, len, tmpryy); + + if (len > 0) { + len ++; + } + if (ret <= 0) { + upsdebugx(3, "read: %s", ret ? nut_usb_strerror(ret) : "timeout"); + return ret; + } + + upsdebugx(1, "received %d (%d)", ret, buf[0]); + + if ((!strcasecmp(cmd, "Q1\r")) && len != 47) continue; + if ((!strcasecmp(cmd, "I\r")) && len != 39) continue; + if ((!strcasecmp(cmd, "F\r")) && len != 22) continue; + if ((!strcasecmp(cmd, "Q5\r")) && len != 22) + { + buf[0] = '('; + for (idx = 1 ; idx < 47 ; idx++) + { + buf[idx] = 0; + } + upsdebugx(3, "read Q5 Fail..."); + return 22; + } + + upsdebugx(3, "read: %.*s", (int)strcspn(buf, "\r"), buf); + return len; + } + + return 0; +} + +static void *ablerex_subdriver_fun(USBDevice_t *device) +{ + NUT_UNUSED_VARIABLE(device); + + subdriver_command = &ablerex_command; + return NULL; +} + +/* Armac communication subdriver + * + * This reproduces a communication protocol used by an old PowerManagerII + * software, which doesn't seem to be Armac specific. The banner is: "2004 + * Richcomm Technologies, Inc. Dec 27 2005 ver 1.1." Maybe other Richcomm UPSes + * would work with this - better than with the richcomm_usb driver. + */ +static int armac_command(const char *cmd, char *buf, size_t buflen) +{ + char tmpbuf[6]; + int ret = 0; + size_t i, bufpos; + const size_t cmdlen = strlen(cmd); + + /* UPS ignores (doesn't echo back) unsupported commands which makes + * the initialization long. List commands tested to be unsupported: + */ + const char *unsupported[] = { + "QGS\r", + "QS\r", + "QPI\r", + "M\r", + "D\r", + NULL + }; + + for (i = 0; unsupported[i] != NULL; i++) { + if (strcmp(cmd, unsupported[i]) == 0) { + upsdebugx(2, + "armac: unsupported cmd: %.*s", + (int)strcspn(cmd, "\r"), cmd); + return snprintf(buf, buflen, "%s", cmd); + } + } + upsdebugx(4, "armac command %.*s", (int)strcspn(cmd, "\r"), cmd); + + /* Send command to the UPS in 3-byte chunks. Most fit 1 chunk, except for eg. + * parameterized tests. */ + for (i = 0; i < cmdlen;) { + const size_t bytes_to_send = (cmdlen <= (i + 3)) ? (cmdlen - i) : 3; + memset(tmpbuf, 0, sizeof(tmpbuf)); + tmpbuf[0] = 0xa0 + bytes_to_send; + memcpy(tmpbuf + 1, cmd + i, bytes_to_send); + ret = usb_control_msg(udev, + USB_ENDPOINT_OUT + USB_TYPE_CLASS + USB_RECIP_INTERFACE, + 0x09, 0x200, 0, + (usb_ctrl_charbuf)tmpbuf, 4, 5000); + i += bytes_to_send; + } + + if (ret <= 0) { + upsdebugx(1, + "send control: %s (%d)", + ret ? nut_usb_strerror(ret) : "timeout", + ret); + return ret; + } + + memset(buf, 0, buflen); + + bufpos = 0; + while (bufpos + 6 < buflen) { + size_t bytes_available; + + /* Read data in 6-byte chunks */ + ret = usb_interrupt_read(udev, + 0x81, + (usb_ctrl_charbuf)tmpbuf, 6, 1000); + + /* Any errors here mean that we are unable to read a reply + * (which will happen after successfully writing a command + * to the UPS) */ + if (ret != 6) { + upsdebugx(1, + "interrupt read error: %s (%d)", + ret ? nut_usb_strerror(ret) : "timeout", + ret); + return ret; + } + + upsdebugx(4, + "read: ret %d buf %02hhx: %02hhx %02hhx %02hhx %02hhx %02hhx >%c%c%c%c%c<", + ret, + tmpbuf[0], tmpbuf[1], tmpbuf[2], tmpbuf[3], tmpbuf[4], tmpbuf[5], + tmpbuf[1], tmpbuf[2], tmpbuf[3], tmpbuf[4], tmpbuf[5]); + + bytes_available = (unsigned char)tmpbuf[0] & 0x0f; + if (bytes_available == 0) { + /* End of transfer */ + break; + } + + memcpy(buf + bufpos, tmpbuf + 1, bytes_available); + bufpos += bytes_available; + + if (bytes_available <= 2) { + /* Slow down, let the UPS buffer more bytes */ + usleep(15000); + } + } + + if (bufpos + 6 >= buflen) { + upsdebugx(2, "Protocol error, too much data read."); + return -1; + } + + upsdebugx(3, "armac command %.*s response read: '%.*s'", + (int)strcspn(cmd, "\r"), cmd, + (int)strcspn(buf, "\r"), buf + ); + + return (int)bufpos; +} + + static void *cypress_subdriver(USBDevice_t *device) { + NUT_UNUSED_VARIABLE(device); + subdriver_command = &cypress_command; return NULL; } static void *sgs_subdriver(USBDevice_t *device) { + NUT_UNUSED_VARIABLE(device); + subdriver_command = &sgs_command; return NULL; } static void *ippon_subdriver(USBDevice_t *device) { + NUT_UNUSED_VARIABLE(device); + subdriver_command = &ippon_command; return NULL; } static void *krauler_subdriver(USBDevice_t *device) { + NUT_UNUSED_VARIABLE(device); + subdriver_command = &krauler_command; return NULL; } static void *phoenix_subdriver(USBDevice_t *device) { + NUT_UNUSED_VARIABLE(device); + subdriver_command = &phoenix_command; return NULL; } static void *fabula_subdriver(USBDevice_t *device) { + NUT_UNUSED_VARIABLE(device); + subdriver_command = &fabula_command; return NULL; } +static void *phoenixtec_subdriver(USBDevice_t *device) +{ + NUT_UNUSED_VARIABLE(device); + + subdriver_command = &phoenixtec_command; + return NULL; +} + +/* Note: the "hunnox_subdriver" name is taken by the subdriver_t structure */ +static void *fabula_hunnox_subdriver(USBDevice_t *device) +{ + NUT_UNUSED_VARIABLE(device); + + subdriver_command = &hunnox_command; + return NULL; +} + static void *fuji_subdriver(USBDevice_t *device) { + NUT_UNUSED_VARIABLE(device); + subdriver_command = &fuji_command; return NULL; } +static void *snr_subdriver(USBDevice_t *device) +{ + NUT_UNUSED_VARIABLE(device); + + subdriver_command = &snr_command; + return NULL; +} + +static void *armac_subdriver(USBDevice_t *device) +{ + NUT_UNUSED_VARIABLE(device); + + subdriver_command = &armac_command; + return NULL; +} + /* USB device match structure */ typedef struct { const int vendorID; /* USB device's VendorID */ @@ -1061,8 +1968,10 @@ typedef struct { /* USB VendorID/ProductID/iManufacturer/iProduct match - note: rightmost comment is used for naming rules by tools/nut-usbinfo.pl */ static qx_usb_device_id_t qx_usb_id[] = { { USB_DEVICE(0x05b8, 0x0000), NULL, NULL, &cypress_subdriver }, /* Agiler UPS */ - { USB_DEVICE(0xffff, 0x0000), NULL, NULL, &krauler_subdriver }, /* Ablerex 625L USB */ + { USB_DEVICE(0xffff, 0x0000), NULL, NULL, &ablerex_subdriver_fun }, /* Ablerex 625L USB (Note: earlier best-fit was "krauler_subdriver" before PR #1135) */ + { USB_DEVICE(0x1cb0, 0x0035), NULL, NULL, &krauler_subdriver }, /* Legrand Daker DK / DK Plus */ { USB_DEVICE(0x0665, 0x5161), NULL, NULL, &cypress_subdriver }, /* Belkin F6C1200-UNV/Voltronic Power UPSes */ + { USB_DEVICE(0x06da, 0x0002), "Phoenixtec Power","USB Cable (V2.00)", &phoenixtec_subdriver },/* Masterguard A Series */ { USB_DEVICE(0x06da, 0x0002), NULL, NULL, &cypress_subdriver }, /* Online Yunto YQ450 */ { USB_DEVICE(0x06da, 0x0003), NULL, NULL, &ippon_subdriver }, /* Mustek Powermust */ { USB_DEVICE(0x06da, 0x0004), NULL, NULL, &cypress_subdriver }, /* Phoenixtec Innova 3/1 T */ @@ -1071,10 +1980,13 @@ static qx_usb_device_id_t qx_usb_id[] = { { USB_DEVICE(0x06da, 0x0601), NULL, NULL, &phoenix_subdriver }, /* Online Zinto A */ { USB_DEVICE(0x0f03, 0x0001), NULL, NULL, &cypress_subdriver }, /* Unitek Alpha 1200Sx */ { USB_DEVICE(0x14f0, 0x00c9), NULL, NULL, &phoenix_subdriver }, /* GE EP series */ - { USB_DEVICE(0x0483, 0x0035), NULL, NULL, &sgs_subdriver }, /* TS Shara UPSes */ + { USB_DEVICE(0x0483, 0x0035), NULL, NULL, &sgs_subdriver }, /* TS Shara UPSes; vendor ID 0x0483 is from ST Microelectronics - with product IDs delegated to different OEMs */ { USB_DEVICE(0x0001, 0x0000), "MEC", "MEC0003", &fabula_subdriver }, /* Fideltronik/MEC LUPUS 500 USB */ + { USB_DEVICE(0x0001, 0x0000), NULL, "MEC0003", &fabula_hunnox_subdriver }, /* Hunnox HNX 850, reported to also help support Powercool and some other devices; closely related to fabula with tweaks */ { USB_DEVICE(0x0001, 0x0000), "ATCL FOR UPS", "ATCL FOR UPS", &fuji_subdriver }, /* Fuji UPSes */ { USB_DEVICE(0x0001, 0x0000), NULL, NULL, &krauler_subdriver }, /* Krauler UP-M500VA */ + { USB_DEVICE(0x0001, 0x0000), NULL, "MEC0003", &snr_subdriver }, /* SNR-UPS-LID-XXXX UPSes */ + { USB_DEVICE(0x0925, 0x1234), NULL, NULL, &armac_subdriver }, /* Armac UPS and maybe other richcomm-like or using old PowerManagerII software */ /* End of list */ { -1, -1, NULL, NULL, NULL } }; @@ -1095,11 +2007,17 @@ static int qx_is_usb_device_supported(qx_usb_device_id_t *usb_device_id_list, US if (usbdev->productID != device->ProductID) continue; - if (usbdev->vendor && (!device->Vendor || strcasecmp(usbdev->vendor, device->Vendor))) + if (usbdev->vendor + && (!device->Vendor || strcasecmp(usbdev->vendor, device->Vendor)) + ) { continue; + } - if (usbdev->product && (!device->Product || strcasecmp(usbdev->product, device->Product))) + if (usbdev->product + && (!device->Product || strcasecmp(usbdev->product, device->Product)) + ) { continue; + } /* Call the specific handler, if it exists */ if (usbdev->fun != NULL) @@ -1114,6 +2032,8 @@ static int qx_is_usb_device_supported(qx_usb_device_id_t *usb_device_id_list, US static int device_match_func(USBDevice_t *hd, void *privdata) { + NUT_UNUSED_VARIABLE(privdata); + if (subdriver_command) { return 1; } @@ -1148,17 +2068,21 @@ int instcmd(const char *cmdname, const char *extradata) if (!strcasecmp(cmdname, "beeper.off")) { /* Compatibility mode for old command */ - upslogx(LOG_WARNING, "The 'beeper.off' command has been renamed to 'beeper.disable'"); + upslogx(LOG_WARNING, + "The 'beeper.off' command has been renamed to 'beeper.disable'"); return instcmd("beeper.disable", NULL); } if (!strcasecmp(cmdname, "beeper.on")) { /* Compatibility mode for old command */ - upslogx(LOG_WARNING, "The 'beeper.on' command has been renamed to 'beeper.enable'"); + upslogx(LOG_WARNING, + "The 'beeper.on' command has been renamed to 'beeper.enable'"); return instcmd("beeper.enable", NULL); } - upslogx(LOG_INFO, "%s(%s, %s)", __func__, cmdname, extradata ? extradata : "[NULL]"); + upslogx(LOG_INFO, "%s(%s, %s)", + __func__, cmdname, + extradata ? extradata : "[NULL]"); /* Retrieve item by command name */ item = find_nut_info(cmdname, QX_FLAG_CMD, QX_FLAG_SKIP); @@ -1191,7 +2115,8 @@ int instcmd(const char *cmdname, const char *extradata) return ret; } - return instcmd("load.off.delay", dstate_getinfo("ups.delay.shutdown")); + return instcmd("load.off.delay", + dstate_getinfo("ups.delay.shutdown")); } @@ -1212,7 +2137,8 @@ int instcmd(const char *cmdname, const char *extradata) return ret; } - return instcmd("load.off.delay", dstate_getinfo("ups.delay.shutdown")); + return instcmd("load.off.delay", + dstate_getinfo("ups.delay.shutdown")); } @@ -1220,12 +2146,15 @@ int instcmd(const char *cmdname, const char *extradata) return STAT_INSTCMD_INVALID; } - /* If extradata is empty, use the default value from the QX to NUT table, if any */ + /* If extradata is empty, use the default value + * from the QX to NUT table, if any */ extradata = extradata ? extradata : item->dfl; snprintf(value, sizeof(value), "%s", extradata ? extradata : ""); /* Preprocess command */ - if (item->preprocess != NULL && item->preprocess(item, value, sizeof(value))) { + if (item->preprocess != NULL + && item->preprocess(item, value, sizeof(value)) + ) { /* Something went wrong */ upslogx(LOG_ERR, "%s: FAILED", __func__); return STAT_INSTCMD_FAILED; @@ -1242,10 +2171,15 @@ int instcmd(const char *cmdname, const char *extradata) return STAT_INSTCMD_FAILED; } - /* We got a reply from the UPS: either subdriver->accepted (-> command handled) or the command itself echoed back (-> command failed) */ + /* We got a reply from the UPS: + * either subdriver->accepted (-> command handled) + * or the command itself echoed back (-> command failed) + */ if (strlen(item->value) > 0) { - if (subdriver->accepted != NULL && !strcasecmp(item->value, subdriver->accepted)) { + if (subdriver->accepted != NULL + && !strcasecmp(item->value, subdriver->accepted) + ) { upslogx(LOG_INFO, "%s: SUCCEED", __func__); /* Set the status so that SEMI_STATIC vars are polled */ data_has_changed = TRUE; @@ -1280,30 +2214,37 @@ int setvar(const char *varname, const char *val) return STAT_SET_UNKNOWN; } - /* No NUT variable is available for this item, so we're handling a one-time setvar from ups.conf */ + /* No NUT variable is available for this item, so we're handling + * a one-time setvar from ups.conf */ if (item->qxflags & QX_FLAG_NONUT) { const char *userval; /* Nothing to do */ if (!testvar(item->info_type)) { - upsdebugx(2, "%s: nothing to do.. [%s]", __func__, item->info_type); + upsdebugx(2, "%s: nothing to do... [%s]", + __func__, item->info_type); return STAT_SET_HANDLED; } userval = getval(item->info_type); - upslogx(LOG_INFO, "%s(%s, %s)", __func__, varname, userval ? userval : "[NULL]"); + upslogx(LOG_INFO, "%s(%s, %s)", + __func__, varname, + userval ? userval : "[NULL]"); snprintf(value, sizeof(value), "%s", userval ? userval : ""); /* This item is available in NUT */ } else { - upslogx(LOG_INFO, "%s(%s, %s)", __func__, varname, strlen(val) ? val : "[NULL]"); + upslogx(LOG_INFO, "%s(%s, %s)", + __func__, varname, + strlen(val) ? val : "[NULL]"); if (!strlen(val)) { - upslogx(LOG_ERR, "%s: value not given for %s", __func__, item->info_type); + upslogx(LOG_ERR, "%s: value not given for %s", + __func__, item->info_type); return STAT_SET_UNKNOWN; /* TODO: HANDLED but FAILED, not UNKNOWN! */ } @@ -1311,7 +2252,8 @@ int setvar(const char *varname, const char *val) /* Nothing to do */ if (!strcasecmp(dstate_getinfo(item->info_type), value)) { - upslogx(LOG_INFO, "%s: nothing to do.. [%s]", __func__, item->info_type); + upslogx(LOG_INFO, "%s: nothing to do... [%s]", + __func__, item->info_type); return STAT_SET_HANDLED; } @@ -1320,22 +2262,25 @@ int setvar(const char *varname, const char *val) /* Check if given value is in the range of accepted values (range) */ if (item->qxflags & QX_FLAG_RANGE) { - int valuetoset, min, max; + long valuetoset, min, max; if (strspn(value, "0123456789 .") != strlen(value)) { - upslogx(LOG_ERR, "%s: non numerical value [%s: %s]", __func__, item->info_type, value); + upslogx(LOG_ERR, "%s: non numerical value [%s: %s]", + __func__, item->info_type, value); return STAT_SET_UNKNOWN; /* TODO: HANDLED but FAILED, not UNKNOWN! */ } valuetoset = strtol(value, NULL, 10); - /* No NUT var is available for this item, so take its range from qx2nut table */ + /* No NUT var is available for this item, so + * take its range from qx2nut table */ if (item->qxflags & QX_FLAG_NONUT) { info_rw_t *rvalue; if (!strlen(value)) { - upslogx(LOG_ERR, "%s: value not given for %s", __func__, item->info_type); + upslogx(LOG_ERR, "%s: value not given for %s", + __func__, item->info_type); return STAT_SET_UNKNOWN; /* TODO: HANDLED but FAILED, not UNKNOWN! */ } @@ -1344,8 +2289,11 @@ int setvar(const char *varname, const char *val) /* Loop on all existing values */ for (rvalue = item->info_rw; rvalue != NULL && strlen(rvalue->value) > 0; rvalue++) { - if (rvalue->preprocess && rvalue->preprocess(rvalue->value, sizeof(rvalue->value))) + if (rvalue->preprocess + && rvalue->preprocess(rvalue->value, sizeof(rvalue->value)) + ) { continue; + } if (min < 0) { min = strtol(rvalue->value, NULL, 10); @@ -1365,14 +2313,16 @@ int setvar(const char *varname, const char *val) } - /* We have a NUT var for this item, so check given value against the already set range */ + /* We have a NUT var for this item, so check given value + * against the already set range */ } else { const range_t *range = state_getrangelist(root, item->info_type); /* Unable to find tree node for var */ if (!range) { - upsdebugx(2, "%s: unable to find tree node for %s", __func__, item->info_type); + upsdebugx(2, "%s: unable to find tree node for %s", + __func__, item->info_type); return STAT_SET_UNKNOWN; } @@ -1392,28 +2342,34 @@ int setvar(const char *varname, const char *val) } if (!ok) { - upslogx(LOG_ERR, "%s: value out of range [%s: %s]", __func__, item->info_type, value); + upslogx(LOG_ERR, "%s: value out of range [%s: %s]", + __func__, item->info_type, value); return STAT_SET_UNKNOWN; /* TODO: HANDLED but FAILED, not UNKNOWN! */ } /* Check if given value is in the range of accepted values (enum) */ } else if (item->qxflags & QX_FLAG_ENUM) { - /* No NUT var is available for this item, so take its range from qx2nut table */ + /* No NUT var is available for this item, so + * take its range from qx2nut table */ if (item->qxflags & QX_FLAG_NONUT) { info_rw_t *envalue; if (!strlen(value)) { - upslogx(LOG_ERR, "%s: value not given for %s", __func__, item->info_type); + upslogx(LOG_ERR, "%s: value not given for %s", + __func__, item->info_type); return STAT_SET_UNKNOWN; /* TODO: HANDLED but FAILED, not UNKNOWN! */ } /* Loop on all existing values */ for (envalue = item->info_rw; envalue != NULL && strlen(envalue->value) > 0; envalue++) { - if (envalue->preprocess && envalue->preprocess(envalue->value, sizeof(envalue->value))) + if (envalue->preprocess + && envalue->preprocess(envalue->value, sizeof(envalue->value)) + ) { continue; + } if (strcasecmp(envalue->value, value)) continue; @@ -1424,14 +2380,16 @@ int setvar(const char *varname, const char *val) } - /* We have a NUT var for this item, so check given value against the already set range */ + /* We have a NUT var for this item, so check given value + * against the already set range */ } else { const enum_t *enumlist = state_getenumlist(root, item->info_type); /* Unable to find tree node for var */ if (!enumlist) { - upsdebugx(2, "%s: unable to find tree node for %s", __func__, item->info_type); + upsdebugx(2, "%s: unable to find tree node for %s", + __func__, item->info_type); return STAT_SET_UNKNOWN; } @@ -1451,30 +2409,39 @@ int setvar(const char *varname, const char *val) } if (!ok) { - upslogx(LOG_ERR, "%s: value out of range [%s: %s]", __func__, item->info_type, value); + upslogx(LOG_ERR, "%s: value out of range [%s: %s]", + __func__, item->info_type, value); return STAT_SET_UNKNOWN; /* TODO: HANDLED but FAILED, not UNKNOWN! */ } /* Check if given value is not too long (string) */ } else if (item->info_flags & ST_FLAG_STRING) { - const int aux = state_getaux(root, item->info_type); + const long aux = state_getaux(root, item->info_type); /* Unable to find tree node for var */ if (aux < 0) { - upsdebugx(2, "%s: unable to find tree node for %s", __func__, item->info_type); + upsdebugx(2, "%s: unable to find tree node for %s", + __func__, item->info_type); return STAT_SET_UNKNOWN; } + /* FIXME? Should this cast to "long"? + * An int-size string is quite a lot already, + * even on architectures with a moderate INTMAX + */ if (aux < (int)strlen(value)) { - upslogx(LOG_ERR, "%s: value is too long [%s: %s]", __func__, item->info_type, value); + upslogx(LOG_ERR, "%s: value is too long [%s: %s]", + __func__, item->info_type, value); return STAT_SET_UNKNOWN; /* TODO: HANDLED but FAILED, not UNKNOWN! */ } } /* Preprocess value: from NUT-compliant to UPS-compliant */ - if (item->preprocess != NULL && item->preprocess(item, value, sizeof(value))) { + if (item->preprocess != NULL + && item->preprocess(item, value, sizeof(value)) + ) { /* Something went wrong */ upslogx(LOG_ERR, "%s: FAILED", __func__); return STAT_SET_UNKNOWN; /* TODO: HANDLED but FAILED, not UNKNOWN! */ @@ -1482,7 +2449,8 @@ int setvar(const char *varname, const char *val) /* Handle server side variable */ if (item->qxflags & QX_FLAG_ABSENT) { - upsdebugx(2, "%s: setting server side variable %s", __func__, item->info_type); + upsdebugx(2, "%s: setting server side variable %s", + __func__, item->info_type); dstate_setinfo(item->info_type, "%s", value); upslogx(LOG_INFO, "%s: SUCCEED", __func__); return STAT_SET_HANDLED; @@ -1499,10 +2467,14 @@ int setvar(const char *varname, const char *val) return STAT_SET_UNKNOWN; /* TODO: HANDLED but FAILED, not UNKNOWN! */ } - /* We got a reply from the UPS: either subdriver->accepted (-> command handled) or the command itself echoed back (-> command failed) */ + /* We got a reply from the UPS: + * either subdriver->accepted (-> command handled) + * or the command itself echoed back (-> command failed) */ if (strlen(item->value) > 0) { - if (subdriver->accepted != NULL && !strcasecmp(item->value, subdriver->accepted)) { + if (subdriver->accepted != NULL + && !strcasecmp(item->value, subdriver->accepted) + ) { upslogx(LOG_INFO, "%s: SUCCEED", __func__); /* Set the status so that SEMI_STATIC vars are polled */ data_has_changed = TRUE; @@ -1522,6 +2494,9 @@ int setvar(const char *varname, const char *val) } /* Try to shutdown the UPS */ +void upsdrv_shutdown(void) + __attribute__((noreturn)); + void upsdrv_shutdown(void) { int retry; @@ -1608,14 +2583,53 @@ void upsdrv_shutdown(void) } - fatalx(EXIT_SUCCESS, "Shutting down in %s seconds", dstate_getinfo("ups.delay.shutdown")); + fatalx(EXIT_SUCCESS, "Shutting down in %s seconds", + dstate_getinfo("ups.delay.shutdown")); } fatalx(EXIT_FAILURE, "Shutdown failed!"); } +#ifdef QX_USB + #ifndef TESTING + static const struct { + const char *name; + int (*command)(const char *cmd, char *buf, size_t buflen); + } usbsubdriver[] = { + { "cypress", &cypress_command }, + { "phoenixtec", &phoenixtec_command }, + { "phoenix", &phoenix_command }, + { "ippon", &ippon_command }, + { "krauler", &krauler_command }, + { "fabula", &fabula_command }, + { "hunnox", &hunnox_command }, + { "fuji", &fuji_command }, + { "sgs", &sgs_command }, + { "snr", &snr_command }, + { "ablerex", &ablerex_command }, + { "armac", &armac_command }, + { NULL, NULL } + }; + #endif +#endif + + void upsdrv_help(void) { +#ifdef QX_USB + #ifndef TESTING + printf("\nAcceptable values for 'subdriver' via -x or ups.conf in this driver: "); + size_t i; + + for (i = 0; usbsubdriver[i].name != NULL; i++) { + if (i>0) + printf(", "); + printf("%s", usbsubdriver[i].name); + } + printf("\n\n"); + #endif +#endif + printf("Read The Fine Manual ('man 8 nutdrv_qx')\n"); } @@ -1627,30 +2641,42 @@ void upsdrv_makevartable(void) upsdebugx(1, "%s...", __func__); - snprintf(temp, sizeof(temp), "Set shutdown delay, in seconds (default=%s)", DEFAULT_OFFDELAY); + snprintf(temp, sizeof(temp), + "Set shutdown delay, in seconds (default=%s)", DEFAULT_OFFDELAY); addvar(VAR_VALUE, QX_VAR_OFFDELAY, temp); - snprintf(temp, sizeof(temp), "Set startup delay, in seconds (default=%s)", DEFAULT_ONDELAY); + snprintf(temp, sizeof(temp), + "Set startup delay, in seconds (default=%s)", DEFAULT_ONDELAY); addvar(VAR_VALUE, QX_VAR_ONDELAY, temp); - addvar(VAR_FLAG, "stayoff", "If invoked the UPS won't return after a shutdown when FSD arises"); + addvar(VAR_FLAG, "stayoff", + "If invoked the UPS won't return after a shutdown when FSD arises"); - snprintf(temp, sizeof(temp), "Set polling frequency, in seconds, to reduce data flow (default=%d)", DEFAULT_POLLFREQ); + snprintf(temp, sizeof(temp), + "Set polling frequency, in seconds, to reduce data flow (default=%d)", + DEFAULT_POLLFREQ); addvar(VAR_VALUE, QX_VAR_POLLFREQ, temp); - addvar(VAR_VALUE, "protocol", "Preselect communication protocol (skip autodetection)"); + addvar(VAR_VALUE, "protocol", + "Preselect communication protocol (skip autodetection)"); /* battery.{charge,runtime} guesstimation */ - addvar(VAR_VALUE, "runtimecal", "Parameters used for runtime calculation"); - addvar(VAR_VALUE, "chargetime", "Nominal charge time for UPS battery"); - addvar(VAR_VALUE, "idleload", "Minimum load to be used for runtime calculation"); + addvar(VAR_VALUE, "runtimecal", + "Parameters used for runtime calculation"); + addvar(VAR_VALUE, "chargetime", + "Nominal charge time for UPS battery"); + addvar(VAR_VALUE, "idleload", + "Minimum load to be used for runtime calculation"); #ifdef QX_USB addvar(VAR_VALUE, "subdriver", "Serial-over-USB subdriver selection"); /* allow -x vendor=X, vendorid=X, product=X, productid=X, serial=X */ nut_usb_addvars(); - addvar(VAR_VALUE, "langid_fix", "Apply the language ID workaround to the krauler subdriver (0x409 or 0x4095)"); + addvar(VAR_VALUE, "langid_fix", + "Apply the language ID workaround to the krauler subdriver " + "(0x409 or 0x4095)"); + addvar(VAR_FLAG, "noscanlangid", "Don't autoscan valid range for langid"); #endif /* QX_USB */ #ifdef QX_SERIAL @@ -1679,7 +2705,8 @@ void upsdrv_updateinfo(void) /* Clear status buffer before beginning */ status_init(); - /* Do a full update (polling) every pollfreq or upon data change (i.e. setvar/instcmd) */ + /* Do a full update (polling) every pollfreq or upon data change + * (i.e. setvar/instcmd) */ if ((now > (lastpoll + pollfreq)) || (data_has_changed == TRUE)) { upsdebugx(1, "Full update..."); @@ -1692,7 +2719,8 @@ void upsdrv_updateinfo(void) if (qx_ups_walk(QX_WALKMODE_FULL_UPDATE) == FALSE) { if (retry < MAXTRIES || retry == MAXTRIES) { - upsdebugx(1, "Communications with the UPS lost: status read failed!"); + upsdebugx(1, + "Communications with the UPS lost: status read failed!"); retry++; } else { dstate_datastale(); @@ -1715,7 +2743,8 @@ void upsdrv_updateinfo(void) if (qx_ups_walk(QX_WALKMODE_QUICK_UPDATE) == FALSE) { if (retry < MAXTRIES || retry == MAXTRIES) { - upsdebugx(1, "Communications with the UPS lost: status read failed!"); + upsdebugx(1, + "Communications with the UPS lost: status read failed!"); retry++; } else { dstate_datastale(); @@ -1777,12 +2806,16 @@ void upsdrv_initinfo(void) } - if (!find_nut_info("load.off", QX_FLAG_CMD, QX_FLAG_SKIP) && find_nut_info("load.off.delay", QX_FLAG_CMD, QX_FLAG_SKIP)) { + if (!find_nut_info("load.off", QX_FLAG_CMD, QX_FLAG_SKIP) + && find_nut_info("load.off.delay", QX_FLAG_CMD, QX_FLAG_SKIP) + ) { /* Adds default with a delay value of '0' (= immediate) */ dstate_addcmd("load.off"); } - if (!find_nut_info("load.on", QX_FLAG_CMD, QX_FLAG_SKIP) && find_nut_info("load.on.delay", QX_FLAG_CMD, QX_FLAG_SKIP)) { + if (!find_nut_info("load.on", QX_FLAG_CMD, QX_FLAG_SKIP) + && find_nut_info("load.on.delay", QX_FLAG_CMD, QX_FLAG_SKIP) + ) { /* Adds default with a delay value of '0' (= immediate) */ dstate_addcmd("load.on"); } @@ -1792,7 +2825,7 @@ void upsdrv_initinfo(void) if (val) pollfreq = strtol(val, NULL, 10); - dstate_setinfo("driver.parameter.pollfreq", "%d", pollfreq); + dstate_setinfo("driver.parameter.pollfreq", "%ld", pollfreq); time(&lastpoll); @@ -1851,7 +2884,7 @@ void upsdrv_initups(void) { "reverse", 0, 1 }, { "both", 1, 1 }, { "none", 0, 0 }, - { NULL } + { NULL, 0, 0 } }; int i; @@ -1912,25 +2945,12 @@ void upsdrv_initups(void) /* USB */ #ifdef QX_USB + warn_if_bad_usb_port_filename(device_path); + #ifndef TESTING - - const struct { - const char *name; - int (*command)(const char *cmd, char *buf, size_t buflen); - } usbsubdriver[] = { - { "cypress", &cypress_command }, - { "phoenix", &phoenix_command }, - { "ippon", &ippon_command }, - { "krauler", &krauler_command }, - { "fabula", &fabula_command }, - { "fuji", &fuji_command }, - { "sgs", &sgs_command }, - { NULL } - }; - int ret, langid; char tbuf[255]; /* Some devices choke on size > 255 */ - char *regex_array[6]; + char *regex_array[7]; char *subdrv = getval("subdriver"); @@ -1940,14 +2960,21 @@ void upsdrv_initups(void) regex_array[3] = getval("product"); regex_array[4] = getval("serial"); regex_array[5] = getval("bus"); + regex_array[6] = getval("device"); /* Check for language ID workaround (#1) */ if (getval("langid_fix")) { /* Skip "0x" prefix and set back to hexadecimal */ - if (sscanf(getval("langid_fix") + 2, "%x", &langid_fix) != 1) { + unsigned int u_langid_fix; + if ( (sscanf(getval("langid_fix") + 2, "%x", &u_langid_fix) != 1) + || (u_langid_fix > INT_MAX) + ) { upslogx(LOG_NOTICE, "Error enabling language ID workaround"); } else { - upsdebugx(2, "Language ID workaround enabled (using '0x%x')", langid_fix); + langid_fix = (int)u_langid_fix; + upsdebugx(2, + "Language ID workaround enabled (using '0x%x')", + langid_fix); } } @@ -1957,7 +2984,9 @@ void upsdrv_initups(void) int i; if (!regex_array[0] || !regex_array[1]) { - fatalx(EXIT_FAILURE, "When specifying a subdriver, 'vendorid' and 'productid' are mandatory."); + fatalx(EXIT_FAILURE, + "When specifying a subdriver, " + "'vendorid' and 'productid' are mandatory."); } for (i = 0; usbsubdriver[i].name; i++) { @@ -1976,7 +3005,9 @@ void upsdrv_initups(void) } - ret = USBNewRegexMatcher(®ex_matcher, regex_array, REG_ICASE | REG_EXTENDED); + ret = USBNewRegexMatcher(®ex_matcher, + regex_array, + REG_ICASE | REG_EXTENDED); switch (ret) { case -1: @@ -1984,7 +3015,9 @@ void upsdrv_initups(void) case 0: break; /* All is well */ default: - fatalx(EXIT_FAILURE, "Invalid regular expression: %s", regex_array[ret]); + fatalx(EXIT_FAILURE, + "Invalid regular expression: %s", + regex_array[ret]); } /* Link the matchers */ @@ -1993,10 +3026,14 @@ void upsdrv_initups(void) ret = usb->open(&udev, &usbdevice, regex_matcher, NULL); if (ret < 0) { fatalx(EXIT_FAILURE, - "No supported devices found. Please check your device availability with 'lsusb'\n" - "and make sure you have an up-to-date version of NUT. If this does not help,\n" - "try running the driver with at least 'subdriver', 'vendorid' and 'productid'\n" - "options specified. Please refer to the man page for details about these options\n" + "No supported devices found. " + "Please check your device availability with 'lsusb'\n" + "and make sure you have an up-to-date version of NUT. " + "If this does not help,\n" + "try running the driver with at least 'subdriver', " + "'vendorid' and 'productid'\n" + "options specified. Please refer to the man page " + "for details about these options\n" "(man 8 nutdrv_qx).\n"); } @@ -2017,17 +3054,25 @@ void upsdrv_initups(void) dstate_setinfo("ups.productid", "%04x", usbdevice.ProductID); /* Check for language ID workaround (#2) */ - if (langid_fix != -1) { + if ((langid_fix != -1) && (!getval("noscanlangid"))) { /* Future improvement: - * Asking for the zero'th index is special - it returns a string descriptor that contains all the language IDs supported by the device. + * Asking for the zero'th index is special - it returns + * a string descriptor that contains all the language + * IDs supported by the device. * Typically there aren't many - often only one. - * The language IDs are 16 bit numbers, and they start at the third byte in the descriptor. - * See USB 2.0 specification, section 9.6.7, for more information on this. + * The language IDs are 16 bit numbers, and they start at + * the third byte in the descriptor. + * See USB 2.0 specification, section 9.6.7, for more + * information on this. * This should allow automatic application of the workaround */ - ret = usb_get_string(udev, 0, 0, tbuf, sizeof(tbuf)); + ret = usb_get_string(udev, 0, 0, + (usb_ctrl_charbuf)tbuf, sizeof(tbuf)); if (ret >= 4) { - langid = tbuf[2] | (tbuf[3] << 8); - upsdebugx(1, "First supported language ID: 0x%x (please report to the NUT maintainer!)", langid); + langid = ((uint8_t)tbuf[2]) | (((uint8_t)tbuf[3]) << 8); + upsdebugx(1, + "First supported language ID: 0x%x " + "(please report to the NUT maintainer!)", + langid); } } @@ -2079,6 +3124,7 @@ void upsdrv_cleanup(void) free(usbdevice.Product); free(usbdevice.Serial); free(usbdevice.Bus); + free(usbdevice.Device); #ifdef QX_SERIAL } /* is_usb */ @@ -2095,18 +3141,25 @@ void upsdrv_cleanup(void) /* Generic command processing function: send a command and read a reply. * Returns < 0 on error, 0 on timeout and the number of bytes read on success. */ -static int qx_command(const char *cmd, char *buf, size_t buflen) +static ssize_t qx_command(const char *cmd, char *buf, size_t buflen) { +/* NOTE: Could not find in which ifdef-ed codepath, but clang complained + * about unused parameters here. Reference them just in case... + */ + NUT_UNUSED_VARIABLE(cmd); + NUT_UNUSED_VARIABLE(buf); + NUT_UNUSED_VARIABLE(buflen); + #ifndef TESTING - int ret = -1; + ssize_t ret = -1; -#ifdef QX_USB +# ifdef QX_USB - #ifdef QX_SERIAL +# ifdef QX_SERIAL /* Communication: USB */ if (is_usb) { - #endif /* QX_SERIAL */ +# endif /* QX_SERIAL (&& QX_USB)*/ if (udev == NULL) { ret = usb->open(&udev, &usbdevice, reopen_matcher, NULL); @@ -2124,77 +3177,108 @@ static int qx_command(const char *cmd, char *buf, size_t buflen) switch (ret) { - case -EBUSY: /* Device or resource busy */ + case ERROR_BUSY: /* Device or resource busy */ fatal_with_errno(EXIT_FAILURE, "Got disconnected by another driver"); +#ifndef HAVE___ATTRIBUTE__NORETURN +# if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunreachable-code" +# endif + exit(EXIT_FAILURE); /* Should not get here in practice, but compiler is afraid we can fall through */ +# if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) +# pragma GCC diagnostic pop +# endif +#endif + #if WITH_LIBUSB_0_1 /* limit to libusb 0.1 implementation */ case -EPERM: /* Operation not permitted */ fatal_with_errno(EXIT_FAILURE, "Permissions problem"); +#ifndef HAVE___ATTRIBUTE__NORETURN +# if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunreachable-code" +# endif + exit(EXIT_FAILURE); /* Should not get here in practice, but compiler is afraid we can fall through */ +# if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) +# pragma GCC diagnostic pop +# endif +#endif + #endif /* WITH_LIBUSB_0_1 */ - case -EPIPE: /* Broken pipe */ + case ERROR_PIPE: /* Broken pipe */ if (usb_clear_halt(udev, 0x81) == 0) { upsdebugx(1, "Stall condition cleared"); break; } - #ifdef ETIME +#if (defined ETIME) && ETIME && WITH_LIBUSB_0_1 /* limit to libusb 0.1 implementation */ + goto fallthrough_case_ETIME; case -ETIME: /* Timer expired */ - #endif /* ETIME */ + fallthrough_case_ETIME: +#endif /* ETIME && WITH_LIBUSB_0_1 */ if (usb_reset(udev) == 0) { upsdebugx(1, "Device reset handled"); } - case -ENODEV: /* No such device */ - case -EACCES: /* Permission denied */ - case -EIO: /* I/O error */ + goto fallthrough_case_reconnect; + case ERROR_NO_DEVICE: /* No such device */ + case ERROR_ACCESS: /* Permission denied */ + case ERROR_IO: /* I/O error */ +#if WITH_LIBUSB_0_1 /* limit to libusb 0.1 implementation */ case -ENXIO: /* No such device or address */ - case -ENOENT: /* No such file or directory */ +#endif /* WITH_LIBUSB_0_1 */ + case ERROR_NOT_FOUND: /* No such file or directory */ + fallthrough_case_reconnect: /* Uh oh, got to reconnect! */ usb->close(udev); udev = NULL; break; - case -ETIMEDOUT: /* Connection timed out */ - case -EOVERFLOW: /* Value too large for defined data type */ -#ifdef EPROTO + case ERROR_TIMEOUT: /* Connection timed out */ + case ERROR_OVERFLOW: /* Value too large for defined data type */ +#if EPROTO && WITH_LIBUSB_0_1 /* limit to libusb 0.1 implementation */ case -EPROTO: /* Protocol error */ #endif default: break; } - #ifdef QX_SERIAL +# ifdef QX_SERIAL /* Communication: serial */ } else { /* !is_usb */ - #endif /* QX_SERIAL */ +# endif /* QX_SERIAL (&& QX_USB) */ -#endif /* QX_USB */ +# endif /* QX_USB (&& TESTING) */ -#ifdef QX_SERIAL +# ifdef QX_SERIAL ser_flush_io(upsfd); ret = ser_send(upsfd, "%s", cmd); if (ret <= 0) { - upsdebugx(3, "send: %s (%d)", ret ? strerror(errno) : "timeout", ret); + upsdebugx(3, "send: %s (%zd)", + ret ? strerror(errno) : "timeout", ret); return ret; } - upsdebugx(3, "send: '%.*s'", (int)strcspn(cmd, "\r"), cmd); + upsdebugx(3, "send: '%.*s'", + (int)strcspn(cmd, "\r"), cmd); ret = ser_get_buf(upsfd, buf, buflen, SER_WAIT_SEC, 0); if (ret <= 0) { - upsdebugx(3, "read: %s (%d)", ret ? strerror(errno) : "timeout", ret); + upsdebugx(3, "read: %s (%zd)", + ret ? strerror(errno) : "timeout", ret); return ret; } - upsdebug_hex(5, "read", buf, ret); + upsdebug_hex(5, "read", buf, (size_t)ret); upsdebugx(3, "read: '%.*s'", (int)strcspn(buf, "\r"), buf); - #ifdef QX_USB +# ifdef QX_USB } /* !is_usb */ - #endif /* QX_USB */ +# endif /* QX_USB (&& QX_SERIAL) */ -#endif /* QX_SERIAL */ +# endif /* QX_SERIAL (&& TESTING) */ return ret; @@ -2213,7 +3297,9 @@ static int qx_command(const char *cmd, char *buf, size_t buflen) continue; } - upsdebugx(3, "read: '%.*s'", (int)strcspn(testing[i].answer, "\r"), testing[i].answer); + upsdebugx(3, "read: '%.*s'", + (int)strcspn(testing[i].answer, "\r"), + testing[i].answer); /* If requested to do so and this is the case, try to preserve inner '\0's (treat answer as a sequence of bytes) */ if (testing[i].answer_len > 0 && strlen(testing[i].answer) < (size_t)testing[i].answer_len) { @@ -2238,7 +3324,9 @@ static int qx_command(const char *cmd, char *buf, size_t buflen) if (subdriver->rejected != NULL) { /* ..fulfill its expectations.. */ - upsdebugx(3, "read: '%.*s'", (int)strcspn(subdriver->rejected, "\r"), subdriver->rejected); + upsdebugx(3, "read: '%.*s'", + (int)strcspn(subdriver->rejected, "\r"), + subdriver->rejected); return snprintf(buf, buflen, "%s", subdriver->rejected); /* ..otherwise.. */ @@ -2281,7 +3369,8 @@ void update_status(const char *value) return; } - upsdebugx(5, "%s: Warning! %s not in list of known values", __func__, value); + upsdebugx(5, "%s: Warning! %s not in list of known values", + __func__, value); } /* Choose subdriver */ @@ -2301,10 +3390,13 @@ static int subdriver_matcher(void) char subdrv_name[SMALLBUF]; /* Get rid of subdriver version */ - snprintf(subdrv_name, sizeof(subdrv_name), "%.*s", (int)strcspn(subdriver_list[i]->name, " "), subdriver_list[i]->name); + snprintf(subdrv_name, sizeof(subdrv_name), "%.*s", + (int)strcspn(subdriver_list[i]->name, " "), + subdriver_list[i]->name); if (strcasecmp(subdrv_name, protocol)) { - upsdebugx(2, "Skipping protocol %s", subdriver_list[i]->name); + upsdebugx(2, "Skipping protocol %s", + subdriver_list[i]->name); continue; } @@ -2357,8 +3449,11 @@ static void qx_set_var(item_t *item) /* Loop on all existing values */ for (envalue = item->info_rw; envalue != NULL && strlen(envalue->value) > 0; envalue++) { - if (envalue->preprocess && envalue->preprocess(envalue->value, sizeof(envalue->value))) + if (envalue->preprocess + && envalue->preprocess(envalue->value, sizeof(envalue->value)) + ) { continue; + } /* This item is not available yet in NUT, so publish these data in the logs */ if (item->qxflags & QX_FLAG_NONUT) { @@ -2375,7 +3470,9 @@ static void qx_set_var(item_t *item) } if (item->qxflags & QX_FLAG_NONUT) - upslogx(LOG_INFO, "%s, settable values:%s", item->info_type, strlen(buf) > 0 ? buf : " none"); + upslogx(LOG_INFO, "%s, settable values:%s", + item->info_type, + strlen(buf) > 0 ? buf : " none"); } @@ -2388,8 +3485,11 @@ static void qx_set_var(item_t *item) /* Loop on all existing values */ for (rvalue = item->info_rw; rvalue != NULL && strlen(rvalue->value) > 0; rvalue++) { - if (rvalue->preprocess && rvalue->preprocess(rvalue->value, sizeof(rvalue->value))) + if (rvalue->preprocess + && rvalue->preprocess(rvalue->value, sizeof(rvalue->value)) + ) { continue; + } if (!from) { from = rvalue; @@ -2398,17 +3498,26 @@ static void qx_set_var(item_t *item) to = rvalue; - /* This item is not available yet in NUT, so publish these data in the logs */ + /* This item is not available yet in NUT, so + * publish these data in the logs */ if (item->qxflags & QX_FLAG_NONUT) { - upslogx(LOG_INFO, "%s, settable range: %s..%s", item->info_type, from->value, to->value); + upslogx(LOG_INFO, "%s, settable range: %s..%s", + item->info_type, from->value, to->value); ok++; /* This item is available in NUT, add its range to the variable */ } else { + long lFrom = strtol(from->value, NULL, 10), + lTo = strtol(to->value, NULL, 10); - dstate_addrange(item->info_type, strtol(from->value, NULL, 10), strtol(to->value, NULL, 10)); - + if (lFrom > INT_MAX || lTo > INT_MAX) { + upslogx(LOG_INFO, + "%s, settable range exceeds INT_MAX: %ld..%ld", + item->info_type, lFrom, lTo); + } else { + dstate_addrange(item->info_type, (int)lFrom, (int)lTo); + } } from = NULL; @@ -2416,7 +3525,8 @@ static void qx_set_var(item_t *item) } - /* This item is not available yet in NUT and we weren't able to get its range; let people know it */ + /* This item is not available yet in NUT and we weren't able to + * get its range; let people know it */ if ((item->qxflags & QX_FLAG_NONUT) && !ok) upslogx(LOG_INFO, "%s, settable range: none", item->info_type); @@ -2439,7 +3549,8 @@ static bool_t qx_ups_walk(walkmode_t mode) memset(previous_item.command, 0, sizeof(previous_item.command)); memset(previous_item.answer, 0, sizeof(previous_item.answer)); - /* 3 modes: QX_WALKMODE_INIT, QX_WALKMODE_QUICK_UPDATE and QX_WALKMODE_FULL_UPDATE */ + /* 3 modes: QX_WALKMODE_INIT, QX_WALKMODE_QUICK_UPDATE + * and QX_WALKMODE_FULL_UPDATE */ /* Device data walk */ for (item = subdriver->qx2nut; item->info_type != NULL; item++) { @@ -2472,8 +3583,11 @@ static bool_t qx_ups_walk(walkmode_t mode) } /* Allow duplicates for these NUT variables */ - if (!strncmp(item->info_type, "ups.alarm", 9) || !strncmp(item->info_type, "ups.status", 10)) + if (!strncmp(item->info_type, "ups.alarm", 9) + || !strncmp(item->info_type, "ups.status", 10) + ) { break; + } /* This one doesn't exist yet */ if (dstate_getinfo(item->info_type) == NULL) @@ -2496,14 +3610,41 @@ static bool_t qx_ups_walk(walkmode_t mode) continue; /* These need to be polled after user changes (setvar / instcmd) */ - if ((item->qxflags & QX_FLAG_SEMI_STATIC) && (data_has_changed == FALSE)) + if ((item->qxflags & QX_FLAG_SEMI_STATIC) + && (data_has_changed == FALSE) + ) { continue; + } break; +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) ) +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT +# pragma GCC diagnostic ignored "-Wcovered-switch-default" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +# pragma GCC diagnostic ignored "-Wunreachable-code" +#endif +/* Older CLANG (e.g. clang-3.4) seems to not support the GCC pragmas above */ +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" +#pragma clang diagnostic ignored "-Wcovered-switch-default" +#endif + /* All enum cases defined as of the time of coding + * have been covered above. Handle later definitions, + * memory corruptions and buggy inputs below... + */ default: - fatalx(EXIT_FAILURE, "%s: unknown update mode!", __func__); +#ifdef __clang__ +# pragma clang diagnostic pop +#endif +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) ) +# pragma GCC diagnostic pop +#endif } @@ -2525,10 +3666,15 @@ static bool_t qx_ups_walk(walkmode_t mode) } - /* Check whether the previous item uses the same command and then use its answer, if available.. */ - if (strlen(previous_item.command) > 0 && strlen(previous_item.answer) > 0 && !strcasecmp(previous_item.command, item->command)) { + /* Check whether the previous item uses the same command + * and then use its answer, if available.. */ + if (strlen(previous_item.command) > 0 + && strlen(previous_item.answer) > 0 + && !strcasecmp(previous_item.command, item->command) + ) { - snprintf(item->answer, sizeof(item->answer), "%s", previous_item.answer); + snprintf(item->answer, sizeof(item->answer), "%s", + previous_item.answer); /* Process the answer */ retcode = qx_process_answer(item, strlen(item->answer)); @@ -2541,8 +3687,10 @@ static bool_t qx_ups_walk(walkmode_t mode) } /* Record item as previous_item */ - snprintf(previous_item.command, sizeof(previous_item.command), "%s", item->command); - snprintf(previous_item.answer, sizeof(previous_item.answer), "%s", item->answer); + snprintf(previous_item.command, sizeof(previous_item.command), "%s", + item->command); + snprintf(previous_item.answer, sizeof(previous_item.answer), "%s", + item->answer); if (retcode) { @@ -2562,7 +3710,8 @@ static bool_t qx_ups_walk(walkmode_t mode) } - /* Process the value we got back (set status bits and set the value of other parameters) */ + /* Process the value we got back (set status bits + * and set the value of other parameters) */ retcode = ups_infoval_set(item); /* Clear data from the item */ @@ -2579,7 +3728,8 @@ static bool_t qx_ups_walk(walkmode_t mode) } - /* Set var flags/range/enum (not for ups.{alarm.status}, hence the retcode check) */ + /* Set var flags/range/enum (not for ups.{alarm.status}, + * hence the retcode check) */ if (retcode && mode == QX_WALKMODE_INIT) { qx_set_var(item); } @@ -2587,7 +3737,9 @@ static bool_t qx_ups_walk(walkmode_t mode) } /* Update battery guesstimation */ - if (mode == QX_WALKMODE_FULL_UPDATE && (batt.runt.act == -1 || batt.chrg.act == -1)) { + if (mode == QX_WALKMODE_FULL_UPDATE + && (d_equal(batt.runt.act, -1) || d_equal(batt.chrg.act, -1)) + ) { if (getval("runtimecal")) { @@ -2613,11 +3765,53 @@ static bool_t qx_ups_walk(walkmode_t mode) } - if (batt.chrg.act == -1) - dstate_setinfo("battery.charge", "%.0f", 100 * batt.runt.est / batt.runt.nom); + const char *val = dstate_getinfo("battery.voltage"); - if (batt.runt.act == -1 && !qx_load()) - dstate_setinfo("battery.runtime", "%.0f", batt.runt.est / load.eff); + if (!val) { + upsdebugx(2, "%s: unable to get battery.voltage", __func__); + } else { + /* For age-corrected estimates below, + * see theory and experimental graphs at + * https://github.com/networkupstools/nut/pull/1027 + */ + + batt.volt.act = batt.packs * strtod(val, NULL); + + if (batt.volt.act > 0 && batt.volt.low > 0 && batt.volt.high > batt.volt.low) { + + double voltage_battery_charge = (batt.volt.act - batt.volt.low) / (batt.volt.high - batt.volt.low); + + if (voltage_battery_charge < 0) { + voltage_battery_charge = 0; + } + + if (voltage_battery_charge > 1) { + voltage_battery_charge = 1; + } + + /* Correct estimated runtime remaining for old batteries: + * this value replacement only happens if the actual + * voltage_battery_charge is smaller than expected by + * previous (load-based) estimation, thus adapting to a + * battery too old and otherwise behaving non-linearly + */ + if (voltage_battery_charge < (batt.runt.est / batt.runt.nom)) { + double estPrev = batt.runt.est; + batt.runt.est = voltage_battery_charge * batt.runt.nom; + upsdebugx(3, "%s: updating batt.runt.est from '%g' to '%g'", + __func__, estPrev, batt.runt.est); + } + + } + } + + if (d_equal(batt.chrg.act, -1)) + dstate_setinfo("battery.charge", "%.0f", + 100 * batt.runt.est / batt.runt.nom); + + if (d_equal(batt.runt.act, -1) && !qx_load()) + dstate_setinfo("battery.runtime", "%.0f", + batt.runt.est / load.eff); battery_lastpoll = battery_now; @@ -2710,35 +3904,44 @@ item_t *find_nut_info(const char *varname, const unsigned long flag, const unsig /* Process the answer we got back from the UPS * Return -1 on errors, 0 on success */ -static int qx_process_answer(item_t *item, const int len) +static int qx_process_answer(item_t *item, const size_t len) { /* Query rejected by the UPS */ if (subdriver->rejected && !strcasecmp(item->answer, subdriver->rejected)) { - upsdebugx(2, "%s: query rejected by the UPS (%s)", __func__, item->info_type); + upsdebugx(2, "%s: query rejected by the UPS (%s)", + __func__, item->info_type); return -1; } /* Short reply */ if (item->answer_len && len < item->answer_len) { - upsdebugx(2, "%s: short reply (%s)", __func__, item->info_type); + upsdebugx(2, "%s: short reply (%s)", + __func__, item->info_type); return -1; } /* Wrong leading character */ if (item->leading && item->answer[0] != item->leading) { - upsdebugx(2, "%s: %s - invalid start character [%02x], expected [%02x]", __func__, item->info_type, item->answer[0], item->leading); + upsdebugx(2, + "%s: %s - invalid start character [%02x], expected [%02x]", + __func__, item->info_type, item->answer[0], item->leading); return -1; } /* Check boundaries */ if (item->to && item->to < item->from) { - upsdebugx(1, "%s: in %s, starting char's position (%d) follows ending char's one (%d)", __func__, item->info_type, item->from, item->to); + upsdebugx(1, + "%s: in %s, starting char's position (%d) " + "follows ending char's one (%d)", + __func__, item->info_type, item->from, item->to); return -1; } /* Get value */ if (strlen(item->answer)) { - snprintf(item->value, sizeof(item->value), "%.*s", item->to ? 1 + item->to - item->from : (int)strcspn(item->answer, "\r") - item->from, item->answer + item->from); + snprintf(item->value, sizeof(item->value), "%.*s", + item->to ? 1 + item->to - item->from : (int)strcspn(item->answer, "\r") - item->from, + item->answer + item->from); } else { snprintf(item->value, sizeof(item->value), "%s", ""); } @@ -2749,20 +3952,30 @@ static int qx_process_answer(item_t *item, const int len) /* See header file for details. */ int qx_process(item_t *item, const char *command) { - char buf[sizeof(item->answer) - 1] = "", - cmd[command ? (strlen(command) >= SMALLBUF ? strlen(command) + 1 : SMALLBUF) : (item->command && strlen(item->command) >= SMALLBUF ? strlen(item->command) + 1 : SMALLBUF)]; - int len; + char buf[sizeof(item->answer) - 1] = "", *cmd; + ssize_t len; + size_t cmdlen = command ? + (strlen(command) >= SMALLBUF ? strlen(command) + 1 : SMALLBUF) : + (item->command && strlen(item->command) >= SMALLBUF ? strlen(item->command) + 1 : SMALLBUF); + size_t cmdsz = (sizeof(char) * cmdlen); /* in bytes, to be pedantic */ + + if ( !(cmd = xmalloc(cmdsz)) ) { + upslogx(LOG_ERR, "qx_process() failed to allocate buffer"); + return -1; + } /* Prepare the command to be used */ - memset(cmd, 0, sizeof(cmd)); - snprintf(cmd, sizeof(cmd), "%s", command ? command : item->command); + memset(cmd, 0, cmdsz); + snprintf(cmd, cmdsz, "%s", command ? command : item->command); /* Preprocess the command */ if ( item->preprocess_command != NULL && - item->preprocess_command(item, cmd, sizeof(cmd)) == -1 + item->preprocess_command(item, cmd, cmdsz) == -1 ) { - upsdebugx(4, "%s: failed to preprocess command [%s]", __func__, item->info_type); + upsdebugx(4, "%s: failed to preprocess command [%s]", + __func__, item->info_type); + free (cmd); return -1; } @@ -2770,21 +3983,34 @@ int qx_process(item_t *item, const char *command) len = qx_command(cmd, buf, sizeof(buf)); memset(item->answer, 0, sizeof(item->answer)); + + if (len < 0 || len > INT_MAX) { + upsdebugx(4, "%s: failed to preprocess answer [%s]", + __func__, item->info_type); + free (cmd); + return -1; + } + memcpy(item->answer, buf, sizeof(buf)); /* Preprocess the answer */ if (item->preprocess_answer != NULL) { - len = item->preprocess_answer(item, len); - if (len == -1) { - upsdebugx(4, "%s: failed to preprocess answer [%s]", __func__, item->info_type); - /* Clear answer, preventing it from being reused by next items with same command */ + len = item->preprocess_answer(item, (int)len); + if (len < 0 || len > INT_MAX) { + upsdebugx(4, "%s: failed to preprocess answer [%s]", + __func__, item->info_type); + /* Clear the failed answer, preventing it from + * being reused by next items with same command */ memset(item->answer, 0, sizeof(item->answer)); + free (cmd); return -1; } } + free (cmd); + /* Process the answer to get the value */ - return qx_process_answer(item, len); + return qx_process_answer(item, (size_t)len); } /* See header file for details. */ @@ -2797,7 +4023,8 @@ int ups_infoval_set(item_t *item) /* Process the value returned by the UPS to NUT standards */ if (item->preprocess(item, value, sizeof(value))) { - upsdebugx(4, "%s: failed to preprocess value [%s: %s]", __func__, item->info_type, item->value); + upsdebugx(4, "%s: failed to preprocess value [%s: %s]", + __func__, item->info_type, item->value); return -1; } @@ -2819,18 +4046,32 @@ int ups_infoval_set(item_t *item) snprintf(value, sizeof(value), "%s", item->value); - /* Cover most of the cases: either left/right filled with hashes, spaces or a mix of both */ + /* Cover most of the cases: either left/right filled with hashes, + * spaces or a mix of both */ if (item->qxflags & QX_FLAG_TRIM) str_trim_m(value, "# "); if (strcasecmp(item->dfl, "%s")) { if (strspn(value, "0123456789 .") != strlen(value)) { - upsdebugx(2, "%s: non numerical value [%s: %s]", __func__, item->info_type, value); + upsdebugx(2, "%s: non numerical value [%s: %s]", + __func__, item->info_type, value); return -1; } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, sizeof(value), item->dfl, strtod(value, NULL)); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif } } @@ -2841,7 +4082,8 @@ int ups_infoval_set(item_t *item) } if (!strlen(value)) { - upsdebugx(1, "%s: non significant value [%s]", __func__, item->info_type); + upsdebugx(1, "%s: non significant value [%s]", + __func__, item->info_type); return -1; } @@ -2857,7 +4099,7 @@ int ups_infoval_set(item_t *item) } /* See header file for details. */ -int qx_status(void) +unsigned int qx_status(void) { return ups_status; } diff --git a/drivers/nutdrv_qx.h b/drivers/nutdrv_qx.h index 73238e0..3cc3ebd 100644 --- a/drivers/nutdrv_qx.h +++ b/drivers/nutdrv_qx.h @@ -73,7 +73,7 @@ typedef struct item_t { char answer[SMALLBUF]; /* Answer from the UPS, filled at runtime. * If you expect a nonvalid C string (e.g.: inner '\0's) or need to perform actions before the answer is used (and treated as a null-terminated string), you should set a preprocess_answer() function */ - const int answer_len; /* Expected min length of the answer. Set it to 0 if there’s no minimum length to look after. */ + const size_t answer_len; /* Expected min length of the answer. Set it to 0 if there's no minimum length to look after. */ const char leading; /* Expected leading character of the answer (optional) */ char value[SMALLBUF]; /* Value from the answer, filled at runtime (i.e. answer between from and to) */ @@ -108,19 +108,19 @@ typedef struct item_t { } item_t; /* Driver's own flags */ -#define QX_FLAG_STATIC 2 /* Retrieve info only once. */ -#define QX_FLAG_SEMI_STATIC 4 /* Retrieve info smartly, i.e. only when a command/setvar is executed and we expect that data could have been changed. */ -#define QX_FLAG_ABSENT 8 /* Data is absent in the device, use default value. */ -#define QX_FLAG_QUICK_POLL 16 /* Mandatory vars, polled also in QX_WALKMODE_QUICK_UPDATE. - * If there’s a problem with a var not flagged as QX_FLAG_QUICK_POLL in QX_WALKMODE_INIT, the driver will automagically set QX_FLAG_SKIP on it and then it’ll skip that item in QX_WALKMODE_{QUICK,FULL}_UPDATE. +#define QX_FLAG_STATIC 2UL /* Retrieve info only once. */ +#define QX_FLAG_SEMI_STATIC 4UL /* Retrieve info smartly, i.e. only when a command/setvar is executed and we expect that data could have been changed. */ +#define QX_FLAG_ABSENT 8UL /* Data is absent in the device, use default value. */ +#define QX_FLAG_QUICK_POLL 16UL /* Mandatory vars, polled also in QX_WALKMODE_QUICK_UPDATE. + * If there's a problem with a var not flagged as QX_FLAG_QUICK_POLL in QX_WALKMODE_INIT, the driver will automagically set QX_FLAG_SKIP on it and then it'll skip that item in QX_WALKMODE_{QUICK,FULL}_UPDATE. * Otherwise, if the item has the flag QX_FLAG_QUICK_POLL set, in case of errors in QX_WALKMODE_INIT the driver will set datastale. */ -#define QX_FLAG_CMD 32 /* Instant command. */ -#define QX_FLAG_SETVAR 64 /* The var is settable and the actual item stores info on how to set it. */ -#define QX_FLAG_TRIM 128 /* This var's value need to be trimmed of leading/trailing spaces/hashes. */ -#define QX_FLAG_ENUM 256 /* Enum values exist and are stored in info_rw. */ -#define QX_FLAG_RANGE 512 /* Ranges for this var available and are stored in info_rw. */ -#define QX_FLAG_NONUT 1024 /* This var doesn't have a corresponding var in NUT. */ -#define QX_FLAG_SKIP 2048 /* Skip this var: this item won’t be processed. */ +#define QX_FLAG_CMD 32UL /* Instant command. */ +#define QX_FLAG_SETVAR 64UL /* The var is settable and the actual item stores info on how to set it. */ +#define QX_FLAG_TRIM 128UL /* This var's value need to be trimmed of leading/trailing spaces/hashes. */ +#define QX_FLAG_ENUM 256UL /* Enum values exist and are stored in info_rw. */ +#define QX_FLAG_RANGE 512UL /* Ranges for this var available and are stored in info_rw. */ +#define QX_FLAG_NONUT 1024UL /* This var doesn't have a corresponding var in NUT. */ +#define QX_FLAG_SKIP 2048UL /* Skip this var: this item won't be processed. */ #define MAXTRIES 3 /* Max number of retries */ @@ -146,7 +146,7 @@ typedef struct { void (*makevartable)(void); /* Subdriver specific ups.conf flags/vars */ const char *accepted; /* String to match if the driver is expecting a reply from the UPS on instcmd/setvar. * This comparison is done after the answer we got back from the UPS has been processed to get the value we are searching: - * - you don’t have to include the trailing carriage return (\r) + * - you don't have to include the trailing carriage return (\r) * - you can decide at which index of the answer the value should start or end setting the appropriate from and to in the item_t */ const char *rejected; /* String to match if the driver is expecting a reply from the UPS in case of error. * This comparison is done on the answer we got back from the UPS before it has been processed: @@ -175,12 +175,12 @@ int qx_process(item_t *item, const char *command); * Return -1 on failure, 0 for a status update and 1 in all other cases. */ int ups_infoval_set(item_t *item); /* Return the currently processed status so that it can be checked with one of the status_bit_t passed to the STATUS() macro. */ -int qx_status(void); +unsigned int qx_status(void); /* Edit the current status: it takes one of the NUT status (all but OB are supported, simply set it as not OL), eventually preceded with an exclamation mark to clear it from the status (e.g. !OL). */ void update_status(const char *nutvalue); /* Data for processing status values */ -#define STATUS(x) ((unsigned)1< + * 2021 Ablerex Software + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "main.h" +#include "nutdrv_qx.h" +#include "nutdrv_qx_blazer-common.h" + +#include "nutdrv_qx_ablerex.h" + +#define ABLEREX_VERSION "Ablerex 0.01" + +static int Q5_Vbc = -1; +static int ablerexQ5Vb = -1; + +static int ablerex_Q5(item_t *item, char *value, const size_t valuelen) { +/* + int RawValue = 0; + + RawValue = (unsigned char)item->value[0] * 256 + (unsigned char)item->value[1]; +*/ + + //ablerexQ5Vb = (unsigned char)buf[7] * 256 + (unsigned char)buf[8]; + //Q5_Vbc = (unsigned char)buf[9] * 256 + (unsigned char)buf[10]; + upsdebugx(2, "Q51: %d %d %d %d %d %d", item->answer[0], item->answer[1], item->answer[2], item->answer[3], item->answer[4], item->answer[5]); + upsdebugx(2, "Q52: %d %d %d %d %d %d", item->answer[6], item->answer[7], item->answer[8], item->answer[9], item->answer[10], item->answer[11]); + upsdebugx(2, "Q53: %d %d %d %d", item->answer[12], item->answer[13], item->answer[14], item->answer[15]); + + int Q5_Fout = (unsigned char)item->answer[1] * 256 + (unsigned char)item->answer[2]; + int Q5_Vb = (unsigned char)item->answer[7] * 256 + (unsigned char)item->answer[8]; + Q5_Vbc = (unsigned char)item->answer[9] * 256 + (unsigned char)item->answer[10]; + //int Q5_InvW = (unsigned char)item->answer[11] * 256 + (unsigned char)item->answer[12]; + int Q5_Err = (unsigned char)item->answer[13] * 256 + (unsigned char)item->answer[14]; + int Q5_O_Cur = (unsigned char)item->answer[15] * 256 + (unsigned char)item->answer[16]; + + ablerexQ5Vb = Q5_Vb; + upsdebugx(2, "Q5: %.1f %d %.1f", 0.1 * Q5_Fout, Q5_Err, 0.1 * Q5_O_Cur); + upsdebugx(2, "Q5Vb: %d Vbc %d", Q5_Vb, Q5_Vbc); + dstate_setinfo("output.frequency", "%.1f", 0.1 * Q5_Fout); + dstate_setinfo("ups.alarm", "%d", Q5_Err); + dstate_setinfo("output.current", "%.1f", 0.1 * Q5_O_Cur); + + snprintf(value, valuelen, "%.1f", Q5_Fout * 0.1); + +/* + switch (item->from) + { + case 1: + snprintf(value, valuelen, "%.1f", RawValue * 0.1); + upsdebugx(2, "Q51: %.1f", 0.1*RawValue); + break; + case 13: + snprintf(value, valuelen, "%.0f", RawValue); + upsdebugx(2, "Q52: %.0f", 0.1*RawValue); + break; + case 15: + snprintf(value, valuelen, "%.1f", RawValue * 0.1); + upsdebugx(2, "Q53: %.1f", 0.1*RawValue); + break; + + default: + //Don't know what happened + return -1; + } +*/ + + return 0; +} + +static int ablerex_battery(item_t *item, char *value, const size_t valuelen) { + double BattV = 0.0; + BattV = strtod(item->value, NULL); + upsdebugx(2, "battvoltact2: %.2f", BattV); + if (!dstate_getinfo("battery.voltage.nominal")) + { + snprintf(value, valuelen, "%.2f", BattV); + return 0; + } + + double nomBattV = 0.0; + nomBattV = strtod(dstate_getinfo("battery.voltage.nominal"), NULL); + upsdebugx(2, "battvoltact1: %.2f", nomBattV); + //return 0; + + double battvoltact = 0.0; + + if (ablerexQ5Vb > 0) { + battvoltact = ablerexQ5Vb * nomBattV / 1200; + } else { + if (BattV > 3.0) { + battvoltact = BattV; + } else { + battvoltact = BattV * 6 * nomBattV / 12; + } + } + + snprintf(value, valuelen, "%.2f", battvoltact); + upsdebugx(2, "battvoltact: %.2f / %.2f", battvoltact, BattV); + + return 0; +} + +static int ablerex_battery_charge(double BattIn) +{ + const double onlineP[] = { + 2.22, 2.21, 2.20, 2.19, 2.18, 2.17, 2.16, 2.15, 2.14, 2.13, + 2.12, 2.11, 2.10, 2.09, 2.08, 2.07, 2.06, 2.05, 2.04, 2.03, + 2.02, 2.01, 2.00, 1.99, 1.98, 1.97, 1.96, 1.95, 1.94, 1.93, + 1.92, 1.91, 1.90, 1.89, 1.88, 1.87, 1.86, 1.85, 1.84, 1.83, + 1.82, 1.81, 1.80, 1.79, 1.78, 1.77, 1.76, 1.75, 1.74, 1.73, + 1.72, 1.71, 1.70, 1.69, 1.68, 1.67 + }; + const int onlineC[] = { + 100, 90, 88, 87, 85, 83, 82, 80, 78, 77, + 75, 73, 72, 70, 68, 65, 65, 62, 62, 58, + 58, 55, 55, 53, 52, 50, 48, 47, 45, 43, + 42, 40, 38, 37, 35, 33, 32, 30, 28, 27, + 25, 23, 22, 20, 18, 17, 15, 13, 12, 10, + 8, 7, 5, 3, 2, 0, -1 + }; + const double offlineP[] = { + 13.5, 13.3, 13.2, 13.1, 13, 12.9, 12.8, 12.7, 12.6, 12.5, + 12.4, 12.3, 12.2, 12.1, 12, 11.9, 11.8, 11.7, 11.6, 11.5, + 11.4, 11.3, 11.2, 11.1, 11, 10.9, 10.8, 10.7, 10.6, 10.5, + 10.4, 10.3, 10.2, 10.1, 10 + }; + const int offlineC[] = { + 100, 90, 88, 86, 83, 80, 77, 74, 72, 69, + 66, 63, 61, 58, 55, 52, 49, 47, 44, 41, + 38, 36, 33, 30, 27, 24, 22, 19, 16, 13, + 11, 8, 5, 2, 0, -1 + }; + + int charge = 0; + int i; + + if (BattIn < 3.0) { + for (i = 0; onlineC[i] > 0; i++) { + if (BattIn >= onlineP[i]) { + charge = onlineC[i]; + break; + } + } + } else { + //double nomBattV = strtod(dstate_getinfo("battery.voltage.nominal"), NULL); + //double battV = BattIn / (nomBattV / 12); + + for (i = 0; offlineC[i] > 0; i++) { + if (BattIn >= offlineP[i]) { + charge = offlineC[i]; + break; + } + } + } + return charge; +} + +static int ablerex_batterycharge(item_t *item, char *value, const size_t valuelen) { + double BattV = 0.0; + BattV = strtod(item->value, NULL); + upsdebugx(2, "battvoltc2: %.2f", BattV); + if (!dstate_getinfo("battery.voltage.nominal")) + { + snprintf(value, valuelen, "%d", 100); + return 0; + } + + double nomBattV = 0.0; + nomBattV = strtod(dstate_getinfo("battery.voltage.nominal"), NULL); + upsdebugx(2, "battvv1: %.2f", nomBattV); + //return 0; + + if (BattV > 3.0) { + BattV = BattV / (nomBattV / 12); + } + int BattP = ablerex_battery_charge(BattV); + //dstate_setinfo("battery.charge", "%.0f", BattP); + + snprintf(value, valuelen, "%d", BattP); + upsdebugx(2, "battcharge: %d", BattP); + + return 0; +} + +static int ablerex_initbattery(item_t *item, char *value, const size_t valuelen) { + + double nomBattV = strtod(dstate_getinfo("battery.voltage.nominal"), NULL); + double batthigh = 0.0; + double battlow = 0.0; + + if (Q5_Vbc > 0) { + battlow = Q5_Vbc * nomBattV / 1200; + } else { + battlow = 960 * nomBattV / 1200; + } + batthigh = 1365 * nomBattV / 1200; + + switch (item->from) + { + case 1: + snprintf(value, valuelen, "%.2f", battlow); + upsdebugx(2, "BattLow: %.2f", battlow); + break; + case 2: + snprintf(value, valuelen, "%.2f", batthigh); + upsdebugx(2, "BattHigh: %.2f", batthigh); + break; + + default: + /* Don't know what happened */ + return -1; + } + + return 0; +} + +static int ablerex_At(item_t *item, char *value, const size_t valuelen) { + int RawValue = 0; + + RawValue = (unsigned char)item->answer[1] * 65536 * 256 + (unsigned char)item->answer[2] * 65536 + + (unsigned char)item->answer[3] * 256 + (unsigned char)item->answer[4]; + + snprintf(value, valuelen, "%d", RawValue); + upsdebugx(2, "At: %d", RawValue); + + return 0; +} + +static int ablerex_TR(item_t *item, char *value, const size_t valuelen) { + char TR[8]; + + TR[0] = item->answer[1]; + TR[1] = item->answer[2]; + TR[2] = item->answer[3]; + TR[3] = item->answer[4]; + TR[4] = 0; + + snprintf(value, valuelen, "%s", TR); + upsdebugx(2, "At: %s", TR); + + return 0; +} + +static int ablerex_process_status_bits(item_t *item, char *value, const size_t valuelen) +{ + char *val = ""; + + switch (item->from) + { + case 40: /* Bypass/Boost or Buck Active */ + + if (item->value[0] == '1') { + + double vi, vo; + + vi = strtod(dstate_getinfo("input.voltage"), NULL); + vo = strtod(dstate_getinfo("output.voltage"), NULL); + + if (item->value[2] == '1') {/* UPS Type is Standby (0 is On_line) */ + if (vo < 0.5 * vi) { + upsdebugx(2, "%s: output voltage too low", __func__); + return -1; + } else if (vo < 0.95 * vi) { + status_set("TRIM"); + } else if (vo < 1.05 * vi) { + status_set("BYPASS"); + } else if (vo < 1.5 * vi) { + status_set("BOOST"); + } else { + upsdebugx(2, "%s: output voltage too high", __func__); + return -1; + } + } else { + status_set("BYPASS"); + } + } + + break; + + case 41: /* UPS Failed - ups.alarm */ + + if (item->value[0] == '1') { /* Battery abnormal */ + status_set("RB"); + } + + double vout = strtod(dstate_getinfo("output.voltage"), NULL); + + if (vout < 50.0) { + status_set("OFF"); + } + break; + + default: + /* Don't know what happened */ + return -1; + } + + snprintf(value, valuelen, "%s", val); + + return 0; +} + +/* qx2nut lookup table */ +static item_t ablerex_qx2nut[] = { + + /* + * > [Q1\r] + * < [(226.0 195.0 226.0 014 49.0 27.5 30.0 00001000\r] + * 01234567890123456789012345678901234567890123456 + * 0 1 2 3 4 + */ + + { "input.voltage", 0, NULL, "Q1\r", "", 47, '(', "", 1, 5, "%.1f", 0, NULL, NULL, NULL }, + { "input.voltage.fault", 0, NULL, "Q1\r", "", 47, '(', "", 7, 11, "%.1f", 0, NULL, NULL, NULL }, + { "output.voltage", 0, NULL, "Q1\r", "", 47, '(', "", 13, 17, "%.1f", 0, NULL, NULL, NULL }, + { "ups.load", 0, NULL, "Q1\r", "", 47, '(', "", 19, 21, "%.0f", 0, NULL, NULL, NULL }, + { "input.frequency", 0, NULL, "Q1\r", "", 47, '(', "", 23, 26, "%.1f", 0, NULL, NULL, NULL }, + { "battery.voltage", 0, NULL, "Q1\r", "", 47, '(', "", 28, 31, "%.2f", 0, NULL, NULL, ablerex_battery }, + { "battery.charge", 0, NULL, "Q1\r", "", 47, '(', "", 28, 31, "%.2f", 0, NULL, NULL, ablerex_batterycharge }, + { "ups.temperature", 0, NULL, "Q1\r", "", 47, '(', "", 33, 36, "%.1f", 0, NULL, NULL, NULL }, + /* Status bits */ + { "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 38, 38, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, blazer_process_status_bits }, /* Utility Fail (Immediate) */ + { "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 39, 39, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, blazer_process_status_bits }, /* Battery Low */ + { "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 40, 42, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, ablerex_process_status_bits }, /* Ablerex Bypass/Boost or Buck Active */ + { "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 41, 41, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, ablerex_process_status_bits }, /* Ablerex UPS Failed */ + { "ups.alarm", 0, NULL, "Q1\r", "", 47, '(', "", 41, 41, NULL, 0, NULL, NULL, blazer_process_status_bits }, /* UPS Failed */ + { "ups.type", 0, NULL, "Q1\r", "", 47, '(', "", 42, 42, "%s", QX_FLAG_STATIC, NULL, NULL, blazer_process_status_bits }, /* UPS Type */ + { "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 43, 43, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, blazer_process_status_bits }, /* Test in Progress */ + { "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 44, 44, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, blazer_process_status_bits }, /* Shutdown Active */ + { "ups.beeper.status", 0, NULL, "Q1\r", "", 47, '(', "", 45, 45, "%s", 0, NULL, NULL, blazer_process_status_bits }, /* Beeper status */ + + /* + * > [F\r] + * < [#220.0 000 024.0 50.0\r] + * 0123456789012345678901 + * 0 1 2 + */ + + { "output.voltage.nominal", 0, NULL, "F\r", "", 22, '#', "", 1, 5, "%.1f", QX_FLAG_QUICK_POLL, NULL, NULL, NULL }, + { "output.current.nominal", 0, NULL, "F\r", "", 22, '#', "", 7, 9, "%.1f", QX_FLAG_QUICK_POLL, NULL, NULL, NULL }, + { "battery.voltage.nominal", 0, NULL, "F\r", "", 22, '#', "", 11, 15, "%.1f", QX_FLAG_QUICK_POLL, NULL, NULL, NULL }, + { "output.frequency.nominal", 0, NULL, "F\r", "", 22, '#', "", 17, 20, "%.1f", QX_FLAG_QUICK_POLL, NULL, NULL, NULL }, + { "battery.voltage.low", 0, NULL, "F\r", "", 22, '#', "", 1, 2, "%.2f", QX_FLAG_QUICK_POLL, NULL, NULL, ablerex_initbattery }, + { "battery.voltage.high", 0, NULL, "F\r", "", 22, '#', "", 2, 3, "%.2f", QX_FLAG_QUICK_POLL, NULL, NULL, ablerex_initbattery }, + + /* Ablerex */ + { "output.frequency", 0, NULL, "Q5\r", "", 22, '(', "", 1, 18, "%.1f", 0, NULL, NULL, ablerex_Q5 }, + { "battery.runtime", 0, NULL, "At\r", "", 0, '(', "", 0, 0, "%d", 0, NULL, NULL, ablerex_At }, + //{ "ups.alarm", 0, NULL, "Q5\r", "", 22, '(', "", 1, 14, "%.0f", 0, QX_FLAG_QUICK_POLL, NULL, ablerex_Q5 }, + { "ups.test.result", 0, NULL, "TR\r", "", 0, '#', "", 0, 0, "%s", 0, NULL, NULL, ablerex_TR }, + //{ "output.current", 0, NULL, "Q5\r", "", 22, '(', "", 1, 16, "%.1f", 0, QX_FLAG_QUICK_POLL, NULL, ablerex_Q5 }, + + /* + * > [I\r] + * < [#------------- ------ VT12046Q \r] + * 012345678901234567890123456789012345678 + * 0 1 2 3 + */ + + { "device.mfr", 0, NULL, "I\r", "", 39, '#', "", 1, 15, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL, NULL, NULL }, + { "device.model", 0, NULL, "I\r", "", 39, '#', "", 17, 26, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL, NULL, NULL }, + { "ups.firmware", 0, NULL, "I\r", "", 39, '#', "", 28, 37, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL, NULL, NULL }, + + /* Instant commands */ + { "beeper.toggle", 0, NULL, "Q\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + { "load.off", 0, NULL, "S.2\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + { "load.on", 0, NULL, "C\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + { "shutdown.return", 0, NULL, "S%s\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, blazer_process_command }, + { "shutdown.stayoff", 0, NULL, "S%sR0000\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, blazer_process_command }, + { "shutdown.stop", 0, NULL, "C\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + { "test.battery.start", 0, NULL, "T%02d\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, blazer_process_command }, + { "test.battery.start.deep", 0, NULL, "TL\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + { "test.battery.start.quick", 0, NULL, "T\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + { "test.battery.stop", 0, NULL, "CT\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + + /* Server-side settable vars */ + { "ups.delay.start", ST_FLAG_RW, blazer_r_ondelay, NULL, "", 0, 0, "", 0, 0, DEFAULT_ONDELAY, QX_FLAG_ABSENT | QX_FLAG_SETVAR | QX_FLAG_RANGE, NULL, NULL, blazer_process_setvar }, + { "ups.delay.shutdown", ST_FLAG_RW, blazer_r_offdelay, NULL, "", 0, 0, "", 0, 0, DEFAULT_OFFDELAY, QX_FLAG_ABSENT | QX_FLAG_SETVAR | QX_FLAG_RANGE, NULL, NULL, blazer_process_setvar }, + + /* End of structure. */ + { NULL, 0, NULL, NULL, "", 0, 0, "", 0, 0, NULL, 0, NULL, NULL, NULL } +}; + +/* Testing table */ +#ifdef TESTING +static testing_t ablerex_testing[] = { + { "Q1\r", "(215.0 195.0 230.0 014 49.0 22.7 30.0 00000000\r", -1 }, + { "F\r", "#230.0 000 024.0 50.0\r", -1 }, + { "I\r", "#NOT_A_LIVE_UPS TESTING TESTING \r", -1 }, + { "Q\r", "", -1 }, + { "S03\r", "", -1 }, + { "C\r", "", -1 }, + { "S02R0005\r", "", -1 }, + { "S.5R0000\r", "", -1 }, + { "T04\r", "", -1 }, + { "TL\r", "", -1 }, + { "T\r", "", -1 }, + { "CT\r", "", -1 }, + { NULL } +}; +#endif /* TESTING */ + +/* Subdriver-specific initups */ +static void ablerex_initups(void) +{ + blazer_initups(ablerex_qx2nut); +} + +/* Subdriver interface */ +subdriver_t ablerex_subdriver = { + ABLEREX_VERSION, + blazer_claim, + ablerex_qx2nut, + ablerex_initups, + NULL, + blazer_makevartable, + "ACK", + NULL, +#ifdef TESTING + ablerex_testing, +#endif /* TESTING */ +}; diff --git a/drivers/nutdrv_qx_ablerex.h b/drivers/nutdrv_qx_ablerex.h new file mode 100755 index 0000000..33c79c2 --- /dev/null +++ b/drivers/nutdrv_qx_ablerex.h @@ -0,0 +1,30 @@ +/* nutdrv_qx_ablerex.h - Subdriver for Ablerex Qx protocol based UPSes + * + * Copyright (C) + * 2013 Daniele Pezzini + * 2021 Ablerex Software + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef NUTDRV_QX_ABLEREX_H +#define NUTDRV_QX_ABLEREX_H + +#include "nutdrv_qx.h" + +extern subdriver_t ablerex_subdriver; + +#endif /* NUTDRV_QX_ABLEREX_H */ diff --git a/drivers/nutdrv_qx_bestups.c b/drivers/nutdrv_qx_bestups.c index 1d4955c..adc102f 100644 --- a/drivers/nutdrv_qx_bestups.c +++ b/drivers/nutdrv_qx_bestups.c @@ -24,9 +24,10 @@ */ #include "main.h" +#include "nut_float.h" +#include "nut_stdint.h" #include "nutdrv_qx.h" #include "nutdrv_qx_blazer-common.h" - #include "nutdrv_qx_bestups.h" #define BESTUPS_VERSION "BestUPS 0.06" @@ -59,7 +60,7 @@ static int inverted_bbb_bit = 0; /* == Ranges/enums == */ /* Range for ups.delay.start */ -info_rw_t bestups_r_ondelay[] = { +static info_rw_t bestups_r_ondelay[] = { { "60", 0 }, { "599940", 0 }, { "", 0 } @@ -157,7 +158,7 @@ static item_t bestups_qx2nut[] = { { "battery.packs", 0, bestups_r_batt_packs, "BP%.0f\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_SETVAR | QX_FLAG_RANGE | QX_FLAG_SKIP, NULL, NULL, bestups_process_setvar }, - /* Query UPS for shutdown mode functionality of Pin 1 and Pin 7 on the UPS DB9 communication port (Per Best Power’s EPS-0059) + /* Query UPS for shutdown mode functionality of Pin 1 and Pin 7 on the UPS DB9 communication port (Per Best Power's EPS-0059) * > [SS?\r] * < [0\r] * 01 @@ -166,7 +167,7 @@ static item_t bestups_qx2nut[] = { { "pins_shutdown_mode", ST_FLAG_RW, bestups_r_pins_shutdown_mode, "SS?\r", "", 2, 0, "", 0, 0, "%.0f", QX_FLAG_SEMI_STATIC | QX_FLAG_RANGE | QX_FLAG_NONUT, NULL, NULL, bestups_get_pins_shutdown_mode }, - /* Set shutdown mode functionality of Pin 1 and Pin 7 on the UPS DB9 communication port (Per Best Power’s EPS-0059) to n (integer, 0-6) + /* Set shutdown mode functionality of Pin 1 and Pin 7 on the UPS DB9 communication port (Per Best Power's EPS-0059) to n (integer, 0-6) * > [SSn\r] * < [] */ @@ -287,7 +288,7 @@ static void bestups_initups(void) /* Subdriver-specific flags/vars */ static void bestups_makevartable(void) { - addvar(VAR_VALUE, "pins_shutdown_mode", "Set shutdown mode functionality of Pin 1 and Pin 7 on the UPS DB9 communication port (Per Best Power’s EPS-0059) to n (integer, 0-6)"); + addvar(VAR_VALUE, "pins_shutdown_mode", "Set shutdown mode functionality of Pin 1 and Pin 7 on the UPS DB9 communication port (Per Best Power's EPS-0059) to n (integer, 0-6)"); blazer_makevartable_light(); } @@ -365,14 +366,26 @@ static int bestups_process_setvar(item_t *item, char *value, const size_t valuel if (!strcasecmp(item->info_type, "pins_shutdown_mode")) { - if (val == pins_shutdown_mode) { + if (d_equal(val, pins_shutdown_mode)) { upslogx(LOG_INFO, "%s is already set to %.0f", item->info_type, val); return -1; } } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->command, val); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif return 0; } @@ -381,7 +394,7 @@ static int bestups_process_setvar(item_t *item, char *value, const size_t valuel static int bestups_process_bbb_status_bit(item_t *item, char *value, const size_t valuelen) { /* Bypass/Boost/Buck bit is not reliable when a battery test, shutdown or on battery condition occurs: always ignore it in these cases */ - if (!(qx_status() & STATUS(OL)) || (qx_status() & (STATUS(CAL) | STATUS(FSD)))) { + if (!((unsigned int)(qx_status()) & STATUS(OL)) || ((unsigned int)(qx_status()) & (STATUS(CAL) | STATUS(FSD)))) { if (item->value[0] == '1') item->value[0] = '0'; @@ -407,6 +420,16 @@ static int bestups_process_bbb_status_bit(item_t *item, char *value, const size_ /* Identify UPS manufacturer */ static int bestups_manufacturer(item_t *item, char *value, const size_t valuelen) { +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + /* Best Power devices */ if ( !strcmp(item->value, "AX1") || @@ -431,6 +454,11 @@ static int bestups_manufacturer(item_t *item, char *value, const size_t valuelen /* Unknown devices */ snprintf(value, valuelen, item->dfl, "Unknown"); + +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif + return 0; } @@ -439,6 +467,16 @@ static int bestups_model(item_t *item, char *value, const size_t valuelen) { item_t *unskip; +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + /* Best Power devices */ if (!strcmp(item->value, "AX1")) { @@ -510,6 +548,10 @@ static int bestups_model(item_t *item, char *value, const size_t valuelen) } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif + return 0; } @@ -526,7 +568,19 @@ static int bestups_batt_runtime(item_t *item, char *value, const size_t valuelen /* Battery runtime is reported by the UPS in minutes, NUT expects seconds */ runtime = strtod(item->value, NULL) * 60; +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, runtime); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif return 0; } @@ -541,7 +595,19 @@ static int bestups_batt_packs(item_t *item, char *value, const size_t valuelen) return -1; } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, strtol(item->value, NULL, 10)); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif /* Unskip battery.packs setvar */ unskip = find_nut_info("battery.packs", QX_FLAG_SETVAR, 0); @@ -555,19 +621,38 @@ static int bestups_batt_packs(item_t *item, char *value, const size_t valuelen) return 0; } -/* *NONUT* Get shutdown mode functionality of Pin 1 and Pin 7 on the UPS DB9 communication port (Per Best Power’s EPS-0059) as set in the UPS */ +/* *NONUT* Get shutdown mode functionality of Pin 1 and Pin 7 on the UPS DB9 communication port (Per Best Power's EPS-0059) as set in the UPS */ static int bestups_get_pins_shutdown_mode(item_t *item, char *value, const size_t valuelen) { item_t *unskip; + long l; if (strspn(item->value, "0123456789") != strlen(item->value)) { upsdebugx(2, "%s: non numerical value [%s: %s]", __func__, item->info_type, item->value); return -1; } - pins_shutdown_mode = strtol(item->value, NULL, 10); + l = strtol(item->value, NULL, 10); + if (l > INT_MAX) { + upsdebugx(2, "%s: pins_shutdown_mode out of range [%s: %s]", + __func__, item->info_type, item->value); + return -1; + } + pins_shutdown_mode = (int)l; +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, pins_shutdown_mode); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif /* We were not asked by the user to change the value */ if ((item->qxflags & QX_FLAG_NONUT) && !getval(item->info_type)) @@ -588,7 +673,8 @@ static int bestups_get_pins_shutdown_mode(item_t *item, char *value, const size_ /* Voltage settings */ static int bestups_voltage_settings(item_t *item, char *value, const size_t valuelen) { - int index, val; + long index; + int val; const char *nominal_voltage; const struct { const int low; /* Low voltage -> input.transfer.low / input.transfer.boost.low */ @@ -638,7 +724,7 @@ static int bestups_voltage_settings(item_t *item, char *value, const size_t valu index = strtol(item->value, NULL, 10); if (index < 0 || index > 9) { - upsdebugx(2, "%s: value '%d' out of range [0..9]", __func__, index); + upsdebugx(2, "%s: value '%ld' out of range [0..9]", __func__, index); return -1; } @@ -683,7 +769,19 @@ static int bestups_voltage_settings(item_t *item, char *value, const size_t valu } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, val); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif return 0; } diff --git a/drivers/nutdrv_qx_blazer-common.c b/drivers/nutdrv_qx_blazer-common.c index feecad1..2ff16bc 100644 --- a/drivers/nutdrv_qx_blazer-common.c +++ b/drivers/nutdrv_qx_blazer-common.c @@ -198,16 +198,27 @@ int blazer_process_setvar(item_t *item, char *value, const size_t valuelen) if (!strcasecmp(item->info_type, "ups.delay.start")) { - int ondelay = strtol(value, NULL, 10); + long ondelay = strtol(value, NULL, 10); + + if (ondelay < 0) { + upslogx(LOG_ERR, "%s: ondelay '%ld' should not be negative", + item->info_type, ondelay); + return -1; + } /* Truncate to minute */ ondelay -= (ondelay % 60); - - snprintf(value, valuelen, "%d", ondelay); + snprintf(value, valuelen, "%ld", ondelay); } else if (!strcasecmp(item->info_type, "ups.delay.shutdown")) { - int offdelay = strtol(value, NULL, 10); + long offdelay = strtol(value, NULL, 10); + + if (offdelay < 0) { + upslogx(LOG_ERR, "%s: offdelay '%ld' should not be negative", + item->info_type, offdelay); + return -1; + } /* Truncate to nearest settable value */ if (offdelay < 60) { @@ -216,7 +227,7 @@ int blazer_process_setvar(item_t *item, char *value, const size_t valuelen) offdelay -= (offdelay % 60); } - snprintf(value, valuelen, "%d", offdelay); + snprintf(value, valuelen, "%ld", offdelay); } else { @@ -231,6 +242,16 @@ int blazer_process_setvar(item_t *item, char *value, const size_t valuelen) /* Preprocess instant commands */ int blazer_process_command(item_t *item, char *value, const size_t valuelen) { +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + if (!strcasecmp(item->info_type, "shutdown.return")) { /* Sn: Shutdown after n minutes and then turn on when mains is back @@ -242,25 +263,43 @@ int blazer_process_command(item_t *item, char *value, const size_t valuelen) * The fix is to push the return value up by 2, i.e. S01R0003, and it will return online properly. * (thus the default of ondelay=3 mins) */ - int offdelay = strtol(dstate_getinfo("ups.delay.shutdown"), NULL, 10), - ondelay = strtol(dstate_getinfo("ups.delay.start"), NULL, 10) / 60; + long offdelay = strtol(dstate_getinfo("ups.delay.shutdown"), NULL, 10), + ondelay = strtol(dstate_getinfo("ups.delay.start"), NULL, 10) / 60; char buf[SMALLBUF] = ""; - if (ondelay == 0) { + if (ondelay <= 0) { + + if (offdelay < 0) { + upslogx(LOG_ERR, "%s: offdelay '%ld' should not be negative", + item->info_type, offdelay); + return -1; + } if (offdelay < 60) { - snprintf(buf, sizeof(buf), ".%d", offdelay / 6); + snprintf(buf, sizeof(buf), ".%ld", offdelay / 6); } else { - snprintf(buf, sizeof(buf), "%02d", offdelay / 60); + snprintf(buf, sizeof(buf), "%02ld", offdelay / 60); } } else if (offdelay < 60) { - snprintf(buf, sizeof(buf), ".%dR%04d", offdelay / 6, ondelay); + if (offdelay < 0) { + upslogx(LOG_ERR, "%s: offdelay '%ld' should not be negative", + item->info_type, offdelay); + return -1; + } + + snprintf(buf, sizeof(buf), ".%ldR%04ld", offdelay / 6, ondelay); } else { - snprintf(buf, sizeof(buf), "%02dR%04d", offdelay / 60, ondelay); + if (offdelay < 0) { + upslogx(LOG_ERR, "%s: offdelay '%ld' should not be negative", + item->info_type, offdelay); + return -1; + } + + snprintf(buf, sizeof(buf), "%02ldR%04ld", offdelay / 60, ondelay); } @@ -272,23 +311,29 @@ int blazer_process_command(item_t *item, char *value, const size_t valuelen) * Shutdown after n minutes and stay off * Accepted values for n: .2 -> .9 , 01 -> 10 */ - int offdelay = strtol(dstate_getinfo("ups.delay.shutdown"), NULL, 10); + long offdelay = strtol(dstate_getinfo("ups.delay.shutdown"), NULL, 10); char buf[SMALLBUF] = ""; + if (offdelay < 0) { + upslogx(LOG_ERR, "%s: offdelay '%ld' should not be negative", + item->info_type, offdelay); + return -1; + } + if (offdelay < 60) { - snprintf(buf, sizeof(buf), ".%d", offdelay / 6); + snprintf(buf, sizeof(buf), ".%ld", offdelay / 6); } else { - snprintf(buf, sizeof(buf), "%02d", offdelay / 60); + snprintf(buf, sizeof(buf), "%02ld", offdelay / 60); } snprintf(value, valuelen, item->command, buf); } else if (!strcasecmp(item->info_type, "test.battery.start")) { - int delay = strlen(value) > 0 ? strtol(value, NULL, 10) : 600; + long delay = strlen(value) > 0 ? strtol(value, NULL, 10) : 600; if ((delay < 60) || (delay > 5940)) { - upslogx(LOG_ERR, "%s: battery test time '%d' out of range [60..5940] seconds", item->info_type, delay); + upslogx(LOG_ERR, "%s: battery test time '%ld' out of range [60..5940] seconds", item->info_type, delay); return -1; } @@ -303,6 +348,10 @@ int blazer_process_command(item_t *item, char *value, const size_t valuelen) } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif + return 0; } diff --git a/drivers/nutdrv_qx_hunnox.c b/drivers/nutdrv_qx_hunnox.c new file mode 100644 index 0000000..f104479 --- /dev/null +++ b/drivers/nutdrv_qx_hunnox.c @@ -0,0 +1,138 @@ +/* nutdrv_qx_hunnox.c - Subdriver for Hunnox protocol based UPSes + * + * Copyright (C) + * 2013 Daniele Pezzini + * 2020 Mariano Jan https://marianojan.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "main.h" +#include "nutdrv_qx.h" +#include "nutdrv_qx_blazer-common.h" + +#include "nutdrv_qx_hunnox.h" + +#define HUNNOX_VERSION "Hunnox 0.01" + +/* qx2nut lookup table */ +static item_t hunnox_qx2nut[] = { + + /* + * > [Q1\r] + * < [(226.0 195.0 226.0 014 49.0 27.5 30.0 00001000\r] + * 01234567890123456789012345678901234567890123456 + * 0 1 2 3 4 + */ + + { "input.voltage", 0, NULL, "Q1\r", "", 47, '(', "", 1, 5, "%.1f", QX_FLAG_QUICK_POLL, NULL, NULL, NULL }, + { "input.voltage.fault", 0, NULL, "Q1\r", "", 47, '(', "", 7, 11, "%.1f", QX_FLAG_QUICK_POLL, NULL, NULL, NULL }, + { "output.voltage", 0, NULL, "Q1\r", "", 47, '(', "", 13, 17, "%.1f", QX_FLAG_QUICK_POLL, NULL, NULL, NULL }, + { "ups.load", 0, NULL, "Q1\r", "", 47, '(', "", 19, 21, "%.0f", QX_FLAG_QUICK_POLL, NULL, NULL, NULL }, + { "input.frequency", 0, NULL, "Q1\r", "", 47, '(', "", 23, 26, "%.1f", QX_FLAG_QUICK_POLL, NULL, NULL, NULL }, + { "battery.voltage", 0, NULL, "Q1\r", "", 47, '(', "", 28, 31, "%.2f", QX_FLAG_QUICK_POLL, NULL, NULL, NULL }, + { "ups.temperature", 0, NULL, "Q1\r", "", 47, '(', "", 33, 36, "%.1f", QX_FLAG_QUICK_POLL, NULL, NULL, NULL }, + /* Status bits */ + { "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 38, 38, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, blazer_process_status_bits }, /* Utility Fail (Immediate) */ + { "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 39, 39, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, blazer_process_status_bits }, /* Battery Low */ + { "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 40, 40, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, blazer_process_status_bits }, /* Bypass/Boost or Buck Active */ + { "ups.alarm", 0, NULL, "Q1\r", "", 47, '(', "", 41, 41, NULL, 0, NULL, NULL, blazer_process_status_bits }, /* UPS Failed */ + { "ups.type", 0, NULL, "Q1\r", "", 47, '(', "", 42, 42, "%s", QX_FLAG_STATIC, NULL, NULL, blazer_process_status_bits }, /* UPS Type */ + { "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 43, 43, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, blazer_process_status_bits }, /* Test in Progress */ + { "ups.status", 0, NULL, "Q1\r", "", 47, '(', "", 44, 44, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, blazer_process_status_bits }, /* Shutdown Active */ + { "ups.beeper.status", 0, NULL, "Q1\r", "", 47, '(', "", 45, 45, "%s", 0, NULL, NULL, blazer_process_status_bits }, /* Beeper status */ + + /* + * > [F\r] + * < [#220.0 000 024.0 50.0\r] + * 0123456789012345678901 + * 0 1 2 + */ + + { "input.voltage.nominal", 0, NULL, "F\r", "", 22, '#', "", 1, 5, "%.0f", QX_FLAG_STATIC, NULL, NULL, NULL }, + { "input.current.nominal", 0, NULL, "F\r", "", 22, '#', "", 7, 9, "%.1f", QX_FLAG_STATIC, NULL, NULL, NULL }, + { "battery.voltage.nominal", 0, NULL, "F\r", "", 22, '#', "", 11, 15, "%.1f", QX_FLAG_STATIC, NULL, NULL, NULL }, + { "input.frequency.nominal", 0, NULL, "F\r", "", 22, '#', "", 17, 20, "%.0f", QX_FLAG_STATIC, NULL, NULL, NULL }, + /* + * > [FW?\r] + * < [#------------- ------ VT12046Q \r] + * 012345678901234567890123456789012345678 + * 0 1 2 3 + */ + + { "device.mfr", 0, NULL, "FW?\r", "", 39, '#', "", 1, 15, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL, NULL, NULL }, + { "device.model", 0, NULL, "FW?\r", "", 39, '#', "", 17, 26, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL, NULL, NULL }, + { "ups.firmware", 0, NULL, "FW?\r", "", 39, '#', "", 28, 37, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, NULL, NULL, NULL }, + + /* Instant commands */ + { "beeper.toggle", 0, NULL, "Q\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + { "load.off", 0, NULL, "S00R0000\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + { "load.on", 0, NULL, "C\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + { "shutdown.return", 0, NULL, "S%s\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, blazer_process_command }, + { "shutdown.stayoff", 0, NULL, "S%sR0000\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, blazer_process_command }, + { "shutdown.stop", 0, NULL, "C\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + { "test.battery.start", 0, NULL, "T%02d\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, blazer_process_command }, + { "test.battery.start.deep", 0, NULL, "TL\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + { "test.battery.start.quick", 0, NULL, "T\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + { "test.battery.stop", 0, NULL, "CT\r", "", 0, 0, "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + + /* Server-side settable vars */ + { "ups.delay.start", ST_FLAG_RW, blazer_r_ondelay, NULL, "", 0, 0, "", 0, 0, "0", QX_FLAG_ABSENT | QX_FLAG_SETVAR | QX_FLAG_RANGE, NULL, NULL, blazer_process_setvar }, + { "ups.delay.shutdown", ST_FLAG_RW, blazer_r_offdelay, NULL, "", 0, 0, "", 0, 0, "60", QX_FLAG_ABSENT | QX_FLAG_SETVAR | QX_FLAG_RANGE, NULL, NULL, blazer_process_setvar }, + + /* End of structure. */ + { NULL, 0, NULL, NULL, "", 0, 0, "", 0, 0, NULL, 0, NULL, NULL, NULL } +}; + +/* Testing table */ +#ifdef TESTING +static testing_t hunnox_testing[] = { + { "Q1\r", "(215.0 195.0 230.0 014 49.0 22.7 30.0 00000000\r", -1 }, + { "F\r", "#230.0 000 024.0 50.0\r", -1 }, + { "FW?\r", "#NOT_A_LIVE_UPS TESTING TESTING \r", -1 }, + { "Q\r", "", -1 }, + { "S03\r", "", -1 }, + { "C\r", "", -1 }, + { "S02R0005\r", "", -1 }, + { "S.5R0000\r", "", -1 }, + { "T04\r", "", -1 }, + { "TL\r", "", -1 }, + { "T\r", "", -1 }, + { "CT\r", "", -1 }, + { NULL } +}; +#endif /* TESTING */ + +/* Subdriver-specific initups */ +static void hunnox_initups(void) +{ + blazer_initups(hunnox_qx2nut); +} + +/* Subdriver interface */ +subdriver_t hunnox_subdriver = { + HUNNOX_VERSION, + blazer_claim, + hunnox_qx2nut, + hunnox_initups, + NULL, + blazer_makevartable, + "UPS No Ack", + NULL, +#ifdef TESTING + hunnox_testing, +#endif /* TESTING */ +}; diff --git a/drivers/nutdrv_qx_hunnox.h b/drivers/nutdrv_qx_hunnox.h new file mode 100644 index 0000000..ca96465 --- /dev/null +++ b/drivers/nutdrv_qx_hunnox.h @@ -0,0 +1,30 @@ +/* nutdrv_qx_hunnox.h - Subdriver for Hunnox protocol based UPSes + * + * Copyright (C) + * 2013 Daniele Pezzini + * 2020 Mariano Jan https://marianojan.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef NUTDRV_QX_HUNNOX_H +#define NUTDRV_QX_HUNNOX_H + +#include "nutdrv_qx.h" + +extern subdriver_t hunnox_subdriver; + +#endif /* NUTDRV_QX_HUNNOX_H */ diff --git a/drivers/nutdrv_qx_masterguard.c b/drivers/nutdrv_qx_masterguard.c new file mode 100644 index 0000000..08168f6 --- /dev/null +++ b/drivers/nutdrv_qx_masterguard.c @@ -0,0 +1,1090 @@ +/* nutdrv_qx_masterguard.c - Subdriver for Masterguard A/E Series + * + * Copyright (C) + * 2020-2021 Edgar Fuß , Mathematisches Institut der Universität Bonn + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version, or a 2-clause BSD License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "main.h" +#include "nutdrv_qx.h" + +#include "nutdrv_qx_masterguard.h" +#include + +#define MASTERGUARD_VERSION "Masterguard 0.02" + +/* series (for un-SKIP) */ +static char masterguard_my_series = '?'; +/* slave address for commands that require it */ +static char masterguard_my_slaveaddr[3] = "??"; /* null-terminated for strtol() in claim() */ +/* next slaveaddr to use after the SS command (which needs the old one) has been run */ +static long masterguard_next_slaveaddr; +/* output current/power computation */ +static long masterguard_my_power = 0; +/* battery voltage computation */ +static long masterguard_my_numcells = 0; + + +/* ranges */ + +static info_rw_t masterguard_r_slaveaddr[] = { + { "0", NULL }, + { "99", NULL }, + { "" , NULL } +}; + +static info_rw_t masterguard_r_batpacks[] = { + { "0", NULL }, /* actually 1 for most models, see masterguard_model() */ + { "9", NULL }, /* varies across models, see masterguard_model() */ + { "" , NULL } +}; + +static info_rw_t masterguard_r_offdelay[] = { + { "0", NULL }, + { "5940", NULL }, /* 99*60 */ + { "" , NULL } +}; + +static info_rw_t masterguard_r_ondelay[] = { + { "0", NULL }, + { "599940", NULL }, /* 9999*60 */ + { "" , NULL } +}; + + +/* enums */ + +static info_rw_t *masterguard_e_outvolts = NULL; /* set in masterguard_output_voltages() */ + + +/* preprocess functions */ + +/* set masterguard_my_slaveaddr (for masterguard_add_slaveaddr) */ +static int masterguard_slaveaddr(item_t *item, char *value, const size_t valuelen) { + if (strlen(item->value) != 2) { + upsdebugx(2, "slaveaddr length not 2"); + return -1; + } + memcpy(masterguard_my_slaveaddr, item->value, 2); + if (valuelen >= 3) memcpy(value, item->value, 3); + return 0; +} + +/* set masterguard_my_series (for activating supported commands in masterguard_claim() */ +static int masterguard_series(item_t *item, char *value, const size_t valuelen) { + NUT_UNUSED_VARIABLE(valuelen); + + switch (item->value[0]) { + case 'A': + break; + case 'E': + break; + default: + upsdebugx(2, "unknown series %s", item->value); + return -1; + } + masterguard_my_series = item->value[0]; + memcpy(value, item->value, 2); + return 0; +} + +/* Convert strangely formatted model name in WH output + * (spaces, -19 only after battery packs) to something readable + * Also set min/max battery packs according to model */ +static int masterguard_model(item_t *item, char *value, const size_t valuelen) { + char *model; + int rack; + char min_bp, max_bp; + + rack = (strstr(item->value, "-19") != NULL); + if (strncmp(item->value, "A 700", 6) == 0) { + model = "A700"; + min_bp = 0; max_bp = 0; + } else if (strncmp(item->value, "A 1000", 6) == 0) { + model = "A1000"; + min_bp = 0; max_bp = 2; + } else if (strncmp(item->value, "A 2000", 6) == 0) { + model = "A2000"; + min_bp = rack ? 1 : 0; max_bp = rack ? 5 : 2; + } else if (strncmp(item->value, "A 3000", 6) == 0) { + model = "A3000"; + min_bp = rack ? 1 : 0; max_bp = rack ? 5 : 2; + } else if (strncmp(item->value, "E 60", 4) == 0) { + model = "E60"; + min_bp = 1; max_bp = 1; /* ??? */ + } else if (strncmp(item->value, "E100", 4) == 0) { + model = "E100"; + min_bp = 1; max_bp = 1; /* ??? */ + } else if (strncmp(item->value, "E200", 4) == 0) { + model = "E200"; + min_bp = 1; max_bp = 1; /* ??? */ + } else { + upsdebugx(2, "unknown T %s", item->value); + return -1; + } + masterguard_r_batpacks[0].value[0] = '0' + min_bp; + masterguard_r_batpacks[1].value[0] = '0' + max_bp; + snprintf(value, valuelen, "%s%s", model, rack ? "-19" : ""); + return 0; +} + +/* set masterguard_my_power (for power/current calculations) according to model */ +static int masterguard_power(item_t *item, char *value, const size_t valuelen) { + int p; + + if (strncmp(item->value, "A 700", 6) == 0) { + p = 700; + } else if (strncmp(item->value, "A 1000", 6) == 0) { + p = 1000; + } else if (strncmp(item->value, "A 2000", 6) == 0) { + p = 2000; + } else if (strncmp(item->value, "A 3000", 6) == 0) { + p = 3000; + } else if (strncmp(item->value, "E 60", 4) == 0) { + p = 6000; + } else if (strncmp(item->value, "E100", 4) == 0) { + p = 10000; + } else if (strncmp(item->value, "E200", 4) == 0) { + p = 20000; + } else { + upsdebugx(2, "unknown T %s", item->value); + return -1; + } + masterguard_my_power = p; + snprintf(value, valuelen, "%d", p); + return 0; +} + +/* convert mmm.ss to seconds */ +static int masterguard_mmm_ss(item_t *item, char *value, const size_t valuelen) { + int m, s; + + if (sscanf(item->value, "%d.%d", &m, &s) != 2) { + upsdebugx(2, "unparsable mmm.ss %s", item->value); + return -1; + } + snprintf(value, valuelen, "%d", 60*m + s); + return 0; +} + +/* convert hhh to seconds */ +static int masterguard_hhh(item_t *item, char *value, const size_t valuelen) { + int h; + if (sscanf(item->value, "%d", &h) != 1) { + upsdebugx(2, "unparsable hhh %s", item->value); + return -1; + } + snprintf(value, valuelen, "%d", 60*60*h); + return 0; +} + +/* convert TTTT:hh:mm:dd to seconds */ +static int masterguard_tttt_hh_mm_ss(item_t *item, char *value, const size_t valuelen) { + int t, h, m, s; + + if (sscanf(item->value, "%d:%d:%d:%d", &t, &h, &m, &s) != 4) { + upsdebugx(2, "unparsable TTTT:hh:mm:ss %s", item->value); + return -1; + } + snprintf(value, valuelen, "%d", 86400*t + 3600*h + 60*m + s); + return 0; +} + +/* set masterguard_my_numcells (for nominal battery voltage computation) */ +static int masterguard_numcells(item_t *item, char *value, const size_t valuelen) { + int v; + if (sscanf(item->value, "%d", &v) != 1) { + upsdebugx(2, "unparsable vvv %s", item->value); + return -1; + } + masterguard_my_numcells = v; + snprintf(value, valuelen, "%d", v); + return 0; +} + +/* compute nominal battery voltage */ +static int masterguard_battvolt(item_t *item, char *value, const size_t valuelen) { + float s; + if (sscanf(item->value, "%f", &s) != 1) { + upsdebugx(2, "unparsable ss.ss %s", item->value); + return -1; + } + snprintf(value, valuelen, "%.2f", masterguard_my_numcells * s); + return 0; +} + +/* compute output power from load percentage */ +static int masterguard_ups_power(item_t *item, char *value, const size_t valuelen) { + int q; + + if (sscanf(item->value, "%d", &q) != 1) { + upsdebugx(2, "unparsable qqq %s", item->value); + return -1; + } + snprintf(value, valuelen, "%.0f", q / 100.0 * masterguard_my_power + 0.5); + return 0; +} + +/* helper routine, not to be called from table */ +static int masterguard_output_current_fraction(item_t *item, char *value, const size_t valuelen, double fraction) { + NUT_UNUSED_VARIABLE(item); + + snprintf(value, valuelen, "%.2f", + fraction * masterguard_my_power / strtod(dstate_getinfo("output.voltage") , NULL) + 0.005); + return 0; +} + +/* compute output current from load percentage and output voltage */ +static int masterguard_output_current(item_t *item, char *value, const size_t valuelen) { + int q; + + if (sscanf(item->value, "%d", &q) != 1) { + upsdebugx(2, "unparsable qqq %s", item->value); + return -1; + } + return masterguard_output_current_fraction(item, value, valuelen, q/100.0); +} + +/* compute nominal output current from output voltage */ +static int masterguard_output_current_nominal(item_t *item, char *value, const size_t valuelen) { + return masterguard_output_current_fraction(item, value, valuelen, 1.0); +} + +/* digest status bits */ +static int masterguard_status(item_t *item, char *value, const size_t valuelen) { + int neg; + char *s; + + switch (item->value[0]) { + case '0': neg = 1; break; + case '1': neg = 0; break; + default: + upsdebugx(2, "unknown flag value %c", item->value[0]); + return -1; + } + switch (item->from) { + case 53: /* B7 */ s = "OL"; neg = !neg; break; + case 54: /* B6 */ s = "LB"; break; + case 55: /* B5 */ s = "BYPASS"; break; + case 56: /* B4 */ s = neg ? "" : "UPS Failed"; neg = 0; break; + case 57: /* B3 */ s = neg ? "online" : "offline"; neg = 0; break; + case 58: /* B2 */ s = "CAL"; break; + case 59: /* B1 */ s = "FSD"; break; + /* 60: blank */ + /* 61: B0 reserved */ + /* 62: T7 reserved */ + case 63: /* T6 */ s = neg ? "" : "problems in parallel operation mode"; neg = 0; break; + /* 64: T5 part of a parallel set */ + case 65: /* T4 */ s = "RB"; break; + case 66: /* T3 */ s = neg ? "" : "no battery connected"; neg = 0; break; + case 67: /* T210 */ + neg = 0; + if (strncmp(item->value, "000", 3) == 0) { + s = "no test in progress"; + } else if (strncmp(item->value, "001", 3) == 0) { + s = "in progress"; + } else if (strncmp(item->value, "010", 3) == 0) { + s = "OK"; + } else if (strncmp(item->value, "011", 3) == 0) { + s = "failed"; + } else if (strncmp(item->value, "100", 3) == 0) { + s = "not possible"; + } else if (strncmp(item->value, "101", 3) == 0) { + s = "aborted"; + } else if (strncmp(item->value, "110", 3) == 0) { + s = "autonomy time calibration in progress"; + } else if (strncmp(item->value, "111", 3) == 0) { + s = "unknown"; + } else { + upsdebugx(2, "unknown test result %s", item->value); + return -1; + } + break; + default: + upsdebugx(2, "unknown flag position %d", item->from); + return -1; + } + snprintf(value, valuelen, "%s%s", neg ? "!" : "", s); + return 0; +} + +/* convert beeper status bit to string required by NUT */ +static int masterguard_beeper_status(item_t *item, char *value, const size_t valuelen) { + switch (item->value[0]) { + case '0': + if (valuelen >= 9) + strcpy(value, "disabled"); + else + *value = '\0'; + break; + case '1': + if (valuelen >= 8) + strcpy(value, "enabled"); + else + *value = '\0'; + break; + default: + upsdebugx(2, "unknown beeper status %c", item->value[0]); + return -1; + } + return 0; +} + +/* parse list of available (nominal) output voltages into masterguard_w_outvolts enum */ +static int masterguard_output_voltages(item_t *item, char *value, const size_t valuelen) { + char sep[] = " "; + char *w; + size_t n = 0; + + strncpy(value, item->value, valuelen); /* save before strtok mangles it */ + for (w = strtok(item->value, sep); w; w = strtok(NULL, sep)) { + n++; + upsdebugx(4, "output voltage #%zu: %s", n, w); + if ((masterguard_e_outvolts = realloc(masterguard_e_outvolts, n * sizeof(info_rw_t))) == NULL) { + upsdebugx(1, "output voltages: allocating #%zu failed", n); + return -1; + } + strncpy(masterguard_e_outvolts[n - 1].value, w, SMALLBUF - 1); + masterguard_e_outvolts[n - 1].preprocess = NULL; + } + /* need to do this seperately in case the loop is run zero times */ + if ((masterguard_e_outvolts = realloc(masterguard_e_outvolts, (n + 1) * sizeof(info_rw_t))) == NULL) { + upsdebugx(1, "output voltages: allocating terminator after #%zu failed", n); + return -1; + } + masterguard_e_outvolts[n].value[0] = '\0'; + masterguard_e_outvolts[n].preprocess = NULL; + return 0; +} + +/* parse fault record string into readable form */ +static int masterguard_fault(item_t *item, char *value, const size_t valuelen) { + char c; + float f; + int t, h, m, s; + long l; + + if (sscanf(item->value, "%c %f %d:%d:%d:%d", &c, &f, &t, &h, &m, &s) != 6) { + upsdebugx(1, "unparsable fault record %s", item->value); + return -1; + } + l = 86400*t + 3600*h + 60*m + s; + snprintf(value, valuelen, "%ld: ", l); + switch (c) { + case '0': + snprintfcat(value, valuelen, "none"); + break; + case '1': + snprintfcat(value, valuelen, "bus fault (%.0fV)", f); + break; + case '2': + snprintfcat(value, valuelen, "inverter fault (%.0fV)", f); + break; + case '3': + snprintfcat(value, valuelen, "overheat fault (%.0fC)", f); + break; + case '4': + snprintfcat(value, valuelen, "battery overvoltage fault (%.2fV)", f); + break; + case '5': + snprintfcat(value, valuelen, "battery mode overload fault (%.0f%%)", f); + break; + case '6': + snprintfcat(value, valuelen, "bypass mode overload fault (%.0f%%)", f); + break; + case '7': + snprintfcat(value, valuelen, "inverter mode outpt short-circuit fault (%.0fV)", f); + break; + case '8': + snprintfcat(value, valuelen, "fan lock fault"); + break; + case '9': + snprintfcat(value, valuelen, "battery fault (%.0fV)", f); + break; + case 'A': + snprintfcat(value, valuelen, "charger fault"); + break; + case 'B': + snprintfcat(value, valuelen, "EPO activated"); + break; + case 'C': + snprintfcat(value, valuelen, "parallel error"); + break; + case 'D': + snprintfcat(value, valuelen, "MCU communication error"); + break; + case 'E': + case 'F': + upsdebugx(1, "reserved fault id %c", c); + return -1; + default: + upsdebugx(1, "unknown fault id %c", c); + return -1; + } + return 0; +} + + +/* pre-command preprocessing functions */ + +/* add slave address (from masterguard_my_slaveaddr) to commands that require it */ +static int masterguard_add_slaveaddr(item_t *item, char *command, const size_t commandlen) { + NUT_UNUSED_VARIABLE(item); + NUT_UNUSED_VARIABLE(commandlen); + + size_t l; + + l = strlen(command); + if (strncmp(command + l - 4, ",XX\r", 4) != 0) { + upsdebugx(1, "add slaveaddr: no ,XX\\r at end of command %s", command); + return -1; + } + upsdebugx(4, "add slaveaddr %s to command %s", masterguard_my_slaveaddr, command); + memcpy(command + l - 3, masterguard_my_slaveaddr, 2); + return 0; +} + + +/* instant command preprocessing functions */ + +/* helper, not to be called directly from table */ +/*!! use parameter from the value field instead of ups.delay.{shutdown,return}?? */ +static int masterguard_shutdown(item_t *item, char *value, const size_t valuelen, const int stayoff) { + NUT_UNUSED_VARIABLE(item); + + long offdelay; + char *p; + const char *val, *name; + char offstr[3]; + + offdelay = strtol((val = dstate_getinfo(name = "ups.delay.shutdown")), &p, 10); + if (*p != '\0') goto ill; + if (offdelay < 0) { + goto ill; + } else if (offdelay < 60) { + offstr[0] = '.'; + offstr[1] = '0' + (char)offdelay / 6; + } else if (offdelay <= 99*60) { + int m = (int)(offdelay / 60); + offstr[0] = '0' + (char)(m / 10); + offstr[1] = '0' + (char)(m % 10); + } else goto ill; + offstr[2] = '\0'; + if (stayoff) { + snprintf(value, valuelen, "S%s\r", offstr); + } else { + long ondelay; + + ondelay = strtol((val = dstate_getinfo(name = "ups.delay.start")), &p, 10); + if (*p != '\0') goto ill; + if (ondelay < 0 || ondelay > 9999*60) goto ill; + snprintf(value, valuelen, "S%sR%04ld\r", offstr, ondelay); + } + return 0; + +ill: + upsdebugx(2, "shutdown: illegal %s %s", name, val); + return -1; +} + +static int masterguard_shutdown_return(item_t *item, char *value, const size_t valuelen) { + return masterguard_shutdown(item, value, valuelen, 0); +} + +static int masterguard_shutdown_stayoff(item_t *item, char *value, const size_t valuelen) { + return masterguard_shutdown(item, value, valuelen, 1); +} + +static int masterguard_test_battery(item_t *item, char *value, const size_t valuelen) { + NUT_UNUSED_VARIABLE(item); + + long duration; + char *p; + + if (value[0] == '\0') { + upsdebugx(2, "battery test: no duration"); + return -1; + } + duration = strtol(value, &p, 10); + if (*p != '\0') goto ill; + if (duration == 10) { + strncpy(value, "T\r", valuelen); + return 0; + } + if (duration < 60 || duration > 99*60) goto ill; + snprintf(value, valuelen, "T%02ld\r", duration / 60); + return 0; + +ill: upsdebugx(2, "battery test: illegal duration %s", value); + return -1; +} + + +/* variable setting preprocessing functions */ + +/* set variable, input format specifier (d/f/s, thms) in item->dfl */ +static int masterguard_setvar(item_t *item, char *value, const size_t valuelen) { + char *p; + char t = 's'; + long i = 0; + double f = 0.0; + char s[80]; + + if (value[0] == '\0') { + upsdebugx(2, "setvar: no value"); + return -1; + } + if (!item->dfl || item->dfl[0] == '\0') { + upsdebugx(2, "setvar: no dfl"); + return -1; + } + if (item->dfl[1] == '\0') { + t = item->dfl[0]; + switch (t) { + case 'd': + i = strtol(value, &p, 10); + if (*p != '\0') goto ill; + break; + case 'f': + f = strtod(value, &p); + if (*p != '\0') { + goto ill; + } else if (errno) { + upsdebug_with_errno(2, "setvar: f value %s", value); + return -1; + } + break; + case 's': + /* copy to s to avoid snprintf()ing value to itself */ + if (strlen(value) >= sizeof s) goto ill; + strcpy(s, value); + break; + default: + upsdebugx(2, "setvar: unknown dfl %c", item->dfl[0]); + return -1; + } + } else if (strncmp(item->dfl, "thms", 4) == 0) { + int tt, h, m, sec; + if (sscanf(item->value, "%d:%d:%d:%d", &tt, &h, &m, &sec) == 4) { + if (tt < 0 || tt > 9999 || h < 0 || h > 23 || m < 0 || m > 59 || sec < 0 || sec > 59) goto ill; + } else { + long l; + char *pl; + + l = strtol(value, &pl, 10); + if (*pl != '\0') goto ill; + sec = l % 60; l /= 60; + m = l % 60; l /= 60; + h = l % 24; l /= 24; + if (l > 9999) goto ill; + tt = (int)l; + } + snprintf(s, sizeof s, "%04d:%02d:%02d:%02d", tt, h, m, sec); + } else { + upsdebugx(2, "setvar: unknown dfl %s", item->dfl); + return -1; + } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + switch (t) { + case 'd': + snprintf(value, valuelen, item->command, i); + break; + case 'f': + snprintf(value, valuelen, item->command, f); + break; + case 's': + snprintf(value, valuelen, item->command, s); + break; + } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif + return 0; +ill: + upsdebugx(2, "setvar: illegal %s value %s", item->dfl, value); + return -1; +} + +/* record new slave address in masterguard_next_slaveaddr; moved to masterguard_my_slaveaddr in masterguard_new_slaveaddr() after the slaveaddr-changing command finished */ +static int masterguard_set_slaveaddr(item_t *item, char *value, const size_t valuelen) { + char *p; + + masterguard_next_slaveaddr = strtol(value, &p, 10); + if (*p != '\0') { + upsdebugx(2, "set_slaveaddr: illegal value %s", value); + return -1; + } + upsdebugx(3, "next slaveaddr %ld", masterguard_next_slaveaddr); + return masterguard_setvar(item, value, valuelen); +} + + +/* variable setting answer preprocessing functions */ + +/* set my_slaveaddr to next_slaveaddr /after/ issuing the SS command (which, itself, needs the /old/ slaveaddr) */ +static int masterguard_new_slaveaddr(item_t *item, const int len) { + NUT_UNUSED_VARIABLE(item); + + upsdebugx(3, "saved slaveaddr %ld", masterguard_next_slaveaddr); + if (masterguard_next_slaveaddr < 0 || masterguard_next_slaveaddr > 99) { + upsdebugx(2, "%s: illegal value %ld", __func__, masterguard_next_slaveaddr); + return -1; + } + masterguard_my_slaveaddr[0] = '0' + (char)(masterguard_next_slaveaddr / 10); + masterguard_my_slaveaddr[1] = '0' + (char)(masterguard_next_slaveaddr % 10); + upsdebugx(3, "new slaveaddr %s", masterguard_my_slaveaddr); + return len; +} + + +/* qx2nut lookup table */ +static item_t masterguard_qx2nut[] = { + /* static values */ + + /* type flags rw command answer len leading value from to dfl qxflags precmd preans preproc */ + { "device.mfr", 0, NULL, "", "", 0, '\0', "", 0, 0, "Masterguard", QX_FLAG_STATIC | QX_FLAG_ABSENT,NULL, NULL, NULL }, + { "load.high", 0, NULL, "", "", 0, '\0', "", 0, 0, "140", QX_FLAG_STATIC | QX_FLAG_ABSENT,NULL, NULL, NULL }, + /* battery.charge.low */ + /* battery.charge.warning */ + { "battery.type", 0, NULL, "", "", 0, '\0', "", 0, 0, "PbAc", QX_FLAG_STATIC | QX_FLAG_ABSENT,NULL, NULL, NULL }, + + + /* variables */ + + /* + * > [WH\r] + * < [(XX VV.VV PP.PP TTTTTTTTTTTTTTTTTTTTTTTTTTTTTT B MMM FF.FF VVV SS.SS HHH.hh GGG.gg RRR mm nn MMM NNN FF.FF FF.FF\r] + * 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012 + * 0 1 2 3 4 5 6 7 8 9 0 1 + * (00 10.06 03.09 A 700 + 0 Bat Pack-19 0 230 50.00 012 02.30 006.00 012.00 018 10 40 160 276 47.00 53.00 + */ + /* type flags rw command answer len leading value from to dfl qxflags precmd preans preproc */ + { "ups.id", ST_FLAG_RW, masterguard_r_slaveaddr,"WH\r", "", 113, '(', "", 1, 2, "%.0f", QX_FLAG_SEMI_STATIC | QX_FLAG_RANGE, NULL, NULL, masterguard_slaveaddr }, + { "ups.firmware", 0, NULL, "WH\r", "", 113, '(', "", 4, 8, "%s", QX_FLAG_STATIC, NULL, NULL, NULL }, + { "ups.firmware.aux", 0, NULL, "WH\r", "", 113, '(', "", 10, 14, "%s", QX_FLAG_STATIC, NULL, NULL, NULL }, + /* several values are deduced from the T field */ + { "experimental.series", 0, NULL, "WH\r", "", 113, '(', "", 16, 16, "%s", QX_FLAG_STATIC | QX_FLAG_NONUT, NULL, NULL, masterguard_series }, + { "device.model", 0, NULL, "WH\r", "", 113, '(', "", 16, 45, "%s", QX_FLAG_STATIC, NULL, NULL, masterguard_model }, + { "ups.power.nominal", 0, NULL, "WH\r", "", 113, '(', "", 16, 45, "%s", QX_FLAG_STATIC, NULL, NULL, masterguard_power }, +/* not used, use GS instead because the value is settable + { "battery.packs", 0, NULL, "WH\r", "", 113, '(', "", 47, 47, "%.0f", QX_FLAG_STATIC, NULL, NULL, NULL }, +*/ + { "input.voltage.nominal", 0, NULL, "WH\r", "", 113, '(', "", 49, 51, "%.0f", QX_FLAG_STATIC, NULL, NULL, NULL }, + { "input.frequency.nominal", 0, NULL, "WH\r", "", 113, '(', "", 53, 57, "%.2f", QX_FLAG_STATIC, NULL, NULL, NULL }, + { "experimental.number_of_battery_cells", 0, NULL, "WH\r", "", 113, '(', "", 59, 61, "%.0f", QX_FLAG_STATIC | QX_FLAG_NONUT, NULL, NULL, masterguard_numcells }, + { "experimental.nominal_cell_voltage", 0, NULL, "WH\r", "", 113, '(', "", 63, 67, "%.2f", QX_FLAG_STATIC | QX_FLAG_NONUT, NULL, NULL, NULL }, + { "battery.voltage.nominal", 0, NULL, "WH\r", "", 113, '(', "", 63, 67, "%.2f", QX_FLAG_STATIC, NULL, NULL, masterguard_battvolt}, + { "experimental.runtime_half", 0, NULL, "WH\r", "", 113, '(', "", 69, 74, "%.0f", QX_FLAG_STATIC | QX_FLAG_NONUT, NULL, NULL, masterguard_mmm_ss }, + { "experimental.runtime_full", 0, NULL, "WH\r", "", 113, '(', "", 76, 81, "%.0f", QX_FLAG_STATIC | QX_FLAG_NONUT, NULL, NULL, masterguard_mmm_ss }, + { "experimental.recharge_time", 0, NULL, "WH\r", "", 113, '(', "", 83, 85, "%.0f", QX_FLAG_STATIC | QX_FLAG_NONUT, NULL, NULL, masterguard_hhh }, +/*!! what's the difference between low/high and low.critical/high.critical?? */ + { "ambient.0.temperature.low", 0, NULL, "WH\r", "", 113, '(', "", 87, 88, "%.0f", QX_FLAG_STATIC, NULL, NULL, NULL }, + { "ambient.0.temperature.high", 0, NULL, "WH\r", "", 113, '(', "", 90, 91, "%.0f", QX_FLAG_STATIC, NULL, NULL, NULL }, + { "input.voltage.low.critical", 0, NULL, "WH\r", "", 113, '(', "", 93, 95, "%.0f", QX_FLAG_STATIC, NULL, NULL, NULL }, + { "input.voltage.high.critical",0, NULL, "WH\r", "", 113, '(', "", 97, 99, "%.0f", QX_FLAG_STATIC, NULL, NULL, NULL }, + { "input.frequency.low", 0, NULL, "WH\r", "", 113, '(', "", 101, 105, "%.2f", QX_FLAG_STATIC, NULL, NULL, NULL }, + { "input.frequency.high", 0, NULL, "WH\r", "", 113, '(', "", 107, 111, "%.2f", QX_FLAG_STATIC, NULL, NULL, NULL }, + + /* + * > [Q3\r] + * 76543210 76543210 + * < [(XX MMM.M NNN.N PPP.P QQQ RR.R SS.SS TT.T ttt.tt CCC BBBBBBBB TTTTTTTT\r] + * 01234567890123456789012345678901234567890123456789012345678901234567890 + * 0 1 2 3 4 5 6 7 + * (00 225.9 225.9 229.3 043 50.0 02.27 23.4 017.03 100 00000000 00000000 + * (01 226.9 226.9 226.9 039 50.0 02.30 21.8 000.00 000 01100000 00011000 + */ + /* type flags rw command answer len leading value from to dfl qxflags precmd preans preproc */ + { "input.voltage", 0, NULL, "Q3\r", "", 71, '(', "", 4, 8, "%.1f", 0, NULL, NULL, NULL }, + { "experimental.input_fault_voltage", 0, NULL, "Q3\r", "", 71, '(', "", 10, 14, "%.1f", QX_FLAG_NONUT, NULL, NULL, NULL }, + { "output.voltage", 0, NULL, "Q3\r", "", 71, '(', "", 16, 20, "%.1f", 0, NULL, NULL, NULL }, + { "ups.load", 0, NULL, "Q3\r", "", 71, '(', "", 22, 24, "%.0f", 0, NULL, NULL, NULL }, + { "ups.power", 0, NULL, "Q3\r", "", 71, '(', "", 22, 24, "%.0f", 0, NULL, NULL, masterguard_ups_power }, + { "output.current", 0, NULL, "Q3\r", "", 71, '(', "", 22, 24, "%f", 0, NULL, NULL, masterguard_output_current }, + { "input.frequency", 0, NULL, "Q3\r", "", 71, '(', "", 26, 29, "%.1f", 0, NULL, NULL, NULL }, + { "battery.voltage", 0, NULL, "Q3\r", "", 71, '(', "", 31, 35, "%.1f", 0, NULL, NULL, masterguard_battvolt }, + { "ups.temperature", 0, NULL, "Q3\r", "", 71, '(', "", 37, 40, "%.1f", 0, NULL, NULL, NULL }, +/*!! report both ups.temperature and ambient.0.temperature?? */ + { "ambient.0.temperature", 0, NULL, "Q3\r", "", 71, '(', "", 37, 40, "%.1f", 0, NULL, NULL, NULL }, + { "battery.runtime", 0, NULL, "Q3\r", "", 71, '(', "", 42, 47, "%.0f", 0, NULL, NULL, masterguard_mmm_ss }, + { "battery.charge", 0, NULL, "Q3\r", "", 71, '(', "", 49, 51, "%.0f", 0, NULL, NULL, NULL }, + /* Status bits, first half (B) */ + { "ups.status", 0, NULL, "Q3\r", "", 71, '(', "", 53, 53, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, masterguard_status }, /* B7: Utility Fail */ + { "ups.status", 0, NULL, "Q3\r", "", 71, '(', "", 54, 54, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, masterguard_status }, /* B6: Battery Low */ + { "ups.status", 0, NULL, "Q3\r", "", 71, '(', "", 55, 55, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, masterguard_status }, /* B5: Bypass/Boost Active */ + { "ups.alarm", 0, NULL, "Q3\r", "", 71, '(', "", 56, 56, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, masterguard_status }, /* B4: UPS Failed */ + { "ups.type", 0, NULL, "Q3\r", "", 71, '(', "", 57, 57, NULL, QX_FLAG_STATIC, NULL, NULL, masterguard_status }, /* B3: UPS Type */ + { "ups.status", 0, NULL, "Q3\r", "", 71, '(', "", 58, 58, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, masterguard_status }, /* B2: Test in Progress */ + { "ups.status", 0, NULL, "Q3\r", "", 71, '(', "", 59, 59, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, masterguard_status }, /* B1: Shutdown Active */ + /* unused */ /* B0: unused */ + /* Status bits, second half (T) */ + /* unused */ /* T7: unused */ + { "ups.alarm", 0, NULL, "Q3\r", "", 69, '(', "", 63, 63, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, masterguard_status }, /* T6: problems in parallel operation mode */ + /* part of a parallel set */ /* T5: is part of a parallel set */ + { "ups.status", 0, NULL, "Q3\r", "", 71, '(', "", 65, 65, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, masterguard_status }, /* T4: Battery: end of service life */ + { "ups.alarm", 0, NULL, "Q3\r", "", 71, '(', "", 66, 66, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, masterguard_status }, /* T3: battery connected */ + { "ups.test.result", 0, NULL, "Q3\r", "", 71, '(', "", 67, 69, NULL, QX_FLAG_QUICK_POLL, NULL, NULL, masterguard_status }, /* T210: Test Status */ + + /* + * > [GS,XX\r] + * < [(XX,ii p a\r] + * 01234567890 + * 0 1 + * (00,00 0 1 + */ + /* type flags rw command answer len leading value from to dfl qxflags precmd preans preproc */ + /* ups.id obtained via WH */ + { "ups.id", 0, NULL, "SS%02d--,XX\r","", 0, '\0', "", 0, 0, "d", QX_FLAG_SETVAR | QX_FLAG_RANGE, masterguard_add_slaveaddr, masterguard_new_slaveaddr, masterguard_set_slaveaddr }, + { "battery.packs", ST_FLAG_RW, masterguard_r_batpacks, "GS,XX\r", "", 0, '(', "", 7, 7, "%.0f", QX_FLAG_SEMI_STATIC | QX_FLAG_RANGE, masterguard_add_slaveaddr, NULL, NULL }, + { "battery.packs", 0, NULL, "SS--%1d-,XX\r","", 0, '\0', "", 0, 0, "d", QX_FLAG_SETVAR | QX_FLAG_RANGE, masterguard_add_slaveaddr, NULL, masterguard_setvar }, +/*!! which QX_FLAGs to use?? (changed by instcmd) */ + { "ups.beeper.status", 0, NULL, "GS,XX\r", "", 11, '(', "", 9, 9, NULL, QX_FLAG_SEMI_STATIC, masterguard_add_slaveaddr, NULL, masterguard_beeper_status }, + /* set with beeper.{en,dis}able */ + + /* + * > [GBS,XX\r] + * < [(XX,CCC hhhh HHHH AAAA BBBB DDDD EEE SS.SS\r] + * 0123456789012345678901234567890123456789012 + * 0 1 2 3 4 + * (00,100 0017 0000 0708 0712 0994 115 02.28 + * (01,000 0000 0360 0708 0712 0994 076 02.30 + */ + /* type flags rw command answer len leading value from to dfl qxflags precmd preans preproc */ + { "battery.charge", 0, NULL, "GBS,XX\r", "", 43, '(', "", 4, 6, "%.0f", 0, masterguard_add_slaveaddr, NULL, NULL }, + /* + * hhhh: hold time (minutes) + * HHHH: recharge time to 90% (minutes) + * AAAA: Ageing factor (promilles) + * BBBB: Ageing factor time dependant (promilles) + * DDDD: Ageing factor cyclic use (promilles) + * EEE: Calibration factor (percent) + * SS.SS: Actual battery cell voltage + */ + + /* + * > [GSN,XX\r] + * < [(XX,SSN=SSSSSSSSSSSnnnnn\r] + * 0123456789012345678901234 + * 0 1 2 + * (00,SSN=6A1212 2782 + */ + /* type flags rw command answer len leading value from to dfl qxflags precmd preans preproc */ + { "device.part", 0, NULL, "GSN,XX\r", "", 25, '(', "", 8, 18, "%s", QX_FLAG_STATIC | QX_FLAG_TRIM, masterguard_add_slaveaddr, NULL, NULL }, + { "device.serial", 0, NULL, "GSN,XX\r", "", 25, '(', "", 20, 23, "%s", QX_FLAG_STATIC, masterguard_add_slaveaddr, NULL, NULL }, + + /* + * > [DRC,XX\r] + * < [(XX,TTTT:hh:mm:ss\r] + * 012345678901234567 + * 0 1 + * (00,1869:19:06:37 + */ + /* type flags rw command answer len leading value from to dfl qxflags precmd preans preproc */ + /* this is not really the uptime, but the running time since last maintenance */ + { "device.uptime", ST_FLAG_RW, NULL, "DRC,XX\r", "", 17, '(', "", 4, 16, "%.0f", QX_FLAG_SEMI_STATIC, masterguard_add_slaveaddr, NULL, masterguard_tttt_hh_mm_ss }, + { "device.uptime", 0, NULL, "SRC%s,XX\r", "", 0, '\0', "", 0, 0, "thms", QX_FLAG_SETVAR, masterguard_add_slaveaddr, NULL, masterguard_setvar }, + + /* + * > [MSO\r] + * < [(220 230 240\r] + * 0123456789012 + * 0 1 + * (220 230 240 + */ + /* type flags rw command answer len leading value from to dfl qxflags precmd preans preproc */ + { "experimental.output_voltages", 0, NULL, "MSO\r", "", 5, '(', "", 1, 0, "%s", QX_FLAG_STATIC | QX_FLAG_NONUT, NULL, NULL, masterguard_output_voltages }, + + /* + * > [PNV\r] + * < [(PNV=nnn\r] + * 012345678 + * 0 + * (PNV=230 + */ + /* type flags rw command answer len leading value from to dfl qxflags precmd preans preproc */ + { "output.voltage.nominal", ST_FLAG_RW, NULL /* see claim */, "PNV\r", "", 8, '(', "", 5, 7, "%.0f", QX_FLAG_SEMI_STATIC | QX_FLAG_ENUM, NULL, NULL, NULL }, + { "output.voltage.nominal", 0, NULL, "PNV=%03d\r", "", 0, '\0', "", 0, 0, "d", QX_FLAG_SETVAR, NULL, NULL, masterguard_setvar }, + { "output.current.nominal", 0, NULL, "PNV\r", "", 8, '(', "", 5, 7, "%.0f", QX_FLAG_SEMI_STATIC, NULL, NULL, masterguard_output_current_nominal }, + + /* + * > [FLT,XX\r] + * < [(XX,A aaaa TTTT:hh:mm:ss B bbbb TTTT:hh:mm:ss C cccc TTTT:hh:mm:ss D dddd TTTT:hh:mm:ss E eeee TTTT:hh:mm:ss\r + * 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678 + * 0 1 2 3 4 5 6 7 8 9 0 + * (00,7 0043 0000:16:48:06 0 0000 0000:00:00:00 0 0000 0000:00:00:00 0 0000 0000:00:00:00 0 0000 0000:00:00:00 + * (01,9 0010 1780:14:57:19 7 0046 0000:21:14:41 0 0000 0000:00:00:00 0 0000 0000:00:00:00 0 0000 0000:00:00:00 + */ + /* type flags rw command answer len leading value from to dfl qxflags precmd preans preproc */ + { "experimental.fault_1", 0, NULL, "FLT,XX\r", "", 108, '(', "", 4, 23, "%s", QX_FLAG_NONUT, masterguard_add_slaveaddr, NULL, masterguard_fault }, + { "experimental.fault_2", 0, NULL, "FLT,XX\r", "", 108, '(', "", 25, 44, "%s", QX_FLAG_NONUT, masterguard_add_slaveaddr, NULL, masterguard_fault }, + { "experimental.fault_3", 0, NULL, "FLT,XX\r", "", 108, '(', "", 46, 65, "%s", QX_FLAG_NONUT, masterguard_add_slaveaddr, NULL, masterguard_fault }, + { "experimental.fault_4", 0, NULL, "FLT,XX\r", "", 108, '(', "", 67, 86, "%s", QX_FLAG_NONUT, masterguard_add_slaveaddr, NULL, masterguard_fault }, + { "experimental.fault_5", 0, NULL, "FLT,XX\r", "", 108, '(', "", 88, 107, "%s", QX_FLAG_NONUT, masterguard_add_slaveaddr, NULL, masterguard_fault }, + + + /* instant commands */ + /* type flags rw command answer len leading value from to dfl qxflags precmd preans preproc */ +/*!! what's the difference between load.off.delay and shutdown.stayoff?? */ +#if 0 + { "load.off", 0, NULL, "S.0\r", "", 0, '\0', "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + { "load.on", 0, NULL, "C\r", "", 0, '\0', "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + /* load.off.delay */ + /* load.on.delay */ +#endif + { "shutdown.return", 0, NULL, NULL, "", 0, '\0', "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, masterguard_shutdown_return }, + { "shutdown.stayoff", 0, NULL, NULL, "", 0, '\0', "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, masterguard_shutdown_stayoff }, + { "shutdown.stop", 0, NULL, "C\r", "", 0, '\0', "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + /* shutdown.reboot */ + /* shutdown.reboot.graceful */ + /* test.panel.start */ + /* test.panel.stop */ + /* test.failure.start */ + /* test.failure.stop */ + { "test.battery.start", 0, NULL, NULL, "", 0, '\0', "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, masterguard_test_battery }, + { "test.battery.start.quick", 0, NULL, "T\r", "", 0, '\0', "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + { "test.battery.start.deep", 0, NULL, "TUD\r", "", 0, '\0', "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + { "test.battery.stop", 0, NULL, "CT\r", "", 0, '\0', "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + /* test.system.start */ + /* calibrate.start */ + /* calibrate.stop */ + { "bypass.start", 0, NULL, "FOFF\r", "", 0, '\0', "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + { "bypass.stop", 0, NULL, "FON\r", "", 0, '\0', "", 0, 0, NULL, QX_FLAG_CMD, NULL, NULL, NULL }, + /* reset.input.minmax */ + /* reset.watchdog */ + { "beeper.enable", 0, NULL, "SS---1,XX\r", "", 0, '\0', "", 0, 0, NULL, QX_FLAG_CMD, masterguard_add_slaveaddr, NULL, NULL }, + { "beeper.disable", 0, NULL, "SS---0,XX\r", "", 0, '\0', "", 0, 0, NULL, QX_FLAG_CMD, masterguard_add_slaveaddr, NULL, NULL }, + /* beeper.mute */ + /* beeper.toggle */ + /* outlet.* */ + + + /* server variables */ + /* type flags rw command answer len leading value from to dfl qxflags precmd preans preproc */ + { "ups.delay.shutdown", ST_FLAG_RW, masterguard_r_offdelay, NULL, "", 0, '\0', "", 0, 0, DEFAULT_OFFDELAY, QX_FLAG_ABSENT | QX_FLAG_SETVAR | QX_FLAG_RANGE, NULL, NULL, NULL }, + { "ups.delay.start", ST_FLAG_RW, masterguard_r_ondelay, NULL, "", 0, '\0', "", 0, 0, DEFAULT_ONDELAY, QX_FLAG_ABSENT | QX_FLAG_SETVAR | QX_FLAG_RANGE, NULL, NULL, NULL }, + + + /* end marker */ + { NULL, 0, NULL, NULL, "", 0, 0, "", 0, 0, NULL, 0, NULL, NULL, NULL } +}; + + +/*!! todo + +untested: +Sxx (.n/nn) +C after S.0 + +unused: +>G01,00 +(00,00000 + +additional E series commands: +PSR +BUS* +V +INVDC + +use ups.{delay,timer}.{start,reboot,shutdown}? +report ups.contacts? +how to report battery.charger.status? +set battery.packs.bad? + +how to report battery aeging/run time? +how to report nominal hold time at half/full load? + +*/ + + +/* commands supported by A series */ +static char *masterguard_commands_a[] = { + "Q", "Q1", "Q3", "T", "TL", "S", "C", "CT", "WH", "M", "N", "O", "DECO", "DRC", "SRC", "FLT", "FCLR", "G", "SS", "GS", "MSO", "PNV", "FOFF", "FON", "TUD", "GBS", "SSN", "GSN", NULL +}; + +/* commands supported by E series */ +static char *masterguard_commands_e[] = { + "Q", "Q1", "Q3", "PSR", "T", "TL", "S", "C", "CT", "WH", "DRC", "SRC", "FLT", "FCLR", "SS", "GS", "MSO", "PNV", "FOFF", "FON", "TUD", "GBS", "SSN", "GSN", "BUS", "V", "INVDC", "BUSP", "BUSN", NULL +}; + +/* claim function. fetch some mandatory values, + * disable unsupported commands, + * set enum for supported output voltages */ +static int masterguard_claim(void) { + item_t *item; + /* mandatory values */ + char *mandatory[] = { + "series", /* SKIP */ + "device.model", /* minimal number of battery packs */ + "ups.power.nominal", /* load computation */ + "ups.id", /* slave address */ + "output_voltages", /* output voltages enum */ +#if 0 + "battery.packs", /* battery voltage computation */ +#endif + NULL + }; + char **sp; + long config_slaveaddr; + char *sa; + char **commands; + + if ((sa = getval("slave_address")) != NULL) { + char *p; + + if (*sa == '\0') { + upsdebugx(2, "claim: empty slave_address"); + return 0; + } + config_slaveaddr = strtol(sa, &p, 10); + if (*p != '\0' || config_slaveaddr < 0 || config_slaveaddr > 99) { + upsdebugx(2, "claim: illegal slave_address %s", sa); + return 0; + } + } else { + config_slaveaddr = -1; + } + for (sp = mandatory; *sp != NULL; sp++) { + char value[SMALLBUF] = ""; + + if ((item = find_nut_info(*sp, 0, QX_FLAG_SETVAR)) == NULL) { + upsdebugx(2, "claim: cannot find %s", *sp); + return 0; + } + /* since qx_process_answer() is not exported, there's no way + * to avoid sending the same command to the UPS again */ + if (qx_process(item, NULL) < 0) { + upsdebugx(2, "claim: cannot process %s", *sp); + return 0; + } + /* only call the preprocess function; don't call ups_infoval_set() + * because that does a dstate_setinfo() before dstate_setflags() + * is called (via qx_set_var() in qx_ups_walk() with QX_WALKMODE_INIT); + * that leads to r/w vars ending up r/o. */ + if (item->preprocess == NULL ) { + upsdebugx(2, "claim: no preprocess function for %s", *sp); + return 0; + } + if (item->preprocess(item, value, sizeof value)) { + upsdebugx(2, "claim: failed to preprocess %s", *sp); + return 0; + } + } + + if (config_slaveaddr >= 0 && config_slaveaddr != strtol(masterguard_my_slaveaddr, NULL, 10)) { + upsdebugx(2, "claim: slave address mismatch: want %02ld, have %s", config_slaveaddr, masterguard_my_slaveaddr); + return 0; + } + + switch (masterguard_my_series) { + case 'A': + commands = masterguard_commands_a; + break; + case 'E': + commands = masterguard_commands_e; + break; + default: + return 0; + } + + /* set SKIP flag for unimplemented commands */ + for (item = masterguard_qx2nut; item->info_type != NULL; item++) { + int match = 0; + if (item->command == NULL || item->command[0] == '\0') continue; + for (sp = commands; sp != NULL; sp++) { + const char *p = *sp, *q = item->command; + + while (1) { + if (*p == '\0' && (*q < 'A' || *q > 'Z')) { + match = 1; break; + } else if (*p == '\0' || *q < 'A' || *q > 'Z' || *p != *q) { + match = 0; break; + } + p++; q++; + } + if (match) break; + } + if (nut_debug_level >= 3) { + char cmd[10]; + char *p = cmd; const char *q = item->command; + while (*q >= 'A' && *q <= 'Z') { + *p++ = *q++; + if (p - cmd >= (ptrdiff_t)sizeof cmd - 1) break; + } + *p++ = '\0'; + upsdebugx(3, "command %s %simplemented", cmd, match ? "" : "NOT "); + + } + if (!match) + item->qxflags |= QX_FLAG_SKIP; + } + + /* set enum for output.voltage.nominal */ + if ((item = find_nut_info("output.voltage.nominal", QX_FLAG_ENUM, QX_FLAG_SETVAR)) == NULL) { + upsdebugx(2, "claim: cannot find output.voltage.nominal"); + return 0; + } + item->info_rw = masterguard_e_outvolts; + + return 1; +} + + +static void masterguard_makevartable(void) { + addvar(VAR_VALUE, "series", "Series (A/E)"); + addvar(VAR_VALUE, "slave_address", "Slave address (UPS id) to match"); + addvar(VAR_VALUE, "input_fault_voltage", "Input fault voltage (whatever that means)"); + addvar(VAR_VALUE, "number_of_battery_cells", "Number of battery cells in series"); + addvar(VAR_VALUE, "nominal_cell_voltage", "Nominal battery cell voltage"); + addvar(VAR_VALUE, "runtime_half", "Nominal battery run time at 50% load (seconds)"); + addvar(VAR_VALUE, "runtime_full", "Nominal battery run time at 100% load (seconds)"); + addvar(VAR_VALUE, "recharge_time", "Nominal battery recharge time to 95% capacity (seconds)"); + addvar(VAR_VALUE, "output_voltages", "Possible output voltages (volts)"); + addvar(VAR_VALUE, "fault_1", "Fault record 1 (newest)"); + addvar(VAR_VALUE, "fault_2", "Fault record 2"); + addvar(VAR_VALUE, "fault_3", "Fault record 3"); + addvar(VAR_VALUE, "fault_4", "Fault record 4"); + addvar(VAR_VALUE, "fault_5", "Fault record 5 (oldest)"); +} + + +#ifdef TESTING +static testing_t masterguard_testing[] = { + { NULL } +}; +#endif /* TESTING */ + +subdriver_t masterguard_subdriver = { + MASTERGUARD_VERSION, + masterguard_claim, + masterguard_qx2nut, + NULL, /* initups */ + NULL, /* intinfo */ + masterguard_makevartable, + NULL, /* accepted */ + NULL, /* rejected */ +#ifdef TESTING + masterguard_testing, +#endif /* TESTING */ +}; diff --git a/drivers/nutdrv_qx_masterguard.h b/drivers/nutdrv_qx_masterguard.h new file mode 100644 index 0000000..71b7f95 --- /dev/null +++ b/drivers/nutdrv_qx_masterguard.h @@ -0,0 +1,29 @@ +/* nutdrv_qx_masterguard.h - Subdriver for Masterguard A/E Series + * + * Copyright (C) + * 2020-2021 Edgar Fuß + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version, or a 2-clause BSD License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef NUTDRV_QX_MASTERGUARD_H +#define NUTDRV_QX_MASTERGUARD_H + +#include "nutdrv_qx.h" + +extern subdriver_t masterguard_subdriver; + +#endif /* NUTDRV_QX_MASTERGUARD_H */ diff --git a/drivers/nutdrv_qx_mecer.c b/drivers/nutdrv_qx_mecer.c index 2e2bacf..d044f33 100644 --- a/drivers/nutdrv_qx_mecer.c +++ b/drivers/nutdrv_qx_mecer.c @@ -215,7 +215,19 @@ static int voltronic_p98_protocol(item_t *item, char *value, const size_t valuel return -1; } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, "Voltronic Power P98"); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif return 0; } @@ -225,7 +237,7 @@ static int mecer_process_test_battery(item_t *item, char *value, const size_t va { const char *protocol = dstate_getinfo("ups.firmware.aux"); char buf[SMALLBUF] = ""; - int min, test_time; + long min, test_time; /* Voltronic P98 units -> Accepted values for test time: .2 -> .9 (.2=12sec ..), 01 -> 99 (minutes) -> range = [12..5940] */ if (protocol && !strcasecmp(protocol, "Voltronic Power P98")) @@ -239,10 +251,12 @@ static int mecer_process_test_battery(item_t *item, char *value, const size_t va return -1; } - test_time = strlen(value) > 0 ? strtol(value, NULL, 10) : 600; + test_time = (strlen(value) > 0) ? strtol(value, NULL, 10) : 600; if ((test_time < min) || (test_time > 5940)) { - upslogx(LOG_ERR, "%s: battery test time '%d' out of range [%d..5940] seconds", item->info_type, test_time, min); + upslogx(LOG_ERR, + "%s: battery test time '%ld' out of range [%ld..5940] seconds", + item->info_type, test_time, min); return -1; } @@ -250,17 +264,29 @@ static int mecer_process_test_battery(item_t *item, char *value, const size_t va if (test_time < 60) { test_time = test_time / 6; - snprintf(buf, sizeof(buf), ".%d", test_time); + snprintf(buf, sizeof(buf), ".%ld", test_time); /* test time > 1 minute */ } else { test_time = test_time / 60; - snprintf(buf, sizeof(buf), "%02d", test_time); + snprintf(buf, sizeof(buf), "%02ld", test_time); } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->command, buf); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif return 0; } diff --git a/drivers/nutdrv_qx_q1.c b/drivers/nutdrv_qx_q1.c index bf3e253..08073bc 100644 --- a/drivers/nutdrv_qx_q1.c +++ b/drivers/nutdrv_qx_q1.c @@ -20,7 +20,7 @@ * NOTE: * This subdriver implements the same protocol as the one used by the 'megatec' subdriver minus the vendor (I) and ratings (F) queries. * In the claim function: - * - it doesn't even try to get 'vendor' informations (I) + * - it doesn't even try to get 'vendor' information (I) * - it checks only status (Q1), through 'input.voltage' variable * Therefore it should be able to work even if the UPS doesn't support vendor/ratings *and* the user doesn't use the 'novendor'/'norating' flags, as long as: * - the UPS replies a Q1-compliant answer (i.e. not necessary filled with all of the Q1-required data, but at least of the right length and with not available data filled with some replacement character) diff --git a/drivers/nutdrv_qx_q1.h b/drivers/nutdrv_qx_q1.h index bad2f13..d990ef7 100644 --- a/drivers/nutdrv_qx_q1.h +++ b/drivers/nutdrv_qx_q1.h @@ -20,7 +20,7 @@ * NOTE: * This subdriver implements the same protocol as the one used by the 'megatec' subdriver minus the vendor (I) and ratings (F) queries. * In the claim function: - * - it doesn't even try to get 'vendor' informations (I) + * - it doesn't even try to get 'vendor' information (I) * - it checks only status (Q1), through 'input.voltage' variable * Therefore it should be able to work even if the UPS doesn't support vendor/ratings *and* the user doesn't use the 'novendor'/'norating' flags, as long as: * - the UPS replies a Q1-compliant answer (i.e. not necessary filled with all of the Q1-required data, but at least of the right length and with not available data filled with some replacement character) diff --git a/drivers/nutdrv_qx_voltronic-qs-hex.c b/drivers/nutdrv_qx_voltronic-qs-hex.c index 6b21acd..9485fe0 100644 --- a/drivers/nutdrv_qx_voltronic-qs-hex.c +++ b/drivers/nutdrv_qx_voltronic-qs-hex.c @@ -207,7 +207,7 @@ static int voltronic_qs_hex_preprocess_qs_answer(item_t *item, const int len) snprintf(refined, sizeof(refined), "%s", "#"); /* e.g.: item->answer = "#\x6C\x01 \x35 \x6C\x01 \x35 \x03 \x51\x9A \x28\x02\x12\xD0 \xE6 \x1E \x09\r" */ - upsdebug_hex(4, "read", item->answer, len); + upsdebug_hex(4, "read", item->answer, (size_t)len); for (i = 1, token = 1; i < len; i++) { @@ -219,7 +219,7 @@ static int voltronic_qs_hex_preprocess_qs_answer(item_t *item, const int len) } /* 'Unescape' raw data */ - if (item->answer[i] == 0x28 && i < len) { + if (i < len && item->answer[i] == 0x28) { switch (item->answer[i + 1]) { @@ -323,7 +323,19 @@ static int voltronic_qs_hex_protocol(item_t *item, char *value, const size_t val return -1; } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, item->value); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif /* Unskip items supported only by devices that implement 'T' protocol */ @@ -344,7 +356,7 @@ static int voltronic_qs_hex_protocol(item_t *item, char *value, const size_t val /* Input/Output voltage */ static int voltronic_qs_hex_input_output_voltage(item_t *item, char *value, const size_t valuelen) { - int val; + long val; double ret; char *str_end; @@ -356,7 +368,19 @@ static int voltronic_qs_hex_input_output_voltage(item_t *item, char *value, cons val = strtol(item->value, &str_end, 16) * strtol(str_end, NULL, 16) / 51; ret = val / 256.0; +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, ret); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif return 0; } @@ -369,7 +393,19 @@ static int voltronic_qs_hex_load(item_t *item, char *value, const size_t valuele return -1; } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, strtol(item->value, NULL, 16)); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif return 0; } @@ -391,7 +427,19 @@ static int voltronic_qs_hex_frequency(item_t *item, char *value, const size_t va ret = val2 / val1; ret = ret > 99.9 ? 99.9 : ret; +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, ret); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif return 0; } @@ -399,7 +447,7 @@ static int voltronic_qs_hex_frequency(item_t *item, char *value, const size_t va /* Battery voltage */ static int voltronic_qs_hex_battery_voltage(item_t *item, char *value, const size_t valuelen) { - int val1, val2; + long val1, val2; char *str_end; if (strspn(item->value, "0123456789ABCDEFabcdef ") != strlen(item->value)) { @@ -410,7 +458,19 @@ static int voltronic_qs_hex_battery_voltage(item_t *item, char *value, const siz val1 = strtol(item->value, &str_end, 16); val2 = strtol(str_end, NULL, 16); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, (val1 * val2) / 510.0); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif return 0; } @@ -418,7 +478,7 @@ static int voltronic_qs_hex_battery_voltage(item_t *item, char *value, const siz /* Ratings bits */ static int voltronic_qs_hex_process_ratings_bits(item_t *item, char *value, const size_t valuelen) { - int val; + long val; double ret; if (strspn(item->value, "01") != strlen(item->value)) { @@ -478,7 +538,19 @@ static int voltronic_qs_hex_process_ratings_bits(item_t *item, char *value, cons return -1; } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, ret); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif return 0; } diff --git a/drivers/nutdrv_qx_voltronic-qs.c b/drivers/nutdrv_qx_voltronic-qs.c index 4437925..43df438 100644 --- a/drivers/nutdrv_qx_voltronic-qs.c +++ b/drivers/nutdrv_qx_voltronic-qs.c @@ -196,7 +196,19 @@ static int voltronic_qs_protocol(item_t *item, char *value, const size_t valuele return -1; } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, item->value); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif return 0; } diff --git a/drivers/nutdrv_qx_voltronic.c b/drivers/nutdrv_qx_voltronic.c index 3ab33a6..8e2f2ad 100644 --- a/drivers/nutdrv_qx_voltronic.c +++ b/drivers/nutdrv_qx_voltronic.c @@ -20,8 +20,9 @@ */ #include "main.h" +#include "nut_float.h" +#include "nut_stdint.h" #include "nutdrv_qx.h" - #include "nutdrv_qx_voltronic.h" #define VOLTRONIC_VERSION "Voltronic 0.06" @@ -29,7 +30,7 @@ /* Support functions */ static int voltronic_claim(void); static void voltronic_makevartable(void); -static void voltronic_massive_unskip(const int protocol); +static void voltronic_massive_unskip(const long protocol); /* Range/enum functions */ static int voltronic_batt_low(char *value, const size_t len); @@ -86,7 +87,7 @@ static char *bypass_alarm, *limited_runtime_on_battery; /* ups.conf settings */ -static int max_bypass_volt, +static long max_bypass_volt, min_bypass_volt, battery_number, output_phase_angle, @@ -131,9 +132,10 @@ static info_rw_t voltronic_r_batt_low[] = { /* Preprocess range value for battery low voltage */ static int voltronic_batt_low(char *value, const size_t len) { - int val = strtol(value, NULL, 10); + long val = strtol(value, NULL, 10); const char *ovn = dstate_getinfo("output.voltage.nominal"), *ocn = dstate_getinfo("output.current.nominal"); + NUT_UNUSED_VARIABLE(len); if (!ovn || !ocn) { upsdebugx(2, "%s: unable to get the value of output voltage nominal/output current nominal", __func__); @@ -211,10 +213,11 @@ static info_rw_t voltronic_r_bypass_volt_max[] = { /* Preprocess range value for Bypass Mode maximum voltage */ static int voltronic_bypass_volt_max(char *value, const size_t len) { - int protocol = strtol(dstate_getinfo("ups.firmware.aux")+1, NULL, 10), + long protocol = strtol(dstate_getinfo("ups.firmware.aux")+1, NULL, 10), val = strtol(value, NULL, 10), ivn; const char *involtnom = dstate_getinfo("input.voltage.nominal"); + NUT_UNUSED_VARIABLE(len); if (!involtnom) { upsdebugx(2, "%s: unable to get input.voltage.nominal", __func__); @@ -267,7 +270,7 @@ static int voltronic_bypass_volt_max(char *value, const size_t len) if (ivn >= 200) return -1; - if (protocol == 2 || protocol == 2 || protocol == 10 || protocol == 13 || protocol == 14) + if (protocol == 2 || protocol == 3 || protocol == 10 || protocol == 13 || protocol == 14) return 0; break; @@ -300,7 +303,7 @@ static int voltronic_bypass_volt_max(char *value, const size_t len) if (ivn < 200) return -1; - if (protocol == 2 || protocol == 2 || protocol == 10 || protocol == 13 || protocol == 14 || protocol == 99) + if (protocol == 2 || protocol == 3 || protocol == 10 || protocol == 13 || protocol == 14 || protocol == 99) return 0; break; @@ -365,10 +368,11 @@ static info_rw_t voltronic_r_bypass_volt_min[] = { /* Preprocess range value for Bypass Mode minimum voltage */ static int voltronic_bypass_volt_min(char *value, const size_t len) { - int protocol = strtol(dstate_getinfo("ups.firmware.aux")+1, NULL, 10), + long protocol = strtol(dstate_getinfo("ups.firmware.aux")+1, NULL, 10), val = strtol(value, NULL, 10), ivn; const char *involtnom = dstate_getinfo("input.voltage.nominal"); + NUT_UNUSED_VARIABLE(len); if (!involtnom) { upsdebugx(2, "%s: unable to get input.voltage.nominal", __func__); @@ -394,7 +398,7 @@ static int voltronic_bypass_volt_min(char *value, const size_t len) if (ivn >= 200) return -1; - if (protocol == 2 || protocol == 3 || protocol == 10 || protocol == 10 || protocol == 13 || protocol == 14) + if (protocol == 2 || protocol == 3 || protocol == 10 || protocol == 13 || protocol == 14) return 0; break; @@ -511,10 +515,11 @@ static info_rw_t voltronic_r_bypass_freq_max[] = { /* Preprocess range value for Bypass Mode maximum frequency */ static int voltronic_bypass_freq_max(char *value, const size_t len) { - int protocol = strtol(dstate_getinfo("ups.firmware.aux")+1, NULL, 10), + long protocol = strtol(dstate_getinfo("ups.firmware.aux")+1, NULL, 10), val = strtol(value, NULL, 10); double ofn; const char *outfreqnom = dstate_getinfo("output.frequency.nominal"); + NUT_UNUSED_VARIABLE(len); if (!outfreqnom) { upsdebugx(2, "%s: unable to get output.frequency.nominal", __func__); @@ -609,10 +614,11 @@ static info_rw_t voltronic_r_bypass_freq_min[] = { /* Preprocess range value for Bypass Mode minimum frequency */ static int voltronic_bypass_freq_min(char *value, const size_t len) { - int protocol = strtol(dstate_getinfo("ups.firmware.aux")+1, NULL, 10), + long protocol = strtol(dstate_getinfo("ups.firmware.aux")+1, NULL, 10), val = strtol(value, NULL, 10); double ofn; const char *outfreqnom = dstate_getinfo("output.frequency.nominal"); + NUT_UNUSED_VARIABLE(len); if (!outfreqnom) { upsdebugx(2, "%s: unable to get output.frequency.nominal", __func__); @@ -723,10 +729,11 @@ static info_rw_t voltronic_r_eco_freq_min[] = { /* Preprocess range value for ECO Mode minimum frequency */ static int voltronic_eco_freq_min(char *value, const size_t len) { - int protocol = strtol(dstate_getinfo("ups.firmware.aux")+1, NULL, 10), + long protocol = strtol(dstate_getinfo("ups.firmware.aux")+1, NULL, 10), val = strtol(value, NULL, 10); double ofn; const char *outfreqnom = dstate_getinfo("output.frequency.nominal"); + NUT_UNUSED_VARIABLE(len); if (!outfreqnom) { upsdebugx(2, "%s: unable to get output.frequency.nominal", __func__); @@ -843,10 +850,11 @@ static info_rw_t voltronic_r_eco_freq_max[] = { /* Preprocess range value for ECO Mode maximum frequency */ static int voltronic_eco_freq_max(char *value, const size_t len) { - int protocol = strtol(dstate_getinfo("ups.firmware.aux")+1, NULL, 10), + long protocol = strtol(dstate_getinfo("ups.firmware.aux")+1, NULL, 10), val = strtol(value, NULL, 10); double ofn; const char *outfreqnom = dstate_getinfo("output.frequency.nominal"); + NUT_UNUSED_VARIABLE(len); if (!outfreqnom) { upsdebugx(2, "%s: unable to get output.frequency.nominal", __func__); @@ -1749,7 +1757,7 @@ static void voltronic_makevartable(void) } /* Unskip vars according to protocol used by the UPS */ -static void voltronic_massive_unskip(const int protocol) +static void voltronic_massive_unskip(const long protocol) { item_t *item; @@ -1878,42 +1886,54 @@ static int voltronic_process_setvar(item_t *item, char *value, const size_t valu } else if (!strcasecmp(item->info_type, "max_bypass_freq")) { - if (val == max_bypass_freq) { + if (d_equal(val, max_bypass_freq)) { upslogx(LOG_INFO, "%s is already set to %.1f", item->info_type, val); return -1; } } else if (!strcasecmp(item->info_type, "min_bypass_freq")) { - if (val == min_bypass_freq) { + if (d_equal(val, min_bypass_freq)) { upslogx(LOG_INFO, "%s is already set to %.1f", item->info_type, val); return -1; } } else if (!strcasecmp(item->info_type, "max_bypass_volt")) { - if (val == max_bypass_volt) { + if (d_equal(val, max_bypass_volt)) { upslogx(LOG_INFO, "%s is already set to %.0f", item->info_type, val); return -1; } } else if (!strcasecmp(item->info_type, "min_bypass_volt")) { - if (val == min_bypass_volt) { + if (d_equal(val, min_bypass_volt)) { upslogx(LOG_INFO, "%s is already set to %.0f", item->info_type, val); return -1; } } else if (!strcasecmp(item->info_type, "battery_number")) { - if (val == battery_number) { + if (d_equal(val, battery_number)) { upslogx(LOG_INFO, "%s is already set to %.0f", item->info_type, val); return -1; } } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->command, val); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif return 0; } @@ -1930,24 +1950,24 @@ static int voltronic_process_command(item_t *item, char *value, const size_t val * Accepted values for n: .2 -> .9 , 01 -> 99 * Accepted values for m: 0001 -> 9999 */ - int offdelay = strtol(dstate_getinfo("ups.delay.shutdown"), NULL, 10), - ondelay = strtol(dstate_getinfo("ups.delay.start"), NULL, 10) / 60; + long offdelay = strtol(dstate_getinfo("ups.delay.shutdown"), NULL, 10), + ondelay = strtol(dstate_getinfo("ups.delay.start"), NULL, 10) / 60; if (ondelay == 0) { if (offdelay < 60) { - snprintf(buf, sizeof(buf), ".%d", offdelay / 6); + snprintf(buf, sizeof(buf), ".%ld", offdelay / 6); } else { - snprintf(buf, sizeof(buf), "%02d", offdelay / 60); + snprintf(buf, sizeof(buf), "%02ld", offdelay / 60); } } else if (offdelay < 60) { - snprintf(buf, sizeof(buf), ".%dR%04d", offdelay / 6, ondelay); + snprintf(buf, sizeof(buf), ".%ldR%04ld", offdelay / 6, ondelay); } else { - snprintf(buf, sizeof(buf), "%02dR%04d", offdelay / 60, ondelay); + snprintf(buf, sizeof(buf), "%02ldR%04ld", offdelay / 60, ondelay); } @@ -1957,12 +1977,12 @@ static int voltronic_process_command(item_t *item, char *value, const size_t val * Shutdown after n minutes and stay off * Accepted values for n: .2 -> .9 , 01 -> 99 */ - int offdelay = strtol(dstate_getinfo("ups.delay.shutdown"), NULL, 10); + long offdelay = strtol(dstate_getinfo("ups.delay.shutdown"), NULL, 10); if (offdelay < 60) { - snprintf(buf, sizeof(buf), ".%d", offdelay / 6); + snprintf(buf, sizeof(buf), ".%ld", offdelay / 6); } else { - snprintf(buf, sizeof(buf), "%02d", offdelay / 60); + snprintf(buf, sizeof(buf), "%02ld", offdelay / 60); } } else if (!strcasecmp(item->info_type, "test.battery.start")) { @@ -1970,17 +1990,21 @@ static int voltronic_process_command(item_t *item, char *value, const size_t val /* Accepted values for test time: .2 -> .9 (.2=12sec ..), 01 -> 99 (minutes) * -> you have to invoke test.battery.start + number of seconds [12..5940] */ - int delay; + long delay; if (strlen(value) != strspn(value, "0123456789")) { - upslogx(LOG_ERR, "%s: non numerical value [%s]", item->info_type, value); + upslogx(LOG_ERR, + "%s: non numerical value [%s]", + item->info_type, value); return -1; } - delay = strlen(value) > 0 ? strtol(value, NULL, 10) : 600; + delay = (strlen(value) > 0) ? strtol(value, NULL, 10) : 600; if ((delay < 12) || (delay > 5940)) { - upslogx(LOG_ERR, "%s: battery test time '%d' out of range [12..5940] seconds", item->info_type, delay); + upslogx(LOG_ERR, + "%s: battery test time '%ld' out of range [12..5940] seconds", + item->info_type, delay); return -1; } @@ -1988,13 +2012,13 @@ static int voltronic_process_command(item_t *item, char *value, const size_t val if (delay < 60) { delay = delay / 6; - snprintf(buf, sizeof(buf), ".%d", delay); + snprintf(buf, sizeof(buf), ".%ld", delay); /* test time > 1 minute */ } else { delay = delay / 60; - snprintf(buf, sizeof(buf), "%02d", delay); + snprintf(buf, sizeof(buf), "%02ld", delay); } @@ -2045,7 +2069,19 @@ static int voltronic_process_command(item_t *item, char *value, const size_t val } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->command, buf); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif return 0; } @@ -2360,7 +2396,19 @@ static int voltronic_capability(item_t *item, char *value, const size_t valuelen if (!val) return -1; +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, val); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif /* This item doesn't have a NUT var and we were not asked by the user to change its value */ if ((item->qxflags & QX_FLAG_NONUT) && !getval(item->info_type)) @@ -2381,6 +2429,15 @@ static int voltronic_capability(item_t *item, char *value, const size_t valuelen /* *SETVAR* Set UPS capability options */ static int voltronic_capability_set(item_t *item, char *value, const size_t valuelen) { +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif if (!strcasecmp(value, "yes")) { snprintf(value, valuelen, item->command, "E"); return 0; @@ -2390,6 +2447,9 @@ static int voltronic_capability_set(item_t *item, char *value, const size_t valu snprintf(value, valuelen, item->command, "D"); return 0; } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif /* At this point value should have been already checked against enum so this shouldn't happen.. however.. */ upslogx(LOG_ERR, "%s: given value [%s] is not acceptable. Enter either 'yes' or 'no'.", item->info_type, value); @@ -2418,7 +2478,7 @@ static int voltronic_capability_set_nonut(item_t *item, char *value, const size_ { "advanced_eco_mode", advanced_eco_mode }, { "constant_phase_angle", constant_phase_angle }, { "limited_runtime_on_battery", limited_runtime_on_battery }, - { NULL } + { NULL, NULL } }; for (i = 0; capability[i].type; i++) { @@ -2442,6 +2502,15 @@ static int voltronic_capability_set_nonut(item_t *item, char *value, const size_ return -1; } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif if (!strcasecmp(value, "disabled")) { snprintf(value, valuelen, item->command, "D"); } else if (!strcasecmp(value, "enabled")) { @@ -2451,6 +2520,9 @@ static int voltronic_capability_set_nonut(item_t *item, char *value, const size_ upslogx(LOG_ERR, "%s: [%s] is not within acceptable values [enabled/disabled]", item->info_type, value); return -1; } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif return 0; } @@ -2463,8 +2535,11 @@ static int voltronic_capability_reset(item_t *item, char *value, const size_t va return -1; /* UPS capability options can be reset only when the UPS is in 'Standby Mode' (=OFF) (from QMOD) */ - if (!(qx_status() & STATUS(OFF))) { - upslogx(LOG_ERR, "%s: UPS capability options can be reset only when the UPS is in Standby Mode (i.e. ups.status = 'OFF').", item->info_type); + if (!((unsigned int)(qx_status()) & STATUS(OFF))) { + upslogx(LOG_ERR, + "%s: UPS capability options can be reset only when the " + "UPS is in Standby Mode (i.e. ups.status = 'OFF').", + item->info_type); return -1; } @@ -2476,8 +2551,8 @@ static int voltronic_capability_reset(item_t *item, char *value, const size_t va /* Voltage limits for ECO Mode */ static int voltronic_eco_volt(item_t *item, char *value, const size_t valuelen) { - const int protocol = strtol(dstate_getinfo("ups.firmware.aux")+1, NULL, 10); - int ovn; + const long protocol = strtol(dstate_getinfo("ups.firmware.aux")+1, NULL, 10); + int ovn; const char *outvoltnom; char buf[SMALLBUF]; item_t *unskip; @@ -2493,11 +2568,25 @@ static int voltronic_eco_volt(item_t *item, char *value, const size_t valuelen) } min; if (strspn(item->value, "0123456789 .") != strlen(item->value)) { - upsdebugx(2, "%s: non numerical value [%s: %s]", __func__, item->info_type, item->value); + upsdebugx(2, + "%s: non numerical value [%s: %s]", + __func__, item->info_type, item->value); return -1; } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, strtod(item->value, NULL)); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif outvoltnom = dstate_getinfo("output.voltage.nominal"); @@ -2508,7 +2597,15 @@ static int voltronic_eco_volt(item_t *item, char *value, const size_t valuelen) return 0; } - ovn = strtol(outvoltnom, NULL, 10); + { /* scoping */ + long l = strtol(outvoltnom, NULL, 10); + if (l > INT_MAX || l < 0) { + /* See comments above */ + upsdebugx(2, "%s: unable to get output voltage nominal: %ld", __func__, l); + return 0; + } + ovn = (int)l; + } /* For P01/P09 */ if (protocol == 1 || protocol == 9) { @@ -2655,7 +2752,19 @@ static int voltronic_eco_freq(item_t *item, char *value, const size_t valuelen) return -1; } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, strtod(item->value, NULL)); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif /* Unskip input.transfer.{high,low} setvar */ unskip = find_nut_info(item->info_type, QX_FLAG_SETVAR, 0); @@ -2703,7 +2812,19 @@ static int voltronic_bypass(item_t *item, char *value, const size_t valuelen) } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, val); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif /* No user-provided value to change.. */ if (!getval(item->info_type)) @@ -2727,13 +2848,32 @@ static int voltronic_batt_numb(item_t *item, char *value, const size_t valuelen) item_t *unskip; if (strspn(item->value, "0123456789 .") != strlen(item->value)) { - upsdebugx(2, "%s: non numerical value [%s: %s]", __func__, item->info_type, item->value); + upsdebugx(2, "%s: non numerical value [%s: %s]", + __func__, item->info_type, item->value); return -1; } battery_number = strtol(item->value, NULL, 10); - snprintf(value, valuelen, item->dfl, battery_number); + if (battery_number > INT_MAX) { + upsdebugx(2, "%s: battery number out of range [%s: %s]", + __func__, item->info_type, item->value); + return -1; + } + +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + snprintf(value, valuelen, item->dfl, (int)battery_number); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif /* No user-provided value to change.. */ if (!getval(item->info_type)) @@ -2764,7 +2904,19 @@ static int voltronic_batt_runtime(item_t *item, char *value, const size_t valuel /* Battery runtime is reported by the UPS in minutes, NUT expects seconds */ runtime = strtod(item->value, NULL) * 60; +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, runtime); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif return 0; } @@ -2772,7 +2924,7 @@ static int voltronic_batt_runtime(item_t *item, char *value, const size_t valuel /* Protocol used by the UPS */ static int voltronic_protocol(item_t *item, char *value, const size_t valuelen) { - int protocol; + long protocol; if (strncasecmp(item->value, "PI", 2)) { upsdebugx(2, "%s: invalid start characters [%.2s]", __func__, item->value); @@ -2805,12 +2957,12 @@ static int voltronic_protocol(item_t *item, char *value, const size_t valuelen) default: - upslogx(LOG_ERR, "Protocol [PI%02d] is not supported by this driver", protocol); + upslogx(LOG_ERR, "Protocol [PI%02ld] is not supported by this driver", protocol); return -1; } - snprintf(value, valuelen, "P%02d", protocol); + snprintf(value, valuelen, "P%02ld", protocol); /* Unskip vars according to protocol */ voltronic_massive_unskip(protocol); @@ -2822,14 +2974,26 @@ static int voltronic_protocol(item_t *item, char *value, const size_t valuelen) * When the UPS is queried for status (QGS), if it reports a fault (6th bit of 12bit flag of the reply to QGS set to 1), the driver unskips the QFS item in qx2nut array: this function processes the reply to QFS query */ static int voltronic_fault(item_t *item, char *value, const size_t valuelen) { - int protocol = strtol(dstate_getinfo("ups.firmware.aux")+1, NULL, 10); + long protocol = strtol(dstate_getinfo("ups.firmware.aux")+1, NULL, 10); - char alarm[SMALLBUF]; + char alarm[LARGEBUF]; /* can sprintf() SMALLBUF plus markup into here */ upslogx(LOG_INFO, "Checking for faults.."); if (!strcasecmp(item->value, "OK")) { +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, "No fault found"); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif upslogx(LOG_INFO, "%s", value); item->qxflags |= QX_FLAG_SKIP; return 0; @@ -3178,7 +3342,19 @@ static int voltronic_fault(item_t *item, char *value, const size_t valuelen) } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, alarm); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif upslogx(LOG_INFO, "Fault found: %s", alarm); item->qxflags |= QX_FLAG_SKIP; @@ -3657,15 +3833,23 @@ static int voltronic_mode(item_t *item, char *value, const size_t valuelen) } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif if (alarm && !strcasecmp(item->info_type, "ups.alarm")) { - snprintf(value, valuelen, item->dfl, alarm); - } else if (status && !strcasecmp(item->info_type, "ups.status")) { - snprintf(value, valuelen, item->dfl, status); - } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif return 0; } @@ -3676,7 +3860,8 @@ static int voltronic_status(item_t *item, char *value, const size_t valuelen) char *val = ""; if (strspn(item->value, "01") != strlen(item->value)) { - upsdebugx(3, "%s: unexpected value %s@%d->%s", __func__, item->value, item->from, item->value); + upsdebugx(3, "%s: unexpected value %s@%d->%s", + __func__, item->value, item->from, item->value); return -1; } @@ -3685,7 +3870,7 @@ static int voltronic_status(item_t *item, char *value, const size_t valuelen) case 63: /* UPS Type - ups.type */ { - int type = strtol(item->value, NULL, 10); + long type = strtol(item->value, NULL, 10); if (!type) /* 00 -> Offline */ val = "offline"; @@ -3694,7 +3879,8 @@ static int voltronic_status(item_t *item, char *value, const size_t valuelen) else if (type == 10) /* 10 -> Online */ val = "online"; else { - upsdebugx(2, "%s: invalid type [%s: %s]", __func__, item->info_type, item->value); + upsdebugx(2, "%s: invalid type [%s: %s]", + __func__, item->info_type, item->value); return -1; } } @@ -3735,7 +3921,7 @@ static int voltronic_status(item_t *item, char *value, const size_t valuelen) val = "TRIM"; } else if (vo < 1.05 * vi) { - int prot = strtol(dstate_getinfo("ups.firmware.aux")+1, NULL, 10); + long prot = strtol(dstate_getinfo("ups.firmware.aux")+1, NULL, 10); if (!prot || prot == 8) { /* ups.alarm */ @@ -3859,7 +4045,19 @@ static int voltronic_output_powerfactor(item_t *item, char *value, const size_t /* UPS report a value expressed in % so -> output.powerfactor*100 e.g. opf = 0,8 -> ups = 80 */ opf = strtod(item->value, NULL) * 0.01; +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, opf); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif return 0; } @@ -3873,7 +4071,20 @@ static int voltronic_serial_numb(item_t *item, char *value, const size_t valuele return -1; } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, item->value); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif + return 0; } @@ -3906,20 +4117,26 @@ static int voltronic_outlet(item_t *item, char *value, const size_t valuelen) } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif if (strstr(item->info_type, "switchable")) { - snprintf(value, valuelen, item->dfl, switchable); - } else if (strstr(item->info_type, "status")) { - snprintf(value, valuelen, item->dfl, status); - } else { - /* Don't know what happened */ return -1; - } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif /* Unskip outlet.n.delay.shutdown */ snprintf(buf, sizeof(buf), "outlet.%c.delay.shutdown", number); @@ -3973,7 +4190,19 @@ static int voltronic_outlet_delay(item_t *item, char *value, const size_t valuel /* UPS reports minutes, NUT expects seconds */ val = strtod(item->value, NULL) * 60; +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(value, valuelen, item->dfl, val); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif /* Unskip outlet.n.delay.shutdown setvar */ snprintf(buf, sizeof(buf), "outlet.%c.delay.shutdown", number); @@ -3992,12 +4221,30 @@ static int voltronic_outlet_delay(item_t *item, char *value, const size_t valuel /* *SETVAR* Outlet delay time */ static int voltronic_outlet_delay_set(item_t *item, char *value, const size_t valuelen) { - int delay = strtol(value, NULL, 10); + long delay = strtol(value, NULL, 10); + + if ((delay/60) > INT_MAX) { + upsdebugx(2, "%s: invalid delay %ld sec set for UPS [%s]", + __func__, delay, item->value); + return -1; + } /* From seconds to minute */ delay = delay / 60; - snprintf(value, valuelen, item->command, delay); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + snprintf(value, valuelen, item->command, (int)delay); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif return 0; } @@ -4005,18 +4252,35 @@ static int voltronic_outlet_delay_set(item_t *item, char *value, const size_t va /* Type of battery */ static int voltronic_p31b(item_t *item, char *value, const size_t valuelen) { - int val; + long val; if ((item->value[0] != '0') || (strspn(item->value+1, "012") != 1)) { - - upsdebugx(2, "%s: invalid battery type reported by the UPS [%s]", __func__, item->value); + upsdebugx(2, "%s: invalid battery type reported by the UPS [%s]", + __func__, item->value); return -1; - } val = strtol(item->value, NULL, 10); - snprintf(value, valuelen, item->dfl, item->info_rw[val].value); + if (val < 0 || (uintmax_t)val > SIZE_MAX) { + upsdebugx(2, "%s: invalid battery type reported by the UPS [%s]", + __func__, item->value); + return -1; + } + +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + snprintf(value, valuelen, item->dfl, item->info_rw[(size_t)val].value); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif return 0; } @@ -4026,6 +4290,9 @@ static int voltronic_p31b_set(item_t *item, char *value, const size_t valuelen) { int i; + if (!item->info_rw) + return -1; + for (i = 0; strlen(item->info_rw[i].value) > 0; i++) { if (!strcasecmp(item->info_rw[i].value, value)) @@ -4034,7 +4301,7 @@ static int voltronic_p31b_set(item_t *item, char *value, const size_t valuelen) } /* At this point value should already be checked against enum so this shouldn't happen.. however.. */ - if (i >= (int)(sizeof(item->info_rw) / sizeof(item->info_rw[0]))) { + if (!strlen(item->info_rw[i].value)) { upslogx(LOG_ERR, "%s: value [%s] out of range", item->info_type, value); return -1; } @@ -4047,18 +4314,36 @@ static int voltronic_p31b_set(item_t *item, char *value, const size_t valuelen) /* *NONUT* Actual device grid working range type for P31 UPSes */ static int voltronic_p31g(item_t *item, char *value, const size_t valuelen) { - int val; + long val; if ((item->value[0] != '0') || (strspn(item->value+1, "01") != 1)) { - - upsdebugx(2, "%s: invalid device grid working range reported by the UPS [%s]", __func__, item->value); + upsdebugx(2, "%s: invalid device grid working range reported by the UPS [%s]", + __func__, item->value); return -1; - } val = strtol(item->value, NULL, 10); - snprintf(value, valuelen, item->dfl, item->info_rw[val].value); + if (val < 0 || (uintmax_t)val > SIZE_MAX) { + upsdebugx(2, "%s: invalid device grid working range reported by the UPS [%s]", + __func__, item->value); + return -1; + } + +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + snprintf(value, valuelen, item->dfl, item->info_rw[(size_t)val].value); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif + work_range_type = val; return 0; @@ -4069,6 +4354,9 @@ static int voltronic_p31g_set(item_t *item, char *value, const size_t valuelen) { int i; + if (!item->info_rw) + return -1; + for (i = 0; strlen(item->info_rw[i].value) > 0; i++) { if (!strcasecmp(item->info_rw[i].value, value)) @@ -4077,7 +4365,7 @@ static int voltronic_p31g_set(item_t *item, char *value, const size_t valuelen) } /* At this point value should have been already checked against enum so this shouldn't happen.. however.. */ - if (i >= (int)(sizeof(item->info_rw) / sizeof(item->info_rw[0]))) { + if (!strlen(item->info_rw[i].value)) { upslogx(LOG_ERR, "%s: value [%s] out of range", item->info_type, value); return -1; } @@ -4095,10 +4383,11 @@ static int voltronic_p31g_set(item_t *item, char *value, const size_t valuelen) /* *NONUT* UPS actual input/output phase angles */ static int voltronic_phase(item_t *item, char *value, const size_t valuelen) { - int angle; + long angle; if (strspn(item->value, "0123456789 .") != strlen(item->value)) { - upsdebugx(2, "%s: non numerical value [%s: %s]", __func__, item->info_type, item->value); + upsdebugx(2, "%s: non numerical value [%s: %s]", + __func__, item->info_type, item->value); return -1; } @@ -4126,7 +4415,25 @@ static int voltronic_phase(item_t *item, char *value, const size_t valuelen) } - snprintf(value, valuelen, item->dfl, angle); + if (angle < 0 || angle > INT_MAX) { + upsdebugx(2, "%s: phase angle out of range [%s: %ld]", + __func__, item->value, angle); + return -1; + } + +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + snprintf(value, valuelen, item->dfl, (int)angle); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif return 0; } @@ -4136,6 +4443,9 @@ static int voltronic_phase_set(item_t *item, char *value, const size_t valuelen) { int i; + if (!item->info_rw) + return -1; + for (i = 0; strlen(item->info_rw[i].value) > 0; i++) { if (!strcasecmp(item->info_rw[i].value, value)) @@ -4144,7 +4454,7 @@ static int voltronic_phase_set(item_t *item, char *value, const size_t valuelen) } /* At this point value should have been already checked against enum so this shouldn't happen.. however.. */ - if (i >= (int)(sizeof(item->info_rw) / sizeof(item->info_rw[0]))) { + if (!strlen(item->info_rw[i].value)) { upslogx(LOG_ERR, "%s: value [%s] out of range", item->info_type, value); return -1; } diff --git a/drivers/nutdrv_siemens_sitop.c b/drivers/nutdrv_siemens_sitop.c new file mode 100644 index 0000000..1c1e9ef --- /dev/null +++ b/drivers/nutdrv_siemens_sitop.c @@ -0,0 +1,298 @@ +/* + * nutdrv_siemens_sitop.c - model specific routines for the Siemens SITOP UPS500 series + * + * + * Copyright (C) 2018 Matthijs H. ten Berge + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * Notes: + * These UPSes operate at 24V DC (both input and output), instead of 110V/230V AC. + * Therefore, the line input is also referred to by Siemens as 'DC'. + * + * The device is configured via DIP-switches. + * For correct functioning in combination with NUT, set the DIP-switches to the following: + * switch 1-4: choose whatever suits your situation. Any combination will work with NUT. + * switch 5 ('=>' / 't'): set to OFF ('t') + * switch 6-10 (delay): set to OFF (no additional delay) + * switch 11 (INTERR.): set to ON + * switch 12 (ON/OFF): set to ON + * + * These UPSes are available with serial or USB port. + * Both are supported by this driver. The version with USB port simply contains + * a serial-over-USB chip, so as far as this driver is concerned, all models are + * actually serial models. + * + * The FTDI USB-to-serial converters in the USB-models are programmed with a non-standard + * Product ID (mine had 0403:e0e3), but can be used with the normal ftdi_sio driver: + * # modprobe ftdi_sio + * # echo 0403 e0e3 > /sys/bus/usb-serial/drivers/ftdi_sio/new_id + * + * This can also be automated via a udev rule: + * ACTION=="add", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="e0e3", \ + * RUN+="/sbin/modprobe ftdi_sio", \ + * RUN+="/bin/sh -c 'echo 0403 e0e3 > /sys/bus/usb-serial/drivers/ftdi_sio/new_id'" + * + * Use the following udev rule to create a persistent device name, for example /dev/ttyUPS: + * SUBSYSTEM=="tty" ATTRS{idVendor}=="0403", ATTRS{idProduct}=="e0e3" SYMLINK+="ttyUPS" + */ + +#include "main.h" +#include "serial.h" +#include "nut_stdint.h" + +#define DRIVER_NAME "Siemens SITOP UPS500 series driver" +#define DRIVER_VERSION "0.03" + +#define RX_BUFFER_SIZE 100 + +/* driver description structure */ +upsdrv_info_t upsdrv_info = { + DRIVER_NAME, + DRIVER_VERSION, + "Matthijs H. ten Berge ", + DRV_EXPERIMENTAL, + { NULL } +}; + +/* The maximum number of consecutive polls in which the UPS does not provide any data: */ +static unsigned int max_polls_without_data; +/* The current number: */ +static unsigned int nr_polls_without_data; +/* receive buffer */ +static char rx_buffer[RX_BUFFER_SIZE]; +static size_t rx_count; + +static struct { + int battery_alarm; + int dc_input_low; + int on_battery; + int battery_above_85_percent; +} current_ups_status; + +/* remove n bytes from the head of rx_buffer, shift the remaining bytes to the start */ +static void rm_buffer_head(unsigned int n) { + if (rx_count <= n) { + /* nothing left */ + rx_count = 0; + return; + } + rx_count -= n; + memmove(rx_buffer, rx_buffer + n, rx_count); +} + +/* parse incoming data from the UPS. + * return true if something new was received. + */ +static int check_for_new_data() { + int new_data_received = 0; + int done = 0; + ssize_t num_received; + + while (!done) { + /* Get new data from the serial port. + * No extra delay, just get the chars that were already buffered. + */ + num_received = ser_get_buf(upsfd, rx_buffer + rx_count, RX_BUFFER_SIZE - rx_count, 0, 0); + if (num_received < 0) { + /* comm error */ + ser_comm_fail("error %zd while reading", num_received); + /* discard any remaining old data from the receive buffer: */ + rx_count = 0; + /* try to re-open the serial port: */ + if (upsfd) { + ser_close(upsfd, device_path); + upsfd = 0; + } + upsfd = ser_open_nf(device_path); + ser_set_speed_nf(upsfd, device_path, B9600); + done = 1; + } else if (num_received == 0) { + /* no (more) new data */ + done = 1; + } else { + rx_count += (unsigned int)num_received; + + /* parse received input data: */ + while (rx_count >= 5) { /* all valid input messages are strings of 5 characters */ + if (strncmp(rx_buffer, "BUFRD", 5) == 0) { + current_ups_status.battery_alarm = 0; + } else if (strncmp(rx_buffer, "ALARM", 5) == 0) { + current_ups_status.battery_alarm = 1; + } else if (strncmp(rx_buffer, "DC_OK", 5) == 0) { + current_ups_status.dc_input_low = 0; + } else if (strncmp(rx_buffer, "DC_LO", 5) == 0) { + current_ups_status.dc_input_low = 1; + } else if (strncmp(rx_buffer, "*****", 5) == 0) { + current_ups_status.on_battery = 0; + } else if (strncmp(rx_buffer, "*BAT*", 5) == 0) { + current_ups_status.on_battery = 1; + } else if (strncmp(rx_buffer, "BA>85", 5) == 0) { + current_ups_status.battery_above_85_percent = 1; + } else if (strncmp(rx_buffer, "BA<85", 5) == 0) { + current_ups_status.battery_above_85_percent = 0; + } else { + /* nothing sensible found at the start of the rx_buffer. */ + rm_buffer_head(1); + continue; /* skip the code below */ + } + rm_buffer_head(5); + new_data_received = 1; + } + } + } + return new_data_received; +} + + +static int instcmd(const char *cmdname, const char *extra) { + /* Note: the UPS does not really like to receive data. + * For example, sending an "R" without \n hangs the serial port. + * In that situation, the UPS will no longer send any status updates. + * For this reason, an additional \n is appended here. + * The commands are sent twice, because the first command is sometimes + * lost as well. + */ + if (!strcasecmp(cmdname, "shutdown.return")) { + upslogx(LOG_NOTICE, "instcmd: sending command R"); + ser_send_pace(upsfd, 200000, "\n\nR\n\n"); + ser_send_pace(upsfd, 200000, "R\n\n"); + return STAT_INSTCMD_HANDLED; + } + if (!strcasecmp(cmdname, "shutdown.stayoff")) { + upslogx(LOG_NOTICE, "instcmd: sending command S"); + ser_send_pace(upsfd, 200000, "\n\nS\n\n"); + ser_send_pace(upsfd, 200000, "S\n\n"); + return STAT_INSTCMD_HANDLED; + } + + upslogx(LOG_NOTICE, "instcmd: unknown command [%s] [%s]", cmdname, extra); + return STAT_INSTCMD_UNKNOWN; +} + + +void upsdrv_initinfo(void) { + int max_attempts = 5; + int found = 0; + while (!found && max_attempts > 0) { + if (check_for_new_data()) { + found = 1; + } else { + sleep(1); /* Sleep a while, then try again */ + } + max_attempts--; + } + if (!found) { + fatalx(EXIT_FAILURE, "No data received from the UPS"); + } + + dstate_setinfo("device.mfr", "Siemens"); + dstate_setinfo("device.model", "SITOP UPS500 series"); + + /* supported commands: */ + dstate_addcmd("shutdown.stayoff"); + dstate_addcmd("shutdown.return"); + + upsh.instcmd = instcmd; +} + + +void upsdrv_updateinfo(void) { + if (check_for_new_data()) { + nr_polls_without_data = 0; + } else { + nr_polls_without_data++; + /* With unsigned int type, we can limit half-way like this: */ + if (nr_polls_without_data > INT_MAX) + nr_polls_without_data = INT_MAX; + } + + if (nr_polls_without_data > max_polls_without_data) { + /* data is stale */ + dstate_datastale(); + return; + } + + /* This is all we know about the charge level... */ + dstate_setinfo("battery.charge.approx", + (current_ups_status.battery_above_85_percent) ? ">85" : "<85"); + + status_init(); + + if (current_ups_status.dc_input_low || current_ups_status.on_battery) { + status_set("OB"); + } else { + status_set("OL"); + } + if (current_ups_status.battery_alarm) { + status_set("LB"); + } + + status_commit(); + dstate_dataok(); + ser_comm_good(); +} + +void upsdrv_shutdown(void) { + /* tell the UPS to shut down, then return - DO NOT SLEEP HERE */ + instcmd("shutdown.return", NULL); +} + + +void upsdrv_help(void) { +} + +/* list flags and values that you want to receive via -x */ +void upsdrv_makevartable(void) { + /* allow '-x max_polls_without_data=' */ + addvar(VAR_VALUE, "max_polls_without_data", "The maximum number of consecutive polls in which the UPS does not provide any data."); +} + +void upsdrv_initups(void) { + char * maxPollsString; + unsigned int parsed; + + upsfd = ser_open(device_path); + ser_set_speed(upsfd, device_path, B9600); + + /* + * Fast polling is preferred, because + * A) the UPS spits out new data every 75 msec, + * B) some models in this SITOP series have a _very_ small capacity + * (< 10sec runtime), so every second might count. + */ + if (poll_interval > 5) { + upslogx(LOG_NOTICE, + "Option poll_interval is recommended to be lower than 5 (found: %jd)", + (intmax_t)poll_interval); + } + + /* option max_polls_without_data: */ + max_polls_without_data = 2; + maxPollsString = getval("max_polls_without_data"); + if (maxPollsString) { + if (str_to_uint(maxPollsString, &parsed, 10) == 1) { + max_polls_without_data = parsed; + } else { + upslog_with_errno(LOG_ERR, "Cannot parse option max_polls_without_data"); + } + } +} + +void upsdrv_cleanup(void) { + ser_close(upsfd, device_path); +} diff --git a/drivers/oneac.c b/drivers/oneac.c index 55035f7..916fc72 100644 --- a/drivers/oneac.c +++ b/drivers/oneac.c @@ -32,10 +32,10 @@ * Enhancing the driver for additional capabilities and later units. * * - 28 November 2003. Eric Lawson - * More or less complete re-write for NUT 1.5.9 - * This was somewhat easier than trying to beat the old driver code + * More or less complete re-write for NUT 1.5.9 + * This was somewhat easier than trying to beat the old driver code * into submission - * + * */ #include "main.h" @@ -47,7 +47,7 @@ int setcmd(const char* varname, const char* setvalue); int instcmd(const char *cmdname, const char *extra); #define DRIVER_NAME "Oneac EG/ON/OZ/OB UPS driver" -#define DRIVER_VERSION "0.80" +#define DRIVER_VERSION "0.81" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -74,22 +74,24 @@ static char UpsFamily [3]; * allow for a repeat of the get request. Also confirm that * the correct number of characters are returned. */ - -int OneacGetResponse (char* chBuff, const int BuffSize, int ExpectedCount) + +static ssize_t OneacGetResponse (char* chBuff, const size_t BuffSize, int ExpectedCount) { int Retries = 10; /* x/2 seconds max with 500000 USEC */ - int return_val; + ssize_t return_val; do { - return_val = ser_get_line(upsfd, chBuff, BuffSize, ENDCHAR, IGNCHARS, - SECS, USEC); + return_val = ser_get_line(upsfd, + chBuff, BuffSize, ENDCHAR, IGNCHARS, SECS, USEC); if (return_val == ExpectedCount) break; - upsdebugx (3,"!OneacGetResponse retry (%d, %d)...", return_val,Retries); - + upsdebugx (3, + "!OneacGetResponse retry (%zd, %d)...", + return_val, Retries); + } while (--Retries > 0); upsdebugx (4,"OneacGetResponse buffer: %s",chBuff); @@ -103,14 +105,14 @@ int OneacGetResponse (char* chBuff, const int BuffSize, int ExpectedCount) { if (Retries < 10) upsdebugx (2,"OneacGetResponse recovered (%d)...", Retries); - + return_val = 0; /* Good comms */ } - - return return_val; + + return return_val; } -void do_battery_test(void) +static void do_battery_test(void) { char buffer[32]; @@ -130,7 +132,7 @@ void do_battery_test(void) ser_send(upsfd,"%s%s%s",BAT_TEST_PREFIX,buffer,COMMAND_END); } -int SetOutputAllow(const char* lowval, const char* highval) +static int SetOutputAllow(const char* lowval, const char* highval) { char buffer[32]; @@ -146,38 +148,38 @@ int SetOutputAllow(const char* lowval, const char* highval) buffer[1] = buffer[0]; buffer[0] = '0'; } - - upsdebugx (2,"SetOutputAllow sending %s%.3s,%.3s...", + + upsdebugx (2,"SetOutputAllow sending %s%.3s,%.3s...", SETX_OUT_ALLOW, buffer, highval); - - ser_send(upsfd,"%s%.3s,%.3s%s", SETX_OUT_ALLOW, buffer, highval, + + ser_send(upsfd,"%s%.3s,%.3s%s", SETX_OUT_ALLOW, buffer, highval, COMMAND_END); ser_get_line(upsfd,buffer,sizeof(buffer), ENDCHAR, IGNCHARS,SECS,USEC); - + if(buffer[0] == DONT_UNDERSTAND) { upsdebugx (2,"SetOutputAllow got asterisk back..."); return 1; /* Invalid command */ } - + return 0; /* Valid command */ } -void EliminateLeadingZeroes (const char* buff1, int StringSize, char* buff2, - const int buff2size) +static void EliminateLeadingZeroes (const char* buff1, int StringSize, char* buff2, + const size_t buff2size) { int i = 0; int j = 0; memset(buff2, '\0', buff2size); /* Fill with nulls */ - + /* Find first non-'0' */ - while ((buff1[i] == '0') && (i < (StringSize - 1))) + while ((i < (StringSize - 1) && (buff1[i] == '0'))) { i++; } - + while (i < StringSize) /* Move rest of string */ { buff2[j++] = buff1[i++]; @@ -205,7 +207,7 @@ void upsdrv_initinfo(void) int i,j, k; int VRange=0; int timevalue; - int RetValue; + ssize_t RetValue; char buffer[256], buffer2[32]; /* All families should reply to this request so we can confirm that it is @@ -222,13 +224,13 @@ void upsdrv_initinfo(void) } else { - if (strncmp(buffer,FAMILY_ON,FAMILY_SIZE) != 0 && + if (strncmp(buffer,FAMILY_ON,FAMILY_SIZE) != 0 && strncmp(buffer,FAMILY_OZ,FAMILY_SIZE) != 0 && - strncmp(buffer,FAMILY_OB,FAMILY_SIZE) != 0 && + strncmp(buffer,FAMILY_OB,FAMILY_SIZE) != 0 && strncmp(buffer,FAMILY_EG,FAMILY_SIZE) != 0) { fatalx(EXIT_FAILURE, "Did not find an ONEAC UPS on %s\n", - device_path); + device_path); } } @@ -239,7 +241,7 @@ void upsdrv_initinfo(void) printf("Found %s family of Oneac UPS\n", UpsFamily); dstate_setinfo("ups.type", "%s", "Line Interactive"); - + dstate_addcmd("test.battery.start.quick"); dstate_addcmd("test.battery.stop"); dstate_addcmd("test.failure.start"); @@ -257,7 +259,7 @@ void upsdrv_initinfo(void) if (strncmp(UpsFamily, FAMILY_EG, FAMILY_SIZE) == 0) { - RetValue = OneacGetResponse (buffer, sizeof(buffer), + RetValue = OneacGetResponse (buffer, sizeof(buffer), GETALL_EG_RESP_SIZE); } else @@ -289,7 +291,7 @@ void upsdrv_initinfo(void) dstate_setflags("ups.delay.shutdown", ST_FLAG_STRING | ST_FLAG_RW); dstate_setaux("ups.delay.shutdown", GET_SHUTDOWN_RESP_SIZE); - + /* Setup some ON/OZ/OB only stuff ... i.e. not EG */ if (strncmp(UpsFamily, FAMILY_EG, FAMILY_SIZE) != 0) @@ -299,7 +301,7 @@ void upsdrv_initinfo(void) /*nominal input voltage*/ VRange = buffer[26]; /* Keep for later use also */ - + switch (VRange) /* Will be '1' or '2' */ { case V120AC: @@ -317,9 +319,9 @@ void upsdrv_initinfo(void) "Invalid nom voltage parameter from UPS [%c]", VRange); } } - + /* Setup some OZ/OB only stuff */ - + if ((strncmp (UpsFamily, FAMILY_OZ, FAMILY_SIZE) == 0) || (strncmp (UpsFamily, FAMILY_OB, FAMILY_SIZE) == 0)) { @@ -328,7 +330,7 @@ void upsdrv_initinfo(void) dstate_addcmd("beeper.enable"); dstate_addcmd("beeper.disable"); dstate_addcmd("beeper.mute"); - + dstate_setaux("ups.delay.shutdown", GETX_SHUTDOWN_RESP_SIZE); ser_flush_in(upsfd,"",0); @@ -355,7 +357,7 @@ void upsdrv_initinfo(void) dstate_setinfo("ups.delay.start", "%s", buffer2); dstate_setflags("ups.delay.start", ST_FLAG_STRING | ST_FLAG_RW); dstate_setaux("ups.delay.start", 4); - + /* Low Batt at time */ strncpy(buffer2, buffer+82, 2); buffer2[2]='\0'; @@ -363,24 +365,36 @@ void upsdrv_initinfo(void) dstate_setinfo("battery.runtime.low", "%d",timevalue); dstate_setflags("battery.runtime.low", ST_FLAG_STRING | ST_FLAG_RW); dstate_setaux("battery.runtime.low", 2); - + /*Get the actual model string for ON UPS reported as OZ/OB family*/ /*UPS Model (full string)*/ memset(buffer2, '\0', 32); - strncpy(buffer2, buffer+5, 10); - for (i = 9; i >= 0 && buffer2[i] == ' '; --i) +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION +#pragma GCC diagnostic ignored "-Wformat-truncation" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRINGOP_TRUNCATION +#pragma GCC diagnostic ignored "-Wstringop-truncation" +#endif + strncpy(buffer2, buffer + 5, 10); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION +#pragma GCC diagnostic pop +#endif + for (i = 9; i >= 0 && buffer2[i] == ' '; --i) { buffer2[i] = '\0'; } dstate_setinfo("device.model", "%s", buffer2); - + /* Serial number */ dstate_setinfo("device.serial", "%.4s-%.4s", buffer+18, buffer+22); - printf("Found %.10s UPS with serial number %.4s-%.4s\n", + printf("Found %.10s UPS with serial number %.4s-%.4s\n", buffer2, buffer+18, buffer+22); - + /* Manufacture Date */ dstate_setinfo("ups.mfr.date", "%.6s (yymmdd)", buffer+38); @@ -388,7 +402,7 @@ void upsdrv_initinfo(void) dstate_setinfo("battery.date", "%.6s (yymmdd)", buffer+44); dstate_setflags("battery.date", ST_FLAG_STRING | ST_FLAG_RW); dstate_setaux("battery.date", 6); - + /* Real power nominal */ EliminateLeadingZeroes (buffer+55, 5, buffer2, sizeof(buffer2)); dstate_setinfo("ups.realpower.nominal", "%s", buffer2); @@ -402,27 +416,39 @@ void upsdrv_initinfo(void) if ((strncmp (UpsFamily, FAMILY_OB, FAMILY_SIZE) == 0) || (strcmp (dstate_getinfo("ups.firmware"), MIN_ALLOW_FW) >= 0 )) { - upsdebugx (2,"Can get output window min/max! (%s)", + upsdebugx (2,"Can get output window min/max! (%s)", dstate_getinfo("ups.firmware")); ser_send(upsfd,"%s%s",GETX_ALLOW_RANGE,COMMAND_END); if(OneacGetResponse (buffer, sizeof(buffer), GETX_RANGE_RESP_SIZE)) { - fatalx(EXIT_FAILURE, + fatalx(EXIT_FAILURE, "Serial timeout(4) with ONEAC UPS on %s\n",device_path); } strncpy(buffer2, buffer, 3); buffer2[3]='\0'; i = atoi(buffer2); /* Minimum voltage */ - - strncpy(buffer2, buffer+4, 3); + +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION +#pragma GCC diagnostic ignored "-Wformat-truncation" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRINGOP_TRUNCATION +#pragma GCC diagnostic ignored "-Wstringop-truncation" +#endif + strncpy(buffer2, buffer + 4, 3); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION +#pragma GCC diagnostic pop +#endif j = atoi(buffer2); /* Maximum voltage */ strncpy(buffer2, buffer+8, 2); buffer2[2]='\0'; k = atoi(buffer2); /* Spread between */ - + dstate_setinfo("input.transfer.low.min", "%3d", i); dstate_setinfo("input.transfer.low.max", "%3d", j-k); dstate_setinfo("input.transfer.high.min", "%3d", i+k); @@ -432,7 +458,7 @@ void upsdrv_initinfo(void) else { /* Use default values from firmware */ - upsdebugx (2,"Using trip defaults (%s)...", + upsdebugx (2,"Using trip defaults (%s)...", dstate_getinfo("ups.firmware")); switch (VRange) /* Held from initial use */ @@ -465,7 +491,7 @@ void upsdrv_updateinfo(void) char buffer[256]; /* Main response buffer */ char buffer2[32]; /* Conversion buffer */ char s; - int RetValue; + ssize_t RetValue; int timevalue; /* Start with EG/ON information */ @@ -485,7 +511,7 @@ void upsdrv_updateinfo(void) { ser_comm_fail("Oneac UPS Comm failure continues on port %s", device_path); - } + } else if (RetValue != 0) { if (--CommTry == 0) @@ -521,10 +547,10 @@ void upsdrv_updateinfo(void) { status_set("OL"); } - + if (s & 0x02) /* Low Battery */ status_set("LB"); - + if (s & 0x04) /* General fault */ { dstate_setinfo("ups.test.result","UPS Internal Failure"); @@ -557,7 +583,7 @@ void upsdrv_updateinfo(void) "High Input Voltage"); break; case NO_VALUE_YET : - dstate_setinfo("input.transfer.reason", + dstate_setinfo("input.transfer.reason", "No transfer yet."); break; default : @@ -578,7 +604,7 @@ void upsdrv_updateinfo(void) /*battery charge*/ if(buffer[10] == YES) dstate_setinfo("battery.charge", "0%.2s",buffer+33); - else + else dstate_setinfo("battery.charge", "100"); EliminateLeadingZeroes (buffer+35, 3, buffer2, sizeof(buffer2)); @@ -601,10 +627,10 @@ void upsdrv_updateinfo(void) { /* A shutdown is underway! */ status_set("FSD"); - + if(buffer[15] != HIGH_COUNT) { - EliminateLeadingZeroes (buffer+15, 3, buffer2, + EliminateLeadingZeroes (buffer+15, 3, buffer2, sizeof(buffer2)); dstate_setinfo("ups.timer.shutdown", "%s", buffer2); } @@ -614,18 +640,18 @@ void upsdrv_updateinfo(void) } } - if (buffer[47] == YES) + if (buffer[47] == YES) status_set("BOOST"); } /* Now update info for only the OZ/OB families of UPS */ if ((strncmp(UpsFamily, FAMILY_OZ, FAMILY_SIZE) == 0) || - (strncmp(UpsFamily, FAMILY_OB, FAMILY_SIZE) == 0)) + (strncmp(UpsFamily, FAMILY_OB, FAMILY_SIZE) == 0)) { ser_flush_in(upsfd,"",0); /*just in case*/ ser_send (upsfd,"%c%s",GETX_ALL_1,COMMAND_END); - RetValue = OneacGetResponse (buffer, sizeof(buffer), + RetValue = OneacGetResponse (buffer, sizeof(buffer), GETX_ALL1_RESP_SIZE); if(RetValue) @@ -667,13 +693,13 @@ void upsdrv_updateinfo(void) /* Battery replace date */ ser_send (upsfd,"%c%s",GETX_BATT_REPLACED,COMMAND_END); - if(!OneacGetResponse (buffer, sizeof(buffer), + if(!OneacGetResponse (buffer, sizeof(buffer), GETX_DATE_RESP_SIZE)) dstate_setinfo("battery.date", "%.6s (yymmdd)", buffer); /* Low and high output trip points */ ser_send (upsfd,"%c%s",GETX_LOW_OUT_ALLOW,COMMAND_END); - if(!OneacGetResponse (buffer, sizeof(buffer), + if(!OneacGetResponse (buffer, sizeof(buffer), GETX_ALLOW_RESP_SIZE)) { EliminateLeadingZeroes (buffer, 3, buffer2,sizeof(buffer2)); @@ -681,16 +707,16 @@ void upsdrv_updateinfo(void) } ser_send (upsfd,"%c%s",GETX_HI_OUT_ALLOW,COMMAND_END); - if(!OneacGetResponse (buffer, sizeof(buffer), + if(!OneacGetResponse (buffer, sizeof(buffer), GETX_ALLOW_RESP_SIZE)) dstate_setinfo("input.transfer.high", "%s", buffer); /* Restart delay */ ser_send (upsfd,"%c%s",GETX_RESTART_DLY,COMMAND_END); - if(!OneacGetResponse (buffer, sizeof(buffer), + if(!OneacGetResponse (buffer, sizeof(buffer), GETX_RSTRT_RESP_SIZE)) { - EliminateLeadingZeroes (buffer, 4, buffer2, + EliminateLeadingZeroes (buffer, 4, buffer2, sizeof(buffer2)); dstate_setinfo("ups.delay.start", "%s", buffer2); } @@ -699,7 +725,7 @@ void upsdrv_updateinfo(void) ser_send (upsfd,"%s%s",GETX_BUZZER_WHAT,COMMAND_END); if(!OneacGetResponse (buffer, sizeof(buffer), 1)) { - switch (buffer[0]) + switch (buffer[0]) { case BUZZER_ENABLED : dstate_setinfo("ups.beeper.status", "enabled"); @@ -737,15 +763,15 @@ void upsdrv_updateinfo(void) /* Shutdown timer */ ser_send (upsfd,"%c%s",GETX_SHUTDOWN,COMMAND_END); - if(!OneacGetResponse (buffer, sizeof(buffer), + if(!OneacGetResponse (buffer, sizeof(buffer), GETX_SHUTDOWN_RESP_SIZE)) { - /* ON would have handled NO_VALUE_YET and setting FSD + /* ON would have handled NO_VALUE_YET and setting FSD * above so only deal with counter value here. */ if (buffer[0] != NO_VALUE_YET) { - EliminateLeadingZeroes (buffer, 5, buffer2, + EliminateLeadingZeroes (buffer, 5, buffer2, sizeof(buffer2)); dstate_setinfo("ups.timer.shutdown", "%s", buffer2); } @@ -753,7 +779,7 @@ void upsdrv_updateinfo(void) /* Restart timer */ ser_send (upsfd,"%s%s",GETX_RESTART_COUNT,COMMAND_END); - if(!OneacGetResponse (buffer, sizeof(buffer), + if(!OneacGetResponse (buffer, sizeof(buffer), GETX_RSTRT_RESP_SIZE)) { if (atoi(buffer) == 0) @@ -762,7 +788,7 @@ void upsdrv_updateinfo(void) } else { - EliminateLeadingZeroes (buffer, 4, buffer2, + EliminateLeadingZeroes (buffer, 4, buffer2, sizeof(buffer2)); dstate_setinfo("ups.timer.start", "%s", buffer2); } @@ -839,7 +865,7 @@ int instcmd(const char *cmdname, const char *extra) return STAT_INSTCMD_HANDLED; } - + if(!strcasecmp(cmdname, "shutdown.reboot")) { ser_send(upsfd, "%s", SHUTDOWN); return STAT_INSTCMD_HANDLED; @@ -860,7 +886,7 @@ int instcmd(const char *cmdname, const char *extra) return STAT_INSTCMD_HANDLED; } - if (!strcasecmp(cmdname, "test.battery.stop")) + if (!strcasecmp(cmdname, "test.battery.stop")) { if ((strncmp (UpsFamily, FAMILY_EG, FAMILY_SIZE) == 0) || (strncmp (UpsFamily, FAMILY_ON, FAMILY_SIZE) == 0)) @@ -870,7 +896,7 @@ int instcmd(const char *cmdname, const char *extra) else { ser_send(upsfd,"%c%s",TEST_ABORT,COMMAND_END); - } + } return STAT_INSTCMD_HANDLED; } @@ -992,7 +1018,7 @@ int setcmd(const char* varname, const char* setvalue) if (atoi(setvalue) <= 99) { ser_send(upsfd,"%s%s%s",SETX_LOWBATT_AT, setvalue, COMMAND_END); - + dstate_setinfo("battery.runtime.low", "%s", setvalue); return STAT_SET_HANDLED; } @@ -1016,7 +1042,7 @@ int setcmd(const char* varname, const char* setvalue) dstate_setinfo("ups.start.auto", "no"); return STAT_SET_HANDLED; } - + return STAT_SET_UNKNOWN; } diff --git a/drivers/oneac.h b/drivers/oneac.h index a85a505..7be4b02 100644 --- a/drivers/oneac.h +++ b/drivers/oneac.h @@ -22,6 +22,9 @@ * */ +#ifndef NUT_ONEAC_H_SEEN +#define NUT_ONEAC_H_SEEN 1 + /*misc stuff*/ #define ENDCHAR '\r' #define IGNCHARS "\n" @@ -167,7 +170,7 @@ #define V120AC '1' #define XFER_BLACKOUT 'B' #define XFER_LOW_VOLT 'L' -#define XFER_HI_VOLT 'H' +#define XFER_HI_VOLT 'H' #define BUZZER_ENABLED '1' #define BUZZER_DISABLED '0' #define BUZZER_MUTED '2' @@ -181,3 +184,5 @@ #define CODE_OVERLOAD "c8" /*"slight" overload*/ #define CODE_GROSS_OVLE "c9" /*gross overload 1 minute to power off*/ #define CODE_CHRGR_FUSE_OPEN "u1" /*battery charger fuse probably open*/ + +#endif /* NUT_ONEAC_H_SEEN */ diff --git a/drivers/openups-hid.c b/drivers/openups-hid.c index bfe386f..d8be70d 100644 --- a/drivers/openups-hid.c +++ b/drivers/openups-hid.c @@ -21,12 +21,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "config.h" /* must be first */ + #include "usbhid-ups.h" #include "openups-hid.h" #include "main.h" /* for getval() */ #include "usb-common.h" -#define OPENUPS_HID_VERSION "openUPS HID 0.4" +#define OPENUPS_HID_VERSION "openUPS HID 0.5" /* Minibox */ #define OPENUPS_VENDORID 0x04d8 @@ -75,14 +77,14 @@ static /* const */ usb_device_id_t openups_usb_device_table[] = { {USB_DEVICE(OPENUPS_VENDORID, 0xd005), get_voltage_multiplier}, /* Terminating entry */ - {-1, -1, NULL} + { 0, 0, NULL } }; -/* Thermistor table used for temperature lookups +/* Thermistor table used for temperature lookups * taken from the windows monitoring application */ static const unsigned int therm_tbl[] = -{ +{ (unsigned int)0x31, (unsigned int)0x40, (unsigned int)0x53, @@ -135,47 +137,47 @@ static const char *openups_scale_cdischarge_fun(double value); static const char *openups_temperature_fun(double value); static info_lkp_t openups_charging_info[] = { - {0, NULL, openups_charging_fun} + {0, NULL, openups_charging_fun, NULL } }; static info_lkp_t openups_discharging_info[] = { - {0, NULL, openups_discharging_fun} + {0, NULL, openups_discharging_fun, NULL } }; static info_lkp_t openups_online_info[] = { - {0, NULL, openups_online_fun} + {0, NULL, openups_online_fun, NULL } }; static info_lkp_t openups_nobattery_info[] = { - {0, NULL, openups_nobattery_fun} + {0, NULL, openups_nobattery_fun, NULL } }; static info_lkp_t openups_off_info[] = { - {0, NULL, openups_off_fun} + {0, NULL, openups_off_fun, NULL } }; static info_lkp_t openups_vin_info[] = { - {0, NULL, openups_scale_vin_fun} + {0, NULL, openups_scale_vin_fun, NULL } }; static info_lkp_t openups_vout_info[] = { - {0, NULL, openups_scale_vout_fun} + {0, NULL, openups_scale_vout_fun, NULL } }; /* static info_lkp_t openups_vbat_info[] = { - {0, NULL, openups_scale_vbat_fun} + {0, NULL, openups_scale_vbat_fun, NULL } };*/ static info_lkp_t openups_ccharge_info[] = { - {0, NULL, openups_scale_ccharge_fun} + {0, NULL, openups_scale_ccharge_fun, NULL } }; static info_lkp_t openups_cdischarge_info[] = { - {0, NULL, openups_scale_cdischarge_fun} + {0, NULL, openups_scale_cdischarge_fun, NULL } }; static info_lkp_t openups_temperature_info[] = { - {0, NULL, openups_temperature_fun} + {0, NULL, openups_temperature_fun, NULL } }; static const char *openups_charging_fun(double value) @@ -236,7 +238,7 @@ static const char *openups_scale_cdischarge_fun(double value) static const char *openups_temperature_fun(double value) { int i; - int pos = -1; + int pos = 0; unsigned int thermistor = value * 100; if (thermistor <= therm_tbl[0]) { @@ -282,7 +284,7 @@ static usage_lkp_t openups_usage_lkp[] = { {"Cell4", 0x00000004}, /* Battery cell 4 on J6 pin 4 */ {"Cell5", 0x00000005}, /* Battery cell 5 on J6 pin 5 */ {"Cell6", 0x00000006}, /* Battery cell 6 on J4 pin 1 */ - /* Usage table for windows monitoring app only updates when + /* Usage table for windows monitoring app only updates when * certain request codes are written to USB endpoint */ /*{ "OpenUPSExtra", 0xff000001 }, */ {NULL, 0} @@ -303,7 +305,7 @@ static hid_info_t openups_hid2nut[] = { /* Battery */ {"battery.type", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%s", HU_FLAG_STATIC, stringid_conversion}, - {"battery.mfr.date", 0, 0, "UPS.PowerSummary.iOEMInformation", NULL, "%s", 0, stringid_conversion}, + {"battery.mfr.date", 0, 0, "UPS.PowerSummary.iOEMInformation", NULL, "%s", HU_FLAG_STATIC, stringid_conversion}, {"battery.voltage", 0, 0, "UPS.PowerSummary.Voltage", NULL, "%.2f", HU_FLAG_QUICK_POLL, NULL}, /* { "battery.voltage.nominal", 0, 0, "UPS.PowerSummary.ConfigVoltage", NULL, NULL, HU_FLAG_QUICK_POLL, openups_vbat_info }, */ {"battery.current", 0, 0, "UPS.PowerSummary.Current", NULL, "%.3f", HU_FLAG_QUICK_POLL, NULL}, @@ -393,4 +395,5 @@ subdriver_t openups_subdriver = { openups_format_model, openups_format_mfr, openups_format_serial, + fix_report_desc, }; diff --git a/drivers/optiups.c b/drivers/optiups.c index 26b7f47..13eedd5 100644 --- a/drivers/optiups.c +++ b/drivers/optiups.c @@ -27,7 +27,7 @@ #include "serial.h" #define DRIVER_NAME "Opti-UPS driver" -#define DRIVER_VERSION "1.01" +#define DRIVER_VERSION "1.02" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -82,34 +82,36 @@ static char _buf[256]; static int optimodel = 0; enum { OPTIMODEL_DEFAULT = 0, - OPTIMODEL_ZINTO =1 + OPTIMODEL_ZINTO = 1 }; /* Status bits returned by the "AG" command */ enum { - OPTISBIT_NOOUTPUT = 2, - OPTISBIT_OVERLOAD = 8, - OPTISBIT_REPLACE_BATTERY = 16, - OPTISBIT_ON_BATTERY_POWER = 32, - OPTISBIT_LOW_BATTERY = 64 + OPTISBIT_NOOUTPUT = 2L, + OPTISBIT_OVERLOAD = 8L, + OPTISBIT_REPLACE_BATTERY = 16L, + OPTISBIT_ON_BATTERY_POWER = 32L, + OPTISBIT_LOW_BATTERY = 64L }; /* Helper struct for the optifill() function */ typedef struct ezfill_s { const char *cmd; const char *var; - const float scale; + const float scale; /* if 0, no conversion is done and the string + is passed to dstate as is, otherwise a float + conversion with single decimal is applied */ } ezfill_t; /* These can be polled right into a string usable by NUT. * Others such as "AG" and "BV" require some transformation of the return value */ static ezfill_t _pollv[] = { - { "NV", "input.voltage" }, + { "NV", "input.voltage", 0 }, { "OL", "ups.load", 1.0 }, - { "OV", "output.voltage" }, + { "OV", "output.voltage", 0 }, { "FF", "input.frequency", 0.1 }, - { "BT", "ups.temperature" }, + { "BT", "ups.temperature", 0 }, }; static ezfill_t _pollv_zinto[] = { { "NV", "input.voltage", 2.0 }, @@ -117,22 +119,22 @@ static ezfill_t _pollv_zinto[] = { { "OV", "output.voltage", 2.0 }, { "OF", "output.frequency", 0.1 }, { "NF", "input.frequency", 0.1 }, - { "BT", "ups.temperature" }, + { "BT", "ups.temperature", 0 }, }; /* model "IO" is parsed differently in upsdrv_initinfo() */ static ezfill_t _initv[] = { - { "IM", "ups.mfr" }, - { "IZ", "ups.serial" }, - { "IS", "ups.firmware" }, + { "IM", "ups.mfr", 0 }, + { "IZ", "ups.serial", 0 }, + { "IS", "ups.firmware", 0 }, }; /* All serial reads of the OPTI-UPS go through here. We always expect a CR/LF terminated * response. Unknown/Unimplemented commands return ^U (0x15). Actions that complete * successfully return ^F (0x06). */ -static inline int optireadline(void) +static inline ssize_t optireadline(void) { - int r; + ssize_t r; usleep(150000); r = ser_get_line(upsfd, _buf, sizeof(_buf), ENDCHAR, IGNCHARS, 0, 500000 ); _buf[sizeof(_buf)-1] = 0; @@ -155,7 +157,7 @@ static inline int optireadline(void) } } else - upsdebugx(1, "READ ERROR: %d", r ); + upsdebugx(1, "READ ERROR: %zd", r ); return r; } @@ -165,7 +167,7 @@ static inline int optireadline(void) * -1 serial timeout * -2 unknown/unimplemented command */ -static inline int optiquery( const char *cmd ) +static inline ssize_t optiquery( const char *cmd ) { upsdebugx(2, "SEND: \"%s\"", cmd ); ser_send( upsfd, "%s", cmd ); @@ -175,9 +177,10 @@ static inline int optiquery( const char *cmd ) } /* Uses the ezfill_t structure to map UPS commands to the NUT variable destinations */ -static void optifill( ezfill_t *a, int len ) +static void optifill( ezfill_t *a, size_t len ) { - int i, r; + size_t i; + ssize_t r; /* Some things are easy to poll and store */ for ( i=0; i * OV - output stage voltage <118> * OL - output stage load <027> - * + * * FV - Input voltage <120> * FF - Input Frequency (0.1Hz) <600> * FO - Output volts <120> @@ -590,7 +594,7 @@ void upsdrv_cleanup(void) * bit 3: 1 = overload * bit 4: 1 = replace battery * bit 5: 1 = on battery, 0 = on line - * bit 6: 1 = low battery + * bit 6: 1 = low battery * TR - Test results <00> * 00 = Unknown * 01 = Passed @@ -598,7 +602,7 @@ void upsdrv_cleanup(void) * 03 = Error * 04 = Aborted * 05 = In Progress - * 06 = No test init + * 06 = No test init * ******************************************* * ACTIONS diff --git a/drivers/phoenixcontact_modbus.c b/drivers/phoenixcontact_modbus.c new file mode 100644 index 0000000..fb4b24e --- /dev/null +++ b/drivers/phoenixcontact_modbus.c @@ -0,0 +1,192 @@ +/* phoenixcontact_modbus.c - Driver for PhoenixContact-QUINT UPS + * + * Copyright (C) + * 2017 Spiros Ioannou + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "main.h" +#include + +#define DRIVER_NAME "NUT PhoenixContact Modbus driver" +#define DRIVER_VERSION "0.02" + +#define CHECK_BIT(var,pos) ((var) & (1<<(pos))) +#define MODBUS_SLAVE_ID 192 + +/* Variables */ +static modbus_t *modbus_ctx = NULL; +static int errcount = 0; + +static int mrir(modbus_t * arg_ctx, int addr, int nb, uint16_t * dest); + +/* driver description structure */ +upsdrv_info_t upsdrv_info = { + DRIVER_NAME, + DRIVER_VERSION, + "Spiros Ioannou \n", + DRV_BETA, + {NULL} +}; + +void upsdrv_initinfo(void) +{ + upsdebugx(2, "upsdrv_initinfo"); + + dstate_setinfo("device.mfr", "Phoenix Contact"); + dstate_setinfo("device.model", "QUINT-UPS/24DC"); + + /* upsh.instcmd = instcmd; */ + /* upsh.setvar = setvar; */ +} + +void upsdrv_updateinfo(void) +{ + errcount = 0; + + upsdebugx(2, "upsdrv_updateinfo"); + + uint16_t tab_reg[64]; + + mrir(modbus_ctx, 29697, 3, tab_reg); + + status_init(); + + if (tab_reg[0]) + status_set("OB"); + else + status_set("OL"); + + if (tab_reg[2]) { + status_set("CHRG"); + } + + if (tab_reg[1]) { + status_set("LB"); /* LB is actually called "shutdown event" on this ups */ + } + + mrir(modbus_ctx, 29745, 1, tab_reg); + dstate_setinfo("output.voltage", "%d", (int) (tab_reg[0] / 1000)); + + mrir(modbus_ctx, 29749, 5, tab_reg); + dstate_setinfo("battery.charge", "%d", tab_reg[0]); + /* dstate_setinfo("battery.runtime",tab_reg[1]*60); */ /* also reported on this address, but less accurately */ + + mrir(modbus_ctx, 29792, 10, tab_reg); + dstate_setinfo("battery.voltage", "%f", (double) (tab_reg[0]) / 1000.0); + dstate_setinfo("battery.temperature", "%d", tab_reg[1] - 273); + dstate_setinfo("battery.runtime", "%d", tab_reg[3]); + dstate_setinfo("battery.capacity", "%d", tab_reg[8] * 10); + dstate_setinfo("output.current", "%f", (double) (tab_reg[6]) / 1000.0); + + /* ALARMS */ + mrir(modbus_ctx, 29840, 1, tab_reg); + alarm_init(); + if (CHECK_BIT(tab_reg[0], 4) && CHECK_BIT(tab_reg[0], 5)) + alarm_set("End of life (Resistance)"); + if (CHECK_BIT(tab_reg[0], 6)) + alarm_set("End of life (Time)"); + if (CHECK_BIT(tab_reg[0], 7)) + alarm_set("End of life (Voltage)"); + if (CHECK_BIT(tab_reg[0], 9)) + alarm_set("No Battery"); + if (CHECK_BIT(tab_reg[0], 10)) + alarm_set("Inconsistent technology"); + if (CHECK_BIT(tab_reg[0], 11)) + alarm_set("Overload Cutoff"); + /* We don't use those low-battery indicators below. + * No info or configuration exists for those alarm low-bat + */ + if (CHECK_BIT(tab_reg[0], 12)) + alarm_set("Low Battery (Voltage)"); + if (CHECK_BIT(tab_reg[0], 13)) + alarm_set("Low Battery (Charge)"); + if (CHECK_BIT(tab_reg[0], 14)) + alarm_set("Low Battery (Time)"); + if (CHECK_BIT(tab_reg[0], 16)) + alarm_set("Low Battery (Service)"); + + if (errcount == 0) { + alarm_commit(); + status_commit(); + dstate_dataok(); + } + else + dstate_datastale(); + +} + +void upsdrv_shutdown(void) + __attribute__((noreturn)); + +void upsdrv_shutdown(void) +{ + fatalx(EXIT_FAILURE, "shutdown not supported"); +} + +void upsdrv_help(void) +{ +} + +/* list flags and values that you want to receive via -x */ +void upsdrv_makevartable(void) +{ +} + +void upsdrv_initups(void) +{ + int r; + upsdebugx(2, "upsdrv_initups"); + + modbus_ctx = modbus_new_rtu(device_path, 115200, 'E', 8, 1); + if (modbus_ctx == NULL) + fatalx(EXIT_FAILURE, "Unable to create the libmodbus context"); + + r = modbus_set_slave(modbus_ctx, MODBUS_SLAVE_ID); /* slave ID */ + if (r < 0) { + modbus_free(modbus_ctx); + fatalx(EXIT_FAILURE, "Invalid modbus slave ID %d",MODBUS_SLAVE_ID); + } + + if (modbus_connect(modbus_ctx) == -1) { + modbus_free(modbus_ctx); + fatalx(EXIT_FAILURE, "modbus_connect: unable to connect: %s", modbus_strerror(errno)); + } + +} + + +void upsdrv_cleanup(void) +{ + if (modbus_ctx != NULL) { + modbus_close(modbus_ctx); + modbus_free(modbus_ctx); + } +} + +/* Modbus Read Input Registers */ +static int mrir(modbus_t * arg_ctx, int addr, int nb, uint16_t * dest) +{ + int r; + r = modbus_read_input_registers(arg_ctx, addr, nb, dest); + if (r == -1) { + upslogx(LOG_ERR, "mrir: modbus_read_input_registers(addr:%d, count:%d): %s (%s)", addr, nb, modbus_strerror(errno), device_path); + errcount++; + } + return r; +} diff --git a/drivers/pijuice.c b/drivers/pijuice.c new file mode 100644 index 0000000..a1b1db1 --- /dev/null +++ b/drivers/pijuice.c @@ -0,0 +1,853 @@ +/* pijuice.c Driver for the PiJuice HAT (www.pijuice.com), addressed via i2c. + + Copyright (C) 2019 Andrew Anderson + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "main.h" + +#include +#include + +/* + * Linux I2C userland is a bit of a mess until distros refresh to + * the i2c-tools 4.x release that profides i2c/smbus.h for userspace + * instead of (re)using linux/i2c-dev.h, which conflicts with a + * kernel header of the same name. + * + * See: + * https://i2c.wiki.kernel.org/index.php/Plans_for_I2C_Tools_4 + */ +#if HAVE_LINUX_SMBUS_H +# include +#endif +#if HAVE_LINUX_I2C_DEV_H +# include /* for I2C_SLAVE */ +# if !HAVE_LINUX_SMBUS_H +# ifndef I2C_FUNC_I2C +# include +# endif +# endif +#endif + +/* + * i2c-tools pre-4.0 has a userspace header with a name that conflicts + * with a kernel header, so it may be ignored/removed by distributions + * when packaging i2c-tools. + * + * This will cause the driver to be un-buildable on certain + * configurations, so include the necessary bits here to handle this + * situation. + */ +#if WITH_LINUX_I2C +#if !HAVE_DECL_I2C_SMBUS_ACCESS +static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command, + int size, union i2c_smbus_data *data) +{ + struct i2c_smbus_ioctl_data args; + __s32 err; + + args.read_write = read_write; + args.command = command; + args.size = size; + args.data = data; + + err = ioctl(file, I2C_SMBUS, &args); + if (err == -1) + err = -errno; + return err; +} +#endif + +#if !HAVE_DECL_I2C_SMBUS_READ_BYTE_DATA +static inline __s32 i2c_smbus_read_byte_data(int file, __u8 command) +{ + union i2c_smbus_data data; + int err; + + if ((err = i2c_smbus_access(file, I2C_SMBUS_READ, command, + I2C_SMBUS_BYTE_DATA, &data)) < 0) + return err; + else + return 0x0FF & data.byte; +} +#endif + +#if !HAVE_DECL_I2C_SMBUS_WRITE_BYTE_DATA +static inline __s32 i2c_smbus_write_byte_data(int file, __u8 command, __u8 value) +{ + union i2c_smbus_data data; + int err; + + data.byte = value; + if ((err = i2c_smbus_access(file, I2C_SMBUS_WRITE, command, + I2C_SMBUS_BYTE_DATA, &data)) < 0) + return err; + else + return 0x0FF & data.byte; +} +#endif + +#if !HAVE_DECL_I2C_SMBUS_READ_WORD_DATA +static inline __s32 i2c_smbus_read_word_data(int file, __u8 command) +{ + union i2c_smbus_data data; + int err; + + if ((err = i2c_smbus_access(file, I2C_SMBUS_READ, command, + I2C_SMBUS_WORD_DATA, &data)) < 0) + return err; + else + return 0x0FFFF & data.word; +} +#endif + +#if !HAVE_DECL_I2C_SMBUS_WRITE_WORD_DATA +static inline __s32 i2c_smbus_write_word_data(int file, __u8 command, __u16 value) +{ + union i2c_smbus_data data; + int err; + + data.word = value; + if ((err = i2c_smbus_access(file, I2C_SMBUS_WRITE, command, + I2C_SMBUS_WORD_DATA, &data)) < 0) + return err; + else + return 0x0FFFF & data.word; +} +#endif + +#if !HAVE_DECL_I2C_SMBUS_READ_BLOCK_DATA +static inline __u8* i2c_smbus_read_i2c_block_data(int file, __u8 command, __u8 length, __u8 *values) +{ + union i2c_smbus_data data; + int err; + + if ( length > I2C_SMBUS_BLOCK_MAX) + { + length = I2C_SMBUS_BLOCK_MAX; + } + + data.block[0] = length; + memcpy(data.block + 1, values, length); + + if ((err = i2c_smbus_access(file, I2C_SMBUS_READ, command, + I2C_SMBUS_I2C_BLOCK_DATA, &data)) < 0) + return NULL; + else + memcpy(values, &data.block[1], data.block[0]); + + return values; +} +#endif +#endif // if WITH_LINUX_I2C + +#define STATUS_CMD 0x40 +#define CHARGE_LEVEL_CMD 0x41 +#define CHARGE_LEVEL_HI_RES_CMD 0x42 +#define FAULT_EVENT_CMD 0x44 +#define BUTTON_EVENT_CMD 0x45 +#define BATTERY_TEMPERATURE_CMD 0x47 +#define BATTERY_VOLTAGE_CMD 0x49 +#define BATTERY_CURRENT_CMD 0x4b +#define IO_VOLTAGE_CMD 0x4d +#define IO_CURRENT_CMD 0x4f + +#define CHARGING_CONFIG_CMD 0x51 +#define BATTERY_PROFILE_ID_CMD 0x52 +#define BATTERY_PROFILE_CMD 0x53 +#define BATTERY_EXT_PROFILE_CMD 0x54 +#define BATTERY_TEMP_SENSE_CONFIG_CMD 0x5D + +#define POWER_INPUTS_CONFIG_CMD 0x5E +#define RUN_PIN_CONFIG_CMD 0x5F +#define POWER_REGULATOR_CONFIG_CMD 0x60 +#define WATCHDOG_ACTIVATION_CMD 0x61 +#define POWER_OFF_CMD 0x62 +#define WAKEUP_ON_CHARGE_CMD 0x63 +#define SYSTEM_POWER_SWITCH_CTRL_CMD 0x64 + +#define LED_STATE_CMD 0x66 +#define LED_BLINK_CMD 0x68 +#define LED_CONFIGURATION_CMD 0x6A +#define BUTTON_CONFIGURATION_CMD 0x6E + +#define IO1_CONFIGURATION_CMD 0x72 +#define IO1_PIN_ACCESS_CMD 0x75 + +#define IO2_CONFIGURATION_CMD 0x77 +#define IO2_PIN_ACCESS_CMD 0x7A + +#define I2C_ADDRESS_CMD 0x7C + +#define ID_EEPROM_WRITE_PROTECT_CTRL_CMD 0x7E +#define ID_EEPROM_ADDRESS_CMD 0x7F + +#define RTC_TIME_CMD 0xB0 +#define RTC_ALARM_CMD 0xB9 +#define RTC_CTRL_STATUS_CMD 0xC2 + +#define RESET_TO_DEFAULT_CMD 0xF0 +#define FIRMWARE_VERSION_CMD 0xFD + +#define BATT_NORMAL 0 +#define BATT_CHARGING_FROM_IN 1 +#define BATT_CHARGING_FROM_5V 2 +#define BATT_NOT_PRESENT 3 + +#define POWER_NOT_PRESENT 0 +#define POWER_BAD 1 +#define POWER_WEAK 2 +#define POWER_PRESENT 3 + +#define LOW_BATTERY_THRESHOLD 25.0 +#define HIGH_BATTERY_THRESHOLD 75.0 +#define NOMINAL_BATTERY_VOLTAGE 4.18 + +#define DRIVER_NAME "PiJuice UPS driver" +#define DRIVER_VERSION "0.10" + +static uint8_t i2c_address = 0x14; +static uint8_t shutdown_delay = 30; + +/* + * Flags used to indicate a change in power status + */ +static uint8_t usb_power = 0; +static uint8_t gpio_power = 0; +static uint8_t battery_power = 0; + +/* + * Smooth out i2c read errors by holding the most recent + * battery charge level reading + */ +static float battery_charge_level = 0; + +/* driver description structure */ +upsdrv_info_t upsdrv_info = { + DRIVER_NAME, + DRIVER_VERSION, + "Andrew Anderson ", + DRV_EXPERIMENTAL, + { NULL } +}; + +/* The macros below all write into a "data" variable defined by the routine + * scope which calls them, with respective type of uint8_t for "byte" and + * uint16_t for "word" macros. Native i2c functions operate with __s32 type + * (currently, signed 32-bit ints?) with negative values for error returns. + * Note: some manpages refer to "s32" while headers on my and CI systems use + * a "__s32" type. Maybe this is something to determine in configure script? + * Code below was fixed to convert the valid values and avoid compiler + * warnings about comparing whether unsigned ints happened to be negative. + */ +#define I2C_READ_BYTE(fd, cmd, label) \ + { \ + __s32 sData; \ + if ((sData = i2c_smbus_read_byte_data(upsfd, cmd)) < 0 ) { \ + upsdebugx(2, "Failure reading the i2c bus [%s]", label); \ + return; \ + } ; \ + data = (uint8_t) sData; \ + } + +#define I2C_WRITE_BYTE(fd, cmd, value, label) \ + { \ + if ( i2c_smbus_write_byte_data(upsfd, cmd, value) < 0 ) { \ + upsdebugx(2, "Failure writing to the i2c bus [%s]", label); \ + return; \ + } ; \ + } + +#define I2C_READ_WORD(fd, cmd, label) \ + { \ + __s32 sData; \ + if ((sData = i2c_smbus_read_word_data(upsfd, cmd)) < 0 ) { \ + upsdebugx(2, "Failure reading the i2c bus [%s]", label); \ + return; \ + } ; \ + data = (uint16_t) sData; \ + } + +#define I2C_READ_BLOCK(fd, cmd, size, block, label) \ + if ((i2c_smbus_read_i2c_block_data(upsfd, cmd, size, block)) < 0 ) { \ + upsdebugx(2, "Failure reading the i2c bus [%s]", label); \ + return; \ + } + +static inline int open_i2c_bus(char *path, uint8_t addr) +{ + int file; + + if ((file = open(path, O_RDWR)) < 0) + { + fatal_with_errno(EXIT_FAILURE, "Failed to open the i2c bus on %s", path); + } + + if (ioctl(file, I2C_SLAVE, addr) < 0) + { + fatal_with_errno(EXIT_FAILURE, "Failed to acquire the i2c bus and/or talk to the UPS"); + } + + return file; +} + +static void get_charge_level_hi_res() +{ + uint8_t cmd = CHARGE_LEVEL_HI_RES_CMD; + uint16_t data; + + upsdebugx( 3, __func__ ); + + I2C_READ_WORD( upsfd, cmd, __func__ ) + + /* + * Use an external variable to allow for missed i2c bus + * reads; the charge level data may be slightly stale, + * but no other options seem reasonable: + * + * 1) store 0 + * Leads to a false report of a depleted battery, possibly + * triggering an immediate shutdown if on battery power only + * 2) store -1 + * Adds a lot of logic to "skip" over negative charge levels, + * which effectively accomplishes the same thing + * 3) retry the read immediately + * Could tie up the i2c bus and make matters exponentially worse + */ + battery_charge_level = data / 10.0; + + upsdebugx( 1, "Battery Charge Level: %02.1f%%", battery_charge_level ); + dstate_setinfo( "battery.charge", "%02.1f", battery_charge_level ); +} + +static void get_status() +{ + uint8_t cmd = STATUS_CMD; + uint8_t data; + char status_buf[ST_MAX_VALUE_LEN]; + + upsdebugx( 3, __func__ ); + + memset( status_buf, 0, ST_MAX_VALUE_LEN ); + + I2C_READ_BYTE( upsfd, cmd, __func__ ) + + uint8_t batteryStatus = data >> 2 & 0x03; + switch( batteryStatus ) + { + case BATT_NORMAL: + upsdebugx( 1, "Battery Status: Normal" ); + dstate_setinfo( "battery.packs", "%d", 1 ); + dstate_setinfo( "battery.packs.bad", "%d", 0 ); + break; + case BATT_CHARGING_FROM_IN: + upsdebugx( 1, "Battery Status: Charging from IN" ); + dstate_setinfo( "battery.packs", "%d", 1 ); + dstate_setinfo( "battery.packs.bad", "%d", 0 ); + break; + case BATT_CHARGING_FROM_5V: + upsdebugx( 1, "Battery Status: Charging from 5V" ); + dstate_setinfo( "battery.packs", "%d", 1 ); + dstate_setinfo( "battery.packs.bad", "%d", 0 ); + break; + case BATT_NOT_PRESENT: + upsdebugx( 1, "Battery Status: Not Present" ); + dstate_setinfo( "battery.packs", "%d", 0 ); + dstate_setinfo( "battery.packs.bad", "%d", 1 ); + break; + default: + upsdebugx( 1, "battery.status: UNKNOWN" ); + } + + uint8_t powerInput = data >> 4 & 0x03; + switch( powerInput ) + { + case POWER_NOT_PRESENT: + upsdebugx( 1, "Power Input: Not Present" ); + break; + case POWER_BAD: + upsdebugx( 1, "Power Input: Bad" ); + break; + case POWER_WEAK: + upsdebugx( 1, "Power Input: Weak" ); + break; + case POWER_PRESENT: + upsdebugx( 1, "Power Input: Present" ); + break; + default: + upsdebugx( 1, "Power Input: UNKNOWN" ); + } + + uint8_t powerInput5vIo = data >> 6 & 0x03; + switch( powerInput5vIo ) + { + case POWER_NOT_PRESENT : + upsdebugx(1, "Power Input 5v: Not Present"); + break; + case POWER_BAD: + upsdebugx(1, "Power Input 5v: Bad"); + break; + case POWER_WEAK: + upsdebugx(1, "Power Input 5v: Weak"); + break; + case POWER_PRESENT: + upsdebugx(1, "Power Input 5v: Present"); + break; + default: + upsdebugx(1, "Power Input 5v: UNKNOWN"); + } + + if ( batteryStatus == BATT_NORMAL || + batteryStatus == BATT_CHARGING_FROM_IN || + batteryStatus == BATT_CHARGING_FROM_5V ) + { + get_charge_level_hi_res(); + + if ( battery_charge_level <= LOW_BATTERY_THRESHOLD ) + { + upsdebugx( 1, "Battery Charge Status: LOW" ); + snprintfcat( status_buf, ST_MAX_VALUE_LEN, "LB " ); + } + else if ( battery_charge_level > HIGH_BATTERY_THRESHOLD ) + { + upsdebugx( 1, "Battery Charge Status: HIGH" ); + snprintfcat( status_buf, ST_MAX_VALUE_LEN, "HB " ); + } + } + else if ( batteryStatus == BATT_NOT_PRESENT ) + { + snprintfcat( status_buf, ST_MAX_VALUE_LEN, "RB " ); + } + + if ( batteryStatus <= BATT_NOT_PRESENT && + powerInput <= POWER_PRESENT && + powerInput5vIo <= POWER_PRESENT ) + { + if ( powerInput == POWER_NOT_PRESENT && + ( powerInput5vIo != POWER_NOT_PRESENT )) + { + if ( usb_power != 1 || gpio_power != 0 ) + { + upslogx( LOG_NOTICE, "On USB power" ); + } + usb_power = 1; + gpio_power = 0; + battery_power = 0; + upsdebugx( 1, "On USB power [%d:%d:%d]", usb_power, gpio_power, battery_power ); + + snprintfcat( status_buf, sizeof(status_buf), "OL" ); + if ( batteryStatus == BATT_CHARGING_FROM_5V ) + { + snprintfcat( status_buf, sizeof( status_buf ), " CHRG" ); + upsdebugx( 1, "Battery Charger Status: charging" ); + dstate_setinfo( "battery.charger.status", "%s", "charging" ); + } + else if ( batteryStatus == BATT_NORMAL ) + { + upsdebugx( 1, "Battery Charger Status: resting" ); + dstate_setinfo( "battery.charger.status", "%s", "resting" ); + } + status_set( status_buf ); + } + else if ( powerInput5vIo == POWER_NOT_PRESENT && + ( powerInput != POWER_NOT_PRESENT && + powerInput <= POWER_PRESENT )) + { + if ( gpio_power != 1 || usb_power != 0 ) + { + upslogx( LOG_NOTICE, "On 5V_GPIO power" ); + } + usb_power = 0; + gpio_power = 1; + battery_power = 0; + upsdebugx( 1, "On 5V_GPIO power [%d:%d:%d]", usb_power, gpio_power, battery_power ); + + snprintfcat( status_buf, sizeof(status_buf), "OL" ); + if ( batteryStatus == BATT_CHARGING_FROM_IN ) + { + snprintfcat( status_buf, sizeof(status_buf), " CHRG" ); + status_set( status_buf ); + upsdebugx( 1, "Battery Charger Status: charging" ); + dstate_setinfo( "battery.charger.status", "%s", "charging" ); + } + else if ( batteryStatus == BATT_NORMAL ) + { + status_set( status_buf ); + upsdebugx( 1, "Battery Charger Status: resting" ); + dstate_setinfo( "battery.charger.status", "%s", "resting" ); + } + } + else if ( ( powerInput != POWER_NOT_PRESENT && powerInput <= POWER_PRESENT ) && + ( powerInput5vIo != POWER_NOT_PRESENT && powerInput5vIo <= POWER_PRESENT )) + { + if ( usb_power != 1 || gpio_power != 1 ) + { + upslogx( LOG_NOTICE, "On USB and 5V_GPIO power" ); + } + usb_power = 1; + gpio_power = 1; + battery_power = 0; + upsdebugx( 1, "On USB and 5V_GPIO power [%d:%d:%d]", usb_power, gpio_power, battery_power ); + + snprintfcat( status_buf, sizeof( status_buf ), "OL" ); + if ( batteryStatus == BATT_CHARGING_FROM_IN ) + { + snprintfcat( status_buf, sizeof(status_buf), " CHRG"); + status_set( status_buf ); + upsdebugx( 1, "Battery Charger Status: charging" ); + dstate_setinfo("battery.charger.status", "%s", "charging"); + } + else if ( batteryStatus == BATT_NORMAL ) + { + status_set( status_buf ); + upsdebugx( 1, "Battery Charger Status: resting" ); + dstate_setinfo( "battery.charger.status", "%s", "resting" ); + } + } + else if ( powerInput == POWER_NOT_PRESENT && powerInput5vIo == POWER_NOT_PRESENT ) + { + if ( usb_power != 0 || gpio_power != 0 ) + { + upslogx( LOG_NOTICE, "On Battery power" ); + } + usb_power = 0; + gpio_power = 0; + battery_power = 1; + upsdebugx( 1, "On Battery power [%d:%d:%d]", usb_power, gpio_power, battery_power ); + + snprintfcat( status_buf, sizeof(status_buf), "OB DISCHRG" ); + status_set( status_buf ); + } + } +} + +static void get_battery_temperature() +{ + uint8_t cmd = BATTERY_TEMPERATURE_CMD; + int16_t data; + + upsdebugx( 3, __func__ ); + + I2C_READ_WORD( upsfd, cmd, __func__ ) + + upsdebugx( 1, "Battery Temperature: %d°C", data ); + dstate_setinfo( "battery.temperature", "%d", data ); +} + +static void get_battery_voltage() +{ + uint8_t cmd = BATTERY_VOLTAGE_CMD; + int16_t data; + + upsdebugx( 3, __func__ ); + + I2C_READ_WORD( upsfd, cmd, __func__ ) + + upsdebugx( 1, "Battery Voltage: %0.3fV", data / 1000.0 ); + dstate_setinfo( "battery.voltage", "%0.3f", data / 1000.0 ); +} + +static void get_battery_current() +{ + uint8_t cmd = BATTERY_CURRENT_CMD; + int16_t data; + + upsdebugx( 3, __func__ ); + + /* + * The reported current can actually be negative, so we cannot + * check for I2C failure by looking for negative values + */ + data = i2c_smbus_read_word_data(upsfd, cmd); + + if ( data & ( 1 << 15 ) ) + { + data = data - ( 1 << 16 ); + } + + upsdebugx( 1, "Battery Current: %0.3fA", data / 1000.0 ); + dstate_setinfo( "battery.current", "%0.3f", data / 1000.0 ); +} + +static void get_io_voltage() +{ + uint8_t cmd = IO_VOLTAGE_CMD; + int16_t data; + + upsdebugx( 3, __func__ ); + + I2C_READ_WORD( upsfd, cmd, __func__ ) + + upsdebugx( 1, "Input Voltage: %.3fV", data / 1000.0 ); + dstate_setinfo( "input.voltage", "%.3f", data / 1000.0 ); +} + +static void get_io_current() +{ + uint8_t cmd = IO_CURRENT_CMD; + int16_t data; + + upsdebugx( 3, __func__ ); + + /* + * The reported current can actually be negative, so we cannot + * check for I2C failure by looking for negative values + */ + data = i2c_smbus_read_word_data(upsfd, cmd); + + if ( data & ( 1 << 15 ) ) + { + data = data - ( 1 << 16 ); + } + + upsdebugx( 1, "Input Current: %.3fA", data / 1000.0 ); + dstate_setinfo( "input.current", "%.3f", data / 1000.0 ); +} + +static void get_firmware_version() +{ + uint8_t cmd = FIRMWARE_VERSION_CMD; + uint16_t data; + uint8_t major, minor; + + upsdebugx( 3, __func__ ); + + I2C_READ_WORD( upsfd, cmd, __func__ ) + + major = data >> 4; + minor = ( data << 4 & 0xf0 ) >> 4; + + if (( major != 1 ) || ( minor > 3 )) + { + upslogx( LOG_WARNING, "Unknown Firmware release: %d.%d", major, minor ); + } + + upsdebugx( 1, "UPS Firmware Version: %d.%d", major, minor ); + dstate_setinfo( "ups.firmware", "%d.%d", major, minor ); +} + +static void get_battery_profile() +{ + uint8_t cmd = BATTERY_PROFILE_CMD; + __u8 block[I2C_SMBUS_BLOCK_MAX]; + + upsdebugx( 3, __func__ ); + + I2C_READ_BLOCK( upsfd, cmd, 14, block, __func__ ) + + upsdebugx( 1, "Battery Capacity: %0.3fAh", ( block[1] << 8 | block[0] ) / 1000.0 ); + dstate_setinfo( "battery.capacity", "%0.3f", ( block[1] << 8 | block[0] ) / 1000.0 ); +} + +static void get_battery_profile_ext() +{ + uint8_t cmd = BATTERY_EXT_PROFILE_CMD; + __u8 block[I2C_SMBUS_BLOCK_MAX]; + + upsdebugx( 3, __func__ ); + + I2C_READ_BLOCK( upsfd, cmd, 17, block, __func__ ) + + switch( block[0] & 0xFF00 ) + { + case 0: + upsdebugx( 1, "Battery Chemistry: LiPO" ); + dstate_setinfo( "battery.type", "%s", "LiPO" ); + break; + case 1: + upsdebugx( 1, "Battery Chemistry: LiFePO4" ); + dstate_setinfo( "battery.type", "%s", "LiFePO4" ); + break; + default: + upsdebugx( 1, "Battery Chemistry: UNKNOWN" ); + dstate_setinfo( "battery.type", "%s", "UNKNOWN" ); + } +} + +static void get_power_off() +{ + uint8_t cmd = POWER_OFF_CMD; + uint8_t data; + + upsdebugx( 3, __func__ ); + + I2C_READ_BYTE( upsfd, cmd, __func__ ) + + if ( data == 255 ) + { + upsdebugx( 1, "Power Off: DISABLED" ); + } + else if ( data <= 250 ) + { + upsdebugx( 1, "Power Off: %d Seconds", data ); + } +} + +static void set_power_off() +{ + uint8_t cmd = POWER_OFF_CMD; + + upsdebugx( 3, __func__ ); + + /* + * Acceptable values for shutdown_delay are 1-250, + * use 0/255 to clear a scheduled power off command + */ + + if ( shutdown_delay > 250 ) + { + upslogx( + LOG_WARNING, + "shutdown delay of >250 seconds requested, shortening to 250 seconds" + ); + shutdown_delay = 250; + } + + if ( shutdown_delay == 0 ) + { + upslogx( + LOG_WARNING, + "shutdown delay of 0 seconds requested, using 1 second instead" + ); + shutdown_delay = 1; + } + + I2C_WRITE_BYTE( upsfd, cmd, shutdown_delay, __func__ ) +} + +static void get_time() +{ + uint8_t cmd = RTC_TIME_CMD; + __u8 block[I2C_SMBUS_BLOCK_MAX]; + uint8_t second, minute, hour, day, month, subsecond; + uint16_t year; + + upsdebugx( 3, __func__ ); + + I2C_READ_BLOCK( upsfd, cmd, 9, block, __func__ ) + + second = (( (block[0] >> 4 ) & 0x07) * 10 ) + ( block[0] & 0x0F ); + minute = (( (block[1] >> 4 ) & 0x07) * 10 ) + ( block[1] & 0x0F ); + hour = (( (block[2] >> 4 ) & 0x03) * 10 ) + ( block[2] & 0x0F ); + day = (( (block[4] >> 4 ) & 0x03) * 10 ) + ( block[4] & 0x0F ); + month = (( (block[5] >> 4 ) & 0x01) * 10 ) + ( block[5] & 0x0F ); + year = (( (block[6] >> 4 ) & 0x0F) * 10 ) + ( block[6] & 0x0F ) + 2000; + subsecond = block[7] * 100 / 256; + + upsdebugx( 1, "UPS Time: %02d:%02d:%02d.%02d", hour, minute, second, subsecond ); + dstate_setinfo( "ups.time", "%02d:%02d:%02d.%02d", hour, minute, second, subsecond ); + + upsdebugx( 1, "UPS Date: %04d-%02d-%02d", year, month, day ); + dstate_setinfo( "ups.date", "%04d-%02d-%02d", year, month, day ); +} + +static void get_i2c_address() +{ + uint8_t cmd = I2C_ADDRESS_CMD; + uint8_t data; + + upsdebugx( 3, __func__ ); + + I2C_READ_BYTE( upsfd, cmd, __func__ ) + + upsdebugx( 1, "I2C Address: 0x%0x", data ); + + if ( data == i2c_address ) + { + upsdebugx( 1, "Found device '0x%0x' on port '%s'", + (unsigned int) i2c_address, device_path ); + } + else + { + fatalx( EXIT_FAILURE, + "Could not find PiJuice HAT at I2C address 0x%0x", + i2c_address ); + } +} + +void upsdrv_initinfo(void) +{ + + dstate_setinfo( "ups.mfr", "%s", "PiJuice" ); + dstate_setinfo( "ups.type", "%s", "HAT" ); + + /* note: for a transition period, these data are redundant */ + + dstate_setinfo( "device.mfr", "%s", "PiJuice" ); + dstate_setinfo( "device.type", "%s", "HAT" ); + + upsdebugx( 1, "Low Battery Threshold: %0.0f%%", LOW_BATTERY_THRESHOLD ); + dstate_setinfo( "battery.charge.low", "%0.0f", LOW_BATTERY_THRESHOLD ); + + upsdebugx( 1, "Nominal Battery Voltage: %0.3fV", NOMINAL_BATTERY_VOLTAGE ); + dstate_setinfo( "battery.voltage.nominal", "%0.3f", NOMINAL_BATTERY_VOLTAGE ); + + get_i2c_address(); + get_battery_profile(); + get_battery_profile_ext(); +} + +void upsdrv_updateinfo(void) +{ + status_init(); + + get_status(); + get_battery_temperature(); + get_battery_voltage(); + get_battery_current(); + get_io_voltage(); + get_io_current(); + get_time(); + get_power_off(); + + status_commit(); + dstate_dataok(); +} + +void upsdrv_shutdown(void) +{ + set_power_off(); +} + +void upsdrv_help(void) +{ + printf("\nThe default I2C address is 20 [0x14]\n"); + printf("\n"); +} + +void upsdrv_makevartable(void) +{ + addvar(VAR_VALUE, "i2c_address", "Override i2c address setting"); +} + +void upsdrv_initups(void) +{ + upsfd = open_i2c_bus( device_path, i2c_address ); + + /* probe ups type */ + get_firmware_version(); + + /* get variables and flags from the command line */ + + if (getval("i2c_address")) + i2c_address = atoi(getval("i2c_address")); +} + +void upsdrv_cleanup(void) +{ + close(upsfd); +} diff --git a/drivers/powercom-hid.c b/drivers/powercom-hid.c index fbe6332..a3973ff 100644 --- a/drivers/powercom-hid.c +++ b/drivers/powercom-hid.c @@ -25,7 +25,7 @@ #include "powercom-hid.h" #include "usb-common.h" -#define POWERCOM_HID_VERSION "PowerCOM HID 0.5" +#define POWERCOM_HID_VERSION "PowerCOM HID 0.6" /* FIXME: experimental flag to be put in upsdrv_info */ /* PowerCOM */ @@ -48,7 +48,7 @@ static usb_device_id_t powercom_usb_device_table[] = { { USB_DEVICE(POWERCOM_VENDORID, 0x0001), NULL }, /* Terminating entry */ - { -1, -1, NULL } + { 0, 0, NULL } }; static char powercom_scratch_buf[32]; @@ -67,9 +67,18 @@ static double powercom_startup_nuf(const char *value) { const char *s = dstate_getinfo("ups.delay.start"); uint16_t val, command; + int iv; - val = atoi(value ? value : s) / 60; - command = ((val << 8) + (val >> 8)); + iv = atoi(value ? value : s) / 60; + if (iv < 0 || (intmax_t)iv > (intmax_t)UINT16_MAX) { + upsdebugx(0, "%s: value = %d is not in uint16_t range", __func__, iv); + return 0; + } + + /* COMMENTME: What are we doing here, a byte-swap in the word? */ + val = (uint16_t)iv; + command = (uint16_t)(val << 8); + command += (uint16_t)(val >> 8); upsdebugx(3, "%s: value = %s, command = %04X", __func__, value, command); return command; @@ -93,10 +102,17 @@ static double powercom_shutdown_nuf(const char *value) { const char *s = dstate_getinfo("ups.delay.shutdown"); uint16_t val, command; + int iv; - val = atoi(value ? value : s); + iv = atoi(value ? value : s); + if (iv < 0 || (intmax_t)iv > (intmax_t)UINT16_MAX) { + upsdebugx(0, "%s: value = %d is not in uint16_t range", __func__, iv); + return 0; + } + + val = (uint16_t)iv; val = val ? val : 1; /* 0 sets the maximum delay */ - command = ((val % 60) << 8) + (val / 60); + command = ((uint16_t)((val % 60) << 8)) + (uint16_t)(val / 60); command |= 0x4000; /* AC RESTART NORMAL ENABLE */ upsdebugx(3, "%s: value = %s, command = %04X", __func__, value, command); @@ -111,10 +127,17 @@ static double powercom_stayoff_nuf(const char *value) { const char *s = dstate_getinfo("ups.delay.shutdown"); uint16_t val, command; + int iv; - val = atoi(value ? value : s); + iv = atoi(value ? value : s); + if (iv < 0 || (intmax_t)iv > (intmax_t)UINT16_MAX) { + upsdebugx(0, "%s: value = %d is not in uint16_t range", __func__, iv); + return 0; + } + + val = (uint16_t)iv; val = val ? val : 1; /* 0 sets the maximum delay */ - command = ((val % 60) << 8) + (val / 60); + command = ((uint16_t)((val % 60) << 8)) + (uint16_t)(val / 60); command |= 0x8000; /* AC RESTART NORMAL DISABLE */ upsdebugx(3, "%s: value = %s, command = %04X", __func__, value, command); @@ -126,9 +149,9 @@ static info_lkp_t powercom_stayoff_info[] = { }; static info_lkp_t powercom_beeper_info[] = { - { 1, "enabled", NULL }, - { 2, "disabled", NULL }, /* muted? */ - { 0, NULL, NULL } + { 1, "enabled", NULL, NULL }, + { 2, "disabled", NULL, NULL }, /* muted? */ + { 0, NULL, NULL, NULL } }; static const char *powercom_voltage_conversion_fun(double value) @@ -139,7 +162,7 @@ static const char *powercom_voltage_conversion_fun(double value) } static info_lkp_t powercom_voltage_conversion[] = { - { 0, NULL, powercom_voltage_conversion_fun } + { 0, NULL, powercom_voltage_conversion_fun, NULL } }; static const char *powercom_upsfail_conversion_fun(double value) @@ -152,7 +175,7 @@ static const char *powercom_upsfail_conversion_fun(double value) } static info_lkp_t powercom_upsfail_conversion[] = { - { 0, NULL, powercom_upsfail_conversion_fun } + { 0, NULL, powercom_upsfail_conversion_fun, NULL } }; static const char *powercom_replacebatt_conversion_fun(double value) @@ -165,7 +188,7 @@ static const char *powercom_replacebatt_conversion_fun(double value) } static info_lkp_t powercom_replacebatt_conversion[] = { - { 0, NULL, powercom_replacebatt_conversion_fun } + { 0, NULL, powercom_replacebatt_conversion_fun, NULL } }; static const char *powercom_test_conversion_fun(double value) @@ -178,7 +201,7 @@ static const char *powercom_test_conversion_fun(double value) } static info_lkp_t powercom_test_conversion[] = { - { 0, NULL, powercom_test_conversion_fun } + { 0, NULL, powercom_test_conversion_fun, NULL } }; static const char *powercom_shutdownimm_conversion_fun(double value) @@ -191,7 +214,7 @@ static const char *powercom_shutdownimm_conversion_fun(double value) } static info_lkp_t powercom_shutdownimm_conversion[] = { - { 0, NULL, powercom_shutdownimm_conversion_fun } + { 0, NULL, powercom_shutdownimm_conversion_fun, NULL } }; static const char *powercom_online_conversion_fun(double value) @@ -204,7 +227,7 @@ static const char *powercom_online_conversion_fun(double value) } static info_lkp_t powercom_online_conversion[] = { - { 0, NULL, powercom_online_conversion_fun } + { 0, NULL, powercom_online_conversion_fun, NULL } }; static const char *powercom_lowbatt_conversion_fun(double value) @@ -217,7 +240,7 @@ static const char *powercom_lowbatt_conversion_fun(double value) } static info_lkp_t powercom_lowbatt_conversion[] = { - { 0, NULL, powercom_lowbatt_conversion_fun } + { 0, NULL, powercom_lowbatt_conversion_fun, NULL } }; static const char *powercom_trim_conversion_fun(double value) @@ -230,7 +253,7 @@ static const char *powercom_trim_conversion_fun(double value) } static info_lkp_t powercom_trim_conversion[] = { - { 0, NULL, powercom_trim_conversion_fun } + { 0, NULL, powercom_trim_conversion_fun, NULL } }; static const char *powercom_boost_conversion_fun(double value) @@ -243,7 +266,7 @@ static const char *powercom_boost_conversion_fun(double value) } static info_lkp_t powercom_boost_conversion[] = { - { 0, NULL, powercom_boost_conversion_fun } + { 0, NULL, powercom_boost_conversion_fun, NULL } }; static const char *powercom_overload_conversion_fun(double value) @@ -256,7 +279,7 @@ static const char *powercom_overload_conversion_fun(double value) } static info_lkp_t powercom_overload_conversion[] = { - { 0, NULL, powercom_overload_conversion_fun } + { 0, NULL, powercom_overload_conversion_fun, NULL } }; /* --------------------------------------------------------------- */ @@ -422,6 +445,7 @@ static hid_info_t powercom_hid2nut[] = { /* { "UPS.DesignCapacity", 0, 0, "PowercomUPS.PowercomDesignCapacity", NULL, "%.0f", 0, NULL }, is always 255 */ { "ups.mfr.date", 0, 0, "PowercomUPS.PowercomManufacturerDate", NULL, "%s", 0, date_conversion }, { "battery.temperature", 0, 0, "PowercomUPS.PowercomBatterySystem.PowercomTemperature", NULL, "%.0f", 0, NULL }, + { "battery.temperature", 0, 0, "UPS.Battery.Temperature", NULL, "%.1f", 0, NULL }, { "battery.charge", 0, 0, "PowercomUPS.PowercomBatterySystem.PowercomVoltage", NULL, "%.0f", 0, NULL }, /* { "UPS.BatterySystem.SpecificationInfo", 0, 0, "PowercomUPS.PowercomBatterySystem.PowercomSpecificationInfo", NULL, "%.0f", 0, NULL }, */ { "input.frequency", 0, 0, "PowercomUPS.PowercomPowerConverter.PowercomInput.PowercomFrequency", NULL, "%.0f", 0, NULL }, @@ -526,4 +550,5 @@ subdriver_t powercom_subdriver = { powercom_format_model, powercom_format_mfr, powercom_format_serial, + fix_report_desc, }; diff --git a/drivers/powercom.c b/drivers/powercom.c index edf2b9b..6e58a3b 100644 --- a/drivers/powercom.c +++ b/drivers/powercom.c @@ -13,21 +13,21 @@ * (C) 2013 Florian Bruhin * (C) 2002 Simon Rozman * (C) 1999 Peter Bieringer - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * + * * rev 0.7: Alexey Sidorov * - add Powercom's Black Knight Pro model support ( BNT-400/500/600/800/801/1000/1200/1500/2000AP 220-240V ) * @@ -74,7 +74,11 @@ * - Fixed the processing of input/output voltages for KIN models * (https://github.com/networkupstools/nut/issues/187) * - */ + * rev 0.18: Rouben Tchakhmakhtchian + * - Added nobt flag to config that skips UPS battery check on startup/init + * (https://github.com/networkupstools/nut/issues/546) + * + */ #include "main.h" #include "serial.h" @@ -82,7 +86,7 @@ #include "math.h" #define DRIVER_NAME "PowerCom protocol UPS driver" -#define DRIVER_VERSION "0.17" +#define DRIVER_VERSION "0.19" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -92,7 +96,8 @@ upsdrv_info_t upsdrv_info = { "Peter Bieringer \n" \ "Alexey Sidorov \n" \ "Florian Bruhin \n" \ - "Arnaud Quette ", + "Arnaud Quette \n" \ + "Rouben Tchakhmakhtchian ", DRV_STABLE, { NULL } }; @@ -140,94 +145,94 @@ static void no_flow_control (void); * 120VoltageFactor, 120VoltageConstant }, */ static struct type types[] = { - { - "Trust", - 11, - { "dtr0rts1", dtr0rts1 }, - { { 5U, 0U }, { 7U, 0U }, { 8U, 0U } }, - { { 0U, 10U }, 'n' }, - { 0.00020997, 0.00020928 }, - { 6.1343, -0.3808, 4.3110, 0.1811 }, - { 5.0000, 0.3268, -825.00, 4.5639, -835.82 }, - { 1.9216, -0.0977, 0.9545, 0.0000 }, - }, - { - "Egys", - 16, - { "no_flow_control", no_flow_control }, - { { 5U, 0x80U }, { 7U, 0U }, { 8U, 0U } }, - { { 0U, 10U }, 'n' }, - { 0.00020997, 0.00020928 }, - { 6.1343, -0.3808, 1.3333, 0.6667 }, - { 5.0000, 0.3268, -825.00, 2.2105, -355.37 }, - { 1.9216, -0.0977, 0.9545, 0.0000 }, - }, - { - "KP625AP", - 16, - { "dtr0rts1", dtr0rts1 }, - { { 5U, 0x80U }, { 7U, 0U }, { 8U, 0U } }, - { { 0U, 10U }, 'n' }, - { 0.00020997, 0.00020928 }, - { 6.1343, -0.3808, 4.3110, 0.1811 }, - { 5.0000, 0.3268, -825.00, 4.5639, -835.82 }, - { 1.9216, -0.0977, 0.9545, 0.0000 }, - }, - { - "IMP", - 16, - { "no_flow_control", no_flow_control }, - { { 5U, 0xFFU }, { 7U, 0U }, { 8U, 0U } }, - { { 1U, 30U }, 'y' }, - { 0.00020997, 0.00020928 }, - { 6.1343, -0.3808, 4.3110, 0.1811 }, - { 5.0000, 0.3268, -825.00, 4.5639, -835.82 }, - { 1.9216, -0.0977, 0.9545, 0.0000 }, - }, - { - "KIN", - 16, - { "no_flow_control", no_flow_control }, - { { 11U, 0x4bU }, { 8U, 0U }, { 8U, 0U } }, - { { 1U, 30U }, 'y' }, - { 0.00020997, 0.0 }, - { 6.1343, -0.3808, 1.075, 0.1811 }, - { 5.0000, 0.3268, -825.00, 0.46511, 0 }, - { 1.9216, -0.0977, 0.82857, 0.0000 }, - }, - { - "BNT", - 16, - { "no_flow_control", no_flow_control }, - { { 11U, 0x42U }, { 8U, 0U }, { 8U, 0U } }, - { { 1U, 30U }, 'y' }, - { 0.00020803, 0.0 }, - { 1.4474, 0.0, 0.8594, 0.0 }, - { 5.0000, 0.3268, -825.00, 0.46511, 0 }, - { 1.9216, -0.0977, 0.82857, 0.0000 }, - }, - { - "BNT-other", - 16, - { "no_flow_control", no_flow_control }, - { { 8U, 0U }, { 8U, 0U }, { 8U, 0U } }, - { { 1U, 30U }, 'y' }, - { 0.00027778, 0.0000 }, - { 1.0000, 0.0000, 1.0000, 0.0000 }, - { 1.0000, 0.0000, 0.0000, 1.0000, 0.0000 }, - { 2.0000, 0.0000, 2.0000, 0.0000 }, - }, - { - "OPTI", - 16, - { "no_flow_control", no_flow_control }, - { { 5U, 0xFFU }, { 7U, 0U }, { 8U, 0U } }, - { { 1U, 30U }, 'y' }, - { 0.0000, 0.0000 }, - { 1.0000, 0.0000, 1.0000, 0.0000 }, - { 1.0000, 0.0000, 0.0000, 1.0000, 0.0000 }, - { 2.0000, 0.0000, 2.0000, 0.0000 }, - }, + { + "Trust", + 11, + { "dtr0rts1", dtr0rts1 }, + { { 5U, 0U }, { 7U, 0U }, { 8U, 0U } }, + { { 0U, 10U }, 'n' }, + { 0.00020997, 0.00020928 }, + { 6.1343, -0.3808, 4.3110, 0.1811 }, + { 5.0000, 0.3268, -825.00, 4.5639, -835.82 }, + { 1.9216, -0.0977, 0.9545, 0.0000 }, + }, + { + "Egys", + 16, + { "no_flow_control", no_flow_control }, + { { 5U, 0x80U }, { 7U, 0U }, { 8U, 0U } }, + { { 0U, 10U }, 'n' }, + { 0.00020997, 0.00020928 }, + { 6.1343, -0.3808, 1.3333, 0.6667 }, + { 5.0000, 0.3268, -825.00, 2.2105, -355.37 }, + { 1.9216, -0.0977, 0.9545, 0.0000 }, + }, + { + "KP625AP", + 16, + { "dtr0rts1", dtr0rts1 }, + { { 5U, 0x80U }, { 7U, 0U }, { 8U, 0U } }, + { { 0U, 10U }, 'n' }, + { 0.00020997, 0.00020928 }, + { 6.1343, -0.3808, 4.3110, 0.1811 }, + { 5.0000, 0.3268, -825.00, 4.5639, -835.82 }, + { 1.9216, -0.0977, 0.9545, 0.0000 }, + }, + { + "IMP", + 16, + { "no_flow_control", no_flow_control }, + { { 5U, 0xFFU }, { 7U, 0U }, { 8U, 0U } }, + { { 1U, 30U }, 'y' }, + { 0.00020997, 0.00020928 }, + { 6.1343, -0.3808, 4.3110, 0.1811 }, + { 5.0000, 0.3268, -825.00, 4.5639, -835.82 }, + { 1.9216, -0.0977, 0.9545, 0.0000 }, + }, + { + "KIN", + 16, + { "no_flow_control", no_flow_control }, + { { 11U, 0x4bU }, { 8U, 0U }, { 8U, 0U } }, + { { 1U, 30U }, 'y' }, + { 0.00020997, 0.0 }, + { 6.1343, -0.3808, 1.075, 0.1811 }, + { 5.0000, 0.3268, -825.00, 0.46511, 0 }, + { 1.9216, -0.0977, 0.82857, 0.0000 }, + }, + { + "BNT", + 16, + { "no_flow_control", no_flow_control }, + { { 11U, 0x42U }, { 8U, 0U }, { 8U, 0U } }, + { { 1U, 30U }, 'y' }, + { 0.00020803, 0.0 }, + { 1.4474, 0.0, 0.8594, 0.0 }, + { 5.0000, 0.3268, -825.00, 0.46511, 0 }, + { 1.9216, -0.0977, 0.82857, 0.0000 }, + }, + { + "BNT-other", + 16, + { "no_flow_control", no_flow_control }, + { { 8U, 0U }, { 8U, 0U }, { 8U, 0U } }, + { { 1U, 30U }, 'y' }, + { 0.00027778, 0.0000 }, + { 1.0000, 0.0000, 1.0000, 0.0000 }, + { 1.0000, 0.0000, 0.0000, 1.0000, 0.0000 }, + { 2.0000, 0.0000, 2.0000, 0.0000 }, + }, + { + "OPTI", + 16, + { "no_flow_control", no_flow_control }, + { { 5U, 0xFFU }, { 7U, 0U }, { 8U, 0U } }, + { { 1U, 30U }, 'y' }, + { 0.0000, 0.0000 }, + { 1.0000, 0.0000, 1.0000, 0.0000 }, + { 1.0000, 0.0000, 0.0000, 1.0000, 0.0000 }, + { 2.0000, 0.0000, 2.0000, 0.0000 }, + }, }; /* values for sending to UPS */ @@ -235,7 +240,7 @@ enum commands { SEND_DATA = '\x01', BATTERY_TEST = '\x03', WAKEUP_TIME = '\x04', - RESTART = '\xb9', + RESTART = '\xb9', SHUTDOWN = '\xba', COUNTER = '\xbc' }; @@ -274,56 +279,69 @@ enum status { OFF = 128U }; -unsigned int voltages[]={100,110,115,120,0,0,0,200,220,230,240,0,0,0,0,0}; -unsigned int BNTmodels[]={0,400,500,600,800,801,1000,1200,1500,2000,0,0,0,0,0,0}; -unsigned int KINmodels[]={0,425,500,525,625,800,1000,1200,1500,1600,2200,2200,2500,3000,5000,0}; -unsigned int IMPmodels[]={0,425,525,625,825,1025,1200,1500,2000,0,0,0,0,0,0,0}; -unsigned int OPTImodels[]={0,0,0,575,0,0,0,0,0,0,0,0,0,0,0,0}; +static unsigned int voltages[] = {100,110,115,120,0,0,0,200,220,230,240,0,0,0,0,0}; +static unsigned int BNTmodels[] = {0,400,500,600,800,801,1000,1200,1500,2000,0,0,0,0,0,0}; +static unsigned int KINmodels[] = {0,425,500,525,625,800,1000,1200,1500,1600,2200,2200,2500,3000,5000,0}; +static unsigned int IMPmodels[] = {0,425,525,625,825,1025,1200,1500,2000,0,0,0,0,0,0,0}; +static unsigned int OPTImodels[] = {0,0,0,575,0,0,0,0,0,0,0,0,0,0,0,0}; /* * local used functions */ +static void shutdown_halt(void) + __attribute__((noreturn)); + static void shutdown_halt(void) { - ser_send_char (upsfd, SHUTDOWN); - if (types[type].shutdown_arguments.minutesShouldBeUsed != 'n') + ser_send_char (upsfd, (unsigned char)SHUTDOWN); + if (types[type].shutdown_arguments.minutesShouldBeUsed != 'n') ser_send_char (upsfd, types[type].shutdown_arguments.delay[0]); ser_send_char (upsfd, types[type].shutdown_arguments.delay[1]); upslogx(LOG_INFO, "Shutdown (stayoff) initiated."); exit (0); } +static void shutdown_ret(void) + __attribute__((noreturn)); + static void shutdown_ret(void) { - ser_send_char (upsfd, RESTART); - ser_send_char (upsfd, COUNTER); - if (types[type].shutdown_arguments.minutesShouldBeUsed != 'n') + ser_send_char (upsfd, (unsigned char)RESTART); + ser_send_char (upsfd, (unsigned char)COUNTER); + if (types[type].shutdown_arguments.minutesShouldBeUsed != 'n') ser_send_char (upsfd, types[type].shutdown_arguments.delay[0]); ser_send_char (upsfd, types[type].shutdown_arguments.delay[1]); upslogx(LOG_INFO, "Shutdown (return) initiated."); - + exit (0); } /* registered instant commands */ static int instcmd (const char *cmdname, const char *extra) { - if (!strcasecmp(cmdname, "test.battery.start")) { + if (!strcasecmp(cmdname, "test.battery.start")) { ser_send_char (upsfd, BATTERY_TEST); return STAT_INSTCMD_HANDLED; - } - if (!strcasecmp(cmdname, "shutdown.return")) { + } + if (!strcasecmp(cmdname, "shutdown.return")) { + /* NOTE: In this context, "return" is UPS behavior after the + * wall-power gets restored. The routine exits the driver anyway. + */ shutdown_ret(); +#ifndef HAVE___ATTRIBUTE__NORETURN return STAT_INSTCMD_HANDLED; +#endif } if (!strcasecmp(cmdname, "shutdown.stayoff")) { - shutdown_halt(); + shutdown_halt(); +#ifndef HAVE___ATTRIBUTE__NORETURN return STAT_INSTCMD_HANDLED; +#endif } - upslogx(LOG_NOTICE, "instcmd: unknown command [%s]", cmdname); - return STAT_INSTCMD_UNKNOWN; + upslogx(LOG_NOTICE, "instcmd: unknown command [%s] [%s]", cmdname, extra); + return STAT_INSTCMD_UNKNOWN; } /* set DTR and RTS lines on a serial port to supply a passive @@ -331,8 +349,8 @@ static int instcmd (const char *cmdname, const char *extra) */ static void dtr0rts1 (void) { - ser_set_dtr(upsfd, 0); - ser_set_rts(upsfd, 1); + ser_set_dtr(upsfd, 0); + ser_set_rts(upsfd, 1); upsdebugx(2, "DTR => 0, RTS => 1"); } @@ -340,13 +358,13 @@ static void dtr0rts1 (void) static void no_flow_control (void) { struct termios tio; - + tcgetattr (upsfd, &tio); - - tio.c_iflag &= ~ (IXON | IXOFF); + + tio.c_iflag &= ~ ((tcflag_t)IXON | (tcflag_t)IXOFF); tio.c_cc[VSTART] = _POSIX_VDISABLE; tio.c_cc[VSTOP] = _POSIX_VDISABLE; - + upsdebugx(2, "Flow control disable"); /* disable any flow control */ @@ -356,15 +374,15 @@ static void no_flow_control (void) /* sane check for returned buffer */ static int validate_raw_data (void) { - int i = 0, - num_of_tests = + int i = 0, + num_of_tests = sizeof types[0].validation / sizeof types[0].validation[0]; - + for (i = 0; - i < num_of_tests && + i < num_of_tests && raw_data[ types[type].validation[i].index_of_byte] == - types[type].validation[i].required_value; + types[type].validation[i].required_value; i++) ; return (i < num_of_tests) ? 1 : 0; } @@ -372,8 +390,9 @@ static int validate_raw_data (void) /* get info from ups */ static int ups_getinfo(void) { - int i, c; - + size_t i; + ssize_t c; + /* send trigger char to UPS */ if (ser_send_char (upsfd, SEND_DATA) != 1) { upslogx(LOG_NOTICE, "writing error"); @@ -382,33 +401,34 @@ static int ups_getinfo(void) } else { upsdebugx(5, "Num of bytes requested for reading from UPS: %d", types[type].num_of_bytes_from_ups); + /* Note: num_of_bytes_from_ups is (unsigned char) so comparable + * to ssize_t without more range checks */ c = ser_get_buf_len(upsfd, raw_data, types[type].num_of_bytes_from_ups, 3, 0); - - if (c != types[type].num_of_bytes_from_ups) { - upslogx(LOG_NOTICE, "data receiving error (%d instead of %d bytes)", c, types[type].num_of_bytes_from_ups); + + if (c != (ssize_t)types[type].num_of_bytes_from_ups) { + upslogx(LOG_NOTICE, "data receiving error (%zd instead of %d bytes)", c, types[type].num_of_bytes_from_ups); dstate_datastale(); return 0; } else - upsdebugx(5, "Num of bytes received from UPS: %d", c); - - }; + upsdebugx(5, "Num of bytes received from UPS: %zd", c); + } /* optional dump of raw data */ if (nut_debug_level > 4) { /* FIXME: use upsdebug_hex() ? */ printf("Raw data from UPS:\n"); for (i = 0; i < types[type].num_of_bytes_from_ups; i++) { - printf("%2d 0x%02x (%c)\n", i, raw_data[i], raw_data[i]>=0x20 ? raw_data[i] : ' '); - }; - }; + printf("%2zu 0x%02x (%c)\n", i, raw_data[i], raw_data[i]>=0x20 ? raw_data[i] : ' '); + } + } /* validate raw data for correctness */ if (validate_raw_data() != 0) { upslogx(LOG_NOTICE, "data receiving error (validation check)"); dstate_datastale(); return 0; - }; + } return 1; } @@ -416,7 +436,7 @@ static float input_voltage(void) { unsigned int model; float tmp=0.0; - + if ( !strcmp(types[type].name, "BNT") && raw_data[MODELNUMBER]%16 > 7 ) { tmp=2.2*raw_data[INPUT_VOLTAGE]-24; } else if ( !strcmp(types[type].name, "KIN")) { @@ -443,7 +463,7 @@ static float input_voltage(void) } else if ( !strcmp(types[type].name, "IMP") || !strcmp(types[type].name, "OPTI")) { tmp=raw_data[INPUT_VOLTAGE]*2.0; } else { - tmp=linevoltage >= 220 ? + tmp=linevoltage >= 220 ? types[type].voltage[0] * raw_data[INPUT_VOLTAGE] + types[type].voltage[1] : types[type].voltage[2] * raw_data[INPUT_VOLTAGE] + types[type].voltage[3]; } @@ -489,16 +509,16 @@ static float output_voltage(void) model=KINmodels[raw_data[MODELNUMBER]/16]; if (statINV == 0) { if (statAVR == 0) { - // FIXME: miss test "if (iUPS == 1) {" + /* FIXME: miss test "if (iUPS == 1) {" */ if (linevoltage >= 200) { - if (linevoltage <= 625) + if (model <= 625) tmp = 1.79*raw_data[OUTPUT_VOLTAGE] + 3.35; else if (model<2000) tmp = 1.61*raw_data[OUTPUT_VOLTAGE]; else tmp = 1.625*raw_data[OUTPUT_VOLTAGE]; } else { - if (linevoltage <= 625) + if (model <= 625) tmp = 0.89 * raw_data[OUTPUT_VOLTAGE] + 6.18; else if (model<2000) tmp = 1.61 * raw_data[OUTPUT_VOLTAGE] / 2.0; @@ -507,7 +527,7 @@ static float output_voltage(void) } } else if (statAVR == 1) { - // FIXME: miss test "if ((iUPS == 1) || (iUPS == 13)) {" + /* FIXME: miss test "if ((iUPS == 1) || (iUPS == 13)) {" */ if (linevoltage >= 200) { if (model <= 525) tmp = 2.07 * raw_data[OUTPUT_VOLTAGE]; @@ -526,7 +546,7 @@ static float output_voltage(void) tmp = 1.875 * raw_data[OUTPUT_VOLTAGE] / 2.0; } } else { - // FIXME: miss test "if ((iUPS == 1) || (iUPS == 13)) {" + /* FIXME: miss test "if ((iUPS == 1) || (iUPS == 13)) {" */ if (linevoltage >= 200) { if (model == 625) tmp = 1.571 * raw_data[OUTPUT_VOLTAGE]; @@ -544,7 +564,7 @@ static float output_voltage(void) } } } else { - // FIXME: miss test "if ((iUPS == 1) && (T != 0))" + /* FIXME: miss test "if ((iUPS == 1) && (T != 0))" */ if (linevoltage < 200) { rdatax = datax1[raw_data[MODELNUMBER]/16]; rdatay = datay1[raw_data[MODELNUMBER]/16]; @@ -562,7 +582,9 @@ static float output_voltage(void) tmp=(raw_data[BATTERY_CHARGE]*rdatax)*(raw_data[BATTERY_CHARGE]*rdatax)* (t-raw_data[OUTPUT_VOLTAGE])/t; if (tmp>0) - tmp=sqrt(tmp)*rdatay*boostdata-raw_data[UPS_LOAD]*rdataz*boostdata; + /* Casts below try to avoid potential multiplication overflow */ + tmp=(float)( (double)sqrt(tmp)*rdatay*boostdata - + (double)raw_data[UPS_LOAD]*rdataz*boostdata ); } else { tmp=(raw_data[BATTERY_CHARGE]*rdatax-raw_data[UPS_LOAD]*rdataz)* (raw_data[BATTERY_CHARGE]*rdatax-raw_data[UPS_LOAD]*rdataz)* @@ -570,7 +592,7 @@ static float output_voltage(void) if (tmp>0) tmp=sqrt(tmp)*rdatay; } - // FIXME: may miss a last processing with ErrorVal = 5 | 10 + /* FIXME: may miss a last processing with ErrorVal = 5 | 10 */ } } else if ( !strcmp(types[type].name, "IMP") || !strcmp(types[type].name, "OPTI")) { tmp=raw_data[OUTPUT_VOLTAGE]*2.0; @@ -591,10 +613,10 @@ static float input_freq(void) return 4807.0/raw_data[INPUT_FREQUENCY]; else if ( !strcmp(types[type].name, "IMP") || !strcmp(types[type].name, "OPTI")) return raw_data[INPUT_FREQUENCY]; - return raw_data[INPUT_FREQUENCY] ? + return raw_data[INPUT_FREQUENCY] ? 1.0 / (types[type].freq[0] * - raw_data[INPUT_FREQUENCY] + - types[type].freq[1]) : 0; + raw_data[INPUT_FREQUENCY] + + types[type].freq[1]) : 0; } static float output_freq(void) @@ -603,10 +625,10 @@ static float output_freq(void) return 4807.0/raw_data[OUTPUT_FREQUENCY]; else if ( !strcmp(types[type].name, "IMP") || !strcmp(types[type].name, "OPTI")) return raw_data[OUTPUT_FREQUENCY]; - return raw_data[OUTPUT_FREQUENCY] ? + return raw_data[OUTPUT_FREQUENCY] ? 1.0 / (types[type].freq[0] * - raw_data[OUTPUT_FREQUENCY] + - types[type].freq[1]) : 0; + raw_data[OUTPUT_FREQUENCY] + + types[type].freq[1]) : 0; } static float load_level(void) @@ -629,7 +651,7 @@ static float load_level(void) int load801i[]={1,1,1,1,1,1,1,1,44,42,40}; int load1000i[]={1,1,1,1,1,1,1,1,56,54,52}; int load1200i[]={1,1,1,1,1,1,1,1,76,74,72}; - + if ( !strcmp(types[type].name, "BNT") && raw_data[MODELNUMBER]%16 > 7 ) { statINV=raw_data[STATUS_A] & ONLINE; voltage=raw_data[MODELNUMBER]%16; @@ -663,18 +685,18 @@ static float load_level(void) if (model==525) return raw_data[UPS_LOAD]*110.0/load525[voltage]; if (model==625) return raw_data[UPS_LOAD]*110.0/load625[voltage]; if (model<2000) return raw_data[UPS_LOAD]*1.13; - if (model>=2000) return raw_data[UPS_LOAD]*110.0/load2k[voltage]; + return raw_data[UPS_LOAD]*110.0/load2k[voltage]; } else { if (model==425) return raw_data[UPS_LOAD]*110.0/load425i[voltage]; if (model==525) return raw_data[UPS_LOAD]*110.0/load525i[voltage]; if (model==625) return raw_data[UPS_LOAD]*110.0/load625i[voltage]; if (model<2000) return raw_data[UPS_LOAD]*1.66; - if (model>=2000) return raw_data[UPS_LOAD]*110.0/load2ki[voltage]; + return raw_data[UPS_LOAD]*110.0/load2ki[voltage]; } } else if ( !strcmp(types[type].name, "IMP") || !strcmp(types[type].name, "OPTI")) { return raw_data[UPS_LOAD]; } - return raw_data[STATUS_A] & MAINS_FAILURE ? + return (raw_data[STATUS_A] & MAINS_FAILURE) ? types[type].loadpct[0] * raw_data[UPS_LOAD] + types[type].loadpct[1] : types[type].loadpct[2] * raw_data[UPS_LOAD] + @@ -683,9 +705,10 @@ static float load_level(void) static float batt_level(void) { - int bat0,bat29,bat100,model; + int bat0,bat29,bat100; + unsigned int model; float battval; - + if ( !strcmp(types[type].name, "BNT") ) { bat0=157; bat29=165; @@ -693,9 +716,9 @@ static float batt_level(void) battval=(raw_data[UPS_LOAD])/4+raw_data[BATTERY_CHARGE]; if (battval<=bat0) return 0.0; - if (battval>bat0 && battval<=bat29) + if (battval<=bat29) return (battval-bat0)*30.0/(bat29-bat0); - if (battval>bat29 && battval<=bat100) + if (battval<=bat100) return 30.0+(battval-bat29)*70.0/(bat100-bat29); return 100.0; } @@ -729,7 +752,7 @@ static float batt_level(void) } if ( !strcmp(types[type].name, "IMP") || !strcmp(types[type].name, "OPTI")) return raw_data[BATTERY_CHARGE]; - return raw_data[STATUS_A] & ONLINE ? /* Are we on battery power? */ + return (raw_data[STATUS_A] & ONLINE) ? /* Are we on battery power? */ /* Yes */ types[type].battpct[0] * raw_data[BATTERY_CHARGE] + types[type].battpct[1] * load_level() + types[type].battpct[2] : @@ -746,11 +769,11 @@ static float batt_level(void) void upsdrv_updateinfo(void) { char val[32]; - + if (!ups_getinfo()){ return; } - + /* input.frequency */ upsdebugx(3, "input.frequency (raw data): [raw: %u]", raw_data[INPUT_FREQUENCY]); @@ -763,7 +786,7 @@ void upsdrv_updateinfo(void) dstate_setinfo("output.frequency", "%02.2f", output_freq()); upsdebugx(2, "output.frequency: %s", dstate_getinfo("output.frequency")); - /* ups.load */ + /* ups.load */ upsdebugx(3, "ups.load (raw data): [raw: %u]", raw_data[UPS_LOAD]); dstate_setinfo("ups.load", "%03.1f", load_level()); @@ -775,23 +798,23 @@ void upsdrv_updateinfo(void) dstate_setinfo("battery.charge", "%03.1f", batt_level()); upsdebugx(2, "battery.charge: %s", dstate_getinfo("battery.charge")); - /* input.voltage */ + /* input.voltage */ upsdebugx(3, "input.voltage (raw data): [raw: %u]", raw_data[INPUT_VOLTAGE]); dstate_setinfo("input.voltage", "%03.1f",input_voltage()); upsdebugx(2, "input.voltage: %s", dstate_getinfo("input.voltage")); - - /* output.voltage */ + + /* output.voltage */ upsdebugx(3, "output.voltage (raw data): [raw: %u]", raw_data[OUTPUT_VOLTAGE]); dstate_setinfo("output.voltage", "%03.1f",output_voltage()); upsdebugx(2, "output.voltage: %s", dstate_getinfo("output.voltage")); status_init(); - + *val = 0; if (!(raw_data[STATUS_A] & MAINS_FAILURE)) { - !(raw_data[STATUS_A] & OFF) ? + !(raw_data[STATUS_A] & OFF) ? status_set("OL") : status_set("OFF"); } else { status_set("OB"); @@ -800,7 +823,7 @@ void upsdrv_updateinfo(void) if (raw_data[STATUS_A] & LOW_BAT) status_set("LB"); if (raw_data[STATUS_A] & AVR_ON) { - input_voltage() < linevoltage ? + input_voltage() < linevoltage ? status_set("BOOST") : status_set("TRIM"); } @@ -817,6 +840,9 @@ void upsdrv_updateinfo(void) } /* shutdown UPS */ +void upsdrv_shutdown(void) + __attribute__((noreturn)); + void upsdrv_shutdown(void) { /* power down the attached load immediately */ @@ -827,71 +853,72 @@ void upsdrv_shutdown(void) /* initialize UPS */ void upsdrv_initups(void) { - int tmp,model = 0; + int tmp; + unsigned int model = 0; unsigned int i; static char buf[20]; /* check manufacturer name from arguments */ - if (getval("manufacturer") != NULL) + if (testvar("manufacturer")) manufacturer = getval("manufacturer"); - + /* check model name from arguments */ - if (getval("modelname") != NULL) + if (testvar("modelname")) modelname = getval("modelname"); - + /* check serial number from arguments */ - if (getval("serialnumber") != NULL) + if (testvar("serialnumber")) serialnumber = getval("serialnumber"); - + /* get and check type */ - if (getval("type") != NULL) { - for (i = 0; + if (testvar("type")) { + for (i = 0; i < NUM_OF_SUBTYPES && strcmp(types[i].name, getval("type")); i++) ; if (i >= NUM_OF_SUBTYPES) { printf("Given UPS type '%s' isn't valid!\n", getval("type")); exit (1); } - type = i; - }; - + type = i; + } + /* check line voltage from arguments */ - if (getval("linevoltage") != NULL) { + if (testvar("linevoltage")) { tmp = atoi(getval("linevoltage")); if (! ( (tmp >= 200 && tmp <= 240) || (tmp >= 100 && tmp <= 120) ) ) { printf("Given line voltage '%d' is out of range (100-120 or 200-240 V)\n", tmp); exit (1); - }; + } linevoltage = (unsigned int) tmp; - }; + } - if (getval("numOfBytesFromUPS") != NULL) { + if (testvar("numOfBytesFromUPS")) { tmp = atoi(getval("numOfBytesFromUPS")); if (! (tmp > 0 && tmp <= MAX_NUM_OF_BYTES_FROM_UPS) ) { printf("Given numOfBytesFromUPS '%d' is out of range (1 to %d)\n", - tmp, MAX_NUM_OF_BYTES_FROM_UPS); + tmp, MAX_NUM_OF_BYTES_FROM_UPS); exit (1); - }; + } types[type].num_of_bytes_from_ups = (unsigned char) tmp; } - if (getval("methodOfFlowControl") != NULL) { - for (i = 0; - i < NUM_OF_SUBTYPES && + if (testvar("methodOfFlowControl")) { + for (i = 0; + i < NUM_OF_SUBTYPES && strcmp(types[i].flowControl.name, getval("methodOfFlowControl")); i++) ; if (i >= NUM_OF_SUBTYPES) { - printf("Given methodOfFlowControl '%s' isn't valid!\n", + printf("Given methodOfFlowControl '%s' isn't valid!\n", getval("methodOfFlowControl")); exit (1); - }; - types[type].flowControl = types[i].flowControl; + } + types[type].flowControl = types[i].flowControl; } - if (getval("validationSequence") && - sscanf(getval("validationSequence"), - "{{%u,%x},{%u,%x},{%u,%x}}", + if (testvar("validationSequence") && + sscanf(getval("validationSequence"), + "{{%u,%x},{%u,%x},{%u,%x}}", &types[type].validation[0].index_of_byte, &types[type].validation[0].required_value, &types[type].validation[1].index_of_byte, @@ -900,58 +927,60 @@ void upsdrv_initups(void) &types[type].validation[2].required_value ) < 6 ) { - printf("Given validationSequence '%s' isn't valid!\n", + printf("Given validationSequence '%s' isn't valid!\n", getval("validationSequence")); exit (1); } - if (getval("shutdownArguments") && - sscanf(getval("shutdownArguments"), "{{%u,%u},%c}", + /* NOTE: %hhu is not supported before C99; that would need reading + * arguments into an uint as %u, checking range and casting */ + if (testvar("shutdownArguments") && + sscanf(getval("shutdownArguments"), "{{%hhu,%hhu},%c}", &types[type].shutdown_arguments.delay[0], &types[type].shutdown_arguments.delay[1], - &types[type].shutdown_arguments.minutesShouldBeUsed + &types[type].shutdown_arguments.minutesShouldBeUsed ) < 3 ) { - printf("Given shutdownArguments '%s' isn't valid!\n", + printf("Given shutdownArguments '%s' isn't valid!\n", getval("shutdownArguments")); exit (1); - } + } - if (getval("frequency") && - sscanf(getval("frequency"), "{%f,%f}", - &types[type].freq[0], &types[type].freq[1] + if (testvar("frequency") && + sscanf(getval("frequency"), "{%f,%f}", + &types[type].freq[0], &types[type].freq[1] ) < 2 ) { - printf("Given frequency '%s' isn't valid!\n", + printf("Given frequency '%s' isn't valid!\n", getval("frequency")); exit (1); } - if (getval("loadPercentage") && - sscanf(getval("loadPercentage"), "{%f,%f,%f,%f}", + if (testvar("loadPercentage") && + sscanf(getval("loadPercentage"), "{%f,%f,%f,%f}", &types[type].loadpct[0], &types[type].loadpct[1], &types[type].loadpct[2], &types[type].loadpct[3] ) < 4 ) { - printf("Given loadPercentage '%s' isn't valid!\n", + printf("Given loadPercentage '%s' isn't valid!\n", getval("loadPercentage")); exit (1); } - if (getval("batteryPercentage") && - sscanf(getval("batteryPercentage"), "{%f,%f,%f,%f,%f}", + if (testvar("batteryPercentage") && + sscanf(getval("batteryPercentage"), "{%f,%f,%f,%f,%f}", &types[type].battpct[0], &types[type].battpct[1], &types[type].battpct[2], &types[type].battpct[3], &types[type].battpct[4] ) < 5 ) { - printf("Given batteryPercentage '%s' isn't valid!\n", + printf("Given batteryPercentage '%s' isn't valid!\n", getval("batteryPercentage")); exit (1); } - if (getval("voltage") && - sscanf(getval("voltage"), "{%f,%f,%f,%f}", + if (testvar("voltage") && + sscanf(getval("voltage"), "{%f,%f,%f,%f}", &types[type].voltage[0], &types[type].voltage[1], &types[type].voltage[2], &types[type].voltage[3] ) < 4 @@ -963,7 +992,7 @@ void upsdrv_initups(void) /* open serial port */ upsfd = ser_open(device_path); ser_set_speed(upsfd, device_path, B1200); - + /* setup flow control */ types[type].flowControl.setup_flow_control(); @@ -998,55 +1027,61 @@ void upsdrv_initups(void) } linevoltage=voltages[raw_data[MODELNUMBER]%16]; if (!strcmp(types[type].name, "OPTI")) { - snprintf(buf,sizeof(buf),"%s-%d",types[type].name,model); + snprintf(buf,sizeof(buf),"%s-%u",types[type].name, model); } else { - snprintf(buf,sizeof(buf),"%s-%dAP",types[type].name,model); + snprintf(buf,sizeof(buf),"%s-%uAP",types[type].name, model); } if (!strcmp(modelname, "Unknown")) modelname=buf; upsdebugx(1,"Detected: %s , %dV",buf,linevoltage); - if (ser_send_char (upsfd, BATTERY_TEST) != 1) { - upslogx(LOG_NOTICE, "writing error"); - dstate_datastale(); - return; + if (testvar("nobt") || dstate_getinfo("driver.flag.nobt")) { + upslogx(LOG_NOTICE, "nobt flag set, skipping battery test as requested"); + } + else { + upslogx(LOG_NOTICE, "nobt flag not set, performing battery test as requested"); + if (ser_send_char (upsfd, BATTERY_TEST) != 1) { + upslogx(LOG_NOTICE, "Write error: failed to send battery test command to UPS!"); + dstate_datastale(); + return; + } } } - + upsdebugx(1, "Values of arguments:"); upsdebugx(1, " manufacturer : '%s'", manufacturer); upsdebugx(1, " model name : '%s'", modelname); upsdebugx(1, " serial number : '%s'", serialnumber); upsdebugx(1, " line voltage : '%u'", linevoltage); upsdebugx(1, " type : '%s'", types[type].name); - upsdebugx(1, " number of bytes from UPS: '%u'", - types[type].num_of_bytes_from_ups); - upsdebugx(1, " method of flow control : '%s'", - types[type].flowControl.name); + upsdebugx(1, " number of bytes from UPS: '%u'", + types[type].num_of_bytes_from_ups); + upsdebugx(1, " method of flow control : '%s'", + types[type].flowControl.name); upsdebugx(1, " validation sequence: '{{%u,%#x},{%u,%#x},{%u,%#x}}'", - types[type].validation[0].index_of_byte, - types[type].validation[0].required_value, - types[type].validation[1].index_of_byte, - types[type].validation[1].required_value, - types[type].validation[2].index_of_byte, - types[type].validation[2].required_value); + types[type].validation[0].index_of_byte, + types[type].validation[0].required_value, + types[type].validation[1].index_of_byte, + types[type].validation[1].required_value, + types[type].validation[2].index_of_byte, + types[type].validation[2].required_value); upsdebugx(1, " shutdown arguments: '{{%u,%u},%c}'", - types[type].shutdown_arguments.delay[0], - types[type].shutdown_arguments.delay[1], - types[type].shutdown_arguments.minutesShouldBeUsed); + types[type].shutdown_arguments.delay[0], + types[type].shutdown_arguments.delay[1], + types[type].shutdown_arguments.minutesShouldBeUsed); if ( strcmp(types[type].name, "KIN") && strcmp(types[type].name, "BNT") && strcmp(types[type].name, "IMP")) { upsdebugx(1, " frequency calculation coefficients: '{%f,%f}'", - types[type].freq[0], types[type].freq[1]); + types[type].freq[0], types[type].freq[1]); upsdebugx(1, " load percentage calculation coefficients: " - "'{%f,%f,%f,%f}'", - types[type].loadpct[0], types[type].loadpct[1], - types[type].loadpct[2], types[type].loadpct[3]); - upsdebugx(1, " battery percentage calculation coefficients: " - "'{%f,%f,%f,%f,%f}'", - types[type].battpct[0], types[type].battpct[1], - types[type].battpct[2], types[type].battpct[3], - types[type].battpct[4]); + "'{%f,%f,%f,%f}'", + types[type].loadpct[0], types[type].loadpct[1], + types[type].loadpct[2], types[type].loadpct[3]); + upsdebugx(1, " battery percentage calculation coefficients: " + "'{%f,%f,%f,%f,%f}'", + types[type].battpct[0], types[type].battpct[1], + types[type].battpct[2], types[type].battpct[3], + types[type].battpct[4]); upsdebugx(1, " voltage calculation coefficients: '{%f,%f}'", - types[type].voltage[2], types[type].voltage[3]); + types[type].voltage[2], types[type].voltage[3]); } } @@ -1054,8 +1089,8 @@ void upsdrv_initups(void) /* display help */ void upsdrv_help(void) { - // 1 2 3 4 5 6 7 8 - // 12345678901234567890123456789012345678901234567890123456789012345678901234567890 MAX + /* 1 2 3 4 5 6 7 8 */ + /* 12345678901234567890123456789012345678901234567890123456789012345678901234567890 MAX */ printf("\n"); printf("Specify UPS information in the ups.conf file.\n"); printf(" type: Type of UPS: 'Trust','Egys','KP625AP','IMP','KIN','BNT',\n"); @@ -1093,7 +1128,8 @@ void upsdrv_help(void) printf(" voltage: Voltage conversion values for 240 and 120 voltage:\n"); printf(" {240A,240B,120A,120B}\n"); printf(" used in function: A*x+B\n"); - printf(" If the raw value x IS HALF the Voltage, then A=2, B=0\n\n"); + printf(" If the raw value x IS HALF the Voltage, then A=2, B=0\n"); + printf(" nobt: Flag to skip battery check on init/startup.\n\n"); printf("Example for BNT1500AP in ups.conf:\n"); printf("[BNT1500AP]\n"); @@ -1113,6 +1149,7 @@ void upsdrv_help(void) printf("# loadPercentage = {1.0000,0.0,1.0000,0.0}\n"); printf("# batteryPercentage = {1.0000,0.0000,0.0000,1.0000,0.0000}\n"); printf("# voltage = {2.0000,0.0000,2.0000,0.0000}\n"); + printf(" nobt\n"); return; } @@ -1127,17 +1164,17 @@ void upsdrv_initinfo(void) dstate_setinfo ("input.voltage.nominal", "%u", linevoltage); /* now add the instant commands */ - dstate_addcmd ("test.battery.start"); - dstate_addcmd ("shutdown.return"); - dstate_addcmd ("shutdown.stayoff"); + dstate_addcmd ("test.battery.start"); + dstate_addcmd ("shutdown.return"); + dstate_addcmd ("shutdown.stayoff"); upsh.instcmd = instcmd; } /* define possible arguments */ void upsdrv_makevartable(void) { - // 1 2 3 4 5 6 7 8 - //2345678901234567890123456789012345678901234567890123456789012345678901234567890 MAX + /* 1 2 3 4 5 6 7 8 */ + /*2345678901234567890123456789012345678901234567890123456789012345678901234567890 MAX */ addvar(VAR_VALUE, "type", "Type of UPS: 'Trust','Egys','KP625AP','IMP','KIN','BNT','BNT-other','OPTI'\n" " (default: 'Trust')"); @@ -1166,6 +1203,8 @@ void upsdrv_makevartable(void) "Battery conversion values: OffFactor, LoadFactor, OffConst, OnFactor, OnConst"); addvar(VAR_VALUE, "voltage", "Voltage conversion values: 240VFactor, 240VConst, 120VFactor, 120VConst"); + addvar(VAR_FLAG, "nobt", + "Disable battery test at driver init/startup"); } } diff --git a/drivers/powercom.h b/drivers/powercom.h index 8d0dab6..4ac2f63 100644 --- a/drivers/powercom.h +++ b/drivers/powercom.h @@ -21,15 +21,18 @@ * */ +#ifndef NUT_POWERCOM_H_SEEN +#define NUT_POWERCOM_H_SEEN 1 + /* C-libary includes */ #include #include #include #include -#include "serial.h" -#include /* nut includes */ +#include "serial.h" +#include "nut_stdint.h" #include "timehead.h" @@ -37,51 +40,51 @@ struct type { const char *name; unsigned char num_of_bytes_from_ups; - + struct method_of_flow_control { - const char *name; - void (*setup_flow_control)(void); + const char *name; + void (*setup_flow_control)(void); } flowControl; - + struct validation_byte { - unsigned int index_of_byte, required_value; - /* An example might explain the intention better then prose. - * Suppose we want to validate the data with: - * powercom_raw_data[5] == 0x80 - * then we will set index_of_byte to 5U and required_value to - * 0x80U: { 5U, 0x80U }. - */ + unsigned int index_of_byte, required_value; + /* An example might explain the intention better then prose. + * Suppose we want to validate the data with: + * powercom_raw_data[5] == 0x80 + * then we will set index_of_byte to 5U and required_value to + * 0x80U: { 5U, 0x80U }. + */ } validation[3]; - /* The validation array is of length 3 because 3 is longest + /* The validation array is of length 3 because 3 is longest * validation sequence for any type. */ - - /* Some UPSs must have a minutes and a seconds arguments for + + /* Some UPSs must have a minutes and a seconds arguments for * the COUNTER commands while others are known to work with the * seconds argument alone. */ struct delay_for_power_kill { - unsigned int delay[2]; /* { minutes, seconds } */ - unsigned char minutesShouldBeUsed; - /* 'n' in case the minutes value, which is delay[0], should - * be skipped and not sent to the UPS. + unsigned char delay[2]; /* { minutes, seconds } */ + unsigned char minutesShouldBeUsed; + /* 'n' in case the minutes value, which is delay[0], should + * be skipped and not sent to the UPS. */ } shutdown_arguments; - + /* parameters to calculate input and output freq., one pair used for * both input and output functions: * The pair [0],[1] defines parameters for 1/(A*x+B) to calculate freq. * from raw data 'x'. */ float freq[2]; - + /* parameters to calculate load %, two pairs for each type: * First pair [0],[1] defines the parameters for A*x+B to calculate load * from raw data when offline and the second pair [2],[3] is used when * online */ float loadpct[4]; - + /* parameters to calculate battery %, five parameters for each type: * First three params [0],[1],[2] defines the parameters for A*x+B*y+C to calculate * battery % (x is raw data, y is load %) when offline. @@ -97,3 +100,5 @@ struct type { */ float voltage[4]; }; + +#endif /* NUT_POWERCOM_H_SEEN */ diff --git a/drivers/powerman-pdu.c b/drivers/powerman-pdu.c index b7bcf3d..df4e91f 100644 --- a/drivers/powerman-pdu.c +++ b/drivers/powerman-pdu.c @@ -20,10 +20,10 @@ #include "main.h" -#include +#include /* pm_err_t and other beasts */ #define DRIVER_NAME "Powerman PDU client driver" -#define DRIVER_VERSION "0.11" +#define DRIVER_VERSION "0.12" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -35,11 +35,11 @@ upsdrv_info_t upsdrv_info = { }; /* Powerman functions and variables */ -static pm_err_t query_one(pm_handle_t pm, char *s, int mode); -static pm_err_t query_all(pm_handle_t pm, int mode); +static pm_err_t query_one(pm_handle_t arg_pm, char *s, int mode); +static pm_err_t query_all(pm_handle_t arg_pm, int mode); -pm_handle_t pm; -char ebuf[64]; +static pm_handle_t pm; +static char ebuf[64]; /* modes to snmp_ups_walk. */ #define WALKMODE_INIT 0 @@ -49,7 +49,7 @@ static int reconnect_ups(void); static int instcmd(const char *cmdname, const char *extra) { - pm_err_t rv = -1; + pm_err_t rv = PM_EBADARG; char *cmdsuffix = NULL; char *cmdindex = NULL; char outletname[SMALLBUF]; @@ -90,7 +90,7 @@ static int instcmd(const char *cmdname, const char *extra) return (rv==PM_ESUCCESS)?STAT_INSTCMD_HANDLED:STAT_SET_INVALID; } - upslogx(LOG_NOTICE, "instcmd: unknown command [%s]", cmdname); + upslogx(LOG_NOTICE, "instcmd: unknown command [%s] [%s]", cmdname, extra); return STAT_INSTCMD_UNKNOWN; } @@ -133,6 +133,9 @@ void upsdrv_initinfo(void) /* FIXME: no need for setvar (ex for outlet.n.delay.*)!? */ } +void upsdrv_shutdown(void) + __attribute__((noreturn)); + void upsdrv_shutdown(void) { /* FIXME: shutdown all outlets? */ @@ -208,7 +211,7 @@ static int reconnect_ups(void) * powerman support functions ****************************/ -static pm_err_t query_one(pm_handle_t pm, char *s, int outletnum) +static pm_err_t query_one(pm_handle_t arg_pm, char *s, int outletnum) { pm_err_t rv; pm_node_state_t ns; @@ -216,7 +219,7 @@ static pm_err_t query_one(pm_handle_t pm, char *s, int outletnum) upsdebugx(1, "entering query_one (%s)", s); - rv = pm_node_status(pm, s, &ns); + rv = pm_node_status(arg_pm, s, &ns); if (rv == PM_ESUCCESS) { upsdebugx(3, "updating status"); @@ -229,7 +232,7 @@ static pm_err_t query_one(pm_handle_t pm, char *s, int outletnum) return rv; } -static pm_err_t query_all(pm_handle_t pm, int mode) +static pm_err_t query_all(pm_handle_t arg_pm, int mode) { pm_err_t rv; pm_node_iterator_t itr; @@ -239,7 +242,7 @@ static pm_err_t query_all(pm_handle_t pm, int mode) upsdebugx(1, "entering query_all ()"); - rv = pm_node_iterator_create(pm, &itr); + rv = pm_node_iterator_create(arg_pm, &itr); if (rv != PM_ESUCCESS) return rv; @@ -247,7 +250,7 @@ static pm_err_t query_all(pm_handle_t pm, int mode) /* in WALKMODE_UPDATE, we always call this one for the * status update... */ - if ((rv = query_one(pm, s, outletnum)) != PM_ESUCCESS) + if ((rv = query_one(arg_pm, s, outletnum)) != PM_ESUCCESS) break; else { /* set the initial generic properties (ie except status) diff --git a/drivers/powerp-bin.c b/drivers/powerp-bin.c index ad6037d..89b0687 100644 --- a/drivers/powerp-bin.c +++ b/drivers/powerp-bin.c @@ -1,6 +1,6 @@ /* * powerp-bin.c - Model specific routines for CyberPower binary - * protocol UPSes + * protocol UPSes * * Copyright (C) * 2007 Doug Reynolds @@ -31,9 +31,12 @@ #include "serial.h" #include "powerp-bin.h" +#include "nut_stdint.h" #include +#define POWERPANEL_BIN_VERSION "Powerpanel-Binary 0.5" + typedef struct { unsigned char start; unsigned char i_volt; @@ -64,34 +67,34 @@ static unsigned char powpan_answer[SMALLBUF]; static const valtab_t tran_high_pr[] = { { "138", -9 }, { "139", -8 }, { "140", -7 }, { "141", -6 }, { "142", -5 }, { "143", -4 }, { "144", -3 }, { "145", -2 }, { "146", -1 }, { "147", 0 }, - { NULL } + { NULL, 0 } }; /* OP series */ static const valtab_t tran_high_op[] = { { "140", -5 }, { "141", -4 }, { "142", -3 }, { "143", -2 }, { "144", -1 }, { "145", 0 }, { "146", +1 }, { "147", +2 }, { "148", +3 }, { "149", +4 }, - { "150", +5 }, { NULL } + { "150", +5 }, { NULL, 0 } }; /* PR series */ static const valtab_t tran_low_pr[] = { { "88", 0 }, { "89", +1 }, { "90", +2 }, { "91", +3 }, { "92", +4 }, { "93", +5 }, { "94", +6 }, { "95", +7 }, { "96", +8 }, { "97", +9 }, - { NULL } + { NULL, 0 } }; /* OP series */ static const valtab_t tran_low_op[] = { { "85", -5 }, { "86", -4 }, { "87", -3 }, { "88", -2 }, { "89", -1 }, { "90", 0 }, { "91", +1 }, { "92", +2 }, { "93", +3 }, { "94", +4 }, - { "95", +5 }, { NULL } + { "95", +5 }, { NULL, 0 } }; /* PR series */ static const valtab_t batt_low_pr[] = { { "25", -6 }, { "30", -5 }, { "35", -3 }, { "40", -1 }, { "45", 0 }, - { "50", +2 }, { "55", +4 }, { "60", +6 }, { NULL } + { "50", +2 }, { "55", +4 }, { "60", +6 }, { NULL, 0 } }; /* OP series */ @@ -99,23 +102,23 @@ static const valtab_t batt_low_op[] = { { "15", -8 }, { "18", -7 }, { "19", -6 }, { "20", -5 }, { "22", -4 }, { "24", -3 }, { "25", -2 }, { "26", -1 }, { "28", 0 }, { "30", +1 }, { "32", +2 }, { "34", +3 }, { "35", +4 }, { "36", +5 }, { "38", +6 }, - { "40", +7 }, { NULL } + { "40", +7 }, { NULL, 0 } }; /* PR series */ static const valtab_t out_volt_pr[] = { - { "110", -10 }, { "120", 0 }, { "130", +10 }, { NULL } + { "110", -10 }, { "120", 0 }, { "130", +10 }, { NULL, 0 } }; /* OP series */ static const valtab_t out_volt_op[] = { { "110", -2 }, { "115", -1 }, { "120", 0 }, { "124", +1 }, { "128", +2 }, - { "130", +3 }, { NULL } + { "130", +3 }, { NULL, 0 } }; static const valtab_t yes_no_info[] = { { "yes", 2 }, { "no", 0 }, - { NULL } + { NULL, 0 } }; /* Older models report the model in a numeric format 'rOnn' */ @@ -133,7 +136,7 @@ static const struct { { "rO41", "OP700AVR" }, { "rO43", "OP1250AVR" }, { "rO45", "OP1500AVR" }, - { NULL } + { NULL, NULL } }; static const struct { @@ -147,13 +150,13 @@ static const struct { { "battery.charge.low", "R\x08\r", "Q\x08%c\r", { batt_low_pr, batt_low_op } }, { "ups.start.battery", "R\x0F\r", "Q\x0F%c\r", { yes_no_info, yes_no_info } }, { "output.voltage.nominal", "R\x18\r", "Q\x18%c\r", { out_volt_pr, out_volt_op } }, - { NULL } + { NULL, NULL, NULL, { NULL, 0 } } }; static const struct { const char *cmd; const char *command; - const int len; + const size_t len; } cmdtab[] = { { "test.battery.start.quick", "T\230\r", 3 }, /* 20 seconds test */ { "test.battery.stop", "CT\r", 3 }, @@ -163,7 +166,7 @@ static const struct { * as shutdown.return when on battery */ { "shutdown.stayoff", "S\0\0W\r", 5 }, { "shutdown.stop", "C\r", 2 }, - { NULL } + { NULL, NULL, 0 } }; /* map UPS data to (approximated) input/output voltage */ @@ -212,9 +215,9 @@ static float op_freq(unsigned char in) return (12600.0 / (in + 32)); } -static int powpan_command(const char *buf, size_t bufsize) +static ssize_t powpan_command(const char *buf, size_t bufsize) { - int ret; + ssize_t ret; ser_flush_io(upsfd); @@ -248,7 +251,7 @@ static int powpan_command(const char *buf, size_t bufsize) return -1; } - upsdebug_hex(3, "read", powpan_answer, ret); + upsdebug_hex(3, "read", powpan_answer, (size_t)ret); return ret; } @@ -257,18 +260,22 @@ static int powpan_instcmd(const char *cmdname, const char *extra) int i; for (i = 0; cmdtab[i].cmd != NULL; i++) { + ssize_t ret; if (strcasecmp(cmdname, cmdtab[i].cmd)) { continue; } - if ((powpan_command(cmdtab[i].command, cmdtab[i].len) == - cmdtab[i].len - 1) && - (!memcmp(powpan_answer, cmdtab[i].command, cmdtab[i].len - 1))) { + ret = powpan_command(cmdtab[i].command, cmdtab[i].len); + assert(cmdtab[i].len < SSIZE_MAX); + if (ret >= 0 && + (ret == (ssize_t)(cmdtab[i].len - 1)) && + (!memcmp(powpan_answer, cmdtab[i].command, cmdtab[i].len - 1)) + ) { return STAT_INSTCMD_HANDLED; } - upslogx(LOG_ERR, "%s: command [%s] failed", __func__, cmdname); + upslogx(LOG_ERR, "%s: command [%s] [%s] failed", __func__, cmdname, extra); return STAT_INSTCMD_FAILED; } @@ -298,8 +305,20 @@ static int powpan_setvar(const char *varname, const char *val) continue; } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(command, sizeof(command), vartab[i].set, vartab[i].map[type][j].command); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif if ((powpan_command(command, 4) == 3) && (!memcmp(powpan_answer, command, 3))) { dstate_setinfo(varname, "%s", val); @@ -359,7 +378,7 @@ static void powpan_initinfo(void) } for (i = 0; vartab[i].var != NULL; i++) { - + if (powpan_command(vartab[i].get, 3) < 2) { continue; } @@ -373,7 +392,7 @@ static void powpan_initinfo(void) dstate_setinfo(vartab[i].var, "%s", vartab[i].map[type][j].val); break; } - + if (dstate_getinfo(vartab[i].var) == NULL) { upslogx(LOG_WARNING, "warning: [%d] unknown value for [%s]!", powpan_answer[1], vartab[i].var); @@ -397,14 +416,14 @@ static void powpan_initinfo(void) powpan_command("R\x2B\r", 3); powpan_command("R\x3D\r", 3); } - + dstate_addcmd("shutdown.stayoff"); dstate_addcmd("shutdown.reboot"); } -static int powpan_status(status_t *status) +static ssize_t powpan_status(status_t *status) { - int ret; + ssize_t ret; ser_flush_io(upsfd); @@ -443,7 +462,7 @@ static int powpan_status(status_t *status) return -1; } - upsdebug_hex(3, "read", status, ret); + upsdebug_hex(3, "read", status, (size_t)ret); if ((status->flags[0] + status->flags[1]) != 255) { upsdebugx(4, " \\_ : checksum flags[0..1] failed"); @@ -481,7 +500,19 @@ static int powpan_updateinfo(void) dstate_setinfo("input.frequency", "%.1f", op_freq(status.i_freq)); break; + case PR: +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wcovered-switch-default" +#endif + /* All enum cases defined as of the time of coding + * have been covered above. Handle later definitions, + * memory corruptions and buggy inputs below... + */ default: +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT) +# pragma GCC diagnostic pop +#endif dstate_setinfo("input.voltage", "%d", status.i_volt); if (status.flags[0] & 0x84) { dstate_setinfo("output.voltage", "%s", dstate_getinfo("output.voltage.nominal")); @@ -523,7 +554,7 @@ static int powpan_updateinfo(void) } else if (status.o_volt < 1.05 * status.i_volt) { upsdebugx(2, "%s: appears to be in BYPASS state", __func__); } else if (status.o_volt < 1.5 * status.i_volt) { - status_set("BOOST"); + status_set("BOOST"); } else { upsdebugx(2, "%s: output voltage too high", __func__); } @@ -542,9 +573,10 @@ static int powpan_updateinfo(void) return (status.flags[0] & 0x80) ? 1 : 0; } -static int powpan_initups(void) +static ssize_t powpan_initups(void) { - int ret, i; + ssize_t ret; + int i; upsdebugx(1, "Trying %s protocol...", powpan_binary.version); @@ -593,10 +625,10 @@ static int powpan_initups(void) continue; } - upsdebug_hex(3, "read", powpan_answer, ret); + upsdebug_hex(3, "read", powpan_answer, (size_t)ret); if (ret < 20) { - upsdebugx(2, "Expected 20 bytes but only got %d", ret); + upsdebugx(2, "Expected 20 bytes but only got %zd", ret); continue; } @@ -631,6 +663,7 @@ static int powpan_initups(void) subdriver_t powpan_binary = { "binary", + POWERPANEL_BIN_VERSION, powpan_instcmd, powpan_setvar, powpan_initups, diff --git a/drivers/powerp-bin.h b/drivers/powerp-bin.h index 4346597..0bb1c63 100644 --- a/drivers/powerp-bin.h +++ b/drivers/powerp-bin.h @@ -1,6 +1,6 @@ /* * powerp-bin.h - Model specific data/definitions for CyberPower text/binary - * protocol UPSes + * protocol UPSes * * Copyright (C) * 2007 Doug Reynolds diff --git a/drivers/powerp-txt.c b/drivers/powerp-txt.c index fa0353a..6f22a60 100644 --- a/drivers/powerp-txt.c +++ b/drivers/powerp-txt.c @@ -1,11 +1,11 @@ /* * powerp-txt.c - Model specific routines for CyberPower text - * protocol UPSes + * protocol UPSes * * Copyright (C) * 2007 Doug Reynolds * 2007-2008 Arjen de Korte - * 2012 Timothy Pearson + * 2012-2016 Timothy Pearson * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,6 +33,8 @@ #include "powerp-txt.h" +#define POWERPANEL_TEXT_VERSION "Powerpanel-Text 0.5" + typedef struct { float i_volt; float o_volt; @@ -51,8 +53,8 @@ typedef struct { float q_unknwn; } status_t; -static int ondelay = 1; /* minutes */ -static int offdelay = 60; /* seconds */ +static long ondelay = 1; /* minutes */ +static long offdelay = 60; /* seconds */ static char powpan_answer[SMALLBUF]; @@ -64,7 +66,7 @@ static struct { { "input.transfer.high", "P6\r", "C2:%03d\r" }, { "input.transfer.low", "P7\r", "C3:%03d\r" }, { "battery.charge.low", "P8\r", "C4:%02d\r" }, - { NULL } + { NULL, NULL, NULL } }; static struct { @@ -72,18 +74,19 @@ static struct { const char *command; } cmdtab[] = { { "test.battery.start.quick", "T\r" }, + { "test.battery.start.deep", "TL\r" }, { "test.battery.stop", "CT\r" }, { "beeper.enable", "C7:1\r" }, { "beeper.disable", "C7:0\r" }, { "beeper.on", NULL }, { "beeper.off", NULL }, { "shutdown.stop", "C\r" }, - { NULL } + { NULL, NULL } }; -static int powpan_command(const char *command) +static ssize_t powpan_command(const char *command) { - int ret; + ssize_t ret; ser_flush_io(upsfd); @@ -118,7 +121,7 @@ static int powpan_command(const char *command) return -1; } - upsdebug_hex(3, "read", powpan_answer, ret); + upsdebug_hex(3, "read", powpan_answer, (size_t)ret); return ret; } @@ -147,34 +150,34 @@ static int powpan_instcmd(const char *cmdname, const char *extra) continue; } - if ((powpan_command(cmdtab[i].command) == 2) && (!strcasecmp(powpan_answer, "#0"))) { + if ((powpan_command(cmdtab[i].command) == 2) && (!strcasecmp(powpan_answer, "#0"))) { return STAT_INSTCMD_HANDLED; } - upslogx(LOG_ERR, "%s: command [%s] failed", __func__, cmdname); + upslogx(LOG_ERR, "%s: command [%s] [%s] failed", __func__, cmdname, extra); return STAT_INSTCMD_FAILED; } if (!strcasecmp(cmdname, "shutdown.return")) { if (offdelay < 60) { - snprintf(command, sizeof(command), "Z.%d\r", offdelay / 6); + snprintf(command, sizeof(command), "Z.%ld\r", offdelay / 6); } else { - snprintf(command, sizeof(command), "Z%02d\r", offdelay / 60); + snprintf(command, sizeof(command), "Z%02ld\r", offdelay / 60); } } else if (!strcasecmp(cmdname, "shutdown.stayoff")) { if (offdelay < 60) { - snprintf(command, sizeof(command), "S.%d\r", offdelay / 6); + snprintf(command, sizeof(command), "S.%ld\r", offdelay / 6); } else { - snprintf(command, sizeof(command), "S%02d\r", offdelay / 60); + snprintf(command, sizeof(command), "S%02ld\r", offdelay / 60); } } else if (!strcasecmp(cmdname, "shutdown.reboot")) { if (offdelay < 60) { - snprintf(command, sizeof(command), "S.%dR%04d\r", offdelay / 6, ondelay); + snprintf(command, sizeof(command), "S.%ldR%04ld\r", offdelay / 6, ondelay); } else { - snprintf(command, sizeof(command), "S%02dR%04d\r", offdelay / 60, ondelay); + snprintf(command, sizeof(command), "S%02ldR%04ld\r", offdelay / 60, ondelay); } } else { - upslogx(LOG_NOTICE, "%s: command [%s] unknown", __func__, cmdname); + upslogx(LOG_NOTICE, "%s: command [%s] [%s] unknown", __func__, cmdname, extra); return STAT_INSTCMD_UNKNOWN; } @@ -182,7 +185,7 @@ static int powpan_instcmd(const char *cmdname, const char *extra) return STAT_INSTCMD_HANDLED; } - upslogx(LOG_ERR, "%s: command [%s] failed", __func__, cmdname); + upslogx(LOG_ERR, "%s: command [%s] [%s] failed", __func__, cmdname, extra); return STAT_INSTCMD_FAILED; } @@ -202,7 +205,19 @@ static int powpan_setvar(const char *varname, const char *val) return STAT_SET_HANDLED; } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(command, sizeof(command), vartab[i].set, atoi(val)); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif if ((powpan_command(command) == 2) && (!strcasecmp(powpan_answer, "#0"))) { dstate_setinfo(varname, "%s", val); @@ -222,8 +237,8 @@ static void powpan_initinfo(void) int i; char *s; - dstate_setinfo("ups.delay.start", "%d", 60 * ondelay); - dstate_setinfo("ups.delay.shutdown", "%d", offdelay); + dstate_setinfo("ups.delay.start", "%ld", 60 * ondelay); + dstate_setinfo("ups.delay.shutdown", "%ld", offdelay); /* * NOTE: The reply is already in the buffer, since the P4\r command @@ -362,15 +377,16 @@ static void powpan_initinfo(void) dstate_addcmd("shutdown.reboot"); } -static int powpan_status(status_t *status) +static ssize_t powpan_status(status_t *status) { - int ret; + ssize_t ret; ser_flush_io(upsfd); /* * WRITE D\r * READ #I119.0O119.0L000B100T027F060.0S..\r + * #I118.0O118.0L029B100F060.0R0218S..\r * 01234567890123456789012345678901234 * 0 1 2 3 */ @@ -404,7 +420,7 @@ static int powpan_status(status_t *status) return -1; } - upsdebug_hex(3, "read", powpan_answer, ret); + upsdebug_hex(3, "read", powpan_answer, (size_t)ret); ret = sscanf(powpan_answer, "#I%fO%fL%dB%dT%dF%fS%2c\r", &status->i_volt, &status->o_volt, &status->o_load, @@ -415,8 +431,21 @@ static int powpan_status(status_t *status) status->has_b_volt = 0; status->has_o_freq = 0; status->has_runtime = 0; + } else { + + ret = sscanf(powpan_answer, "#I%fO%fL%dB%dF%fR%dS%2c\r", + &status->i_volt, &status->o_volt, &status->o_load, + &status->b_chrg, &status->i_freq, &status->runtime, + status->flags); + + if (ret >= 7) { + status->has_b_volt = 0; + status->has_o_freq = 0; + status->has_runtime = 1; + } + } - else { + if (ret < 7) { ret = ser_get_buf_len(upsfd, powpan_answer+35, 23, SER_WAIT_SEC, SER_WAIT_USEC); if (ret < 0) { @@ -424,14 +453,14 @@ static int powpan_status(status_t *status) upsdebug_hex(4, " \\_", powpan_answer+35, 23); return -1; } - + if (ret == 0) { upsdebugx(3, "read: timeout"); upsdebug_hex(4, " \\_", powpan_answer+35, 23); return -1; } - - upsdebug_hex(3, "read", powpan_answer, ret); + + upsdebug_hex(3, "read", powpan_answer, (size_t)ret); ret = sscanf(powpan_answer, "#I%fO%fL%dB%dV%fT%dF%fH%fR%dC%dQ%fS%2c\r", &status->i_volt, &status->o_volt, &status->o_load, @@ -499,7 +528,7 @@ static int powpan_updateinfo(void) } else if (status.o_volt < 1.05 * status.i_volt) { /* ignore */ } else if (status.o_volt < 1.5 * status.i_volt) { - status_set("BOOST"); + status_set("BOOST"); } else { upsdebugx(2, "%s: output voltage too high", __func__); } @@ -518,9 +547,10 @@ static int powpan_updateinfo(void) return (status.flags[0] & 0x40) ? 1 : 0; } -static int powpan_initups(void) +static ssize_t powpan_initups(void) { - int ret, i; + ssize_t ret; + int i; upsdebugx(1, "Trying text protocol..."); @@ -535,7 +565,7 @@ static int powpan_initups(void) /* * WRITE P4\r - * READ #BC1200 ,1.600,000000000000,CYBER POWER + * READ #BC1200 ,1.600,000000000000,CYBER POWER * 01234567890123456789012345678901234567890123456 * 0 1 2 3 4 */ @@ -544,9 +574,9 @@ static int powpan_initups(void) if (ret < 1) { continue; } - + if (ret < 46) { - upsdebugx(2, "Expected 46 bytes, but only got %d", ret); + upsdebugx(2, "Expected 46 bytes, but only got %zd", ret); continue; } @@ -561,7 +591,7 @@ static int powpan_initups(void) } if ((ondelay < 0) || (ondelay > 9999)) { - fatalx(EXIT_FAILURE, "Start delay '%d' out of range [0..9999]", ondelay); + fatalx(EXIT_FAILURE, "Start delay '%ld' out of range [0..9999]", ondelay); } val = getval("offdelay"); @@ -570,7 +600,7 @@ static int powpan_initups(void) } if ((offdelay < 6) || (offdelay > 600)) { - fatalx(EXIT_FAILURE, "Shutdown delay '%d' out of range [6..600]", offdelay); + fatalx(EXIT_FAILURE, "Shutdown delay '%ld' out of range [6..600]", offdelay); } /* Truncate to nearest setable value */ @@ -588,6 +618,7 @@ static int powpan_initups(void) subdriver_t powpan_text = { "text", + POWERPANEL_TEXT_VERSION, powpan_instcmd, powpan_setvar, powpan_initups, diff --git a/drivers/powerp-txt.h b/drivers/powerp-txt.h index 790fd4c..a830d03 100644 --- a/drivers/powerp-txt.h +++ b/drivers/powerp-txt.h @@ -1,6 +1,6 @@ /* * powerp-txt.h - Model specific data/definitions for CyberPower text - * protocol UPSes + * protocol UPSes * * Copyright (C) * 2007 Doug Reynolds diff --git a/drivers/powerpanel.c b/drivers/powerpanel.c index 45e1f1e..6c677b8 100644 --- a/drivers/powerpanel.c +++ b/drivers/powerpanel.c @@ -1,6 +1,6 @@ /* * powerpanel.c - Model specific routines for CyberPower text/binary - * protocol UPSes + * protocol UPSes * * Copyright (C) * 2007 Doug Reynolds @@ -36,7 +36,7 @@ static subdriver_t *subdriver[] = { }; #define DRIVER_NAME "CyberPower text/binary protocol UPS driver" -#define DRIVER_VERSION "0.27" +#define DRIVER_VERSION "0.28" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -102,7 +102,7 @@ void upsdrv_updateinfo(void) void upsdrv_shutdown(void) { - int i, ret; + int i, ret = -1; /* * Try to shutdown with delay and automatic reboot if the power @@ -125,7 +125,7 @@ void upsdrv_shutdown(void) } } - if (ret) { + if (ret > 0) { /* * When on battery, the 'shutdown.stayoff' command will make * the UPS switch back on when the power returns. @@ -134,7 +134,7 @@ void upsdrv_shutdown(void) upslogx(LOG_INFO, "Waiting for power to return..."); return; } - } else { + } else if (ret == 0) { /* * Apparently, the power came back already, so we just need to reboot. */ diff --git a/drivers/powerpanel.h b/drivers/powerpanel.h index 8e441ba..b2b34be 100644 --- a/drivers/powerpanel.h +++ b/drivers/powerpanel.h @@ -1,6 +1,6 @@ /* * powerpanel.h - Model specific data/definitions for CyberPower text/binary - * protocol UPSes + * protocol UPSes * * Copyright (C) * 2007 Doug Reynolds @@ -33,10 +33,11 @@ #define SER_WAIT_USEC 250000 typedef struct { - const char *version; + const char *version; /* TODO: Rename: this is a subdriver type: "text" or "binary" */ + const char *versionString; /* TODO: Rename: this is the actual subdriver version */ int (*instcmd)(const char *cmdname, const char *extra); int (*setvar)(const char *varname, const char *val); - int (*initups)(void); + ssize_t (*initups)(void); void (*initinfo)(void); int (*updateinfo)(void); } subdriver_t; diff --git a/drivers/powervar-hid.c b/drivers/powervar-hid.c new file mode 100755 index 0000000..a37978a --- /dev/null +++ b/drivers/powervar-hid.c @@ -0,0 +1,147 @@ +/* powervar-hid.c - subdriver to monitor Powervar USB/HID devices with NUT + * + * Copyright (C) + * 2003 - 2012 Arnaud Quette + * 2005 - 2006 Peter Selinger + * 2008 - 2009 Arjen de Korte + * 2013 Charles Lepple + * 2019 AMETEK Powervar - Andrew McCartney + * + * Note: this subdriver was initially generated as a "stub" by the + * gen-usbhid-subdriver script. It must be customized. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config.h" /* must be first */ + +#include "usbhid-ups.h" +#include "powervar-hid.h" +#include "main.h" /* for getval() */ +#include "usb-common.h" + +#define POWERVAR_HID_VERSION "Powervar HID 0.20" +/* FIXME: experimental flag to be put in upsdrv_info */ + +/* Powervar */ +#define POWERVAR_VENDORID 0x4234 + +/* USB IDs device table */ +static usb_device_id_t powervar_usb_device_table[] = { + /* Powervar */ + { USB_DEVICE(POWERVAR_VENDORID, 0x0002), NULL }, + + /* Terminating entry */ + { 0, 0, NULL } +}; + +static usb_communication_subdriver_t *usb = &usb_subdriver; + +/* --------------------------------------------------------------- */ +/* Vendor-specific usage table */ +/* --------------------------------------------------------------- */ + +/* POWERVAR usage table */ +static usage_lkp_t powervar_usage_lkp[] = { + { "POWERVAR1", 0xff000001 }, + { NULL, 0 } +}; + +static usage_tables_t powervar_utab[] = { + powervar_usage_lkp, + hid_usage_lkp, + NULL, +}; + +/* --------------------------------------------------------------- */ +/* HID2NUT lookup table */ +/* --------------------------------------------------------------- */ + +static hid_info_t powervar_hid2nut[] = { + + /* Battery page */ + { "battery.type", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%s", 0, stringid_conversion }, + { "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", 0, NULL }, + { "battery.capacity", 0, 0, "UPS.PowerSummary.FullChargeCapacity", NULL, "%.0f", 0, NULL }, + { "battery.runtime", 0, 0, "UPS.PowerSummary.RuntimeToEmpty", NULL, "%.0f", 0, NULL }, + +/* Special case: ups.status & ups.alarm */ + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, online_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, discharging_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, charging_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ShutdownImminent", NULL, NULL, 0, shutdownimm_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit", NULL, NULL, 0, lowbatt_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Overload", NULL, NULL, 0, overload_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.NeedReplacement", NULL, NULL, 0, replacebatt_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.RemainingTimeLimitExpired", NULL, NULL, 0, timelimitexpired_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.InternalFailure", NULL, NULL, 0, yes_no_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Good", NULL, NULL, 0, yes_no_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.OverTemperature", NULL, NULL, 0, overheat_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.FullyCharged", NULL, NULL, 0, fullycharged_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.FullyDischarged", NULL, NULL, 0, depleted_info }, + + /* end of structure. */ + { NULL, 0, 0, NULL, NULL, NULL, 0, NULL } +}; + +static const char *powervar_format_model(HIDDevice_t *hd) { + return hd->Product; +} + +static const char *powervar_format_mfr(HIDDevice_t *hd) { + return hd->Vendor ? hd->Vendor : "Powervar"; +} + +static const char *powervar_format_serial(HIDDevice_t *hd) { + return hd->Serial; +} + +/* this function allows the subdriver to "claim" a device: return 1 if + * the device is supported by this subdriver, else 0. */ +static int powervar_claim(HIDDevice_t *hd) +{ + int status = is_usb_device_supported(powervar_usb_device_table, hd); + + switch (status) + { + case POSSIBLY_SUPPORTED: + /* by default, reject, unless the productid option is given */ + if (getval("productid")) { + usb->hid_rep_index = 1; + return 1; + } + possibly_supported("Powervar", hd); + return 0; + + case SUPPORTED: + usb->hid_rep_index = 1; + return 1; + + case NOT_SUPPORTED: + default: + return 0; + } +} + +subdriver_t powervar_subdriver = { + POWERVAR_HID_VERSION, + powervar_claim, + powervar_utab, + powervar_hid2nut, + powervar_format_model, + powervar_format_mfr, + powervar_format_serial, + fix_report_desc, +}; diff --git a/drivers/powervar-hid.h b/drivers/powervar-hid.h new file mode 100755 index 0000000..f86d5b8 --- /dev/null +++ b/drivers/powervar-hid.h @@ -0,0 +1,30 @@ +/* powervar-hid.h - subdriver to monitor Powervar USB/HID devices with NUT + * + * Copyright (C) + * 2003 - 2009 Arnaud Quette + * 2005 - 2006 Peter Selinger + * 2008 - 2009 Arjen de Korte + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef POWERVAR_HID_H +#define POWERVAR_HID_H + +#include "usbhid-ups.h" + +extern subdriver_t powervar_subdriver; + +#endif /* POWERVAR_HID_H */ diff --git a/drivers/powerware-mib.c b/drivers/powerware-mib.c index 1c2f9f2..e4b0296 100644 --- a/drivers/powerware-mib.c +++ b/drivers/powerware-mib.c @@ -4,7 +4,7 @@ * Copyright (C) * 2005-2006 Olli Savia * 2005-2006 Niels Baggesen - * 2015-2016 Arnaud Quette + * 2015-2019 Eaton (author: Arnaud Quette ) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,18 +24,23 @@ */ #include "powerware-mib.h" +#if WITH_SNMP_LKP_FUN +/* FIXME: shared helper code, need to be put in common */ +#include "eaton-pdu-marlin-helpers.h" +#endif -#define PW_MIB_VERSION "0.87" +#define PW_MIB_VERSION "0.104" /* TODO: more sysOID and MIBs support: - * + * * Powerware UPS (Ingrasys X-SLOT and BD-SLOT): ".1.3.6.1.4.1.534.1" * Powerware PXGX cards: ".1.3.6.1.4.1.534.2.12" * PXGX 2000 cards (UPS): Get xupsIdentModel (".1.3.6.1.4.1.534.1.1.2.0") * PXGX 1000 cards (PDU/RPP/RPM): Get pduNumPanels ".1.3.6.1.4.1.534.6.6.4.1.1.1.4.0" */ -/* Powerware UPS (Ingrasys X-SLOT and BD-SLOT) */ +/* Powerware UPS (Ingrasys X-SLOT and BD-SLOT) + * Eaton Gigabit Network Card (Genepi) */ #define POWERWARE_SYSOID ".1.3.6.1.4.1.534.1" /* Powerware UPS newer PXGX UPS cards (BladeUPS, ...) */ #define EATON_PXGX_SYSOID ".1.3.6.1.4.1.534.2.12" @@ -71,10 +76,9 @@ #define PW_OID_BY_VOLTAGE "1.3.6.1.4.1.534.1.5.3.1.2" /* XUPS-MIB::xupsBypassVoltage */ #define PW_OID_BATTEST_START "1.3.6.1.4.1.534.1.8.1" /* XUPS-MIB::xupsTestBattery set to startTest(1) to initiate test*/ -#define PW_OID_BATTEST_RES "1.3.6.1.4.1.534.1.8.2" /* XUPS-MIB::xupsTestBatteryStatus */ -#define PW_OID_CONT_OFFDELAY "1.3.6.1.4.1.534.1.9.1" /* XUPS-MIB::xupsControlOutputOffDelay */ -#define PW_OID_CONT_ONDELAY "1.3.6.1.4.1.534.1.9.2" /* XUPS-MIB::xupsControlOutputOnDelay */ +#define PW_OID_CONT_OFFDELAY "1.3.6.1.4.1.534.1.9.1.0" /* XUPS-MIB::xupsControlOutputOffDelay */ +#define PW_OID_CONT_ONDELAY "1.3.6.1.4.1.534.1.9.2.0" /* XUPS-MIB::xupsControlOutputOnDelay */ #define PW_OID_CONT_OFFT_DEL "1.3.6.1.4.1.534.1.9.3" /* XUPS-MIB::xupsControlOutputOffTrapDelay */ #define PW_OID_CONT_ONT_DEL "1.3.6.1.4.1.534.1.9.4" /* XUPS-MIB::xupsControlOutputOnTrapDelay */ #define PW_OID_CONT_LOAD_SHED_AND_RESTART "1.3.6.1.4.1.534.1.9.6" /* XUPS-MIB::xupsLoadShedSecsWithRestart */ @@ -103,101 +107,264 @@ #define DEFAULT_SHUTDOWNDELAY 0 static info_lkp_t pw_alarm_ob[] = { - { 1, "OB" }, - { 2, "" }, - { 0, NULL } -} ; - -static info_lkp_t pw_alarm_lb[] = { - { 1, "LB" }, - { 2, "" }, - { 0, NULL } -} ; - -static info_lkp_t pw_pwr_info[] = { - { 1, "" /* other */ }, - { 2, "OFF" /* none */ }, - { 3, "OL" /* normal */ }, - { 4, "BYPASS" /* bypass */ }, - { 5, "OB" /* battery */ }, - { 6, "OL BOOST" /* booster */ }, - { 7, "OL TRIM" /* reducer */ }, - { 8, "OL" /* parallel capacity */ }, - { 9, "OL" /* parallel redundancy */ }, - { 10, "OL" /* high efficiency */ }, - /* Extended status values */ - { 240, "OB" /* battery (0xF0) */ }, - { 100, "BYPASS" /* maintenanceBypass (0x64) */ }, - { 96, "BYPASS" /* Bypass (0x60) */ }, - { 81, "OL" /* high efficiency (0x51) */ }, - { 80, "OL" /* normal (0x50) */ }, - { 64, "OL" /* UPS supporting load, normal degraded mode (0x40) */ }, - { 16, "OFF" /* none (0x10) */ }, - { 0, NULL } + { 1, "OB", NULL, NULL }, + { 2, "", NULL, NULL }, + { 0, NULL, NULL, NULL } }; -static info_lkp_t pw_mode_info[] = { - { 1, "" }, - { 2, "" }, - { 3, "normal" }, - { 4, "" }, - { 5, "" }, - { 6, "" }, - { 7, "" }, - { 8, "parallel capacity" }, - { 9, "parallel redundancy" }, - { 10, "high efficiency" }, +static info_lkp_t pw_alarm_lb[] = { + { 1, "LB", NULL, NULL }, + { 2, "", NULL, NULL }, + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t pw_pwr_info[] = { + { 1, "" /* other */, NULL, NULL }, + { 2, "OFF" /* none */, NULL, NULL }, + { 3, "OL" /* normal */, NULL, NULL }, + { 4, "BYPASS" /* bypass */, NULL, NULL }, + { 5, "OB" /* battery */, NULL, NULL }, + { 6, "OL BOOST" /* booster */, NULL, NULL }, + { 7, "OL TRIM" /* reducer */, NULL, NULL }, + { 8, "OL" /* parallel capacity */, NULL, NULL }, + { 9, "OL" /* parallel redundancy */, NULL, NULL }, + { 10, "OL" /* high efficiency */, NULL, NULL }, /* Extended status values */ - { 240, "" /* battery (0xF0) */ }, - { 100, "" /* maintenanceBypass (0x64) */ }, - { 96, "" /* Bypass (0x60) */ }, - { 81, "high efficiency" /* high efficiency (0x51) */ }, - { 80, "normal" /* normal (0x50) */ }, - { 64, "" /* UPS supporting load, normal degraded mode (0x40) */ }, - { 16, "" /* none (0x10) */ }, - { 0, NULL } + { 240, "OB" /* battery (0xF0) */, NULL, NULL }, + { 100, "BYPASS" /* maintenanceBypass (0x64) */, NULL, NULL }, + { 96, "BYPASS" /* Bypass (0x60) */, NULL, NULL }, + { 81, "OL" /* high efficiency (0x51) */, NULL, NULL }, + { 80, "OL" /* normal (0x50) */, NULL, NULL }, + { 64, "OL" /* UPS supporting load, normal degraded mode (0x40) */, NULL, NULL }, + { 16, "OFF" /* none (0x10) */, NULL, NULL }, + { 0, NULL, NULL, NULL } +}; + +/* FIXME: mapped to (experimental.)ups.type, but + * should be output.source or ups.mode (need RFC) + * to complement the above ups.status + * along with having ups.type as described hereafter*/ +/* FIXME: should be used by ups.mode or output.source (need RFC); + * Note: this define is not set via project options; code was hidden with + * original commit to "snmp-ups: support newer Genepi management cards"; + * un-hidden to make it "experimental.*" namespace during backporting + */ +#ifndef USE_PW_MODE_INFO +# define USE_PW_MODE_INFO 1 +#endif + +#if USE_PW_MODE_INFO +static info_lkp_t pw_mode_info[] = { + { 1, "", NULL, NULL }, + { 2, "", NULL, NULL }, + { 3, "normal", NULL, NULL }, + { 4, "", NULL, NULL }, + { 5, "", NULL, NULL }, + { 6, "", NULL, NULL }, + { 7, "", NULL, NULL }, + { 8, "parallel capacity", NULL, NULL }, + { 9, "parallel redundancy", NULL, NULL }, + { 10, "high efficiency", NULL, NULL }, + /* Extended status values, + * FIXME: check for source and completion */ + { 240, "" /* battery (0xF0) */, NULL, NULL }, + { 100, "" /* maintenanceBypass (0x64) */, NULL, NULL }, + { 96, "" /* Bypass (0x60) */, NULL, NULL }, + { 81, "high efficiency" /* high efficiency (0x51) */, NULL, NULL }, + { 80, "normal" /* normal (0x50) */, NULL, NULL }, + { 64, "" /* UPS supporting load, normal degraded mode (0x40) */, NULL, NULL }, + { 16, "" /* none (0x10) */, NULL, NULL }, + { 0, NULL, NULL, NULL } +}; +#endif /* USE_PW_MODE_INFO */ + +/* FIXME: may be standardized + * extracted from bcmxcp.c->BCMXCP_TOPOLOGY_*, Make some common definitions */ +static info_lkp_t pw_topology_info[] = { + { 0x0000, "", NULL, NULL }, /* None; use the Table of Elements */ + { 0x0010, "Off-line switcher, Single Phase", NULL, NULL }, + { 0x0020, "Line-Interactive UPS, Single Phase", NULL, NULL }, + { 0x0021, "Line-Interactive UPS, Two Phase", NULL, NULL }, + { 0x0022, "Line-Interactive UPS, Three Phase", NULL, NULL }, + { 0x0030, "Dual AC Input, On-Line UPS, Single Phase", NULL, NULL }, + { 0x0031, "Dual AC Input, On-Line UPS, Two Phase", NULL, NULL }, + { 0x0032, "Dual AC Input, On-Line UPS, Three Phase", NULL, NULL }, + { 0x0040, "On-Line UPS, Single Phase", NULL, NULL }, + { 0x0041, "On-Line UPS, Two Phase", NULL, NULL }, + { 0x0042, "On-Line UPS, Three Phase", NULL, NULL }, + { 0x0050, "Parallel Redundant On-Line UPS, Single Phase", NULL, NULL }, + { 0x0051, "Parallel Redundant On-Line UPS, Two Phase", NULL, NULL }, + { 0x0052, "Parallel Redundant On-Line UPS, Three Phase", NULL, NULL }, + { 0x0060, "Parallel for Capacity On-Line UPS, Single Phase", NULL, NULL }, + { 0x0061, "Parallel for Capacity On-Line UPS, Two Phase", NULL, NULL }, + { 0x0062, "Parallel for Capacity On-Line UPS, Three Phase", NULL, NULL }, + { 0x0102, "System Bypass Module, Three Phase", NULL, NULL }, + { 0x0122, "Hot-Tie Cabinet, Three Phase", NULL, NULL }, + { 0x0200, "Outlet Controller, Single Phase", NULL, NULL }, + { 0x0222, "Dual AC Input Static Switch Module, 3 Phase", NULL, NULL }, + { 0, NULL, NULL, NULL } }; /* Legacy implementation */ static info_lkp_t pw_battery_abm_status[] = { - { 1, "CHRG" }, - { 2, "DISCHRG" }, -/* { 3, "Floating" }, */ -/* { 4, "Resting" }, */ -/* { 5, "Unknown" }, */ - { 0, NULL } -} ; + { 1, "CHRG", NULL, NULL }, + { 2, "DISCHRG", NULL, NULL }, +/* { 3, "Floating", NULL, NULL }, */ +/* { 4, "Resting", NULL, NULL }, */ +/* { 5, "Unknown", NULL, NULL }, */ + { 0, NULL, NULL, NULL } +}; -static info_lkp_t eaton_abm_status_info[] = { - { 1, "charging" }, - { 2, "discharging" }, - { 3, "floating" }, - { 4, "resting" }, - { 5, "unknown" }, /* Undefined - ABM is not activated */ - { 6, "disabled" }, /* ABM Charger Disabled */ - { 0, NULL } +static info_lkp_t pw_abm_status_info[] = { + { 1, "charging", NULL, NULL }, + { 2, "discharging", NULL, NULL }, + { 3, "floating", NULL, NULL }, + { 4, "resting", NULL, NULL }, + { 5, "unknown", NULL, NULL }, /* Undefined - ABM is not activated */ + { 6, "disabled", NULL, NULL }, /* ABM Charger Disabled */ + { 0, NULL, NULL, NULL } }; static info_lkp_t pw_batt_test_info[] = { - { 1, "" }, /* unknown */ - { 2, "Done and passed" }, - { 3, "Done and error" }, - { 4, "In progress" }, - { 5, "Not supported" }, - { 6, "Inhibited" }, - { 7, "Scheduled" }, - { 0, NULL } + { 1, "Unknown", NULL, NULL }, + { 2, "Done and passed", NULL, NULL }, + { 3, "Done and error", NULL, NULL }, + { 4, "In progress", NULL, NULL }, + { 5, "Not supported", NULL, NULL }, + { 6, "Inhibited", NULL, NULL }, + { 7, "Scheduled", NULL, NULL }, + { 0, NULL, NULL, NULL } }; -static info_lkp_t ietf_yes_no_info[] = { - { 1, "yes" }, - { 2, "no" }, - { 0, NULL } +static info_lkp_t pw_yes_no_info[] = { + { 1, "yes", NULL, NULL }, + { 2, "no", NULL, NULL }, + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t pw_outlet_status_info[] = { + { 1, "on", NULL, NULL }, + { 2, "off", NULL, NULL }, + { 3, "on", NULL, NULL }, /* pendingOff, transitional status */ + { 4, "off", NULL, NULL }, /* pendingOn, transitional status */ + /* { 5, "", NULL, NULL }, unknown */ + /* { 6, "", NULL, NULL }, reserved */ + { 7, "off", NULL, NULL }, /* Failed in Closed position */ + { 8, "on", NULL, NULL }, /* Failed in Open position */ + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t pw_ambient_drycontacts_info[] = { + { -1, "unknown", NULL, NULL }, + { 1, "opened", NULL, NULL }, + { 2, "closed", NULL, NULL }, + { 3, "opened", NULL, NULL }, /* openWithNotice */ + { 4, "closed", NULL, NULL }, /* closedWithNotice */ + { 0, NULL, NULL, NULL } +}; + +#if WITH_SNMP_LKP_FUN +/* Note: eaton_sensor_temperature_unit_fun() is defined in eaton-pdu-marlin-helpers.c + * and su_temperature_read_fun() is in snmp-ups.c + * Future work for DMF might provide same-named routines via LUA-C gateway. + */ + +# if WITH_SNMP_LKP_FUN_DUMMY +/* Temperature unit consideration */ +const char *eaton_sensor_temperature_unit_fun(void *raw_snmp_value) { + /* snmp_value here would be a (long*) */ + NUT_UNUSED_VARIABLE(raw_snmp_value); + return "unknown"; +} +/* FIXME: please DMF, though this should be in snmp-ups.c or equiv. */ +const char *su_temperature_read_fun(void *raw_snmp_value) { + /* snmp_value here would be a (long*) */ + NUT_UNUSED_VARIABLE(raw_snmp_value); + return "dummy"; +}; +# endif /* WITH_SNMP_LKP_FUN_DUMMY */ + +static info_lkp_t pw_sensor_temperature_unit_info[] = { + { 0, "dummy", eaton_sensor_temperature_unit_fun, NULL }, + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t pw_sensor_temperature_read_info[] = { + { 0, "dummy", su_temperature_read_fun, NULL }, + { 0, NULL, NULL, NULL } +}; + +#else /* if not WITH_SNMP_LKP_FUN: */ + +/* FIXME: For now, DMF codebase falls back to old implementation with static + * lookup/mapping tables for this, which can easily go into the DMF XML file. + */ +static info_lkp_t pw_sensor_temperature_unit_info[] = { + { 0, "kelvin", NULL, NULL }, + { 1, "celsius", NULL, NULL }, + { 2, "fahrenheit", NULL, NULL }, + { 0, NULL, NULL, NULL } +}; + +#endif /* WITH_SNMP_LKP_FUN */ + +static info_lkp_t pw_ambient_drycontacts_polarity_info[] = { + { 0, "normal-opened", NULL, NULL }, + { 1, "normal-closed", NULL, NULL }, + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t pw_ambient_drycontacts_state_info[] = { + { 0, "inactive", NULL, NULL }, + { 1, "active", NULL, NULL }, + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t pw_emp002_ambient_presence_info[] = { + { 0, "unknown", NULL, NULL }, + { 2, "yes", NULL, NULL }, /* communicationOK */ + { 3, "no", NULL, NULL }, /* communicationLost */ + { 0, NULL, NULL, NULL } +}; + +/* extracted from drivers/eaton-pdu-marlin-mib.c -> marlin_threshold_status_info */ +static info_lkp_t pw_threshold_status_info[] = { + { 0, "good", NULL, NULL }, /* No threshold triggered */ + { 1, "warning-low", NULL, NULL }, /* Warning low threshold triggered */ + { 2, "critical-low", NULL, NULL }, /* Critical low threshold triggered */ + { 3, "warning-high", NULL, NULL }, /* Warning high threshold triggered */ + { 4, "critical-high", NULL, NULL }, /* Critical high threshold triggered */ + { 0, NULL, NULL, NULL } +}; + +/* extracted from drivers/eaton-pdu-marlin-mib.c -> marlin_threshold_xxx_alarms_info */ +static info_lkp_t pw_threshold_temperature_alarms_info[] = { + { 0, "", NULL, NULL }, /* No threshold triggered */ + { 1, "low temperature warning!", NULL, NULL }, /* Warning low threshold triggered */ + { 2, "low temperature critical!", NULL, NULL }, /* Critical low threshold triggered */ + { 3, "high temperature warning!", NULL, NULL }, /* Warning high threshold triggered */ + { 4, "high temperature critical!", NULL, NULL }, /* Critical high threshold triggered */ + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t pw_threshold_humidity_alarms_info[] = { + { 0, "", NULL, NULL }, /* No threshold triggered */ + { 1, "low humidity warning!", NULL, NULL }, /* Warning low threshold triggered */ + { 2, "low humidity critical!", NULL, NULL }, /* Critical low threshold triggered */ + { 3, "high humidity warning!", NULL, NULL }, /* Warning high threshold triggered */ + { 4, "high humidity critical!", NULL, NULL }, /* Critical high threshold triggered */ + { 0, NULL, NULL, NULL } }; /* Snmp2NUT lookup table */ static snmp_info_t pw_mib[] = { + + /* standard MIB items */ + { "device.description", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.1.0", NULL, SU_FLAG_OK, NULL }, + { "device.contact", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.4.0", NULL, SU_FLAG_OK, NULL }, + { "device.location", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.6.0", NULL, SU_FLAG_OK, NULL }, + /* FIXME: miss device page! */ /* UPS page */ /* info_type, info_flags, info_len, OID, dfl, flags, oid2info, setvar */ @@ -205,16 +372,23 @@ static snmp_info_t pw_mib[] = { SU_FLAG_STATIC, NULL }, { "ups.model", ST_FLAG_STRING, SU_INFOSIZE, PW_OID_MODEL_NAME, "", SU_FLAG_STATIC, NULL }, + /* FIXME: the 2 "firmware" entries below should be SU_FLAG_SEMI_STATIC */ { "ups.firmware", ST_FLAG_STRING, SU_INFOSIZE, PW_OID_FIRMREV, "", - SU_FLAG_STATIC, NULL }, + 0, NULL }, { "ups.firmware.aux", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_AGENTREV, "", - SU_FLAG_STATIC, NULL }, + 0, NULL }, { "ups.serial", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_IDENT, "", SU_FLAG_STATIC, NULL }, { "ups.load", 0, 1.0, PW_OID_OUT_LOAD, "", - SU_OUTPUT_1, NULL }, + 0, NULL }, + /* FIXME: should be removed in favor of output.power */ { "ups.power", 0, 1.0, PW_OID_OUT_POWER ".1", "", 0, NULL }, + /* Duplicate of the above entry, but pointing at the first index */ + /* xupsOutputWatts.1.0; Value (Integer): 300 */ + { "ups.power", 0, 1.0, "1.3.6.1.4.1.534.1.4.4.1.4.1.0", "", + 0, NULL }, + { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, PW_OID_POWER_STATUS, "OFF", SU_STATUS_PWR, &pw_pwr_info[0] }, { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, PW_OID_ALARM_OB, "", @@ -223,10 +397,20 @@ static snmp_info_t pw_mib[] = { SU_STATUS_BATT, &pw_alarm_lb[0] }, { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, PW_OID_BATT_STATUS, "", SU_STATUS_BATT, &pw_battery_abm_status[0] }, - { "ups.type", ST_FLAG_STRING, SU_INFOSIZE, PW_OID_POWER_STATUS, "", +#if USE_PW_MODE_INFO + /* FIXME: should be ups.mode or output.source (need RFC) */ + /* Note: this define is not set via project options; code hidden with + * commit to "snmp-ups: support newer Genepi management cards" */ + { "experimental.ups.type", ST_FLAG_STRING, SU_INFOSIZE, PW_OID_POWER_STATUS, "", SU_FLAG_STATIC | SU_FLAG_OK, &pw_mode_info[0] }, +#endif /* USE_PW_MODE_INFO */ + /* xupsTopologyType.0; Value (Integer): 32 */ + { "ups.type", ST_FLAG_STRING, SU_INFOSIZE, "1.3.6.1.4.1.534.1.13.1.0", "", + SU_FLAG_STATIC | SU_FLAG_OK, &pw_topology_info[0] }, + /* FIXME: should be removed in favor of their output. equivalent! */ { "ups.realpower.nominal", 0, 1.0, PW_OID_CONF_POWER, "", 0, NULL }, + /* FIXME: should be removed in favor of output.power.nominal */ { "ups.power.nominal", 0, 1.0, IETF_OID_CONF_OUT_VA, "", 0, NULL }, /* XUPS-MIB::xupsEnvAmbientTemp.0 */ @@ -236,12 +420,12 @@ static snmp_info_t pw_mib[] = { { "ups.temperature.low", ST_FLAG_RW, 1.0, "1.3.6.1.4.1.534.1.6.2.0", "", 0, NULL }, /* XUPS-MIB::xupsEnvAmbientUpperLimit.0 */ { "ups.temperature.high", ST_FLAG_RW, 1.0, "1.3.6.1.4.1.534.1.6.3.0", "", 0, NULL }, - { "ups.test.result", ST_FLAG_STRING, SU_INFOSIZE, PW_OID_BATTEST_RES, "", - 0, &pw_batt_test_info[0] }, - { "ups.start.auto", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_AUTO_RESTART, "", - SU_FLAG_OK, &ietf_yes_no_info[0] }, - { "battery.charger.status", ST_FLAG_STRING, SU_INFOSIZE, PW_OID_BATT_STATUS, "", - SU_STATUS_BATT, &eaton_abm_status_info[0] }, + /* XUPS-MIB::xupsTestBatteryStatus */ + { "ups.test.result", ST_FLAG_STRING, SU_INFOSIZE, "1.3.6.1.4.1.534.1.8.2.0", "", 0, &pw_batt_test_info[0] }, + /* UPS-MIB::upsAutoRestart */ + { "ups.start.auto", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, "1.3.6.1.2.1.33.1.8.5.0", "", SU_FLAG_OK, &pw_yes_no_info[0] }, + /* XUPS-MIB::xupsBatteryAbmStatus.0 */ + { "battery.charger.status", ST_FLAG_STRING, SU_INFOSIZE, "1.3.6.1.4.1.534.1.2.5.0", "", SU_STATUS_BATT, &pw_abm_status_info[0] }, /* Battery page */ { "battery.charge", 0, 1.0, PW_OID_BATT_CHARGE, "", @@ -254,18 +438,41 @@ static snmp_info_t pw_mib[] = { 0, NULL }, { "battery.runtime.low", 0, 60.0, IETF_OID_CONF_RUNTIME_LOW, "", 0, NULL }, + { "battery.date", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.1.2.6.0", NULL, SU_FLAG_OK, &su_convert_to_iso_date_info[FUNMAP_USDATE_TO_ISODATE] }, /* Output page */ - { "output.phases", 0, 1.0, PW_OID_OUT_LINES, "", - SU_FLAG_SETINT, NULL, &output_phases }, - { "output.frequency", 0, 0.1, PW_OID_OUT_FREQUENCY, "", - 0, NULL }, - { "output.voltage", 0, 1.0, PW_OID_OUT_VOLTAGE ".1", "", - SU_OUTPUT_1, NULL }, + { "output.phases", 0, 1.0, PW_OID_OUT_LINES, "", 0, NULL }, + /* XUPS-MIB::xupsOutputFrequency.0 */ + { "output.frequency", 0, 0.1, "1.3.6.1.4.1.534.1.4.2.0", "", 0, NULL }, + /* XUPS-MIB::xupsConfigOutputFreq.0 */ + { "output.frequency.nominal", 0, 0.1, "1.3.6.1.4.1.534.1.10.4.0", "", 0, NULL }, + /* XUPS-MIB::xupsOutputVoltage.1 */ + { "output.voltage", 0, 1.0, "1.3.6.1.4.1.534.1.4.4.1.2.1", "", SU_OUTPUT_1, NULL }, + /* Duplicate of the above entry, but pointing at the first index */ + /* xupsOutputVoltage.1.0; Value (Integer): 230 */ + { "output.voltage", 0, 1.0, "1.3.6.1.4.1.534.1.4.4.1.2.1.0", "", SU_OUTPUT_1, NULL }, + /* XUPS-MIB::xupsConfigOutputVoltage.0 */ + { "output.voltage.nominal", 0, 1.0, "1.3.6.1.4.1.534.1.10.1.0", "", 0, NULL }, + /* XUPS-MIB::xupsConfigLowOutputVoltageLimit.0 */ + { "output.voltage.low", 0, 1.0, ".1.3.6.1.4.1.534.1.10.6.0", "", 0, NULL }, + /* XUPS-MIB::xupsConfigHighOutputVoltageLimit.0 */ + { "output.voltage.high", 0, 1.0, ".1.3.6.1.4.1.534.1.10.7.0", "", 0, NULL }, { "output.current", 0, 1.0, PW_OID_OUT_CURRENT ".1", "", SU_OUTPUT_1, NULL }, + /* Duplicate of the above entry, but pointing at the first index */ + /* xupsOutputCurrent.1.0; Value (Integer): 0 */ + { "output.current", 0, 1.0, "1.3.6.1.4.1.534.1.4.4.1.3.1.0", "", + SU_OUTPUT_1, NULL }, { "output.realpower", 0, 1.0, PW_OID_OUT_POWER ".1", "", SU_OUTPUT_1, NULL }, + /* Duplicate of the above entry, but pointing at the first index */ + /* Name/OID: xupsOutputWatts.1.0; Value (Integer): 1200 */ + { "output.realpower", 0, 1.0, "1.3.6.1.4.1.534.1.4.4.1.4.1.0", "", + 0, NULL }, + /* Duplicate of "ups.realpower.nominal" + * FIXME: map either ups or output, but not both (or have an auto-remap) */ + { "output.realpower.nominal", 0, 1.0, PW_OID_CONF_POWER, "", + 0, NULL }, { "output.L1-N.voltage", 0, 1.0, PW_OID_OUT_VOLTAGE ".1", "", SU_OUTPUT_3, NULL }, { "output.L2-N.voltage", 0, 1.0, PW_OID_OUT_VOLTAGE ".2", "", @@ -293,16 +500,21 @@ static snmp_info_t pw_mib[] = { SU_OUTPUT_3, NULL }, { "output.voltage.nominal", 0, 1.0, PW_OID_CONF_OVOLTAGE, "", 0, NULL }, - { "output.frequency.nominal", 0, 0.1, PW_OID_CONF_FREQ, "", - 0, NULL }, /* Input page */ { "input.phases", 0, 1.0, PW_OID_IN_LINES, "", - SU_FLAG_SETINT, NULL, &input_phases }, + 0, NULL }, { "input.frequency", 0, 0.1, PW_OID_IN_FREQUENCY, "", 0, NULL }, { "input.voltage", 0, 1.0, PW_OID_IN_VOLTAGE ".0", "", SU_INPUT_1, NULL }, + /* Duplicate of the above entry, but pointing at the first index */ + /* xupsInputVoltage.1[.0]; Value (Integer): 245 */ + { "input.voltage", 0, 1.0, "1.3.6.1.4.1.534.1.3.4.1.2.1", "", + SU_INPUT_1, NULL }, + + /* XUPS-MIB::xupsConfigInputVoltage.0 */ + { "input.voltage.nominal", 0, 1.0, "1.3.6.1.4.1.534.1.10.2.0", "", 0, NULL }, { "input.current", 0, 0.1, PW_OID_IN_CURRENT ".0", "", SU_INPUT_1, NULL }, { "input.L1-N.voltage", 0, 1.0, PW_OID_IN_VOLTAGE ".1", "", @@ -325,14 +537,16 @@ static snmp_info_t pw_mib[] = { SU_INPUT_3, NULL }, { "input.quality", 0, 1.0, PW_OID_IN_LINE_BADS, "", 0, NULL }, - { "input.voltage.nominal", 0, 1.0, PW_OID_CONF_IVOLTAGE, "", - 0, NULL }, - /* this segfaults? do we assume the same number of bypass phases as input phases? - { "input.bypass.phases", 0, 1.0, PW_OID_BY_LINES, "", - SU_FLAG_SETINT, NULL }, */ + /* FIXME: this segfaults! do we assume the same number of bypass phases as input phases? + { "input.bypass.phases", 0, 1.0, PW_OID_BY_LINES, "", 0, NULL }, */ + { "input.bypass.frequency", 0, 0.1, PW_OID_BY_FREQUENCY, "", 0, NULL }, { "input.bypass.voltage", 0, 1.0, PW_OID_BY_VOLTAGE ".0", "", SU_INPUT_1, NULL }, + /* Duplicate of the above entry, but pointing at the first index */ + /* xupsBypassVoltage.1.0; Value (Integer): 244 */ + { "input.bypass.voltage", 0, 1.0, "1.3.6.1.4.1.534.1.5.3.1.2.1.0", "", + SU_INPUT_1, NULL }, { "input.bypass.L1-N.voltage", 0, 1.0, PW_OID_BY_VOLTAGE ".1", "", SU_INPUT_3, NULL }, { "input.bypass.L2-N.voltage", 0, 1.0, PW_OID_BY_VOLTAGE ".2", "", @@ -340,20 +554,115 @@ static snmp_info_t pw_mib[] = { { "input.bypass.L3-N.voltage", 0, 1.0, PW_OID_BY_VOLTAGE ".3", "", SU_INPUT_3, NULL }, - /* Ambient page */ + /* Outlet page */ + /* Master outlet id always equal to 0 */ + { "outlet.id", 0, 1, NULL, "0", SU_FLAG_STATIC , NULL }, + /* XUPS-MIB:: xupsSwitchable.0 */ + { "outlet.switchable", 0, 1, ".1.3.6.1.4.1.534.1.9.7.0", NULL, SU_FLAG_STATIC , &pw_yes_no_info[0] }, + /* XUPS-MIB::xupsNumReceptacles; Value (Integer): 2 */ + { "outlet.count", 0, 1, ".1.3.6.1.4.1.534.1.12.1.0", NULL, SU_FLAG_STATIC, NULL }, + /* XUPS-MIB::xupsRecepIndex.X; Value (Integer): X */ + { "outlet.%i.id", 0, 1, ".1.3.6.1.4.1.534.1.12.2.1.1.%i", NULL, SU_FLAG_STATIC | SU_OUTLET, NULL }, + /* This MIB does not provide outlets switchability info. So map to a nearby + OID, for data activation, and map all values to "yes" */ + { "outlet.%i.switchable", 0, 1, ".1.3.6.1.4.1.534.1.12.2.1.1.%i", NULL, SU_FLAG_STATIC | SU_OUTLET, NULL }, + /* XUPS-MIB::xupsRecepStatus.X; Value (Integer): 1 */ + { "outlet.%i.status", 0, 1, ".1.3.6.1.4.1.534.1.12.2.1.2.%i", NULL, SU_OUTLET, &pw_outlet_status_info[0] }, + + /* Ambient collection */ + /* EMP001 (legacy) mapping */ /* XUPS-MIB::xupsEnvRemoteTemp.0 */ { "ambient.temperature", 0, 1.0, "1.3.6.1.4.1.534.1.6.5.0", "", 0, NULL }, /* XUPS-MIB::xupsEnvRemoteTempLowerLimit.0 */ { "ambient.temperature.low", ST_FLAG_RW, 1.0, "1.3.6.1.4.1.534.1.6.9.0", "", 0, NULL }, /* XUPS-MIB::xupsEnvRemoteTempUpperLimit.0 */ { "ambient.temperature.high", ST_FLAG_RW, 1.0, "1.3.6.1.4.1.534.1.6.10.0", "", 0, NULL }, - /* XUPS-MIB::xupsEnvRemoteHumidity.0 */ { "ambient.humidity", 0, 1.0, "1.3.6.1.4.1.534.1.6.6.0", "", 0, NULL }, /* XUPS-MIB::xupsEnvRemoteHumidityLowerLimit.0 */ { "ambient.humidity.low", ST_FLAG_RW, 1.0, "1.3.6.1.4.1.534.1.6.11.0", "", 0, NULL }, /* XUPS-MIB::xupsEnvRemoteHumidityUpperLimit.0 */ { "ambient.humidity.high", ST_FLAG_RW, 1.0, "1.3.6.1.4.1.534.1.6.12.0", "", 0, NULL }, + /* XUPS-MIB::xupsContactDescr.n */ + { "ambient.contacts.1.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.1.6.8.1.4.1", "", 0, NULL }, + { "ambient.contacts.2.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.1.6.8.1.4.2", "", 0, NULL }, + /* XUPS-MIB::xupsContactState.n */ + { "ambient.contacts.1.status", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.1.6.8.1.3.1", "", 0, &pw_ambient_drycontacts_info[0] }, + { "ambient.contacts.2.status", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.1.6.8.1.3.2", "", 0, &pw_ambient_drycontacts_info[0] }, + + /* EMP002 (EATON EMP MIB) mapping, including daisychain support */ + /* Warning: indexes start at '1' not '0'! */ + /* sensorCount.0 */ + { "ambient.count", ST_FLAG_RW, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.1.0", "", 0, NULL }, + /* CommunicationStatus.n */ + { "ambient.%i.present", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.1.4.1.1.%i", + NULL, SU_AMBIENT_TEMPLATE, &pw_emp002_ambient_presence_info[0] }, + /* sensorName.n: OctetString EMPDT1H1C2 @1 */ + { "ambient.%i.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.3.1.1.%i", "", SU_AMBIENT_TEMPLATE, NULL }, + /* sensorManufacturer.n */ + { "ambient.%i.mfr", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.6.%i", "", SU_AMBIENT_TEMPLATE, NULL }, + /* sensorModel.n */ + { "ambient.%i.model", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.7.%i", "", SU_AMBIENT_TEMPLATE, NULL }, + /* sensorSerialNumber.n */ + { "ambient.%i.serial", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.9.%i", "", SU_AMBIENT_TEMPLATE, NULL }, + /* sensorUuid.n */ + { "ambient.%i.id", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.2.%i", "", SU_AMBIENT_TEMPLATE, NULL }, + /* sensorAddress.n */ + { "ambient.%i.address", 0, 1, ".1.3.6.1.4.1.534.6.8.1.1.2.1.4.%i", "", SU_AMBIENT_TEMPLATE, NULL }, + /* sensorFirmwareVersion.n */ + { "ambient.%i.firmware", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.10.%i", "", SU_AMBIENT_TEMPLATE, NULL }, + /* temperatureUnit.1 + * MUST be before the temperature data reading! */ + { "ambient.%i.temperature.unit", 0, 1.0, ".1.3.6.1.4.1.534.6.8.1.2.5.0", "", SU_AMBIENT_TEMPLATE, &pw_sensor_temperature_unit_info[0] }, + /* temperatureValue.n.1 */ + { "ambient.%i.temperature", 0, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.3.1.3.%i.1", "", SU_AMBIENT_TEMPLATE, +#if WITH_SNMP_LKP_FUN + &pw_sensor_temperature_read_info[0] +#else + NULL +#endif + }, + { "ambient.%i.temperature.status", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.8.1.2.3.1.1.%i.1", + NULL, SU_AMBIENT_TEMPLATE, &pw_threshold_status_info[0] }, + { "ups.alarm", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.8.1.2.3.1.1.%i.1", + NULL, SU_AMBIENT_TEMPLATE, &pw_threshold_temperature_alarms_info[0] }, + /* FIXME: ambient.n.temperature.{minimum,maximum} */ + /* temperatureThresholdLowCritical.n.1 */ + { "ambient.%i.temperature.low.critical", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.2.1.6.%i.1", "", SU_AMBIENT_TEMPLATE, NULL }, + /* temperatureThresholdLowWarning.n.1 */ + { "ambient.%i.temperature.low.warning", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.2.1.5.%i.1", "", SU_AMBIENT_TEMPLATE, NULL }, + /* temperatureThresholdHighWarning.n.1 */ + { "ambient.%i.temperature.high.warning", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.2.1.7.%i.1", "", SU_AMBIENT_TEMPLATE, NULL }, + /* temperatureThresholdHighCritical.n.1 */ + { "ambient.%i.temperature.high.critical", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.2.1.8.%i.1", "", SU_AMBIENT_TEMPLATE, NULL }, + /* humidityValue.n.1 */ + { "ambient.%i.humidity", 0, 0.1, ".1.3.6.1.4.1.534.6.8.1.3.3.1.3.%i.1", "", SU_AMBIENT_TEMPLATE, NULL }, + { "ambient.%i.humidity.status", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.8.1.3.3.1.1.%i.1", + NULL, SU_AMBIENT_TEMPLATE, &pw_threshold_status_info[0] }, + { "ups.alarm", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.8.1.3.3.1.1.%i.1", + NULL, SU_AMBIENT_TEMPLATE, &pw_threshold_humidity_alarms_info[0] }, + /* FIXME: consider ambient.n.humidity.{minimum,maximum} */ + /* humidityThresholdLowCritical.n.1 */ + { "ambient.%i.humidity.low.critical", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.3.2.1.6.%i.1", "", SU_AMBIENT_TEMPLATE, NULL }, + /* humidityThresholdLowWarning.n.1 */ + { "ambient.%i.humidity.low.warning", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.3.2.1.5.%i.1", "", SU_AMBIENT_TEMPLATE, NULL }, + /* humidityThresholdHighWarning.n.1 */ + { "ambient.%i.humidity.high.warning", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.3.2.1.7.%i.1", "", SU_AMBIENT_TEMPLATE, NULL }, + /* humidityThresholdHighCritical.n.1 */ + { "ambient.%i.humidity.high.critical", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.3.2.1.8.%i.1", "", SU_AMBIENT_TEMPLATE, NULL }, + /* digitalInputName.n.{1,2} */ + { "ambient.%i.contacts.1.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.2.1.1.%i.1", "", SU_AMBIENT_TEMPLATE, NULL }, + { "ambient.%i.contacts.2.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.2.1.1.%i.2", "", SU_AMBIENT_TEMPLATE, NULL }, + /* digitalInputPolarity.n */ + { "ambient.%i.contacts.1.config", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.4.2.1.3.%i.1", "", SU_AMBIENT_TEMPLATE, &pw_ambient_drycontacts_polarity_info[0] }, + { "ambient.%i.contacts.2.config", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.4.2.1.3.%i.2", "", SU_AMBIENT_TEMPLATE, &pw_ambient_drycontacts_polarity_info[0] }, + /* XUPS-MIB::xupsContactState.n */ + { "ambient.%i.contacts.1.status", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.3.1.3.%i.1", "", SU_AMBIENT_TEMPLATE, &pw_ambient_drycontacts_state_info[0] }, + { "ambient.%i.contacts.2.status", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.3.1.3.%i.2", "", SU_AMBIENT_TEMPLATE, &pw_ambient_drycontacts_state_info[0] }, /* instant commands */ { "test.battery.start.quick", 0, 1, PW_OID_BATTEST_START, "", @@ -364,17 +673,37 @@ static snmp_info_t pw_mib[] = { /* Cancel output off, by writing 0 to xupsControlOutputOffDelay */ { "shutdown.stop", 0, 0, PW_OID_CONT_OFFDELAY, "", SU_TYPE_CMD | SU_FLAG_OK, NULL }, + /* XUPS-MIB::xupsControlOutputOffDelay */ /* load off after 1 sec, shortest possible delay; 0 cancels */ - { "load.off", 0, 1, PW_OID_CONT_OFFDELAY, "", + { "load.off", 0, 1, PW_OID_CONT_OFFDELAY, "1", SU_TYPE_CMD | SU_FLAG_OK, NULL }, - { "load.off.delay", 0, DEFAULT_OFFDELAY, PW_OID_CONT_OFFDELAY, "", + /* Delayed version, parameter is mandatory (so dfl is NULL)! */ + { "load.off.delay", 0, 1, PW_OID_CONT_OFFDELAY, NULL, SU_TYPE_CMD | SU_FLAG_OK, NULL }, + /* XUPS-MIB::xupsControlOutputOnDelay */ /* load on after 1 sec, shortest possible delay; 0 cancels */ - { "load.on", 0, 1, PW_OID_CONT_ONDELAY, "", + { "load.on", 0, 1, PW_OID_CONT_ONDELAY, "1", SU_TYPE_CMD | SU_FLAG_OK, NULL }, - { "load.on.delay", 0, DEFAULT_ONDELAY, PW_OID_CONT_ONDELAY, "", + /* Delayed version, parameter is mandatory (so dfl is NULL)! */ + { "load.on.delay", 0, 1, PW_OID_CONT_ONDELAY, NULL, SU_TYPE_CMD | SU_FLAG_OK, NULL }, + /* Delays handling: + * 0-n :Time in seconds until the command is issued + * -1:Cancel a pending Off/On command */ + /* XUPS-MIB::xupsRecepOffDelaySecs.n */ + { "outlet.%i.load.off", 0, 1, ".1.3.6.1.4.1.534.1.12.2.1.3.%i", + "0", SU_TYPE_CMD | SU_OUTLET, NULL }, + /* XUPS-MIB::xupsRecepOnDelaySecs.n */ + { "outlet.%i.load.on", 0, 1, ".1.3.6.1.4.1.534.1.12.2.1.4.%i", + "0", SU_TYPE_CMD | SU_OUTLET, NULL }, + /* Delayed version, parameter is mandatory (so dfl is NULL)! */ + { "outlet.%i.load.off.delay", 0, 1, ".1.3.6.1.4.1.534.1.12.2.1.3.%i", + NULL, SU_TYPE_CMD | SU_OUTLET, NULL }, + /* XUPS-MIB::xupsRecepOnDelaySecs.n */ + { "outlet.%i.load.on.delay", 0, 1, ".1.3.6.1.4.1.534.1.12.2.1.4.%i", + NULL, SU_TYPE_CMD | SU_OUTLET, NULL }, + { "ups.alarms", 0, 1.0, PW_OID_ALARMS, "", 0, NULL }, diff --git a/drivers/raritan-pdu-mib.c b/drivers/raritan-pdu-mib.c index 255ab41..f4e52ac 100644 --- a/drivers/raritan-pdu-mib.c +++ b/drivers/raritan-pdu-mib.c @@ -1,6 +1,6 @@ /* raritan-mib.c - data to monitor Raritan PDUs (Basic and Complex) * - * Copyright (C) 2008 + * Copyright (C) 2008-2019 * Arnaud Quette * * Sponsored by Eaton @@ -25,7 +25,7 @@ #include "raritan-pdu-mib.h" -#define RARITAN_MIB_VERSION "0.5" +#define RARITAN_MIB_VERSION "0.8" /* Raritan MIB * this one uses the same MIB as Eaton Revelation, @@ -34,70 +34,76 @@ #define RARITAN_SYSOID RARITAN_BASE_OID #define RARITAN_OID_MODEL_NAME ".1.3.6.1.4.1.13742.1.1.12.0" -#define DO_OFF 0 -#define DO_ON 1 -#define DO_CYCLE 2 +#define DO_OFF "0" +#define DO_ON "1" +#define DO_CYCLE "2" -static info_lkp_t outlet_status_info[] = { - { -1, "error" }, - { 0, "off" }, - { 1, "on" }, - { 2, "cycling" }, /* transitional status */ - { 0, NULL } +static info_lkp_t raritan_pdu_outlet_status_info[] = { + { -1, "error", NULL, NULL }, + { 0, "off", NULL, NULL }, + { 1, "on", NULL, NULL }, + { 2, "cycling", NULL, NULL }, /* transitional status */ + { 0, NULL, NULL, NULL } }; /* Snmp2NUT lookup table for Raritan MIB */ static snmp_info_t raritan_mib[] = { + + /* standard MIB items */ + { "device.description", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.1.0", NULL, SU_FLAG_OK, NULL }, + { "device.contact", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.4.0", NULL, SU_FLAG_OK, NULL }, + { "device.location", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.6.0", NULL, SU_FLAG_OK, NULL }, + /* Device page */ { "device.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "Raritan", - SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL, NULL }, + SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, { "device.model", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.1.12.0", - "Generic SNMP PDU", SU_FLAG_STATIC | SU_FLAG_OK, NULL, NULL }, + "Generic SNMP PDU", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, { "device.serial", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.1.2.0", "", - SU_FLAG_STATIC | SU_FLAG_OK, NULL, NULL }, + SU_FLAG_STATIC | SU_FLAG_OK, NULL }, { "device.type", ST_FLAG_STRING, SU_INFOSIZE, NULL, "pdu", - SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL, NULL }, + SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, { "device.macaddr", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.1.6.0", "", - SU_FLAG_STATIC | SU_FLAG_OK, NULL, NULL }, + SU_FLAG_STATIC | SU_FLAG_OK, NULL }, /* UPS page */ { "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "Raritan", - SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL, NULL }, + SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, { "ups.model", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.1.12.0", - "Generic SNMP PDU", SU_FLAG_STATIC | SU_FLAG_OK, NULL, NULL }, + "Generic SNMP PDU", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, { "ups.id", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.1.13.0", - "unknown", SU_FLAG_STATIC | SU_FLAG_OK, NULL, NULL }, + "unknown", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, { "ups.serial", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.1.2.0", "", - SU_FLAG_STATIC | SU_FLAG_OK, NULL, NULL }, + SU_FLAG_STATIC | SU_FLAG_OK, NULL }, { "ups.firmware", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.1.1.0", "", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, { "ups.type", ST_FLAG_STRING, SU_INFOSIZE, NULL, "pdu", - SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL, NULL }, - { "ups.temperature", 0, 1, ".1.3.6.1.4.1.13742.1.3.1.5.0", NULL, 0, NULL, NULL }, + SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, + { "ups.temperature", 0, 1, ".1.3.6.1.4.1.13742.1.3.1.5.0", NULL, 0, NULL }, /* Outlet page */ { "outlet.id", 0, 1, NULL, "0", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, { "outlet.desc", ST_FLAG_RW | ST_FLAG_STRING, 20, NULL, "All outlets", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, { "outlet.count", 0, 1, ".1.3.6.1.4.1.13742.1.2.1.0", "0", 0, NULL }, - { "outlet.current", 0, 0.001, ".1.3.6.1.4.1.13742.1.3.1.1" ".0", NULL, 0, NULL, NULL }, - { "outlet.voltage", 0, 0.001, ".1.3.6.1.4.1.13742.1.3.1.2" ".0", NULL, 0, NULL, NULL }, - { "outlet.realpower", 0, 1.0, ".1.3.6.1.4.1.13742.1.3.1.3" ".0", NULL, 0, NULL, NULL }, - { "outlet.power", 0, 1.0, ".1.3.6.1.4.1.13742.1.3.1.4" ".0", NULL, 0, NULL, NULL }, + { "outlet.current", 0, 0.001, ".1.3.6.1.4.1.13742.1.3.1.1" ".0", NULL, 0, NULL }, + { "outlet.voltage", 0, 0.001, ".1.3.6.1.4.1.13742.1.3.1.2" ".0", NULL, 0, NULL }, + { "outlet.realpower", 0, 1.0, ".1.3.6.1.4.1.13742.1.3.1.3" ".0", NULL, 0, NULL }, + { "outlet.power", 0, 1.0, ".1.3.6.1.4.1.13742.1.3.1.4" ".0", NULL, 0, NULL }, /* outlet template definition * Caution: the index of the data start at 0, while the name is +1 * ie outlet.1 => .0 */ - { "outlet.%i.switchable", 0, 1, ".1.3.6.1.4.1.13742.1.2.2.1.1.%i", "yes", SU_FLAG_STATIC | SU_OUTLET, NULL, NULL }, - { "outlet.%i.id", 0, 1, NULL, "%i", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK | SU_OUTLET, NULL, NULL }, - { "outlet.%i.desc", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.2.2.1.2.%i", NULL, SU_OUTLET, NULL, NULL }, - { "outlet.%i.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.2.2.1.3.%i", NULL, SU_FLAG_OK | SU_OUTLET, &outlet_status_info[0], NULL }, - { "outlet.%i.current", 0, 0.001, ".1.3.6.1.4.1.13742.1.2.2.1.4.%i", NULL, SU_OUTLET, NULL, NULL }, - { "outlet.%i.current.maximum", 0, 0.001, ".1.3.6.1.4.1.13742.1.2.2.1.5.%i", NULL, SU_OUTLET, NULL, NULL }, - { "outlet.%i.realpower", 0, 1.0, ".1.3.6.1.4.1.13742.1.2.2.1.7.%i", NULL, SU_OUTLET, NULL, NULL }, - { "outlet.%i.voltage", 0, 1.0, ".1.3.6.1.4.1.13742.1.2.2.1.6.%i", NULL, SU_OUTLET, NULL, NULL }, - { "outlet.%i.powerfactor", 0, 0.01, ".1.3.6.1.4.1.13742.1.2.2.1.9.%i", NULL, SU_OUTLET, NULL, NULL }, - { "outlet.%i.power", 0, 1.0, ".1.3.6.1.4.1.13742.1.2.2.1.8.%i", NULL, SU_OUTLET, NULL, NULL }, + { "outlet.%i.switchable", 0, 1, ".1.3.6.1.4.1.13742.1.2.2.1.1.%i", "yes", SU_FLAG_STATIC | SU_OUTLET, NULL }, + { "outlet.%i.id", 0, 1, NULL, "%i", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK | SU_OUTLET, NULL }, + { "outlet.%i.desc", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.2.2.1.2.%i", NULL, SU_OUTLET, NULL }, + { "outlet.%i.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.2.2.1.3.%i", NULL, SU_FLAG_OK | SU_OUTLET, &raritan_pdu_outlet_status_info[0] }, + { "outlet.%i.current", 0, 0.001, ".1.3.6.1.4.1.13742.1.2.2.1.4.%i", NULL, SU_OUTLET, NULL }, + { "outlet.%i.current.maximum", 0, 0.001, ".1.3.6.1.4.1.13742.1.2.2.1.5.%i", NULL, SU_OUTLET, NULL }, + { "outlet.%i.realpower", 0, 1.0, ".1.3.6.1.4.1.13742.1.2.2.1.7.%i", NULL, SU_OUTLET, NULL }, + { "outlet.%i.voltage", 0, 1.0, ".1.3.6.1.4.1.13742.1.2.2.1.6.%i", NULL, SU_OUTLET, NULL }, + { "outlet.%i.powerfactor", 0, 0.01, ".1.3.6.1.4.1.13742.1.2.2.1.9.%i", NULL, SU_OUTLET, NULL }, + { "outlet.%i.power", 0, 1.0, ".1.3.6.1.4.1.13742.1.2.2.1.8.%i", NULL, SU_OUTLET, NULL }, /* FIXME: * - delay for startup/shutdown sequence @@ -110,15 +116,15 @@ static snmp_info_t raritan_mib[] = { /* instant commands. */ /* Note that load.cycle might be replaced by / mapped on shutdown.reboot */ /* no counterpart found! - { "outlet.load.off", 0, DO_OFF, ".1.3.6.1.4.1.13742.1.2.2.1.3.0", NULL, SU_TYPE_CMD, NULL, NULL }, - { "outlet.load.on", 0, DO_ON, ".1.3.6.1.4.1.13742.1.2.2.1.3.0", NULL, SU_TYPE_CMD, NULL, NULL }, - { "outlet.load.cycle", 0, DO_CYCLE, ".1.3.6.1.4.1.13742.1.2.2.1.3.0", NULL, SU_TYPE_CMD, NULL, NULL }, */ - { "outlet.%i.load.off", 0, DO_OFF, ".1.3.6.1.4.1.13742.1.2.2.1.3.%i", NULL, SU_TYPE_CMD | SU_OUTLET, NULL, NULL }, - { "outlet.%i.load.on", 0, DO_ON, ".1.3.6.1.4.1.13742.1.2.2.1.3.%i", NULL, SU_TYPE_CMD | SU_OUTLET, NULL, NULL }, - { "outlet.%i.load.cycle", 0, DO_CYCLE, ".1.3.6.1.4.1.13742.1.2.2.1.3.%i", NULL, SU_TYPE_CMD | SU_OUTLET, NULL, NULL }, + { "outlet.load.off", 0, 1, ".1.3.6.1.4.1.13742.1.2.2.1.3.0", DO_OFF, SU_TYPE_CMD, NULL }, + { "outlet.load.on", 0, 1, ".1.3.6.1.4.1.13742.1.2.2.1.3.0", DO_ON, SU_TYPE_CMD, NULL }, + { "outlet.load.cycle", 0, 1, ".1.3.6.1.4.1.13742.1.2.2.1.3.0", DO_CYCLE, SU_TYPE_CMD, NULL }, */ + { "outlet.%i.load.off", 0, 1, ".1.3.6.1.4.1.13742.1.2.2.1.3.%i", DO_OFF, SU_TYPE_CMD | SU_OUTLET, NULL }, + { "outlet.%i.load.on", 0, 1, ".1.3.6.1.4.1.13742.1.2.2.1.3.%i", DO_ON, SU_TYPE_CMD | SU_OUTLET, NULL }, + { "outlet.%i.load.cycle", 0, 1, ".1.3.6.1.4.1.13742.1.2.2.1.3.%i", DO_CYCLE, SU_TYPE_CMD | SU_OUTLET, NULL }, /* end of structure. */ - { NULL, 0, 0, NULL, NULL, 0, NULL, NULL } + { NULL, 0, 0, NULL, NULL, 0, NULL } }; -mib2nut_info_t raritan = { "raritan", RARITAN_MIB_VERSION, NULL, RARITAN_OID_MODEL_NAME, raritan_mib, RARITAN_SYSOID }; +mib2nut_info_t raritan = { "raritan", RARITAN_MIB_VERSION, NULL, RARITAN_OID_MODEL_NAME, raritan_mib, RARITAN_SYSOID, NULL }; diff --git a/drivers/raritan-px2-mib.c b/drivers/raritan-px2-mib.c new file mode 100644 index 0000000..5f7ca2d --- /dev/null +++ b/drivers/raritan-px2-mib.c @@ -0,0 +1,586 @@ +/* raritan-px2-mib.c - subdriver to monitor RARITAN PX2 SNMP devices with NUT + * + * Copyright (C) + * 2011 - 2012 Arnaud Quette + * 2016 Arnaud Quette + * + * Based on initial work and data from Opengear + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "raritan-px2-mib.h" + +#define RARITAN_PX2_MIB_VERSION "0.4" + +#define RARITAN_PX2_MIB_SYSOID ".1.3.6.1.4.1.13742.6" +#define RARITAN_PX2_OID_MODEL_NAME ".1.3.6.1.4.1.13742.6.3.2.1.1.3.1" + +/* info elements */ +/* FIXME: triage between status and alarms, and make it compliant! */ +static info_lkp_t raritanpx2_outlet_status_info[] = { + { -1, "unavailable", NULL, NULL }, + { 0, "open", NULL, NULL }, + { 1, "closed", NULL, NULL }, + { 2, "belowLowerCritical", NULL, NULL }, + { 3, "belowLowerWarning", NULL, NULL }, + { 4, "normal", NULL, NULL }, + { 5, "aboveUpperWarning", NULL, NULL }, + { 6, "aboveUpperCritical", NULL, NULL }, + { 7, "on", NULL, NULL }, + { 8, "off", NULL, NULL }, + { 9, "detected", NULL, NULL }, + { 10, "notDetected", NULL, NULL }, + { 11, "alarmed", NULL, NULL }, + { 12, "ok", NULL, NULL }, + { 13, "marginal", NULL, NULL }, + { 14, "fail", NULL, NULL }, + { 15, "yes", NULL, NULL }, + { 16, "no", NULL, NULL }, + { 17, "standby", NULL, NULL }, + { 18, "one", NULL, NULL }, + { 19, "two", NULL, NULL }, + { 20, "inSync", NULL, NULL }, + { 21, "outOfSync", NULL, NULL }, + { 0, "NULL", NULL, NULL } +}; + +static info_lkp_t raritanpx2_outlet_switchability_info[] = { + { -1, "yes", NULL, NULL }, + { 1, "yes", NULL, NULL }, + { 2, "no", NULL, NULL }, + { 0, NULL, NULL, NULL } +}; + +/* PDU2-MIB Snmp2NUT lookup table */ +static snmp_info_t raritan_px2_mib[] = { + + /* standard MIB items */ + { "device.description", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.1.0", NULL, SU_FLAG_OK, NULL }, + { "device.contact", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.4.0", NULL, SU_FLAG_OK, NULL }, + { "device.location", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.6.0", NULL, SU_FLAG_OK, NULL }, + + /* pduManufacturer.1 = STRING: Raritan */ + { "device.mfr", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.2.1.1.2.1", + "Raritan", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, + /* pduModel.1 = STRING: PX2-5475 */ + { "device.model", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.2.1.1.3.1", + "Raritan PX2 SNMP PDU device", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, + /* pduSerialNumber.1 = STRING: QFC3950619 */ + { "device.serial", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.2.1.1.4.1", + NULL, SU_FLAG_STATIC | SU_FLAG_OK, NULL }, + { "device.type", ST_FLAG_STRING, SU_INFOSIZE, NULL, "pdu", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, + /* pxMACAddress.1 = STRING: 0:d:5d:b:49:0 */ + { "device.macaddr", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.2.2.1.11.1", + NULL, SU_FLAG_STATIC | SU_FLAG_OK, NULL }, + + /* boardVersion.1.mainController.1 = STRING: 0x01 */ + /* FIXME: not compliant! to be RFC'ed */ + { "device.revision", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.2.3.1.4.1.1.1", "", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, + /* FIXME: move to device collection! */ + /* Wrong OID! + * { "ups.mfr.date", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.2.3.1.6.1.1.1", "", SU_FLAG_OK | SU_FLAG_STATIC, NULL },*/ + /* boardFirmwareVersion.1.mainController.1 = STRING: 2.4.3.5-40298 */ + { "ups.firmware", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.2.3.1.6.1.1.1", "", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, + /* pduName.1 = STRING: my PX */ + { "ups.id", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.2.2.1.13.1", "", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, + { "ups.model", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.2.1.1.3.1", + "Raritan PX2 SNMP PDU device", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, + + /* Input data: + * Units are given in inletSensorUnits.1.1.%i + * Value should be scaled by inletSensorDecimalDigits.1.1.%i + * For example, if the value is 1 and inletSensorDecimalDigits is 2, then actual value is 0.01. */ + /* measurementsInletSensorValue.1.1.rmsCurrent = Gauge32: 10 (A) */ + { "input.load", 0, 0.1, ".1.3.6.1.4.1.13742.6.5.2.3.1.4.1.1.1", NULL, SU_FLAG_OK, NULL }, + /* measurementsInletSensorValue.1.1.rmsVoltage = Gauge32: 119 (V) */ + { "input.voltage", 0, 1, ".1.3.6.1.4.1.13742.6.5.2.3.1.4.1.1.4", NULL, SU_FLAG_OK, NULL }, + /* measurementsInletSensorValue.1.1.activePower = Gauge32: 10 (W) */ + { "input.realpower", 0, 1, ".1.3.6.1.4.1.13742.6.5.2.3.1.4.1.1.5", NULL, SU_FLAG_OK, NULL }, + /* measurementsInletSensorValue.1.1.apparentPower = Gauge32: 122 (VA) */ + { "input.power", 0, 1, ".1.3.6.1.4.1.13742.6.5.2.3.1.4.1.1.6", NULL, SU_FLAG_OK, NULL }, + /* measurementsInletSensorValue.1.1.powerFactor = Gauge32: 8 (none) */ + /* FIXME: need RFC! */ + { "input.powerfactor", 0, 0.01, ".1.3.6.1.4.1.13742.6.5.2.3.1.4.1.1.7", NULL, SU_FLAG_OK, NULL }, + /* measurementsInletSensorValue.1.1.activeEnergy = Gauge32: 193359 (wattHour) */ + /* { "unmapped.measurementsInletSensorValue", 0, 1, ".1.3.6.1.4.1.13742.6.5.2.3.1.4.1.1.8", NULL, SU_FLAG_OK, NULL }, */ + + /* inletPlug.1.1 = INTEGER: plugIEC320C20(6) */ + /* FIXME: need RFC (input.type | [input.]inlet.type...) and standardization + * { "unmapped.inletPlug", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.3.1.4.1.1", NULL, SU_FLAG_OK, NULL },*/ + + /* outletCount.1 = INTEGER: 24 */ + { "outlet.count", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.4.1", "0", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, + + /* outlet template definition + * Indexes start from 1, ie outlet.1 => .1 */ + /* Note: the first definition is used to determine the base index (ie 0 or 1) */ + /* outletName.1.%i = STRING: */ + { "outlet.%i.desc", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.5.3.1.3.1.%i", NULL, SU_OUTLET, NULL }, + /* outletSwitchingState.1.%i = INTEGER: on(7) */ + { "outlet.%i.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.4.1.2.1.3.1.%i", NULL, SU_OUTLET, &raritanpx2_outlet_status_info[0] }, + /* outletLabel.1.%i = STRING: 1 */ + { "outlet.%i.id", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.3.1.2.1.%i", "%i", SU_FLAG_STATIC | SU_OUTLET | SU_FLAG_OK, NULL }, + + /* outletReceptacle.1.1 = INTEGER: receptacleNEMA520R(37) */ + /* FIXME: need RFC and standardization + * { "outlet.%i.type", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.3.1.4.1.%i", NULL, SU_OUTLET | SU_FLAG_OK, NULL }, */ + + /* RMS Current (divide by 10). e.g. 5 == 0.5A */ + /* measurementsOutletSensorValue.1.%i.rmsCurrent = Gauge32: 10 */ + { "outlet.%i.current", 0, 0.1, ".1.3.6.1.4.1.13742.6.5.4.3.1.4.1.%i.1", NULL, SU_OUTLET | SU_FLAG_OK, NULL }, + /* measurementsOutletSensorValue.1.%i.rmsVoltage = Gauge32: 119 */ + { "outlet.%i.voltage", 0, 1, ".1.3.6.1.4.1.13742.6.5.4.3.1.4.1.%i.4", "%i", SU_OUTLET | SU_FLAG_OK, NULL }, + /* measurementsOutletSensorValue.1.%i.activePower = Gauge32: 10 */ + { "outlet.%i.power", 0, 1, ".1.3.6.1.4.1.13742.6.5.4.3.1.4.1.%i.5", "%i", SU_OUTLET | SU_FLAG_OK, NULL }, + /* measurementsOutletSensorValue.1.%i.apparentPower = Gauge32: 122 */ + { "outlet.%i.realpower", 0, 1, ".1.3.6.1.4.1.13742.6.5.4.3.1.4.1.%i.6", "%i", SU_OUTLET | SU_FLAG_OK, NULL }, + /* measurementsOutletSensorValue.1.%i.powerFactor = Gauge32: 8 */ + { "outlet.%i.powerfactor", 0, 1, ".1.3.6.1.4.1.13742.6.5.4.3.1.4.1.%i.7", "%i", SU_OUTLET | SU_FLAG_OK, NULL }, + /* measurementsOutletSensorValue.1.1.activeEnergy = Gauge32: 89890 */ + /* FIXME: + * { "unmapped.measurementsOutletSensorValue", 0, 1, ".1.3.6.1.4.1.13742.6.5.4.3.1.4.1.1.8", NULL, SU_FLAG_OK, NULL }, */ + /* measurementsOutletSensorValue.1.1.onOff = Gauge32: 0 */ + /* FIXME: + * { "unmapped.measurementsOutletSensorValue", 0, 1, ".1.3.6.1.4.1.13742.6.5.4.3.1.4.1.1.14", NULL, SU_FLAG_OK, NULL }, */ + + /* outletSwitchable.1.%i = INTEGER: true(1) */ + { "outlet.%i.switchable", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.5.3.1.28.1.%i", "no", SU_FLAG_STATIC | SU_OUTLET | SU_FLAG_OK, &raritanpx2_outlet_switchability_info[0] }, + + /* instant commands. */ + /* switchingOperation.1.1 = INTEGER: on(1) */ + { "outlet.%i.load.off", 0, 1, ".1.3.6.1.4.1.13742.6.4.1.2.1.2.1.%i", "0", SU_TYPE_CMD | SU_OUTLET, NULL }, + { "outlet.%i.load.on", 0, 1, ".1.3.6.1.4.1.13742.6.4.1.2.1.2.1.%i", "1", SU_TYPE_CMD | SU_OUTLET, NULL }, + { "outlet.%i.load.cycle", 0, 1, ".1.3.6.1.4.1.13742.6.4.1.2.1.2.1.%i", "2", SU_TYPE_CMD | SU_OUTLET, NULL }, + +#ifdef DEBUG + /* pduCount.0 = INTEGER: 1 */ + /* FIXME: part of daisychain support, RFC device.count */ + { "device.count", 0, 1, ".1.3.6.1.4.1.13742.6.3.1.0", NULL, SU_FLAG_OK, NULL }, + + /* pduRatedVoltage.1 = STRING: 100-120V */ + { "unmapped.pduRatedVoltage", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.2.1.1.5.1", NULL, SU_FLAG_OK, NULL }, + /* pduRatedCurrent.1 = STRING: 16A */ + { "unmapped.pduRatedCurrent", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.2.1.1.6.1", NULL, SU_FLAG_OK, NULL }, + /* pduRatedFrequency.1 = STRING: 50/60Hz */ + { "unmapped.pduRatedFrequency", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.2.1.1.7.1", NULL, SU_FLAG_OK, NULL }, + /* pduRatedVA.1 = STRING: 1.6-1.9kVA */ + { "unmapped.pduRatedVA", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.2.1.1.8.1", NULL, SU_FLAG_OK, NULL }, + /* pduImage.1 = STRING: */ + { "unmapped.pduImage", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.2.1.1.9.1", NULL, SU_FLAG_OK, NULL }, + /* inletCount.1 = INTEGER: 1 */ + { "unmapped.inletCount", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.2.1", NULL, SU_FLAG_OK, NULL }, + /* overCurrentProtectorCount.1 = INTEGER: 0 */ + { "unmapped.overCurrentProtectorCount", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.3.1", NULL, SU_FLAG_OK, NULL }, + + /* inletControllerCount.1 = INTEGER: 0 */ + { "unmapped.inletControllerCount", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.5.1", NULL, SU_FLAG_OK, NULL }, + /* outletControllerCount.1 = INTEGER: 6 */ + { "unmapped.outletControllerCount", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.6.1", NULL, SU_FLAG_OK, NULL }, + /* externalSensorCount.1 = INTEGER: 16 */ + { "unmapped.externalSensorCount", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.7.1", NULL, SU_FLAG_OK, NULL }, + /* pxIPAddress.1 = IpAddress: 192.168.20.188 */ + { "unmapped.pxIPAddress", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.8.1", NULL, SU_FLAG_OK, NULL }, + /* netmask.1 = IpAddress: 255.255.255.0 */ + { "unmapped.netmask", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.9.1", NULL, SU_FLAG_OK, NULL }, + /* gateway.1 = IpAddress: 192.168.20.254 */ + { "unmapped.gateway", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.10.1", NULL, SU_FLAG_OK, NULL }, + /* utcOffset.1 = STRING: -5:00 */ + { "unmapped.utcOffset", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.2.2.1.12.1", NULL, SU_FLAG_OK, NULL }, + /* externalSensorsZCoordinateUnits.1 = INTEGER: rackUnits(0) */ + { "unmapped.externalSensorsZCoordinateUnits", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.34.1", NULL, SU_FLAG_OK, NULL }, + /* unitDeviceCapabilities.1 = BITS: 00 00 00 00 00 00 */ + { "unmapped.unitDeviceCapabilities", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.35.1", NULL, SU_FLAG_OK, NULL }, + /* outletSequencingDelay.1 = Gauge32: 200 */ + { "unmapped.outletSequencingDelay", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.36.1", NULL, SU_FLAG_OK, NULL }, + /* globalOutletPowerCyclingPowerOffPeriod.1 = Gauge32: 10 */ + { "unmapped.globalOutletPowerCyclingPowerOffPeriod", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.37.1", NULL, SU_FLAG_OK, NULL }, + /* globalOutletStateOnStartup.1 = INTEGER: lastKnownState(2) */ + { "unmapped.globalOutletStateOnStartup", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.38.1", NULL, SU_FLAG_OK, NULL }, + /* outletPowerupSequence.1 = STRING: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24 */ + { "unmapped.outletPowerupSequence", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.2.2.1.39.1", NULL, SU_FLAG_OK, NULL }, + /* pduPowerCyclingPowerOffPeriod.1 = Gauge32: 3 */ + { "unmapped.pduPowerCyclingPowerOffPeriod", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.40.1", NULL, SU_FLAG_OK, NULL }, + /* pduDaisychainMemberType.1 = INTEGER: standalone(0) */ + { "unmapped.pduDaisychainMemberType", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.41.1", NULL, SU_FLAG_OK, NULL }, + /* managedExternalSensorCount.1 = INTEGER: 0 */ + { "unmapped.managedExternalSensorCount", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.42.1", NULL, SU_FLAG_OK, NULL }, + /* pxInetAddressType.1 = INTEGER: ipv4(1) */ + { "unmapped.pxInetAddressType", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.50.1", NULL, SU_FLAG_OK, NULL }, + /* pxInetIPAddress.1 = Hex-STRING: C0 A8 14 BC */ + { "unmapped.pxInetIPAddress", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.2.2.1.51.1", NULL, SU_FLAG_OK, NULL }, + /* pxInetNetmask.1 = Hex-STRING: FF FF FF 00 */ + { "unmapped.pxInetNetmask", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.2.2.1.52.1", NULL, SU_FLAG_OK, NULL }, + /* pxInetGateway.1 = Hex-STRING: C0 A8 14 FE */ + { "unmapped.pxInetGateway", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.2.2.1.53.1", NULL, SU_FLAG_OK, NULL }, + /* loadShedding.1 = INTEGER: false(2) */ + { "unmapped.loadShedding", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.55.1", NULL, SU_FLAG_OK, NULL }, + /* serverCount.1 = INTEGER: 8 */ + { "unmapped.serverCount", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.56.1", NULL, SU_FLAG_OK, NULL }, + /* inrushGuardDelay.1 = Gauge32: 200 */ + { "unmapped.inrushGuardDelay", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.57.1", NULL, SU_FLAG_OK, NULL }, + /* cascadedDeviceConnected.1 = INTEGER: false(2) */ + { "unmapped.cascadedDeviceConnected", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.58.1", NULL, SU_FLAG_OK, NULL }, + /* synchronizeWithNTPServer.1 = INTEGER: false(2) */ + { "unmapped.synchronizeWithNTPServer", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.59.1", NULL, SU_FLAG_OK, NULL }, + /* useDHCPProvidedNTPServer.1 = INTEGER: true(1) */ + { "unmapped.useDHCPProvidedNTPServer", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.60.1", NULL, SU_FLAG_OK, NULL }, + /* firstNTPServerAddressType.1 = INTEGER: unknown(0) */ + { "unmapped.firstNTPServerAddressType", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.61.1", NULL, SU_FLAG_OK, NULL }, + /* firstNTPServerAddress.1 = "" */ + { "unmapped.firstNTPServerAddress", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.62.1", NULL, SU_FLAG_OK, NULL }, + /* secondNTPServerAddressType.1 = INTEGER: unknown(0) */ + { "unmapped.secondNTPServerAddressType", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.63.1", NULL, SU_FLAG_OK, NULL }, + /* secondNTPServerAddress.1 = "" */ + { "unmapped.secondNTPServerAddress", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.64.1", NULL, SU_FLAG_OK, NULL }, + /* wireCount.1 = INTEGER: 0 */ + { "unmapped.wireCount", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.65.1", NULL, SU_FLAG_OK, NULL }, + /* transferSwitchCount.1 = INTEGER: 0 */ + { "unmapped.transferSwitchCount", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.2.1.66.1", NULL, SU_FLAG_OK, NULL }, + + /* boardVersion.1.outletController.{1-6} = STRING: 60 */ + { "unmapped.boardVersion", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.2.3.1.4.1.3.1", NULL, SU_FLAG_OK, NULL }, + + /* boardFirmwareVersion.1.outletController.{1-6} = STRING: 1F */ + { "unmapped.boardFirmwareVersion", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.2.3.1.6.1.3.1", NULL, SU_FLAG_OK, NULL }, + + /* boardFirmwareTimeStamp.1.mainController.1 = Gauge32: 0 */ + { "unmapped.boardFirmwareTimeStamp", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.3.1.8.1.1.1", NULL, SU_FLAG_OK, NULL }, + /* dataLogging.1 = INTEGER: true(1) */ + { "unmapped.dataLogging", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.4.1.1.1", NULL, SU_FLAG_OK, NULL }, + /* measurementPeriod.1 = INTEGER: 1 */ + { "unmapped.measurementPeriod", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.4.1.2.1", NULL, SU_FLAG_OK, NULL }, + /* measurementsPerLogEntry.1 = INTEGER: 60 */ + { "unmapped.measurementsPerLogEntry", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.4.1.3.1", NULL, SU_FLAG_OK, NULL }, + /* logSize.1 = INTEGER: 120 */ + { "unmapped.logSize", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.4.1.4.1", NULL, SU_FLAG_OK, NULL }, + /* dataLoggingEnableForAllSensors.1 = INTEGER: false(2) */ + { "unmapped.dataLoggingEnableForAllSensors", 0, 1, ".1.3.6.1.4.1.13742.6.3.2.4.1.5.1", NULL, SU_FLAG_OK, NULL }, + /* inletLabel.1.1 = STRING: I1 */ + { "unmapped.inletLabel", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.3.3.1.2.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletName.1.1 = STRING: */ + { "unmapped.inletName", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.3.3.1.3.1.1", NULL, SU_FLAG_OK, NULL }, + + /* inletPoleCount.1.1 = INTEGER: 2 */ + { "unmapped.inletPoleCount", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.3.1.5.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletRatedVoltage.1.1 = STRING: 100-120V */ + { "unmapped.inletRatedVoltage", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.3.3.1.6.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletRatedCurrent.1.1 = STRING: 16A */ + { "unmapped.inletRatedCurrent", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.3.3.1.7.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletDeviceCapabilities.1.1 = BITS: 9F 00 00 00 00 00 rmsCurrent(0) rmsVoltage(3) activePower(4) apparentPower(5) powerFactor(6) activeEnergy(7) */ + { "unmapped.inletDeviceCapabilities", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.3.1.10.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletPoleCapabilities.1.1 = BITS: 00 00 00 00 00 00 */ + { "unmapped.inletPoleCapabilities", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.3.1.11.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletPlugDescriptor.1.1 = STRING: IEC 60320 C20 */ + { "unmapped.inletPlugDescriptor", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.3.3.1.12.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletSensorLogAvailable.1.1.rmsCurrent = INTEGER: true(1) */ + { "unmapped.inletSensorLogAvailable", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.4.1.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletSensorLogAvailable.1.1.rmsVoltage = INTEGER: true(1) */ + { "unmapped.inletSensorLogAvailable", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.4.1.1.4", NULL, SU_FLAG_OK, NULL }, + /* inletSensorLogAvailable.1.1.activePower = INTEGER: true(1) */ + { "unmapped.inletSensorLogAvailable", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.4.1.1.5", NULL, SU_FLAG_OK, NULL }, + /* inletSensorLogAvailable.1.1.apparentPower = INTEGER: true(1) */ + { "unmapped.inletSensorLogAvailable", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.4.1.1.6", NULL, SU_FLAG_OK, NULL }, + /* inletSensorLogAvailable.1.1.powerFactor = INTEGER: true(1) */ + { "unmapped.inletSensorLogAvailable", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.4.1.1.7", NULL, SU_FLAG_OK, NULL }, + /* inletSensorLogAvailable.1.1.activeEnergy = INTEGER: true(1) */ + { "unmapped.inletSensorLogAvailable", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.4.1.1.8", NULL, SU_FLAG_OK, NULL }, + /* inletSensorUnits.1.1.rmsCurrent = INTEGER: amp(2) */ + { "unmapped.inletSensorUnits", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.6.1.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletSensorUnits.1.1.rmsVoltage = INTEGER: volt(1) */ + { "unmapped.inletSensorUnits", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.6.1.1.4", NULL, SU_FLAG_OK, NULL }, + /* inletSensorUnits.1.1.activePower = INTEGER: watt(3) */ + { "unmapped.inletSensorUnits", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.6.1.1.5", NULL, SU_FLAG_OK, NULL }, + /* inletSensorUnits.1.1.apparentPower = INTEGER: voltamp(4) */ + { "unmapped.inletSensorUnits", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.6.1.1.6", NULL, SU_FLAG_OK, NULL }, + /* inletSensorUnits.1.1.powerFactor = INTEGER: none(-1) */ + { "unmapped.inletSensorUnits", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.6.1.1.7", NULL, SU_FLAG_OK, NULL }, + /* inletSensorUnits.1.1.activeEnergy = INTEGER: wattHour(5) */ + { "unmapped.inletSensorUnits", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.6.1.1.8", NULL, SU_FLAG_OK, NULL }, + /* inletSensorDecimalDigits.1.1.rmsCurrent = Gauge32: 1 */ + { "unmapped.inletSensorDecimalDigits", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.7.1.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletSensorDecimalDigits.1.1.rmsVoltage = Gauge32: 0 */ + { "unmapped.inletSensorDecimalDigits", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.7.1.1.4", NULL, SU_FLAG_OK, NULL }, + /* inletSensorDecimalDigits.1.1.activePower = Gauge32: 0 */ + { "unmapped.inletSensorDecimalDigits", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.7.1.1.5", NULL, SU_FLAG_OK, NULL }, + /* inletSensorDecimalDigits.1.1.apparentPower = Gauge32: 0 */ + { "unmapped.inletSensorDecimalDigits", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.7.1.1.6", NULL, SU_FLAG_OK, NULL }, + /* inletSensorDecimalDigits.1.1.powerFactor = Gauge32: 2 */ + { "unmapped.inletSensorDecimalDigits", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.7.1.1.7", NULL, SU_FLAG_OK, NULL }, + /* inletSensorDecimalDigits.1.1.activeEnergy = Gauge32: 0 */ + { "unmapped.inletSensorDecimalDigits", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.7.1.1.8", NULL, SU_FLAG_OK, NULL }, + /* inletSensorAccuracy.1.1.rmsCurrent = Gauge32: 100 */ + { "unmapped.inletSensorAccuracy", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.8.1.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletSensorAccuracy.1.1.rmsVoltage = Gauge32: 100 */ + { "unmapped.inletSensorAccuracy", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.8.1.1.4", NULL, SU_FLAG_OK, NULL }, + /* inletSensorAccuracy.1.1.activePower = Gauge32: 300 */ + { "unmapped.inletSensorAccuracy", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.8.1.1.5", NULL, SU_FLAG_OK, NULL }, + /* inletSensorAccuracy.1.1.apparentPower = Gauge32: 200 */ + { "unmapped.inletSensorAccuracy", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.8.1.1.6", NULL, SU_FLAG_OK, NULL }, + /* inletSensorAccuracy.1.1.powerFactor = Gauge32: 500 */ + { "unmapped.inletSensorAccuracy", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.8.1.1.7", NULL, SU_FLAG_OK, NULL }, + /* inletSensorAccuracy.1.1.activeEnergy = Gauge32: 100 */ + { "unmapped.inletSensorAccuracy", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.8.1.1.8", NULL, SU_FLAG_OK, NULL }, + /* inletSensorResolution.1.1.rmsCurrent = Gauge32: 1 */ + { "unmapped.inletSensorResolution", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.9.1.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletSensorResolution.1.1.rmsVoltage = Gauge32: 1 */ + { "unmapped.inletSensorResolution", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.9.1.1.4", NULL, SU_FLAG_OK, NULL }, + /* inletSensorResolution.1.1.activePower = Gauge32: 1 */ + { "unmapped.inletSensorResolution", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.9.1.1.5", NULL, SU_FLAG_OK, NULL }, + /* inletSensorResolution.1.1.apparentPower = Gauge32: 1 */ + { "unmapped.inletSensorResolution", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.9.1.1.6", NULL, SU_FLAG_OK, NULL }, + /* inletSensorResolution.1.1.powerFactor = Gauge32: 1 */ + { "unmapped.inletSensorResolution", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.9.1.1.7", NULL, SU_FLAG_OK, NULL }, + /* inletSensorResolution.1.1.activeEnergy = Gauge32: 1 */ + { "unmapped.inletSensorResolution", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.9.1.1.8", NULL, SU_FLAG_OK, NULL }, + /* inletSensorTolerance.1.1.rmsCurrent = Gauge32: 120 */ + { "unmapped.inletSensorTolerance", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.10.1.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletSensorTolerance.1.1.rmsVoltage = Gauge32: 5 */ + { "unmapped.inletSensorTolerance", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.10.1.1.4", NULL, SU_FLAG_OK, NULL }, + /* inletSensorTolerance.1.1.activePower = Gauge32: 120 */ + { "unmapped.inletSensorTolerance", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.10.1.1.5", NULL, SU_FLAG_OK, NULL }, + /* inletSensorTolerance.1.1.apparentPower = Gauge32: 120 */ + { "unmapped.inletSensorTolerance", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.10.1.1.6", NULL, SU_FLAG_OK, NULL }, + /* inletSensorTolerance.1.1.powerFactor = Gauge32: 50 */ + { "unmapped.inletSensorTolerance", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.10.1.1.7", NULL, SU_FLAG_OK, NULL }, + /* inletSensorTolerance.1.1.activeEnergy = Gauge32: 120 */ + { "unmapped.inletSensorTolerance", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.10.1.1.8", NULL, SU_FLAG_OK, NULL }, + /* inletSensorMaximum.1.1.rmsCurrent = Gauge32: 7680 */ + { "unmapped.inletSensorMaximum", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.11.1.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletSensorMaximum.1.1.rmsVoltage = Gauge32: 264 */ + { "unmapped.inletSensorMaximum", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.11.1.1.4", NULL, SU_FLAG_OK, NULL }, + /* inletSensorMaximum.1.1.activePower = Gauge32: 202752 */ + { "unmapped.inletSensorMaximum", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.11.1.1.5", NULL, SU_FLAG_OK, NULL }, + /* inletSensorMaximum.1.1.apparentPower = Gauge32: 202752 */ + { "unmapped.inletSensorMaximum", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.11.1.1.6", NULL, SU_FLAG_OK, NULL }, + /* inletSensorMaximum.1.1.powerFactor = Gauge32: 100 */ + { "unmapped.inletSensorMaximum", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.11.1.1.7", NULL, SU_FLAG_OK, NULL }, + /* inletSensorMaximum.1.1.activeEnergy = Gauge32: 4294967295 */ + { "unmapped.inletSensorMaximum", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.11.1.1.8", NULL, SU_FLAG_OK, NULL }, + /* inletSensorMinimum.1.1.rmsCurrent = Gauge32: 0 */ + { "unmapped.inletSensorMinimum", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.12.1.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletSensorMinimum.1.1.rmsVoltage = Gauge32: 0 */ + { "unmapped.inletSensorMinimum", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.12.1.1.4", NULL, SU_FLAG_OK, NULL }, + /* inletSensorMinimum.1.1.activePower = Gauge32: 0 */ + { "unmapped.inletSensorMinimum", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.12.1.1.5", NULL, SU_FLAG_OK, NULL }, + /* inletSensorMinimum.1.1.apparentPower = Gauge32: 0 */ + { "unmapped.inletSensorMinimum", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.12.1.1.6", NULL, SU_FLAG_OK, NULL }, + /* inletSensorMinimum.1.1.powerFactor = Gauge32: 0 */ + { "unmapped.inletSensorMinimum", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.12.1.1.7", NULL, SU_FLAG_OK, NULL }, + /* inletSensorMinimum.1.1.activeEnergy = Gauge32: 0 */ + { "unmapped.inletSensorMinimum", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.12.1.1.8", NULL, SU_FLAG_OK, NULL }, + /* inletSensorHysteresis.1.1.rmsCurrent = Gauge32: 10 */ + { "unmapped.inletSensorHysteresis", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.13.1.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletSensorHysteresis.1.1.rmsVoltage = Gauge32: 2 */ + { "unmapped.inletSensorHysteresis", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.13.1.1.4", NULL, SU_FLAG_OK, NULL }, + /* inletSensorHysteresis.1.1.activePower = Gauge32: 0 */ + { "unmapped.inletSensorHysteresis", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.13.1.1.5", NULL, SU_FLAG_OK, NULL }, + /* inletSensorHysteresis.1.1.apparentPower = Gauge32: 0 */ + { "unmapped.inletSensorHysteresis", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.13.1.1.6", NULL, SU_FLAG_OK, NULL }, + /* inletSensorHysteresis.1.1.powerFactor = Gauge32: 0 */ + { "unmapped.inletSensorHysteresis", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.13.1.1.7", NULL, SU_FLAG_OK, NULL }, + /* inletSensorHysteresis.1.1.activeEnergy = Gauge32: 0 */ + { "unmapped.inletSensorHysteresis", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.13.1.1.8", NULL, SU_FLAG_OK, NULL }, + /* inletSensorStateChangeDelay.1.1.rmsCurrent = Gauge32: 0 */ + { "unmapped.inletSensorStateChangeDelay", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.14.1.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletSensorStateChangeDelay.1.1.rmsVoltage = Gauge32: 0 */ + { "unmapped.inletSensorStateChangeDelay", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.14.1.1.4", NULL, SU_FLAG_OK, NULL }, + /* inletSensorStateChangeDelay.1.1.activePower = Gauge32: 0 */ + { "unmapped.inletSensorStateChangeDelay", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.14.1.1.5", NULL, SU_FLAG_OK, NULL }, + /* inletSensorStateChangeDelay.1.1.apparentPower = Gauge32: 0 */ + { "unmapped.inletSensorStateChangeDelay", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.14.1.1.6", NULL, SU_FLAG_OK, NULL }, + /* inletSensorStateChangeDelay.1.1.powerFactor = Gauge32: 0 */ + { "unmapped.inletSensorStateChangeDelay", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.14.1.1.7", NULL, SU_FLAG_OK, NULL }, + /* inletSensorStateChangeDelay.1.1.activeEnergy = Gauge32: 0 */ + { "unmapped.inletSensorStateChangeDelay", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.14.1.1.8", NULL, SU_FLAG_OK, NULL }, + +/* Inlet thresholds */ + /* inletSensorLowerCriticalThreshold.1.1.rmsCurrent = Gauge32: 0 */ + { "unmapped.inletSensorLowerCriticalThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.21.1.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletSensorLowerCriticalThreshold.1.1.rmsVoltage = Gauge32: 94 */ + { "unmapped.inletSensorLowerCriticalThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.21.1.1.4", NULL, SU_FLAG_OK, NULL }, + /* inletSensorLowerCriticalThreshold.1.1.activePower = Gauge32: 0 */ + { "unmapped.inletSensorLowerCriticalThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.21.1.1.5", NULL, SU_FLAG_OK, NULL }, + /* inletSensorLowerCriticalThreshold.1.1.apparentPower = Gauge32: 0 */ + { "unmapped.inletSensorLowerCriticalThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.21.1.1.6", NULL, SU_FLAG_OK, NULL }, + /* inletSensorLowerCriticalThreshold.1.1.powerFactor = Gauge32: 0 */ + { "unmapped.inletSensorLowerCriticalThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.21.1.1.7", NULL, SU_FLAG_OK, NULL }, + /* inletSensorLowerCriticalThreshold.1.1.activeEnergy = Gauge32: 0 */ + { "unmapped.inletSensorLowerCriticalThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.21.1.1.8", NULL, SU_FLAG_OK, NULL }, + /* inletSensorLowerWarningThreshold.1.1.rmsCurrent = Gauge32: 0 */ + { "unmapped.inletSensorLowerWarningThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.22.1.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletSensorLowerWarningThreshold.1.1.rmsVoltage = Gauge32: 97 */ + { "unmapped.inletSensorLowerWarningThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.22.1.1.4", NULL, SU_FLAG_OK, NULL }, + /* inletSensorLowerWarningThreshold.1.1.activePower = Gauge32: 0 */ + { "unmapped.inletSensorLowerWarningThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.22.1.1.5", NULL, SU_FLAG_OK, NULL }, + /* inletSensorLowerWarningThreshold.1.1.apparentPower = Gauge32: 0 */ + { "unmapped.inletSensorLowerWarningThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.22.1.1.6", NULL, SU_FLAG_OK, NULL }, + /* inletSensorLowerWarningThreshold.1.1.powerFactor = Gauge32: 0 */ + { "unmapped.inletSensorLowerWarningThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.22.1.1.7", NULL, SU_FLAG_OK, NULL }, + /* inletSensorLowerWarningThreshold.1.1.activeEnergy = Gauge32: 0 */ + { "unmapped.inletSensorLowerWarningThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.22.1.1.8", NULL, SU_FLAG_OK, NULL }, + /* inletSensorUpperCriticalThreshold.1.1.rmsCurrent = Gauge32: 128 */ + { "unmapped.inletSensorUpperCriticalThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.23.1.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletSensorUpperCriticalThreshold.1.1.rmsVoltage = Gauge32: 127 */ + { "unmapped.inletSensorUpperCriticalThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.23.1.1.4", NULL, SU_FLAG_OK, NULL }, + /* inletSensorUpperCriticalThreshold.1.1.activePower = Gauge32: 0 */ + { "unmapped.inletSensorUpperCriticalThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.23.1.1.5", NULL, SU_FLAG_OK, NULL }, + /* inletSensorUpperCriticalThreshold.1.1.apparentPower = Gauge32: 0 */ + { "unmapped.inletSensorUpperCriticalThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.23.1.1.6", NULL, SU_FLAG_OK, NULL }, + /* inletSensorUpperCriticalThreshold.1.1.powerFactor = Gauge32: 0 */ + { "unmapped.inletSensorUpperCriticalThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.23.1.1.7", NULL, SU_FLAG_OK, NULL }, + /* inletSensorUpperCriticalThreshold.1.1.activeEnergy = Gauge32: 0 */ + { "unmapped.inletSensorUpperCriticalThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.23.1.1.8", NULL, SU_FLAG_OK, NULL }, + /* inletSensorUpperWarningThreshold.1.1.rmsCurrent = Gauge32: 104 */ + { "unmapped.inletSensorUpperWarningThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.24.1.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletSensorUpperWarningThreshold.1.1.rmsVoltage = Gauge32: 124 */ + { "unmapped.inletSensorUpperWarningThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.24.1.1.4", NULL, SU_FLAG_OK, NULL }, + /* inletSensorUpperWarningThreshold.1.1.activePower = Gauge32: 0 */ + { "unmapped.inletSensorUpperWarningThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.24.1.1.5", NULL, SU_FLAG_OK, NULL }, + /* inletSensorUpperWarningThreshold.1.1.apparentPower = Gauge32: 0 */ + { "unmapped.inletSensorUpperWarningThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.24.1.1.6", NULL, SU_FLAG_OK, NULL }, + /* inletSensorUpperWarningThreshold.1.1.powerFactor = Gauge32: 0 */ + { "unmapped.inletSensorUpperWarningThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.24.1.1.7", NULL, SU_FLAG_OK, NULL }, + /* inletSensorUpperWarningThreshold.1.1.activeEnergy = Gauge32: 0 */ + { "unmapped.inletSensorUpperWarningThreshold", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.24.1.1.8", NULL, SU_FLAG_OK, NULL }, + /* inletSensorEnabledThresholds.1.1.rmsCurrent = BITS: 30 upperWarning(2) upperCritical(3) */ + { "unmapped.inletSensorEnabledThresholds", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.25.1.1.1", NULL, SU_FLAG_OK, NULL }, + /* inletSensorEnabledThresholds.1.1.rmsVoltage = BITS: F0 lowerCritical(0) lowerWarning(1) upperWarning(2) upperCritical(3) */ + { "unmapped.inletSensorEnabledThresholds", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.25.1.1.4", NULL, SU_FLAG_OK, NULL }, + /* inletSensorEnabledThresholds.1.1.activePower = BITS: 00 */ + { "unmapped.inletSensorEnabledThresholds", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.25.1.1.5", NULL, SU_FLAG_OK, NULL }, + /* inletSensorEnabledThresholds.1.1.apparentPower = BITS: 00 */ + { "unmapped.inletSensorEnabledThresholds", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.25.1.1.6", NULL, SU_FLAG_OK, NULL }, + /* inletSensorEnabledThresholds.1.1.powerFactor = BITS: 00 */ + { "unmapped.inletSensorEnabledThresholds", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.25.1.1.7", NULL, SU_FLAG_OK, NULL }, + /* inletSensorEnabledThresholds.1.1.activeEnergy = BITS: 00 */ + { "unmapped.inletSensorEnabledThresholds", 0, 1, ".1.3.6.1.4.1.13742.6.3.3.4.1.25.1.1.8", NULL, SU_FLAG_OK, NULL }, + + /* outletPoleCount.1.{1-24} = INTEGER: 2 */ + { "unmapped.outletPoleCount", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.3.1.5.1.1", NULL, SU_FLAG_OK, NULL }, + + /* outletRatedVoltage.1.{1-24} = STRING: 100-120V */ + { "unmapped.outletRatedVoltage", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.5.3.1.6.1.1", NULL, SU_FLAG_OK, NULL }, + + /* outletRatedCurrent.1.{1-24} = STRING: 16A */ + { "unmapped.outletRatedCurrent", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.5.3.1.7.1.1", NULL, SU_FLAG_OK, NULL }, + + /* outletDeviceCapabilities.1.{1-24} = BITS: 9F 04 00 00 00 00 rmsCurrent(0) rmsVoltage(3) activePower(4) apparentPower(5) powerFactor(6) activeEnergy(7) onOff(13) */ + { "unmapped.outletDeviceCapabilities", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.3.1.10.1.1", NULL, SU_FLAG_OK, NULL }, + + /* outletPowerCyclingPowerOffPeriod.1.{1-24} = Gauge32: 10 */ + { "unmapped.outletPowerCyclingPowerOffPeriod", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.3.1.12.1.1", NULL, SU_FLAG_OK, NULL }, + + /* outletStateOnStartup.1.{1-24} = INTEGER: globalOutletStateOnStartup(3) */ + { "unmapped.outletStateOnStartup", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.3.1.13.1.1", NULL, SU_FLAG_OK, NULL }, + + /* outletUseGlobalPowerCyclingPowerOffPeriod.1.{1-24} = INTEGER: true(1) */ + { "unmapped.outletUseGlobalPowerCyclingPowerOffPeriod", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.3.1.14.1.1", NULL, SU_FLAG_OK, NULL }, + + /* outletReceptacleDescriptor.1.{1-24} = STRING: NEMA 5-20R */ + { "unmapped.outletReceptacleDescriptor", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.6.3.5.3.1.29.1.1", NULL, SU_FLAG_OK, NULL }, + + /* outletNonCritical.1.{1-24} = INTEGER: false(2) */ + { "unmapped.outletNonCritical", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.3.1.30.1.1", NULL, SU_FLAG_OK, NULL }, + + /* outletSequenceDelay.1.{1-24} = Gauge32: 0 */ + { "unmapped.outletSequenceDelay", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.3.1.32.1.%i", NULL, SU_FLAG_OK, NULL }, + + /* outletSensorLogAvailable.1.{1-24}.rmsCurrent = INTEGER: true(1) */ + { "unmapped.outletSensorLogAvailable", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.4.1.%i.1", NULL, SU_FLAG_OK, NULL }, + /* outletSensorLogAvailable.1.{1-24}.rmsVoltage = INTEGER: true(1) */ + { "unmapped.outletSensorLogAvailable", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.4.1.%i.4", NULL, SU_FLAG_OK, NULL }, + /* outletSensorLogAvailable.1.{1-24}.activePower = INTEGER: true(1) */ + { "unmapped.outletSensorLogAvailable", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.4.1.%i.5", NULL, SU_FLAG_OK, NULL }, + /* outletSensorLogAvailable.1.{1-24}.apparentPower = INTEGER: true(1) */ + { "unmapped.outletSensorLogAvailable", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.4.1.%i.6", NULL, SU_FLAG_OK, NULL }, + /* outletSensorLogAvailable.1.{1-24}.powerFactor = INTEGER: true(1) */ + { "unmapped.outletSensorLogAvailable", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.4.1.%i.7", NULL, SU_FLAG_OK, NULL }, + /* outletSensorLogAvailable.1.{1-24}.activeEnergy = INTEGER: true(1) */ + { "unmapped.outletSensorLogAvailable", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.4.1.%i.8", NULL, SU_FLAG_OK, NULL }, + /* outletSensorLogAvailable.1.{1-24}.onOff = INTEGER: true(1) */ + { "unmapped.outletSensorLogAvailable", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.4.1.%i.14", NULL, SU_FLAG_OK, NULL }, + + /* outletSensorUnits.1.{1-24}.rmsCurrent = INTEGER: amp(2) */ + { "unmapped.outletSensorUnits", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.6.1.%i.1", NULL, SU_FLAG_OK, NULL }, + /* outletSensorUnits.1.{1-24}.rmsVoltage = INTEGER: volt(1) */ + { "unmapped.outletSensorUnits", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.6.1.%i.4", NULL, SU_FLAG_OK, NULL }, + /* outletSensorUnits.1.{1-24}.activePower = INTEGER: watt(3) */ + { "unmapped.outletSensorUnits", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.6.1.%i.5", NULL, SU_FLAG_OK, NULL }, + /* outletSensorUnits.1.{1-24}.apparentPower = INTEGER: voltamp(4) */ + { "unmapped.outletSensorUnits", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.6.1.%i.6", NULL, SU_FLAG_OK, NULL }, + /* outletSensorUnits.1.{1-24}.powerFactor = INTEGER: none(-1) */ + { "unmapped.outletSensorUnits", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.6.1.%i.7", NULL, SU_FLAG_OK, NULL }, + /* outletSensorUnits.1.{1-24}.activeEnergy = INTEGER: wattHour(5) */ + { "unmapped.outletSensorUnits", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.6.1.%i.8", NULL, SU_FLAG_OK, NULL }, + /* outletSensorUnits.1.{1-24}.onOff = INTEGER: none(-1) */ + { "unmapped.outletSensorUnits", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.6.1.%i.14", NULL, SU_FLAG_OK, NULL }, + + /* outletSensorDecimalDigits.1.{1-24}.rmsCurrent = Gauge32: 1 */ + { "unmapped.outletSensorDecimalDigits", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.7.1.%i.1", NULL, SU_FLAG_OK, NULL }, + /* outletSensorDecimalDigits.1.{1-24}.rmsVoltage = Gauge32: 0 */ + { "unmapped.outletSensorDecimalDigits", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.7.1.%i.4", NULL, SU_FLAG_OK, NULL }, + /* outletSensorDecimalDigits.1.{1-24}.activePower = Gauge32: 0 */ + { "unmapped.outletSensorDecimalDigits", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.7.1.%i.5", NULL, SU_FLAG_OK, NULL }, + /* outletSensorDecimalDigits.1.{1-24}.apparentPower = Gauge32: 0 */ + { "unmapped.outletSensorDecimalDigits", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.7.1.%i.6", NULL, SU_FLAG_OK, NULL }, + /* outletSensorDecimalDigits.1.{1-24}.powerFactor = Gauge32: 2 */ + { "unmapped.outletSensorDecimalDigits", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.7.1.%i.7", NULL, SU_FLAG_OK, NULL }, + /* outletSensorDecimalDigits.1.{1-24}.activeEnergy = Gauge32: 0 */ + { "unmapped.outletSensorDecimalDigits", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.7.1.%i.8", NULL, SU_FLAG_OK, NULL }, + /* outletSensorDecimalDigits.1.{1-24}.onOff = Gauge32: 0 */ + { "unmapped.outletSensorDecimalDigits", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.7.1.%i.14", NULL, SU_FLAG_OK, NULL }, + + /* outletSensorAccuracy.1.{1-24}.rmsCurrent = Gauge32: 100 */ + { "unmapped.outletSensorAccuracy", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.8.1.%i.1", NULL, SU_FLAG_OK, NULL }, + /* outletSensorAccuracy.1.{1-24}.rmsVoltage = Gauge32: 100 */ + { "unmapped.outletSensorAccuracy", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.8.1.%i.4", NULL, SU_FLAG_OK, NULL }, + /* outletSensorAccuracy.1.{1-24}.activePower = Gauge32: 300 */ + { "unmapped.outletSensorAccuracy", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.8.1.%i.5", NULL, SU_FLAG_OK, NULL }, + /* outletSensorAccuracy.1.{1-24}.apparentPower = Gauge32: 200 */ + { "unmapped.outletSensorAccuracy", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.8.1.%i.6", NULL, SU_FLAG_OK, NULL }, + /* outletSensorAccuracy.1.{1-24}.powerFactor = Gauge32: 100 */ + { "unmapped.outletSensorAccuracy", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.8.1.%i.7", NULL, SU_FLAG_OK, NULL }, + /* outletSensorAccuracy.1.{1-24}.activeEnergy = Gauge32: 100 */ + { "unmapped.outletSensorAccuracy", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.8.1.%i.8", NULL, SU_FLAG_OK, NULL }, + /* outletSensorAccuracy.1.{1-24}.onOff = Gauge32: 0 */ + { "unmapped.outletSensorAccuracy", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.8.1.%i.14", NULL, SU_FLAG_OK, NULL }, + + /* outletSensorResolution.1.{1-24}.rmsCurrent = Gauge32: 1 */ + { "unmapped.outletSensorResolution", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.9.1.%i.1", NULL, SU_FLAG_OK, NULL }, + /* outletSensorResolution.1.{1-24}.rmsVoltage = Gauge32: 1 */ + { "unmapped.outletSensorResolution", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.9.1.%i.4", NULL, SU_FLAG_OK, NULL }, + /* outletSensorResolution.1.{1-24}.activePower = Gauge32: 1 */ + { "unmapped.outletSensorResolution", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.9.1.%i.5", NULL, SU_FLAG_OK, NULL }, + /* outletSensorResolution.1.{1-24}.apparentPower = Gauge32: 1 */ + { "unmapped.outletSensorResolution", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.9.1.%i.6", NULL, SU_FLAG_OK, NULL }, + /* outletSensorResolution.1.{1-24}.powerFactor = Gauge32: 1 */ + { "unmapped.outletSensorResolution", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.9.1.%i.7", NULL, SU_FLAG_OK, NULL }, + /* outletSensorResolution.1.{1-24}.activeEnergy = Gauge32: 1 */ + { "unmapped.outletSensorResolution", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.9.1.%i.8", NULL, SU_FLAG_OK, NULL }, + /* outletSensorResolution.1.{1-24}.onOff = Gauge32: 0 */ + { "unmapped.outletSensorResolution", 0, 1, ".1.3.6.1.4.1.13742.6.3.5.4.1.9.1.%i.14", NULL, SU_FLAG_OK, NULL }, + + /* end of interesting data + * the rest is 18MB of verbose log and satellite data */ + + /* Note: All reliabilityXXX data were removed */ +#endif /* DEBUG */ + + /* end of structure. */ + { NULL, 0, 0, NULL, NULL, 0, NULL } +}; + +mib2nut_info_t raritan_px2 = { "raritan-px2", RARITAN_PX2_MIB_VERSION, NULL, RARITAN_PX2_OID_MODEL_NAME, raritan_px2_mib, RARITAN_PX2_MIB_SYSOID, NULL }; diff --git a/drivers/eaton-ats-mib.h b/drivers/raritan-px2-mib.h similarity index 82% rename from drivers/eaton-ats-mib.h rename to drivers/raritan-px2-mib.h index 8b04f4e..5402bd8 100644 --- a/drivers/eaton-ats-mib.h +++ b/drivers/raritan-px2-mib.h @@ -1,4 +1,4 @@ -/* eaton_ats-mib.h - subdriver to monitor eaton_ats SNMP devices with NUT +/* raritan-px2-mib.h - subdriver to monitor RARITAN PX2 SNMP devices with NUT * * Copyright (C) * 2011 - 2012 Arnaud Quette @@ -19,12 +19,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef EATON_ATS_MIB_H -#define EATON_ATS_MIB_H +#ifndef RARITAN_PX2_MIB_H +#define RARITAN_PX2_MIB_H #include "main.h" #include "snmp-ups.h" -extern mib2nut_info_t eaton_ats; +extern mib2nut_info_t raritan_px2; -#endif /* EATON_ATS_MIB_H */ +#endif /* RARITAN_PX2_MIB_H */ diff --git a/drivers/rhino.c b/drivers/rhino.c index c43c411..c99770d 100644 --- a/drivers/rhino.c +++ b/drivers/rhino.c @@ -22,20 +22,22 @@ 2005/10/26 - Version 0.40 - Operational-2 release 2005/11/29 - Version 0.50 - rhino commands release - + http://www.microsol.com.br */ +#include "config.h" /* must be the first header */ + #include -#include #include "main.h" #include "serial.h" +#include "nut_float.h" #include "timehead.h" #define DRIVER_NAME "Microsol Rhino UPS driver" -#define DRIVER_VERSION "0.51" +#define DRIVER_VERSION "0.52" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -129,10 +131,10 @@ static unsigned char EventosRede, EventosSaida, EventosBateria; /* Methods */ static void ScanReceivePack(void); static int AutonomyCalc( int ); -static void CommReceive(const unsigned char*, int ); +static void CommReceive(const unsigned char*, ssize_t); static void getbaseinfo(void); static void getupdateinfo(void); - + static unsigned char RecPack[37]; /* comment on english language */ @@ -160,327 +162,327 @@ static unsigned char RecPack[37]; static int AutonomyCalc( int ia ) /* all models */ { + int result = 0; + double auton, calc, currin; - int result = 0; - double auton, calc, currin; - - if( ia ) - { - if( ( BattVoltage == 0 ) ) - result = 0; - else + if( ia ) { - calc = ( OutVoltage * OutCurrent )* 1.0 / ( 0.08 * BattVoltage ); - auton = pow( calc, 1.18 ); - if( ( auton == 0 ) ) - result = 0; - else - { - auton = 1.0 / auton; - auton = auton * 11.07; - calc = ( BattVoltage * 1.0 / 10 ) - 168; - result = (int) ( auton * calc * 2.5 ); - } - } - } - else - { - currin = ( UtilPowerOut + ConstInt ) *1.0 / Vin; - auton = ( ( ( AmpH *1.0 / currin ) * 60 * ( ( BattVoltage - VbatMin ) * 1.0 /( VbatNom - VbatMin ) ) * FM ) + FA ); - if( ( BattVoltage > 129 ) || ( BattVoltage < 144 ) ) - result = 133; - else - result = (int) auton; - } - - return result; + if( d_equal(BattVoltage, 0) ) + result = 0; + else + { + calc = ( OutVoltage * OutCurrent )* 1.0 / ( 0.08 * BattVoltage ); + auton = pow( calc, 1.18 ); + if( d_equal(auton, 0) ) + result = 0; + else + { + auton = 1.0 / auton; + auton = auton * 11.07; + calc = ( BattVoltage * 1.0 / 10 ) - 168; + result = (int) ( auton * calc * 2.5 ); + } + } + } + else + { + currin = ( UtilPowerOut + ConstInt ) *1.0 / Vin; + auton = ( ( ( AmpH *1.0 / currin ) * 60 * ( ( BattVoltage - VbatMin ) * 1.0 /( VbatNom - VbatMin ) ) * FM ) + FA ); + if( ( BattVoltage > 129 ) && ( BattVoltage < 144 ) ) + result = 133; + else + result = (int) auton; + } + return result; } /* Treat received package */ static void ScanReceivePack( void ) { + /* model independent data */ - /* model independent data */ + Year = RecPack[31] + ( RecPack[32] * 100 ); + Month = RecPack[30]; + Day = RecPack[29]; - Year = RecPack[31] + ( RecPack[32] * 100 ); - Month = RecPack[30]; - Day = RecPack[29]; + /* UPS internal time */ + ihour = RecPack[26]; + imin = RecPack[27]; + isec = RecPack[28]; - /* UPS internal time */ - ihour = RecPack[26]; - imin = RecPack[27]; - isec = RecPack[28]; + /* Flag1 */ + /* SobreTemp = ( ( 0x01 & RecPack[33]) = 0x01 ); */ + /* OutputOn = ( ( 0x02 & RecPack[33]) = 0x02 ); OutputOn */ + /* InputOn = ( ( 0x04 & RecPack[33]) = 0x04 ); InputOn */ + /* ByPassOn = ( ( 0x08 & RecPack[33]) = 0x08 ); BypassOn */ + /* Auto_HAB = ( ( 0x10 & RecPack[33]) = 0x10 ); */ + /* Timer_HAB = ( ( 0x20 & RecPack[33]) = 0x20 ); */ + /* Boost_Ligado = ( ( 0x40 & RecPack[33]) = 0x40 ); */ + /* Bateria_Desc = ( ( 0x80 & RecPack[33]) = 0x80 ); */ - /* Flag1 */ - /* SobreTemp = ( ( 0x01 & RecPack[33]) = 0x01 ); */ - /* OutputOn = ( ( 0x02 & RecPack[33]) = 0x02 ); OutputOn */ - /* InputOn = ( ( 0x04 & RecPack[33]) = 0x04 ); InputOn */ - /* ByPassOn = ( ( 0x08 & RecPack[33]) = 0x08 ); BypassOn */ - /* Auto_HAB = ( ( 0x10 & RecPack[33]) = 0x10 ); */ - /* Timer_HAB = ( ( 0x20 & RecPack[33]) = 0x20 ); */ - /* Boost_Ligado = ( ( 0x40 & RecPack[33]) = 0x40 ); */ - /* Bateria_Desc = ( ( 0x80 & RecPack[33]) = 0x80 ); */ + /* Flag2 */ + /* Quad_Ant_Ent = ( ( 0x01 & RecPack[34]) = 0x01 ); */ + /* Quadratura = ( ( 0x02 & RecPack[34]) = 0x02 ); */ + /* Termino_XMODEM = ( ( 0x04 & RecPack[34]) = 0x04 ); */ + /* Em_Sincronismo = ( ( 0x08 & RecPack[34]) = 0x08 ); */ + /* Out110 = ( ( 0x10 & RecPack[34]) = 0x10 ); Out110 */ + /* Exec_Beep = ( ( 0x20 & RecPack[34]) = 0x20 ); */ + /* LowBatt = ( ( 0x40 & RecPack[34]) = 0x40 ); LowBatt */ + /* Boost_Sobre = ( ( 0x80 & RecPack[34]) = 0x80 ); */ - /* Flag2 */ - /* Quad_Ant_Ent = ( ( 0x01 & RecPack[34]) = 0x01 ); */ - /* Quadratura = ( ( 0x02 & RecPack[34]) = 0x02 ); */ - /* Termino_XMODEM = ( ( 0x04 & RecPack[34]) = 0x04 ); */ - /* Em_Sincronismo = ( ( 0x08 & RecPack[34]) = 0x08 ); */ - /* Out110 = ( ( 0x10 & RecPack[34]) = 0x10 ); Out110 */ - /* Exec_Beep = ( ( 0x20 & RecPack[34]) = 0x20 ); */ - /* LowBatt = ( ( 0x40 & RecPack[34]) = 0x40 ); LowBatt */ - /* Boost_Sobre = ( ( 0x80 & RecPack[34]) = 0x80 ); */ + /* Flag3 */ + /* OverCharge = ( ( 0x01 & RecPack[35]) = 0x01 ); OverCharge */ + /* SourceFail = ( ( 0x02 & RecPack[35]) = 0x02 ); SourceFail */ + /* RedeAnterior = ( ( 0x04 & RecPack[35]) = 0x04 ); */ + /* Cmd_Executado = ( ( 0x08 & RecPack[35]) = 0x08 ); */ + /* Exec_Autoteste = ( ( 0x10 & RecPack[35]) = 0x10 ); */ + /* Quad_Ant_Sai = ( ( 0x20 & RecPack[35]) = 0x20 ); */ + /* ComandoSerial = ( ( 0x40 & RecPack[35]) = 0x40 ); */ + /* SobreTensao = ( ( 0x80 & RecPack[35]) = 0x80 ); */ - /* Flag3 */ - /* OverCharge = ( ( 0x01 & RecPack[35]) = 0x01 ); OverCharge */ - /* SourceFail = ( ( 0x02 & RecPack[35]) = 0x02 ); SourceFail */ - /* RedeAnterior = ( ( 0x04 & RecPack[35]) = 0x04 ); */ - /* Cmd_Executado = ( ( 0x08 & RecPack[35]) = 0x08 ); */ - /* Exec_Autoteste = ( ( 0x10 & RecPack[35]) = 0x10 ); */ - /* Quad_Ant_Sai = ( ( 0x20 & RecPack[35]) = 0x20 ); */ - /* ComandoSerial = ( ( 0x40 & RecPack[35]) = 0x40 ); */ - /* SobreTensao = ( ( 0x80 & RecPack[35]) = 0x80 ); */ + OutputOn = ( ( 0x02 & RecPack[33] ) == 0x02 ); + InputOn = ( ( 0x04 & RecPack[33] ) == 0x04 ); + BypassOn = ( ( 0x08 & RecPack[33] ) == 0x08 ); - OutputOn = ( ( 0x02 & RecPack[33] ) == 0x02 ); - InputOn = ( ( 0x04 & RecPack[33] ) == 0x04 ); - BypassOn = ( ( 0x08 & RecPack[33] ) == 0x08 ); + Out110 = ( ( 0x10 & RecPack[34] ) == 0x10 ); + LowBatt = ( ( 0x40 & RecPack[34] ) == 0x40 ); - Out110 = ( ( 0x10 & RecPack[34] ) == 0x10 ); - LowBatt = ( ( 0x40 & RecPack[34] ) == 0x40 ); + OverCharge = ( ( 0x01 & RecPack[35] ) == 0x01 ); + SourceFail = ( ( 0x02 & RecPack[35] ) == 0x02 ); - OverCharge = ( ( 0x01 & RecPack[35] ) == 0x01 ); - SourceFail = ( ( 0x02 & RecPack[35] ) == 0x02 ); + /* model dependent data read */ - /* model dependent data read */ - - PowerFactor = 800; - - if( RecPack[0] ==0xC2 ) - { - LimInfBattSrc = 174; - LimSupBattSrc = 192;/* 180????? carregador eh 180 (SCOPOS) */ - LimInfBattInv = 174; - LimSupBattInv = 192;/* 170????? (SCOPOS) */ - } - else - { - LimInfBattSrc = 138; - LimSupBattSrc = 162;/* 180????? carregador eh 180 (SCOPOS) */ - LimInfBattInv = 126; - LimSupBattInv = 156;/* 170????? (SCOPOS) */ - } - - BattNonValue = 144; - /* VersaoInterna = "R10" + IntToStr( RecPack[1] ); */ - InVoltage = RecPack[2]; - InCurrent = RecPack[3]; - UtilPowerIn = RecPack[4] + RecPack[5] * 256; - AppPowerIn = RecPack[6] + RecPack[7] * 256; - FatorPotEntrada = RecPack[8]; - InFreq = ( RecPack[9] + RecPack[10] * 256 ) * 1.0 / 10; - OutVoltage = RecPack[11]; - OutCurrent = RecPack[12]; - UtilPowerOut = RecPack[13] + RecPack[14] * 256; - AppPowerOut = RecPack[15] + RecPack[16] * 256; - FatorPotSaida = RecPack[17]; - OutFreq = ( RecPack[18] + RecPack[19] * 256 ) * 1.0 / 10; - BattVoltage = RecPack[20]; - BoostVolt = RecPack[21] + RecPack[22] * 256; - Temperature = ( 0x7F & RecPack[23] ); - Rendimento = RecPack[24]; + PowerFactor = 800; - /* model independent data */ - - if( ( BattVoltage < LimInfBattInv ) ) - CriticBatt = true; - - if( BypassOn ) - OutVoltage = ( InVoltage * 1.0 / 2 ) + 5; - - if( SourceFail && RedeAnterior ) /* falha pela primeira vez */ - OcorrenciaDeFalha = true; - - if( !( SourceFail ) && !( RedeAnterior ) ) /* retorno da rede */ - RetornoDaRede = true; - - if( !( SourceFail ) == RedeAnterior ) - { - RetornoDaRede = false; - OcorrenciaDeFalha = false; - } - - RedeAnterior = !( SourceFail ); - - LimInfSaida = 75; - LimSupSaida = 150; - ValorNominalSaida = 110; - - LimInfEntrada = 190; - LimSupEntrada = 250; - ValorNominalEntrada = 220; - - if( SourceFail ) - { - StatusEntrada = 2; - RecPack[8] = 200; /* ?????????????????????????????????? */ - } - else - { - StatusEntrada = 1; - RecPack[8] = 99; /* ??????????????????????????????????? */ - } - - if( OutputOn ) /* Output Status */ - StatusSaida = 2; - else - StatusSaida = 1; - - if( OverCharge ) - StatusSaida = 3; - - if( CriticBatt ) /* Battery Status */ - StatusBateria = 4; - else - StatusBateria = 1; - - EventosRede = 0; - - if( OcorrenciaDeFalha ) - EventosRede = 1; - - if( RetornoDaRede ) - EventosRede = 2; - - /* verify InversorOn */ - if( Flag_inversor ) - { - oldInversorOn = InputOn; - Flag_inversor = false; - } + if( RecPack[0] == 0xC2 ) + { + LimInfBattSrc = 174; + LimSupBattSrc = 192;/* 180????? carregador eh 180 (SCOPOS) */ + LimInfBattInv = 174; + LimSupBattInv = 192;/* 170????? (SCOPOS) */ + } + else + { + LimInfBattSrc = 138; + LimSupBattSrc = 162;/* 180????? carregador eh 180 (SCOPOS) */ + LimInfBattInv = 126; + LimSupBattInv = 156;/* 170????? (SCOPOS) */ + } - EventosSaida = 0; - if( InputOn && !( oldInversorOn ) ) - EventosSaida = 26; - if( oldInversorOn && !( InputOn ) ) - EventosSaida = 27; - oldInversorOn = InputOn; - if( SuperAquecimento && !( SuperAquecimentoAnterior ) ) - EventosSaida = 12; - if( SuperAquecimentoAnterior && !( SuperAquecimento ) ) - EventosSaida = 13; - SuperAquecimentoAnterior = SuperAquecimento; - EventosBateria = 0; - OldCritBatt = CriticBatt; + BattNonValue = 144; + /* VersaoInterna = "R10" + IntToStr( RecPack[1] ); */ + InVoltage = RecPack[2]; + InCurrent = RecPack[3]; + UtilPowerIn = RecPack[4] + RecPack[5] * 256; + AppPowerIn = RecPack[6] + RecPack[7] * 256; + FatorPotEntrada = RecPack[8]; + InFreq = ( RecPack[9] + RecPack[10] * 256 ) * 1.0 / 10; + OutVoltage = RecPack[11]; + OutCurrent = RecPack[12]; + UtilPowerOut = RecPack[13] + RecPack[14] * 256; + AppPowerOut = RecPack[15] + RecPack[16] * 256; + FatorPotSaida = RecPack[17]; + OutFreq = ( RecPack[18] + RecPack[19] * 256 ) * 1.0 / 10; + BattVoltage = RecPack[20]; + BoostVolt = RecPack[21] + RecPack[22] * 256; + Temperature = ( 0x7F & RecPack[23] ); + Rendimento = RecPack[24]; - if( OverCharge && !( OldOverCharge ) ) - EventosSaida = 10; - if( OldOverCharge && !( OverCharge ) ) - EventosSaida = 11; - OldOverCharge = OverCharge; + /* model independent data */ - /* autonomy calc. */ - if( RecPack[ 0 ] ==0xC2 ) - Autonomy = AutonomyCalc( 1 ); - else - Autonomy = AutonomyCalc( 0 ); + if( ( BattVoltage < LimInfBattInv ) ) + CriticBatt = true; + if( BypassOn ) + OutVoltage = ( InVoltage * 1.0 / 2 ) + 5; + + if( SourceFail && RedeAnterior ) /* falha pela primeira vez */ + OcorrenciaDeFalha = true; + + if( !( SourceFail ) && !( RedeAnterior ) ) /* retorno da rede */ + RetornoDaRede = true; + + if( RedeAnterior == !( SourceFail ) ) + { + RetornoDaRede = false; + OcorrenciaDeFalha = false; + } + + RedeAnterior = !( SourceFail ); + + LimInfSaida = 75; + LimSupSaida = 150; + ValorNominalSaida = 110; + + LimInfEntrada = 190; + LimSupEntrada = 250; + ValorNominalEntrada = 220; + + if( SourceFail ) + { + StatusEntrada = 2; + RecPack[8] = 200; /* ?????????????????????????????????? */ + } + else + { + StatusEntrada = 1; + RecPack[8] = 99; /* ??????????????????????????????????? */ + } + + if( OutputOn ) /* Output Status */ + StatusSaida = 2; + else + StatusSaida = 1; + + if( OverCharge ) + StatusSaida = 3; + + if( CriticBatt ) /* Battery Status */ + StatusBateria = 4; + else + StatusBateria = 1; + + EventosRede = 0; + + if( OcorrenciaDeFalha ) + EventosRede = 1; + + if( RetornoDaRede ) + EventosRede = 2; + + /* verify InversorOn */ + if( Flag_inversor ) + { + oldInversorOn = InputOn; + Flag_inversor = false; + } + + EventosSaida = 0; + if( InputOn && !( oldInversorOn ) ) + EventosSaida = 26; + if( oldInversorOn && !( InputOn ) ) + EventosSaida = 27; + oldInversorOn = InputOn; + if( SuperAquecimento && !( SuperAquecimentoAnterior ) ) + EventosSaida = 12; + if( SuperAquecimentoAnterior && !( SuperAquecimento ) ) + EventosSaida = 13; + SuperAquecimentoAnterior = SuperAquecimento; + EventosBateria = 0; + OldCritBatt = CriticBatt; + + if( OverCharge && !( OldOverCharge ) ) + EventosSaida = 10; + if( OldOverCharge && !( OverCharge ) ) + EventosSaida = 11; + OldOverCharge = OverCharge; + + /* autonomy calc. */ + if( RecPack[ 0 ] == 0xC2 ) + Autonomy = AutonomyCalc( 1 ); + else + Autonomy = AutonomyCalc( 0 ); } static void -CommReceive(const unsigned char *bufptr, int size) +CommReceive(const unsigned char *bufptr, ssize_t size) { + int i, i_end, CheckSum, chk; - int i, i_end, CheckSum, chk; - - if( ( size==37 ) ) - Waiting = 0; - - printf("CommReceive size = %d waiting = %d\n", size, Waiting ); + if( size == 37 ) + Waiting = 0; - switch( Waiting ) - { - /* normal package */ - case 0: - { - if( size == 37 ) - { - i_end = 37; - for( i = 0 ; i < i_end ; ++i ) - { - RecPack[i] = *bufptr; - bufptr++; - } - - /* CheckSum verify */ - CheckSum = 0; - i_end = 36; - for( i = 0 ; i < i_end ; ++i ) - { - chk = RecPack[ i ]; - CheckSum = CheckSum + chk; - } + printf("CommReceive size = %zd waiting = %d\n", size, Waiting ); - CheckSum = CheckSum % 256; + switch( Waiting ) + { + /* normal package */ + case 0: + { + if( size == 37 ) + { + i_end = 37; + for( i = 0 ; i < i_end ; ++i ) + { + RecPack[i] = *bufptr; + bufptr++; + } - ser_flush_in(upsfd,"",0); /* clean port */ + /* CheckSum verify */ + CheckSum = 0; + i_end = 36; + for( i = 0 ; i < i_end ; ++i ) + { + chk = RecPack[ i ]; + CheckSum = CheckSum + chk; + } - /* correct package */ - if( ( RecPack[0] == 0xC0 || RecPack[0] == 0xC1 || RecPack[0] == 0xC2 || RecPack[0] == 0xC3 ) - && ( RecPack[ 36 ] == CheckSum ) ) - { + CheckSum = CheckSum % 256; - if(!(detected)) - { - RhinoModel = RecPack[0]; - detected = true; - } + ser_flush_in(upsfd,"",0); /* clean port */ - switch( RhinoModel ) - { - case 0xC0: - case 0xC1: - case 0xC2: - case 0xC3: - { - ScanReceivePack(); - break; - } - default: - { - printf( M_UNKN ); - break; - } - } - } + /* correct package */ + if( ( RecPack[0] == 0xC0 || RecPack[0] == 0xC1 || RecPack[0] == 0xC2 || RecPack[0] == 0xC3 ) + && ( RecPack[ 36 ] == CheckSum ) ) + { - } - - break; - } - - case 1: - { - /* dumping package, nothing to do yet */ - Waiting = 0; - break; - } + if(!(detected)) + { + RhinoModel = RecPack[0]; + detected = true; + } - } + switch( RhinoModel ) + { + case 0xC0: + case 0xC1: + case 0xC2: + case 0xC3: + { + ScanReceivePack(); + break; + } + default: + { + printf( M_UNKN ); + break; + } + } + } + } - Waiting =0; + break; + } + case 1: + { + /* dumping package, nothing to do yet */ + Waiting = 0; + break; + } + + } + + Waiting = 0; } -static int -send_command( int cmd ) +static ssize_t +send_command( unsigned char cmd ) { + static const size_t sizes = 19, iend = 18; + size_t i, kount; /*, j, uc; */ + unsigned char chk, checksum = 0; + ssize_t ret = -1; + unsigned char ch, *psend = NULL; - int i, chk, checksum = 0, iend = 18, sizes = 19, ret, kount; /*, j, uc; */ - unsigned char ch, psend[sizes]; - - /* mounting buffer to send */ + if ( !(psend = xmalloc(sizeof(char) * sizes)) ) { + upslogx(LOG_ERR, "send_command() failed to allocate buffer"); + return -1; + } + + /* mounting buffer to send */ for(i = 0; i < iend; i++ ) { @@ -488,7 +490,7 @@ send_command( int cmd ) chk = 0x01; else { - if( i == 1) + if( i == 1 ) chk = cmd; else chk = 0x00; /* 0x20; */ @@ -496,12 +498,12 @@ send_command( int cmd ) ch = chk; psend[i] = ch; /* psend[0 - 17] */ - if( i > 0 ) /* psend[0] not computed */ + if( i > 0 ) /* psend[0] not computed */ checksum = checksum + chk; } ch = checksum; - ch = (~( ch) ); /* not ch */ + ch = (~( ch) ); /* not ch */ psend[iend] = ch; /* send five times the command */ @@ -518,98 +520,101 @@ send_command( int cmd ) usleep( UPSDELAY ); /* delay between sent command */ kount++; } + + free (psend); return ret; } static void sendshut( void ) { - int i; for(i=0; i < 30000; i++) - usleep( UPSDELAY ); /* 15 seconds delay */ + usleep( UPSDELAY ); /* 15 seconds delay */ - send_command( CMD_SHUT ); - upslogx(LOG_NOTICE, "Ups shutdown command sent"); + if ( send_command( CMD_SHUT ) < 1 ) + upslogx(LOG_ERR, "Ups shutdown command sending failed"); + else + upslogx(LOG_NOTICE, "Ups shutdown command sent"); printf("Ups shutdown command sent\n"); - } static void getbaseinfo(void) { - unsigned char temp[256]; + unsigned char temp[256]; unsigned char Pacote[37]; - int tam, i, j=0; + ssize_t tam, i, j=0; time_t tmt; struct tm *now; + struct tm tmbuf; const char *Model; time( &tmt ); - now = localtime( &tmt ); + now = localtime_r( &tmt, &tmbuf ); dian = now->tm_mday; mesn = now->tm_mon+1; anon = now->tm_year+1900; - weekn = now->tm_wday; + weekn = now->tm_wday; /* trying detect rhino model */ while ( ( !detected ) && ( j < 10 ) ) - { + { - temp[0] = 0; /* flush temp buffer */ - tam = ser_get_buf_len(upsfd, temp, pacsize, 3, 0); - if( tam == 37 ) - { - for( i = 0 ; i < tam ; i++ ) - { - Pacote[i] = temp[i]; - } - } + temp[0] = 0; /* flush temp buffer */ + tam = ser_get_buf_len(upsfd, temp, pacsize, 3, 0); + if( tam == 37 ) + { + for( i = 0 ; i < tam ; i++ ) + { + Pacote[i] = temp[i]; + } + } - j++; - if( tam == 37) - CommReceive(Pacote, tam); - else - CommReceive(temp, tam); - } + j++; + if( tam == 37) + CommReceive(Pacote, tam); + else + CommReceive(temp, tam); + } if( (!detected) ) - { - fatalx(EXIT_FAILURE, NO_RHINO ); - } + { + fatalx(EXIT_FAILURE, NO_RHINO ); + } switch( RhinoModel ) - { - case 0xC0: - { - Model = "Rhino 20.0 kVA"; - PotenciaNominal = 20000; - break; - } - case 0xC1: - { - Model = "Rhino 10.0 kVA"; - PotenciaNominal = 10000; - break; - } - case 0xC2: - { - Model = "Rhino 6.0 kVA"; - PotenciaNominal = 6000; - break; - } - case 0xC3: - { - Model = "Rhino 7.5 kVA"; - PotenciaNominal = 7500; - break; - } - default: - { - Model = "Rhino unknown model"; - PotenciaNominal = 0; - break; - } - } + { + case 0xC0: + { + Model = "Rhino 20.0 kVA"; + PotenciaNominal = 20000; + break; + } + case 0xC1: + { + Model = "Rhino 10.0 kVA"; + PotenciaNominal = 10000; + break; + } + case 0xC2: + { + Model = "Rhino 6.0 kVA"; + PotenciaNominal = 6000; + break; + } + case 0xC3: + { + Model = "Rhino 7.5 kVA"; + PotenciaNominal = 7500; + break; + } + default: + { + Model = "Rhino unknown model"; + PotenciaNominal = 0; + break; + } + } /* manufacturer and model */ dstate_setinfo("ups.mfr", "%s", "Microsol"); @@ -629,13 +634,12 @@ static void getbaseinfo(void) dstate_addcmd("bypass.stop"); /* CMD_PASSOFF = 6 */ printf("Detected %s on %s\n", dstate_getinfo("ups.model"), device_path); - } static void getupdateinfo(void) { - unsigned char temp[256]; - int tam; + unsigned char temp[256]; + ssize_t tam; temp[0] = 0; /* flush temp buffer */ tam = ser_get_buf_len(upsfd, temp, pacsize, 3, 0); @@ -646,57 +650,54 @@ static void getupdateinfo(void) static int instcmd(const char *cmdname, const char *extra) { + ssize_t ret = 0; - int ret = 0; - if (!strcasecmp(cmdname, "shutdown.stayoff")) - { - /* shutdown now (one way) */ - /* send_command( CMD_SHUT ); */ - sendshut(); - return STAT_INSTCMD_HANDLED; - } + { + /* shutdown now (one way) */ + /* send_command( CMD_SHUT ); */ + sendshut(); + return STAT_INSTCMD_HANDLED; + } if (!strcasecmp(cmdname, "load.on")) - { - /* liga Saida */ - ret = send_command( 3 ); - if ( ret < 1 ) - upslogx(LOG_ERR, "send_command 3 failed"); - return STAT_INSTCMD_HANDLED; - } + { + /* liga Saida */ + ret = send_command( 3 ); + if ( ret < 1 ) + upslogx(LOG_ERR, "send_command 3 failed"); + return STAT_INSTCMD_HANDLED; + } if (!strcasecmp(cmdname, "load.off")) - { - /* desliga Saida */ - ret = send_command( 4 ); - if ( ret < 1 ) - upslogx(LOG_ERR, "send_command 4 failed"); - return STAT_INSTCMD_HANDLED; - } + { + /* desliga Saida */ + ret = send_command( 4 ); + if ( ret < 1 ) + upslogx(LOG_ERR, "send_command 4 failed"); + return STAT_INSTCMD_HANDLED; + } if (!strcasecmp(cmdname, "bypass.start")) - { - /* liga Bypass */ - ret = send_command( 5 ); - if ( ret < 1 ) - upslogx(LOG_ERR, "send_command 5 failed"); - return STAT_INSTCMD_HANDLED; - } + { + /* liga Bypass */ + ret = send_command( 5 ); + if ( ret < 1 ) + upslogx(LOG_ERR, "send_command 5 failed"); + return STAT_INSTCMD_HANDLED; + } if (!strcasecmp(cmdname, "bypass.stop")) - { - /* desliga Bypass */ - ret = send_command( 6 ); - if ( ret < 1 ) - upslogx(LOG_ERR, "send_command 6 failed"); - return STAT_INSTCMD_HANDLED; - } + { + /* desliga Bypass */ + ret = send_command( 6 ); + if ( ret < 1 ) + upslogx(LOG_ERR, "send_command 6 failed"); + return STAT_INSTCMD_HANDLED; + } - - upslogx(LOG_NOTICE, "instcmd: unknown command [%s]", cmdname); + upslogx(LOG_NOTICE, "instcmd: unknown command [%s] [%s]", cmdname, extra); return STAT_INSTCMD_UNKNOWN; - } void upsdrv_initinfo(void) @@ -708,8 +709,7 @@ void upsdrv_initinfo(void) void upsdrv_updateinfo(void) { - - getupdateinfo(); /* new package for updates */ + getupdateinfo(); /* new package for updates */ dstate_setinfo("output.voltage", "%03.1f", OutVoltage); dstate_setinfo("input.voltage", "%03.1f", InVoltage); @@ -717,51 +717,51 @@ void upsdrv_updateinfo(void) /* output and bypass tests */ if( OutputOn ) - dstate_setinfo("outlet.switchable", "%s", "yes"); + dstate_setinfo("outlet.switchable", "%s", "yes"); else - dstate_setinfo("outlet.switchable", "%s", "no"); + dstate_setinfo("outlet.switchable", "%s", "no"); if( BypassOn ) - dstate_setinfo("outlet.1.switchable", "%s", "yes"); + dstate_setinfo("outlet.1.switchable", "%s", "yes"); else - dstate_setinfo("outlet.1.switchable", "%s", "no"); + dstate_setinfo("outlet.1.switchable", "%s", "no"); status_init(); if (!SourceFail ) - status_set("OL"); /* on line */ + status_set("OL"); /* on line */ else - status_set("OB"); /* on battery */ - + status_set("OB"); /* on battery */ + if (Autonomy < 5 ) - status_set("LB"); /* low battery */ - + status_set("LB"); /* low battery */ + status_commit(); dstate_setinfo("ups.temperature", "%2.2f", Temperature); dstate_setinfo("input.frequency", "%2.1f", InFreq); dstate_dataok(); - } /* power down the attached load immediately */ void upsdrv_shutdown(void) { - /* basic idea: find out line status and send appropriate command */ /* on line: send normal shutdown, ups will return by itself on utility */ /* on battery: send shutdown+return, ups will cycle and return soon */ if (!SourceFail) /* on line */ - { - printf("On line, forcing shutdown command...\n"); - send_command( CMD_SHUT ); - } + { + /* FIXME: Both legs of the if-clause send CMD_SHUT, where is the "forcing"? */ + printf("On line, forcing shutdown command...\n"); + /* send_command( CMD_SHUT ); */ + sendshut(); + } else - { - printf("On battery, sending normal shutdown command...\n"); - send_command( CMD_SHUT ); - } - + { + printf("On battery, sending normal shutdown command...\n"); + /* send_command( CMD_SHUT ); */ + sendshut(); + } } void upsdrv_help(void) @@ -770,9 +770,7 @@ void upsdrv_help(void) void upsdrv_makevartable(void) { - addvar(VAR_VALUE, "battext", "Battery Extension (0-80)min"); - } void upsdrv_initups(void) @@ -783,7 +781,6 @@ void upsdrv_initups(void) /* dtr and rts setting */ ser_set_dtr(upsfd, 1); ser_set_rts(upsfd, 0); - } void upsdrv_cleanup(void) diff --git a/drivers/richcomm_usb.c b/drivers/richcomm_usb.c index 0b9b8f2..f8da32e 100644 --- a/drivers/richcomm_usb.c +++ b/drivers/richcomm_usb.c @@ -6,6 +6,7 @@ * * Copyright (C) 2007 Peter van Valderen * Dirk Teurlings + * Copyright (C) 2016 Eaton * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,10 +25,11 @@ #include "main.h" #include "usb-common.h" +#include "nut_stdint.h" /* driver version */ #define DRIVER_NAME "Richcomm dry-contact to USB driver" -#define DRIVER_VERSION "0.04" +#define DRIVER_VERSION "0.10" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -55,8 +57,8 @@ static usb_device_id_t richcomm_usb_id[] = { /* Sweex 1000VA */ { USB_DEVICE(0x0925, 0x1234), NULL }, - /* end of list */ - {-1, -1, NULL} + /* Terminating entry */ + { 0, 0, NULL } }; static usb_dev_handle *udev = NULL; @@ -65,6 +67,8 @@ static unsigned int comm_failures = 0; static int device_match_func(USBDevice_t *device, void *privdata) { + NUT_UNUSED_VARIABLE(privdata); + switch (is_usb_device_supported(richcomm_usb_id, device)) { case SUPPORTED: @@ -83,30 +87,79 @@ static USBDeviceMatcher_t device_matcher = { NULL }; +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC) ) +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC +# pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif static int execute_and_retrieve_query(char *query, char *reply) { int ret; ret = usb_control_msg(udev, STATUS_REQUESTTYPE, REQUEST_VALUE, - MESSAGE_VALUE, INDEX_VALUE, query, QUERY_PACKETSIZE, 1000); + MESSAGE_VALUE, INDEX_VALUE, + (usb_ctrl_charbuf)query, QUERY_PACKETSIZE, 1000); if (ret <= 0) { - upsdebugx(3, "send: %s", ret ? usb_strerror() : "timeout"); + upsdebugx(3, "send: %s", + ret ? nut_usb_strerror(ret) : "timeout"); return ret; } - upsdebug_hex(3, "send", query, ret); +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) ) +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE +# pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif + /* Cast up within the signed/unsigned same type */ + if ((unsigned int)ret >= SIZE_MAX) { +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) ) +# pragma GCC diagnostic pop +#endif + upsdebugx(3, "send: ret=%d exceeds SIZE_MAX", ret); + } + upsdebug_hex(3, "send", query, (size_t)ret); - ret = usb_interrupt_read(udev, REPLY_REQUESTTYPE, reply, REPLY_PACKETSIZE, 1000); + ret = usb_interrupt_read(udev, + REPLY_REQUESTTYPE, + (usb_ctrl_charbuf)reply, REPLY_PACKETSIZE, 1000); if (ret <= 0) { - upsdebugx(3, "read: %s", ret ? usb_strerror() : "timeout"); + upsdebugx(3, "read: %s", + ret ? nut_usb_strerror(ret) : "timeout"); return ret; } - upsdebug_hex(3, "read", reply, ret); +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) ) +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE +# pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif + /* Cast up within the signed/unsigned same type */ + if ((unsigned int)ret >= SIZE_MAX) { +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) ) +# pragma GCC diagnostic pop +#endif + upsdebugx(3, "read: ret=%d exceeds SIZE_MAX", ret); + } + upsdebug_hex(3, "read", reply, (size_t)ret); return ret; } +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC) ) +# pragma GCC diagnostic pop +#endif static int query_ups(char *reply) { @@ -147,7 +200,19 @@ static void usb_comm_fail(const char *fmt, ...) } va_start(ap, fmt); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif ret = vsnprintf(why, sizeof(why), fmt, ap); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif va_end(ap); if ((ret < 1) || (ret >= (int) sizeof(why))) { @@ -163,7 +228,7 @@ static void usb_comm_good(void) return; } - upslogx(LOG_NOTICE, "Communications with UPS re-established"); + upslogx(LOG_NOTICE, "Communications with UPS re-established"); comm_failures = 0; } @@ -176,6 +241,8 @@ static void usb_comm_good(void) */ static int driver_callback(usb_dev_handle *handle, USBDevice_t *device) { + NUT_UNUSED_VARIABLE(device); + if (usb_set_configuration(handle, 1) < 0) { upsdebugx(5, "Can't set USB configuration"); return -1; @@ -186,10 +253,19 @@ static int driver_callback(usb_dev_handle *handle, USBDevice_t *device) return -1; } +#if WITH_LIBUSB_0_1 if (usb_set_altinterface(handle, 0) < 0) { upsdebugx(5, "Can't set USB alternate interface"); return -1; } +#elif WITH_LIBUSB_1_0 + int ret = 0; + + if ((ret = libusb_set_interface_alt_setting(handle, 0, 0)) < 0) { + upsdebugx(5, "Can't set USB alternate interface: %s", nut_usb_strerror(ret)); + return -1; + } +#endif /* WITH_LIBUSB_1_0 */ if (usb_clear_halt(handle, 0x81) < 0) { upsdebugx(5, "Can't reset USB endpoint"); @@ -201,31 +277,73 @@ static int driver_callback(usb_dev_handle *handle, USBDevice_t *device) static int usb_device_close(usb_dev_handle *handle) { + int ret = 0; + if (!handle) { return 0; } /* usb_release_interface() sometimes blocks and goes - into uninterruptible sleep. So don't do it. */ + * into uninterruptible sleep. So don't do it. + */ /* usb_release_interface(handle, 0); */ - return usb_close(handle); + +#if WITH_LIBUSB_1_0 + libusb_close(handle); + libusb_exit(NULL); +#else + ret = usb_close(handle); +#endif + + return ret; } static int usb_device_open(usb_dev_handle **handlep, USBDevice_t *device, USBDeviceMatcher_t *matcher, int (*callback)(usb_dev_handle *handle, USBDevice_t *device)) { - struct usb_bus *bus; + int ret = 0; + uint8_t iManufacturer = 0, iProduct = 0, iSerialNumber = 0; /* libusb base init */ +#if WITH_LIBUSB_1_0 + if (libusb_init(NULL) < 0) { + libusb_exit(NULL); + fatal_with_errno(EXIT_FAILURE, "Failed to init libusb 1.0"); + } +#else /* => WITH_LIBUSB_0_1 */ usb_init(); usb_find_busses(); usb_find_devices(); +#endif /* WITH_LIBUSB_1_0 */ #ifndef __linux__ /* SUN_LIBUSB (confirmed to work on Solaris and FreeBSD) */ /* Causes a double free corruption in linux if device is detached! */ - usb_device_close(*handlep); + /* usb_device_close(*handlep); */ + if (*handlep) + usb_close(*handlep); #endif +#if WITH_LIBUSB_1_0 + libusb_device **devlist; + ssize_t devcount = 0; + libusb_device_handle *handle; + struct libusb_device_descriptor dev_desc; + uint8_t bus; + int i; + + devcount = libusb_get_device_list(NULL, &devlist); + if (devcount <= 0) + fatal_with_errno(EXIT_FAILURE, "No USB device found"); + + for (i = 0; i < devcount; i++) { + + USBDeviceMatcher_t *m; + libusb_device *dev = devlist[i]; + libusb_get_device_descriptor(dev, &dev_desc); + ret = libusb_open(dev, &handle); + *handlep = handle; +#else /* => WITH_LIBUSB_0_1 */ + struct usb_bus *bus; for (bus = usb_busses; bus; bus = bus->next) { struct usb_device *dev; @@ -233,18 +351,22 @@ static int usb_device_open(usb_dev_handle **handlep, USBDevice_t *device, USBDev for (dev = bus->devices; dev; dev = dev->next) { - int i, ret; + int i; USBDeviceMatcher_t *m; - upsdebugx(4, "Checking USB device [%04x:%04x] (%s/%s)", dev->descriptor.idVendor, - dev->descriptor.idProduct, bus->dirname, dev->filename); - + upsdebugx(3, "Checking USB device [%04x:%04x] (%s/%s)", + dev->descriptor.idVendor, + dev->descriptor.idProduct, + bus->dirname, dev->filename); + /* supported vendors are now checked by the supplied matcher */ /* open the device */ *handlep = handle = usb_open(dev); +#endif /* WITH_LIBUSB_1_0 */ + if (!handle) { - upsdebugx(4, "Failed to open USB device, skipping: %s", usb_strerror()); + upsdebugx(4, "Failed to open USB device, skipping: %s", nut_usb_strerror(ret)); continue; } @@ -261,34 +383,70 @@ static int usb_device_open(usb_dev_handle **handlep, USBDevice_t *device, USBDev memset(device, 0, sizeof(*device)); +#if WITH_LIBUSB_1_0 + device->VendorID = dev_desc.idVendor; + device->ProductID = dev_desc.idProduct; + bus = libusb_get_bus_number(dev); + device->Bus = (char *)malloc(4); + if (device->Bus == NULL) { + libusb_free_device_list(devlist, 1); + fatal_with_errno(EXIT_FAILURE, "Out of memory"); + } + sprintf(device->Bus, "%03d", bus); + iManufacturer = dev_desc.iManufacturer; + iProduct = dev_desc.iProduct; + iSerialNumber = dev_desc.iSerialNumber; +#else /* => WITH_LIBUSB_0_1 */ device->VendorID = dev->descriptor.idVendor; device->ProductID = dev->descriptor.idProduct; - device->Bus = strdup(bus->dirname); - - if (dev->descriptor.iManufacturer) { + device->Bus = xstrdup(bus->dirname); + iManufacturer = dev->descriptor.iManufacturer; + iProduct = dev->descriptor.iProduct; + iSerialNumber = dev->descriptor.iSerialNumber; +#endif /* WITH_LIBUSB_1_0 */ + + if (iManufacturer) { char buf[SMALLBUF]; - ret = usb_get_string_simple(handle, dev->descriptor.iManufacturer, - buf, sizeof(buf)); + ret = usb_get_string_simple(handle, iManufacturer, + (usb_ctrl_charbuf)buf, sizeof(buf)); if (ret > 0) { device->Vendor = strdup(buf); + if (device->Vendor == NULL) { +#if WITH_LIBUSB_1_0 + libusb_free_device_list(devlist, 1); +#endif /* WITH_LIBUSB_1_0 */ + fatal_with_errno(EXIT_FAILURE, "Out of memory"); + } } } - if (dev->descriptor.iProduct) { + if (iProduct) { char buf[SMALLBUF]; - ret = usb_get_string_simple(handle, dev->descriptor.iProduct, - buf, sizeof(buf)); + ret = usb_get_string_simple(handle, iProduct, + (usb_ctrl_charbuf)buf, sizeof(buf)); if (ret > 0) { device->Product = strdup(buf); + if (device->Product == NULL) { +#if WITH_LIBUSB_1_0 + libusb_free_device_list(devlist, 1); +#endif /* WITH_LIBUSB_1_0 */ + fatal_with_errno(EXIT_FAILURE, "Out of memory"); + } } } - if (dev->descriptor.iSerialNumber) { + if (iSerialNumber) { char buf[SMALLBUF]; - ret = usb_get_string_simple(handle, dev->descriptor.iSerialNumber, - buf, sizeof(buf)); + ret = usb_get_string_simple(handle, iSerialNumber, + (usb_ctrl_charbuf)buf, sizeof(buf)); if (ret > 0) { device->Serial = strdup(buf); + if (device->Serial == NULL) { +#if WITH_LIBUSB_1_0 + libusb_free_device_list(devlist, 1); +#endif /* WITH_LIBUSB_1_0 */ + fatal_with_errno(EXIT_FAILURE, "Out of memory"); + } } } @@ -300,49 +458,106 @@ static int usb_device_open(usb_dev_handle **handlep, USBDevice_t *device, USBDev upsdebugx(4, "- Bus : %s", device->Bus ? device->Bus : "unknown"); for (m = matcher; m; m = m->next) { - + switch (m->match_function(device, m->privdata)) { case 0: upsdebugx(4, "Device does not match - skipping"); goto next_device; case -1: +#if WITH_LIBUSB_1_0 + libusb_free_device_list(devlist, 1); +#endif /* WITH_LIBUSB_1_0 */ fatal_with_errno(EXIT_FAILURE, "matcher"); +#ifndef HAVE___ATTRIBUTE__NORETURN +# if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunreachable-code" +# endif goto next_device; +# if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) +# pragma GCC diagnostic pop +# endif +#endif case -2: upsdebugx(4, "matcher: unspecified error"); goto next_device; } } +#ifdef HAVE_LIBUSB_SET_AUTO_DETACH_KERNEL_DRIVER + /* First, try the auto-detach kernel driver method + * This function is not available on FreeBSD 10.1-10.3 */ + if ((ret = libusb_set_auto_detach_kernel_driver(handle, 1)) < 0) + upsdebugx(2, + "failed to auto detach kernel driver from USB device: %s", + nut_usb_strerror((enum libusb_error)ret)); + else + upsdebugx(2, "auto detached kernel driver from USB device"); +#endif /* HAVE_LIBUSB_SET_AUTO_DETACH_KERNEL_DRIVER */ for (i = 0; i < 3; i++) { ret = callback(handle, device); if (ret >= 0) { - upsdebugx(4, "USB device [%04x:%04x] opened", device->VendorID, device->ProductID); + upsdebugx(4, "USB device [%04x:%04x] opened", + device->VendorID, device->ProductID); +#if WITH_LIBUSB_1_0 + libusb_free_device_list(devlist, 1); +#endif /* WITH_LIBUSB_1_0 */ return ret; } -#ifdef HAVE_USB_DETACH_KERNEL_DRIVER_NP +#if WITH_LIBUSB_0_1 && (defined HAVE_USB_DETACH_KERNEL_DRIVER_NP) /* this method requires at least libusb 0.1.8: * it force device claiming by unbinding * attached driver... From libhid */ - if (usb_detach_kernel_driver_np(handle, 0) < 0) { - upsdebugx(4, "failed to detach kernel driver from USB device: %s", usb_strerror()); + if ((ret = usb_detach_kernel_driver_np(handle, 0)) < 0) { + upsdebugx(4, + "failed to detach kernel driver from USB device: %s", + nut_usb_strerror(ret)); } else { upsdebugx(4, "detached kernel driver from USB device..."); } -#endif +#else +# ifdef HAVE_LIBUSB_DETACH_KERNEL_DRIVER + if ((ret = libusb_detach_kernel_driver(handle, 0)) < 0) { + upsdebugx(4, + "failed to detach kernel driver from USB device: %s", + nut_usb_strerror(ret)); + } else { + upsdebugx(4, "detached kernel driver from USB device..."); + } +# else +# ifdef HAVE_LIBUSB_DETACH_KERNEL_DRIVER_NP + if ((ret = libusb_detach_kernel_driver_np(udev, 0)) < 0) { + upsdebugx(4, + "failed to detach kernel driver from USB device: %s", + nut_usb_strerror(ret)); + } else { + upsdebugx(4, "detached kernel driver from USB device..."); + } +# endif /* HAVE_LIBUSB_DETACH_KERNEL_DRIVER_NP */ +# endif /* HAVE_LIBUSB_DETACH_KERNEL_DRIVER */ +#endif /* HAVE_USB_DETACH_KERNEL_DRIVER_NP or HAVE_LIBUSB_DETACH_KERNEL_DRIVER or HAVE_LIBUSB_DETACH_KERNEL_DRIVER_NP */ } - fatalx(EXIT_FAILURE, "USB device [%04x:%04x] matches, but driver callback failed: %s", - device->VendorID, device->ProductID, usb_strerror()); +#if WITH_LIBUSB_1_0 + libusb_free_device_list(devlist, 1); +#endif /* WITH_LIBUSB_1_0 */ + fatalx(EXIT_FAILURE, + "USB device [%04x:%04x] matches, but driver callback failed: %s", + device->VendorID, device->ProductID, nut_usb_strerror(ret)); next_device: usb_close(handle); +#if (!WITH_LIBUSB_1_0) /* => WITH_LIBUSB_0_1 */ } +#endif /* WITH_LIBUSB_1_0 */ } *handlep = NULL; +#if WITH_LIBUSB_1_0 + libusb_free_device_list(devlist, 1); +#endif /* WITH_LIBUSB_1_0 */ upsdebugx(4, "No matching USB device found"); return -1; @@ -356,6 +571,8 @@ void upsdrv_initups(void) char reply[REPLY_PACKETSIZE]; int i; + warn_if_bad_usb_port_filename(device_path); + for (i = 0; usb_device_open(&udev, &usbdevice, &device_matcher, &driver_callback) < 0; i++) { if ((i < 32) && (sleep(5) == 0)) { diff --git a/drivers/riello.c b/drivers/riello.c index 0725453..8671225 100644 --- a/drivers/riello.c +++ b/drivers/riello.c @@ -22,8 +22,8 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Reference of the derivative work: blazer driver + * + * Reference of the derivative work: blazer driver */ #include @@ -32,7 +32,7 @@ #include "main.h" #include "riello.h" -uint8_t foundheader=0; +static uint8_t foundheader = 0; uint16_t buf_ptr_length; uint8_t wait_packet = 0; @@ -42,11 +42,11 @@ uint8_t foundbadcrc = 0; uint8_t commbyte; uint8_t requestSENTR; -unsigned char LAST_DATA[6]; +static unsigned char LAST_DATA[6]; uint16_t riello_calc_CRC(uint8_t type, uint8_t *buff, uint16_t size, uint8_t checksum) { - uint8_t i; + uint16_t i; uint16_t pom, CRC_Word; CRC_Word = 0; @@ -58,7 +58,7 @@ uint16_t riello_calc_CRC(uint8_t type, uint8_t *buff, uint16_t size, uint8_t che CRC_Word += buff[i]; } else { - for (i=0; i> 4); + pom = (CRC_Word ^ *buff) & 0x00ff; + pom = (pom ^ (pom << 4)) & 0x00ff; + /* Thanks to &0xff above, pom is at most 255 -- + * so shifted by 8 bits is still uint16_t range + */ + pom = (uint16_t)(pom << 8); + pom ^= (pom << 3); + pom ^= (pom >> 4); CRC_Word = (CRC_Word >> 8) ^ pom; buff++; } - } + } else { CRC_Word = 0; - for (i=1; iIdentif_bytes[0] != '1') pom_long/=100; - data->NomPowerKVA = pom_long; + assert (pom_long < UINT16_MAX); + data->NomPowerKVA = (uint16_t)pom_long; pom_long = (buffer[j++]-0x30)*65536; pom_long += (buffer[j++]-0x30)*4096; @@ -462,7 +468,8 @@ void riello_parse_gn(uint8_t* buffer, TRielloData* data) if (data->Identif_bytes[0] != '1') pom_long/=100; - data->NomPowerKW = pom_long; + assert (pom_long < UINT16_MAX); + data->NomPowerKW = (uint16_t)pom_long; pom_word = (buffer[j++]-0x30)*256; pom_word += (buffer[j++]-0x30)*16; @@ -564,7 +571,7 @@ void riello_parse_rs(uint8_t* buffer, TRielloData* data, uint8_t numread) pom_word += (buffer[j++]-0x30)*16; pom_word += (buffer[j++]-0x30); data->Uinp3 = pom_word; - } + } else { data->Uinp2 = 0; data->Uinp3 = 0; @@ -593,7 +600,7 @@ void riello_parse_rs(uint8_t* buffer, TRielloData* data, uint8_t numread) pom_word += (buffer[j++]-0x30)*16; pom_word += (buffer[j++]-0x30); data->Ubypass3 = pom_word; - } + } else { data->Uout2 = 0; data->Pout2 = 0; @@ -638,42 +645,42 @@ void riello_parse_re(uint8_t* buffer, TRielloData* data) pom_long += (buffer[j++]-0x30)*256; pom_long += (buffer[j++]-0x30)*16; pom_long += (buffer[j++]-0x30); - data->Pout1W = pom_word; + data->Pout1W = pom_long; pom_long = (buffer[j++]-0x30)*65536; pom_long += (buffer[j++]-0x30)*4096; pom_long += (buffer[j++]-0x30)*256; pom_long += (buffer[j++]-0x30)*16; pom_long += (buffer[j++]-0x30); - data->Pout2W = pom_word; + data->Pout2W = pom_long; pom_long = (buffer[j++]-0x30)*65536; pom_long += (buffer[j++]-0x30)*4096; pom_long += (buffer[j++]-0x30)*256; pom_long += (buffer[j++]-0x30)*16; pom_long += (buffer[j++]-0x30); - data->Pout3W = pom_word; + data->Pout3W = pom_long; pom_long = (buffer[j++]-0x30)*65536; pom_long += (buffer[j++]-0x30)*4096; pom_long += (buffer[j++]-0x30)*256; pom_long += (buffer[j++]-0x30)*16; pom_long += (buffer[j++]-0x30); - data->Pout1VA = pom_word; + data->Pout1VA = pom_long; pom_long = (buffer[j++]-0x30)*65536; pom_long += (buffer[j++]-0x30)*4096; pom_long += (buffer[j++]-0x30)*256; pom_long += (buffer[j++]-0x30)*16; pom_long += (buffer[j++]-0x30); - data->Pout2VA = pom_word; + data->Pout2VA = pom_long; pom_long = (buffer[j++]-0x30)*65536; pom_long += (buffer[j++]-0x30)*4096; pom_long += (buffer[j++]-0x30)*256; pom_long += (buffer[j++]-0x30)*16; pom_long += (buffer[j++]-0x30); - data->Pout3VA = pom_word; + data->Pout3VA = pom_long; } void riello_parse_rc(uint8_t* buffer, TRielloData* data) @@ -682,7 +689,7 @@ void riello_parse_rc(uint8_t* buffer, TRielloData* data) j = 7; for (i = 0; i < 22; i++, j+=2) { - data->StatusCodeT[i] = (buffer[j+1]-0x30); + data->StatusCodeT[i] = (char)(buffer[j+1]-0x30); data->StatusCodeT[i] |= ((buffer[j]-0x30) << 4); } data->StatusCodeT[23] = 0; @@ -704,7 +711,7 @@ void riello_parse_sentr(uint8_t* buffer, TRielloData* data) else requestSENTR = SENTR_ONLY192; data->NomPowerKVA = data->Model/10; - } + } else { if (((data->Model-3000) % 10) >= 4) { if (buffer[100] & 0x01) @@ -733,11 +740,11 @@ void riello_parse_sentr(uint8_t* buffer, TRielloData* data) data->SWversion = buffer[4]+256*buffer[5]; - data->Version[0] = (uint8_t)(48 + ((data->SWversion / 1000) % 10)); - data->Version[1] = (uint8_t)(48 + ((data->SWversion / 100) % 10)); + data->Version[0] = (char)(uint8_t)(48 + ((data->SWversion / 1000) % 10)); + data->Version[1] = (char)(uint8_t)(48 + ((data->SWversion / 100) % 10)); data->Version[2] = '.'; - data->Version[3] = (uint8_t)(48 + ((data->SWversion / 10) % 10)); - data->Version[4] = (uint8_t)(48 + (data->SWversion % 10)); + data->Version[3] = (char)(uint8_t)(48 + ((data->SWversion / 10) % 10)); + data->Version[4] = (char)(uint8_t)(48 + (data->SWversion % 10)); if (data->Model < 3000) pom = data->Model*100; @@ -756,7 +763,7 @@ void riello_parse_sentr(uint8_t* buffer, TRielloData* data) data->Uout1 = (buffer[135]+buffer[136]*256)/10; data->Uout2 = (buffer[137]+buffer[138]*256)/10; data->Uout3 = (buffer[139]+buffer[140]*256)/10; - data->Iout1 = (buffer[141]+buffer[142]*256)/10; + data->Iout1 = (buffer[141]+buffer[142]*256)/10; data->Iout2 = (buffer[143]+buffer[144]*256)/10; data->Iout3 = (buffer[145]+buffer[146]*256)/10; @@ -769,9 +776,10 @@ void riello_parse_sentr(uint8_t* buffer, TRielloData* data) data->Uinp1 = buffer[35]*230/100; data->Uinp2 = buffer[36]*230/100; data->Uinp3 = buffer[37]*230/100; - data->Iinp1 = ((pom/690)*buffer[38])/100;; - data->Iinp2 = ((pom/690)*buffer[39])/100;; - data->Iinp3 = ((pom/690)*buffer[40])/100;; + /* TODO: Range-check the casts to uint16_t? */ + data->Iinp1 = (uint16_t)(((pom/690)*buffer[38])/100); + data->Iinp2 = (uint16_t)(((pom/690)*buffer[39])/100); + data->Iinp3 = (uint16_t)(((pom/690)*buffer[40])/100); data->Finp = buffer[41]+256*buffer[42]; if (buffer[79] & 0x80) { @@ -786,14 +794,16 @@ void riello_parse_sentr(uint8_t* buffer, TRielloData* data) } if (buffer[73]) { + /* FIXME: Wondering how the addition below works for uint8_t[] buffer... */ + /* TODO: Range-check the casts to uint16_t? */ if (buffer[73] < 100) buffer[73]+=256; if (data->Model < 3000) /* singlephase */ - data->Iout1 = ((pom/buffer[73])*buffer[62])/100; + data->Iout1 = (uint16_t)(((pom/buffer[73])*buffer[62])/100); else - data->Iout1 = ((pom/buffer[73])*buffer[62])/100/3; - data->Iout2 = ((pom/buffer[73])*buffer[63])/100/3; - data->Iout3 = ((pom/buffer[73])*buffer[64])/100/3; + data->Iout1 = (uint16_t)(((pom/buffer[73])*buffer[62])/100/3); + data->Iout2 = (uint16_t)(((pom/buffer[73])*buffer[63])/100/3); + data->Iout3 = (uint16_t)(((pom/buffer[73])*buffer[64])/100/3); } else { data->Iout1 = 0; @@ -817,7 +827,7 @@ void riello_parse_sentr(uint8_t* buffer, TRielloData* data) data->Ipout2 = 0; data->Ipout3 = 0; } - else { + else { data->Ipout2 = buffer[66]*3; data->Ipout3 = buffer[67]*3; } @@ -843,7 +853,7 @@ void riello_parse_sentr(uint8_t* buffer, TRielloData* data) data->Ubat *= 10; data->Ibat = buffer[45]+256*buffer[46]; if (!buffer[47]) - data->Ibat = data->Ibat*10; + data->Ibat = data->Ibat*10; data->Tsystem = buffer[48]; data->NomBatCap = buffer[74]+256*buffer[75]; @@ -876,32 +886,32 @@ void riello_parse_sentr(uint8_t* buffer, TRielloData* data) data->StatusCode[4] = 0x00; /* Overload if (riello_test_bit(&DevData.StatusCode[4], 2)) */ - if (buffer[31] & 128) + if (buffer[31] & 128) data->StatusCode[4] |= 0x04; /* Bypass if (riello_test_bit(&DevData.StatusCode[1], 3)) */ - if (((buffer[31] & 2) || (riello_test_bit(&buffer[32], 0)) || (riello_test_bit(&buffer[32], 12)) || + if (((buffer[31] & 2) || (riello_test_bit(&buffer[32], 0)) || (riello_test_bit(&buffer[32], 12)) || (riello_test_bit(&buffer[32], 13)) || (riello_test_bit(&buffer[32], 14))) && (!(buffer[34] & 8))) data->StatusCode[1] |= 0x08; /* AC Fail if (riello_test_bit(&DevData.StatusCode[0], 1)) */ - if (buffer[31] & 8) + if (buffer[31] & 8) data->StatusCode[0] |= 0x02; /* LowBatt if ((riello_test_bit(&DevData.StatusCode[0], 1)) && (riello_test_bit(&DevData.StatusCode[0], 0))) */ if (buffer[31] & 16) { - if (buffer[31] & 8) { + if (buffer[31] & 8) { data->StatusCode[0] |= 0x02; data->StatusCode[0] |= 0x01; } } /* Standby if (!riello_test_bit(&DevData.StatusCode[0], 3)) */ - if ((buffer[22] & 2) || (buffer[34] & 4) || (buffer[34] & 8)) + if ((buffer[22] & 2) || (buffer[34] & 4) || (buffer[34] & 8)) data->StatusCode[0] &= 0xF7; /* Battery bad (Replace battery) if (riello_test_bit(&DevData.StatusCode[2], 0)) */ - if (buffer[31] & 0x40) + if (buffer[31] & 0x40) data->StatusCode[2] |= 0x01; } @@ -913,7 +923,7 @@ void riello_init_serial() foundnak = 0; } -uint8_t riello_header(uint8_t type, uint8_t a, uint8_t* length) +uint8_t riello_header(uint8_t type, uint8_t a, uint8_t* length) { LAST_DATA[0] = LAST_DATA[1]; LAST_DATA[1] = LAST_DATA[2]; @@ -944,7 +954,7 @@ uint8_t riello_tail(uint8_t type, uint8_t length) switch (type) { case DEV_RIELLOSENTRY: - number = length; + number = length; if (buf_ptr_length >= number) return(1); @@ -973,15 +983,15 @@ void riello_parse_serialport(uint8_t typedev, uint8_t* buffer, uint8_t checksum) static uint8_t actual_char, int_i; static uint8_t length; - actual_char = commbyte; + actual_char = commbyte; - if ((riello_header(typedev, actual_char, &length)) && (!foundheader)) { + if ((riello_header(typedev, actual_char, &length)) && (!foundheader)) { upsdebugx(5,"Header detected: LAST_DATA:%X,%X,%X,%X,%X,%X buf_ptr:%i \n\r", LAST_DATA[0], LAST_DATA[1], LAST_DATA[2], LAST_DATA[3], LAST_DATA[4], LAST_DATA[5], buf_ptr_length); foundheader = 1; - buf_ptr_length = 1; + buf_ptr_length = 1; memset(buffer, 0, BUFFER_SIZE); buffer[0] = LAST_DATA[4]; } @@ -1001,13 +1011,13 @@ void riello_parse_serialport(uint8_t typedev, uint8_t* buffer, uint8_t checksum) if (riello_test_nak(typedev, buffer)) { wait_packet = 0; - foundnak = 1; + foundnak = 1; } if (riello_test_crc(typedev, buffer, buf_ptr_length, checksum)) { wait_packet = 0; foundbadcrc = 1; - } + } else { wait_packet = 0; foundbadcrc = 0; diff --git a/drivers/riello.h b/drivers/riello.h index 64453e5..2f3c6a7 100644 --- a/drivers/riello.h +++ b/drivers/riello.h @@ -26,17 +26,14 @@ * Reference of the derivative work: blazer driver */ -#ifndef dev_dataH -#define dev_dataH +#ifndef NUT_RIELLO_H_SEEN +#define NUT_RIELLO_H_SEEN 1 #include #define CTRL_RETRIES 50 #define CTRL_TIMEOUT 100 -#define USB_ENDPOINT_IN 0x80 -#define USB_ENDPOINT_OUT 0x00 - #define MAX_READ_WRITE (16 * 1024) #define USB_WRITE_DELAY 200 @@ -169,11 +166,22 @@ void riello_parse_rc(uint8_t* buffer, TRielloData* data); void riello_parse_sentr(uint8_t* buffer, TRielloData* data); /* communication functions */ -void riello_init_serial(); +void riello_init_serial(void); uint8_t riello_header(uint8_t type, uint8_t a, uint8_t* length); uint8_t riello_tail(uint8_t type, uint8_t length); uint8_t riello_test_nak(uint8_t type, uint8_t* buffer); void riello_parse_serialport(uint8_t typedev, uint8_t* buffer, uint8_t checksum); void riello_comm_setup(const char *port); -#endif +int get_ups_statuscode(void); + +/* Shared global variables for driver subtypes */ +/* extern uint8_t foundheader; */ +extern uint16_t buf_ptr_length; +extern uint8_t wait_packet; +extern uint8_t foundnak; +extern uint8_t foundbadcrc; +extern uint8_t commbyte; +extern uint8_t requestSENTR; + +#endif /* NUT_RIELLO_H_SEEN */ diff --git a/drivers/riello_ser.c b/drivers/riello_ser.c index 9ee779d..8c2714f 100644 --- a/drivers/riello_ser.c +++ b/drivers/riello_ser.c @@ -24,20 +24,29 @@ * Reference of the derivative work: blazer driver */ +#include "config.h" /* must be the first header */ + #include #include -#include "config.h" #include "main.h" #include "serial.h" #include "timehead.h" +/* +// The serial driver has no need for HID structures/code currently +// (maybe there is/was a plan for sharing something between siblings). +// Note that HID is tied to libusb or libshut definitions at the moment. #include "hidparser.h" #include "hidtypes.h" +*/ #include "common.h" /* for upsdebugx() etc */ #include "riello.h" #define DRIVER_NAME "Riello serial driver" -#define DRIVER_VERSION "0.03" +#define DRIVER_VERSION "0.07" + +#define DEFAULT_OFFDELAY 5 +#define DEFAULT_BOOTDELAY 5 /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -48,41 +57,37 @@ upsdrv_info_t upsdrv_info = { { NULL } }; -uint8_t bufOut[BUFFER_SIZE]; -uint8_t bufIn[BUFFER_SIZE]; +static uint8_t bufOut[BUFFER_SIZE]; +static uint8_t bufIn[BUFFER_SIZE]; -uint8_t gpser_error_control; -uint8_t typeRielloProtocol; +static uint8_t gpser_error_control; +static uint8_t typeRielloProtocol; -uint8_t input_monophase; -uint8_t output_monophase; +static uint8_t input_monophase; +static uint8_t output_monophase; -extern uint8_t commbyte; -extern uint8_t wait_packet; -extern uint8_t foundnak; -extern uint8_t foundbadcrc; -extern uint8_t buf_ptr_length; -extern uint8_t requestSENTR; +static unsigned int offdelay = DEFAULT_OFFDELAY; +static unsigned int bootdelay = DEFAULT_BOOTDELAY; -TRielloData DevData; +static TRielloData DevData; /********************************************************************** - * char_read (char *bytes, int size, int read_timeout) + * char_read (char *bytes, size_t size, int read_timeout) * * reads size bytes from the serial port * - * bytes - buffer to store the data + * bytes - buffer to store the data * size - size of the data to get * read_timeout - serial timeout (in milliseconds) * * return -1 on error, -2 on timeout, nb_bytes_readen on success * *********************************************************************/ -static int char_read (char *bytes, int size, int read_timeout) +static ssize_t char_read (char *bytes, size_t size, int read_timeout) { struct timeval serial_timeout; fd_set readfs; - int readen = 0; + ssize_t readen = 0; int rc = 0; FD_ZERO (&readfs); @@ -96,13 +101,12 @@ static int char_read (char *bytes, int size, int read_timeout) return -2; /* timeout */ if (FD_ISSET (upsfd, &readfs)) { - int now = read (upsfd, bytes, size - readen); + ssize_t now = read (upsfd, bytes, size - (size_t)readen); if (now < 0) { return -1; } else { - bytes += now; readen += now; } } @@ -122,12 +126,12 @@ static int char_read (char *bytes, int size, int read_timeout) * returns 0 on success, -1 on error, -2 on timeout * **********************************************************************/ -int serial_read (int read_timeout, u_char *readbuf) +static ssize_t serial_read (int read_timeout, unsigned char *readbuf) { - static u_char cache[512]; - static u_char *cachep = cache; - static u_char *cachee = cache; - int recv; + static unsigned char cache[512]; + static unsigned char *cachep = cache; + static unsigned char *cachee = cache; + ssize_t recv; *readbuf = '\0'; /* if still data in cache, get it */ @@ -154,7 +158,7 @@ int serial_read (int read_timeout, u_char *readbuf) return -1; } -void riello_serialcomm(uint8_t* bufIn, uint8_t typedev) +static void riello_serialcomm(uint8_t* arg_bufIn, uint8_t typedev) { time_t realt, nowt; uint8_t commb = 0; @@ -164,14 +168,14 @@ void riello_serialcomm(uint8_t* bufIn, uint8_t typedev) serial_read(1000, &commb); nowt = time(NULL); commbyte = commb; - riello_parse_serialport(typedev, bufIn, gpser_error_control); + riello_parse_serialport(typedev, arg_bufIn, gpser_error_control); if ((nowt - realt) > 4) break; } } -int get_ups_nominal() +static int get_ups_nominal() { uint8_t length; @@ -204,7 +208,7 @@ int get_ups_nominal() return 0; } -int get_ups_status() +static int get_ups_status() { uint8_t numread, length; @@ -244,7 +248,7 @@ int get_ups_status() return 0; } -int get_ups_extended() +static int get_ups_extended() { uint8_t length; @@ -277,6 +281,7 @@ int get_ups_extended() return 0; } +/* Not static, exposed via header. Not used though, currently... */ int get_ups_statuscode() { uint8_t length; @@ -310,7 +315,7 @@ int get_ups_statuscode() return 0; } -int get_ups_sentr() +static int get_ups_sentr() { uint8_t length; @@ -353,7 +358,7 @@ int get_ups_sentr() return 0; } -int riello_instcmd(const char *cmdname, const char *extra) +static int riello_instcmd(const char *cmdname, const char *extra) { uint8_t length; uint16_t delay; @@ -390,8 +395,11 @@ int riello_instcmd(const char *cmdname, const char *extra) } if (!strcasecmp(cmdname, "load.off.delay")) { + int ipv; delay_char = dstate_getinfo("ups.delay.shutdown"); - delay = atoi(delay_char); + ipv = atoi(delay_char); + if (ipv < 0 || (intmax_t)ipv > (intmax_t)UINT16_MAX) return STAT_INSTCMD_FAILED; + delay = (uint16_t)ipv; riello_init_serial(); if (typeRielloProtocol == DEV_RIELLOGPSER) @@ -427,7 +435,7 @@ int riello_instcmd(const char *cmdname, const char *extra) length = riello_prepare_cr(bufOut, gpser_error_control, delay); else { length = riello_prepare_setrebsentr(bufOut, delay); - + if (ser_send_buf(upsfd, bufOut, length) == 0) { upsdebugx (3, "Command load.on communication error"); return STAT_INSTCMD_FAILED; @@ -468,8 +476,12 @@ int riello_instcmd(const char *cmdname, const char *extra) } if (!strcasecmp(cmdname, "load.on.delay")) { + int ipv; delay_char = dstate_getinfo("ups.delay.reboot"); - delay = atoi(delay_char); + ipv = atoi(delay_char); + if (ipv < 0 || (intmax_t)ipv > (intmax_t)UINT16_MAX) return STAT_INSTCMD_FAILED; + delay = (uint16_t)ipv; + riello_init_serial(); if (typeRielloProtocol == DEV_RIELLOGPSER) @@ -518,8 +530,12 @@ int riello_instcmd(const char *cmdname, const char *extra) } else { if (!strcasecmp(cmdname, "shutdown.return")) { + int ipv; delay_char = dstate_getinfo("ups.delay.shutdown"); - delay = atoi(delay_char); + ipv = atoi(delay_char); + if (ipv < 0 || (intmax_t)ipv > (intmax_t)UINT16_MAX) return STAT_INSTCMD_FAILED; + delay = (uint16_t)ipv; + riello_init_serial(); if (typeRielloProtocol == DEV_RIELLOGPSER) @@ -551,7 +567,7 @@ int riello_instcmd(const char *cmdname, const char *extra) if (!strcasecmp(cmdname, "shutdown.stop")) { riello_init_serial(); - if (typeRielloProtocol == DEV_RIELLOGPSER) + if (typeRielloProtocol == DEV_RIELLOGPSER) length = riello_prepare_cd(bufOut, gpser_error_control); else length = riello_prepare_cancelsentr(bufOut); @@ -627,11 +643,11 @@ int riello_instcmd(const char *cmdname, const char *extra) return STAT_INSTCMD_HANDLED; } - upslogx(LOG_NOTICE, "instcmd: unknown command [%s]", cmdname); + upslogx(LOG_NOTICE, "instcmd: unknown command [%s] [%s]", cmdname, extra); return STAT_INSTCMD_UNKNOWN; } -int start_ups_comm() +static int start_ups_comm() { uint8_t length; @@ -679,7 +695,7 @@ int start_ups_comm() void upsdrv_initinfo(void) { int ret; - + ret = start_ups_comm(); if (ret < 0) @@ -751,6 +767,14 @@ void upsdrv_initinfo(void) dstate_addcmd("shutdown.stop"); dstate_addcmd("test.battery.start"); + dstate_setinfo("ups.delay.shutdown", "%u", offdelay); + dstate_setflags("ups.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING); + dstate_setaux("ups.delay.shutdown", 3); + dstate_setinfo("ups.delay.reboot", "%u", bootdelay); + dstate_setflags("ups.delay.reboot", ST_FLAG_RW | ST_FLAG_STRING); + dstate_setaux("ups.delay.reboot", 3); + + if (typeRielloProtocol == DEV_RIELLOGPSER) dstate_addcmd("test.panel.start"); @@ -776,7 +800,7 @@ void upsdrv_updateinfo(void) } } - if (typeRielloProtocol == DEV_RIELLOGPSER) + if (typeRielloProtocol == DEV_RIELLOGPSER) stat = get_ups_status(); else stat = get_ups_sentr(); @@ -803,9 +827,14 @@ void upsdrv_updateinfo(void) dstate_setinfo("input.bypass.frequency", "%.2f", DevData.Fbypass/10.0); dstate_setinfo("output.frequency", "%.2f", DevData.Fout/10.0); dstate_setinfo("battery.voltage", "%.1f", DevData.Ubat/10.0); - dstate_setinfo("battery.charge", "%u", DevData.BatCap); - dstate_setinfo("battery.runtime", "%u", DevData.BatTime*60); - dstate_setinfo("ups.temperature", "%u", DevData.Tsystem); + + if ((DevData.BatCap < 0xFFFF) && (DevData.BatTime < 0xFFFF)) { + dstate_setinfo("battery.charge", "%u", DevData.BatCap); + dstate_setinfo("battery.runtime", "%u", DevData.BatTime*60); + } + + if (DevData.Tsystem < 0xFF) + dstate_setinfo("ups.temperature", "%u", DevData.Tsystem); if (input_monophase) { dstate_setinfo("input.voltage", "%u", DevData.Uinp1); @@ -836,7 +865,7 @@ void upsdrv_updateinfo(void) } status_init(); - + /* AC Fail */ if (riello_test_bit(&DevData.StatusCode[0], 1)) status_set("OB"); @@ -905,6 +934,9 @@ void upsdrv_updateinfo(void) */ } +void upsdrv_shutdown(void) + __attribute__((noreturn)); + void upsdrv_shutdown(void) { /* tell the UPS to shut down, then return - DO NOT SLEEP HERE */ diff --git a/drivers/riello_usb.c b/drivers/riello_usb.c index 34b319a..417ab89 100644 --- a/drivers/riello_usb.c +++ b/drivers/riello_usb.c @@ -7,6 +7,7 @@ * http://www.networkupstools.org/ups-protocols/riello/PSGPSER-0104.pdf * * Copyright (C) 2012 - Elio Parisi + * Copyright (C) 2016 Eaton * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,15 +26,20 @@ * Reference of the derivative work: blazer driver */ +#include "config.h" /* must be the first header */ + #include #include "main.h" -#include "libusb.h" +#include "nut_libusb.h" #include "usb-common.h" #include "riello.h" #define DRIVER_NAME "Riello USB driver" -#define DRIVER_VERSION "0.03" +#define DRIVER_VERSION "0.07" + +#define DEFAULT_OFFDELAY 5 /*!< seconds (max 0xFF) */ +#define DEFAULT_BOOTDELAY 5 /*!< seconds (max 0xFF) */ /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -44,22 +50,19 @@ upsdrv_info_t upsdrv_info = { { NULL } }; -uint8_t bufOut[BUFFER_SIZE]; -uint8_t bufIn[BUFFER_SIZE]; +static uint8_t bufOut[BUFFER_SIZE]; +static uint8_t bufIn[BUFFER_SIZE]; -uint8_t gpser_error_control; +static uint8_t gpser_error_control; -uint8_t input_monophase; -uint8_t output_monophase; +static uint8_t input_monophase; +static uint8_t output_monophase; -extern uint8_t commbyte; -extern uint8_t wait_packet; -extern uint8_t foundnak; -extern uint8_t foundbadcrc; -extern uint8_t buf_ptr_length; -extern uint8_t requestSENTR; +/*! Time in seconds to delay before shutting down. */ +static unsigned int offdelay = DEFAULT_OFFDELAY; +static unsigned int bootdelay = DEFAULT_BOOTDELAY; -TRielloData DevData; +static TRielloData DevData; static usb_communication_subdriver_t *usb = &usb_subdriver; static usb_dev_handle *udev = NULL; @@ -69,7 +72,7 @@ static USBDeviceMatcher_t *regex_matcher = NULL; static int (*subdriver_command)(uint8_t *cmd, uint8_t *buf, uint16_t length, uint16_t buflen) = NULL; -void ussleep(long usec) +static void ussleep(useconds_t usec) { if (usec == 1) @@ -92,12 +95,12 @@ static int cypress_setfeatures() /* Write features report */ ret = usb_control_msg(udev, USB_ENDPOINT_OUT + USB_TYPE_CLASS + USB_RECIP_INTERFACE, - 0x09, /* HID_REPORT_SET = 0x09 */ - 0 + (0x03 << 8), /* HID_REPORT_TYPE_FEATURE */ - 0, (char*) bufOut, 0x5, 1000); + 0x09, /* HID_REPORT_SET = 0x09 */ + 0 + (0x03 << 8), /* HID_REPORT_TYPE_FEATURE */ + 0, (usb_ctrl_charbuf) bufOut, 0x5, 1000); if (ret <= 0) { - upsdebugx(3, "send: %s", ret ? usb_strerror() : "error"); + upsdebugx(3, "send: %s", ret ? nut_usb_strerror(ret) : "error"); return ret; } @@ -105,10 +108,11 @@ static int cypress_setfeatures() return ret; } -int Send_USB_Packet(uint8_t *send_str, uint16_t numbytes) +static int Send_USB_Packet(uint8_t *send_str, uint16_t numbytes) { uint8_t USB_buff_pom[10]; - int i, err, size, errno; + int i, err, size; + /*int errno;*/ /* is input correct ? */ if ((!send_str) || (!numbytes)) @@ -127,7 +131,7 @@ int Send_USB_Packet(uint8_t *send_str, uint16_t numbytes) USB_buff_pom[6] = send_str[(i*7)+5]; USB_buff_pom[7] = send_str[(i*7)+6]; - err = usb_bulk_write(udev, 0x2, (char*) USB_buff_pom, 8, 1000); + err = usb_bulk_write(udev, 0x2, (usb_ctrl_charbuf) USB_buff_pom, 8, 1000); if (err < 0) { upsdebugx(3, "USB: Send_USB_Packet: send_usb_packet, err = %d %s ", err, strerror(errno)); @@ -157,7 +161,7 @@ int Send_USB_Packet(uint8_t *send_str, uint16_t numbytes) if (((i*7)+6) 0) upsdebugx(3, "read: %02X %02X %02X %02X %02X %02X %02X %02X", inBuf[0], inBuf[1], inBuf[2], inBuf[3], inBuf[4], inBuf[5], inBuf[6], inBuf[7]); - + if (err < 0){ upsdebugx(3, "USB: Get_USB_Packet: send_usb_packet, err = %d %s ", err, strerror(errno)); return err; } /* copy to buffer */ - size = inBuf[0] & 0x07; + size = (unsigned char)(inBuf[0]) & 0x07; if (size) memcpy(buffer, &inBuf[1], size); - return(size); + if (size > INT_MAX) + return -1; + + return (int)size; } static int cypress_command(uint8_t *buffer, uint8_t *buf, uint16_t length, uint16_t buflen) @@ -251,6 +263,8 @@ static int cypress_command(uint8_t *buffer, uint8_t *buf, uint16_t length, uint1 static void *cypress_subdriver(USBDevice_t *device) { + NUT_UNUSED_VARIABLE(device); + subdriver_command = &cypress_command; return NULL; } @@ -262,13 +276,15 @@ static usb_device_id_t riello_usb_id[] = { /* various models */ { USB_DEVICE(RIELLO_VENDORID, 0x5500), &cypress_subdriver }, - /* end of list */ - {-1, -1, NULL} + /* Terminating entry */ + { 0, 0, NULL } }; static int device_match_func(USBDevice_t *hd, void *privdata) { + NUT_UNUSED_VARIABLE(privdata); + if (subdriver_command) { return 1; } @@ -300,15 +316,22 @@ static USBDeviceMatcher_t device_matcher = { * caller, don't do this here. Return < 0 on error, 0 or higher on * success. */ -static int driver_callback(usb_dev_handle *handle, USBDevice_t *device, unsigned char *rdbuf, int rdlen) +static int driver_callback(usb_dev_handle *handle, USBDevice_t *device, usb_ctrl_charbuf rdbuf, usb_ctrl_charbufsize rdlen) { - /*if (usb_set_configuration(handle, 1) < 0) { - upslogx(LOG_WARNING, "Can't set USB configuration: %s", usb_strerror()); - return -1; - } */ + int ret = 0; + NUT_UNUSED_VARIABLE(device); + NUT_UNUSED_VARIABLE(rdbuf); + NUT_UNUSED_VARIABLE(rdlen); - if (usb_claim_interface(handle, 0) < 0) { - upslogx(LOG_WARNING, "Can't claim USB interface: %s", usb_strerror()); +/* + if ((ret = usb_set_configuration(handle, 1)) < 0) { + upslogx(LOG_WARNING, "Can't set USB configuration: %s", nut_usb_strerror(ret)); + return -1; + } +*/ + + if ((ret = usb_claim_interface(handle, 0)) < 0) { + upslogx(LOG_WARNING, "Can't claim USB interface: %s", nut_usb_strerror(ret)); return -1; } @@ -322,7 +345,7 @@ static int driver_callback(usb_dev_handle *handle, USBDevice_t *device, unsigned * Returns < 0 on error, 0 on timeout and the number of bytes read on * success. */ -int riello_command(uint8_t *cmd, uint8_t *buf, uint16_t length, uint16_t buflen) +static int riello_command(uint8_t *cmd, uint8_t *buf, uint16_t length, uint16_t buflen) { int ret; @@ -330,10 +353,10 @@ int riello_command(uint8_t *cmd, uint8_t *buf, uint16_t length, uint16_t buflen) ret = usb->open(&udev, &usbdevice, reopen_matcher, &driver_callback); upsdebugx (3, "riello_command err udev NULL : %d ", ret); - if (ret < 0) + if (ret < 0) return ret; - - upsdrv_initinfo(); //reconekt usb cable + + upsdrv_initinfo(); /* reconnect usb cable */ } ret = (*subdriver_command)(cmd, buf, length, buflen); @@ -346,39 +369,53 @@ int riello_command(uint8_t *cmd, uint8_t *buf, uint16_t length, uint16_t buflen) switch (ret) { - case -EBUSY: /* Device or resource busy */ + case ERROR_BUSY: /* Device or resource busy */ fatal_with_errno(EXIT_FAILURE, "Got disconnected by another driver"); +#ifndef HAVE___ATTRIBUTE__NORETURN + exit(EXIT_FAILURE); /* Should not get here in practice, but compiler is afraid we can fall through */ +#endif - case -EPERM: /* Operation not permitted */ +#if WITH_LIBUSB_0_1 /* limit to libusb 0.1 implementation */ + case -EPERM: /* Operation not permitted */ fatal_with_errno(EXIT_FAILURE, "Permissions problem"); +# ifndef HAVE___ATTRIBUTE__NORETURN + exit(EXIT_FAILURE); /* Should not get here in practice, but compiler is afraid we can fall through */ +# endif +#endif - case -EPIPE: /* Broken pipe */ + case ERROR_PIPE: /* Broken pipe */ if (usb_clear_halt(udev, 0x81) == 0) { upsdebugx(1, "Stall condition cleared"); break; } -#ifdef ETIME - case -ETIME: /* Timer expired */ +#if (defined ETIME) && ETIME && WITH_LIBUSB_0_1 + goto fallthrough_case_etime; + case -ETIME: /* Timer expired */ + fallthrough_case_etime: #endif if (usb_reset(udev) == 0) { upsdebugx(1, "Device reset handled"); } - case -ENODEV: /* No such device */ - case -EACCES: /* Permission denied */ - case -EIO: /* I/O error */ - case -ENXIO: /* No such device or address */ - case -ENOENT: /* No such file or directory */ + goto fallthrough_case_reconnect; + case ERROR_NO_DEVICE: /* No such device */ + case ERROR_ACCESS: /* Permission denied */ + case ERROR_IO: /* I/O error */ +#if WITH_LIBUSB_0_1 /* limit to libusb 0.1 implementation */ + case -ENXIO: /* No such device or address */ +#endif + case ERROR_NOT_FOUND: /* No such file or directory */ + fallthrough_case_reconnect: /* Uh oh, got to reconnect! */ usb->close(udev); udev = NULL; break; - case -ETIMEDOUT: /* Connection timed out */ + case ERROR_TIMEOUT: /* Connection timed out */ upsdebugx (3, "riello_command err: Resource temporarily unavailable"); + break; - - case -EOVERFLOW: /* Value too large for defined data type */ -#ifdef EPROTO + case ERROR_OVERFLOW: /* Value too large for defined data type */ +#if EPROTO && WITH_LIBUSB_0_1 case -EPROTO: /* Protocol error */ #endif break; @@ -386,11 +423,10 @@ int riello_command(uint8_t *cmd, uint8_t *buf, uint16_t length, uint16_t buflen) break; } - return ret; } -int get_ups_nominal() +static int get_ups_nominal() { uint8_t length; @@ -423,7 +459,7 @@ int get_ups_nominal() return 0; } -int get_ups_status() +static int get_ups_status() { uint8_t numread, length; int recv; @@ -462,7 +498,7 @@ int get_ups_status() return 0; } -int get_ups_extended() +static int get_ups_extended() { uint8_t length; int recv; @@ -494,6 +530,7 @@ int get_ups_extended() return 0; } +/* Not static, exposed via header. Not used though, currently... */ int get_ups_statuscode() { uint8_t length; @@ -526,7 +563,7 @@ int get_ups_statuscode() return 0; } -int riello_instcmd(const char *cmdname, const char *extra) +static int riello_instcmd(const char *cmdname, const char *extra) { uint8_t length; int recv; @@ -561,8 +598,12 @@ int riello_instcmd(const char *cmdname, const char *extra) } if (!strcasecmp(cmdname, "load.off.delay")) { + int ipv; delay_char = dstate_getinfo("ups.delay.shutdown"); - delay = atoi(delay_char); + ipv = atoi(delay_char); + /* With a "char" in the name, might assume we fit... but :) */ + if (ipv < 0 || (intmax_t)ipv > (intmax_t)UINT16_MAX) return STAT_INSTCMD_FAILED; + delay = (uint16_t)ipv; length = riello_prepare_cs(bufOut, gpser_error_control, delay); recv = riello_command(&bufOut[0], &bufIn[0], length, LENGTH_DEF); @@ -612,8 +653,12 @@ int riello_instcmd(const char *cmdname, const char *extra) } if (!strcasecmp(cmdname, "load.on.delay")) { + int ipv; delay_char = dstate_getinfo("ups.delay.reboot"); - delay = atoi(delay_char); + ipv = atoi(delay_char); + /* With a "char" in the name, might assume we fit... but :) */ + if (ipv < 0 || (intmax_t)ipv > (intmax_t)UINT16_MAX) return STAT_INSTCMD_FAILED; + delay = (uint16_t)ipv; length = riello_prepare_cr(bufOut, gpser_error_control, delay); recv = riello_command(&bufOut[0], &bufIn[0], length, LENGTH_DEF); @@ -639,8 +684,12 @@ int riello_instcmd(const char *cmdname, const char *extra) } else { if (!strcasecmp(cmdname, "shutdown.return")) { + int ipv; delay_char = dstate_getinfo("ups.delay.shutdown"); - delay = atoi(delay_char); + ipv = atoi(delay_char); + /* With a "char" in the name, might assume we fit... but :) */ + if (ipv < 0 || (intmax_t)ipv > (intmax_t)UINT16_MAX) return STAT_INSTCMD_FAILED; + delay = (uint16_t)ipv; length = riello_prepare_cs(bufOut, gpser_error_control, delay); recv = riello_command(&bufOut[0], &bufIn[0], length, LENGTH_DEF); @@ -734,11 +783,11 @@ int riello_instcmd(const char *cmdname, const char *extra) return STAT_INSTCMD_HANDLED; } - upslogx(LOG_NOTICE, "instcmd: unknown command [%s]", cmdname); + upslogx(LOG_NOTICE, "instcmd: unknown command [%s] [%s]", cmdname, extra); return STAT_INSTCMD_UNKNOWN; } -int start_ups_comm() +static int start_ups_comm() { uint16_t length; int recv; @@ -789,20 +838,23 @@ void upsdrv_initups(void) int (*command)(uint8_t *cmd, uint8_t *buf, uint16_t length, uint16_t buflen); } subdriver[] = { { "cypress", &cypress_command }, - { NULL } + { NULL, NULL } }; int ret; - char *regex_array[6]; + char *regex_array[7]; char *subdrv = getval("subdriver"); + warn_if_bad_usb_port_filename(device_path); + regex_array[0] = getval("vendorid"); regex_array[1] = getval("productid"); regex_array[2] = getval("vendor"); regex_array[3] = getval("product"); regex_array[4] = getval("serial"); regex_array[5] = getval("bus"); + regex_array[6] = getval("device"); /* pick up the subdriver name if set explicitly */ if (subdrv) { @@ -929,6 +981,13 @@ void upsdrv_initinfo(void) dstate_addcmd("test.battery.start"); dstate_addcmd("test.panel.start"); + dstate_setinfo("ups.delay.shutdown", "%u", offdelay); + dstate_setflags("ups.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING); + dstate_setaux("ups.delay.shutdown", 3); + dstate_setinfo("ups.delay.reboot", "%u", bootdelay); + dstate_setflags("ups.delay.reboot", ST_FLAG_RW | ST_FLAG_STRING); + dstate_setaux("ups.delay.reboot", 3); + /* install handlers */ /* upsh.setvar = hid_set_value; setvar; */ @@ -939,6 +998,9 @@ void upsdrv_initinfo(void) upsh.instcmd = riello_instcmd; } +void upsdrv_shutdown(void) + __attribute__((noreturn)); + void upsdrv_shutdown(void) { /* tell the UPS to shut down, then return - DO NOT SLEEP HERE */ @@ -1012,9 +1074,14 @@ void upsdrv_updateinfo(void) dstate_setinfo("input.bypass.frequency", "%.2f", DevData.Fbypass/10.0); dstate_setinfo("output.frequency", "%.2f", DevData.Fout/10.0); dstate_setinfo("battery.voltage", "%.1f", DevData.Ubat/10.0); - dstate_setinfo("battery.charge", "%u", DevData.BatCap); - dstate_setinfo("battery.runtime", "%u", DevData.BatTime*60); - dstate_setinfo("ups.temperature", "%u", DevData.Tsystem); + if ((DevData.BatCap < 0xFFFF) && (DevData.BatTime < 0xFFFF)) { + dstate_setinfo("battery.charge", "%u", DevData.BatCap); + dstate_setinfo("battery.runtime", "%u", DevData.BatTime*60); + } + + if (DevData.Tsystem < 0xFF) + dstate_setinfo("ups.temperature", "%u", DevData.Tsystem); + if (input_monophase) { dstate_setinfo("input.voltage", "%u", DevData.Uinp1); @@ -1075,11 +1142,11 @@ void upsdrv_updateinfo(void) /* Boost */ if (riello_test_bit(&DevData.StatusCode[1], 1)) - status_set("BOOST"); + status_set("BOOST"); /* Replace battery */ if (riello_test_bit(&DevData.StatusCode[2], 0)) - status_set("RB"); + status_set("RB"); /* Charging battery */ if (riello_test_bit(&DevData.StatusCode[2], 2)) @@ -1156,4 +1223,5 @@ void upsdrv_cleanup(void) free(usbdevice.Product); free(usbdevice.Serial); free(usbdevice.Bus); + free(usbdevice.Device); } diff --git a/drivers/safenet.c b/drivers/safenet.c index 77170fb..2715db8 100644 --- a/drivers/safenet.c +++ b/drivers/safenet.c @@ -41,7 +41,7 @@ #include "safenet.h" #define DRIVER_NAME "Generic SafeNet UPS driver" -#define DRIVER_VERSION "1.6" +#define DRIVER_VERSION "1.7" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -60,13 +60,14 @@ static union { struct safenet status; } ups; -static int ondelay = 1; /* minutes */ -static int offdelay = 30; /* seconds */ +static long ondelay = 1; /* minutes */ +static long offdelay = 30; /* seconds */ static int safenet_command(const char *command) { char reply[32]; - int i, ret; + size_t i; + ssize_t ret; /* * Get rid of whatever is in the in- and output buffers. @@ -260,7 +261,7 @@ static int instcmd(const char *cmdname, const char *extra) */ if (!strcasecmp(cmdname, "shutdown.return")) { char command[] = SHUTDOWN_RETURN; - + command[4] += ((offdelay % 1000) / 100); command[5] += ((offdelay % 100) / 10); command[6] += (offdelay % 10); @@ -288,7 +289,7 @@ static int instcmd(const char *cmdname, const char *extra) return STAT_INSTCMD_HANDLED; } - upslogx(LOG_NOTICE, "instcmd: unknown command [%s]", cmdname); + upslogx(LOG_NOTICE, "instcmd: unknown command [%s] [%s]", cmdname, extra); return STAT_INSTCMD_UNKNOWN; } @@ -328,8 +329,8 @@ void upsdrv_initinfo(void) dstate_setinfo("ups.model", "%s", ((v = getval("modelname")) != NULL) ? v : "unknown"); dstate_setinfo("ups.serial", "%s", ((v = getval("serialnumber")) != NULL) ? v : "unknown"); - dstate_setinfo("ups.delay.start", "%d", 60 * ondelay); - dstate_setinfo("ups.delay.shutdown", "%d", offdelay); + dstate_setinfo("ups.delay.start", "%ld", 60 * ondelay); + dstate_setinfo("ups.delay.shutdown", "%ld", offdelay); /* * These are the instant commands we support. @@ -508,7 +509,7 @@ void upsdrv_initups(void) } if ((ondelay < 0) || (ondelay > 9999)) { - fatalx(EXIT_FAILURE, "Start delay '%d' out of range [0..9999]", ondelay); + fatalx(EXIT_FAILURE, "Start delay '%ld' out of range [0..9999]", ondelay); } val = getval("offdelay"); @@ -517,7 +518,7 @@ void upsdrv_initups(void) } if ((offdelay < 0) || (offdelay > 999)) { - fatalx(EXIT_FAILURE, "Shutdown delay '%d' out of range [0..999]", offdelay); + fatalx(EXIT_FAILURE, "Shutdown delay '%ld' out of range [0..999]", offdelay); } } diff --git a/drivers/safenet.h b/drivers/safenet.h index 12f2040..25d4976 100644 --- a/drivers/safenet.h +++ b/drivers/safenet.h @@ -18,6 +18,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef NUT_SAFENET_H_SEEN +#define NUT_SAFENET_H_SEEN 1 + /* * The following commands where traced on the serial port. From these, the * COM_POLL_STAT command is just an example of how this command looks. @@ -58,3 +61,5 @@ struct safenet { char systemtest; char dunno_10; }; + +#endif /* NUT_SAFENET_H_SEEN */ diff --git a/drivers/salicru-hid.c b/drivers/salicru-hid.c new file mode 100644 index 0000000..b49b099 --- /dev/null +++ b/drivers/salicru-hid.c @@ -0,0 +1,276 @@ +/* salicru-hid.c - subdriver to monitor Salicru USB/HID devices with NUT + * + * Copyright (C) + * 2003 - 2012 Arnaud Quette + * 2005 - 2006 Peter Selinger + * 2008 - 2009 Arjen de Korte + * 2013 Charles Lepple + * 2021 Francois Lacroix + * + * Note: this subdriver was initially generated as a "stub" by the + * gen-usbhid-subdriver script. It must be customized. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config.h" /* must be first */ + +#include "usbhid-ups.h" +#include "salicru-hid.h" +#include "main.h" /* for getval() */ +#include "usb-common.h" + +#define SALICRU_HID_VERSION "Salicru HID 0.3" +/* FIXME: experimental flag to be put in upsdrv_info */ + +/* Salicru */ +#define SALICRU_VENDORID 0x2e66 + +/* USB IDs device table */ +static usb_device_id_t salicru_usb_device_table[] = { + /* TWINPRO3/TWINRT3 (SLC-1500-TWIN PRO3) per https://github.com/networkupstools/nut/issues/1142 */ + /* SLC TWIN PRO2<=3KVA per https://github.com/networkupstools/nut/issues/450 */ + { USB_DEVICE(SALICRU_VENDORID, 0x0201), NULL }, + { USB_DEVICE(SALICRU_VENDORID, 0x0202), NULL }, + { USB_DEVICE(SALICRU_VENDORID, 0x0203), NULL }, + + /* Salicru SPS 850 HOME per https://github.com/networkupstools/nut/pull/1199 */ + /* https://www.salicru.com/sps-home.html */ + { USB_DEVICE(SALICRU_VENDORID, 0x0300), NULL }, + + /* Terminating entry */ + { 0, 0, NULL } +}; + + +/* --------------------------------------------------------------- */ +/* Vendor-specific usage table */ +/* --------------------------------------------------------------- */ + +/* SALICRU usage table */ +static usage_lkp_t salicru_usage_lkp[] = { + { NULL, 0 } +}; + +static usage_tables_t salicru_utab[] = { + salicru_usage_lkp, + hid_usage_lkp, + NULL, +}; + +/* --------------------------------------------------------------- */ +/* HID2NUT lookup table */ +/* --------------------------------------------------------------- */ + +static hid_info_t salicru_hid2nut[] = { + +#ifdef DEBUG + { "experimental.ups.powersummary.imanufacturer", 0, 0, "UPS.PowerSummary.iManufacturer", NULL, "%.0f", 0, NULL }, + { "experimental.ups.powersummary.iproduct", 0, 0, "UPS.PowerSummary.CapacityMode", NULL, "%.0f", 0, NULL }, + { "experimental.ups.powersummary.iserialnumber", 0, 0, "UPS.PowerSummary.iSerialNumber", NULL, "%.0f", 0, NULL }, + { "experimental.ups.powersummary.capacitymode", 0, 0, "UPS.PowerSummary.CapacityMode", NULL, "%.0f", 0, NULL }, + { "experimental.ups.powersummary.rechargeable", 0, 0, "UPS.PowerSummary.Rechargeable", NULL, "%.0f", 0, NULL }, + { "experimental.ups.powersummary.designcapacity", 0, 0, "UPS.PowerSummary.DesignCapacity", NULL, "%.0f", 0, NULL }, + { "experimental.ups.powersummary.fullchargecapacity", 0, 0, "UPS.PowerSummary.FullChargeCapacity", NULL, "%.0f", 0, NULL }, +#endif /* DEBUG */ + +/* A few more unknown fields + 0.043266 [D1] Path: UPS.ff010004.ff010024.ff0100d0, Type: Feature, ReportID: 0x19, Offset: 0, Size: 8, Value: 0.1 + 0.043766 [D1] Path: UPS.ff010004.ff010024.ff0100d1, Type: Feature, ReportID: 0x1a, Offset: 0, Size: 8, Value: 0 + 0.044308 [D1] Path: UPS.ff01001d.ff010019.ff010020, Type: Feature, ReportID: 0x25, Offset: 0, Size: 1, Value: 0 + 0.044762 [D1] Path: UPS.ff01001d.ff010019.ff010021, Type: Feature, ReportID: 0x2c, Offset: 0, Size: 1, Value: 0 + 0.044891 [D1] Path: UPS.ff01001d.ff010019.ff010021, Type: Input, ReportID: 0x2c, Offset: 0, Size: 1, Value: 0 + 0.045386 [D1] Path: UPS.ff01001d.ff01001a.ff010001, Type: Feature, ReportID: 0x26, Offset: 0, Size: 1, Value: 0 + 0.045888 [D1] Path: UPS.ff01001d.ff01001a.ff010002, Type: Feature, ReportID: 0x27, Offset: 0, Size: 8, Value: 1 + 0.047553 [D2] libusb_get_report: error sending control message: Value too large for defined data type + 0.047659 [D1] Can't retrieve Report 28: Value too large for defined data type + 0.047796 [D1] Path: UPS.ff01001d.ff01001b.ff010040, Type: Feature, ReportID: 0x28, Offset: 0, Size: 8 + 0.048272 [D2] libusb_get_report: error sending control message: Value too large for defined data type + 0.048403 [D1] Can't retrieve Report 28: Value too large for defined data type + 0.048537 [D1] Path: UPS.ff01001d.ff01001b.ff010016, Type: Input, ReportID: 0x28, Offset: 0, Size: 8 + 0.049017 [D2] libusb_get_report: error sending control message: Value too large for defined data type + 0.049147 [D1] Can't retrieve Report 28: Value too large for defined data type + 0.049280 [D1] Path: UPS.ff01001d.ff01001b.ff010018, Type: Feature, ReportID: 0x28, Offset: 8, Size: 8 + 0.050944 [D2] libusb_get_report: error sending control message: Value too large for defined data type + 0.051124 [D1] Can't retrieve Report 28: Value too large for defined data type + 0.051264 [D1] Path: UPS.ff01001d.ff01001b.ff010018, Type: Input, ReportID: 0x28, Offset: 8, Size: 8 + 0.052965 [D2] libusb_get_report: error sending control message: Value too large for defined data type + 0.053137 [D1] Can't retrieve Report 29: Value too large for defined data type + 0.053277 [D1] Path: UPS.ff01001d.ff01001b.ff010015, Type: Feature, ReportID: 0x29, Offset: 0, Size: 8 + 0.053804 [D2] libusb_get_report: error sending control message: Value too large for defined data type + 0.053954 [D1] Can't retrieve Report 29: Value too large for defined data type + 0.054091 [D1] Path: UPS.ff01001d.ff01001b.ff010015, Type: Output, ReportID: 0x29, Offset: 0, Size: 8 + 0.054530 [D2] libusb_get_report: error sending control message: Value too large for defined data type + 0.054664 [D1] Can't retrieve Report 29: Value too large for defined data type + 0.054799 [D1] Path: UPS.ff01001d.ff01001b.ff010017, Type: Feature, ReportID: 0x29, Offset: 8, Size: 8 + 0.055285 [D2] libusb_get_report: error sending control message: Value too large for defined data type + 0.055421 [D1] Can't retrieve Report 29: Value too large for defined data type + 0.055557 [D1] Path: UPS.ff01001d.ff01001b.ff010017, Type: Output, ReportID: 0x29, Offset: 8, Size: 8 + 0.056130 [D2] libusb_get_report: error sending control message: Value too large for defined data type + 0.056273 [D1] Can't retrieve Report 2d: Value too large for defined data type + 0.056409 [D1] Path: UPS.ff01001d.ff01001b.ff010010, Type: Feature, ReportID: 0x2d, Offset: 0, Size: 1 + 0.056927 [D2] libusb_get_report: error sending control message: Value too large for defined data type + 0.057074 [D1] Can't retrieve Report 2d: Value too large for defined data type + 0.057211 [D1] Path: UPS.ff01001d.ff01001b.ff01001e, Type: Feature, ReportID: 0x2d, Offset: 1, Size: 1 + 0.057676 [D2] libusb_get_report: error sending control message: Value too large for defined data type + 0.057825 [D1] Can't retrieve Report 2d: Value too large for defined data type + 0.057962 [D1] Path: UPS.ff01001d.ff01001b.ff01001f, Type: Feature, ReportID: 0x2d, Offset: 2, Size: 1 + 0.058416 [D2] libusb_get_report: error sending control message: Value too large for defined data type + 0.058551 [D1] Can't retrieve Report 2d: Value too large for defined data type + 0.058685 [D1] Path: UPS.ff01001d.ff01001b.ff010010, Type: Input, ReportID: 0x2d, Offset: 0, Size: 1 + 0.059156 [D2] libusb_get_report: error sending control message: Value too large for defined data type + 0.059291 [D1] Can't retrieve Report 2d: Value too large for defined data type + 0.059426 [D1] Path: UPS.ff01001d.ff01001b.ff01001e, Type: Input, ReportID: 0x2d, Offset: 1, Size: 1 + 0.059957 [D2] libusb_get_report: error sending control message: Value too large for defined data type + 0.060112 [D1] Can't retrieve Report 2d: Value too large for defined data type + 0.060248 [D1] Path: UPS.ff01001d.ff01001b.ff01001f, Type: Input, ReportID: 0x2d, Offset: 2, Size: 1 + 0.061944 [D2] libusb_get_report: error sending control message: Value too large for defined data type + 0.062117 [D1] Can't retrieve Report 2a: Value too large for defined data type + 0.062256 [D1] Path: UPS.ff01001d.ff01001b.ff010013, Type: Feature, ReportID: 0x2a, Offset: 0, Size: 1 + 0.063941 [D2] libusb_get_report: error sending control message: Value too large for defined data type + 0.064104 [D1] Can't retrieve Report 2b: Value too large for defined data type + 0.064242 [D1] Path: UPS.ff01001d.ff01001b.ff010014, Type: Feature, ReportID: 0x2b, Offset: 0, Size: 1 +*/ + + /* Battery page */ + { "battery.type", 0, 0, "UPS.PowerSummary.iDeviceChemistry", NULL, "%s", 0, stringid_conversion }, + { "battery.charge", 0, 0, "UPS.PowerSummary.RemainingCapacity", NULL, "%.0f", 0, NULL }, + { "battery.charge.warning", 0, 0, "UPS.PowerSummary.WarningCapacityLimit", NULL, "%.0f", 0, NULL }, + { "battery.charge.low", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerSummary.RemainingCapacityLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "battery.runtime", 0, 0, "UPS.PowerSummary.RunTimeToEmpty", NULL, "%.0f", 0, NULL }, + { "battery.runtime.low", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.PowerSummary.RemainingTimeLimit", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "battery.voltage.nominal", 0, 0, "UPS.PowerSummary.ConfigVoltage", NULL, "%.0f", 0, NULL }, + { "battery.voltage", 0, 0, "UPS.PowerSummary.Voltage", NULL, "%.2f", 0, NULL }, + + /* UPS page */ + { "ups.load", 0, 0, "UPS.Output.PercentLoad", NULL, "%.0f", 0, NULL }, + { "ups.beeper.status", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "%s", 0, beeper_info }, + { "ups.test.result", 0, 0, "UPS.Output.Test", NULL, "%s", 0, test_read_info }, + { "ups.realpower.nominal", 0, 0, "UPS.Output.ConfigActivePower", NULL, "%.0f", 0, NULL }, + + /* Boolean value */ + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.ACPresent", NULL, NULL, HU_FLAG_QUICK_POLL, online_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Charging", NULL, NULL, HU_FLAG_QUICK_POLL, charging_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Discharging", NULL, NULL, HU_FLAG_QUICK_POLL, discharging_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.BelowRemainingCapacityLimit", NULL, NULL, HU_FLAG_QUICK_POLL, lowbatt_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.FullyCharged", NULL, NULL, 0, fullycharged_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.RemainingTimeLimitExpired", NULL, NULL, 0, timelimitexpired_info }, + { "BOOL", 0, 0, "UPS.Output.CommunicationLost", NULL, NULL, 0, commfault_info }, + { "BOOL", 0, 0, "UPS.Output.Boost", NULL, NULL, 0, boost_info }, + { "BOOL", 0, 0, "UPS.Output.Overload", NULL, NULL, 0, overload_info }, + + /* Input page */ + { "input.frequency", 0, 0, "UPS.Input.Frequency", NULL, "%.1f", 0, NULL }, + { "input.voltage.nominal", 0, 0, "UPS.Input.ConfigVoltage", NULL, "%.0f", 0, NULL }, + { "input.voltage", 0, 0, "UPS.Input.Voltage", NULL, "%.1f", 0, NULL }, + /* read-only on this model but probably R/W in other models */ +/* + { "input.transfer.low", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.Input.LowVoltageTransfer", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, + { "input.transfer.high", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.Input.HighVoltageTransfer", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL }, +*/ + { "input.transfer.high", 0, 0, "UPS.PowerConverter.Output.HighVoltageTransfer", NULL, "%.0f", HU_FLAG_STATIC, NULL }, + { "input.transfer.low", 0, 0, "UPS.PowerConverter.Output.LowVoltageTransfer", NULL, "%.0f", HU_FLAG_STATIC, NULL }, + + /* Output page */ + { "output.frequency", 0, 0, "UPS.Output.Frequency", NULL, "%.1f", 0, NULL }, + { "output.voltage", 0, 0, "UPS.Output.Voltage", NULL, "%.1f", 0, NULL }, + { "output.voltage.nominal", 0, 0, "UPS.Output.ConfigVoltage", NULL, "%.0f", 0, NULL }, + + /* instant commands. */ +/* Need testing + { "test.battery.start.quick", 0, 0, "UPS.Output.Test", NULL, "1", HU_TYPE_CMD, NULL }, + { "test.battery.start.deep", 0, 0, "UPS.Output.Test", NULL, "2", HU_TYPE_CMD, NULL }, + { "test.battery.stop", 0, 0, "UPS.Output.Test", NULL, "3", HU_TYPE_CMD, NULL }, + { "load.off.delay", 0, 0, "UPS.Output.DelayBeforeShutdown", NULL, DEFAULT_OFFDELAY, HU_TYPE_CMD, NULL }, + { "load.on.delay", 0, 0, "UPS.Output.DelayBeforeStartup", NULL, DEFAULT_ONDELAY, HU_TYPE_CMD, NULL }, + { "shutdown.stop", 0, 0, "UPS.Output.DelayBeforeShutdown", NULL, "-1", HU_TYPE_CMD, NULL }, + { "shutdown.reboot", 0, 0, "UPS.Output.DelayBeforeReboot", NULL, "10", HU_TYPE_CMD, NULL }, + { "beeper.on", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "2", HU_TYPE_CMD, NULL }, + { "beeper.off", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "3", HU_TYPE_CMD, NULL }, + { "beeper.enable", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "2", HU_TYPE_CMD, NULL }, + { "beeper.disable", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "1", HU_TYPE_CMD, NULL }, + { "beeper.mute", 0, 0, "UPS.PowerSummary.AudibleAlarmControl", NULL, "3", HU_TYPE_CMD, NULL }, +*/ + + /* Salicru Twin Pro 2 Descriptors: Sensors */ + { "ups.load", 0, 0, "UPS.PowerSummary.PercentLoad", NULL, "%.0f", 0, NULL }, + { "ups.test.result", 0, 0, "UPS.BatterySystem.Battery.Test", NULL, "%s", 0, test_read_info }, + { "ups.realpower.nominal", 0, 0, "UPS.Flow.[4].ConfigActivePower", NULL, "%.0f", 0, NULL }, + { "ups.realpower", 0, 0, "UPS.PowerConverter.Output.ActivePower", NULL, "%.0f", 0, NULL }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.Overload", NULL, NULL, 0, overload_info }, + { "BOOL", 0, 0, "UPS.PowerSummary.PresentStatus.OverTemperature", NULL, NULL, 0, overheat_info }, + { "input.frequency", 0, 0, "UPS.PowerConverter.Input.[1].Frequency", NULL, "%.1f", 0, NULL }, + { "input.voltage", 0, 0, "UPS.PowerConverter.Input.[1].Voltage", NULL, "%.1f", 0, NULL }, + { "output.frequency", 0, 0, "UPS.PowerConverter.Output.Frequency", NULL, "%.1f", 0, NULL }, + { "output.voltage", 0, 0, "UPS.PowerConverter.Output.Voltage", NULL, "%.1f", 0, NULL }, + { "output.voltage.nominal", 0, 0, "UPS.PowerSummary.ConfigVoltage", NULL, "%.0f", 0, NULL }, + { "ups.test.result", 0, 0, "UPS.BatterySystem.Battery.Test", NULL, "%s", 0, test_read_info }, + + /* Salicru Twin Pro 2 Descriptors: Instant commands */ + { "test.battery.start.quick", 0, 0, "UPS.BatterySystem.Battery.Test", NULL, "1", HU_TYPE_CMD, NULL }, + { "test.battery.start.deep", 0, 0, "UPS.BatterySystem.Battery.Test", NULL, "2", HU_TYPE_CMD, NULL }, + { "test.battery.stop", 0, 0, "UPS.BatterySystem.Battery.Test", NULL, "3", HU_TYPE_CMD, NULL }, + + /* end of structure. */ + { NULL, 0, 0, NULL, NULL, NULL, 0, NULL } +}; + +static const char *salicru_format_model(HIDDevice_t *hd) { + return hd->Product; +} + +static const char *salicru_format_mfr(HIDDevice_t *hd) { + return hd->Vendor ? hd->Vendor : "Salicru"; +} + +static const char *salicru_format_serial(HIDDevice_t *hd) { + return hd->Serial; +} + +/* this function allows the subdriver to "claim" a device: return 1 if + * the device is supported by this subdriver, else 0. */ +static int salicru_claim(HIDDevice_t *hd) +{ + int status = is_usb_device_supported(salicru_usb_device_table, hd); + + switch (status) + { + case POSSIBLY_SUPPORTED: + /* by default, reject, unless the productid option is given */ + if (getval("productid")) { + return 1; + } + possibly_supported("Salicru", hd); + return 0; + + case SUPPORTED: + return 1; + + case NOT_SUPPORTED: + default: + return 0; + } +} + +subdriver_t salicru_subdriver = { + SALICRU_HID_VERSION, + salicru_claim, + salicru_utab, + salicru_hid2nut, + salicru_format_model, + salicru_format_mfr, + salicru_format_serial, + fix_report_desc, +}; diff --git a/drivers/salicru-hid.h b/drivers/salicru-hid.h new file mode 100644 index 0000000..e0e6b9c --- /dev/null +++ b/drivers/salicru-hid.h @@ -0,0 +1,30 @@ +/* salicru-hid.h - subdriver to monitor Salicru USB/HID devices with NUT + * + * Copyright (C) + * 2003 - 2009 Arnaud Quette + * 2005 - 2006 Peter Selinger + * 2008 - 2009 Arjen de Korte + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef SALICRU_HID_H +#define SALICRU_HID_H + +#include "usbhid-ups.h" + +extern subdriver_t salicru_subdriver; + +#endif /* SALICRU_HID_H */ diff --git a/drivers/serial.c b/drivers/serial.c index 9c6129d..60af06f 100644 --- a/drivers/serial.c +++ b/drivers/serial.c @@ -21,6 +21,7 @@ #include "timehead.h" #include "serial.h" #include "main.h" +#include "attribute.h" #include #include @@ -34,8 +35,13 @@ #include #endif +#include "nut_stdint.h" + static unsigned int comm_failures = 0; +static void ser_open_error(const char *port) + __attribute__((noreturn)); + static void ser_open_error(const char *port) { struct stat fs; @@ -57,7 +63,7 @@ static void ser_open_error(const char *port) user = getpwuid(getuid()); if (user) - printf(" Current user id: %s (%d)\n", + printf(" Current user id: %s (%d)\n", user->pw_name, (int) user->pw_uid); user = getpwuid(fs.st_uid); @@ -97,7 +103,7 @@ static void lock_set(int fd, const char *port) ret = uu_lock(xbasename(port)); if (ret != 0) - fatalx(EXIT_FAILURE, "Can't uu_lock %s: %s", xbasename(port), + fatalx(EXIT_FAILURE, "Can't uu_lock %s: %s", xbasename(port), uu_lockerr(ret)); #elif defined(HAVE_FLOCK) @@ -125,7 +131,6 @@ static void lock_set(int fd, const char *port) /* Non fatal version of ser_open */ int ser_open_nf(const char *port) - { int fd; @@ -155,6 +160,7 @@ int ser_open(const char *port) int ser_set_speed_nf(int fd, const char *port, speed_t speed) { struct termios tio; + NUT_UNUSED_VARIABLE(port); if (tcgetattr(fd, &tio) != 0) { return -1; @@ -256,17 +262,29 @@ int ser_close(int fd, const char *port) return 0; } -int ser_send_char(int fd, unsigned char ch) +ssize_t ser_send_char(int fd, unsigned char ch) { return ser_send_buf_pace(fd, 0, &ch, 1); } -static int send_formatted(int fd, const char *fmt, va_list va, unsigned long d_usec) +static ssize_t send_formatted(int fd, const char *fmt, va_list va, useconds_t d_usec) { int ret; char buf[LARGEBUF]; +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif ret = vsnprintf(buf, sizeof(buf), fmt, va); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif if (ret >= (int)sizeof(buf)) { upslogx(LOG_WARNING, "vsnprintf needed more than %d bytes", (int)sizeof(buf)); @@ -276,14 +294,26 @@ static int send_formatted(int fd, const char *fmt, va_list va, unsigned long d_u } /* send the results of the format string with d_usec delay after each char */ -int ser_send_pace(int fd, unsigned long d_usec, const char *fmt, ...) +ssize_t ser_send_pace(int fd, useconds_t d_usec, const char *fmt, ...) { - int ret; + ssize_t ret; va_list ap; va_start(ap, fmt); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif ret = send_formatted(fd, fmt, ap, d_usec); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif va_end(ap); @@ -291,14 +321,26 @@ int ser_send_pace(int fd, unsigned long d_usec, const char *fmt, ...) } /* send the results of the format string with no delay */ -int ser_send(int fd, const char *fmt, ...) +ssize_t ser_send(int fd, const char *fmt, ...) { - int ret; + ssize_t ret; va_list ap; va_start(ap, fmt); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif ret = send_formatted(fd, fmt, ap, 0); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif va_end(ap); @@ -306,22 +348,23 @@ int ser_send(int fd, const char *fmt, ...) } /* send buflen bytes from buf with no delay */ -int ser_send_buf(int fd, const void *buf, size_t buflen) +ssize_t ser_send_buf(int fd, const void *buf, size_t buflen) { return ser_send_buf_pace(fd, 0, buf, buflen); } /* send buflen bytes from buf with d_usec delay after each char */ -int ser_send_buf_pace(int fd, unsigned long d_usec, const void *buf, +ssize_t ser_send_buf_pace(int fd, useconds_t d_usec, const void *buf, size_t buflen) { - int ret; - size_t sent; + ssize_t ret = 0; + ssize_t sent; const char *data = buf; - for (sent = 0; sent < buflen; sent += ret) { - - ret = write(fd, &data[sent], (d_usec == 0) ? (buflen - sent) : 1); + assert(buflen < SSIZE_MAX); + for (sent = 0; sent < (ssize_t)buflen; sent += ret) { + /* Conditions above ensure that (buflen - sent) > 0 below */ + ret = write(fd, &data[sent], (d_usec == 0) ? (size_t)((ssize_t)buflen - sent) : 1); if (ret < 1) { return ret; @@ -333,30 +376,37 @@ int ser_send_buf_pace(int fd, unsigned long d_usec, const void *buf, return sent; } -int ser_get_char(int fd, void *ch, long d_sec, long d_usec) +ssize_t ser_get_char(int fd, void *ch, time_t d_sec, useconds_t d_usec) { - return select_read(fd, ch, 1, d_sec, d_usec); + /* Per standard below, we can cast here, because required ranges are + * effectively the same (and signed -1 for suseconds_t), and at most long: + * https://pubs.opengroup.org/onlinepubs/009604599/basedefs/sys/types.h.html + */ + return select_read(fd, ch, 1, d_sec, (suseconds_t)d_usec); } -int ser_get_buf(int fd, void *buf, size_t buflen, long d_sec, long d_usec) +ssize_t ser_get_buf(int fd, void *buf, size_t buflen, time_t d_sec, useconds_t d_usec) { memset(buf, '\0', buflen); - return select_read(fd, buf, buflen, d_sec, d_usec); + return select_read(fd, buf, buflen, d_sec, (suseconds_t)d_usec); } /* keep reading until buflen bytes are received or a timeout occurs */ -int ser_get_buf_len(int fd, void *buf, size_t buflen, long d_sec, long d_usec) +ssize_t ser_get_buf_len(int fd, void *buf, size_t buflen, time_t d_sec, useconds_t d_usec) { - int ret; - size_t recv; + ssize_t ret; + ssize_t recv; char *data = buf; + assert(buflen < SSIZE_MAX); memset(buf, '\0', buflen); - for (recv = 0; recv < buflen; recv += ret) { + for (recv = 0; recv < (ssize_t)buflen; recv += ret) { - ret = select_read(fd, &data[recv], buflen - recv, d_sec, d_usec); + ret = select_read(fd, &data[recv], + (size_t)((ssize_t)buflen - recv), + d_sec, (suseconds_t)d_usec); if (ret < 1) { return ret; @@ -368,21 +418,22 @@ int ser_get_buf_len(int fd, void *buf, size_t buflen, long d_sec, long d_usec) /* reads a line up to , discarding anything else that may follow, with callouts to the handler if anything matches the alertset */ -int ser_get_line_alert(int fd, void *buf, size_t buflen, char endchar, - const char *ignset, const char *alertset, void handler(char ch), - long d_sec, long d_usec) +ssize_t ser_get_line_alert(int fd, void *buf, size_t buflen, char endchar, + const char *ignset, const char *alertset, void handler(char ch), + time_t d_sec, useconds_t d_usec) { - int i, ret; + ssize_t i, ret; char tmp[64]; char *data = buf; - size_t count = 0, maxcount; + ssize_t count = 0, maxcount; + assert(buflen < SSIZE_MAX && buflen > 0); memset(buf, '\0', buflen); - maxcount = buflen - 1; /* for trailing \0 */ + maxcount = (ssize_t)buflen - 1; /* for trailing \0 */ while (count < maxcount) { - ret = select_read(fd, tmp, sizeof(tmp), d_sec, d_usec); + ret = select_read(fd, tmp, sizeof(tmp), d_sec, (suseconds_t)d_usec); if (ret < 1) { return ret; @@ -412,16 +463,16 @@ int ser_get_line_alert(int fd, void *buf, size_t buflen, char endchar, } /* as above, only with no alertset handling (just a wrapper) */ -int ser_get_line(int fd, void *buf, size_t buflen, char endchar, - const char *ignset, long d_sec, long d_usec) +ssize_t ser_get_line(int fd, void *buf, size_t buflen, char endchar, + const char *ignset, time_t d_sec, useconds_t d_usec) { return ser_get_line_alert(fd, buf, buflen, endchar, ignset, "", NULL, d_sec, d_usec); } -int ser_flush_in(int fd, const char *ignset, int verbose) +ssize_t ser_flush_in(int fd, const char *ignset, int verbose) { - int ret, extra = 0; + ssize_t ret, extra = 0; char ch; while ((ret = ser_get_char(fd, &ch, 0, 0)) > 0) { @@ -434,7 +485,7 @@ int ser_flush_in(int fd, const char *ignset, int verbose) if (verbose == 0) continue; - if (isprint(ch & 0xFF)) + if (isprint((unsigned char)ch & 0xFF)) upslogx(LOG_INFO, "ser_flush_in: read char %c", ch); else upslogx(LOG_INFO, "ser_flush_in: read char 0x%02x", ch); @@ -467,7 +518,19 @@ void ser_comm_fail(const char *fmt, ...) return; va_start(ap, fmt); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif ret = vsnprintf(why, sizeof(why), fmt, ap); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif va_end(ap); if ((ret < 1) || (ret >= (int) sizeof(why))) diff --git a/drivers/serial.h b/drivers/serial.h index 5fb3a45..c2f5a2c 100644 --- a/drivers/serial.h +++ b/drivers/serial.h @@ -11,6 +11,10 @@ # include #endif /* HAVE_SYS_TERMIOS_H */ +#include /* for usleep() and useconds_t, latter also might be via */ +#include +#include /* for suseconds_t */ + /* limit the amount of spew that goes in the syslog when we lose the UPS */ #define SER_ERR_LIMIT 10 /* start limiting after 10 in a row */ #define SER_ERR_RATE 100 /* then only print every 100th error */ @@ -34,41 +38,41 @@ int ser_flush_io(int fd); int ser_close(int fd, const char *port); -int ser_send_char(int fd, unsigned char ch); +ssize_t ser_send_char(int fd, unsigned char ch); /* send the results of the format string with d_usec delay after each char */ -int ser_send_pace(int fd, unsigned long d_usec, const char *fmt, ...) +ssize_t ser_send_pace(int fd, useconds_t d_usec, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4))); /* send the results of the format string with no delay */ -int ser_send(int fd, const char *fmt, ...) +ssize_t ser_send(int fd, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); /* send buflen bytes from buf with no delay */ -int ser_send_buf(int fd, const void *buf, size_t buflen); +ssize_t ser_send_buf(int fd, const void *buf, size_t buflen); /* send buflen bytes from buf with d_usec delay after each char */ -int ser_send_buf_pace(int fd, unsigned long d_usec, const void *buf, +ssize_t ser_send_buf_pace(int fd, useconds_t d_usec, const void *buf, size_t buflen); -int ser_get_char(int fd, void *ch, long d_sec, long d_usec); +ssize_t ser_get_char(int fd, void *ch, time_t d_sec, useconds_t d_usec); -int ser_get_buf(int fd, void *buf, size_t buflen, long d_sec, long d_usec); +ssize_t ser_get_buf(int fd, void *buf, size_t buflen, time_t d_sec, useconds_t d_usec); /* keep reading until buflen bytes are received or a timeout occurs */ -int ser_get_buf_len(int fd, void *buf, size_t buflen, long d_sec, long d_usec); +ssize_t ser_get_buf_len(int fd, void *buf, size_t buflen, time_t d_sec, useconds_t d_usec); /* reads a line up to , discarding anything else that may follow, with callouts to the handler if anything matches the alertset */ -int ser_get_line_alert(int fd, void *buf, size_t buflen, char endchar, +ssize_t ser_get_line_alert(int fd, void *buf, size_t buflen, char endchar, const char *ignset, const char *alertset, void handler (char ch), - long d_sec, long d_usec); + time_t d_sec, useconds_t d_usec); /* as above, only with no alertset handling (just a wrapper) */ -int ser_get_line(int fd, void *buf, size_t buflen, char endchar, - const char *ignset, long d_sec, long d_usec); +ssize_t ser_get_line(int fd, void *buf, size_t buflen, char endchar, + const char *ignset, time_t d_sec, useconds_t d_usec); -int ser_flush_in(int fd, const char *ignset, int verbose); +ssize_t ser_flush_in(int fd, const char *ignset, int verbose); /* unified failure reporting: call these often */ void ser_comm_fail(const char *fmt, ...) diff --git a/drivers/skel.c b/drivers/skel.c index 5d4b930..f6d4cb3 100644 --- a/drivers/skel.c +++ b/drivers/skel.c @@ -1,18 +1,20 @@ /* anything commented is optional anything else is mandatory - + for more information, refer to: * docs/developers.txt * docs/new-drivers.txt * docs/new-names.txt - + and possibly also to: * docs/hid-subdrivers.txt for USB/HID devices * or docs/snmp-subdrivers.txt for SNMP devices */ +#include "config.h" #include "main.h" +#include "attribute.h" /* #include "serial.h" */ @@ -20,7 +22,7 @@ /* #define IGNCHARS "" */ #define DRIVER_NAME "Skeleton UPS driver" -#define DRIVER_VERSION "0.02" +#define DRIVER_VERSION "0.03" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -55,7 +57,7 @@ void upsdrv_updateinfo(void) /* ser_send(upsfd, "foo%d", 1234); */ /* ser_send_buf(upsfd, bincmd, 12); */ - /* + /* * ret = ser_get_line(upsfd, temp, sizeof(temp), ENDCHAR, IGNCHARS); * * if (ret < STATUS_LEN) { @@ -92,6 +94,9 @@ void upsdrv_updateinfo(void) */ } +void upsdrv_shutdown(void) + __attribute__((noreturn)); + void upsdrv_shutdown(void) { /* tell the UPS to shut down, then return - DO NOT SLEEP HERE */ diff --git a/drivers/snmp-ups-helpers.c b/drivers/snmp-ups-helpers.c new file mode 100644 index 0000000..b4116ff --- /dev/null +++ b/drivers/snmp-ups-helpers.c @@ -0,0 +1,106 @@ +/* snmp-ups-helpers.c - Shared helper functions and data mapping tables + * for NUT Generic SNMP driver core + * + * Copyright (C) + * 2015 - 2021 Eaton (author: Arnaud Quette ) + * 2016 - 2021 Eaton (author: Jim Klimov ) + * + * Sponsored by Eaton + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/* NUT SNMP common functions */ +#include "common.h" /* includes "config.h" which must be the first header */ +/* +#include "config.h" +#include "main.h" +#include "nut_float.h" +#include "nut_stdint.h" +*/ +#include "snmp-ups.h" +#include "timehead.h" /* time.h => strptime() */ + +#include /* for isprint() */ + +/*********************************************************************** + * Subdrivers shared helpers functions + * Code below is primarily used in snmp-ups driver, but may be part + * of other compilation units, so separated into a stand-alone file + **********************************************************************/ + +static char su_scratch_buf[255]; + +/* Temperature handling, to convert back to Celsius */ +int temperature_unit = TEMPERATURE_UNKNOWN; + +/* Convert a US formated date (mm/dd/yyyy) to an ISO 8601 Calendar date (yyyy-mm-dd) */ +const char *su_usdate_to_isodate_info_fun(void *raw_date) +{ + const char *usdate = (char *)raw_date; + struct tm tm; + memset(&tm, 0, sizeof(struct tm)); + memset(&su_scratch_buf, 0, sizeof(su_scratch_buf)); + + upsdebugx(3, "%s: US date = %s", __func__, usdate); + + /* Try to convert from US date string to time */ + /* Note strptime returns NULL upon failure, and a ptr to the last + null char of the string upon success. Just try blindly the conversion! */ + strptime(usdate, "%m/%d/%Y", &tm); + if (strftime(su_scratch_buf, 254, "%F", &tm) != 0) { + upsdebugx(3, "%s: successfully reformated: %s", __func__, su_scratch_buf); + return su_scratch_buf; + } + + return NULL; +} + +info_lkp_t su_convert_to_iso_date_info[] = { + /* array index = FUNMAP_USDATE_TO_ISODATE: */ + { 1, "dummy", su_usdate_to_isodate_info_fun, NULL }, + { 0, NULL, NULL, NULL } +}; + +/* Process temperature value according to 'temperature_unit' */ +const char *su_temperature_read_fun(void *raw_snmp_value) +{ + const long snmp_value = *((long*)raw_snmp_value); + long celsius_value = snmp_value; + + memset(su_scratch_buf, 0, sizeof(su_scratch_buf)); + + switch (temperature_unit) { + case TEMPERATURE_KELVIN: + celsius_value = (snmp_value / 10) - 273.15; + snprintf(su_scratch_buf, sizeof(su_scratch_buf), "%.1ld", celsius_value); + break; + case TEMPERATURE_CELSIUS: + snprintf(su_scratch_buf, sizeof(su_scratch_buf), "%.1ld", (snmp_value / 10)); + break; + case TEMPERATURE_FAHRENHEIT: + celsius_value = (((snmp_value / 10) - 32) * 5) / 9; + snprintf(su_scratch_buf, sizeof(su_scratch_buf), "%.1ld", celsius_value); + break; + case TEMPERATURE_UNKNOWN: + default: + upsdebugx(1, "%s: not a known temperature unit for conversion!", __func__); + break; + } + upsdebugx(2, "%s: %.1ld => %s", __func__, (snmp_value / 10), su_scratch_buf); + return su_scratch_buf; +} diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index 4eab02e..fad0997 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -1,10 +1,11 @@ -/* snmp-ups.c - NUT Meta SNMP driver (support different MIBS) +/* snmp-ups.c - NUT Generic SNMP driver core (supports different MIBs) * - * Based on NetSNMP API (Simple Network Management Protocol V1-2) + * Based on NetSNMP API (Simple Network Management Protocol v1-2c-3) * * Copyright (C) * 2002 - 2014 Arnaud Quette - * 2015 - 2016 Arnaud Quette + * 2015 - 2021 Eaton (author: Arnaud Quette ) + * 2016 - 2022 Eaton (author: Jim Klimov ) * 2002 - 2006 Dmitry Frolov * J.W. Hoogervorst * Niels Baggesen @@ -30,21 +31,26 @@ * */ -#include -#include /* for isprint() */ - /* NUT SNMP common functions */ -#include "main.h" +#include "main.h" /* includes "config.h" which must be the first header */ +#include "nut_float.h" +#include "nut_stdint.h" #include "snmp-ups.h" #include "parseconf.h" +#include /* for isprint() */ + /* include all known mib2nut lookup tables */ #include "apc-mib.h" #include "mge-mib.h" #include "netvision-mib.h" #include "powerware-mib.h" -#include "eaton-mib.h" +#include "eaton-pdu-genesis2-mib.h" +#include "eaton-pdu-marlin-mib.h" +#include "eaton-pdu-pulizzi-mib.h" +#include "eaton-pdu-revelation-mib.h" #include "raritan-pdu-mib.h" +#include "raritan-px2-mib.h" #include "baytech-mib.h" #include "compaq-mib.h" #include "bestpower-mib.h" @@ -53,42 +59,72 @@ #include "huawei-mib.h" #include "ietf-mib.h" #include "xppc-mib.h" -#include "eaton-ats-mib.h" +#include "eaton-ats16-nmc-mib.h" +#include "eaton-ats16-nm2-mib.h" #include "apc-ats-mib.h" +#include "apc-pdu-mib.h" +#include "eaton-ats30-mib.h" +#include "emerson-avocent-pdu-mib.h" +#include "hpe-pdu-mib.h" /* Address API change */ -#ifndef usmAESPrivProtocol +#if ( ! NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol ) && ( ! defined usmAESPrivProtocol ) #define usmAESPrivProtocol usmAES128PrivProtocol #endif +#ifdef USM_PRIV_PROTO_AES_LEN +# define NUT_securityPrivProtoLen USM_PRIV_PROTO_AES_LEN +#else +# ifdef USM_PRIV_PROTO_AES128_LEN +# define NUT_securityPrivProtoLen USM_PRIV_PROTO_AES128_LEN +# else +/* FIXME: Find another way to get the size of array(?) to avoid: + * error: division 'sizeof (oid * {aka long unsigned int *}) / sizeof (oid {aka long unsigned int})' does not compute the number of array elements [-Werror=sizeof-pointer-div] + * See also https://bugs.php.net/bug.php?id=37564 for context + * which is due to most values in /usr/include/net-snmp/librarytransform_oids.h + * being defined as "oid[10]" or similar arrays, and "backwards compatibility" + * usmAESPrivProtocol name is an "oid *" pointer. + */ +# define NUT_securityPrivProtoLen (sizeof(usmAESPrivProtocol)/sizeof(oid)) +# endif +#endif + static mib2nut_info_t *mib2nut[] = { - &apc, - &mge, - &netvision, - &powerware, - &pxgx_ups, - &aphel_genesisII, - &aphel_revelation, - &eaton_marlin, - &pulizzi_switched1, - &pulizzi_switched2, - &raritan, - &baytech, - &compaq, - &bestpower, - &cyberpower, - &delta_ups, - &xppc, - &huawei, - &tripplite_ietf, - &eaton_ats, - &apc_ats, + &apc_ats, /* This struct comes from : apc-ats-mib.c */ + &apc_pdu_rpdu, /* This struct comes from : apc-pdu-mib.c */ + &apc_pdu_rpdu2, /* This struct comes from : apc-pdu-mib.c */ + &apc_pdu_msp, /* This struct comes from : apc-pdu-mib.c */ + &apc, /* This struct comes from : apc-mib.c */ + &baytech, /* This struct comes from : baytech-mib.c */ + &bestpower, /* This struct comes from : bestpower-mib.c */ + &compaq, /* This struct comes from : compaq-mib.c */ + &cyberpower, /* This struct comes from : cyberpower-mib.c */ + &delta_ups, /* This struct comes from : delta_ups-mib.c */ + &eaton_ats16_nmc, /* This struct comes from : eaton-ats16-nmc-mib.c */ + &eaton_ats16_nm2, /* This struct comes from : eaton-ats16-nm2-mib.c */ + &eaton_ats30, /* This struct comes from : eaton-ats30-mib.c */ + &eaton_marlin, /* This struct comes from : eaton-mib.c */ + &emerson_avocent_pdu, /* This struct comes from : emerson-avocent-pdu-mib.c */ + &aphel_revelation, /* This struct comes from : eaton-mib.c */ + &aphel_genesisII, /* This struct comes from : eaton-mib.c */ + &pulizzi_switched1, /* This struct comes from : eaton-mib.c */ + &pulizzi_switched2, /* This struct comes from : eaton-mib.c */ + &hpe_pdu, /* This struct comes from : hpe-pdu-mib.c */ + &huawei, /* This struct comes from : huawei-mib.c */ + &mge, /* This struct comes from : mge-mib.c */ + &netvision, /* This struct comes from : netvision-mib.c */ + &powerware, /* This struct comes from : powerware-mib.c */ + &pxgx_ups, /* This struct comes from : powerware-mib.c */ + &raritan, /* This struct comes from : raritan-pdu-mib.c */ + &raritan_px2, /* This struct comes from : raritan-px2-mib.c */ + &xppc, /* This struct comes from : xppc-mib.c */ /* * Prepend vendor specific MIB mappings before IETF, so that * if a device supports both IETF and vendor specific MIB, - * the vendor specific one takes precedence (when mib=auto) + * the vendor specific one takes precedence (when mibs=auto) */ - &ietf, + &tripplite_ietf, /* This struct comes from : ietf-mib.c */ + &ietf, /* This struct comes from : ietf-mib.c */ /* end of structure. */ NULL }; @@ -97,18 +133,40 @@ struct snmp_session g_snmp_sess, *g_snmp_sess_p; const char *OID_pwr_status; int g_pwr_battery; int pollfreq; /* polling frequency */ -int input_phases, output_phases, bypass_phases; +int semistaticfreq; /* semistatic entry update frequency */ +static int semistatic_countdown = 0; + +static int quirk_symmetra_threephase = 0; + +/* Number of device(s): standard is "1", but talking + * to a daisychain (master device) means more than 1 + * (a directly addressable member of a daisy chain + * would be seen as a single-device chain though) + */ +static long devices_count = 1; +/* global var to handle daisychain iterations - + * changed by loops in snmp_ups_walk() and su_addcmd(); + * may be 0 for addressing certain values/commands + * across all chain devices via master (1); + * also may be 0 for non-daisychained devices + */ +static int current_device_number = 0; +/* global var to handle daisychain iterations - + * made TRUE if we resolved a "device.count" value + */ +static bool_t daisychain_enabled = FALSE; +static daisychain_info_t **daisychain_info = NULL; /* pointer to the Snmp2Nut lookup table */ mib2nut_info_t *mib2nut_info; /* FIXME: to be trashed */ snmp_info_t *snmp_info; alarms_info_t *alarms_info; -const char *mibname; -const char *mibvers; +static const char *mibname; +static const char *mibvers; #define DRIVER_NAME "Generic SNMP UPS driver" -#define DRIVER_VERSION "0.97" +#define DRIVER_VERSION "1.21" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -119,17 +177,30 @@ upsdrv_info_t upsdrv_info = { "Dmitry Frolov \n" \ "J.W. Hoogervorst \n" \ "Niels Baggesen \n" \ + "Jim Klimov \n" \ "Arjen de Korte ", DRV_STABLE, { NULL } }; /* FIXME: integrate MIBs info? do the same as for usbhid-ups! */ -time_t lastpoll = 0; +static time_t lastpoll = 0; + +/* Communication status handling */ +#define COMM_UNKNOWN 0 +#define COMM_OK 1 +#define COMM_LOST 2 +static int comm_status = COMM_UNKNOWN; /* template OIDs index start with 0 or 1 (estimated stable for a MIB), * automatically guessed at the first pass */ -int template_index_base = -1; +static int template_index_base = -1; +/* Not that stable in the end... */ +static int device_template_index_base = -1; /* OID index of the 1rst daisychained device */ +static int outlet_template_index_base = -1; +static int outletgroup_template_index_base = -1; +static int ambient_template_index_base = -1; +static int device_template_offset = -1; /* sysOID location */ #define SYSOID_OID ".1.3.6.1.2.1.1.2.0" @@ -137,7 +208,8 @@ int template_index_base = -1; /* Forward functions declarations */ static void disable_transfer_oids(void); bool_t get_and_process_data(int mode, snmp_info_t *su_info_p); -int extract_template_number(int template_type, const char* varname); +int extract_template_number(snmp_info_flags_t template_type, const char* varname); +snmp_info_flags_t get_template_type(const char* varname); /* --------------------------------------------- * driver functions implementations @@ -150,30 +222,63 @@ void upsdrv_initinfo(void) dstate_setinfo("driver.version.data", "%s MIB %s", mibname, mibvers); + if (snmp_info == NULL) { + fatalx(EXIT_FAILURE, "%s: snmp_info is not initialized", __func__); + } + + if (snmp_info[0].info_type == NULL) { + upsdebugx(1, "%s: WARNING: snmp_info is empty", __func__); + } + /* add instant commands to the info database. * outlet (and groups) commands are processed later, during initial walk */ - for (su_info_p = &snmp_info[0]; su_info_p->info_type != NULL ; su_info_p++) + for (su_info_p = &snmp_info[0]; (su_info_p != NULL && su_info_p->info_type != NULL) ; su_info_p++) { + if (su_info_p->flags == 0UL) { + upsdebugx(4, + "SNMP UPS driver: %s: MIB2NUT mapping '%s' (OID '%s') did not define flags bits. " + "Entry would be treated as SU_FLAG_OK if available in returned data.", + __func__, + (su_info_p->info_type ? su_info_p->info_type : ""), + (su_info_p->OID ? su_info_p->OID : "") + ); + /* Treat as OK if avail, otherwise discarded */ + } + su_info_p->flags |= SU_FLAG_OK; if ((SU_TYPE(su_info_p) == SU_TYPE_CMD) && !(su_info_p->flags & SU_OUTLET) - && !(su_info_p->flags & SU_OUTLET_GROUP)) { + && !(su_info_p->flags & SU_OUTLET_GROUP)) + { /* first check that this OID actually exists */ + /* FIXME: daisychain commands support! */ + su_addcmd(su_info_p); +/* if (nut_snmp_get(su_info_p->OID) != NULL) { dstate_addcmd(su_info_p->info_type); upsdebugx(1, "upsdrv_initinfo(): adding command '%s'", su_info_p->info_type); } +*/ } } if (testvar("notransferoids")) disable_transfer_oids(); - /* initialize all other INFO_ fields from list */ - if (snmp_ups_walk(SU_WALKMODE_INIT) == TRUE) - dstate_dataok(); + if (testvar("symmetrathreephase")) + quirk_symmetra_threephase = 1; else + quirk_symmetra_threephase = 0; + + /* initialize all other INFO_ fields from list */ + if (snmp_ups_walk(SU_WALKMODE_INIT) == TRUE) { + dstate_dataok(); + comm_status = COMM_OK; + } + else { dstate_datastale(); + comm_status = COMM_LOST; + } /* setup handlers for instcmd and setvar functions */ upsh.setvar = su_setvar; @@ -192,17 +297,36 @@ void upsdrv_updateinfo(void) status_init(); /* update all dynamic info fields */ - if (snmp_ups_walk(SU_WALKMODE_UPDATE)) + if (snmp_ups_walk(SU_WALKMODE_UPDATE)) { + upsdebugx(1, "%s: pollfreq: Data OK", __func__); dstate_dataok(); - else + comm_status = COMM_OK; + } + else { + upsdebugx(1, "%s: pollfreq: Data STALE", __func__); dstate_datastale(); + comm_status = COMM_LOST; + } - alarm_commit(); + /* Commit status first, otherwise in daisychain mode, "device.0" may + * clear the alarm count since it has an empty alarm buffer and if there + * is only one device that has alarms! */ + if (daisychain_enabled == FALSE) + alarm_commit(); status_commit(); + if (daisychain_enabled == TRUE) + alarm_commit(); /* store timestamp */ lastpoll = time(NULL); } + else { + /* Just tell the same status to upsd */ + if (comm_status == COMM_OK) + dstate_dataok(); + else + dstate_datastale(); + } } void upsdrv_shutdown(void) @@ -218,6 +342,9 @@ void upsdrv_shutdown(void) upsdebugx(1, "%s...", __func__); + /* set shutdown and autostart delay */ + set_delays(); + /* Try to shutdown with delay */ if (su_instcmd("shutdown.return", NULL) == STAT_INSTCMD_HANDLED) { /* Shutdown successful */ @@ -250,19 +377,24 @@ void upsdrv_makevartable(void) upsdebugx(1, "entering %s()", __func__); addvar(VAR_VALUE, SU_VAR_MIBS, + "NOTE: You can run the driver binary with '-x mibs=--list' for an up to date listing)\n" "Set MIB compliance (default=ietf, allowed: mge,apcc,netvision,pw,cpqpower,...)"); addvar(VAR_VALUE | VAR_SENSITIVE, SU_VAR_COMMUNITY, "Set community name (default=public)"); addvar(VAR_VALUE, SU_VAR_VERSION, - "Set SNMP version (default=v1, allowed v2c)"); + "Set SNMP version (default=v1, allowed: v2c,v3)"); addvar(VAR_VALUE, SU_VAR_POLLFREQ, "Set polling frequency in seconds, to reduce network flow (default=30)"); + addvar(VAR_VALUE, SU_VAR_SEMISTATICFREQ, + "Set semistatic value update frequency in update cycles, to reduce network flow (default=10)"); addvar(VAR_VALUE, SU_VAR_RETRIES, "Specifies the number of Net-SNMP retries to be used in the requests (default=5)"); addvar(VAR_VALUE, SU_VAR_TIMEOUT, "Specifies the Net-SNMP timeout in seconds between retries (default=1)"); addvar(VAR_FLAG, "notransferoids", "Disable transfer OIDs (use on APCC Symmetras)"); + addvar(VAR_FLAG, "symmetrathreephase", + "Enable APCC three phase Symmetra quirks (use on APCC three phase Symmetras)"); addvar(VAR_VALUE, SU_VAR_SECLEVEL, "Set the securityLevel used for SNMPv3 messages (default=noAuthNoPriv, allowed: authNoPriv,authPriv)"); addvar(VAR_VALUE | VAR_SENSITIVE, SU_VAR_SECNAME, @@ -270,24 +402,205 @@ void upsdrv_makevartable(void) addvar(VAR_VALUE | VAR_SENSITIVE, SU_VAR_AUTHPASSWD, "Set the authentication pass phrase used for authenticated SNMPv3 messages (no default)"); addvar(VAR_VALUE | VAR_SENSITIVE, SU_VAR_PRIVPASSWD, - "Set the privacy pass phrase used for encrypted SNMPv3 messages (no default)"); - addvar(VAR_VALUE, SU_VAR_AUTHPROT, - "Set the authentication protocol (MD5 or SHA) used for authenticated SNMPv3 messages (default=MD5)"); - addvar(VAR_VALUE, SU_VAR_PRIVPROT, - "Set the privacy protocol (DES or AES) used for encrypted SNMPv3 messages (default=DES)"); + "Set the privacy pass phrase used for encrypted SNMPv3 messages (no default)"); + + /* Construct addvar() for SU_VAR_AUTHPROT: */ + { int comma = 0; + char tmp_buf[SU_LARGEBUF]; + char *p = tmp_buf; + char *pn; /* proto name to add */ + size_t remain = sizeof(tmp_buf) - 1; + int ret; + NUT_UNUSED_VARIABLE(comma); /* potentially, if no protocols are available */ + + tmp_buf[0] = '\0'; + + ret = snprintf(p, remain, "%s", + "Set the authentication protocol ("); + if (ret < 0 || (uintmax_t)ret > (uintmax_t)remain || (uintmax_t)ret > SIZE_MAX) { + fatalx(EXIT_FAILURE, "Could not addvar()"); + } + p += ret; + remain -= (size_t)ret; + +#if NUT_HAVE_LIBNETSNMP_usmHMACMD5AuthProtocol + pn = "MD5"; + ret = snprintf(p, remain, "%s%s", (comma++ ? ", " : ""), pn ); + if (ret < 0 || (uintmax_t)ret > (uintmax_t)remain || (uintmax_t)ret > SIZE_MAX) { + fatalx(EXIT_FAILURE, "Could not addvar(%s)", pn); + } + p += ret; + remain -= (size_t)ret; +#endif +#if NUT_HAVE_LIBNETSNMP_usmHMACSHA1AuthProtocol + pn = "SHA"; + ret = snprintf(p, remain, "%s%s", (comma++ ? ", " : ""), pn ); + if (ret < 0 || (uintmax_t)ret > (uintmax_t)remain || (uintmax_t)ret > SIZE_MAX) { + fatalx(EXIT_FAILURE, "Could not addvar(%s)", pn); + } + p += ret; + remain -= (size_t)ret; +#endif +#if NUT_HAVE_LIBNETSNMP_usmHMAC192SHA256AuthProtocol + pn = "SHA256"; + ret = snprintf(p, remain, "%s%s", (comma++ ? ", " : ""), pn ); + if (ret < 0 || (uintmax_t)ret > (uintmax_t)remain || (uintmax_t)ret > SIZE_MAX) { + fatalx(EXIT_FAILURE, "Could not addvar(%s)", pn); + } + p += ret; + remain -= (size_t)ret; +#endif +#if NUT_HAVE_LIBNETSNMP_usmHMAC256SHA384AuthProtocol + pn = "SHA384"; + ret = snprintf(p, remain, "%s%s", (comma++ ? ", " : ""), pn ); + if (ret < 0 || (uintmax_t)ret > (uintmax_t)remain || (uintmax_t)ret > SIZE_MAX) { + fatalx(EXIT_FAILURE, "Could not addvar(%s)", pn); + } + p += ret; + remain -= (size_t)ret; +#endif +#if NUT_HAVE_LIBNETSNMP_usmHMAC384SHA512AuthProtocol + pn = "SHA512"; + ret = snprintf(p, remain, "%s%s", (comma++ ? ", " : ""), pn ); + if (ret < 0 || (uintmax_t)ret > (uintmax_t)remain || (uintmax_t)ret > SIZE_MAX) { + fatalx(EXIT_FAILURE, "Could not addvar(%s)", pn); + } + p += ret; + remain -= (size_t)ret; +#endif + + pn = "none supported"; + ret = snprintf(p, remain, "%s", (comma++ ? "" : pn) ); + if (ret < 0 || (uintmax_t)ret > (uintmax_t)remain || (uintmax_t)ret > SIZE_MAX) { + fatalx(EXIT_FAILURE, "Could not addvar(%s)", pn); + } + p += ret; + remain -= (size_t)ret; + + ret = snprintf(p, remain, "%s", + ") used for authenticated SNMPv3 messages (default=MD5 if available)"); + if (ret < 0 || (uintmax_t)ret > (uintmax_t)remain || (uintmax_t)ret > SIZE_MAX) { + fatalx(EXIT_FAILURE, "Could not addvar()"); + } + p += ret; + remain -= (size_t)ret; + + addvar(VAR_VALUE, SU_VAR_AUTHPROT, tmp_buf); + } /* Construct addvar() for AUTHPROTO */ + + /* Construct addvar() for SU_VAR_PRIVPROT: */ + { int comma = 0; + char tmp_buf[SU_LARGEBUF]; + char *p = tmp_buf; + char *pn; /* proto name to add */ + size_t remain = sizeof(tmp_buf) - 1; + int ret; + NUT_UNUSED_VARIABLE(comma); /* potentially, if no protocols are available */ + + tmp_buf[0] = '\0'; + + ret = snprintf(p, remain, "%s", + "Set the privacy protocol ("); + if (ret < 0 || (uintmax_t)ret > (uintmax_t)remain || (uintmax_t)ret > SIZE_MAX) { + fatalx(EXIT_FAILURE, "Could not addvar()"); + } + p += ret; + remain -= (size_t)ret; + +#if NUT_HAVE_LIBNETSNMP_usmDESPrivProtocol + pn = "DES"; + ret = snprintf(p, remain, "%s%s", (comma++ ? ", " : ""), pn ); + if (ret < 0 || (uintmax_t)ret > (uintmax_t)remain || (uintmax_t)ret > SIZE_MAX) { + fatalx(EXIT_FAILURE, "Could not addvar(%s)", pn); + } + p += ret; + remain -= (size_t)ret; +#endif +#if NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol || NUT_HAVE_LIBNETSNMP_usmAES128PrivProtocol + pn = "AES"; + ret = snprintf(p, remain, "%s%s", (comma++ ? ", " : ""), pn ); + if (ret < 0 || (uintmax_t)ret > (uintmax_t)remain || (uintmax_t)ret > SIZE_MAX) { + fatalx(EXIT_FAILURE, "Could not addvar(%s)", pn); + } + p += ret; + remain -= (size_t)ret; +#endif +#if NUT_HAVE_LIBNETSNMP_DRAFT_BLUMENTHAL_AES_04 +# if NUT_HAVE_LIBNETSNMP_usmAES192PrivProtocol + pn = "AES192"; + ret = snprintf(p, remain, "%s%s", (comma++ ? ", " : ""), pn ); + if (ret < 0 || (uintmax_t)ret > (uintmax_t)remain || (uintmax_t)ret > SIZE_MAX) { + fatalx(EXIT_FAILURE, "Could not addvar(%s)", pn); + } + p += ret; + remain -= (size_t)ret; +# endif +# if NUT_HAVE_LIBNETSNMP_usmAES256PrivProtocol + pn = "AES256"; + ret = snprintf(p, remain, "%s%s", (comma++ ? ", " : ""), pn ); + if (ret < 0 || (uintmax_t)ret > (uintmax_t)remain || (uintmax_t)ret > SIZE_MAX) { + fatalx(EXIT_FAILURE, "Could not addvar(%s)", pn); + } + p += ret; + remain -= (size_t)ret; +# endif +#endif /* NUT_HAVE_LIBNETSNMP_DRAFT_BLUMENTHAL_AES_04 */ + + pn = "none supported"; + ret = snprintf(p, remain, "%s", (comma++ ? "" : pn) ); + if (ret < 0 || (uintmax_t)ret > (uintmax_t)remain || (uintmax_t)ret > SIZE_MAX) { + fatalx(EXIT_FAILURE, "Could not addvar(%s)", pn); + } + p += ret; + remain -= (size_t)ret; + + ret = snprintf(p, remain, "%s", + ") used for encrypted SNMPv3 messages (default=DES if available)"); + if (ret < 0 || (uintmax_t)ret > (uintmax_t)remain || (uintmax_t)ret > SIZE_MAX) { + fatalx(EXIT_FAILURE, "Could not addvar()"); + } + p += ret; + remain -= (size_t)ret; + + addvar(VAR_VALUE, SU_VAR_PRIVPROT, tmp_buf); + } /* Construct addvar() for PRIVPROTO */ + + addvar(VAR_VALUE, SU_VAR_ONDELAY, + "Set start delay time after shutdown"); + addvar(VAR_VALUE, SU_VAR_OFFDELAY, + "Set delay time before shutdown "); } void upsdrv_initups(void) { - snmp_info_t *su_info_p; + snmp_info_t *su_info_p, *cur_info_p; char model[SU_INFOSIZE]; bool_t status= FALSE; const char *mibs; + int curdev = 0; upsdebugx(1, "SNMP UPS driver: entering %s()", __func__); /* Retrieve user's parameters */ mibs = testvar(SU_VAR_MIBS) ? getval(SU_VAR_MIBS) : "auto"; + if (!strcmp(mibs, "--list")) { + printf("The 'mibs' argument is '%s', so just listing the mappings this driver knows,\n" + "and for 'mibs=auto' these mappings will be tried in the following order until\n" + "the first one matches your device\n\n", mibs); + int i; + printf("%7s\t%-23s\t%-7s\t%-31s\t%-s\n", + "NUMBER", "MAPPING NAME", "VERSION", + "ENTRY POINT OID", "AUTO CHECK OID"); + for (i=0; mib2nut[i] != NULL; i++) { + printf(" %4d \t%-23s\t%7s\t%-31s\t%-s\n", (i+1), + mib2nut[i]->mib_name ? mib2nut[i]->mib_name : "" , + mib2nut[i]->mib_version ? mib2nut[i]->mib_version : "" , + mib2nut[i]->sysOID ? mib2nut[i]->sysOID : "" , + mib2nut[i]->oid_auto_check ? mib2nut[i]->oid_auto_check : "" ); + } + printf("\nOverall this driver has loaded %d MIB-to-NUT mapping tables\n", i); + exit(EXIT_SUCCESS); + } /* init SNMP library, etc... */ nut_snmp_init(progname, device_path); @@ -303,14 +616,68 @@ void upsdrv_initups(void) else pollfreq = DEFAULT_POLLFREQ; + /* init semistatic update frequency */ + if (getval(SU_VAR_SEMISTATICFREQ)) + semistaticfreq = atoi(getval(SU_VAR_SEMISTATICFREQ)); + else + semistaticfreq = DEFAULT_SEMISTATICFREQ; + if (semistaticfreq < 1) { + upsdebugx(1, "Bad %s value provided, setting to default", SU_VAR_SEMISTATICFREQ); + semistaticfreq = DEFAULT_SEMISTATICFREQ; + } + semistatic_countdown = semistaticfreq; + /* Get UPS Model node to see if there's a MIB */ +/* FIXME: extend and use match_model_OID(char *model) */ su_info_p = su_find_info("ups.model"); /* Try to get device.model if ups.model is not available */ if (su_info_p == NULL) su_info_p = su_find_info("device.model"); - if (su_info_p != NULL) - status = nut_snmp_get_str(su_info_p->OID, model, sizeof(model), NULL); + if (su_info_p != NULL) { + /* Daisychain specific: we may have a template (including formatting + * string) that needs to be adapted! */ + if (strchr(su_info_p->OID, '%') != NULL) + { + upsdebugx(2, "Found template, need to be adapted"); + cur_info_p = (snmp_info_t *)malloc(sizeof(snmp_info_t)); + cur_info_p->info_type = (char *)xmalloc(SU_INFOSIZE); + cur_info_p->OID = (char *)xmalloc(SU_INFOSIZE); + snprintf((char*)cur_info_p->info_type, SU_INFOSIZE, "%s", su_info_p->info_type); + /* Use the daisychain master (0) / 1rst device index */ +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + snprintf((char*)cur_info_p->OID, SU_INFOSIZE, su_info_p->OID, 0); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif + } + else { + upsdebugx(2, "Found entry, not a template %s", su_info_p->OID); + /* Otherwise, just point at what we found */ + cur_info_p = su_info_p; + } + + /* Actually get the data */ + status = nut_snmp_get_str(cur_info_p->OID, model, sizeof(model), NULL); + + /* Free our malloc, if it was dynamic */ + if (strchr(su_info_p->OID, '%') != NULL) { + if (cur_info_p->info_type != NULL) + free((char*)cur_info_p->info_type); + if (cur_info_p->OID != NULL) + free((char*)cur_info_p->OID); + if (cur_info_p != NULL) + free((char*)cur_info_p); + } + } if (status == TRUE) upslogx(0, "Detected %s on host %s (mib: %s %s)", @@ -319,6 +686,24 @@ void upsdrv_initups(void) fatalx(EXIT_FAILURE, "%s MIB wasn't found on %s", mibs, g_snmp_sess.peername); /* FIXME: "No supported device detected" */ + /* Init daisychain and check if support is required */ + daisychain_init(); + + /* Allocate / init the daisychain info structure (for phases only for now) + * daisychain_info[0] is the whole chain! (added +1) */ + daisychain_info = (daisychain_info_t**)malloc( + sizeof(daisychain_info_t) * (size_t)(devices_count + 1) + ); + for (curdev = 0 ; curdev <= devices_count ; curdev++) { + daisychain_info[curdev] = (daisychain_info_t*)malloc(sizeof(daisychain_info_t)); + daisychain_info[curdev]->input_phases = (long)-1; + daisychain_info[curdev]->output_phases = (long)-1; + daisychain_info[curdev]->bypass_phases = (long)-1; + } + + /* FIXME: also need daisychain awareness (so init)! + * i.e load.off.delay+load.off + device.1.load.off.delay+device.1.load.off + ... */ +/* FIXME: daisychain commands support! */ if (su_find_info("load.off.delay")) { /* Adds default with a delay value of '0' (= immediate) */ dstate_addcmd("load.off"); @@ -334,10 +719,59 @@ void upsdrv_initups(void) dstate_addcmd("shutdown.return"); dstate_addcmd("shutdown.stayoff"); } + + /* Publish sysDescr, sysContact and sysLocation (from IETF standard paths) + * for all subdrivers that do not have one defined in their mapping + * tables (note: for lack of better knowledge, defined as read-only + * entries here, and also read-once - not updated during driver uptime) */ + + if (NULL == dstate_getinfo("device.description") + && NULL == dstate_getinfo("device.1.description") + ) { + /* sysDescr.0 */ + if (nut_snmp_get_str(".1.3.6.1.2.1.1.1.0", model, sizeof(model), NULL) == TRUE) { + upsdebugx(2, "Using IETF-MIB default to get and publish sysDescr for device.description (once)"); + dstate_setinfo("device.description", "%s", model); + } else { + upsdebugx(2, "Can't get and publish sysDescr for device.description"); + } + } + + if (NULL == dstate_getinfo("device.contact") + && NULL == dstate_getinfo("device.1.contact") + ) { + /* sysContact.0 */ + if (nut_snmp_get_str(".1.3.6.1.2.1.1.4.0", model, sizeof(model), NULL) == TRUE) { + upsdebugx(2, "Using IETF-MIB default to get and publish sysContact for device.contact (once)"); + dstate_setinfo("device.contact", "%s", model); + } else { + upsdebugx(2, "Can't get and publish sysContact for device.contact"); + } + } + + if (NULL == dstate_getinfo("device.location") + && NULL == dstate_getinfo("device.1.location") + ) { + /* sysLocation.0 */ + if (nut_snmp_get_str(".1.3.6.1.2.1.1.6.0", model, sizeof(model), NULL) == TRUE) { + upsdebugx(2, "Using IETF-MIB default to get and publish sysLocation for device.location (once)"); + dstate_setinfo("device.location", "%s", model); + } else { + upsdebugx(2, "Can't get and publish sysLocation for device.location"); + } + } + + /* set shutdown and autostart delay */ + set_delays(); } void upsdrv_cleanup(void) { + /* General cleanup */ + if (daisychain_info) + free(daisychain_info); + + /* Net-SNMP specific cleanup */ nut_snmp_cleanup(); } @@ -387,7 +821,18 @@ void nut_snmp_init(const char *type, const char *hostname) /* Retrieve user parameters */ version = testvar(SU_VAR_VERSION) ? getval(SU_VAR_VERSION) : "v1"; - + +/* Older CLANG (e.g. clang-3.4) sees short strings in str{n}cmp() + * arguments as arrays and claims out-of-bounds accesses + */ +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ARRAY_BOUNDS) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Warray-bounds" +#endif +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Warray-bounds" +#endif if ((strcmp(version, "v1") == 0) || (strcmp(version, "v2c") == 0)) { g_snmp_sess.version = (strcmp(version, "v1") == 0) ? SNMP_VERSION_1 : SNMP_VERSION_2c; community = testvar(SU_VAR_COMMUNITY) ? getval(SU_VAR_COMMUNITY) : "public"; @@ -395,6 +840,12 @@ void nut_snmp_init(const char *type, const char *hostname) g_snmp_sess.community_len = strlen(community); } else if (strcmp(version, "v3") == 0) { +#ifdef __clang__ +# pragma clang diagnostic pop +#endif +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ARRAY_BOUNDS) +# pragma GCC diagnostic pop +#endif /* SNMP v3 related init */ g_snmp_sess.version = SNMP_VERSION_3; @@ -445,23 +896,74 @@ void nut_snmp_init(const char *type, const char *hostname) g_snmp_sess.securityAuthKeyLen = USM_AUTH_KU_LEN; authProtocol = testvar(SU_VAR_AUTHPROT) ? getval(SU_VAR_AUTHPROT) : "MD5"; +#if NUT_HAVE_LIBNETSNMP_usmHMACMD5AuthProtocol if (strcmp(authProtocol, "MD5") == 0) { g_snmp_sess.securityAuthProto = usmHMACMD5AuthProtocol; g_snmp_sess.securityAuthProtoLen = sizeof(usmHMACMD5AuthProtocol)/sizeof(oid); } - else if (strcmp(authProtocol, "SHA") == 0) { + else +#endif +#if NUT_HAVE_LIBNETSNMP_usmHMACSHA1AuthProtocol + if (strcmp(authProtocol, "SHA") == 0) { g_snmp_sess.securityAuthProto = usmHMACSHA1AuthProtocol; g_snmp_sess.securityAuthProtoLen = sizeof(usmHMACSHA1AuthProtocol)/sizeof(oid); } else +#endif +#if NUT_HAVE_LIBNETSNMP_usmHMAC192SHA256AuthProtocol + if (strcmp(authProtocol, "SHA256") == 0) { + g_snmp_sess.securityAuthProto = usmHMAC192SHA256AuthProtocol; + g_snmp_sess.securityAuthProtoLen = sizeof(usmHMAC192SHA256AuthProtocol)/sizeof(oid); + } + else +#endif +#if NUT_HAVE_LIBNETSNMP_usmHMAC256SHA384AuthProtocol + if (strcmp(authProtocol, "SHA384") == 0) { + g_snmp_sess.securityAuthProto = usmHMAC256SHA384AuthProtocol; + g_snmp_sess.securityAuthProtoLen = sizeof(usmHMAC256SHA384AuthProtocol)/sizeof(oid); + } + else +#endif +#if NUT_HAVE_LIBNETSNMP_usmHMAC384SHA512AuthProtocol + if (strcmp(authProtocol, "SHA512") == 0) { + g_snmp_sess.securityAuthProto = usmHMAC384SHA512AuthProtocol; + g_snmp_sess.securityAuthProtoLen = sizeof(usmHMAC384SHA512AuthProtocol)/sizeof(oid); + } + else +#endif fatalx(EXIT_FAILURE, "Bad SNMPv3 authProtocol: %s", authProtocol); /* set the authentication key to a MD5/SHA1 hashed version of our * passphrase (must be at least 8 characters long) */ - if(g_snmp_sess.securityLevel != SNMP_SEC_LEVEL_NOAUTH) { + if (g_snmp_sess.securityLevel != SNMP_SEC_LEVEL_NOAUTH) { +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) ) +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE +# pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif + +/* NOTE: Net-SNMP headers just are weird like that, in the same release: +net-snmp/types.h: size_t securityAuthProtoLen; +net-snmp/library/keytools.h: int generate_Ku(const oid * hashtype, u_int hashtype_len, ... + * Should we match in configure like for "getnameinfo()" arg types? + * Currently we cast one to another, below (detecting target type could help). + */ + if ((uintmax_t)g_snmp_sess.securityAuthProtoLen > UINT_MAX) { +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) ) +# pragma GCC diagnostic pop +#endif + fatalx(EXIT_FAILURE, + "Bad SNMPv3 securityAuthProtoLen: %zu", + g_snmp_sess.securityAuthProtoLen); + } + if (generate_Ku(g_snmp_sess.securityAuthProto, - g_snmp_sess.securityAuthProtoLen, - (u_char *) authPassword, strlen(authPassword), + (u_int)g_snmp_sess.securityAuthProtoLen, + (const unsigned char *) authPassword, strlen(authPassword), g_snmp_sess.securityAuthKey, &g_snmp_sess.securityAuthKeyLen) != SNMPERR_SUCCESS) { @@ -471,24 +973,65 @@ void nut_snmp_init(const char *type, const char *hostname) privProtocol = testvar(SU_VAR_PRIVPROT) ? getval(SU_VAR_PRIVPROT) : "DES"; +#if NUT_HAVE_LIBNETSNMP_usmDESPrivProtocol if (strcmp(privProtocol, "DES") == 0) { g_snmp_sess.securityPrivProto = usmDESPrivProtocol; g_snmp_sess.securityPrivProtoLen = sizeof(usmDESPrivProtocol)/sizeof(oid); } - else if (strcmp(privProtocol, "AES") == 0) { + else +#endif +#if NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol || NUT_HAVE_LIBNETSNMP_usmAES128PrivProtocol + if (strcmp(privProtocol, "AES") == 0) { g_snmp_sess.securityPrivProto = usmAESPrivProtocol; - g_snmp_sess.securityPrivProtoLen = sizeof(usmAESPrivProtocol)/sizeof(oid); + g_snmp_sess.securityPrivProtoLen = NUT_securityPrivProtoLen; } else - fatalx(EXIT_FAILURE, "Bad SNMPv3 authProtocol: %s", authProtocol); +#endif +#if NUT_HAVE_LIBNETSNMP_DRAFT_BLUMENTHAL_AES_04 +# if NUT_HAVE_LIBNETSNMP_usmAES192PrivProtocol + if (strcmp(privProtocol, "AES192") == 0) { + g_snmp_sess.securityPrivProto = usmAES192PrivProtocol; + g_snmp_sess.securityPrivProtoLen = (sizeof(usmAES192PrivProtocol)/sizeof(oid)); + } + else +# endif +# if NUT_HAVE_LIBNETSNMP_usmAES256PrivProtocol + if (strcmp(privProtocol, "AES256") == 0) { + g_snmp_sess.securityPrivProto = usmAES256PrivProtocol; + g_snmp_sess.securityPrivProtoLen = (sizeof(usmAES256PrivProtocol)/sizeof(oid)); + } + else +# endif +#endif /* NUT_HAVE_LIBNETSNMP_DRAFT_BLUMENTHAL_AES_04 */ + fatalx(EXIT_FAILURE, "Bad SNMPv3 privProtocol: %s", privProtocol); /* set the privacy key to a MD5/SHA1 hashed version of our * passphrase (must be at least 8 characters long) */ - if(g_snmp_sess.securityLevel == SNMP_SEC_LEVEL_AUTHPRIV) { + if (g_snmp_sess.securityLevel == SNMP_SEC_LEVEL_AUTHPRIV) { g_snmp_sess.securityPrivKeyLen = USM_PRIV_KU_LEN; + +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) ) +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE +# pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif + /* See comment on generate_Ku() a few dozen lines above */ + if ((uintmax_t)g_snmp_sess.securityAuthProtoLen > UINT_MAX) { +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) ) +# pragma GCC diagnostic pop +#endif + fatalx(EXIT_FAILURE, + "Bad SNMPv3 securityAuthProtoLen: %zu", + g_snmp_sess.securityAuthProtoLen); + } + if (generate_Ku(g_snmp_sess.securityAuthProto, - g_snmp_sess.securityAuthProtoLen, - (u_char *) privPassword, strlen(privPassword), + (u_int)g_snmp_sess.securityAuthProtoLen, + (const unsigned char *) privPassword, strlen(privPassword), g_snmp_sess.securityPrivKey, &g_snmp_sess.securityPrivKeyLen) != SNMPERR_SUCCESS) { @@ -519,22 +1062,24 @@ void nut_snmp_cleanup(void) } /* Free a struct snmp_pdu * returned by nut_snmp_walk */ -void nut_snmp_free(struct snmp_pdu ** array_to_free) +static void nut_snmp_free(struct snmp_pdu ** array_to_free) { struct snmp_pdu ** current_element; - current_element = array_to_free; + if (array_to_free != NULL) { + current_element = array_to_free; - while (*current_element != NULL) { - snmp_free_pdu(*current_element); - current_element++; + while (*current_element != NULL) { + snmp_free_pdu(*current_element); + current_element++; + } + + free( array_to_free ); } - - free( array_to_free ); } /* Return a NULL terminated array of snmp_pdu * */ -struct snmp_pdu **nut_snmp_walk(const char *OID, int max_iteration) +static struct snmp_pdu **nut_snmp_walk(const char *OID, int max_iteration) { int status; struct snmp_pdu *pdu, *response = NULL; @@ -584,6 +1129,7 @@ struct snmp_pdu **nut_snmp_walk(const char *OID, int max_iteration) if (mibname == NULL) { /* We are probing for proper mib - ignore errors */ snmp_free_pdu(response); + nut_snmp_free(ret_array); return NULL; } @@ -613,7 +1159,17 @@ struct snmp_pdu **nut_snmp_walk(const char *OID, int max_iteration) nb_iteration++; /* +1 is for the terminating NULL */ - ret_array = realloc(ret_array,sizeof(struct snmp_pdu*)*(nb_iteration+1)); + struct snmp_pdu ** new_ret_array = realloc( + ret_array, + sizeof(struct snmp_pdu*) * ((size_t)nb_iteration+1) + ); + if (new_ret_array == NULL) { + upsdebugx(1, "%s: Failed to realloc thread", __func__); + break; + } + else { + ret_array = new_ret_array; + } ret_array[nb_iteration-1] = response; ret_array[nb_iteration]=NULL; @@ -662,36 +1218,57 @@ static bool_t decode_str(struct snmp_pdu *pdu, char *buf, size_t buf_len, info_l case ASN_OPAQUE: len = pdu->variables->val_len > buf_len - 1 ? buf_len - 1 : pdu->variables->val_len; - if (len > 0) { - /* Test for hexadecimal values */ - if (!isprint(pdu->variables->val.string[0])) - snprint_hexstring(buf, buf_len, pdu->variables->val.string, pdu->variables->val_len); - else { - memcpy(buf, pdu->variables->val.string, len); - buf[len] = '\0'; + /* Test for hexadecimal values */ + int hex = 0, x; + unsigned char *cp; + for(cp = pdu->variables->val.string, x = 0; x < (int)pdu->variables->val_len; x++, cp++) { + if (!(isprint((size_t)*cp) || isspace((size_t)*cp))) { + hex = 1; } } + if (hex) + snprint_hexstring(buf, buf_len, pdu->variables->val.string, pdu->variables->val_len); + else { + memcpy(buf, pdu->variables->val.string, len); + buf[len] = '\0'; + } break; case ASN_INTEGER: case ASN_COUNTER: case ASN_GAUGE: if(oid2info) { const char *str; - if((str=su_find_infoval(oid2info, *pdu->variables->val.integer))) { + /* See union netsnmp_vardata in net-snmp/types.h: "integer" is a "long*" */ + assert(sizeof(pdu->variables->val.integer) == sizeof(long*)); + /* If in future net-snmp headers val becomes not-a-pointer, + * compiler should complain about (void*) arg casting here */ + if((str = su_find_infoval(oid2info, pdu->variables->val.integer))) { strncpy(buf, str, buf_len-1); } + /* when oid2info returns NULL, don't publish the variable! */ else { - strncpy(buf, "UNKNOWN", buf_len-1); + /* strncpy(buf, "UNKNOWN", buf_len-1); */ + return FALSE; } buf[buf_len-1]='\0'; } else { - len = snprintf(buf, buf_len, "%ld", *pdu->variables->val.integer); + int ret = snprintf(buf, buf_len, "%ld", *pdu->variables->val.integer); + if (ret < 0) + upsdebugx(3, "Failed to retrieve ASN_GAUGE"); + else + len = (size_t)ret; } break; case ASN_TIMETICKS: /* convert timeticks to seconds */ - len = snprintf(buf, buf_len, "%ld", *pdu->variables->val.integer / 100); + { + int ret = snprintf(buf, buf_len, "%ld", *pdu->variables->val.integer / 100); + if (ret < 0) + upsdebugx(3, "Failed to retrieve ASN_TIMETICKS"); + else + len = (size_t)ret; + } break; case ASN_OBJECT_ID: snprint_objid (tmp_buf, sizeof(tmp_buf), pdu->variables->val.objid, pdu->variables->val_len / sizeof(oid)); @@ -704,8 +1281,6 @@ static bool_t decode_str(struct snmp_pdu *pdu, char *buf, size_t buf_len, info_l snprintf(buf, buf_len, "%s", oid_leaf+1); upsdebugx(3, "Fallback value: %s", buf); } - else - snprintf(buf, buf_len, "%s", tmp_buf); break; default: return FALSE; @@ -792,6 +1367,8 @@ bool_t nut_snmp_get_int(const char *OID, long *pval) long value; char *buf; + upsdebugx(3, "Entering %s()", __func__); + pdu = nut_snmp_get(OID); if (pdu == NULL) return FALSE; @@ -919,17 +1496,33 @@ void nut_snmp_perror(struct snmp_session *sess, int status, upsname?upsname:device_name, buf, snmperrstr); free(snmperrstr); } else if (status == STAT_SUCCESS) { +/* Net-SNMP headers provide and consume errstat with different types: +net-snmp/output_api.h: const char *snmp_errstring(int snmp_errorno); +net-snmp/types.h: long errstat; + * Should we match in configure like for "getnameinfo()" arg types? + * Currently we cast one to another, below (detecting target type could help). + */ switch (response->errstat) { case SNMP_ERR_NOERROR: break; case SNMP_ERR_NOSUCHNAME: /* harmless */ upsdebugx(2, "[%s] %s: %s", - upsname?upsname:device_name, buf, snmp_errstring(response->errstat)); + upsname?upsname:device_name, + buf, + (response->errstat > INT_MAX + ? "(Net-SNMP errstat value is out of range)" + : snmp_errstring((int)response->errstat) + )); break; default: upslogx(LOG_ERR, "[%s] %s: Error in packet: %s", - upsname?upsname:device_name, buf, snmp_errstring(response->errstat)); + upsname?upsname:device_name, + buf, + (response->errstat > INT_MAX + ? "(Net-SNMP errstat value is out of range)" + : snmp_errstring((int)response->errstat) + )); break; } } else if (status == STAT_TIMEOUT) { @@ -954,7 +1547,15 @@ static void disable_transfer_oids(void) upslogx(LOG_INFO, "Disabling transfer OIDs"); - for (su_info_p = &snmp_info[0]; su_info_p->info_type != NULL ; su_info_p++) { + if (snmp_info == NULL) { + fatalx(EXIT_FAILURE, "%s: snmp_info is not initialized", __func__); + } + + if (snmp_info[0].info_type == NULL) { + upsdebugx(1, "%s: WARNING: snmp_info is empty", __func__); + } + + for (su_info_p = &snmp_info[0]; (su_info_p != NULL && su_info_p->info_type != NULL) ; su_info_p++) { if (!strcasecmp(su_info_p->info_type, "input.transfer.low")) { su_info_p->flags &= ~SU_FLAG_OK; continue; @@ -967,12 +1568,87 @@ static void disable_transfer_oids(void) } } -/* universal function to add or update info element. */ +/* Universal function to add or update info element. + * If value is NULL, use the default one (su_info_p->dfl) if provided */ void su_setinfo(snmp_info_t *su_info_p, const char *value) { info_lkp_t *info_lkp; + char info_type[128]; /* We tweak incoming "su_info_p->info_type" value in some cases */ - upsdebugx(1, "entering %s(%s)", __func__, su_info_p->info_type); +/* FIXME: Replace hardcoded 128 with a macro above (use {SU_}LARGEBUF?), + * and same macro or sizeof(info_type) below (also more 128 cases below)? + */ + + upsdebugx(1, "entering %s(%s, %s)", __func__, su_info_p->info_type, (value)?value:""); + +/* FIXME: This 20 seems very wrong (should be "128", macro or sizeof? see above) */ + memset(info_type, 0, 20); + /* pre-fill with the device name for checking */ + snprintf(info_type, 128, "device.%i", current_device_number); + + /* Daisy-chain template magic should only apply to defaulted + * entries (oid==null) or templated entries (contains .%i); + * however at this point we see exact OIDs handed down from + * su_ups_get() which instantiates a template (if needed - + * and knows it was a template) and calls su_setinfo(). + * NOTE: For setting the values (or commands) from clients + * like `upsrw`, see su_setOID() method. Here we change our + * device state records based on readings from a device. + */ + if ((daisychain_enabled == TRUE) && (devices_count > 1)) { + if (su_info_p->OID != NULL + && strstr(su_info_p->OID, ".%i") != NULL + ) { + /* Only inform, do not react so far, + * need more understanding if and when + * such situation might happen at all: + */ + upsdebugx(5, "%s: in a daisy-chained device, " + "got a templated OID %s for type %s", + __func__, su_info_p->OID, + su_info_p->info_type); + } + + /* Only append "device.X" for master and slaves, if not already done! */ + if ((current_device_number > 0) && (strstr(su_info_p->info_type, info_type) == NULL)) { + /* Special case: we remove "device" from the device collection not to + * get "device.X.device.", but "device.X." */ + if (!strncmp(su_info_p->info_type, "device.", 7)) { + upsdebugx(6, "%s: in a daisy-chained device, " + "OID %s: TRIM 'device.' from type %s (value %s)", + __func__, su_info_p->OID, + su_info_p->info_type, (value)?value:""); + snprintf(info_type, 128, "device.%i.%s", + current_device_number, su_info_p->info_type + 7); + } + else { + upsdebugx(6, "%s: in a daisy-chained device, " + "OID %s is templated: for type %s (value %s)", + __func__, su_info_p->OID, + su_info_p->info_type, (value)?value:""); + snprintf(info_type, 128, "device.%i.%s", + current_device_number, su_info_p->info_type); + } + } + else { + upsdebugx(6, "%s: in a daisy-chained device, " + "OID %s: for type %s (value %s) " + "device %d is not positive or type already " + "contains the prepared expectation: %s", + __func__, su_info_p->OID, + su_info_p->info_type, (value)?value:"", + current_device_number, + info_type + ); + snprintf(info_type, 128, "%s", su_info_p->info_type); + } + } + else { + upsdebugx(6, "%s: NOT in a daisy-chained device", __func__); + snprintf(info_type, 128, "%s", su_info_p->info_type); + } + + upsdebugx(1, "%s: using info_type '%s'", __func__, info_type); if (SU_TYPE(su_info_p) == SU_TYPE_CMD) return; @@ -983,15 +1659,20 @@ void su_setinfo(snmp_info_t *su_info_p, const char *value) && (strcasecmp(strrchr(su_info_p->info_type, '.'), ".alarm"))) { if (value != NULL) - dstate_setinfo(su_info_p->info_type, "%s", value); - else - dstate_setinfo(su_info_p->info_type, "%s", su_info_p->dfl); + dstate_setinfo(info_type, "%s", value); + else if (su_info_p->dfl != NULL) + dstate_setinfo(info_type, "%s", su_info_p->dfl); + else { + upsdebugx(3, "%s: no value nor default provided, aborting...", __func__); + return; + } - dstate_setflags(su_info_p->info_type, su_info_p->info_flags); - dstate_setaux(su_info_p->info_type, su_info_p->info_len); + dstate_setflags(info_type, su_info_p->info_flags); + dstate_setaux(info_type, su_info_p->info_len); /* Set enumerated values, only if the data has ST_FLAG_RW and there * are lookup values */ +/* FIXME: daisychain settings support: check if applicable */ if ((su_info_p->info_flags & ST_FLAG_RW) && su_info_p->oid2info) { upsdebugx(3, "%s: adding enumerated values", __func__); @@ -999,7 +1680,7 @@ void su_setinfo(snmp_info_t *su_info_p, const char *value) /* Loop on all existing values */ for (info_lkp = su_info_p->oid2info; info_lkp != NULL && info_lkp->info_value != NULL; info_lkp++) { - dstate_addenum(su_info_p->info_type, "%s", info_lkp->info_value); + dstate_addenum(info_type, "%s", info_lkp->info_value); } } @@ -1015,9 +1696,9 @@ void su_status_set(snmp_info_t *su_info_p, long value) upsdebugx(2, "SNMP UPS driver: entering %s()", __func__); - if ((info_value = su_find_infoval(su_info_p->oid2info, value)) != NULL) + if ((info_value = su_find_infoval(su_info_p->oid2info, &value)) != NULL) { - if (strcmp(info_value, "")) { + if (info_value[0] != '\0') { status_set(info_value); } } @@ -1027,20 +1708,36 @@ void su_status_set(snmp_info_t *su_info_p, long value) void su_alarm_set(snmp_info_t *su_info_p, long value) { const char *info_value = NULL; + const char *info_type = NULL; char alarm_info_value[SU_LARGEBUF]; /* number of the outlet or phase */ int item_number = -1; upsdebugx(2, "SNMP UPS driver: entering %s(%s)", __func__, su_info_p->info_type); - if ((info_value = su_find_infoval(su_info_p->oid2info, value)) != NULL + /* daisychain handling + * extract the template part to get the relevant 'info_type' part + * ex: device.6.L1.alarm => L1.alarm + * ex: device.6.outlet.1.alarm => outlet.1.alarm */ + if (!strncmp(su_info_p->info_type, "device.", 7)) { + info_type = strchr(su_info_p->info_type + 7, '.') + 1; + } + else + info_type = su_info_p->info_type; + + upsdebugx(2, "%s: using definition %s", __func__, info_type); + + if ((info_value = su_find_infoval(su_info_p->oid2info, &value)) != NULL && info_value[0] != 0) { /* Special handling for outlet & outlet groups alarms */ if ((su_info_p->flags & SU_OUTLET) || (su_info_p->flags & SU_OUTLET_GROUP)) { /* Extract template number */ - item_number = extract_template_number(su_info_p->flags, su_info_p->info_type); + item_number = extract_template_number(su_info_p->flags, info_type); + + upsdebugx(2, "%s: appending %s %i", __func__, + (su_info_p->flags & SU_OUTLET_GROUP) ? "outlet group" : "outlet", item_number); /* Inject in the alarm string */ snprintf(alarm_info_value, sizeof(alarm_info_value), @@ -1051,14 +1748,17 @@ void su_alarm_set(snmp_info_t *su_info_p, long value) /* Special handling for phase alarms * Note that SU_*PHASE flags are cleared, so match the 'Lx' * start of path */ - if (su_info_p->info_type[0] == 'L') { + if (info_type[0] == 'L') { /* Extract phase number */ - item_number = atoi(su_info_p->info_type+1); + item_number = atoi(info_type+1); + char alarm_info_value_more[SU_LARGEBUF + 32]; /* can sprintf() SU_LARGEBUF plus markup into here */ + + upsdebugx(2, "%s: appending phase L%i", __func__, item_number); /* Inject in the alarm string */ - snprintf(alarm_info_value, sizeof(alarm_info_value), + snprintf(alarm_info_value_more, sizeof(alarm_info_value_more), "phase L%i %s", item_number, info_value); - info_value = &alarm_info_value[0]; + info_value = &alarm_info_value_more[0]; } /* Set the alarm value */ @@ -1072,7 +1772,15 @@ snmp_info_t *su_find_info(const char *type) { snmp_info_t *su_info_p; - for (su_info_p = &snmp_info[0]; su_info_p->info_type != NULL ; su_info_p++) + if (snmp_info == NULL) { + fatalx(EXIT_FAILURE, "%s: snmp_info is not initialized", __func__); + } + + if (snmp_info[0].info_type == NULL) { + upsdebugx(1, "%s: WARNING: snmp_info is empty", __func__); + } + + for (su_info_p = &snmp_info[0]; (su_info_p != NULL && su_info_p->info_type != NULL) ; su_info_p++) if (!strcasecmp(su_info_p->info_type, type)) { upsdebugx(3, "%s: \"%s\" found", __func__, type); return su_info_p; @@ -1082,13 +1790,73 @@ snmp_info_t *su_find_info(const char *type) return NULL; } +/* Counter match the sysOID using {device,ups}.model OID + * Return TRUE if this OID can be retrieved, FALSE otherwise */ +static bool_t match_model_OID() +{ + bool_t retCode = FALSE; + snmp_info_t *su_info_p, *cur_info_p; + char testOID_buf[LARGEBUF]; + + /* Try to get device.model first */ + su_info_p = su_find_info("device.model"); + /* Otherwise, try to get ups.model */ + if (su_info_p == NULL) + su_info_p = su_find_info("ups.model"); + + if (su_info_p != NULL) { + /* Daisychain specific: we may have a template (including formatting + * string) that needs to be adapted! */ + if (strchr(su_info_p->OID, '%') != NULL) + { + upsdebugx(2, "Found template, need to be adapted"); + cur_info_p = (snmp_info_t *)malloc(sizeof(snmp_info_t)); + cur_info_p->info_type = (char *)xmalloc(SU_INFOSIZE); + cur_info_p->OID = (char *)xmalloc(SU_INFOSIZE); + snprintf((char*)cur_info_p->info_type, SU_INFOSIZE, "%s", su_info_p->info_type); + /* Use the daisychain master (0) / 1rst device index */ +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + snprintf((char*)cur_info_p->OID, SU_INFOSIZE, su_info_p->OID, 0); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif + } + else { + upsdebugx(2, "Found entry, not a template %s", su_info_p->OID); + /* Otherwise, just point at what we found */ + cur_info_p = su_info_p; + } + + upsdebugx(2, "Testing %s using OID %s", cur_info_p->info_type, cur_info_p->OID); + retCode = nut_snmp_get_str(cur_info_p->OID, testOID_buf, LARGEBUF, NULL); + + /* Free our malloc, if it was dynamic */ + if (strchr(su_info_p->OID, '%') != NULL) { + if (cur_info_p->info_type != NULL) + free((char*)cur_info_p->info_type); + if (cur_info_p->OID != NULL) + free((char*)cur_info_p->OID); + if (cur_info_p != NULL) + free((char*)cur_info_p); + } + } + + return retCode; +} + /* Try to find the MIB using sysOID matching. * Return a pointer to a mib2nut definition if found, NULL otherwise */ -mib2nut_info_t *match_sysoid() +static mib2nut_info_t *match_sysoid() { - snmp_info_t *su_info_p; char sysOID_buf[LARGEBUF]; - char testOID_buf[LARGEBUF]; oid device_sysOID[MAX_OID_LEN]; size_t device_sysOID_len = MAX_OID_LEN; oid mib2nut_sysOID[MAX_OID_LEN]; @@ -1106,7 +1874,7 @@ mib2nut_info_t *match_sysoid() upsdebugx(2, "%s: can't build device_sysOID %s: %s", __func__, sysOID_buf, snmp_api_errstring(snmp_errno)); - return FALSE; + return NULL; } /* Now, iterate on mib2nut definitions */ @@ -1118,7 +1886,7 @@ mib2nut_info_t *match_sysoid() continue; /* Clear variables */ - memset(mib2nut_sysOID, 0, MAX_OID_LEN); + memset(mib2nut_sysOID, 0, sizeof(mib2nut_sysOID)); mib2nut_sysOID_len = MAX_OID_LEN; if (!read_objid(mib2nut[i]->sysOID, mib2nut_sysOID, &mib2nut_sysOID_len)) @@ -1129,6 +1897,7 @@ mib2nut_info_t *match_sysoid() /* Try to continue anyway! */ continue; } + /* Now compare these */ upsdebugx(1, "%s: comparing %s with %s", __func__, sysOID_buf, mib2nut[i]->sysOID); if (!netsnmp_oid_equals(device_sysOID, device_sysOID_len, mib2nut_sysOID, mib2nut_sysOID_len)) @@ -1136,24 +1905,33 @@ mib2nut_info_t *match_sysoid() upsdebugx(2, "%s: sysOID matches MIB '%s'!", __func__, mib2nut[i]->mib_name); /* Counter verify, using {ups,device}.model */ snmp_info = mib2nut[i]->snmp_info; - su_info_p = su_find_info("ups.model"); - /* Try to get device.model if ups.model is not available */ - if (su_info_p == NULL) - su_info_p = su_find_info("device.model"); - if (su_info_p != NULL) { - upsdebugx(2, "Testing %s using OID %s", su_info_p->info_type, su_info_p->OID); - if (nut_snmp_get_str(su_info_p->OID, testOID_buf, LARGEBUF, NULL) != TRUE) { - upsdebugx(2, "%s: testOID provided and doesn't match MIB '%s'!", __func__, mib2nut[i]->mib_name); - snmp_info = NULL; - continue; - } - else - upsdebugx(2, "%s: testOID provided and matches MIB '%s'!", __func__, mib2nut[i]->mib_name); + if (snmp_info == NULL) { + upsdebugx(0, "%s: WARNING: snmp_info is not initialized " + "for mapping table entry #%d \"%s\"", + __func__, i, mib2nut[i]->mib_name + ); + continue; } + else if (snmp_info[0].info_type == NULL) { + upsdebugx(1, "%s: WARNING: snmp_info is empty " + "for mapping table entry #%d \"%s\"", + __func__, i, mib2nut[i]->mib_name); + } + + if (match_model_OID() != TRUE) + { + upsdebugx(2, "%s: testOID provided and doesn't match MIB '%s'!", __func__, mib2nut[i]->mib_name); + snmp_info = NULL; + continue; + } + else + upsdebugx(2, "%s: testOID provided and matches MIB '%s'!", __func__, mib2nut[i]->mib_name); + return mib2nut[i]; } } + /* Yell all to call for user report */ upslogx(LOG_ERR, "No matching MIB found for sysOID '%s'!\n" \ "Please report it to NUT developers, with an 'upsc' output for your device.\n" \ @@ -1170,19 +1948,39 @@ mib2nut_info_t *match_sysoid() bool_t load_mib2nut(const char *mib) { int i; - char buf[LARGEBUF]; - snmp_info_t *su_info_p; mib2nut_info_t *m2n = NULL; + /* Below we have many checks for "auto"; avoid redundant string walks: */ + bool_t mibIsAuto = (0 == strcmp(mib, "auto")); + bool_t mibSeen = FALSE; /* Did we see the MIB name while walking mib2nut[]? */ - upsdebugx(2, "SNMP UPS driver: entering %s(%s)", __func__, mib); + upsdebugx(1, "SNMP UPS driver: entering %s(%s) to detect " + "proper MIB for device [%s] (host %s)", + __func__, mib, + upsname ? upsname : device_name, + device_path /* the "port" from config section is hostname/IP for networked drivers */ + ); /* First, try to match against sysOID, if no MIB was provided. * This should speed up init stage * (Note: sysOID points the device main MIB entry point) */ - if (!strcmp(mib, "auto")) + if (mibIsAuto) { - upsdebugx(1, "trying the new match_sysoid() method"); - m2n = match_sysoid(); + upsdebugx(2, "%s: trying the new match_sysoid() method with %s", + __func__, mib); + /* Retry at most 3 times, to maximise chances */ + for (i = 0; i < 3 ; i++) { + upsdebugx(3, "%s: trying the new match_sysoid() method: attempt #%d", + __func__, (i+1)); + if ((m2n = match_sysoid()) != NULL) + break; + + if (m2n == NULL) + upsdebugx(3, "%s: failed with new match_sysoid() method", + __func__); + else + upsdebugx(3, "%s: found something with new match_sysoid() method", + __func__); + } } /* Otherwise, revert to the classic method */ @@ -1190,28 +1988,52 @@ bool_t load_mib2nut(const char *mib) { for (i = 0; mib2nut[i] != NULL; i++) { /* Is there already a MIB name provided? */ - if (strcmp(mib, "auto") && strcmp(mib, mib2nut[i]->mib_name)) { + upsdebugx(4, "%s: checking against mapping table entry #%d \"%s\"", + __func__, i, mib2nut[i]->mib_name); + if (!mibIsAuto && strcmp(mib, mib2nut[i]->mib_name)) { + /* "mib" is neither "auto" nor the name in mapping table */ + upsdebugx(2, "%s: skip the \"%s\" entry which " + "is neither \"auto\" nor a valid name in the mapping table", + __func__, mib); continue; } - upsdebugx(1, "load_mib2nut: trying classic method with '%s' mib", mib2nut[i]->mib_name); + upsdebugx(2, "%s: trying classic sysOID matching method with '%s' mib", + __func__, mib2nut[i]->mib_name); /* Classic method: test an OID specific to this MIB */ snmp_info = mib2nut[i]->snmp_info; - su_info_p = su_find_info("ups.model"); - /* Try to get device.model if ups.model is not available */ - if (su_info_p == NULL) - su_info_p = su_find_info("device.model"); - if (su_info_p != NULL) { - upsdebugx(2, "Testing %s using OID %s", su_info_p->info_type, su_info_p->OID); - if (nut_snmp_get_str(su_info_p->OID, buf, LARGEBUF, NULL) != TRUE) { - upsdebugx(2, "%s: testOID provided and doesn't match MIB '%s'!", __func__, mib2nut[i]->mib_name); - snmp_info = NULL; - continue; - } - else - upsdebugx(2, "%s: testOID provided and matches MIB '%s'!", __func__, mib2nut[i]->mib_name); + if (snmp_info == NULL) { + upsdebugx(0, "%s: WARNING: snmp_info is not initialized " + "for mapping table entry #%d \"%s\"", + __func__, i, mib2nut[i]->mib_name + ); + continue; } + else if (snmp_info[0].info_type == NULL) { + upsdebugx(1, "%s: WARNING: snmp_info is empty " + "for mapping table entry #%d \"%s\"", + __func__, i, mib2nut[i]->mib_name); + } + + /* Device might not support this MIB, but we want to + * track that the name string is valid for diags below + */ + if (!mibIsAuto) { + mibSeen = TRUE; + } + + if (match_model_OID() != TRUE) + { + upsdebugx(3, "%s: testOID provided and doesn't match MIB '%s'!", + __func__, mib2nut[i]->mib_name); + snmp_info = NULL; + continue; + } + else + upsdebugx(3, "%s: testOID provided and matches MIB '%s'!", + __func__, mib2nut[i]->mib_name); + /* MIB found */ m2n = mib2nut[i]; break; @@ -1226,16 +2048,31 @@ bool_t load_mib2nut(const char *mib) mibname = m2n->mib_name; mibvers = m2n->mib_version; alarms_info = m2n->alarms_info; - upsdebugx(1, "load_mib2nut: using %s mib", mibname); + upsdebugx(1, "%s: using %s MIB for device [%s] (host %s)", + __func__, mibname, + upsname ? upsname : device_name, device_path); return TRUE; } /* Did we find something or is it really an unknown mib */ - if (strcmp(mib, "auto") != 0) { - fatalx(EXIT_FAILURE, "Unknown mibs value: %s", mib); + if (!mibIsAuto) { + if (mibSeen) { + fatalx(EXIT_FAILURE, "Requested 'mibs' value '%s' " + "did not match this device [%s] (host %s)", + mib, upsname ? upsname : device_name, device_path); + } else { + /* String not seen during mib2nut[] walk - + * and if we had no hits, we walked it all + */ + fatalx(EXIT_FAILURE, "Unknown 'mibs' value: %s", mib); + } } else { - fatalx(EXIT_FAILURE, "No supported device detected"); + fatalx(EXIT_FAILURE, "No supported device detected at [%s] (host %s)", + upsname ? upsname : device_name, device_path); } + + /* Should not get here thanks to fatalx() above, but need to silence a warning */ + return FALSE; } /* find the OID value matching that INFO_* value */ @@ -1257,11 +2094,42 @@ long su_find_valinfo(info_lkp_t *oid2info, const char* value) return -1; } -/* find the INFO_* value matching that OID value */ -const char *su_find_infoval(info_lkp_t *oid2info, long value) +/* String reformating function */ +const char *su_find_strval(info_lkp_t *oid2info, void *value) +{ +#if WITH_SNMP_LKP_FUN + /* First test if we have a generic lookup function */ + if ( (oid2info != NULL) && (oid2info->fun_vp2s != NULL) ) { + upsdebugx(2, "%s: using generic lookup function (string reformatting)", __func__); + const char * retvalue = oid2info->fun_vp2s(value); + upsdebugx(2, "%s: got value '%s'", __func__, retvalue); + return retvalue; + } + upsdebugx(1, "%s: no result value for this OID string value (%s)", __func__, (char*)value); +#else + NUT_UNUSED_VARIABLE(oid2info); + upsdebugx(1, "%s: no mapping function for this OID string value (%s)", __func__, (char*)value); +#endif // WITH_SNMP_LKP_FUN + return NULL; +} + +/* find the INFO_* value matching that OID numeric (long) value */ +const char *su_find_infoval(info_lkp_t *oid2info, void *raw_value) { info_lkp_t *info_lkp; + long value = *((long *)raw_value); +#if WITH_SNMP_LKP_FUN + /* First test if we have a generic lookup function */ + if ( (oid2info != NULL) && (oid2info->fun_vp2s != NULL) ) { + upsdebugx(2, "%s: using generic lookup function", __func__); + const char * retvalue = oid2info->fun_vp2s(raw_value); + upsdebugx(2, "%s: got value '%s'", __func__, retvalue); + return retvalue; + } +#endif // WITH_SNMP_LKP_FUN + + /* Otherwise, use the simple values mapping */ for (info_lkp = oid2info; (info_lkp != NULL) && (info_lkp->info_value != NULL) && (strcmp(info_lkp->info_value, "NULL")); info_lkp++) { @@ -1281,7 +2149,15 @@ static void disable_competition(snmp_info_t *entry) { snmp_info_t *p; - for(p=snmp_info; p->info_type!=NULL; p++) { + if (snmp_info == NULL) { + fatalx(EXIT_FAILURE, "%s: snmp_info is not initialized", __func__); + } + + if (snmp_info[0].info_type == NULL) { + upsdebugx(1, "%s: WARNING: snmp_info is empty", __func__); + } + + for(p = snmp_info; (p != NULL && p->info_type != NULL) ; p++) { if(p!=entry && !strcmp(p->info_type, entry->info_type)) { upsdebugx(2, "%s: disabling %s %s", __func__, p->info_type, p->OID); @@ -1290,16 +2166,71 @@ static void disable_competition(snmp_info_t *entry) } } +/* set shutdown and/or start delays */ +void set_delays(void) +{ + int ondelay, offdelay; + char su_scratch_buf[255]; + + if (getval(SU_VAR_ONDELAY)) + ondelay = atoi(getval(SU_VAR_ONDELAY)); + else + ondelay = -1; + + if (getval(SU_VAR_OFFDELAY)) + offdelay = atoi(getval(SU_VAR_OFFDELAY)); + else + offdelay = -1; + + if (ondelay >= 0) { + sprintf(su_scratch_buf, "%d", ondelay); + su_setvar("ups.delay.start", su_scratch_buf); + } + + if (offdelay >= 0) { + sprintf(su_scratch_buf, "%d", offdelay); + su_setvar("ups.delay.shutdown", su_scratch_buf); + } +} + /*********************************************************************** * Template handling functions **********************************************************************/ -/* Instantiate an snmp_info_t from a template. - * Useful for outlet and outlet.group templates. - * Note: remember to adapt info_type, OID and optionaly dfl */ -snmp_info_t *instantiate_info(snmp_info_t *info_template, snmp_info_t *new_instance) +/* Test if the template is a multiple one, i.e. with a formatting string that + * contains multiple "%i". + * Return TRUE if yes (multiple "%i" found), FALSE otherwise */ +static bool_t is_multiple_template(const char *OID_template) { - upsdebugx(1, "%s(%s)", __func__, info_template->info_type); + bool_t retCode = FALSE; + char *format_char = NULL; + + if (OID_template) { + format_char = strchr(OID_template, '%'); + upsdebugx(4, "%s(%s)", __func__, OID_template); + } + else + upsdebugx(4, "%s(NULL)", __func__); + + if (format_char != NULL) { + if (strchr(format_char + 1, '%') != NULL) { + retCode = TRUE; + } + } + + upsdebugx(4, "%s: has %smultiple template definition", + __func__, (retCode == FALSE)?"not ":""); + + return retCode; +} + +/* Instantiate an snmp_info_t from a template. + * Useful for device, outlet, outlet.group and ambient templates. + * Note: remember to adapt info_type, OID and optionaly dfl */ +static snmp_info_t *instantiate_info(snmp_info_t *info_template, snmp_info_t *new_instance) +{ + upsdebugx(1, "%s(%s)", __func__, + info_template ? info_template->info_type : "n/a"); /* sanity check */ if (info_template == NULL) @@ -1307,19 +2238,27 @@ snmp_info_t *instantiate_info(snmp_info_t *info_template, snmp_info_t *new_insta if (new_instance == NULL) new_instance = (snmp_info_t *)xmalloc(sizeof(snmp_info_t)); + /* TOTHINK: Should there be an "else" to free() + * the fields which we (re-)allocate below? */ new_instance->info_type = (char *)xmalloc(SU_INFOSIZE); - if (info_template->OID != NULL) + if (new_instance->info_type) + memset((char *)new_instance->info_type, 0, SU_INFOSIZE); + if (info_template->OID != NULL) { new_instance->OID = (char *)xmalloc(SU_INFOSIZE); - else + if (new_instance->OID) + memset((char *)new_instance->OID, 0, SU_INFOSIZE); + } + else { new_instance->OID = NULL; + } + new_instance->info_flags = info_template->info_flags; new_instance->info_len = info_template->info_len; /* FIXME: check if we need to adapt this one... */ new_instance->dfl = info_template->dfl; new_instance->flags = info_template->flags; new_instance->oid2info = info_template->oid2info; - new_instance->setvar = info_template->setvar; upsdebugx(2, "instantiate_info: template instantiated"); return new_instance; @@ -1327,7 +2266,7 @@ snmp_info_t *instantiate_info(snmp_info_t *info_template, snmp_info_t *new_insta /* Free a dynamically allocated snmp_info_t. * Useful for outlet and outlet.group templates */ -void free_info(snmp_info_t *su_info_p) +static void free_info(snmp_info_t *su_info_p) { /* sanity check */ if (su_info_p == NULL) @@ -1344,52 +2283,161 @@ void free_info(snmp_info_t *su_info_p) /* return the base SNMP index (0 or 1) to start template iteration on * the MIB, based on a test using a template OID */ -int base_snmp_template_index(const char *OID_template) +static int base_snmp_template_index(const snmp_info_t *su_info_p) { - int base_index = template_index_base; + if (!su_info_p) + return -1; + + int base_index = -1; char test_OID[SU_INFOSIZE]; + snmp_info_flags_t template_type = get_template_type(su_info_p->info_type); + + if (!su_info_p->OID) + return base_index; + + upsdebugx(3, "%s: OID template = %s", __func__, su_info_p->OID); + + /* Try to differentiate between template types which may have + * different indexes ; and store it to not redo it again */ + switch (template_type) { + case SU_OUTLET: + template_index_base = outlet_template_index_base; + break; + case SU_OUTLET_GROUP: + template_index_base = outletgroup_template_index_base; + break; + case SU_DAISY: + template_index_base = device_template_index_base; + break; + case SU_AMBIENT_TEMPLATE: + template_index_base = ambient_template_index_base; + break; + default: + /* we should never fall here! */ + upsdebugx(3, "%s: unknown template type '%" PRI_SU_FLAGS "' for %s", + __func__, template_type, su_info_p->info_type); + } + base_index = template_index_base; if (template_index_base == -1) { /* not initialised yet */ for (base_index = 0 ; base_index < 2 ; base_index++) { - snprintf(test_OID, sizeof(test_OID), OID_template, base_index); - if (nut_snmp_get(test_OID) != NULL) - break; - } - template_index_base = base_index; - } - upsdebugx(3, "%s: %i", __func__, template_index_base); - return base_index; -} +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + /* Test if this template also includes daisychain, in which case + * we just use the current device index */ + if (is_multiple_template(su_info_p->OID) == TRUE) { + if (su_info_p->flags & SU_TYPE_DAISY_1) { + snprintf(test_OID, sizeof(test_OID), su_info_p->OID, + current_device_number + device_template_offset, base_index); + } + else { + snprintf(test_OID, sizeof(test_OID), su_info_p->OID, + base_index, current_device_number + device_template_offset); + } + } + else { + snprintf(test_OID, sizeof(test_OID), su_info_p->OID, base_index); + } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif -/* return the NUT offset (increment) based on template_index_base - * ie (template_index_base == 0) => increment +1 - * (template_index_base == 1) => increment +0 */ -int base_nut_template_offset(void) -{ - return (template_index_base==0)?1:0; + if (nut_snmp_get(test_OID) != NULL) { + if (su_info_p->flags & SU_FLAG_ZEROINVALID) { + long value; + if ((nut_snmp_get_int(test_OID, &value)) && (value!=0)) { + break; + } + } + else if (su_info_p->flags & SU_FLAG_NAINVALID) { + char value[SU_BUFSIZE]; + if ((nut_snmp_get_str(test_OID, value, SU_BUFSIZE, NULL)) + && (strncmp(value, "N/A", 3))) { + break; + } + } + else { + break; + } + } + } + /* Only store if it's a template for outlets or outlets groups, + * not for daisychain (which has different index) */ + if (su_info_p->flags & SU_OUTLET) + outlet_template_index_base = base_index; + else if (su_info_p->flags & SU_OUTLET_GROUP) + outletgroup_template_index_base = base_index; + else if (su_info_p->flags & SU_AMBIENT_TEMPLATE) + ambient_template_index_base = base_index; + else + device_template_index_base = base_index; + } + upsdebugx(3, "%s: template_index_base = %i", __func__, base_index); + return base_index; } /* Try to determine the number of items (outlets, outlet groups, ...), * using a template definition. Walk through the template until we can't * get anymore values. I.e., if we can iterate up to 8 item, return 8 */ -static int guestimate_template_count(const char *OID_template) +static int guestimate_template_count(snmp_info_t *su_info_p) { int base_index = 0; char test_OID[SU_INFOSIZE]; int base_count; + const char *OID_template = su_info_p->OID; upsdebugx(1, "%s(%s)", __func__, OID_template); /* Determine if OID index starts from 0 or 1? */ +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(test_OID, sizeof(test_OID), OID_template, base_index); - if (nut_snmp_get(test_OID) == NULL) +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif + if (nut_snmp_get(test_OID) == NULL) { base_index++; + } + else { + if (su_info_p->flags & SU_FLAG_ZEROINVALID) { + long value; + if ((nut_snmp_get_int(test_OID, &value)) && (value==0)) { + base_index++; + } + } + } /* Now, actually iterate */ for (base_count = 0 ; ; base_count++) { +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif snprintf(test_OID, sizeof(test_OID), OID_template, base_index + base_count); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif if (nut_snmp_get(test_OID) == NULL) break; } @@ -1400,8 +2448,8 @@ static int guestimate_template_count(const char *OID_template) /* Process template definition, instantiate and get data or register * command - * type: outlet, outlet.group */ -bool_t process_template(int mode, const char* type, snmp_info_t *su_info_p) + * type: outlet, outlet.group, device */ +static bool_t process_template(int mode, const char* type, snmp_info_t *su_info_p) { /* Default to TRUE, and leave to get_and_process_data() to set * to FALSE when actually getting data from devices, to avoid false @@ -1410,37 +2458,162 @@ bool_t process_template(int mode, const char* type, snmp_info_t *su_info_p) int cur_template_number = 1; int cur_nut_index = 0; int template_count = 0; + int base_snmp_index = 0; snmp_info_t cur_info_p; - char template_count_var[SU_BUFSIZE]; + char template_count_var[SU_BUFSIZE * 2]; + /* Needed *2 to fit a max size_t in snprintf() below, + * even if that should never happen */ + char tmp_buf[SU_INFOSIZE]; upsdebugx(1, "%s template definition found (%s)...", type, su_info_p->info_type); - snprintf(template_count_var, sizeof(template_count_var), "%s.count", type); + if ((strncmp(type, "device", 6)) && (devices_count > 1) && (current_device_number > 0)) { + snprintf(template_count_var, sizeof(template_count_var), "device.%i.%s.count", current_device_number, type); + } else { + snprintf(template_count_var, sizeof(template_count_var), "%s.count", type); + } if(dstate_getinfo(template_count_var) == NULL) { /* FIXME: should we disable it? * su_info_p->flags &= ~SU_FLAG_OK; * or rely on guestimation? */ - template_count = guestimate_template_count(su_info_p->OID); + template_count = guestimate_template_count(su_info_p); /* Publish the count estimation */ - dstate_setinfo(template_count_var, "%i", template_count); + if (template_count > 0) { + dstate_setinfo(template_count_var, "%i", template_count); + } } else { template_count = atoi(dstate_getinfo(template_count_var)); } + upsdebugx(1, "%i instances found...", template_count); /* Only instantiate templates if needed! */ if (template_count > 0) { /* general init of data using the template */ instantiate_info(su_info_p, &cur_info_p); - for (cur_template_number = base_snmp_template_index(su_info_p->OID) ; - cur_template_number < (template_count + base_snmp_template_index(su_info_p->OID)) ; + base_snmp_index = base_snmp_template_index(su_info_p); + + for (cur_template_number = base_snmp_index ; + cur_template_number < (template_count + base_snmp_index) ; cur_template_number++) { - cur_nut_index = cur_template_number + base_nut_template_offset(); - snprintf((char*)cur_info_p.info_type, SU_INFOSIZE, - su_info_p->info_type, cur_nut_index); + upsdebugx(1, "Processing instance %i/%i...", cur_template_number, template_count); + /* Special processing for daisychain: + * append 'device.x' to the NUT variable name, except for the + * whole daisychain ("device.0") */ + if (!strncmp(type, "device", 6)) + { + /* Device(s) 1-N (master + slave(s)) need to append 'device.x' */ + if (current_device_number > 0) { + char *ptr = NULL; + /* Another special processing for daisychain + * device collection needs special appending */ + if (!strncmp(su_info_p->info_type, "device.", 7)) + ptr = (char*)&su_info_p->info_type[7]; + else + ptr = (char*)su_info_p->info_type; + + snprintf((char*)cur_info_p.info_type, SU_INFOSIZE, + "device.%i.%s", current_device_number, ptr); + } + else + { + /* Device 1 ("device.0", whole daisychain) needs no + * special processing */ + cur_nut_index = cur_template_number; +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + snprintf((char*)cur_info_p.info_type, SU_INFOSIZE, + su_info_p->info_type, cur_nut_index); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif + } + } + else if (!strncmp(type, "outlet", 6)) /* Outlet and outlet groups templates */ + { + /* Get the index of the current template instance */ + cur_nut_index = cur_template_number; + +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + /* Special processing for daisychain */ + if (daisychain_enabled == TRUE) { + /* Device(s) 1-N (master + slave(s)) need to append 'device.x' */ + if ((devices_count > 1) && (current_device_number > 0)) { + memset(&tmp_buf[0], 0, SU_INFOSIZE); + strcat(&tmp_buf[0], "device.%i."); + strcat(&tmp_buf[0], su_info_p->info_type); + + upsdebugx(4, "FORMATTING STRING = %s", &tmp_buf[0]); + snprintf((char*)cur_info_p.info_type, SU_INFOSIZE, + &tmp_buf[0], current_device_number, cur_nut_index); + } + else { + /* FIXME: daisychain-whole, what to do? */ + snprintf((char*)cur_info_p.info_type, SU_INFOSIZE, + su_info_p->info_type, cur_nut_index); + } + } + else { + snprintf((char*)cur_info_p.info_type, SU_INFOSIZE, + su_info_p->info_type, cur_nut_index); + } + } + else if (!strncmp(type, "ambient", 7)) + { + /* FIXME: can be grouped with outlet* above */ + /* Get the index of the current template instance */ + cur_nut_index = cur_template_number; + + /* Special processing for daisychain */ + if (daisychain_enabled == TRUE) { + /* Only publish on the daisychain host */ + if ( (su_info_p->flags & SU_TYPE_DAISY_MASTER_ONLY) + && (current_device_number != 1) ) { + upsdebugx(2, "discarding variable due to daisychain master flag"); + continue; + } + + /* Device(s) 1-N (master + slave(s)) need to append 'device.x' */ + if ((devices_count > 1) && (current_device_number > 0)) { + memset(&tmp_buf[0], 0, SU_INFOSIZE); + strcat(&tmp_buf[0], "device.%i."); + strcat(&tmp_buf[0], su_info_p->info_type); + + upsdebugx(4, "FORMATTING STRING = %s", &tmp_buf[0]); + snprintf((char*)cur_info_p.info_type, SU_INFOSIZE, + &tmp_buf[0], current_device_number, cur_nut_index); + } + else { + /* FIXME: daisychain-whole, what to do? */ + snprintf((char*)cur_info_p.info_type, SU_INFOSIZE, + su_info_p->info_type, cur_nut_index); + } + } + else { + snprintf((char*)cur_info_p.info_type, SU_INFOSIZE, + su_info_p->info_type, cur_nut_index); + } + } + else + upsdebugx(4, "Error: unknown template type '%s", type); /* check if default value is also a template */ if ((cur_info_p.dfl != NULL) && @@ -1450,7 +2623,42 @@ bool_t process_template(int mode, const char* type, snmp_info_t *su_info_p) } if (cur_info_p.OID != NULL) { - snprintf((char *)cur_info_p.OID, SU_INFOSIZE, su_info_p->OID, cur_template_number); + /* Special processing for daisychain */ + if (!strncmp(type, "device", 6)) { + if (current_device_number > 0) { + snprintf((char *)cur_info_p.OID, SU_INFOSIZE, su_info_p->OID, current_device_number + device_template_offset); + } + /*else + * FIXME: daisychain-whole, what to do? + */ + } + else { + /* Special processing for daisychain: + * these outlet | outlet groups also include formatting info, + * so we have to check if the daisychain is enabled, and if + * the formatting info for it are in 1rst or 2nd position */ + if (daisychain_enabled == TRUE) { + if (su_info_p->flags & SU_TYPE_DAISY_1) { + snprintf((char *)cur_info_p.OID, SU_INFOSIZE, + su_info_p->OID, current_device_number + device_template_offset, cur_template_number); + } + else if (su_info_p->flags & SU_TYPE_DAISY_2) { + snprintf((char *)cur_info_p.OID, SU_INFOSIZE, + su_info_p->OID, cur_template_number + device_template_offset, + current_device_number - device_template_offset); + } + else { + /* Note: no device daisychain templating (SU_TYPE_DAISY_MASTER_ONLY)! */ + snprintf((char *)cur_info_p.OID, SU_INFOSIZE, su_info_p->OID, cur_template_number); + } + } + else { + snprintf((char *)cur_info_p.OID, SU_INFOSIZE, su_info_p->OID, cur_template_number); + } + } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif /* add instant commands to the info database. */ if (SU_TYPE(su_info_p) == SU_TYPE_CMD) { @@ -1483,14 +2691,23 @@ bool_t process_template(int mode, const char* type, snmp_info_t *su_info_p) /* Return the type of template, according to a variable name. * Return: SU_OUTLET_GROUP, SU_OUTLET or 0 if not a template */ -int get_template_type(const char* varname) +snmp_info_flags_t get_template_type(const char* varname) { - /* Check if it is outlet / outlet.group */ if (!strncmp(varname, "outlet.group", 12)) { + upsdebugx(4, "outlet.group template"); return SU_OUTLET_GROUP; } else if (!strncmp(varname, "outlet", 6)) { - return SU_OUTLET_GROUP; + upsdebugx(4, "outlet template"); + return SU_OUTLET; + } + else if (!strncmp(varname, "device", 6)) { + upsdebugx(4, "device template"); + return SU_DAISY; + } + else if (!strncmp(varname, "ambient", 7)) { + upsdebugx(4, "ambient template"); + return SU_AMBIENT_TEMPLATE; } else { upsdebugx(2, "Unknown template type: %s", varname); @@ -1500,7 +2717,7 @@ int get_template_type(const char* varname) /* Extract the id number of an instantiated template. * Example: return '1' for type = 'outlet.1.desc', -1 if unknown */ -int extract_template_number(int template_type, const char* varname) +int extract_template_number(snmp_info_flags_t template_type, const char* varname) { const char* item_number_ptr = NULL; int item_number = -1; @@ -1509,6 +2726,10 @@ int extract_template_number(int template_type, const char* varname) item_number_ptr = &varname[12]; else if (template_type & SU_OUTLET) item_number_ptr = &varname[6]; + else if (template_type & SU_DAISY) + item_number_ptr = &varname[6]; + else if (template_type & SU_AMBIENT_TEMPLATE) + item_number_ptr = &varname[7]; else return -1; @@ -1519,7 +2740,7 @@ int extract_template_number(int template_type, const char* varname) /* Extract the id number of a template from a variable name. * Example: return '1' for type = 'outlet.1.desc' */ -int extract_template_number_from_snmp_info_t(const char* varname) +static int extract_template_number_from_snmp_info_t(const char* varname) { return extract_template_number(get_template_type(varname), varname); } @@ -1532,20 +2753,23 @@ bool_t get_and_process_data(int mode, snmp_info_t *su_info_p) { bool_t status = FALSE; - upsdebugx(1, "getting data: %s (%s)", su_info_p->info_type, su_info_p->OID); + upsdebugx(1, "%s: %s (%s)", __func__, + su_info_p->info_type, su_info_p->OID); /* ok, update this element. */ status = su_ups_get(su_info_p); + upsdebugx(4, "%s: su_ups_get returned %d", __func__, status); /* set stale flag if data is stale, clear if not. */ if (status == TRUE) { if (su_info_p->flags & SU_FLAG_STALE) { - upslogx(LOG_INFO, "[%s] snmp_ups_walk: data resumed for %s", - upsname?upsname:device_name, su_info_p->info_type); + upslogx(LOG_INFO, "[%s] %s: data resumed for %s", + upsname?upsname:device_name, __func__, su_info_p->info_type); su_info_p->flags &= ~SU_FLAG_STALE; } if(su_info_p->flags & SU_FLAG_UNIQUE) { /* We should be the only provider of this */ + upsdebugx(4, "%s: unique flag", __func__); disable_competition(su_info_p); su_info_p->flags &= ~SU_FLAG_UNIQUE; } @@ -1566,170 +2790,518 @@ bool_t get_and_process_data(int mode, snmp_info_t *su_info_p) return status; } +/*********************************************************************** + * Daisychain handling functions + **********************************************************************/ + +/*! + * Daisychained devices support init: + * Determine the number of device(s) and if daisychain support has to be enabled + * Set the values of devices_count (internal) and "device.count" (public) + * Return TRUE if daisychain support is enabled, FALSE otherwise */ +bool_t daisychain_init() +{ + snmp_info_t *su_info_p = NULL; + + upsdebugx(1, "Checking if daisychain support has to be enabled"); + + su_info_p = su_find_info("device.count"); + + if (su_info_p != NULL) + { + upsdebugx(1, "Found device.count entry..."); + + /* Enable daisychain if there is a device.count entry. + * This means that will have templates for entries */ + daisychain_enabled = TRUE; + + /* Try to get the OID value, if it's not a template */ + upsdebugx(3, "OID for device.count is %s", + su_info_p->OID ? su_info_p->OID : ""); + if ((su_info_p->OID != NULL) && + (strstr(su_info_p->OID, "%i") == NULL)) + { +#if WITH_SNMP_LKP_FUN + devices_count = -1; + /* First test if we have a generic lookup function + * FIXME: Check if the field type is a string? + */ + /* TODO: backport the 2x2 mapping function support + * and this would be "fun_s2l" in resulting codebase + */ + if ( (su_info_p->oid2info != NULL) && (su_info_p->oid2info->nuf_s2l != NULL) ) { + char buf[1024]; + upsdebugx(2, "%s: using generic string-to-long lookup function", __func__); + if (TRUE == nut_snmp_get_str(su_info_p->OID, buf, sizeof(buf), su_info_p->oid2info)) { + devices_count = su_info_p->oid2info->nuf_s2l(buf); + upsdebugx(2, "%s: got value '%ld'", __func__, devices_count); + } + } + + if (devices_count == -1) { +#endif /* WITH_SNMP_LKP_FUN */ + + if (nut_snmp_get_int(su_info_p->OID, &devices_count) == TRUE) + upsdebugx(1, "There are %ld device(s) present", devices_count); + else + { + upsdebugx(1, "Error: can't get the number of device(s) present!"); + upsdebugx(1, "Falling back to 1 device!"); + devices_count = 1; + } + +#if WITH_SNMP_LKP_FUN + } +#endif /* WITH_SNMP_LKP_FUN */ + } + /* Otherwise (template), use the guesstimation function to get + * the number of devices present */ + else + { + devices_count = guestimate_template_count(su_info_p); + upsdebugx(1, "Guesstimation: there are %ld device(s) present", devices_count); + } + + /* Sanity check before data publication */ + if (devices_count < 1) { + devices_count = 1; + daisychain_enabled = FALSE; + upsdebugx(1, "Devices count is less than 1!"); + upsdebugx(1, "Falling back to 1 device and disabling daisychain support!"); + } else { + /* Publish the device(s) count - even if just one + * device was recognized at this moment */ + dstate_setinfo("device.count", "%ld", devices_count); + + /* Also publish the default value for mfr and a forged model + * for device.0 (whole daisychain) */ + su_info_p = su_find_info("device.mfr"); + if (su_info_p != NULL) { + su_info_p = su_find_info("ups.mfr"); + if (su_info_p != NULL) { + su_setinfo(su_info_p, NULL); + } + } + /* Forge model using device.type and number */ + su_info_p = su_find_info("device.type"); + if ((su_info_p != NULL) && (su_info_p->dfl != NULL)) { + dstate_setinfo("device.model", "daisychain %s (1+%ld)", + su_info_p->dfl, devices_count - 1); + dstate_setinfo("device.type", "%s", su_info_p->dfl); + } + else { + dstate_setinfo("device.model", "daisychain (1+%ld)", devices_count - 1); + } + } + } + else { + daisychain_enabled = FALSE; + upsdebugx(1, "No device.count entry found, daisychain support not needed"); + } + + /* Finally, compute and store the base OID index and NUT offset */ + su_info_p = su_find_info("device.model"); + if (su_info_p != NULL) { + device_template_index_base = base_snmp_template_index(su_info_p); + upsdebugx(1, "%s: device_template_index_base = %i", __func__, device_template_index_base); + device_template_offset = device_template_index_base - 1; + upsdebugx(1, "%s: device_template_offset = %i", __func__, device_template_offset); + } + else { + upsdebugx(1, "%s: No device.model entry found.", __func__); + } + + upsdebugx(1, "%s: daisychain support is %s", __func__, + (daisychain_enabled==TRUE)?"enabled":"disabled"); + + return daisychain_enabled; +} + +/*********************************************************************** + * SNMP handling functions + **********************************************************************/ + +/* Process a data with regard to SU_OUTPHASES, SU_INPHASES and SU_BYPPHASES. + * 3phases related data are disabled if the unit is 1ph, and conversely. + * If the related phases data (input, output, bypass) is not yet valued, + * retrieve it first. + * + * type: input, output, bypass + * su_info_p: variable to process flags on + * Return 0 if OK, 1 if the caller needs to "continue" the walk loop (i.e. + * skip the present data) + */ +static int process_phase_data(const char* type, long *nb_phases, snmp_info_t *su_info_p) +{ + snmp_info_t *tmp_info_p; + char tmpOID[SU_INFOSIZE]; + char tmpInfo[SU_INFOSIZE]; + long tmpValue; + snmp_info_flags_t phases_flag = 0, single_phase_flag = 0, three_phase_flag = 0; + + /* Phase specific data */ + if (!strncmp(type, "input", 5)) { + phases_flag = SU_INPHASES; + single_phase_flag = SU_INPUT_1; + three_phase_flag = SU_INPUT_3; + } + else if (!strncmp(type, "output", 6)) { + phases_flag = SU_OUTPHASES; + single_phase_flag = SU_OUTPUT_1; + three_phase_flag = SU_OUTPUT_3; + } + else if (!strncmp(type, "input.bypass", 12)) { + phases_flag = SU_BYPPHASES; + single_phase_flag = SU_BYPASS_1; + three_phase_flag = SU_BYPASS_3; + } + else { + upsdebugx(2, "%s: unknown type '%s'", __func__, type); + return 1; + } + + /* Init the phase(s) info for this device, if not already done */ + if (*nb_phases == -1) { + upsdebugx(2, "%s phases information not initialized for device %i", + type, current_device_number); + + memset(tmpInfo, 0, SU_INFOSIZE); + + /* daisychain specifics... */ + if ( (daisychain_enabled == TRUE) && (current_device_number > 0) ) { + /* Device(s) 2-N (slave(s)) need to append 'device.x' */ + snprintf(tmpInfo, SU_INFOSIZE, + "device.%i.%s.phases", current_device_number, type); + } + else { + snprintf(tmpInfo, SU_INFOSIZE, "%s.phases", type); + } + + if (dstate_getinfo(tmpInfo) == NULL) { + /* {input,output,bypass}.phases is not yet published, + * try to get the template for it */ + snprintf(tmpInfo, SU_INFOSIZE, "%s.phases", type); + tmp_info_p = su_find_info(tmpInfo); + if (tmp_info_p != NULL) { + memset(tmpOID, 0, SU_INFOSIZE); + + /* Daisychain specific: we may have a template (including + * formatting string) that needs to be adapted! */ + if (strchr(tmp_info_p->OID, '%') != NULL) { + upsdebugx(2, "Found template, need to be adapted"); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + snprintf((char*)tmpOID, SU_INFOSIZE, tmp_info_p->OID, current_device_number + device_template_offset); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif + } + else { + /* Otherwise, just point at what we found */ + upsdebugx(2, "Found entry, not a template %s", tmp_info_p->OID); + snprintf((char*)tmpOID, SU_INFOSIZE, "%s", tmp_info_p->OID); + } + /* Actually get the data */ + if (nut_snmp_get_int(tmpOID, &tmpValue) == TRUE) { + *nb_phases = tmpValue; + } + else { + upsdebugx(2, "Can't get %s value. Defaulting to 1 %s.phase", tmpInfo, type); + *nb_phases = 1; + /* FIXME: return something or process using default?! */ + } + } + else { + upsdebugx(2, "No %s entry. Defaulting to 1 %s.phase", tmpInfo, type); + *nb_phases = 1; + /* FIXME: return something or process using default?! */ + } + } + else { + *nb_phases = atoi(dstate_getinfo(tmpInfo)); + } + /* Publish the number of phase(s) */ + dstate_setinfo(tmpInfo, "%ld", *nb_phases); + upsdebugx(2, "device %i has %ld %s.phases", current_device_number, *nb_phases, type); + } + /* FIXME: what to do here? + else if (*nb_phases == 0) { + return 1; + } */ + + + /* Actual processing of phases related data */ +/* FIXME: don't clear SU_INPHASES in daisychain mode!!! ??? */ + if (su_info_p->flags & single_phase_flag) { + if (*nb_phases == 1) { + upsdebugx(1, "%s_phases is 1", type); + su_info_p->flags &= ~phases_flag; + } else { + upsdebugx(1, "%s_phases is not 1", type); + su_info_p->flags &= ~SU_FLAG_OK; + return 1; + } + } else if (su_info_p->flags & three_phase_flag) { + if (*nb_phases == 3) { + upsdebugx(1, "%s_phases is 3", type); + su_info_p->flags &= ~phases_flag; + } else { + upsdebugx(1, "%s_phases is not 3", type); + su_info_p->flags &= ~SU_FLAG_OK; + return 1; + } + } else { + upsdebugx(1, "%s_phases is %ld", type, *nb_phases); + } + return 0; /* FIXME: remap EXIT_SUCCESS to RETURN_SUCCESS */ +} + + /* walk ups variables and set elements of the info array. */ bool_t snmp_ups_walk(int mode) { + long *walked_input_phases, *walked_output_phases, *walked_bypass_phases; static unsigned long iterations = 0; snmp_info_t *su_info_p; bool_t status = FALSE; - for (su_info_p = &snmp_info[0]; su_info_p->info_type != NULL ; su_info_p++) { + if (mode == SU_WALKMODE_UPDATE) { + semistatic_countdown--; + if (semistatic_countdown < 0) + semistatic_countdown = semistaticfreq; + } - /* Check if we are asked to stop (reactivity++) */ - if (exit_flag != 0) - return TRUE; + /* Loop through all device(s) */ + /* Note: considering "unitary" and "daisy-chained" devices, we have + * several variables (and their values) that can come into play: + * devices_count == 1 (default) AND daisychain_enabled == FALSE => unitary + * devices_count > 1 (AND/OR?) daisychain_enabled == TRUE => a daisy-chain + * The current_device_number == 0 in context of daisy-chain means the + * "whole device" with composite or summary values that refer to the + * chain as a virtual power device (e.g. might be a sum of outlet counts). + * If daisychain_enabled == TRUE and current_device_number == 1 then we + * are looking at the "master" device (one that we have direct/networked + * connectivity to; the current_device_number > 1 is a slave (chained by + * some proprietary link not visible from the outside) and represented + * through the master - the slaves are not addressable directly. If the + * master dies/reboots, connection to the whole chain is interrupted. + * The dstate string names for daisychained sub-devices have the prefix + * "device." and number embedded (e.g. "device.3.input.phases") except + * for the whole (#0) virtual device, so it *seems* similar to unitary. + */ - /* skip instcmd, not linked to outlets */ - if ((SU_TYPE(su_info_p) == SU_TYPE_CMD) - && !(su_info_p->flags & SU_OUTLET) - && !(su_info_p->flags & SU_OUTLET_GROUP)) { - upsdebugx(1, "SU_CMD_MASK => %s", su_info_p->OID); - continue; + for (current_device_number = (daisychain_enabled == FALSE && devices_count == 1 ? 1 : 0) ; + current_device_number <= devices_count; current_device_number++) + { + + upsdebugx(1, "%s: walking device %d", + __func__, current_device_number); + + /* reinit the alarm buffer, before */ + if (devices_count > 1) + device_alarm_init(); + + /* better safe than sorry, check sanity on every loop cycle */ + if (snmp_info == NULL) { + fatalx(EXIT_FAILURE, "%s: snmp_info is not initialized", __func__); } - /* skip elements we shouldn't show */ - if (!(su_info_p->flags & SU_FLAG_OK)) - continue; - /* skip static elements in update mode */ - if (mode == SU_WALKMODE_UPDATE && - su_info_p->flags & SU_FLAG_STATIC) - continue; + if (snmp_info[0].info_type == NULL) { + upsdebugx(1, "%s: WARNING: snmp_info is empty", __func__); + } - /* Set default value if we cannot fetch it */ - /* and set static flag on this element. - * Not applicable to outlets (need SU_FLAG_STATIC tagging) */ - if ((su_info_p->flags & SU_FLAG_ABSENT) - && !(su_info_p->flags & SU_OUTLET) - && !(su_info_p->flags & SU_OUTLET_GROUP)) { - if (mode == SU_WALKMODE_INIT) { - if (su_info_p->dfl) { - /* Set default value if we cannot fetch it from ups. */ - su_setinfo(su_info_p, NULL); - } - su_info_p->flags |= SU_FLAG_STATIC; + /* Loop through all mapping entries for the current_device_number */ + for (su_info_p = &snmp_info[0]; (su_info_p != NULL && su_info_p->info_type != NULL) ; su_info_p++) { + + /* NOTE: Effectively below we do this: + * switch(current_device_number) { + * case 0: devtype = "daisychain whole" + * case 1: devtype = "daisychain master" + * default: devtype = "daisychain slave" + * } + * with a consideration for directly-addressable + * slave devices (can be seen in chain via master, + * but also queryable alone with an IP connection) + * NOTE: until proven otherwise, "single" may mean + * both (either) a daisy-chain enabled master device + * without further connected "slave" devices, and + * a directly addressable (IP-connected) "slave". + * Possibly also an ePDU etc. that serves a MIB + * which resolves "device.count" with the selected + * subdriver. + */ + if (daisychain_enabled == TRUE) { + upsdebugx(1, "%s: processing daisy-chain device %i (%s)", + __func__, current_device_number, + (current_device_number == 1) + ? (devices_count > 1 ? "master" : "single") + : (current_device_number > 1 ? "slave" : "whole") + ); + } else { + upsdebugx(1, "%s: processing unitary device (%i)", + __func__, current_device_number); } - continue; - } - /* check stale elements only on each PN_STALE_RETRY iteration. */ -/* if ((su_info_p->flags & SU_FLAG_STALE) && - (iterations % SU_STALE_RETRY) != 0) - continue; + /* Check if we are asked to stop (reactivity++) */ + if (exit_flag != 0) { + upsdebugx(1, "%s: aborting because exit_flag was set", __func__); + return TRUE; + } + + /* Skip daisychain data count */ + if (mode == SU_WALKMODE_INIT && + (!strncmp(su_info_p->info_type, "device.count", 12))) + { + su_info_p->flags &= ~SU_FLAG_OK; + continue; + } + +/* FIXME: daisychain-whole, what to do? */ +/* Note that when addressing the FIXME above, + * if (current_device_number == 0 && daisychain_enabled == FALSE) + * then we'd skip it still (unitary device is at current_device_number == 1)... + */ + /* skip the whole-daisychain for now */ + if (current_device_number == 0 && daisychain_enabled == TRUE) { + upsdebugx(1, "Skipping daisychain device.0 for now..."); + continue; + } + + /* skip instcmd, not linked to outlets */ + if ((SU_TYPE(su_info_p) == SU_TYPE_CMD) + && !(su_info_p->flags & SU_OUTLET) + && !(su_info_p->flags & SU_OUTLET_GROUP)) { + upsdebugx(1, "SU_CMD_MASK => %s", su_info_p->OID); + continue; + } + /* skip elements we shouldn't show in update mode */ + if ((mode == SU_WALKMODE_UPDATE) && !(su_info_p->flags & SU_FLAG_OK)) + continue; + + /* skip semi-static elements in update mode: only parse when countdown reaches 0 */ + if ((mode == SU_WALKMODE_UPDATE) && (su_info_p->flags & SU_FLAG_SEMI_STATIC)) { + if (semistatic_countdown != 0) + continue; + upsdebugx(1, "Refreshing semi-static entry %s", su_info_p->OID); + } + + /* skip static elements in update mode */ + if ((mode == SU_WALKMODE_UPDATE) && (su_info_p->flags & SU_FLAG_STATIC)) + continue; + + /* Set default value if we cannot fetch it */ + /* and set static flag on this element. + * Not applicable to outlets (need SU_FLAG_STATIC tagging) */ + if ((su_info_p->flags & SU_FLAG_ABSENT) + && !(su_info_p->flags & SU_OUTLET) + && !(su_info_p->flags & SU_OUTLET_GROUP) + && !(su_info_p->flags & SU_AMBIENT_TEMPLATE)) + { + if (mode == SU_WALKMODE_INIT) + { + if (su_info_p->dfl) + { + if ((daisychain_enabled == TRUE) && (devices_count > 1)) + { + if (current_device_number == 0) + { + su_setinfo(su_info_p, NULL); /* FIXME: daisychain-whole, what to do? */ + } else { + status = process_template(mode, "device", su_info_p); + } + } + else { + /* Set default value if we cannot fetch it from ups. */ + su_setinfo(su_info_p, NULL); + } + } + su_info_p->flags |= SU_FLAG_STATIC; + } + continue; + } + + /* check stale elements only on each PN_STALE_RETRY iteration. */ + /* if ((su_info_p->flags & SU_FLAG_STALE) && + (iterations % SU_STALE_RETRY) != 0) + continue; + */ + /* Filter 1-phase Vs 3-phase according to {input,output,bypass}.phase. + * Non matching items are disabled, and flags are cleared at init + * time */ + /* Process input phases information */ + walked_input_phases = &daisychain_info[current_device_number]->input_phases; + if (su_info_p->flags & SU_INPHASES) { + upsdebugx(1, "Check input_phases (%ld)", *walked_input_phases); + if (process_phase_data("input", walked_input_phases, su_info_p) == 1) + continue; + } + + /* Process output phases information */ + walked_output_phases = &daisychain_info[current_device_number]->output_phases; + if (su_info_p->flags & SU_OUTPHASES) { + upsdebugx(1, "Check output_phases (%ld)", *walked_output_phases); + if (process_phase_data("output", walked_output_phases, su_info_p) == 1) + continue; + } + + /* Process bypass phases information */ + walked_bypass_phases = &daisychain_info[current_device_number]->bypass_phases; + if (su_info_p->flags & SU_BYPPHASES) { + upsdebugx(1, "Check bypass_phases (%ld)", *walked_bypass_phases); + if (process_phase_data("input.bypass", walked_bypass_phases, su_info_p) == 1) + continue; + } + + /* process template (outlet, outlet group, inc. daisychain) definition */ + if (su_info_p->flags & SU_OUTLET) { + /* Skip commands after init */ + if ((SU_TYPE(su_info_p) == SU_TYPE_CMD) && (mode == SU_WALKMODE_UPDATE)) + continue; + else + status = process_template(mode, "outlet", su_info_p); + } + else if (su_info_p->flags & SU_OUTLET_GROUP) { + /* Skip commands after init */ + if ((SU_TYPE(su_info_p) == SU_TYPE_CMD) && (mode == SU_WALKMODE_UPDATE)) + continue; + else + status = process_template(mode, "outlet.group", su_info_p); + } + else if (su_info_p->flags & SU_AMBIENT_TEMPLATE) { + /* Skip commands after init */ + if ((SU_TYPE(su_info_p) == SU_TYPE_CMD) && (mode == SU_WALKMODE_UPDATE)) + continue; + else + status = process_template(mode, "ambient", su_info_p); + } + else { +/* if (daisychain_enabled == TRUE) { + status = process_template(mode, "device", su_info_p); + } + else { +*/ /* get and process this data, including daisychain adaptation */ + status = get_and_process_data(mode, su_info_p); +/* + } */ - /* Filter 1-phase Vs 3-phase according to {input,output}.phase. - * Non matching items are disabled, and flags are cleared at - * init time */ - if (su_info_p->flags & SU_INPHASES) { - upsdebugx(1, "Check input_phases (%i)", input_phases); - if (input_phases == 0) { - /* FIXME: to get from input.phases - * this would avoid the use of the SU_FLAG_SETINT flag - * and potential human-error to not declare the right way. - * It would also free the slot for SU_OUTLET_GROUP */ - continue; } - if (su_info_p->flags & SU_INPUT_1) { - if (input_phases == 1) { - upsdebugx(1, "input_phases is 1"); - su_info_p->flags &= ~SU_INPHASES; - } else { - upsdebugx(1, "input_phases is not 1"); - su_info_p->flags &= ~SU_FLAG_OK; - continue; - } - } else if (su_info_p->flags & SU_INPUT_3) { - if (input_phases == 3) { - upsdebugx(1, "input_phases is 3"); - su_info_p->flags &= ~SU_INPHASES; - } else { - upsdebugx(1, "input_phases is not 3"); - su_info_p->flags &= ~SU_FLAG_OK; - continue; - } - } else { - upsdebugx(1, "input_phases is %d", input_phases); - } - } + } /* for (su_info_p... */ - if (su_info_p->flags & SU_OUTPHASES) { - upsdebugx(1, "Check output_phases"); - if (output_phases == 0) { - /* FIXME: same as for input_phases */ - continue; - } - if (su_info_p->flags & SU_OUTPUT_1) { - if (output_phases == 1) { - upsdebugx(1, "output_phases is 1"); - su_info_p->flags &= ~SU_OUTPHASES; - } else { - upsdebugx(1, "output_phases is not 1"); - su_info_p->flags &= ~SU_FLAG_OK; - continue; - } - } else if (su_info_p->flags & SU_OUTPUT_3) { - if (output_phases == 3) { - upsdebugx(1, "output_phases is 3"); - su_info_p->flags &= ~SU_OUTPHASES; - } else { - upsdebugx(1, "output_phases is not 3"); - su_info_p->flags &= ~SU_FLAG_OK; - continue; - } - } else { - upsdebugx(1, "output_phases is %d", output_phases); - } - } + if (devices_count > 1) { + /* commit the device alarm buffer */ + device_alarm_commit(current_device_number); - if (su_info_p->flags & SU_BYPPHASES) { - upsdebugx(1, "Check bypass_phases"); - if (bypass_phases == 0) { - /* FIXME: same as for input_phases */ - continue; - } - if (su_info_p->flags & SU_BYPASS_1) { - if (bypass_phases == 1) { - upsdebugx(1, "bypass_phases is 1"); - su_info_p->flags &= ~SU_BYPPHASES; - } else { - upsdebugx(1, "bypass_phases is not 1"); - su_info_p->flags &= ~SU_FLAG_OK; - continue; - } - } else if (su_info_p->flags & SU_BYPASS_3) { - if (input_phases == 3) { - upsdebugx(1, "bypass_phases is 3"); - su_info_p->flags &= ~SU_BYPPHASES; - } else { - upsdebugx(1, "bypass_phases is not 3"); - su_info_p->flags &= ~SU_FLAG_OK; - continue; - } - } else { - upsdebugx(1, "bypass_phases is %d", bypass_phases); - } + /* reinit the alarm buffer, after, not to pollute "device.0" */ + device_alarm_init(); } - - /* process outlet template definition */ - if (su_info_p->flags & SU_OUTLET) { - /* Skip commands after init */ - if ((SU_TYPE(su_info_p) == SU_TYPE_CMD) && (mode == SU_WALKMODE_UPDATE)) - continue; - else - status = process_template(mode, "outlet", su_info_p); - } - else if (su_info_p->flags & SU_OUTLET_GROUP) { - /* Skip commands after init */ - if ((SU_TYPE(su_info_p) == SU_TYPE_CMD) && (mode == SU_WALKMODE_UPDATE)) - continue; - else - status = process_template(mode, "outlet.group", su_info_p); - } - else { - /* get and process this data */ - status = get_and_process_data(mode, su_info_p); - } - } /* for (su_info_p... */ - + } iterations++; return status; } @@ -1739,24 +3311,123 @@ bool_t su_ups_get(snmp_info_t *su_info_p) static char buf[SU_INFOSIZE]; bool_t status; long value; + double dvalue; const char *strValue = NULL; struct snmp_pdu ** pdu_array; struct snmp_pdu * current_pdu; alarms_info_t * alarms; int index = 0; + char *format_char = NULL; + int saved_current_device_number = -1; + snmp_info_t *tmp_info_p = NULL; upsdebugx(2, "%s: %s %s", __func__, su_info_p->info_type, su_info_p->OID); - if (!strcasecmp(su_info_p->info_type, "ups.status")) { + /* Check if this is a daisychain template */ + if (su_info_p->OID != NULL + && (format_char = strchr(su_info_p->OID, '%')) != NULL + ) { + upsdebugx(3, "%s: calling instantiate_info() for " + "daisy-chain template", __func__); + tmp_info_p = instantiate_info(su_info_p, tmp_info_p); + if (tmp_info_p != NULL) { + upsdebugx(3, "%s: instantiate_info() returned " + "non-null OID: %s", + __func__, tmp_info_p->OID); + /* adapt the OID */ + if (su_info_p->OID != NULL) { +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + snprintf((char *)tmp_info_p->OID, SU_INFOSIZE, su_info_p->OID, + current_device_number + device_template_offset); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif + upsdebugx(3, "%s: OID %s adapted into %s", + __func__, su_info_p->OID, + tmp_info_p->OID); + } + else { + free_info(tmp_info_p); + return FALSE; + } + /* adapt info_type */ + if (su_info_p->info_type != NULL) { + snprintf((char *)tmp_info_p->info_type, + SU_INFOSIZE, "%s", + su_info_p->info_type); + } + else { + free_info(tmp_info_p); + return FALSE; + } + + su_info_p = tmp_info_p; + } + else { + upsdebugx(2, "%s: can't instantiate template", __func__); + return FALSE; + } + } + else { + /* Non-templated OID, still may be aimed at a + * daisy-chained device (master of the chain + * makes sense for IETF device.contact etc.). + * BUT: It could be a direct request for earlier + * resolved OID. So check for "device.N." too. + */ + if (daisychain_enabled == TRUE + && devices_count > 1 + && current_device_number > 0 + ) { + /* So we had a literal OID string, originally + * Check for "device.N." in the string: */ + char * varname = su_info_p->info_type; + if (!strncmp(varname, "device.", 7) + && (varname[7] >= '0' && varname[7] <= '9') + ) { + upsdebugx(2, "%s: keeping original " + "current device == %d for " + "non-templated daisy value", + __func__, current_device_number); + } else { + upsdebugx(2, "%s: would fake " + "current device == 1 for " + "non-templated daisy value " + "instead of %d", + __func__, current_device_number); + saved_current_device_number = current_device_number; + } + /* At this point we applied no hacks yet, + * just stashed a non-negative value into + * saved_current_device_number + */ + } + } + + if (!strcasecmp(su_info_p->info_type, "ups.status")) { +/* FIXME: daisychain status support! */ + upsdebugx(2, "%s: requesting nut_snmp_get_int() for " + "ups.status, with%s daisy template originally", + __func__, (format_char!=NULL ? "" : "out")); status = nut_snmp_get_int(su_info_p->OID, &value); if (status == TRUE) { su_status_set(su_info_p, value); upsdebugx(2, "=> value: %ld", value); } - else upsdebugx(2, "=> Failed"); + else + upsdebugx(2, "=> Failed"); + free_info(tmp_info_p); return status; } @@ -1766,6 +3437,10 @@ bool_t su_ups_get(snmp_info_t *su_info_p) upsdebugx(2, "Processing alarm: %s", su_info_p->info_type); +/* FIXME: daisychain alarms support! */ + upsdebugx(2, "%s: requesting nut_snmp_get_int() for " + "some alarm, with%s daisy template originally", + __func__, (format_char!=NULL ? "" : "out")); status = nut_snmp_get_int(su_info_p->OID, &value); if (status == TRUE) { @@ -1774,6 +3449,7 @@ bool_t su_ups_get(snmp_info_t *su_info_p) } else upsdebugx(2, "=> Failed"); + free_info(tmp_info_p); return status; } @@ -1782,6 +3458,9 @@ bool_t su_ups_get(snmp_info_t *su_info_p) * present, this means that the alarm condition is TRUE. * Only present in powerware-mib.c for now */ if (!strcasecmp(su_info_p->info_type, "ups.alarms")) { + upsdebugx(2, "%s: requesting nut_snmp_get_int() for " + "ups.alarms, with%s daisy template originally", + __func__, (format_char!=NULL ? "" : "out")); status = nut_snmp_get_int(su_info_p->OID, &value); if (status == TRUE) { upsdebugx(2, "=> %ld alarms present", value); @@ -1825,6 +3504,7 @@ bool_t su_ups_get(snmp_info_t *su_info_p) upsdebugx(2, "=> Failed"); } + free_info(tmp_info_p); return status; } @@ -1832,9 +3512,13 @@ bool_t su_ups_get(snmp_info_t *su_info_p) if (!strcasecmp(su_info_p->info_type, "ambient.temperature")) { float temp=0; + upsdebugx(2, "%s: requesting nut_snmp_get_int() for " + "ambient.temperature, with%s daisy template originally", + __func__, (format_char!=NULL ? "" : "out")); status = nut_snmp_get_int(su_info_p->OID, &value); if(status != TRUE) { + free_info(tmp_info_p); return status; } @@ -1858,210 +3542,251 @@ bool_t su_ups_get(snmp_info_t *su_info_p) snprintf(buf, sizeof(buf), "%.1f", temp); su_setinfo(su_info_p, buf); + free_info(tmp_info_p); return TRUE; } - if (su_info_p->info_flags & ST_FLAG_STRING) { - status = nut_snmp_get_str(su_info_p->OID, buf, sizeof(buf), su_info_p->oid2info); + /* special treatment for element without oid but with default value */ + if (su_info_p->OID == NULL && su_info_p->dfl != NULL) { + status = TRUE; + /* FIXME: strlcpy() would fit here safer; not used in NUT yet */ + strncpy(buf, su_info_p->dfl, sizeof(buf) - 1); + buf[sizeof(buf) - 1] = '\0'; + } + else if (su_info_p->info_flags & ST_FLAG_STRING) { + upsdebugx(2, "%s: requesting nut_snmp_get_str(), " + "with%s daisy template originally", + __func__, (format_char!=NULL ? "" : "out")); + status = nut_snmp_get_str(su_info_p->OID, buf, + sizeof(buf), su_info_p->oid2info); + if (status == TRUE) { + if (quirk_symmetra_threephase) { + if (!strcasecmp(su_info_p->info_type, "input.transfer.low") + || !strcasecmp(su_info_p->info_type, "input.transfer.high")) { + /* Convert from three phase line-to-line voltage to line-to-neutral voltage */ + double tmp_dvalue = atof(buf); + tmp_dvalue = tmp_dvalue * 0.707; + snprintf(buf, sizeof(buf), "%.2f", tmp_dvalue); + } + } + /* Check if there is a string reformating function */ + const char *fmt_buf = NULL; + if ((fmt_buf = su_find_strval(su_info_p->oid2info, buf)) != NULL) { + snprintf(buf, sizeof(buf), "%s", fmt_buf); + } + } } else { + upsdebugx(2, "%s: requesting nut_snmp_get_int(), " + "with%s daisy template originally", + __func__, (format_char!=NULL ? "" : "out")); status = nut_snmp_get_int(su_info_p->OID, &value); if (status == TRUE) { - if (su_info_p->flags&SU_FLAG_NEGINVALID && value<0) { + if ((su_info_p->flags&SU_FLAG_NEGINVALID && value<0) + || (su_info_p->flags&SU_FLAG_ZEROINVALID && value==0)) { su_info_p->flags &= ~SU_FLAG_OK; if(su_info_p->flags&SU_FLAG_UNIQUE) { disable_competition(su_info_p); su_info_p->flags &= ~SU_FLAG_UNIQUE; } + free_info(tmp_info_p); return FALSE; } - if (su_info_p->flags & SU_FLAG_SETINT) { - upsdebugx(1, "setvar %s", su_info_p->OID); - *su_info_p->setvar = value; - } /* Check if there is a value to be looked up */ - if ((strValue = su_find_infoval(su_info_p->oid2info, value)) != NULL) + if ((strValue = su_find_infoval(su_info_p->oid2info, &value)) != NULL) snprintf(buf, sizeof(buf), "%s", strValue); - else - snprintf(buf, sizeof(buf), "%.2f", value * su_info_p->info_len); + else { + /* Check if there is a need to publish decimal too, + * i.e. if switching to integer does not cause a + * loss of precision. + * FIXME: Use remainder? is (dvalue%1.0)>0 cleaner? + */ + dvalue = value * su_info_p->info_len; + if (f_equal((int)dvalue, dvalue)) + snprintf(buf, sizeof(buf), "%i", (int)dvalue); + else + snprintf(buf, sizeof(buf), "%.2f", (float)dvalue); + } } } if (status == TRUE) { + if (saved_current_device_number >= 0) { + current_device_number = 1; + } su_setinfo(su_info_p, buf); + if (saved_current_device_number >= 0) { + current_device_number = saved_current_device_number; + } upsdebugx(2, "=> value: %s", buf); } - else + else { upsdebugx(2, "=> Failed"); + } + free_info(tmp_info_p); return status; } -/* set r/w INFO_ element to a value. */ -int su_setvar(const char *varname, const char *val) +/* Common function for setting OIDs, from a NUT variable name, + * used by su_setvar() and su_instcmd() + * Params: + * @mode: SU_MODE_INSTCMD for instant commands, SU_MODE_SETVAR for settings + * @varname: name of variable or command to set the OID from + * @val: value for settings, NULL for commands + + * Returns + * STAT_SET_HANDLED if OK, + * STAT_SET_INVALID or STAT_SET_UNKNOWN if the command / setting is not supported + * STAT_SET_FAILED otherwise + */ +static int su_setOID(int mode, const char *varname, const char *val) { snmp_info_t *su_info_p = NULL; bool_t status; int retval = STAT_SET_FAILED; + int cmd_offset = 0; long value = -1; /* normal (default), outlet, or outlet group variable */ - int vartype = get_template_type(varname); + snmp_info_flags_t vartype = 0; + int daisychain_device_number = -1; + /* variable without the potential "device.X" prefix, to find the template */ + char *tmp_varname = NULL; + char setOID[SU_INFOSIZE]; + /* Used for potentially appending "device.X." to {outlet,outlet.group}.count */ + char template_count_var[SU_BUFSIZE]; - upsdebugx(2, "entering %s(%s, %s)", __func__, varname, val); + upsdebugx(2, "entering %s(%s, %s, %s)", __func__, + (mode==SU_MODE_INSTCMD)?"instcmd":"setvar", varname, val); - /* Check if it is outlet / outlet.group */ - if (strncmp(varname, "outlet", 6)) - su_info_p = su_find_info(varname); - else { - snmp_info_t *tmp_info_p; - /* Point the outlet or outlet group number in the string */ - const char *item_number_ptr = NULL; - /* Store the target outlet or group number */ - int item_number = extract_template_number_from_snmp_info_t(varname); - /* Store the total number of outlets or outlet groups */ - int total_items = -1; + memset(setOID, 0, SU_INFOSIZE); + memset(template_count_var, 0, SU_BUFSIZE); - /* Check if it is outlet / outlet.group */ - if (vartype == SU_OUTLET_GROUP) { - total_items = atoi(dstate_getinfo("outlet.group.count")); - item_number_ptr = &varname[12]; + /* Check if it's a daisychain setting (device.x.varname), + * or a non-daisy setting/value/cmd for the "master" unit + * (as un-numbered device.varname), or something else? + */ + if (!strncmp(varname, "device", 6)) { + if (varname[7] >= '0' && varname[7] <= '9') { + /* Extract the (single-digit) device number + * TODO: use strtol() or similar to support multi-digit + * chains and offset tmp_varname inside varname properly + */ + daisychain_device_number = atoi(&varname[7]); + /* Point at the command, without the "device.x" prefix */ + tmp_varname = strdup(&varname[9]); + snprintf(template_count_var, 10, "%s", varname); + + upsdebugx(2, "%s: got a daisychain %s (%s) for device %i", + __func__, (mode==SU_MODE_INSTCMD)?"command":"setting", + tmp_varname, daisychain_device_number); + + if (daisychain_device_number > devices_count) + upsdebugx(2, "%s: item is out of bound (%i / %ld)", + __func__, daisychain_device_number, devices_count); } else { - total_items = atoi(dstate_getinfo("outlet.count")); - item_number_ptr = &varname[6]; + /* Note: below we check if "OID" contains ".%i" template text + * like we do in su_setinfo(); eventually we might get vendor + * MIBs that do expose device.contact/location/description + * for each link in the chain... + */ + if (daisychain_enabled == TRUE) { + /* Is the original "device.varname" backed by a templated + * OID string, so we can commonly set e.g. device.contact + * for everything in the chain? + */ + su_info_p = su_find_info(varname); + if (su_info_p + && (su_info_p->OID == NULL || strstr(su_info_p->OID, ".%i") != NULL) + ) { + /* is templated or defaulted */ + daisychain_device_number = 0; + } else { + daisychain_device_number = 1; + } + + upsdebugx(2, "%s: got an un-numbered daisychain %s (%s), " + "directing it to %s", + __func__, (mode==SU_MODE_INSTCMD)?"command":"setting", + varname, + (daisychain_device_number==1)?"'master' device":"all devices" + ); + } else { + /* No daisy, no poppy */ + daisychain_device_number = 0; + } + tmp_varname = strdup(varname); } - - item_number = atoi(++item_number_ptr); - upsdebugx(3, "%s: item %i / %i", __func__, item_number, total_items); - - /* ensure the item number is supported (filtered upstream though)! */ - if (item_number > total_items) { - /* out of bound item number */ - upsdebugx(2, "%s: item is out of bound (%i / %i)", - __func__, item_number, total_items); - return STAT_SET_INVALID; - } - /* find back the item template */ - char *item_varname = (char *)xmalloc(SU_INFOSIZE); - snprintf(item_varname, SU_INFOSIZE, "%s.%s%s", - (vartype == SU_OUTLET)?"outlet":"outlet.group", - "%i", strchr(item_number_ptr++, '.')); - - upsdebugx(3, "%s: searching for template\"%s\"", __func__, item_varname); - tmp_info_p = su_find_info(item_varname); - free(item_varname); - - /* for an snmp_info_t instance */ - su_info_p = instantiate_info(tmp_info_p, su_info_p); - - /* check if default value is also a template */ - if ((su_info_p->dfl != NULL) && - (strstr(tmp_info_p->dfl, "%i") != NULL)) { - su_info_p->dfl = (char *)xmalloc(SU_INFOSIZE); - snprintf((char *)su_info_p->dfl, sizeof(su_info_p->dfl), tmp_info_p->dfl, - item_number - base_nut_template_offset()); - } - /* adapt the OID */ - if (su_info_p->OID != NULL) { - snprintf((char *)su_info_p->OID, sizeof(su_info_p->OID), tmp_info_p->OID, - item_number - base_nut_template_offset()); - } - /* else, don't return STAT_SET_INVALID since we can be setting - * a server side variable! */ - - /* adapt info_type */ - if (su_info_p->info_type != NULL) - snprintf((char *)su_info_p->info_type, sizeof(su_info_p->info_type), "%s", varname); + } + else { + daisychain_device_number = 0; + tmp_varname = strdup(varname); } - if (!su_info_p || !su_info_p->info_type || !(su_info_p->flags & SU_FLAG_OK)) { - upsdebugx(2, "%s: info element unavailable %s", __func__, varname); - - /* Free template (outlet and outlet.group) */ - if (vartype != 0) - free_info(su_info_p); - - return STAT_SET_UNKNOWN; - } - - if (!(su_info_p->info_flags & ST_FLAG_RW) || su_info_p->OID == NULL) { - upsdebugx(2, "%s: not writable %s", __func__, varname); - - /* Free template (outlet and outlet.group) */ - if (vartype != 0) - free_info(su_info_p); - + /* skip the whole-daisychain for now: + * will send the settings to all devices in the daisychain */ + if ((daisychain_enabled == TRUE) && (devices_count > 1) && (daisychain_device_number == 0)) { + upsdebugx(2, "daisychain %s for device.0 are not yet supported!", + (mode==SU_MODE_INSTCMD)?"command":"setting"); + free(tmp_varname); return STAT_SET_INVALID; } - /* set value into the device */ - if (su_info_p->info_flags & ST_FLAG_STRING) { - status = nut_snmp_set_str(su_info_p->OID, val); + /* Check if it is outlet / outlet.group, or standard variable */ + if (strncmp(tmp_varname, "outlet", 6)) { + su_info_p = su_find_info(tmp_varname); + /* what if e.g. "device.x.contact" is not found as a "contact"? */ + if (!su_info_p && strcmp(tmp_varname, varname)) { + upsdebugx(2, + "%s: did not find info for daisychained entry %s, " + "retrying with original varname %s", + __func__, tmp_varname, varname); + su_info_p = su_find_info(varname); + + /* Still nothing? Try to revert from "device.1." + * as a daisychain master? */ + if (!su_info_p + && daisychain_enabled == TRUE + && devices_count > 1 + && daisychain_device_number == 1 + && !strncmp(varname, "device.1.", 9) + ) { + char tmp_buf[SU_INFOSIZE]; + snprintf(tmp_buf, sizeof(tmp_buf), + "device.%s", (varname + 9)); + su_info_p = su_find_info(tmp_buf); + if (su_info_p) { + upsdebugx(2, "%s: finally found " + "as daisy master revert %s", + __func__, tmp_buf); + free(tmp_varname); + tmp_varname = strdup(tmp_buf); + } + } + } } else { - /* non string data may imply a value lookup */ - if (su_info_p->oid2info) { - value = su_find_valinfo(su_info_p->oid2info, val); - } - else { - /* Convert value and apply multiplier */ - value = atof(val) / su_info_p->info_len; - } - /* Actually apply the new value */ - status = nut_snmp_set_int(su_info_p->OID, value); - } - - if (status == FALSE) - upsdebugx(1, "%s: cannot set value %s for %s", __func__, val, su_info_p->OID); - else { - retval = STAT_SET_HANDLED; - upsdebugx(1, "%s: successfully set %s to \"%s\"", __func__, varname, val); - - /* update info array - * FIXME: we'd better call su_ups_get() to refresh! */ - su_setinfo(su_info_p, val); - } - /* Free template (outlet and outlet.group) */ - if (vartype != 0) - free_info(su_info_p); - - return retval; -} - -/* process instant command and take action. */ -int su_instcmd(const char *cmdname, const char *extradata) -{ - snmp_info_t *su_info_p = NULL; - int status; - int retval = STAT_INSTCMD_FAILED; - int cmd_offset = 0; - /* normal (default), outlet, or outlet group variable */ - int vartype = get_template_type(cmdname); - - upsdebugx(2, "entering %s(%s, %s)", __func__, cmdname, extradata); - - /* FIXME: this should only apply if strchr(%)! */ - if (strncmp(cmdname, "outlet", 6)) { - su_info_p = su_find_info(cmdname); - } - else { -/* FIXME: common with su_setvar(), apart from upsdebugx */ + /* is indeed an outlet.* or device.x.outlet.* */ snmp_info_t *tmp_info_p; /* Point the outlet or outlet group number in the string */ const char *item_number_ptr = NULL; /* Store the target outlet or group number */ - int item_number = extract_template_number_from_snmp_info_t(cmdname); + int item_number = extract_template_number_from_snmp_info_t(tmp_varname); /* Store the total number of outlets or outlet groups */ int total_items = -1; /* Check if it is outlet / outlet.group */ + vartype = get_template_type(tmp_varname); if (vartype == SU_OUTLET_GROUP) { - total_items = atoi(dstate_getinfo("outlet.group.count")); - item_number_ptr = &cmdname[12]; + snprintfcat(template_count_var, SU_BUFSIZE, "outlet.group.count"); + total_items = atoi(dstate_getinfo(template_count_var)); + item_number_ptr = &tmp_varname[12]; } else { - total_items = atoi(dstate_getinfo("outlet.count")); - item_number_ptr = &cmdname[6]; + snprintfcat(template_count_var, SU_BUFSIZE, "outlet.count"); + total_items = atoi(dstate_getinfo(template_count_var)); + item_number_ptr = &tmp_varname[6]; } - + upsdebugx(3, "Using count variable '%s'", template_count_var); item_number = atoi(++item_number_ptr); upsdebugx(3, "%s: item %i / %i", __func__, item_number, total_items); @@ -2087,106 +3812,220 @@ int su_instcmd(const char *cmdname, const char *extradata) /* check if default value is also a template */ if ((su_info_p->dfl != NULL) && - (strstr(tmp_info_p->dfl, "%i") != NULL)) { + (strstr(tmp_info_p->dfl, "%i") != NULL)) + { su_info_p->dfl = (char *)xmalloc(SU_INFOSIZE); - snprintf((char *)su_info_p->dfl, sizeof(su_info_p->dfl), tmp_info_p->dfl, - item_number - base_nut_template_offset()); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + snprintf((char *)su_info_p->dfl, SU_INFOSIZE, tmp_info_p->dfl, + item_number); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif } -/* FIXME: common with su_setvar(), apart from upsdebugx */ - /* adapt the OID */ if (su_info_p->OID != NULL) { - /* Workaround buggy Eaton Pulizzi implementation - * which have different offsets index for data & commands! */ - if (su_info_p->flags & SU_CMD_OFFSET) { - upsdebugx(3, "Adding command offset"); - cmd_offset++; + if (mode==SU_MODE_INSTCMD) { + /* Workaround buggy Eaton Pulizzi implementation + * which have different offsets index for data & commands! */ + if (su_info_p->flags & SU_CMD_OFFSET) { + upsdebugx(3, "Adding command offset"); + cmd_offset++; + } } - snprintf((char *)su_info_p->OID, sizeof(su_info_p->OID), tmp_info_p->OID, - item_number - base_nut_template_offset() + cmd_offset); - } else { - free_info(su_info_p); - return STAT_INSTCMD_UNKNOWN; + /* Special processing for daisychain: + * these outlet | outlet groups also include formatting info, + * so we have to check if the daisychain is enabled, and if + * the formatting info for it are in 1rst or 2nd position */ +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + if (daisychain_enabled == TRUE) { + /* Note: daisychain_enabled == TRUE means that we have + * daisychain template. However: + * * when there are multiple devices, offset "-1" applies + * since device.0 is a fake and actual devices start at + * index 1 + * * when there is only 1 device, offset doesn't apply since + * the device index is "0" + */ + int daisychain_offset = 0; + if (devices_count > 1) + daisychain_offset = 1; + + if (su_info_p->flags & SU_TYPE_DAISY_1) { + snprintf((char *)su_info_p->OID, SU_INFOSIZE, tmp_info_p->OID, + daisychain_device_number - daisychain_offset, item_number); + } + else { + snprintf((char *)su_info_p->OID, SU_INFOSIZE, tmp_info_p->OID, + item_number, daisychain_device_number - daisychain_offset); + } + } + else { + snprintf((char *)su_info_p->OID, SU_INFOSIZE, tmp_info_p->OID, item_number); + } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif + } + /* else, don't return STAT_SET_INVALID for mode==SU_MODE_SETVAR since we + * can be setting a server side variable! */ + else { + if (mode==SU_MODE_INSTCMD) { + free_info(su_info_p); + return STAT_INSTCMD_UNKNOWN; + } + else { + /* adapt info_type */ + if (su_info_p->info_type != NULL) + snprintf((char *)su_info_p->info_type, SU_INFOSIZE, "%s", tmp_varname); + } } } /* Sanity check */ if (!su_info_p || !su_info_p->info_type || !(su_info_p->flags & SU_FLAG_OK)) { - /* Check for composite commands */ - if (!strcasecmp(cmdname, "load.on")) { - return su_instcmd("load.on.delay", "0"); - } + upsdebugx(2, "%s: info element unavailable %s", __func__, varname); - if (!strcasecmp(cmdname, "load.off")) { - return su_instcmd("load.off.delay", "0"); - } - - if (!strcasecmp(cmdname, "shutdown.return")) { - int ret; - - /* Ensure "ups.start.auto" is set to "yes", if supported */ - if (dstate_getinfo("ups.start.auto")) { - su_setvar("ups.start.auto", "yes"); - } - - ret = su_instcmd("load.on.delay", dstate_getinfo("ups.delay.start")); - if (ret != STAT_INSTCMD_HANDLED) { - return ret; - } - - return su_instcmd("load.off.delay", dstate_getinfo("ups.delay.shutdown")); - } - - if (!strcasecmp(cmdname, "shutdown.stayoff")) { - int ret; - - /* Ensure "ups.start.auto" is set to "no", if supported */ - if (dstate_getinfo("ups.start.auto")) { - su_setvar("ups.start.auto", "no"); - } - - ret = su_instcmd("load.on.delay", "-1"); - if (ret != STAT_INSTCMD_HANDLED) { - return ret; - } - - return su_instcmd("load.off.delay", dstate_getinfo("ups.delay.shutdown")); - } - - upsdebugx(2, "%s: %s unavailable", __func__, cmdname); - - if (!strncmp(cmdname, "outlet", 6)) - free_info(su_info_p); - - return STAT_INSTCMD_UNKNOWN; - } - - /* set value, using the provided one, or the default one otherwise */ - if (su_info_p->info_flags & ST_FLAG_STRING) { - status = nut_snmp_set_str(su_info_p->OID, extradata ? extradata : su_info_p->dfl); - } else { - status = nut_snmp_set_int(su_info_p->OID, extradata ? atoi(extradata) : su_info_p->info_len); - } - - if (status == FALSE) - upsdebugx(1, "%s: cannot set value for %s", __func__, cmdname); - else { - retval = STAT_INSTCMD_HANDLED; - upsdebugx(1, "%s: successfully sent command %s", __func__, cmdname); - } - - if (!strncmp(cmdname, "outlet", 6)) + /* Free template (outlet and outlet.group) */ free_info(su_info_p); + if (tmp_varname != NULL) + free(tmp_varname); + + return STAT_SET_UNKNOWN; + } + + /* set value into the device, using the provided one, or the default one otherwise */ + if (mode==SU_MODE_INSTCMD) { + /* Sanity check: commands should either have a value or a default */ + if ( (val == NULL) && (su_info_p->dfl == NULL) ) { + upsdebugx(1, "%s: cannot execute command '%s': a provided or default value is needed!", __func__, varname); + return STAT_SET_INVALID; + } + } + + if (su_info_p->info_flags & ST_FLAG_STRING) { + status = nut_snmp_set_str(su_info_p->OID, val ? val : su_info_p->dfl); + } + else { + if (mode==SU_MODE_INSTCMD) { + if ( !str_to_long(val ? val : su_info_p->dfl, &value, 10) ) { + upsdebugx(1, "%s: cannot execute command '%s': value is not a number!", __func__, varname); + return STAT_SET_INVALID; + } + } + else { + /* non string data may imply a value lookup */ + if (su_info_p->oid2info) { + value = su_find_valinfo(su_info_p->oid2info, val ? val : su_info_p->dfl); + } + else { + /* Convert value and apply multiplier */ + if ( !str_to_long(val, &value, 10) ) { + upsdebugx(1, "%s: cannot set '%s': value is not a number!", __func__, varname); + return STAT_SET_INVALID; + } + value = (long)((double)value / su_info_p->info_len); + } + } + /* Actually apply the new value */ + if (SU_TYPE(su_info_p) == SU_TYPE_TIME) { + status = nut_snmp_set_time(su_info_p->OID, value); + } + else { + status = nut_snmp_set_int(su_info_p->OID, value); + } + } + + /* Process result */ + if (status == FALSE) { + if (mode==SU_MODE_INSTCMD) + upsdebugx(1, "%s: cannot execute command '%s'", __func__, varname); + else + upsdebugx(1, "%s: cannot set value %s on OID %s", __func__, val, su_info_p->OID); + + retval = STAT_SET_FAILED; + } + else { + retval = STAT_SET_HANDLED; + if (mode==SU_MODE_INSTCMD) + upsdebugx(1, "%s: successfully sent command %s", __func__, varname); + else { + upsdebugx(1, "%s: successfully set %s to \"%s\"", __func__, varname, val); + + /* update info array: call dstate_setinfo, since flags and aux are + * already published, and this saves us some processing */ + dstate_setinfo(varname, "%s", val); + } + } + + /* Free template (outlet and outlet.group) */ + if (!strncmp(tmp_varname, "outlet", 6)) + free_info(su_info_p); + free(tmp_varname); + return retval; } +/* set r/w INFO_ element to a value. + * FIXME: make a common function with su_instcmd! */ +int su_setvar(const char *varname, const char *val) +{ + return su_setOID(SU_MODE_SETVAR, varname, val); +} + +/* Daisychain-aware function to add instant commands: + * Every command that is valid for a device has to be added for device.0 + * This then allows to composite commands, called on device.0 and executed + * on all devices of the daisychain */ +int su_addcmd(snmp_info_t *su_info_p) +{ + upsdebugx(2, "entering %s(%s)", __func__, su_info_p->info_type); + + if (daisychain_enabled == TRUE) { +/* FIXME?: daisychain */ + for (current_device_number = 1 ; current_device_number <= devices_count ; + current_device_number++) + { + process_template(SU_WALKMODE_INIT, "device", su_info_p); + } + } + else { + if (nut_snmp_get(su_info_p->OID) != NULL) { + dstate_addcmd(su_info_p->info_type); + upsdebugx(1, "%s: adding command '%s'", __func__, su_info_p->info_type); + } + } + return 0; +} + +/* process instant command and take action. */ +int su_instcmd(const char *cmdname, const char *extradata) +{ + return su_setOID(SU_MODE_INSTCMD, cmdname, extradata); +} + /* FIXME: the below functions can be removed since these were for loading * the mib2nut information from a file instead of the .h definitions... */ /* return 1 if usable, 0 if not */ -static int parse_mibconf_args(int numargs, char **arg) +static int parse_mibconf_args(size_t numargs, char **arg) { bool_t ret; @@ -2218,11 +4057,13 @@ static int parse_mibconf_args(int numargs, char **arg) return 1; } + /* called for fatal errors in parseconf like malloc failures */ static void mibconf_err(const char *errmsg) { upslogx(LOG_ERR, "Fatal error in parseconf (*mib.conf): %s", errmsg); } + /* load *mib.conf into an snmp_info_t structure */ void read_mibconf(char *mib) { diff --git a/drivers/snmp-ups.h b/drivers/snmp-ups.h index 05e0d3f..6ac670a 100644 --- a/drivers/snmp-ups.h +++ b/drivers/snmp-ups.h @@ -4,11 +4,14 @@ * * Copyright (C) * 2002-2010 Arnaud Quette + * 2015-2021 Eaton (author: Arnaud Quette ) + * 2016-2021 Eaton (author: Jim Klimov ) * 2002-2006 Dmitry Frolov - * J.W. Hoogervorst + * J.W. Hoogervorst * Niels Baggesen * - * Sponsored by MGE UPS SYSTEMS + * Sponsored by Eaton + * and originally by MGE UPS SYSTEMS * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,7 +30,6 @@ */ /* TODO list: -- add syscontact/location (to all mib.h or centralized?) - complete shutdown - add enum values to OIDs. - optimize network flow by: @@ -78,13 +80,23 @@ #include #include +#ifndef ONE_SEC +/* This macro name disappeared from net-snmp sources and headers + * after v5.9 tag, and was replaced by explicit expression below: */ +# define ONE_SEC (1000L * 1000L) +#endif + /* Force numeric OIDs by disabling MIB loading */ +#ifdef DISABLE_MIB_LOADING +# undef DISABLE_MIB_LOADING +#endif #define DISABLE_MIB_LOADING 1 /* Parameters default values */ #define DEFAULT_POLLFREQ 30 /* in seconds */ #define DEFAULT_NETSNMP_RETRIES 5 #define DEFAULT_NETSNMP_TIMEOUT 1 /* in seconds */ +#define DEFAULT_SEMISTATICFREQ 10 /* in snmpwalk update cycles */ /* use explicit booleans */ #ifndef FALSE @@ -103,10 +115,46 @@ typedef int bool_t; /* typedef void (*interpreter)(char *, char *, int); */ +#ifndef WITH_SNMP_LKP_FUN +/* Recent addition of fun/nuf hooks in info_lkp_t is not well handled by + * all corners of the codebase, e.g. not by DMF. So at least until that + * is fixed, (TODO) we enable those bits of code only optionally during + * a build for particular usage. Conversely, experimenters can define + * this macro to a specific value while building the codebase and see + * what happens under different conditions ;) + */ +# if (defined WITH_DMFMIB) && (WITH_DMFMIB != 0) +# define WITH_SNMP_LKP_FUN 0 +# else +# define WITH_SNMP_LKP_FUN 1 +# endif +#endif + +#ifndef WITH_SNMP_LKP_FUN_DUMMY +# define WITH_SNMP_LKP_FUN_DUMMY 0 +#endif + /* for lookup between OID values and INFO_ value */ typedef struct { - int oid_value; /* OID value */ - const char *info_value; /* INFO_* value */ + int oid_value; /* SNMP OID value */ + const char *info_value; /* NUT INFO_* value */ +#if WITH_SNMP_LKP_FUN +/* FIXME: Currently we do not have a way to provide custom C code + * via DMF - keep old approach until we get the ability, e.g. by + * requiring a LUA implementation to be passed alongside C lookups. + */ +/* + * Currently there are a few cases using a "fun_vp2s" type of lookup + * function, while the "nuf_s2l" type was added for completeness but + * is not really handled and does not have real consumers in the + * existing NUT codebase (static mib2nut tables in *-mib.c files). + * Related to su_find_infoval() (long* => string), su_find_valinfo() + * (string => long) and su_find_strval() (char* => string) routines + * defined below. + */ + const char *(*fun_vp2s)(void *snmp_value); /* optional SNMP to NUT mapping function, converting a pointer to SNMP data (e.g. numeric or string) into a NUT string */ + long (*nuf_s2l)(const char *nut_value); /* optional NUT to SNMP mapping function, converting a NUT string into SNMP numeric data */ +#endif /* WITH_SNMP_LKP_FUN */ } info_lkp_t; /* Structure containing info about one item that can be requested @@ -114,30 +162,55 @@ typedef struct { use sprintf with given format string. If unit is not NONE, values are converted according to the multiplier table */ +typedef uint32_t snmp_info_flags_t; /* To extend when 32 bits become too congested */ +#define PRI_SU_FLAGS PRIu32 + typedef struct { - const char *info_type; /* INFO_ or CMD_ element */ - int info_flags; /* flags to set in addinfo */ - double info_len; /* length of strings if STR, - * cmd value if CMD, multiplier otherwise. */ - const char *OID; /* SNMP OID or NULL */ - const char *dfl; /* default value */ - unsigned long flags; /* my flags */ - info_lkp_t *oid2info; /* lookup table between OID and NUT values */ - int *setvar; /* variable to set for SU_FLAG_SETINT */ + char *info_type; /* INFO_ or CMD_ element */ + int info_flags; /* flags to set in addinfo: see ST_FLAG_* + * defined in include/extstate.h */ + double info_len; /* length of strings if ST_FLAG_STRING, + * multiplier otherwise. */ + char *OID; /* SNMP OID or NULL */ + char *dfl; /* default value */ + snmp_info_flags_t flags; /* snmp-ups internal flags: see SU_* bit-shifts + * defined below (SU_FLAG*, SU_TYPE*, SU_STATUS* + * and others for outlets, phases, daisy-chains, + * etc.) + * NOTE that some *-mib.c mappings can specify + * a zero in this field... better fix that in + * favor of explicit values with a meaning! + * Current code treats such zero values as + * "OK if avail, otherwise discarded". + * NOTE: With C99+ a "long" is guaranteed to be + * at least 4 bytes; consider "unsigned long long" + * when/if we get more than 32 flag values. + */ + info_lkp_t *oid2info; /* lookup table between OID and NUT values */ } snmp_info_t; -#define SU_FLAG_OK (1 << 0) /* show element to upsd. */ -#define SU_FLAG_STATIC (1 << 1) /* retrieve info only once. */ -#define SU_FLAG_ABSENT (1 << 2) /* data is absent in the device, +/* "flags" bits 0..9 */ +#define SU_FLAG_OK (1UL << 0) /* show element to upsd - + * internal to snmp driver */ +#define SU_FLAG_STATIC (1UL << 1) /* retrieve info only once. */ +#define SU_FLAG_ABSENT (1UL << 2) /* data is absent in the device, * use default value. */ -#define SU_FLAG_STALE (1 << 3) /* data stale, don't try too often. */ -#define SU_FLAG_NEGINVALID (1 << 4) /* Invalid if negative value */ -#define SU_FLAG_UNIQUE (1 << 5) /* There can be only be one +#define SU_FLAG_STALE (1UL << 3) /* data stale, don't try too often - + * internal to snmp driver */ +#define SU_FLAG_NEGINVALID (1UL << 4) /* Invalid if negative value */ +#define SU_FLAG_UNIQUE (1UL << 5) /* There can be only be one * provider of this info, * disable the other providers */ -#define SU_FLAG_SETINT (1 << 6) /* save value */ -#define SU_OUTLET (1 << 7) /* outlet template definition */ -#define SU_CMD_OFFSET (1 << 8) /* Add +1 to the OID index */ +/* Note: older releases defined the following flag, but removed it by 2.7.5: + * #define SU_FLAG_SETINT (1UL << 6)*/ /* save value */ +#define SU_FLAG_ZEROINVALID (1UL << 6) /* Invalid if "0" value */ +#define SU_FLAG_NAINVALID (1UL << 7) /* Invalid if "N/A" value */ +#define SU_CMD_OFFSET (1UL << 8) /* Add +1 to the OID index */ + +#define SU_FLAG_SEMI_STATIC (1UL << 9) /* Refresh this entry once in several walks + * (for R/W values user can set on device, + * like descriptions or contacts) */ + /* Notes on outlet templates usage: * - outlet.count MUST exist and MUST be declared before any outlet template * Otherwise, the driver will try to determine it by itself... @@ -145,44 +218,73 @@ typedef struct { * a valid OID) in order to detect the base SNMP index (0 or 1) */ +/* "flags" bit 10 */ +#define SU_OUTLET_GROUP (1UL << 10) /* outlet group template definition */ +#define SU_OUTLET (1UL << 11) /* outlet template definition */ + +/* Phase specific data */ +/* "flags" bits 12..17 */ +#define SU_PHASES (0x0000003F << 12) +#define SU_INPHASES (0x00000003 << 12) +#define SU_INPUT_1 (1UL << 12) /* only if 1 input phase */ +#define SU_INPUT_3 (1UL << 13) /* only if 3 input phases */ +#define SU_OUTPHASES (0x00000003 << 14) +#define SU_OUTPUT_1 (1UL << 14) /* only if 1 output phase */ +#define SU_OUTPUT_3 (1UL << 15) /* only if 3 output phases */ +#define SU_BYPPHASES (0x00000003 << 16) +#define SU_BYPASS_1 (1UL << 16) /* only if 1 bypass phase */ +#define SU_BYPASS_3 (1UL << 17) /* only if 3 bypass phases */ +/* FIXME: use input.phases and output.phases to replace this */ + +/* hints for su_ups_set, applicable only to rw vars */ +/* "flags" bits 18..20 */ +#define SU_TYPE_INT (1UL << 18) /* cast to int when setting value */ +#define SU_TYPE_TIME (1UL << 19) /* cast to int */ +#define SU_TYPE_CMD (1UL << 20) /* instant command */ +/* The following helper macro is used like: + * if (SU_TYPE(su_info_p) == SU_TYPE_CMD) { ... } + */ +#define SU_TYPE(t) ((t)->flags & (7UL << 18)) + +/* Daisychain template definition */ +/* the following 2 flags specify the position of the daisychain device index + * in the formatting string. This is useful when considering daisychain with + * templates, such as outlets / outlets groups, which already have a format + * string specifier */ +/* "flags" bits 21..23 (and 24 reserved for DMF) */ +#define SU_TYPE_DAISY_1 (1UL << 21) /* Daisychain index is the 1st %i specifier in a template with more than one */ +#define SU_TYPE_DAISY_2 (1UL << 22) /* Daisychain index is the 2nd %i specifier in a template with more than one */ +#define SU_TYPE_DAISY(t) ((t)->flags & (11UL << 21)) /* Mask the SU_TYPE_DAISY_{1,2,MASTER_ONLY} but not SU_DAISY */ +#define SU_DAISY (1UL << 23) /* Daisychain template definition - set at run-time for devices with detected "device.count" over 1 */ +/* NOTE: Previously SU_DAISY had same bit-flag value as SU_TYPE_DAISY_2 */ +#define SU_TYPE_DAISY_MASTER_ONLY (1UL << 24) /* Only valid for daisychain master (device.1) */ + +/* Free slot: (1UL << 25) */ + +#define SU_AMBIENT_TEMPLATE (1UL << 26) /* ambient template definition */ + +/* Reserved slot -- to import from DMF branch codebase: +//#define SU_FLAG_FUNCTION (1UL << 27) +*/ + /* status string components * FIXME: these should be removed, since there is no added value. * Ie, this can be guessed from info->type! */ - -#define SU_STATUS_PWR (0 << 8) /* indicates power status element */ -#define SU_STATUS_BATT (1 << 8) /* indicates battery status element */ -#define SU_STATUS_CAL (2 << 8) /* indicates calibration status element */ -#define SU_STATUS_RB (3 << 8) /* indicates replace battery status element */ -#define SU_STATUS_NUM_ELEM 4 -#define SU_STATUS_INDEX(t) (((t) >> 8) & 7) -#define SU_OUTLET_GROUP (1 << 10) /* outlet group template definition */ - -/* Phase specific data */ -#define SU_PHASES (0x3F << 12) -#define SU_INPHASES (0x3 << 12) -#define SU_INPUT_1 (1 << 12) /* only if 1 input phase */ -#define SU_INPUT_3 (1 << 13) /* only if 3 input phases */ -#define SU_OUTPHASES (0x3 << 14) -#define SU_OUTPUT_1 (1 << 14) /* only if 1 output phase */ -#define SU_OUTPUT_3 (1 << 15) /* only if 3 output phases */ -#define SU_BYPPHASES (0x3 << 16) -#define SU_BYPASS_1 (1 << 16) /* only if 1 bypass phase */ -#define SU_BYPASS_3 (1 << 17) /* only if 3 bypass phases */ -/* FIXME: use input.phases and output.phases to replace this */ - - -/* hints for su_ups_set, applicable only to rw vars */ -#define SU_TYPE_INT (0 << 18) /* cast to int when setting value */ -#define SU_TYPE_STRING (1 << 18) /* cast to string. FIXME: redundant with ST_FLAG_STRING */ -#define SU_TYPE_TIME (2 << 18) /* cast to int */ -#define SU_TYPE_CMD (3 << 18) /* instant command */ -#define SU_TYPE(t) ((t)->flags & (7 << 18)) +/* "flags" bits 28..31 */ +#define SU_STATUS_PWR (1UL << 28) /* indicates power status element */ +#define SU_STATUS_BATT (1UL << 29) /* indicates battery status element */ +#define SU_STATUS_CAL (1UL << 30) /* indicates calibration status element */ +#define SU_STATUS_RB (1UL << 31) /* indicates replace battery status element */ +#define SU_STATUS_NUM_ELEM 4 /* Obsolete? No references found in codebase */ +#define SU_STATUS_INDEX(t) (((unsigned long)(t) >> 28) & 15UL) +/* Despite similar names, definitons below are not among the bit-flags ;) */ #define SU_VAR_COMMUNITY "community" #define SU_VAR_VERSION "snmp_version" #define SU_VAR_RETRIES "snmp_retries" #define SU_VAR_TIMEOUT "snmp_timeout" +#define SU_VAR_SEMISTATICFREQ "semistaticfreq" #define SU_VAR_MIBS "mibs" #define SU_VAR_POLLFREQ "pollfreq" /* SNMP v3 related parameters */ @@ -193,6 +295,8 @@ typedef struct { #define SU_VAR_AUTHPROT "authProtocol" #define SU_VAR_PRIVPROT "privProtocol" +#define SU_VAR_ONDELAY "ondelay" +#define SU_VAR_OFFDELAY "offdelay" #define SU_INFOSIZE 128 #define SU_BUFSIZE 32 @@ -205,6 +309,10 @@ typedef struct { #define SU_WALKMODE_INIT 0 #define SU_WALKMODE_UPDATE 1 +/* modes for su_setOID */ +#define SU_MODE_INSTCMD 1 +#define SU_MODE_SETVAR 2 + /* log spew limiters */ #define SU_ERR_LIMIT 10 /* start limiting after this many errors in a row */ #define SU_ERR_RATE 100 /* only print every nth error once limiting starts */ @@ -232,10 +340,12 @@ void nut_snmp_cleanup(void); struct snmp_pdu *nut_snmp_get(const char *OID); bool_t nut_snmp_get_str(const char *OID, char *buf, size_t buf_len, info_lkp_t *oid2info); +bool_t nut_snmp_get_oid(const char *OID, char *buf, size_t buf_len); bool_t nut_snmp_get_int(const char *OID, long *pval); bool_t nut_snmp_set(const char *OID, char type, const char *value); bool_t nut_snmp_set_str(const char *OID, const char *value); bool_t nut_snmp_set_int(const char *OID, long value); +bool_t nut_snmp_set_time(const char *OID, long value); void nut_snmp_perror(struct snmp_session *sess, int status, struct snmp_pdu *response, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 4, 5))); @@ -246,19 +356,50 @@ void su_init_instcmds(void); void su_setuphandlers(void); /* need to deal with external function ptr */ void su_setinfo(snmp_info_t *su_info_p, const char *value); void su_status_set(snmp_info_t *, long value); +void su_alarm_set(snmp_info_t *, long value); snmp_info_t *su_find_info(const char *type); bool_t snmp_ups_walk(int mode); bool_t su_ups_get(snmp_info_t *su_info_p); bool_t load_mib2nut(const char *mib); -const char *su_find_infoval(info_lkp_t *oid2info, long value); +/* Practical logic around lookup functions, see fun_vp2s and nuf_s2l + * fields in struct info_lkp_t */ +const char *su_find_infoval(info_lkp_t *oid2info, void *value); long su_find_valinfo(info_lkp_t *oid2info, const char* value); +const char *su_find_strval(info_lkp_t *oid2info, void *value); + +/***************************************************** + * Common conversion structs and functions provided by snmp-ups-helpers.c + * so they can be used and so "shared" by different subdrivers + *****************************************************/ + +const char *su_usdate_to_isodate_info_fun(void *raw_date); +extern info_lkp_t su_convert_to_iso_date_info[]; +/* Name the mapping location in that array for consumers to reference */ +#define FUNMAP_USDATE_TO_ISODATE 0 + +/* Process temperature value according to 'temperature_unit' */ +const char *su_temperature_read_fun(void *raw_snmp_value); + +/* Temperature handling, to convert back to Celsius (NUT standard) */ +extern int temperature_unit; + +#define TEMPERATURE_UNKNOWN 0 +#define TEMPERATURE_CELSIUS 1 +#define TEMPERATURE_KELVIN 2 +#define TEMPERATURE_FAHRENHEIT 3 + +/***************************************************** + * End of Subdrivers shared helpers functions + *****************************************************/ int su_setvar(const char *varname, const char *val); int su_instcmd(const char *cmdname, const char *extradata); void su_shutdown_ups(void); +void set_delays(void); + void read_mibconf(char *mib); extern struct snmp_session g_snmp_sess, *g_snmp_sess_p; @@ -266,6 +407,25 @@ extern const char *OID_pwr_status; extern int g_pwr_battery; extern int pollfreq; /* polling frequency */ extern int input_phases, output_phases, bypass_phases; +extern int semistaticfreq; /* semistatic entry update frequency */ + +/* pointer to the Snmp2Nut lookup table */ +extern mib2nut_info_t *mib2nut_info; +/* FIXME: to be trashed */ +extern snmp_info_t *snmp_info; +extern alarms_info_t *alarms_info; + +/* Common daisychain structure and functions */ + +bool_t daisychain_init(void); +int su_addcmd(snmp_info_t *su_info_p); + +/* Structure containing info about each daisychain device, including phases + * for input, output and bypass */ +typedef struct { + long input_phases; + long output_phases; + long bypass_phases; +} daisychain_info_t; #endif /* SNMP_UPS_H */ - diff --git a/drivers/socomec_jbus.c b/drivers/socomec_jbus.c new file mode 100644 index 0000000..fd1f865 --- /dev/null +++ b/drivers/socomec_jbus.c @@ -0,0 +1,492 @@ +/* socomec_jbus.c - Driver for Socomec JBUS UPS + * + * Copyright (C) + * 2021 Thanos Chatziathanassiou + * + * Based on documentation found freely on + * https://www.socomec.com/files/live/sites/systemsite/files/GB-JBUS-MODBUS-for-Delphys-MP-and-Delphys-MX-operating-manual.pdf + * but with dubious legal license. The document itself states: + * ``CAUTION : “This is a product for restricted sales distribution to informed partners. + * Installation restrictions or additional measures may be needed to prevent disturbances'' + * YMMV + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "main.h" +#include + +#define DRIVER_NAME "Socomec jbus driver" +#define DRIVER_VERSION "0.06" + +#define CHECK_BIT(var,pos) ((var) & (1<<(pos))) +#define MODBUS_SLAVE_ID 1 +#define BATTERY_RUNTIME_CRITICAL 15 + +/* Variables */ +static modbus_t *modbus_ctx = NULL; + +static int mrir(modbus_t * arg_ctx, int addr, int nb, uint16_t * dest); + +/* driver description structure */ +upsdrv_info_t upsdrv_info = { + DRIVER_NAME, + DRIVER_VERSION, + "Thanos Chatziathanassiou \n", + DRV_BETA, + {NULL} +}; + +void upsdrv_initinfo(void) +{ + upsdebugx(2, "upsdrv_initinfo"); + + uint16_t tab_reg[12]; + int r; + + dstate_setinfo("device.mfr", "socomec jbus"); + dstate_setinfo("device.model", "Socomec Generic"); + + upsdebugx(2, "initial read"); + + /* + this is a neat trick, but not really helpful right now + https://stackoverflow.com/questions/25811662/spliting-an-hex-into-2-hex-values/41733170#41733170 + uint8_t *lowbyte; + uint8_t *hibyte; + */ + + r = mrir(modbus_ctx, 0x1000, 12, tab_reg); + + if (r == -1) { + fatalx(EXIT_FAILURE, "failed to read UPS code from JBUS. r is %d error %s", r, modbus_strerror(errno)); + } + + upsdebugx(2, "read UPS Code %d", tab_reg[0]); + + if (tab_reg[1]) { + upsdebugx(2, "read UPS Power %d (kVA * 10)", tab_reg[1]); + dstate_setinfo("ups.power", "%u", tab_reg[1]*100 ); + } + + /* known Socomec Models */ + switch (tab_reg[0]) { + case 130: + dstate_setinfo("ups.model", "%s", "DIGYS"); + break; + + case 515: + dstate_setinfo("ups.model", "%s", "DELPHYS MX"); + break; + + case 516: + dstate_setinfo("ups.model", "%s", "DELPHYS MX elite"); + break; + + default: + dstate_setinfo("ups.model", "Unknown Socomec JBUS. Send id %u and specify the model", tab_reg[0]); + } + + if (tab_reg[3] && tab_reg[4] && tab_reg[5] && tab_reg[6] && tab_reg[7]) { + dstate_setinfo("ups.serial", "%c%c%c%c%c%c%c%c%c%c", + (tab_reg[3]&0xFF), (tab_reg[3]>>8), + (tab_reg[4]&0xFF), (tab_reg[4]>>8), + (tab_reg[5]&0xFF), (tab_reg[5]>>8), + (tab_reg[6]&0xFF), (tab_reg[6]>>8), + (tab_reg[7]&0xFF), (tab_reg[7]>>8) + ); + } + + /* upsh.instcmd = instcmd; */ + /* upsh.setvar = setvar; */ +} + +void upsdrv_updateinfo(void) +{ + upsdebugx(2, "upsdrv_updateinfo"); + + uint16_t tab_reg[64]; + int r; + + status_init(); + + /* ups configuration */ + r = mrir(modbus_ctx, 0x10E0, 32, tab_reg); + + if (r == -1 || !tab_reg[0]) { + upsdebugx(2, "Did not receive any data from the UPS at 0x10E0 ! Going stale r is %d error %s", r, modbus_strerror(errno)); + dstate_datastale(); + return; + } + + dstate_setinfo("input.voltage", "%u", tab_reg[0]); + dstate_setinfo("output.voltage", "%u", tab_reg[1]); + dstate_setinfo("input.frequency", "%u", tab_reg[2]); + dstate_setinfo("output.frequency", "%u", tab_reg[3]); + + upsdebugx(2, "battery capacity (Ah * 10) %u", tab_reg[8]); + upsdebugx(2, "battery elements %u", tab_reg[9]); + + /* time and date */ + r = mrir(modbus_ctx, 0x1360, 4, tab_reg); + if (r == -1) { + upsdebugx(2, "Did not receive any data from the UPS at 0x1360 ! Ignoring ? r is %d error %s", r, modbus_strerror(errno)); + } + + dstate_setinfo("ups.time", "%02d:%02d:%02d", (tab_reg[1]&0xFF), (tab_reg[0]>>8), (tab_reg[0]&0xFF) ); + dstate_setinfo("ups.date", "%04d/%02d/%02d", (tab_reg[3]+2000), (tab_reg[2]>>8), (tab_reg[1]>>8) ); + + /* ups status */ + r = mrir(modbus_ctx, 0x1020, 6, tab_reg); + + if (r == -1) { + upsdebugx(2, "Did not receive any data from the UPS at 0x1020 ! Ignoring ? r is %d error %s", r, modbus_strerror(errno)); + /* + dstate_datastale(); + return; + */ + } + + if (CHECK_BIT(tab_reg[0], 0)) + upsdebugx(2, "Rectifier Input supply present"); + if (CHECK_BIT(tab_reg[0], 1)) + upsdebugx(2, "Inverter ON "); + if (CHECK_BIT(tab_reg[0], 2)) + upsdebugx(2, "Rectifier ON"); + if (CHECK_BIT(tab_reg[0], 3)) + upsdebugx(2, "Load protected by inverter"); + if (CHECK_BIT(tab_reg[0], 4)) + upsdebugx(2, "Load on automatic bypass"); + if (CHECK_BIT(tab_reg[0], 5)) + upsdebugx(2, "Load on battery"); + if (CHECK_BIT(tab_reg[0], 6)) + upsdebugx(2, "Remote controls disable"); + if (CHECK_BIT(tab_reg[0], 7)) + upsdebugx(2, "Eco-mode ON"); + + if (CHECK_BIT(tab_reg[0], 14)) + upsdebugx(2, "Battery Test failed"); + if (CHECK_BIT(tab_reg[0], 15)) + upsdebugx(2, "Battery near end of backup time"); + if (CHECK_BIT(tab_reg[0], 16)) + upsdebugx(2, "Battery disacharged"); + + if (CHECK_BIT(tab_reg[1], 0)) + upsdebugx(2, "Battery OK"); + if (CHECK_BIT(tab_reg[1], 10)) + upsdebugx(2, "Bypass input supply present"); + if (CHECK_BIT(tab_reg[1], 11)) + upsdebugx(2, "Battery charging"); + if (CHECK_BIT(tab_reg[1], 12)) + upsdebugx(2, "Bypass input frequency out of tolerance"); + + if (CHECK_BIT(tab_reg[2], 0)) + upsdebugx(2, "Unit operating"); + + if (CHECK_BIT(tab_reg[3], 0)) + upsdebugx(2, "Maintenance mode active"); + + if (CHECK_BIT(tab_reg[4], 0)) + upsdebugx(2, "Boost charge ON"); + if (CHECK_BIT(tab_reg[4], 2)) + upsdebugx(2, "Inverter switch closed"); + if (CHECK_BIT(tab_reg[4], 3)) + upsdebugx(2, "Bypass breaker closed"); + if (CHECK_BIT(tab_reg[4], 4)) + upsdebugx(2, "Maintenance bypass breaker closed"); + if (CHECK_BIT(tab_reg[4], 5)) + upsdebugx(2, "Remote maintenance bypass breaker closed"); + if (CHECK_BIT(tab_reg[4], 6)) + upsdebugx(2, "Output breaker closed (Q3)"); + if (CHECK_BIT(tab_reg[4], 9)) + upsdebugx(2, "Unit working"); + if (CHECK_BIT(tab_reg[4], 12)) + upsdebugx(2, "normal mode active"); + + /* alarms */ + r = mrir(modbus_ctx, 0x1040, 4, tab_reg); + + alarm_init(); + + if (r == -1) { + upsdebugx(2, "Did not receive any data from the UPS at 0x1040 ! Ignoring ? r is %d error %s", r, modbus_strerror(errno)); + /* + dstate_datastale(); + return; + */ + } + + if (CHECK_BIT(tab_reg[0], 0)) { + upsdebugx(2, "General Alarm"); + alarm_set("General Alarm present."); + } + if (CHECK_BIT(tab_reg[0], 1)) { + upsdebugx(2, "Battery failure"); + alarm_set("Battery failure."); + } + if (CHECK_BIT(tab_reg[0], 2)) { + upsdebugx(2, "UPS overload"); + alarm_set("Overload fault."); + } + if (CHECK_BIT(tab_reg[0], 4)) { + upsdebugx(2, "Control failure (com, internal supply...)"); + alarm_set("Control failure (com, internal supply...)"); + } + if (CHECK_BIT(tab_reg[0], 5)) { + upsdebugx(2, "Rectifier input supply out of tolerance "); + alarm_set("Rectifier input supply out of tolerance."); + } + if (CHECK_BIT(tab_reg[0], 6)) { + upsdebugx(2, "Bypass input supply out of tolerance "); + alarm_set("Bypass input supply out of tolerance."); + } + if (CHECK_BIT(tab_reg[0], 7)) { + upsdebugx(2, "Over temperature alarm "); + alarm_set("Over temperature fault."); + } + if (CHECK_BIT(tab_reg[0], 8)) { + upsdebugx(2, "Maintenance bypass closed"); + alarm_set("Maintenance bypass closed."); + } + if (CHECK_BIT(tab_reg[0], 10)) { + upsdebugx(2, "Battery charger fault"); + alarm_set("Battery charger fault."); + } + + if (CHECK_BIT(tab_reg[1], 1)) + upsdebugx(2, "Improper condition of use"); + if (CHECK_BIT(tab_reg[1], 2)) + upsdebugx(2, "Inverter stopped for overload (or bypass transfer)"); + if (CHECK_BIT(tab_reg[1], 3)) + upsdebugx(2, "Microprocessor control system"); + if (CHECK_BIT(tab_reg[1], 5)) + upsdebugx(2, "Synchronisation fault (PLL fault)"); + if (CHECK_BIT(tab_reg[1], 6)) + upsdebugx(2, "Rectifier input supply fault"); + if (CHECK_BIT(tab_reg[1], 7)) + upsdebugx(2, "Rectifier preventive alarm"); + if (CHECK_BIT(tab_reg[1], 9)) + upsdebugx(2, "Inverter preventive alarm"); + if (CHECK_BIT(tab_reg[1], 10)) + upsdebugx(2, "Charger general alarm"); + if (CHECK_BIT(tab_reg[1], 13)) + upsdebugx(2, "Bypass preventive alarm"); + if (CHECK_BIT(tab_reg[1], 15)) { + upsdebugx(2, "Imminent STOP"); + alarm_set("Imminent STOP."); + } + + if (CHECK_BIT(tab_reg[2], 12)) { + upsdebugx(2, "Servicing alarm"); + alarm_set("Servicing alarm."); + } + if (CHECK_BIT(tab_reg[2], 15)) + upsdebugx(2, "Battery room alarm"); + + if (CHECK_BIT(tab_reg[3], 0)) { + upsdebugx(2, "Maintenance bypass alarm"); + alarm_set("Maintenance bypass."); + } + if (CHECK_BIT(tab_reg[3], 1)) { + upsdebugx(2, "Battery discharged"); + alarm_set("Battery discharged."); + } + if (CHECK_BIT(tab_reg[3], 3)) + upsdebugx(2, "Synoptic alarm"); + if (CHECK_BIT(tab_reg[3], 4)) { + upsdebugx(2, "Critical Rectifier fault"); + alarm_set("Critical Rectifier fault."); + } + if (CHECK_BIT(tab_reg[3], 6)) { + upsdebugx(2, "Critical Inverter fault"); + alarm_set("Critical Inverter fault."); + } + if (CHECK_BIT(tab_reg[3], 10)) + upsdebugx(2, "ESD activated"); + if (CHECK_BIT(tab_reg[3], 11)) { + upsdebugx(2, "Battery circuit open"); + alarm_set("Battery circuit open."); + } + if (CHECK_BIT(tab_reg[3], 14)) { + upsdebugx(2, "Bypass critical alarm"); + alarm_set("Bypass critical alarm."); + } + + /* measurements */ + r = mrir(modbus_ctx, 0x1060, 48, tab_reg); + + if (r == -1) { + upsdebugx(2, "Did not receive any data from the UPS at 0x1060 ! Ignoring ? r is %d error %s", r, modbus_strerror(errno)); + /* + dstate_datastale(); + return; + */ + } + + if (tab_reg[1] == 0xFFFF && tab_reg[2] == 0xFFFF) { + /* this a 1-phase model */ + dstate_setinfo("input.phases", "1" ); + dstate_setinfo("ups.load", "%u", tab_reg[0] ); + + dstate_setinfo("input.bypass.voltage", "%u", tab_reg[6] ); + + dstate_setinfo("output.voltage", "%u", tab_reg[9] ); + + if (tab_reg[15] != 0xFFFF) + dstate_setinfo("output.current", "%u", tab_reg[15] ); + } + else { + /* this a 3-phase model */ + dstate_setinfo("input.phases", "3" ); + + dstate_setinfo("ups.load", "%u", tab_reg[3] ); + + dstate_setinfo("ups.L1.load", "%u", tab_reg[0] ); + dstate_setinfo("ups.L2.load", "%u", tab_reg[1] ); + dstate_setinfo("ups.L3.load", "%u", tab_reg[2] ); + + dstate_setinfo("input.bypass.L1-N.voltage", "%u", tab_reg[6] ); + dstate_setinfo("input.bypass.L2-N.voltage", "%u", tab_reg[7] ); + dstate_setinfo("input.bypass.L3-N.voltage", "%u", tab_reg[8] ); + + dstate_setinfo("output.L1-N.voltage", "%u", tab_reg[9] ); + dstate_setinfo("output.L2-N.voltage", "%u", tab_reg[10] ); + dstate_setinfo("output.L3-N.voltage", "%u", tab_reg[11] ); + + if (tab_reg[15] != 0xFFFF) + dstate_setinfo("output.L1.current", "%u", tab_reg[15] ); + + if (tab_reg[16] != 0xFFFF) + dstate_setinfo("output.L2.current", "%u", tab_reg[16] ); + + if (tab_reg[17] != 0xFFFF) + dstate_setinfo("output.L3.current", "%u", tab_reg[17] ); + } + + dstate_setinfo("battery.charge", "%u", tab_reg[4] ); + dstate_setinfo("battery.capacity", "%u", (tab_reg[5]/10) ); + dstate_setinfo("battery.voltage", "%.2f", (double) (tab_reg[20]) / 10); + dstate_setinfo("battery.current", "%.2f", (double) (tab_reg[24]) / 10 ); + dstate_setinfo("battery.runtime", "%u", tab_reg[23] ); + + dstate_setinfo("input.bypass.frequency", "%u", (tab_reg[18]/10) ); + dstate_setinfo("output.frequency", "%u", (tab_reg[19]/10) ); + + if (tab_reg[22] != 0xFFFF) { + dstate_setinfo("ambient.1.present", "yes"); + dstate_setinfo("ambient.1.temperature", "%u", tab_reg[22] ); + } + + if (tab_reg[23] == 0xFFFF) { + /* battery.runtime == 0xFFFF means we're on mains */ + status_set("OL"); + } + else if (tab_reg[23] > BATTERY_RUNTIME_CRITICAL) { + /* we still have mora than BATTERY_RUNTIME_CRITICAL min left ? */ + status_set("OB"); + } + else { + status_set("LB"); + } + + /*TODO: + --essential + ups.status TRIM/BOOST/OVER + ups.alarm + + --dangerous + ups.shutdown + shutdown.return + shutdown.stop + shutdown.reboot + shutdown.reboot.graceful + bypass.start + beeper.enable + beeper.disable + */ + + alarm_commit(); + status_commit(); + dstate_dataok(); + + return; +} + +void upsdrv_shutdown(void) + __attribute__((noreturn)); + +void upsdrv_shutdown(void) +{ + fatalx(EXIT_FAILURE, "shutdown not supported"); +} + +void upsdrv_help(void) +{ +} + +/* list flags and values that you want to receive via -x */ +void upsdrv_makevartable(void) +{ +} + +void upsdrv_initups(void) +{ + int r; + upsdebugx(2, "upsdrv_initups"); + + modbus_ctx = modbus_new_rtu(device_path, 9600, 'N', 8, 1); + if (modbus_ctx == NULL) + fatalx(EXIT_FAILURE, "Unable to create the libmodbus context"); + + r = modbus_set_slave(modbus_ctx, MODBUS_SLAVE_ID); /* slave ID */ + if (r < 0) { + modbus_free(modbus_ctx); + fatalx(EXIT_FAILURE, "Invalid modbus slave ID %d",MODBUS_SLAVE_ID); + } + + if (modbus_connect(modbus_ctx) == -1) { + modbus_free(modbus_ctx); + fatalx(EXIT_FAILURE, "modbus_connect: unable to connect: %s", modbus_strerror(errno)); + } + +} + +void upsdrv_cleanup(void) +{ + if (modbus_ctx != NULL) { + modbus_close(modbus_ctx); + modbus_free(modbus_ctx); + } +} + +/* Modbus Read Input Registers */ +static int mrir(modbus_t * arg_ctx, int addr, int nb, uint16_t * dest) +{ + int r, i; + + /* zero out the thing, because we might have reused it */ + for (i=0; i + Copyright (C) 2004 Silvino B. Magalhães + 2019 Roberto Panerai Velloso This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,8 +24,11 @@ 2005/06/30 - Version 0.41 - patch for solaris compability 2005/07/01 - Version 0.50 - add internal e external shutdown programming 2005/08/18 - Version 0.60 - save external shutdown programming to ups, - and support new cables for solis 3 + and support new cables for solis 3 2015/09/19 - Version 0.65 - patch for correct reading for Microsol Back-Ups BZ1200-BR + 2017/12/21 - Version 0.66 - remove memory leaks (unfreed strdup()s); + remove ser_flush_in calls that were causing desync issues; + other minor improvements in source code. (see the version control logs for more recent updates) Microsol contributed with UPS Solis 1.5 HS 1.5 KVA for my tests. @@ -33,22 +37,25 @@ */ +#include "main.h" /* Includes "config.h", must be first */ + #include #include -#include -#include "main.h" +#include "nut_stdint.h" #include "serial.h" +#include "nut_float.h" #include "solis.h" #include "timehead.h" #define DRIVER_NAME "Microsol Solis UPS driver" -#define DRIVER_VERSION "0.65" +#define DRIVER_VERSION "0.68" /* driver description structure */ upsdrv_info_t upsdrv_info = { DRIVER_NAME, DRIVER_VERSION, - "Silvino B. Magalhães ", + "Silvino B. Magalhães " \ + "Roberto Panerai Velloso ", DRV_STABLE, { NULL } }; @@ -56,7 +63,7 @@ upsdrv_info_t upsdrv_info = { #define false 0 #define true 1 #define RESP_END 0xFE -#define ENDCHAR 13 /* replies end with CR */ +#define ENDCHAR 13 /* replies end with CR */ /* solis commands */ #define CMD_UPSCONT 0xCC #define CMD_SHUT 0xDD @@ -105,327 +112,173 @@ upsdrv_info_t upsdrv_info = { #define FMT_DAYS " %d %d %d %d %d %d %d\n" /* convert standard days string to firmware format */ -static char* convdays( char *cop ) -{ +static char* convert_days(char *cop) { + static char alt[8]; - char *stra; - char alt[8]; - int i, ish, fim, iw; - iw = weekn; - if ( iw == 6) + int ish, fim; + if (weekn >= 6 || weekn < 0) ish = 0; else - ish = 1 + iw; + ish = 1 + weekn; fim = 7 - ish; /* rotate left only 7 bits */ - for(i=0; i < fim; i++) { - alt[i] = cop[i+ish]; - } + memcpy(alt, &cop[ish], (size_t)fim); - if ( ish > 0 ) { - - for(i=0; i < ish; i++) { - alt[i+fim] = cop[i]; - } - } + if (ish > 0) + memcpy(&alt[fim], cop, (size_t)ish); alt[7] = 0; /* string terminator */ - stra = strdup( alt ); - return stra; + return alt; } -static int IsBinary(char ch ) -{ - if( ch == '1' || ch == '0' ) - return 1; - else - return 0; +inline static int is_binary(char ch ) { + return ( ch == '1' || ch == '0' ); } /* convert string to binary */ -static int Binary( char *nome ) -{ +static uint8_t str2bin( char *binStr ) { + uint8_t result = 0; + int i; - char ch, cc; - int cont=0, nint = 1, tobin=0; - int ex, nbin; - - while( *nome && ( cont < 7 ) ) { - ch = *nome; - if( !(IsBinary( ch ) ) ) - nint = 0; + for (i = 0; i < 7; ++i) { + char ch = binStr[i]; + if (is_binary(ch)) + result += ( (ch - '0') << (6 - i) ); else - { - if( ch == '1') { - cc = 1; - ex = (6 - cont); - nbin = cc<> (5 - weekn - i)) & 0x01; - switch ( iw ) - { - case 0: /* sunday */ - { - alt[0] = ( ( ( dweek & 0x20 ) == 0x20 ) ); - alt[1] = ( ( ( dweek & 0x10 ) == 0x10 ) ); - alt[2] = ( ( ( dweek & 0x08 ) == 0x08 ) ); - alt[3] = ( ( ( dweek & 0x04 ) == 0x04 ) ); - alt[4] = ( ( ( dweek & 0x02 ) == 0x02 ) ); - alt[5] = ( ( ( dweek & 0x01 ) == 0x01 ) ); - alt[6] = ( ( ( dweek & 0x40 ) == 0x40 ) ); - break; - } - case 1: - { - alt[0] = ( ( ( dweek & 0x10 ) == 0x10 ) ); - alt[1] = ( ( ( dweek & 0x08 ) == 0x08 ) ); - alt[2] = ( ( ( dweek & 0x04 ) == 0x04 ) ); - alt[3] = ( ( ( dweek & 0x02 ) == 0x02 ) ); - alt[4] = ( ( ( dweek & 0x01 ) == 0x01 ) ); - alt[5] = ( ( ( dweek & 0x40 ) == 0x40 ) ); - alt[6] = ( ( ( dweek & 0x20 ) == 0x20 ) ); - break; - } - case 2: - { - alt[0] = ( ( ( dweek & 0x08 ) == 0x08 ) ); - alt[1] = ( ( ( dweek & 0x04 ) == 0x04 ) ); - alt[2] = ( ( ( dweek & 0x02 ) == 0x02 ) ); - alt[3] = ( ( ( dweek & 0x01 ) == 0x01 ) ); - alt[4] = ( ( ( dweek & 0x40 ) == 0x40 ) ); - alt[5] = ( ( ( dweek & 0x20 ) == 0x20 ) ); - alt[6] = ( ( ( dweek & 0x10 ) == 0x10 ) ); - break; - } - case 3: - { - alt[0] = ( ( ( dweek & 0x04 ) == 0x04 ) ); - alt[1] = ( ( ( dweek & 0x02 ) == 0x02 ) ); - alt[2] = ( ( ( dweek & 0x01 ) == 0x01 ) ); - alt[3] = ( ( ( dweek & 0x40 ) == 0x40 ) ); - alt[4] = ( ( ( dweek & 0x20 ) == 0x20 ) ); - alt[5] = ( ( ( dweek & 0x10 ) == 0x10 ) ); - alt[6] = ( ( ( dweek & 0x08 ) == 0x08 ) ); - break; - } - case 4: - { - alt[0] = ( ( ( dweek & 0x02 ) == 0x02 ) ); - alt[1] = ( ( ( dweek & 0x01 ) == 0x01 ) ); - alt[2] = ( ( ( dweek & 0x40 ) == 0x40 ) ); - alt[3] = ( ( ( dweek & 0x20 ) == 0x20 ) ); - alt[4] = ( ( ( dweek & 0x10 ) == 0x10 ) ); - alt[5] = ( ( ( dweek & 0x08 ) == 0x08 ) ); - alt[6] = ( ( ( dweek & 0x04 ) == 0x04 ) ); - break; - } - case 5: - { - alt[0] = ( ( ( dweek & 0x01 ) == 0x01 ) ); - alt[1] = ( ( ( dweek & 0x40 ) == 0x40 ) ); - alt[2] = ( ( ( dweek & 0x20 ) == 0x20 ) ); - alt[3] = ( ( ( dweek & 0x10 ) == 0x10 ) ); - alt[4] = ( ( ( dweek & 0x08 ) == 0x08 ) ); - alt[5] = ( ( ( dweek & 0x04 ) == 0x04 ) ); - alt[6] = ( ( ( dweek & 0x02 ) == 0x02 ) ); - break; - } - case 6: /* saturday */ - { - alt[0] = ( ( ( dweek & 0x40 ) == 0x40 ) ); - alt[1] = ( ( ( dweek & 0x20 ) == 0x20 ) ); - alt[2] = ( ( ( dweek & 0x10 ) == 0x10 ) ); - alt[3] = ( ( ( dweek & 0x08 ) == 0x08 ) ); - alt[4] = ( ( ( dweek & 0x04 ) == 0x04 ) ); - alt[5] = ( ( ( dweek & 0x02 ) == 0x02 ) ); - alt[6] = ( ( ( dweek & 0x01 ) == 0x01 ) ); - } + for (i = 0; i < weekn+1; ++i) + alt[i+(6-weekn)] = (dweek >> (6 - i)) & 0x01; - } - - for(i=0; i < 7; i++) { - if( alt[i] == 0 ) - alt[i] = '0'; - if( alt[i] == 1 ) - alt[i] = '1'; - } + for (i=0; i < 7; i++) + alt[i] += '0'; alt[7] = 0; /* string terminator */ - keewd = Binary ( alt ); - - return keewd; + return str2bin(alt); } -static int IsHour( char *strx, int qual ) -{ +static int is_hour(char *hour, int qual) { + int hora, min; - int hora=0, min = 0; - - if ((strlen(strx) != 5) || (sscanf(strx, "%d:%d", &hora, &min) != 2)) { + if ((strlen(hour) != 5) || + (sscanf(hour, "%d:%d", &hora, &min) != 2)) return -1; - } - if( qual ) { + if (qual) { dhour = hora; dmin = min; - } - else - { + } else { lhour = hora; lmin = min; } return 1; - } - -static void sendshut( void ) -{ - +static void send_shutdown( void ) { int i; - for(i=0; i < 10; i++) + for (i = 0; i < 10; i++) ser_send_char(upsfd, CMD_SHUT ); upslogx(LOG_NOTICE, "Ups shutdown command sent"); printf("Ups shutdown command sent\n"); - } /* save config ups */ -static void confups( void ) -{ - +static void save_ups_config( void ) { int i, chks = 0; - ConfigPack[0] = 0xCF; - ConfigPack[1] = ihour; - ConfigPack[2] = imin; - ConfigPack[3] = isec; - ConfigPack[4] = lhour; - ConfigPack[5] = lmin; - ConfigPack[6] = dhour; - ConfigPack[7] = dmin; - ConfigPack[8] = weekn << 5; - ConfigPack[8] = ConfigPack[8] | dian; - ConfigPack[9] = mesn << 4; - ConfigPack[9] = ConfigPack[9] | ( anon - BASE_YEAR ); - ConfigPack[10] = DaysOffWeek; + /* FIXME? Check for overflows with int => char truncations? + * See also microsol-common.c for very similar code + */ + ConfigPack[0] = (unsigned char)0xCF; + ConfigPack[1] = (unsigned char)ihour; + ConfigPack[2] = (unsigned char)imin; + ConfigPack[3] = (unsigned char)isec; + ConfigPack[4] = (unsigned char)lhour; + ConfigPack[5] = (unsigned char)lmin; + ConfigPack[6] = (unsigned char)dhour; + ConfigPack[7] = (unsigned char)dmin; + ConfigPack[8] = (unsigned char)(weekn << 5); + ConfigPack[8] = (unsigned char)ConfigPack[8] | (unsigned char)dian; + ConfigPack[9] = (unsigned char)(mesn << 4); + ConfigPack[9] = (unsigned char)ConfigPack[9] | (unsigned char)( anon - BASE_YEAR ); + ConfigPack[10] = (unsigned char)DaysOffWeek; /* MSB zero */ ConfigPack[10] = ConfigPack[10] & (~(0x80)); - for(i=0; i < 11; i++) - chks = chks + ConfigPack[i]; + for (i=0; i < 11; i++) + chks += ConfigPack[i]; - ConfigPack[11] = chks % 256; - - for(i=0; i < 12; i++) - ser_send_char(upsfd, ConfigPack[i] ); + /* FIXME? Does truncation to char have same effect as %256 ? */ + ConfigPack[11] = (unsigned char)(chks % 256); + for (i=0; i < 12; i++) + ser_send_char(upsfd, ConfigPack[i]); } /* print UPS internal variables */ -static void prnInfo( void ) -{ +static void print_info( void ) { + printf(UPS_DATE, Year, Month, Day); + printf(SYS_DATE, anon, mesn, dian, seman); + printf(UPS_TIME, ihour, imin, isec); - int sunday=0, monday=0, tuesday=0, wednesday=0, thursday=0, friday=0, saturday=0; - unsigned char dweek; - - printf( UPS_DATE, Year, Month, Day ); - printf( SYS_DATE, anon, mesn, dian, seman ); - - printf( UPS_TIME, ihour, imin, isec); - - dweek = DaysStd; - - if( prgups > 0 ) { + if (prgups > 0) { + /*sunday, monday, tuesday, wednesday, thursday, friday, saturday*/ + int week_days[7] = {0, 0, 0, 0, 0, 0, 0}; + int i; /* this is the string to binary standard */ - sunday = ( ( dweek & 0x40 ) == 0x40 ); - monday = ( ( dweek & 0x20 ) == 0x20 ); - tuesday = ( ( dweek & 0x10 ) == 0x10 ); - wednesday = ( ( dweek & 0x08 ) == 0x08 ); - thursday = ( ( dweek & 0x04 ) == 0x04 ); - friday = ( ( dweek & 0x02 ) == 0x02 ); - saturday = ( ( dweek & 0x01 ) == 0x01 ); + for (i = 0; i < 7; ++i) + week_days[i] = (DaysStd >> (6 - i)) & 0x01; - if( prgups == 3) - printf( PRG_ONOU ); + if (prgups == 3) + printf(PRG_ONOU); else - printf( PRG_ONON ); - printf( TIME_ON, lhour, lmin); - printf( TIME_OFF, dhour, dmin); - printf( PRG_DAYS ); - printf( FMT_DAYS, sunday, monday, tuesday, wednesday, thursday, friday, saturday); - } - else - printf( PRG_ONOF ); + printf(PRG_ONON); + printf(TIME_ON, lhour, lmin); + printf(TIME_OFF, dhour, dmin); + printf(PRG_DAYS); + printf(FMT_DAYS, + week_days[0], week_days[1], week_days[2], + week_days[3], week_days[4], week_days[5], + week_days[6]); + } else + printf(PRG_ONOF); } /* is today shutdown day ? */ -static int IsToday( unsigned char dweek, int nweek) -{ - - switch ( nweek ) - { - case 0: /* sunday */ - return ( ( ( dweek & 0x40 ) == 0x40 ) ); - case 1: - return ( ( ( dweek & 0x20 ) == 0x20 ) ); - case 2: - return ( ( ( dweek & 0x10 ) == 0x10 ) ); - case 3: - return ( ( ( dweek & 0x08 ) == 0x08 ) ); - case 4: - return ( ( ( dweek & 0x04 ) == 0x04 ) ); - case 5: - return ( ( ( dweek & 0x02 ) == 0x02 ) ); - case 6: /* saturday */ - return ( ( ( dweek & 0x01 ) == 0x01 ) ); - } - - return 0; - +inline static int is_today( unsigned char dweek, int nweek) { + return (dweek >> (6 - nweek)) & 0x01; } -static void AutonomyCalc( int iauto ) /* all models */ -{ - - int indice, indd, lim, min, max, inf, sup, indc, bx, ipo =0; +/* all models */ +static void autonomy_calc( int iauto ) { + int indice, indd, lim, min, max, inf, sup, indc, bx, ipo = 0; bx = bext[iauto]; indice = RecPack[3]; indd = indice - 139; - if( UtilPower > 20 ) - ipo = ( UtilPower - 51 ) / 100; + if (UtilPower > 20) + ipo = (UtilPower - 51) / 100; indc = auton[iauto].maxi; @@ -438,42 +291,38 @@ static void AutonomyCalc( int iauto ) /* all models */ lim = max - 139; sup = max + 1; - if( UtilPower <= 20 ) { + if (UtilPower <= 20) { Autonomy = 170; - maxauto = 170; - } - else - { + maxauto = 170; + } else { maxauto = auton[iauto].mm[ipo][lim]; - if( indice > inf && indice < sup ) { + if( indice > inf && indice < sup ) Autonomy = auton[iauto].mm[ipo][indd]; - } - else - { - if( indice > max ) Autonomy = maxauto; - if( indice < min ) Autonomy = 0; + else { + if (indice > max) + Autonomy = maxauto; + if (indice < min) + Autonomy = 0; } } - if( BattExtension > 0 && iauto < 4 ) + if (BattExtension > 0 && iauto < 4) Autonomy = ( Autonomy * ( BattExtension + bx ) * 1.0 / bx ); - } -static void ScanReceivePack( void ) -{ - int aux, im, ov = 0; +static void scan_received_pack(void) { + int aux, im, ov; /* model independent data */ - Year = ( RecPack[ 19 ] & 0x0F ) + BASE_YEAR; - Month = ( RecPack[ 19 ] & 0xF0 ) >> 4; - Day = ( RecPack[ 18 ] & 0x1F ); + Year = (RecPack[ 19 ] & 0x0F) + BASE_YEAR; + Month = (RecPack[ 19 ] & 0xF0) >> 4; + Day = (RecPack[ 18 ] & 0x1F); DaysOnWeek = RecPack[17]; /* Days of week if in UPS shutdown programming mode */ - if( prgups == 3 ) { - DaysStd = revertdays( DaysOnWeek ); + if (prgups == 3) { + DaysStd = revert_days( DaysOnWeek ); /* time for programming UPS off */ dhour = RecPack[15]; @@ -488,21 +337,23 @@ static void ScanReceivePack( void ) imin = RecPack[10]; isec = RecPack[9]; - if( ( ( 0x01 & RecPack[ 20 ] ) == 0x01 ) ) + if ((0x01 & RecPack[20]) == 0x01) Out220 = 1; - CriticBatt = ( ( 0x04 & RecPack[ 20 ] ) == 0x04 ); - InversorOn = ( ( 0x08 & RecPack[ 20 ] ) == 0x08 ); - SuperHeat = ( ( 0x10 & RecPack[ 20 ] ) == 0x10 ); - SourceFail = ( ( 0x20 & RecPack[ 20 ] ) == 0x20 ); - OverCharge = ( ( 0x80 & RecPack[ 20 ] ) == 0x80 ); - if( ( ( 0x40 & RecPack[ 20 ] ) == 0x40 ) ) + CriticBatt = (0x04 & RecPack[20]) == 0x04; + InversorOn = (0x08 & RecPack[20]) == 0x08; + SuperHeat = (0x10 & RecPack[20]) == 0x10; + SourceFail = (0x20 & RecPack[20]) == 0x20; + OverCharge = (0x80 & RecPack[20]) == 0x80; + + if ((0x40 & RecPack[20]) == 0x40) InputValue = 1; else InputValue = 0; - Temperature = ( 0x7F & RecPack[ 4 ]); - if( ( ( 0x80 & RecPack[ 4 ] ) == 0x80 ) ) - Temperature = Temperature - 128; + + Temperature = 0x7F & RecPack[4]; + if (0x80 & RecPack[4]) + Temperature -= 128; /* model dependent data */ @@ -510,36 +361,29 @@ static void ScanReceivePack( void ) ov = Out220; if (SolisModel != 16) { - - if( RecPack[ 6 ] >= 194 ) - InVoltage = RecPack[ 6 ] * ctab[imodel].m_involt194[0] + ctab[imodel].m_involt194[1]; + if (RecPack[6] >= 194) + InVoltage = RecPack[6] * ctab[imodel].m_involt194[0] + ctab[imodel].m_involt194[1]; else - InVoltage = RecPack[ 6 ] * ctab[imodel].m_involt193[0] + ctab[imodel].m_involt193[1]; + InVoltage = RecPack[6] * ctab[imodel].m_involt193[0] + ctab[imodel].m_involt193[1]; } else { /* Code InVoltage for STAY1200_USB */ - - if ((RecPack[20] & 0x1) == 0) { //IsOutVoltage 220 - + if ((RecPack[20] & 0x1) == 0) /* IsOutVoltage 220 */ InVoltage = RecPack[2] * ctab[imodel].m_involt193[0] + ctab[imodel].m_involt193[1]; - } else { - + else InVoltage = RecPack[2] * ctab[imodel].m_involt193[0] + ctab[imodel].m_involt193[1] - 3.0; - } } BattVoltage = RecPack[ 3 ] * ctab[imodel].m_battvolt[0] + ctab[imodel].m_battvolt[1]; NominalPower = nompow[im]; - if( SourceFail ) { + if (SourceFail) { OutVoltage = RecPack[ 1 ] * ctab[imodel].m_outvolt_i[ov][0] + ctab[imodel].m_outvolt_i[ov][1]; OutCurrent = RecPack[ 5 ] * ctab[imodel].m_outcurr_i[ov][0] + ctab[imodel].m_outcurr_i[ov][1]; AppPower = ( RecPack[ 5 ] * RecPack[ 1 ] ) * ctab[imodel].m_appp_i[ov][0] + ctab[imodel].m_appp_i[ov][1]; UtilPower = ( RecPack[ 7 ] + RecPack[ 8 ] * 256 ) * ctab[imodel].m_utilp_i[ov][0] + ctab[imodel].m_utilp_i[ov][1]; InCurrent = 0; - } - else - { + } else { OutVoltage = RecPack[ 1 ] * ctab[imodel].m_outvolt_s[ov][0] + ctab[imodel].m_outvolt_s[ov][1]; OutCurrent = RecPack[ 5 ] * ctab[imodel].m_outcurr_s[ov][0] + ctab[imodel].m_outcurr_s[ov][1]; AppPower = ( RecPack[ 5 ] * RecPack[ 1 ] ) * ctab[imodel].m_appp_s[ov][0] + ctab[imodel].m_appp_s[ov][1]; @@ -547,102 +391,89 @@ static void ScanReceivePack( void ) InCurrent = ( ctab[imodel].m_incurr[0] * 1.0 / BattVoltage ) - ( AppPower * 1.0 / ctab[imodel].m_incurr[1] ) + OutCurrent *( OutVoltage * 1.0 / InVoltage ); } - if (SolisModel == 16) { - int configRelay = (RecPack[6] & 0x38) >> 3; - double TENSAO_SAIDA_F1_MR[8] = { 1.1549, 1.0925, 0.0, 0.0, 1.0929, 1.0885, 0.0, 0.8654262224145391 }; - double TENSAO_SAIDA_F2_MR[8] = { -6.9157, 11.026, 10.43, 0.0, -0.6109, 12.18, 0.0, 13.677}; + if (SolisModel == 16) { + int configRelay = (RecPack[6] & 0x38) >> 3; + double TENSAO_SAIDA_F1_MR[8] = { 1.1549, 1.0925, 0.0, 0.0, 1.0929, 1.0885, 0.0, 0.8654262224145391 }; + double TENSAO_SAIDA_F2_MR[8] = { -6.9157, 11.026, 10.43, 0.0, -0.6109, 12.18, 0.0, 13.677}; - const double TENSAO_SAIDA_F2_MI[8] ={ 5.59, 9.47, 13.7, 0.0, 0.0, 0.0, 0.0, 0.0 }; - const double TENSAO_SAIDA_F1_MI[8] = { 7.9, 9.1, 17.6, 0.0, 0.0, 0.0, 0.0, 0.0 }; + const double TENSAO_SAIDA_F2_MI[8] ={ 5.59, 9.47, 13.7, 0.0, 0.0, 0.0, 0.0, 0.0 }; + const double TENSAO_SAIDA_F1_MI[8] = { 7.9, 9.1, 17.6, 0.0, 0.0, 0.0, 0.0, 0.0 }; - const double corrente_saida_F1_MR = 0.12970000389100012; - const double corrente_saida_F2_MR = 0.5387060281204546; - /* double corrente_saida_F1_MI = 0.1372; - double corrente_saida_F2_MI = 0.3456; */ + const double corrente_saida_F1_MR = 0.12970000389100012; + const double corrente_saida_F2_MR = 0.5387060281204546; + /* double corrente_saida_F1_MI = 0.1372; + double corrente_saida_F2_MI = 0.3456; */ - if (SourceFail) { - if (RecPack[20] == 0) { - double a = RecPack[1] * 2; - a /= 128.0; - // a = double sqrt(a); - OutVoltage = RecPack[1] * a * TENSAO_SAIDA_F1_MI[configRelay] + TENSAO_SAIDA_F2_MI[configRelay]; + if (SourceFail) { + if (RecPack[20] == 0) { + double a = RecPack[1] * 2; + a /= 128.0; + /* a = double sqrt(a); */ + OutVoltage = RecPack[1] * a * TENSAO_SAIDA_F1_MI[configRelay] + TENSAO_SAIDA_F2_MI[configRelay]; + } + } else { + OutCurrent = (float)(corrente_saida_F1_MR * RecPack[5] + corrente_saida_F2_MR); + OutVoltage = RecPack[1] * TENSAO_SAIDA_F1_MR[configRelay] + TENSAO_SAIDA_F2_MR[configRelay]; + AppPower = OutCurrent * OutVoltage; - } - - } else { - - - OutCurrent = (float)(corrente_saida_F1_MR * RecPack[5] + corrente_saida_F2_MR); - OutVoltage = RecPack[1] * TENSAO_SAIDA_F1_MR[configRelay] + TENSAO_SAIDA_F2_MR[configRelay]; - AppPower = OutCurrent * OutVoltage; - - - - double RealPower = (RecPack[7] + RecPack[8] * 256); - - double potVA1 = 5.968 * AppPower - 284.36; - double potVA2 = 7.149 * AppPower - 567.18; - double potLin = 0.1664 * RealPower + 49.182; - double potRe = 0.1519 * RealPower + 32.644; - if (fabs(potVA1 - RealPower) < fabs(potVA2 - RealPower)) { - RealPower = potLin; - } else { - RealPower = potRe; - - } - if (OutCurrent < 0.7) { - RealPower = AppPower; - } - if (AppPower < RealPower) { - double f = AppPower; - AppPower = RealPower; - RealPower = f; - } + double RealPower = (RecPack[7] + RecPack[8] * 256); + double potVA1 = 5.968 * AppPower - 284.36; + double potVA2 = 7.149 * AppPower - 567.18; + double potLin = 0.1664 * RealPower + 49.182; + double potRe = 0.1519 * RealPower + 32.644; + if (fabs(potVA1 - RealPower) < fabs(potVA2 - RealPower)) + RealPower = potLin; + else + RealPower = potRe; + if (OutCurrent < 0.7) + RealPower = AppPower; + if (AppPower < RealPower) { + double f = AppPower; + AppPower = RealPower; + RealPower = f; } } + } - aux = ( RecPack[ 21 ] + RecPack[ 22 ] * 256 ); - if( aux > 0 ) + aux = (RecPack[ 21 ] + RecPack[ 22 ] * 256); + if (aux > 0) InFreq = ctab[imodel].m_infreq * 1.0 / aux; /* Specific for STAY1200_USB */ - if (SolisModel == 16) { - InFreq = ((float)(0.37 * (257 - (aux >> 8)))); - } - else + if (SolisModel == 16) { + InFreq = ((float)(0.37 * (257 - (aux >> 8)))); + } else InFreq = 0; /* input voltage offset */ - if( InVoltage < InVolt_offset ) { /* all is equal 30 */ + if (InVoltage < InVolt_offset) { /* all is equal 30 */ InFreq = 0; InVoltage = 0; InCurrent = 0; } /* app power offset */ - if( AppPower < ctab[imodel].m_appp_offset ) { + if (AppPower < ctab[imodel].m_appp_offset) { AppPower = 0; UtilPower = 0; ChargePowerFactor = 0; OutCurrent = 0; } - if( im < 3 ) - AutonomyCalc( im ); - else - { - if( BattExtension == 80 ) - AutonomyCalc( im + 1 ); + if (im < 3) + autonomy_calc(im); + else { + if (BattExtension == 80 && im == 3) + autonomy_calc(im + 1); else - AutonomyCalc( im ); + autonomy_calc(im); } /* model independent data */ - batcharge = ( Autonomy / maxauto ) * 100.0; upscharge = ( AppPower / NominalPower ) * 100.0; @@ -650,45 +481,46 @@ static void ScanReceivePack( void ) batcharge = 100.0; OutFreq = 60; - if( !( InversorOn ) ) { + if (!InversorOn) { OutVoltage = 0; OutFreq = 0; } - if( ( !( SourceFail ) && InversorOn ) ) + if (!SourceFail && InversorOn) OutFreq = InFreq; - if( AppPower <= 0 ) /* charge pf */ + if (AppPower < 0) /* charge pf */ ChargePowerFactor = 0; - else - { - if( AppPower == 0 ) + else { + if( d_equal(AppPower, 0) ) ChargePowerFactor = 100; else - ChargePowerFactor = (( UtilPower / AppPower) * 100 ); - if( ChargePowerFactor > 100 ) + ChargePowerFactor = (( UtilPower / AppPower) * 100); + + if(ChargePowerFactor > 100) ChargePowerFactor = 100; } - if( SourceFail && SourceLast ) /* first time failure */ + if (SourceFail && SourceLast) /* first time failure */ FailureFlag = true; /* source return */ - if( !( SourceFail ) && !( SourceLast ) ) { + if (!SourceFail && !SourceLast) { SourceReturn = true; - ser_flush_in(upsfd,"",0); /* clean port */ + /* clean port: */ + /* ser_flush_in(upsfd,"",0); */ } - if( !( SourceFail ) == SourceLast ) { + if((!SourceFail) == SourceLast) { SourceReturn = false; FailureFlag = false; } - SourceLast = !( SourceFail ); + SourceLast = !SourceFail; /* Autonomy */ - if( Autonomy < 5 ) + if (Autonomy < 5) LowBatt = true; else LowBatt = false; @@ -696,337 +528,298 @@ static void ScanReceivePack( void ) UpsPowerFactor = 700; /* input 110V or 220v */ - if( InputValue == 0 ) { + if (InputValue == 0) { InDownLim = 75; InUpLim = 150; NomInVolt = 110; - } - else - { + } else { InDownLim = 150; InUpLim = 300; NomInVolt = 220; } /* output volage 220V or 110V */ - if( Out220 ) { + if (Out220) { OutDownLim = 190; OutUpLim = 250; NomOutVolt = 220; - } - else - { + } else { OutDownLim = 100; OutUpLim = 140; NomOutVolt = 110; } - if( SourceFail ) /* source status */ + if (SourceFail) /* source status */ InputStatus = 2; else InputStatus = 1; - if( InversorOn ) /* output status */ + if (InversorOn) /* output status */ OutputStatus = 1; else OutputStatus = 2; - if( OverCharge ) + if (OverCharge) OutputStatus = 3; - if( CriticBatt ) /* battery status */ + if (CriticBatt) /* battery status */ BattStatus = 4; else BattStatus = 1; SourceEvents = 0; - if( FailureFlag ) + if (FailureFlag) SourceEvents = 1; - if( SourceReturn ) + if (SourceReturn) SourceEvents = 2; /* verify Inversor */ - if( Flag_inversor ) { + if (Flag_inversor) { InversorOnLast = InversorOn; Flag_inversor = false; } OutputEvents = 0; - if( InversorOn && !( InversorOnLast ) ) + if (InversorOn && !InversorOnLast) OutputEvents = 26; - if( InversorOnLast && !( InversorOn ) ) + if (InversorOnLast && !InversorOn) OutputEvents = 27; InversorOnLast = InversorOn; - if( SuperHeat && !( SuperHeatLast ) ) + + if (SuperHeat && !SuperHeatLast) OutputEvents = 12; - if( SuperHeatLast && !( SuperHeat ) ) + if (SuperHeatLast && !SuperHeat) OutputEvents = 13; SuperHeatLast = SuperHeat; - if( OverCharge && !( OverChargeLast ) ) + + if (OverCharge && !OverChargeLast) OutputEvents = 10; - if( OverChargeLast && !( OverCharge ) ) + if (OverChargeLast && !OverCharge) OutputEvents = 11; OverChargeLast = OverCharge; BattEvents = 0; CriticBattLast = CriticBatt; - } -static void -CommReceive(const char *bufptr, int size) -{ +static void comm_receive(const unsigned char *bufptr, size_t size) { + if (size == packet_size) { + int CheckSum = 0; + size_t i; - int i, CheckSum, i_end; + memcpy(RecPack, bufptr, packet_size); - if( size == 25 ) { - i_end = 25; - for( i = 0 ; i < i_end ; ++i ) { - RecPack[i] = *bufptr; - bufptr++; - } - if(nut_debug_level >= 3) { - upsdebug_hex(3, "CommReceive: RecPack", RecPack, size); - } + if (nut_debug_level >= 3) + upsdebug_hex(3, "comm_receive: RecPack", RecPack, size); /* CheckSum verify */ - CheckSum = 0; - i_end = 23; - for( i = 0 ; i < i_end ; ++i ) - CheckSum = RecPack[ i ] + CheckSum; + for (i = 0 ; i < packet_size-2 ; ++i ) + CheckSum += RecPack[i]; CheckSum = CheckSum % 256; upsdebugx(4, "%s: calculated checksum = 0x%02x, RecPack[23] = 0x%02x", __func__, CheckSum, RecPack[23]); - ser_flush_in(upsfd,"",0); /* clean port */ + /* clean port: */ + /* ser_flush_in(upsfd,"",0); */ - /* RecPack[0] identify the model number below. - * SOLIS = 1; - RHINO = 2; - STAY = 3; - SOLIS_LI_700 = 169; - SOLIS_M11 = 171; - SOLIS_M15 = 175; - SOLIS_M14 = 174; - SOLIS_M13 = 173; - SOLISDC_M14 = 201; - SOLISDC_M13 = 206; - SOLISDC_M15 = 207; - CABECALHO_RHINO = 194; - PS800 = 185; - STAY1200_USB = 186; - PS350_CII = 184; - PS2200 = 187; - PS2200_22 = 188; - STAY700_USB = 189; - BZ1500 = 190; + /* RecPack[0] == model number below: + * SOLIS = 1; + * RHINO = 2; + * STAY = 3; + * SOLIS_LI_700 = 169; + * SOLIS_M11 = 171; + * SOLIS_M15 = 175; + * SOLIS_M14 = 174; + * SOLIS_M13 = 173; + * SOLISDC_M14 = 201; + * SOLISDC_M13 = 206; + * SOLISDC_M15 = 207; + * CABECALHO_RHINO = 194; + * PS800 = 185; + * STAY1200_USB = 186; + * PS350_CII = 184; + * PS2200 = 187; + * PS2200_22 = 188; + * STAY700_USB = 189; + * BZ1500 = 190; */ - if( ( ( (RecPack[0] & 0xF0) == 0xA0 ) || (RecPack[0] & 0xF0) == 0xB0) - && ( RecPack[ 24 ] == 254 ) - && ( RecPack[ 23 ] == CheckSum ) ) { - if(!(detected)) { + if ((((RecPack[0] & 0xF0) == 0xA0 ) || (RecPack[0] & 0xF0) == 0xB0) && + (RecPack[24] == 254) && + (RecPack[23] == CheckSum)) { - if (RecPack[0] == 186) { + if (!detected) { + if (RecPack[0] == 186) SolisModel = 16; - } else { + else SolisModel = (int) (RecPack[0] & 0x0F); - } - if( SolisModel < 13 ) + + if (SolisModel < 13) imodel = SolisModel - 10; /* 10 = 0, 11 = 1 */ else imodel = SolisModel - 11; /* 13 = 2, 14 = 3, 15 = 4 */ detected = true; - } - switch( SolisModel ) - { - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - { - ScanReceivePack(); - break; - } - case 16: // STAY1200_USB model - { - ScanReceivePack(); - break; - } - default: - { - printf( M_UNKN ); - ScanReceivePack(); // Scan anyway. - break; - } + switch (SolisModel) { + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + scan_received_pack(); + break; + case 16: /* STAY1200_USB model */ + scan_received_pack(); + break; + default: + printf(M_UNKN); + scan_received_pack(); /* Scan anyway. */ + break; } } } } -static void getbaseinfo(void) -{ - unsigned char tmp; +static void get_base_info(void) { #ifdef PORTUGUESE - const char diassemana[7][4]={"Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"}; + const char DaysOfWeek[7][4]={"Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"}; #else const char DaysOfWeek[7][4]={"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; #endif - char *str1, *str2, *str3, *str4, *strx; - unsigned char Pacote[25]; - int i, i1=0, i2=0, tam; - const int tpac=25; + unsigned char packet[PACKET_SIZE], syncEOR = '\0', syncEOR_was_read = 0; + int i1=0, i2=0; + size_t i; + ssize_t tam; time_t tmt; struct tm *now; - time( &tmt ); - now = localtime( &tmt ); + struct tm tmbuf; + + time(&tmt); + now = localtime_r(&tmt, &tmbuf); dian = now->tm_mday; mesn = now->tm_mon+1; anon = now->tm_year+1900; ihour = now->tm_hour; imin = now->tm_min; isec = now->tm_sec; - weekn = now->tm_wday; + weekn = now->tm_wday; -#ifdef PORTUGUESE - strcpy( seman, diassemana[weekn] ); -#else - strcpy( seman, DaysOfWeek[weekn] ); -#endif + strcpy(seman, DaysOfWeek[weekn]); - if( testvar("battext")) + if (testvar("battext")) BattExtension = atoi(getval("battext")); - if( testvar("prgshut")) + if (testvar("prgshut")) prgups = atoi(getval("prgshut")); - if( prgups > 0 && prgups < 3 ) { - if( testvar("daysweek") ) { - strx = getval("daysweek"); - str1 = convdays( strx ); - DaysOnWeek = Binary( str1 ); + if (prgups > 0 && prgups < 3) { + if (testvar("daysweek")) + DaysOnWeek = str2bin(convert_days(getval("daysweek"))); + + if (testvar("daysoff")) { + char *doff = getval("daysoff"); + DaysStd = str2bin(doff); + DaysOffWeek = str2bin( convert_days(doff)); } - if( testvar("daysoff") ) { - strx = getval("daysoff"); - str2 = convdays( strx ); - DaysStd = Binary ( strx ); - DaysOffWeek = Binary( str2 ); - } + if (testvar("houron")) + i1 = is_hour(getval("houron"), 0); - if( testvar("houron") ) { - str3 = getval("houron"); - i1 = IsHour( str3, 0 ); - } + if (testvar("houroff")) + i2 = is_hour(getval("houroff"), 1); - if( testvar("houroff") ) { - str4 = getval("houroff"); - i2 = IsHour( str4, 1 ); - } - - if( i1 == 1 && i2 == 1 && ( DaysOnWeek > 0 ) ) { + if (i1 == 1 && i2 == 1 && (DaysOnWeek > 0)) { isprogram = 1; /* prgups == 1 ou 2 */ - if( prgups == 2 ) - confups(); /* save ups config */ - } - else - { - if( (i2 == 1) && ( DaysOffWeek > 0 ) ) { + if (prgups == 2) + save_ups_config(); /* save ups config */ + } else { + if (i2 == 1 && DaysOffWeek > 0) { isprogram = 1; - if( DaysOnWeek != DaysOffWeek ) DaysOnWeek = DaysOffWeek; + } } - } - } /* end prgups 1 - 2 */ /* dummy read attempt to sync - throw it out */ upsdebugx(3, "%s: sending CMD_UPSCONT and ENDCHAR to sync", __func__); ser_send(upsfd, "%c%c", CMD_UPSCONT, ENDCHAR); - /* Read until end-of-response character (0xFE): */ - for(i=0; i 0 && nut_debug_level >= 4) { - upsdebug_hex(4, "received from ser_get_buf_len()", Pacote, tam); + upsdebugx(4, "%s: requesting %zu bytes from ser_get_buf_len()", __func__, packet_size); + tam = ser_get_buf_len(upsfd, packet, packet_size, 3, 0); + if (tam < 0) { + upsdebugx(0, "%s: Error (%zd) reading from ser_get_buf_len()", __func__, tam); + fatalx(EXIT_FAILURE, NO_SOLIS); } - CommReceive((char *)Pacote, tam); + upsdebugx(2, "%s: received %zd bytes from ser_get_buf_len()", __func__, tam); + if (tam > 0 && nut_debug_level >= 4) { + upsdebug_hex(4, "received from ser_get_buf_len()", packet, (size_t)tam); + } + comm_receive(packet, (size_t)tam); } - if( (!detected) ) { + if (!detected) fatalx(EXIT_FAILURE, NO_SOLIS ); - } - switch( SolisModel ) - { + switch (SolisModel) { case 10: - case 11: case 12: - { Model = "Solis 1.0"; break; - } case 13: - { Model = "Solis 1.5"; break; - } case 14: - { Model = "Solis 2.0"; break; - } case 15: - { Model = "Solis 3.0"; break; - } case 16: Model = "Microsol Back-Ups BZ1200-BR"; break; } /* if( isprogram ) */ - if( prgups == 1 ) { + if (prgups == 1) { hourshut = dhour; minshut = dmin; - } - else - { - if( prgups == 2 || prgups == 3 ) { /* broadcast before firmware shutdown */ - if( dmin < 5 ) { - if( dhour > 1 ) + } else { + if (prgups == 2 || prgups == 3) { /* broadcast before firmware shutdown */ + if (dmin < 5) { + if (dhour > 1) hourshut = dhour - 1; else hourshut = 23; - minshut = 60 - ( 5 - dmin ); - } - else - { - hourshut = dhour; - minshut = dmin - 5; - } - } - } + minshut = 60 - ( 5 - dmin ); + } else { + hourshut = dhour; + minshut = dmin - 5; + } + } + } /* manufacturer */ dstate_setinfo("ups.mfr", "%s", "Microsol"); @@ -1040,91 +833,91 @@ static void getbaseinfo(void) printf("Detected %s on %s\n", dstate_getinfo("ups.model"), device_path); - prnInfo(); + print_info(); } -static void getupdateinfo(void) -{ - unsigned char temp[256]; - int tam, isday, hourn, minn; +static void get_update_info(void) { + unsigned char temp[256]; + int isday, hourn, minn; + ssize_t tam; /* time update and programable shutdown block */ time_t tmt; struct tm *now; - time( &tmt ); - now = localtime( &tmt ); + struct tm tmbuf; + + time(&tmt); + now = localtime_r(&tmt, &tmbuf); hourn = now->tm_hour; minn = now->tm_min; - weekn = now->tm_wday; + weekn = now->tm_wday; - if( isprogram || prgups == 3 ) { - if( isprogram ) - isday = IsToday( DaysStd, weekn ); + if (isprogram || prgups == 3) { + if (isprogram) + isday = is_today(DaysStd, weekn); else - isday = IsToday( DaysStd, weekn ); + isday = is_today( DaysStd, weekn); - if( isday ) - printf( TODAY_DD, hourshut, minshut ); + if (isday) + printf(TODAY_DD, hourshut, minshut); + + if ( + (hourn == hourshut) && + (minn >= minshut) && + isday) { - if( ( hourn == hourshut ) && ( minn >= minshut ) && isday ) { printf( SHUT_NOW ); progshut = 1; } } - /* programable shutdown end block */ - pacsize = 25; - /* get update package */ temp[0] = 0; /* flush temp buffer */ - upsdebugx(3, "%s: requesting %d bytes from ser_get_buf_len()", __func__, pacsize); - tam = ser_get_buf_len(upsfd, temp, pacsize, 3, 0); + upsdebugx(3, "%s: requesting %zu bytes from ser_get_buf_len()", __func__, packet_size); + tam = ser_get_buf_len(upsfd, temp, packet_size, 3, 0); - upsdebugx(2, "%s: received %d bytes from ser_get_buf_len()", __func__, tam); - if(tam > 0 && nut_debug_level >= 4) { - upsdebug_hex(4, "received from ser_get_buf_len()", temp, tam); + if (tam < 0) { + upsdebugx(0, "%s: Error (%zd) reading from ser_get_buf_len()", __func__, tam); + fatalx(EXIT_FAILURE, NO_SOLIS); } - CommReceive((char *)temp, tam); + upsdebugx(2, "%s: received %zd bytes from ser_get_buf_len()", __func__, tam); + if(tam > 0 && nut_debug_level >= 4) + upsdebug_hex(4, "received from ser_get_buf_len()", temp, (size_t)tam); + comm_receive(temp, (size_t)tam); } -static int instcmd(const char *cmdname, const char *extra) -{ - - if (!strcasecmp(cmdname, "shutdown.return")) { +static int instcmd(const char *cmdname, const char *extra) { + if (!strcasecmp(cmdname, "shutdown.return")) { /* shutdown and restart */ ser_send_char(upsfd, CMD_SHUTRET); /* 0xDE */ /* ser_send_char(upsfd, ENDCHAR); */ return STAT_INSTCMD_HANDLED; } - if (!strcasecmp(cmdname, "shutdown.stayoff")) - { - /* shutdown now (one way) */ - ser_send_char(upsfd, CMD_SHUT); /* 0xDD */ - /* ser_send_char(upsfd, ENDCHAR); */ - return STAT_INSTCMD_HANDLED; - } + if (!strcasecmp(cmdname, "shutdown.stayoff")) { + /* shutdown now (one way) */ + ser_send_char(upsfd, CMD_SHUT); /* 0xDD */ + /* ser_send_char(upsfd, ENDCHAR); */ + return STAT_INSTCMD_HANDLED; + } - upslogx(LOG_NOTICE, "instcmd: unknown command [%s]", cmdname); + upslogx(LOG_NOTICE, "instcmd: unknown command [%s] [%s]", cmdname, extra); return STAT_INSTCMD_UNKNOWN; } -void upsdrv_initinfo(void) -{ - getbaseinfo(); +void upsdrv_initinfo(void) { + get_base_info(); upsh.instcmd = instcmd; } -void upsdrv_updateinfo(void) -{ - - getupdateinfo(); /* new package for updates */ +void upsdrv_updateinfo(void) { + get_update_info(); /* new package for updates */ dstate_setinfo("output.voltage", "%03.1f", OutVoltage); dstate_setinfo("input.voltage", "%03.1f", InVoltage); @@ -1133,17 +926,17 @@ void upsdrv_updateinfo(void) dstate_setinfo("output.current", "%03.1f", OutCurrent); status_init(); - if (!SourceFail ) + if (!SourceFail) status_set("OL"); /* on line */ else status_set("OB"); /* on battery */ - if (Autonomy < 5 ) + if (Autonomy < 5) status_set("LB"); /* low battery */ - if( progshut ) { /* software programable shutdown immediately */ + if (progshut) { /* software programable shutdown immediately */ if( prgups == 2 ) - sendshut(); /* Ups shutdown in 4-5 minutes -- redundant Ups shutdown */ + send_shutdown(); /* Ups shutdown in 4-5 minutes -- redundant Ups shutdown */ status_set("LB"); /* no low battery but is a force shutdown */ } @@ -1155,7 +948,6 @@ void upsdrv_updateinfo(void) dstate_setinfo("ups.load", "%03.1f", upscharge); dstate_dataok(); - } /*! @brief Power down the attached load immediately. @@ -1163,26 +955,17 @@ void upsdrv_updateinfo(void) * - on battery: send normal shutdown, UPS will return by itself on utility * - on line: send shutdown+return, UPS will cycle and return soon. */ -void upsdrv_shutdown(void) -{ - - +void upsdrv_shutdown(void) { if (!SourceFail) { /* on line */ - upslogx(LOG_NOTICE, "On line, sending shutdown+return command...\n"); ser_send_char(upsfd, CMD_SHUTRET ); - } - else - { + } else { upslogx(LOG_NOTICE, "On battery, sending normal shutdown command...\n"); ser_send_char(upsfd, CMD_SHUT); } - } -void upsdrv_help(void) -{ - +void upsdrv_help(void) { printf("\nSolis options\n"); printf(" Battery Extension in AH\n"); printf(" battext = 80\n"); @@ -1198,25 +981,20 @@ void upsdrv_help(void) printf(" houron = hh:mm hh = hour 0-23 mm = minute 0-59 separated with :\n"); printf(" houroff = hh:mm hh = hour 0-23 mm = minute 0-59 separated with :\n"); printf(" where houron is power-on hour and houroff is shutdown and power-off hour\n"); - printf(" Uses daysweek and houron to programing and save UPS power on/off\n"); + printf(" Uses daysweek and houron to programming and save UPS power on/off\n"); printf(" These are valid only if prgshut = 2 or 3\n"); - } -void upsdrv_makevartable(void) -{ - +void upsdrv_makevartable(void) { addvar(VAR_VALUE, "battext", "Battery Extension (0-80)min"); addvar(VAR_VALUE, "prgshut", "Programable power off (0-3)"); addvar(VAR_VALUE, "daysweek", "Days of week UPS power of/off"); addvar(VAR_VALUE, "daysoff", "Days of week Driver shutdown"); addvar(VAR_VALUE, "houron", "Power on hour (hh:mm)"); addvar(VAR_VALUE, "houroff", "Power off hour (hh:mm)"); - } -void upsdrv_initups(void) -{ +void upsdrv_initups(void) { upsfd = ser_open(device_path); ser_set_speed(upsfd, device_path, B9600); @@ -1224,7 +1002,6 @@ void upsdrv_initups(void) ser_set_rts(upsfd, 0); } -void upsdrv_cleanup(void) -{ +void upsdrv_cleanup(void) { ser_close(upsfd, device_path); } diff --git a/drivers/solis.h b/drivers/solis.h index 528a8bb..54c9471 100644 --- a/drivers/solis.h +++ b/drivers/solis.h @@ -1,6 +1,8 @@ /* solis.h - Microsol Solis UPS hardware - Copyright (C) 2004 Silvino B. Magalhaes + Copyright (C) 2004 Silvino B. Magalhaes + 2019 Roberto Panerai Velloso + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,7 +24,7 @@ 2004/10/30 - Version 0.40 - add model data structs 2004/11/22 - Version 0.50 - add internal e external shutdown programming 2005/06/16 - Version 0.60 - save external shutdown programming to ups, - support new cables and Solaris compilation + support new cables and Solaris compilation 2015/09/19 - Version 0.63 - patch for correct reading for Microsol Back-Ups BZ1200-BR */ @@ -30,16 +32,26 @@ #ifndef INCLUDED_SOLIS_H #define INCLUDED_SOLIS_H +#include "nut_stdint.h" + +/* General FIXMEs: + * * "static" declarations belong in some one single C source; + * headers should use "extern" to refer linker to look for + * vars in other object files + * * use a common definition of bool_t + */ typedef int bool_t; /* autonomy constants */ -const static int bext[5] = {14,18,28,18,1}; -const static int nompow[5] = { 1000,1500,2000,3000,1200 }; -const static int inds[6] = { 0,0,1,2,3,4 }; -const static double InVolt_offset = 30.; +static const int bext[5] = {14,18,28,18,1}; +static const int nompow[5] = { 1000,1500,2000,3000,1200 }; +static const int inds[6] = { 0,0,1,2,3,4 }; +static const double InVolt_offset = 30.; +#define PACKET_SIZE 25 +static const size_t packet_size = PACKET_SIZE; -const static struct { +static const struct { int maxi; /* power internals */ int minc[21]; /* power minimal index */ int maxc[21]; /* power maximus index */ @@ -202,7 +214,7 @@ const static struct { * Solis constants for data ajustment * ----------------------------------------------------------- */ -const static struct { +static const struct { double m_infreq; double m_appp_offset; double m_involt193[2]; @@ -309,34 +321,34 @@ const static struct { */ - { 101800.0, //m_infreq - 56.0, //m_appp_offset - { 1.64, 9.34 },// m_involt193 - ok - { 2.5, -250.0 }, //m_involt194 - { 35.0, 1000.0 }, //m_incurr - { 0.1551, 0.2525 }, //m_battvolt - { { 1.41, 13.0 }, { 1.4, 17.0 } }, //m_outvolt_s - { { 2.73, 25.0 }, { 2.73, 30.0 } }, //m_outvolt_i - { { 1.0/8.15, 0.25 }, { 1.0/8.15, 0.25 } }, //m_outcurr_s - { { 1.0/16.0, 0.4 }, { 1.0/15.0, 0.4 } }, //m_outcurr_i - { { 1.0/4.87, 19.0 }, { 1.0/4.55, 17.0 } }, //m_utilp_s - { { 1.0/4.78, 52.0 }, { 1.0/4.55, 55.0 } }, //m_utilp_i - { { 1.0/5.15, 29.0 }, { 1.0/4.8, 26.0 } }, //m__app_s - { { 1.0/4.78, 52.0 }, { 1.0/4.55, 55.0 } } //m_app_i + { 101800.0, /* m_infreq */ + 56.0, /* m_appp_offset */ + { 1.64, 9.34 }, /* m_involt193 - ok */ + { 2.5, -250.0 }, /* m_involt194 */ + { 35.0, 1000.0 }, /* m_incurr */ + { 0.1551, 0.2525 }, /* m_battvolt */ + { { 1.41, 13.0 }, { 1.4, 17.0 } }, /* m_outvolt_s */ + { { 2.73, 25.0 }, { 2.73, 30.0 } }, /* m_outvolt_i */ + { { 1.0/8.15, 0.25 }, { 1.0/8.15, 0.25 } }, /* m_outcurr_s */ + { { 1.0/16.0, 0.4 }, { 1.0/15.0, 0.4 } }, /* m_outcurr_i */ + { { 1.0/4.87, 19.0 }, { 1.0/4.55, 17.0 } }, /* m_utilp_s */ + { { 1.0/4.78, 52.0 }, { 1.0/4.55, 55.0 } }, /* m_utilp_i */ + { { 1.0/5.15, 29.0 }, { 1.0/4.8, 26.0 } }, /* m__app_s */ + { { 1.0/4.78, 52.0 }, { 1.0/4.55, 55.0 } } /* m_app_i */ } }; /* Date, time and programming group */ -static int const BASE_YEAR = 1998; +static int const BASE_YEAR = 1998; /* Note: code below uses relative "unsigned char" years */ static int Day, Month, Year; static int isprogram = 0, progshut = 0, prgups = 0; static int dian=0, mesn=0, anon=0, weekn=0; static int dhour, dmin, lhour, lmin, ihour,imin, isec, hourshut, minshut; -static unsigned char DaysOnWeek=0, DaysOffWeek=0, DaysStd = 0; +static uint8_t DaysOnWeek=0, DaysOffWeek=0, DaysStd = 0; static char seman[4]; /* buffers */ -static unsigned char RecPack[25]; +static unsigned char RecPack[PACKET_SIZE]; static unsigned char ConfigPack[12]; /* @@ -349,9 +361,6 @@ static const char *Model; static int SolisModel, imodel; static int InputValue, Out220; -/* protocol */ -static int pacsize; - /* Status group */ static unsigned char InputStatus,OutputStatus, BattStatus; /* Events group */ @@ -375,12 +384,12 @@ static double BattVoltage, Temperature, batcharge; static double AppPower, UtilPower, upscharge; static int ChargePowerFactor, NominalPower, UpsPowerFactor; -static void prnInfo(void); -static int IsToday( unsigned char, int ); -static void AutonomyCalc( int ); -static void ScanReceivePack(void); -static void CommReceive(const char*, int ); -static void getbaseinfo(void); -static void getupdateinfo(void); +static void print_info(void); +static int is_today( unsigned char, int ); +static void autonomy_calc( int ); +static void scan_received_pack(void); +static void comm_receive(const unsigned char*, size_t); +static void get_base_info(void); +static void get_update_info(void); #endif /* INCLUDED_SOLIS_H */ diff --git a/drivers/tripplite-hid.c b/drivers/tripplite-hid.c index 13bd288..20d5152 100644 --- a/drivers/tripplite-hid.c +++ b/drivers/tripplite-hid.c @@ -29,7 +29,7 @@ #include "tripplite-hid.h" #include "usb-common.h" -#define TRIPPLITE_HID_VERSION "TrippLite HID 0.82" +#define TRIPPLITE_HID_VERSION "TrippLite HID 0.84" /* FIXME: experimental flag to be put in upsdrv_info */ @@ -47,17 +47,20 @@ static double io_current_scale = 1.0; /* Specific handlers for USB device matching */ static void *battery_scale_1dot0(USBDevice_t *device) { + NUT_UNUSED_VARIABLE(device); /* FIXME: we could remove this one since it's the default! */ battery_scale = 1.0; return NULL; } static void *battery_scale_0dot1(USBDevice_t *device) { + NUT_UNUSED_VARIABLE(device); battery_scale = 0.1; return NULL; } static void *smart1500lcdt_scale(USBDevice_t *device) { + NUT_UNUSED_VARIABLE(device); battery_scale = 100000.0; io_voltage_scale = 100000.0; io_frequency_scale = 0.01; @@ -71,6 +74,9 @@ static void *smart1500lcdt_scale(USBDevice_t *device) /* Hewlett Packard */ #define HP_VENDORID 0x03f0 +/* Delta/Minuteman */ +#define DELTA_VENDORID 0x05dd + /* USB IDs device table */ static usb_device_id_t tripplite_usb_device_table[] = { /* e.g. TrippLite AVR550U */ @@ -81,6 +87,8 @@ static usb_device_id_t tripplite_usb_device_table[] = { { USB_DEVICE(TRIPPLITE_VENDORID, 0x1008), battery_scale_0dot1 }, { USB_DEVICE(TRIPPLITE_VENDORID, 0x1009), battery_scale_0dot1 }, { USB_DEVICE(TRIPPLITE_VENDORID, 0x1010), battery_scale_0dot1 }, + /* e.g. TrippLite SU3000LCD2UHV */ + { USB_DEVICE(TRIPPLITE_VENDORID, 0x1330), battery_scale_1dot0 }, /* e.g. TrippLite OMNI1000LCD */ { USB_DEVICE(TRIPPLITE_VENDORID, 0x2005), battery_scale_0dot1 }, /* e.g. TrippLite OMNI900LCD */ @@ -109,6 +117,8 @@ static usb_device_id_t tripplite_usb_device_table[] = { { USB_DEVICE(TRIPPLITE_VENDORID, 0x3015), battery_scale_1dot0 }, /* e.g. TrippLite Smart1500LCD (newer unit) */ { USB_DEVICE(TRIPPLITE_VENDORID, 0x3016), smart1500lcdt_scale }, + /* e.g. TrippLite AVR750U (newer unit) */ + { USB_DEVICE(TRIPPLITE_VENDORID, 0x3024), smart1500lcdt_scale }, /* e.g. TrippLite SmartOnline SU1500RTXL2UA (older unit?) */ { USB_DEVICE(TRIPPLITE_VENDORID, 0x4001), battery_scale_1dot0 }, /* e.g. TrippLite SmartOnline SU6000RT4U? */ @@ -142,8 +152,11 @@ static usb_device_id_t tripplite_usb_device_table[] = { /* HP R/T 2200 INTL (like SMART2200RMXL2U) */ { USB_DEVICE(HP_VENDORID, 0x1f0a), battery_scale_1dot0 }, + /* Delta/Minuteman Enterprise Plus E1500RM2U */ + { USB_DEVICE(DELTA_VENDORID, 0xa011), battery_scale_1dot0 }, + /* Terminating entry */ - { -1, -1, NULL } + { 0, 0, NULL } }; /* returns statically allocated string - must not use it again before @@ -169,7 +182,7 @@ static const char *tripplite_chemistry_fun(double value) } static info_lkp_t tripplite_chemistry[] = { - { 0, NULL, tripplite_chemistry_fun } + { 0, NULL, tripplite_chemistry_fun, NULL } }; /* returns statically allocated string - must not use it again before @@ -184,7 +197,7 @@ static const char *tripplite_battvolt_fun(double value) } static info_lkp_t tripplite_battvolt[] = { - { 0, NULL, tripplite_battvolt_fun } + { 0, NULL, tripplite_battvolt_fun, NULL } }; static const char *tripplite_iovolt_fun(double value) @@ -197,7 +210,7 @@ static const char *tripplite_iovolt_fun(double value) } static info_lkp_t tripplite_iovolt[] = { - { 0, NULL, tripplite_iovolt_fun } + { 0, NULL, tripplite_iovolt_fun, NULL } }; static const char *tripplite_iofreq_fun(double value) @@ -210,7 +223,7 @@ static const char *tripplite_iofreq_fun(double value) } static info_lkp_t tripplite_iofreq[] = { - { 0, NULL, tripplite_iofreq_fun } + { 0, NULL, tripplite_iofreq_fun, NULL } }; static const char *tripplite_ioamp_fun(double value) @@ -223,7 +236,7 @@ static const char *tripplite_ioamp_fun(double value) } static info_lkp_t tripplite_ioamp[] = { - { 0, NULL, tripplite_ioamp_fun } + { 0, NULL, tripplite_ioamp_fun, NULL } }; /* --------------------------------------------------------------- */ @@ -549,4 +562,5 @@ subdriver_t tripplite_subdriver = { tripplite_format_model, tripplite_format_mfr, tripplite_format_serial, + fix_report_desc, }; diff --git a/drivers/tripplite-hid.h b/drivers/tripplite-hid.h index b444c4d..5a09c08 100644 --- a/drivers/tripplite-hid.h +++ b/drivers/tripplite-hid.h @@ -1,6 +1,6 @@ /* tripplite-hid.h - data to monitor Tripp Lite USB/HID devices with NUT * - * Copyright (C) + * Copyright (C) * 2003 - 2005 Arnaud Quette * 2005 Peter Selinger * diff --git a/drivers/tripplite.c b/drivers/tripplite.c index 78ef253..672c734 100644 --- a/drivers/tripplite.c +++ b/drivers/tripplite.c @@ -65,13 +65,17 @@ * :C -- fetches result of a self-test * :K1 -- turns on power receptacles * :K0 -- turns off power receptacles + * :K3 -- turns on bank 1 receptacle(s) + * :K2 -- turns off bank 1 receptacle(s) + * :K5 -- turns on bank 2 receptacle(s) + * :K4 -- turns off bank 2 receptacle(s) * :G -- unconfirmed: shuts down UPS until power returns * :Q1 -- enable "Remote Reboot" * :Q0 -- disable "Remote Reboot" * :W -- returns 'W' data * :L -- returns 'L' data * :V -- returns 'V' data (firmware revision) - * :X -- returns 'X' data (firmware revision) + * :X -- returns 'X' data (firmware checksum) * :D -- returns general status data * :B -- returns battery voltage (hexadecimal decivolts) * :I -- returns minimum input voltage (hexadecimal hertz) @@ -108,11 +112,12 @@ #include "main.h" #include "serial.h" #include "tripplite.h" +#include "nut_stdint.h" #include #include #define DRIVER_NAME "Tripp-Lite SmartUPS driver" -#define DRIVER_VERSION "0.91" +#define DRIVER_VERSION "0.93" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -130,7 +135,7 @@ static unsigned int offdelay = DEFAULT_OFFDELAY; static unsigned int startdelay = DEFAULT_STARTDELAY; static unsigned int bootdelay = DEFAULT_BOOTDELAY; -static int hex2d(char *start, unsigned int len) +static long hex2d(char *start, unsigned int len) { char buf[32]; @@ -146,16 +151,16 @@ static int hex2d(char *start, unsigned int len) * very clean. * * return: # of chars in buf, excluding terminating \0 */ -static int send_cmd(const char *str, char *buf, size_t len) +static ssize_t send_cmd(const char *str, char *buf, size_t len) { - unsigned char c; - int ret = 0; - size_t i = 0; + char c; + ssize_t ret = 0; + ssize_t i = 0; ser_flush_io(upsfd); ser_send(upsfd, "%s", str); - if (!len || !buf) + if (!len || !buf || len > SSIZE_MAX) return -1; for (;;) { @@ -173,14 +178,15 @@ static int send_cmd(const char *str, char *buf, size_t len) if (c == IGNCHAR || c == ENDCHAR) continue; buf[i++] = c; - } while (c != ENDCHAR && i < len); + } while (c != ENDCHAR && i < (int)len); buf[i] = '\0'; return i; } static void get_letter_cmd(const char *str, char *buf, size_t len) { - int tries, ret; + int tries; + ssize_t ret; for (tries = 0; tries < MAXTRIES; ++tries) { ret = send_cmd(str, buf, len); @@ -190,7 +196,7 @@ static void get_letter_cmd(const char *str, char *buf, size_t len) fatalx(EXIT_FAILURE, "\nFailed to find UPS - giving up..."); } -static int do_reboot_now(void) +static ssize_t do_reboot_now(void) { char buf[256], cmd[16]; @@ -207,7 +213,7 @@ static void do_reboot(void) do_reboot_now(); } -static int soft_shutdown(void) +static ssize_t soft_shutdown(void) { char buf[256], cmd[16]; @@ -216,7 +222,7 @@ static int soft_shutdown(void) return send_cmd(":G\r", buf, sizeof buf); } -static int hard_shutdown(void) +static ssize_t hard_shutdown(void) { char buf[256], cmd[16]; @@ -241,6 +247,22 @@ static int instcmd(const char *cmdname, const char *extra) send_cmd(":K1\r", buf, sizeof buf); return STAT_INSTCMD_HANDLED; } + if (!strcasecmp(cmdname, "outlet.1.load.off")) { + send_cmd(":K2\r", buf, sizeof buf); + return STAT_INSTCMD_HANDLED; + } + if (!strcasecmp(cmdname, "outlet.1.load.on")) { + send_cmd(":K3\r", buf, sizeof buf); + return STAT_INSTCMD_HANDLED; + } + if (!strcasecmp(cmdname, "outlet.2.load.off")) { + send_cmd(":K4\r", buf, sizeof buf); + return STAT_INSTCMD_HANDLED; + } + if (!strcasecmp(cmdname, "outlet.2.load.on")) { + send_cmd(":K5\r", buf, sizeof buf); + return STAT_INSTCMD_HANDLED; + } if (!strcasecmp(cmdname, "shutdown.reboot")) { do_reboot_now(); return STAT_INSTCMD_HANDLED; @@ -258,25 +280,31 @@ static int instcmd(const char *cmdname, const char *extra) return STAT_INSTCMD_HANDLED; } - upslogx(LOG_NOTICE, "instcmd: unknown command [%s]", cmdname); + upslogx(LOG_NOTICE, "instcmd: unknown command [%s] [%s]", cmdname, extra); return STAT_INSTCMD_UNKNOWN; } static int setvar(const char *varname, const char *val) { if (!strcasecmp(varname, "ups.delay.shutdown")) { - offdelay = atoi(val); - dstate_setinfo("ups.delay.shutdown", "%d", offdelay); + int ipv = atoi(val); + if (ipv >= 0) + offdelay = (unsigned int)ipv; + dstate_setinfo("ups.delay.shutdown", "%u", offdelay); return STAT_SET_HANDLED; } if (!strcasecmp(varname, "ups.delay.start")) { - startdelay = atoi(val); - dstate_setinfo("ups.delay.start", "%d", startdelay); + int ipv = atoi(val); + if (ipv >= 0) + startdelay = (unsigned int)ipv; + dstate_setinfo("ups.delay.start", "%u", startdelay); return STAT_SET_HANDLED; } if (!strcasecmp(varname, "ups.delay.reboot")) { - bootdelay = atoi(val); - dstate_setinfo("ups.delay.reboot", "%d", bootdelay); + int ipv = atoi(val); + if (ipv >= 0) + bootdelay = (unsigned int)ipv; + dstate_setinfo("ups.delay.reboot", "%u", bootdelay); return STAT_SET_HANDLED; } return STAT_SET_UNKNOWN; @@ -286,8 +314,8 @@ void upsdrv_initinfo(void) { const char *model; char w_value[16], l_value[16], v_value[16], x_value[16]; - int va; - long w, l; + int gen, plugs; + long w, l, va; get_letter_cmd(":W\r", w_value, sizeof w_value); get_letter_cmd(":L\r", l_value, sizeof l_value); @@ -299,17 +327,20 @@ void upsdrv_initinfo(void) w = hex2d(w_value, 2); l = hex2d(l_value, 2); - model = "Smart %d"; + model = "Smart"; if (w & 0x40) - model = "Unison %d"; + model = "Unison"; va = ((w & 0x3f) * 32 + (l >> 3)) * 5; /* New formula */ if (!(w & 0x80)) va = l / 2; /* Old formula */ - dstate_setinfo("ups.model", model, va); - dstate_setinfo("ups.firmware", "%c%c", - 'A'+v_value[0]-'0', 'A'+v_value[1]-'0'); + gen = 1 + (!(x_value[0] & 0x07) * !(x_value[1] & 0x07)); + plugs = x_value[0] - !!(x_value[1] >> 3) * 8; + + dstate_setinfo("ups.model", "%s %ld", model, va); + dstate_setinfo("ups.firmware", "%c%c (Gen %d)", + 'A'+v_value[0]-'0', 'A'+v_value[1]-'0', gen); dstate_setinfo("ups.delay.shutdown", "%d", offdelay); dstate_setflags("ups.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING); @@ -329,6 +360,15 @@ void upsdrv_initinfo(void) dstate_addcmd("shutdown.return"); dstate_addcmd("shutdown.stayoff"); + if (plugs > 1) { + dstate_addcmd("outlet.1.load.off"); + dstate_addcmd("outlet.1.load.on"); + if (plugs > 2) { + dstate_addcmd("outlet.2.load.off"); + dstate_addcmd("outlet.2.load.on"); + } + } + upsh.instcmd = instcmd; upsh.setvar = setvar; @@ -345,7 +385,9 @@ void upsdrv_updateinfo(void) { static int numfails; char buf[256]; - int bp, volt, temp, load, vmax, vmin, stest, len; + int bp, temp; + ssize_t len; + long volt, load, vmax, vmin, stest; int bcond, lstate, tstate, mode; float bv, freq; @@ -353,7 +395,7 @@ void upsdrv_updateinfo(void) if (len != 21) { ++numfails; if (numfails > MAXTRIES) { - ser_comm_fail("Data command failed: [%d] bytes != 21 bytes.", len); + ser_comm_fail("Data command failed: [%zd] bytes != 21 bytes.", len); dstate_datastale(); } return; @@ -373,7 +415,7 @@ void upsdrv_updateinfo(void) freq > FREQ_MAX || freq < FREQ_MIN) { ++numfails; if (numfails > MAXTRIES) { - ser_comm_fail("Data out of bounds: [%0d,%3d,%3d,%02.2f]", + ser_comm_fail("Data out of bounds: [%0ld,%3d,%3ld,%02.2f]", volt, temp, load, freq); dstate_datastale(); } @@ -381,7 +423,7 @@ void upsdrv_updateinfo(void) } send_cmd(":B\r", buf, sizeof buf); - bv = (float)hex2d(buf, 2) / 10.0; + bv = (float)(hex2d(buf, 2)) / 10.0; if (bv > 50.0 || bv < 0.0) { ++numfails; if (numfails > MAXTRIES) { @@ -396,7 +438,7 @@ void upsdrv_updateinfo(void) if (vmax > INVOLT_MAX || vmax < INVOLT_MIN) { ++numfails; if (numfails > MAXTRIES) { - ser_comm_fail("InVoltMax out of bounds: [%d]", vmax); + ser_comm_fail("InVoltMax out of bounds: [%ld]", vmax); dstate_datastale(); } return; @@ -407,7 +449,7 @@ void upsdrv_updateinfo(void) if (vmin > INVOLT_MAX || vmin < INVOLT_MIN) { ++numfails; if (numfails > MAXTRIES) { - ser_comm_fail("InVoltMin out of bounds: [%d]", vmin); + ser_comm_fail("InVoltMin out of bounds: [%ld]", vmin); dstate_datastale(); } return; @@ -419,7 +461,7 @@ void upsdrv_updateinfo(void) if (errno == ERANGE) { ++numfails; if (numfails > MAXTRIES) { - ser_comm_fail("Self test is out of range: [%d]", stest); + ser_comm_fail("Self test is out of range: [%ld]", stest); dstate_datastale(); } return; @@ -435,7 +477,7 @@ void upsdrv_updateinfo(void) if (stest > 3 || stest < 0) { ++numfails; if (numfails > MAXTRIES) { - ser_comm_fail("Self test out of bounds: [%d]", stest); + ser_comm_fail("Self test out of bounds: [%ld]", stest); dstate_datastale(); } return; @@ -444,9 +486,9 @@ void upsdrv_updateinfo(void) /* We've successfully gathered all the data for an update. */ numfails = 0; - dstate_setinfo("input.voltage", "%0d", volt); + dstate_setinfo("input.voltage", "%0ld", volt); dstate_setinfo("ups.temperature", "%3d", temp); - dstate_setinfo("ups.load", "%3d", load); + dstate_setinfo("ups.load", "%3ld", load); dstate_setinfo("input.frequency", "%02.2f", freq); status_init(); @@ -524,8 +566,8 @@ void upsdrv_updateinfo(void) dstate_setinfo("battery.voltage", "%.1f", bv); dstate_setinfo("battery.charge", "%3d", bp); - dstate_setinfo("input.voltage.maximum", "%d", vmax); - dstate_setinfo("input.voltage.minimum", "%d", vmin); + dstate_setinfo("input.voltage.maximum", "%ld", vmax); + dstate_setinfo("input.voltage.minimum", "%ld", vmin); switch (stest) { case 0: @@ -572,13 +614,23 @@ void upsdrv_initups(void) { upsfd = ser_open(device_path); ser_set_speed(upsfd, device_path, B2400); + char *val; - if (getval("offdelay")) - offdelay = atoi(getval("offdelay")); - if (getval("startdelay")) - startdelay = atoi(getval("startdelay")); - if (getval("rebootdelay")) - bootdelay = atoi(getval("rebootdelay")); + if ((val = getval("offdelay"))) { + int ipv = atoi(val); + if (ipv >= 0) + offdelay = (unsigned int)ipv; + } + if ((val = getval("startdelay"))) { + int ipv = atoi(val); + if (ipv >= 0) + startdelay = (unsigned int)ipv; + } + if ((val = getval("rebootdelay"))) { + int ipv = atoi(val); + if (ipv >= 0) + bootdelay = (unsigned int)ipv; + } } void upsdrv_cleanup(void) diff --git a/drivers/tripplite.h b/drivers/tripplite.h index 931d62d..498f69c 100644 --- a/drivers/tripplite.h +++ b/drivers/tripplite.h @@ -23,6 +23,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef NUT_TRIPPLITE_H_SEEN +#define NUT_TRIPPLITE_H_SEEN 1 + #define ENDCHAR '\n' /* replies end with CR LF -- use LF to end */ #define IGNCHAR '\r' /* ignore CR */ #define MAXTRIES 3 /* max number of times we try to detect ups */ @@ -56,3 +59,4 @@ #define MAX_VOLT 13.4 /* Max battery voltage (100%) */ #define MIN_VOLT 11.0 /* Min battery voltage (10%) */ +#endif /* NUT_TRIPPLITE_H_SEEN */ diff --git a/drivers/tripplite_usb.c b/drivers/tripplite_usb.c index 9b06407..cbaf73b 100644 --- a/drivers/tripplite_usb.c +++ b/drivers/tripplite_usb.c @@ -1,4 +1,4 @@ -/*!@file tripplite_usb.c +/*!@file tripplite_usb.c * @brief Driver for Tripp Lite non-PDC/HID USB models. */ /* @@ -9,6 +9,7 @@ Copyright (C) 2001 Rickard E. (Rik) Faith Copyright (C) 2004 Nicholas J. Kain Copyright (C) 2005-2008, 2014 Charles Lepple + Copyright (C) 2016 Eaton This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,7 +27,7 @@ */ -/* % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % +/* % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % * * Protocol 1001 * @@ -37,12 +38,12 @@ * :P -> P01000X (1000VA unit) * :S -> Sbb_XXX (bb = 10: on-line, 11: on battery) * :V -> V102XXX (firmware/protocol version?) - * :Wt -> Wt (watchdog; t = time in seconds (binary, not hex), + * :Wt -> Wt (watchdog; t = time in seconds (binary, not hex), * 0 = disable; if UPS is not pinged in this interval, it * will power off the load, and then power it back on after * a delay.) * - * % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % + * % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % * * The outgoing commands are sent with HID Set_Report commands over EP0 * (control message), and incoming commands are received on EP1IN (interrupt @@ -53,14 +54,14 @@ * The descriptors say that bInterval is 10 ms. You generally need to wait at * least 80-90 ms to get some characters back from the device. If it takes * more than 250 ms, you probably need to resend the command. - * + * * All outgoing commands are followed by a checksum, which is 255 - (sum of * characters after ':'), and then by '\r'. All responses should start with * the command letter that was sent (no colon), and should be followed by * '\r'. If the command is not supported (or apparently if there is a serial * timeout internally), the previous response will be echoed back. * - * % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % + * % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % * * SMARTPRO commands (3003): * @@ -85,14 +86,14 @@ * individually switchable.) * :W_ -> W_ (watchdog) * :Z -> Z (reset for max/min; takes a moment to complete) - * - * % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % + * + * % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % * * The SMARTPRO unit seems to be slightly saner with regard to message * polling. It specifies an interrupt in interval of 100 ms, but I just - * started at a 2 second timeout to obtain the above table. + * started at a 2 second timeout to obtain the above table. * - * % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % + * % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % * * Commands from serial tripplite.c: * @@ -129,14 +130,13 @@ */ #include "main.h" -#include "libusb.h" +#include "nut_libusb.h" #include #include -#include #include "usb-common.h" #define DRIVER_NAME "Tripp Lite OMNIVS / SMARTPRO driver" -#define DRIVER_VERSION "0.29" +#define DRIVER_VERSION "0.33" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -151,20 +151,27 @@ upsdrv_info_t upsdrv_info = { }; /* TrippLite */ -#define TRIPPLITE_VENDORID 0x09ae +#define TRIPPLITE_VENDORID 0x09ae /* USB IDs device table */ static usb_device_id_t tripplite_usb_device_table[] = { /* e.g. OMNIVS1000, SMART550USB, ... */ { USB_DEVICE(TRIPPLITE_VENDORID, 0x0001), NULL }, - + /* Terminating entry */ - { -1, -1, NULL } + { 0, 0, NULL } }; -static int subdriver_match_func(USBDevice_t *hd, void *privdata) +static int subdriver_match_func(USBDevice_t *arghd, void *privdata) { - switch (is_usb_device_supported(tripplite_usb_device_table, hd)) + NUT_UNUSED_VARIABLE(privdata); + + /* FIXME? Should we save "arghd" into global "hd" variable? + * This was previously shadowed by function argument named "hd"... + */ + /* hd = arghd; */ + + switch (is_usb_device_supported(tripplite_usb_device_table, arghd)) { case SUPPORTED: return 1; @@ -174,6 +181,8 @@ static int subdriver_match_func(USBDevice_t *hd, void *privdata) if (getval("productid")) { return 1; } + return 0; + case NOT_SUPPORTED: default: return 0; @@ -203,7 +212,23 @@ static int is_binary_protocol() switch(tl_model) { case TRIPP_LITE_SMART_3005: return 1; + case TRIPP_LITE_SMARTPRO: + case TRIPP_LITE_SMART_0004: + case TRIPP_LITE_OMNIVS: + case TRIPP_LITE_OMNIVS_2001: + case TRIPP_LITE_UNKNOWN: +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wcovered-switch-default" +#endif + /* All enum cases defined as of the time of coding + * have been covered above. Handle later definitions, + * memory corruptions and buggy inputs below... + */ default: +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT) +# pragma GCC diagnostic pop +#endif return 0; } } @@ -218,13 +243,27 @@ static int is_smart_protocol() case TRIPP_LITE_SMART_0004: case TRIPP_LITE_SMART_3005: return 1; + case TRIPP_LITE_OMNIVS: + case TRIPP_LITE_OMNIVS_2001: + case TRIPP_LITE_UNKNOWN: +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wcovered-switch-default" +#endif + /* All enum cases defined as of the time of coding + * have been covered above. Handle later definitions, + * memory corruptions and buggy inputs below... + */ default: +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT) +# pragma GCC diagnostic pop +#endif return 0; } } /*!@brief If a character is not printable, return a dot. */ -#define toprint(x) (isalnum((unsigned)x) ? (x) : '.') +#define toprint(x) (isalnum((int)x) ? (char)(x) : (char)'.') #define ENDCHAR 13 @@ -263,13 +302,13 @@ static usb_communication_subdriver_t *comm_driver = &usb_subdriver; /* Interval notation for Q% = 10% <= [minV, maxV] <= 100% */ static double V_interval[2] = {MIN_VOLT, MAX_VOLT}; -static int battery_voltage_nominal = 12, +static long battery_voltage_nominal = 12, input_voltage_nominal = 120, input_voltage_scaled = 120, /* input_voltage_maximum = -1, input_voltage_minimum = -1, */ switchable_load_banks = 0, - unit_id = -1; /*!< range: 1-65535, most likely */ + unit_id = -1; /*!< range: 1-65535, most likely */ /*! Time in seconds to delay before shutting down. */ static unsigned int offdelay = DEFAULT_OFFDELAY; @@ -306,16 +345,17 @@ static int reconnect_ups(void) /*!@brief Convert a string to printable characters (in-place) * * @param[in,out] str String to convert - * @param[in] len Maximum number of characters to convert, or <= 0 to + * @param[in] len Maximum number of characters to convert, or == 0 to * convert all. * * Uses toprint() macro defined above. */ -void toprint_str(char *str, int len) +static void toprint_str(char *str, size_t len) { - int i; - if(len <= 0) len = strlen(str); - for(i=0; i < len; i++) + size_t i; + if (len == 0) len = strlen(str); + /* FIXME? Should we check for '\0' along the way? */ + for (i = 0; i < len; i++) str[i] = toprint(str[i]); } @@ -329,7 +369,7 @@ void toprint_str(char *str, int len) * * @return See strtol(3) */ -static int hex2d(const unsigned char *start, unsigned int len) +static long hex2d(const unsigned char *start, unsigned int len) { unsigned char buf[32]; buf[31] = '\0'; @@ -361,7 +401,7 @@ static unsigned int bin2d(const unsigned char *start, unsigned int len) return value; } -static int hex_or_bin2d(const unsigned char *start, unsigned int len) +static long hex_or_bin2d(const unsigned char *start, unsigned int len) { if(is_binary_protocol()) { return bin2d(start, len); @@ -395,7 +435,7 @@ static const char *hexascdump(unsigned char *msg, size_t len) if (end-bufp > 0) *bufp++ = '\''; for(i=0; i0; i++) { - *bufp++ = toprint(msg[i]); + *bufp++ = (unsigned char)toprint(msg[i]); } if (end-bufp > 0) *bufp++ = '\''; @@ -407,7 +447,7 @@ static const char *hexascdump(unsigned char *msg, size_t len) return (char *)buf; } -enum tl_model_t decode_protocol(unsigned int proto) +static enum tl_model_t decode_protocol(unsigned int proto) { switch(proto) { case 0x0004: @@ -433,10 +473,10 @@ enum tl_model_t decode_protocol(unsigned int proto) return TRIPP_LITE_UNKNOWN; } -void decode_v(const unsigned char *value) +static void decode_v(const unsigned char *value) { unsigned char ivn, lb; - int bv; + long bv; if(is_binary_protocol()) { /* 0x00 0x0c -> 12V ? */ @@ -450,16 +490,16 @@ void decode_v(const unsigned char *value) lb = value[4]; switch(ivn) { - case '0': input_voltage_nominal = + case '0': input_voltage_nominal = input_voltage_scaled = 100; break; case 2: /* protocol 3005 */ - case '1': input_voltage_nominal = + case '1': input_voltage_nominal = input_voltage_scaled = 120; break; - case '2': input_voltage_nominal = + case '2': input_voltage_nominal = input_voltage_scaled = 230; break; @@ -467,6 +507,10 @@ void decode_v(const unsigned char *value) input_voltage_scaled = 230; break; + case 6: input_voltage_nominal = + input_voltage_scaled = 230; + break; + default: upslogx(2, "Unknown input voltage range: 0x%02x", (unsigned int)ivn); break; @@ -484,28 +528,33 @@ void decode_v(const unsigned char *value) } } } - upsdebugx(2, "Switchable load banks: %d", switchable_load_banks); + upsdebugx(2, "Switchable load banks: %ld", switchable_load_banks); } void upsdrv_initinfo(void); /*!@brief Report a USB comm failure, and reconnect if necessary - * + * * @param[in] res Result code from libusb/libhid call * @param[in] msg Error message to display */ -void usb_comm_fail(int res, const char *msg) +static void usb_comm_fail(int res, const char *msg) { static int try = 0; switch(res) { - case -EBUSY: - upslogx(LOG_WARNING, "%s: Device claimed by another process", msg); + case ERROR_BUSY: + upslogx(LOG_WARNING, + "%s: Device claimed by another process", msg); fatalx(EXIT_FAILURE, "Terminating: EBUSY"); +#ifndef HAVE___ATTRIBUTE__NORETURN break; +#endif default: - upslogx(LOG_WARNING, "%s: Device detached? (error %d: %s)", msg, res, usb_strerror()); + upslogx(LOG_WARNING, + "%s: Device detached? (error %d: %s)", + msg, res, nut_usb_strerror(res)); upslogx(LOG_NOTICE, "Reconnect attempt #%d", ++try); hd = NULL; @@ -540,6 +589,7 @@ void usb_comm_fail(int res, const char *msg) */ static int send_cmd(const unsigned char *msg, size_t msg_len, unsigned char *reply, size_t reply_len) { + NUT_UNUSED_VARIABLE(reply_len); unsigned char buffer_out[8]; unsigned char csum = 0; int ret = 0, send_try, recv_try=0, done = 0; @@ -567,21 +617,26 @@ static int send_cmd(const unsigned char *msg, size_t msg_len, unsigned char *rep for(send_try=0; !done && send_try < MAX_SEND_TRIES; send_try++) { upsdebugx(6, "send_cmd send_try %d", send_try+1); - ret = comm_driver->set_report(udev, 0, buffer_out, sizeof(buffer_out)); + ret = comm_driver->set_report(udev, 0, + (usb_ctrl_charbuf)buffer_out, + (usb_ctrl_charbufsize)sizeof(buffer_out)); if(ret != sizeof(buffer_out)) { - upslogx(1, "libusb_set_report() returned %d instead of %u", - ret, (unsigned)(sizeof(buffer_out))); + upslogx(1, "libusb_set_report() returned %d instead of %zu", + ret, sizeof(buffer_out)); return ret; } #if ! defined(__FreeBSD__) - if(!done) { usleep(1000*100); /* TODO: nanosleep */ } + usleep(1000*100); /* TODO: nanosleep */ #endif for(recv_try=0; !done && recv_try < MAX_RECV_TRIES; recv_try++) { upsdebugx(7, "send_cmd recv_try %d", recv_try+1); - ret = comm_driver->get_interrupt(udev, reply, sizeof(buffer_out), RECV_WAIT_MSEC); + ret = comm_driver->get_interrupt(udev, + (usb_ctrl_charbuf)reply, + (usb_ctrl_charbufsize)sizeof(buffer_out), + RECV_WAIT_MSEC); if(ret != sizeof(buffer_out)) { upslogx(1, "libusb_get_interrupt() returned %d instead of %u while sending %s", ret, (unsigned)(sizeof(buffer_out)), @@ -595,8 +650,8 @@ static int send_cmd(const unsigned char *msg, size_t msg_len, unsigned char *rep upsdebugx(5, "send_cmd: received %s (%s)", hexascdump(reply, sizeof(buffer_out)), done ? "OK" : "bad"); } - - upsdebugx(((send_try > 2) || (recv_try > 2)) ? 3 : 6, + + upsdebugx(((send_try > 2) || (recv_try > 2)) ? 3 : 6, "send_cmd: send_try = %d, recv_try = %d\n", send_try, recv_try); return done ? sizeof(buffer_out) : 0; @@ -610,7 +665,7 @@ static int send_cmd(const unsigned char *msg, size_t msg_len, unsigned char *rep * The variables are of the form "ups.debug.X" where "X" is the command * character. */ -void debug_message(const char *msg, int len) +static void debug_message(const char *msg, size_t len) { int ret; unsigned char tmp_value[9]; @@ -632,7 +687,7 @@ void debug_message(const char *msg, int len) static void do_reboot_wait(unsigned dly) { int ret; - char buf[256], cmd_W[]="Wx"; + char buf[256], cmd_W[]="Wx"; cmd_W[1] = dly; upsdebugx(3, "do_reboot_wait(wait=%d): N", dly); @@ -659,8 +714,9 @@ static int soft_shutdown(void) unsigned char buf[256], cmd_N[]="N\0x", cmd_G[] = "G"; /* Already binary: */ - cmd_N[2] = offdelay; - cmd_N[1] = offdelay >> 8; + /* FIXME: Assumes memory layout / endianness? */ + cmd_N[2] = (unsigned char)(offdelay & 0x00FF); + cmd_N[1] = (unsigned char)(offdelay >> 8); upsdebugx(3, "soft_shutdown(offdelay=%d): N", offdelay); ret = send_cmd(cmd_N, sizeof(cmd_N), buf, sizeof(buf)); @@ -671,8 +727,8 @@ static int soft_shutdown(void) } sleep(2); - - /*! The unit must be on battery for this to work. + + /*! The unit must be on battery for this to work. * * @todo check for on-battery condition, and print error if not. * @todo Find an equivalent command for non-OMNIVS models. @@ -691,17 +747,18 @@ static int soft_shutdown(void) static int hard_shutdown(void) { int ret; - char buf[256], cmd_N[]="N\0x", cmd_K[] = "K\0"; + unsigned char buf[256], cmd_N[]="N\0x", cmd_K[] = "K\0"; - cmd_N[2] = offdelay; - cmd_N[1] = offdelay >> 8; + /* FIXME: Assumes memory layout / endianness? */ + cmd_N[2] = (unsigned char)(offdelay & 0x00FF); + cmd_N[1] = (unsigned char)(offdelay >> 8); upsdebugx(3, "hard_shutdown(offdelay=%d): N", offdelay); ret = send_cmd(cmd_N, sizeof(cmd_N), buf, sizeof(buf)); if(ret != 8) return ret; sleep(2); - + ret = send_cmd(cmd_K, sizeof(cmd_K), buf, sizeof(buf)); return (ret == 8); } @@ -730,7 +787,20 @@ static int control_outlet(int outlet_id, int state) } else { return 1; } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_BREAK +#pragma GCC diagnostic ignored "-Wunreachable-code-break" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic ignored "-Wunreachable-code" +#endif break; +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic pop +#endif + case TRIPP_LITE_SMART_3005: snprintf(k_cmd, sizeof(k_cmd)-1, "N%c", 5); ret = send_cmd((unsigned char *)k_cmd, strlen(k_cmd) + 1, (unsigned char *)buf, sizeof buf); @@ -743,8 +813,35 @@ static int control_outlet(int outlet_id, int state) } else { return 1; } +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_BREAK +#pragma GCC diagnostic ignored "-Wunreachable-code-break" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic ignored "-Wunreachable-code" +#endif break; +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic pop +#endif + + case TRIPP_LITE_OMNIVS: + case TRIPP_LITE_OMNIVS_2001: + case TRIPP_LITE_UNKNOWN: +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wcovered-switch-default" +#endif + /* All enum cases defined as of the time of coding + * have been covered above. Handle later definitions, + * memory corruptions and buggy inputs below... + */ default: +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT) +# pragma GCC diagnostic pop +#endif upslogx(LOG_ERR, "control_outlet unimplemented for protocol %04x", tl_model); } return 0; @@ -793,26 +890,33 @@ static int instcmd(const char *cmdname, const char *extra) return STAT_INSTCMD_HANDLED; } - upslogx(LOG_NOTICE, "instcmd: unknown command [%s]", cmdname); + upslogx(LOG_NOTICE, "instcmd: unknown command [%s] [%s]", cmdname, extra); return STAT_INSTCMD_UNKNOWN; } static int setvar(const char *varname, const char *val) { if (!strcasecmp(varname, "ups.delay.shutdown")) { - offdelay = atoi(val); - dstate_setinfo("ups.delay.shutdown", "%d", offdelay); - return STAT_SET_HANDLED; + int ival = atoi(val); + if (ival >= 0) { + offdelay = (unsigned int)ival; + dstate_setinfo("ups.delay.shutdown", "%d", offdelay); + return STAT_SET_HANDLED; + } else { + upslogx(LOG_NOTICE, "FAILED to set '%s' to %d", varname, ival); + return STAT_SET_UNKNOWN; + } } if (unit_id >= 0 && !strcasecmp(varname, "ups.id")) { - int new_unit_id, ret; + int new_unit_id, ret; unsigned char J_msg[] = "J__", buf[9]; new_unit_id = atoi(val); - J_msg[1] = new_unit_id >> 8; - J_msg[2] = new_unit_id & 0xff; - ret = send_cmd(J_msg, sizeof(J_msg), buf, sizeof(buf)); + /* FIXME: Assumes memory layout / endianness? */ + J_msg[1] = (unsigned char)(new_unit_id >> 8); + J_msg[2] = (unsigned char)(new_unit_id & 0xff); + ret = send_cmd(J_msg, sizeof(J_msg), buf, sizeof(buf)); if(ret <= 0) { upslogx(LOG_NOTICE, "Could not set Unit ID (return code: %d).", ret); @@ -826,16 +930,21 @@ static int setvar(const char *varname, const char *val) if(!strncmp(varname, "outlet.", strlen("outlet."))) { char outlet_name[80]; char index_str[10], *first_dot, *next_dot; - int index_chars, index, state, ret; + long index_chars; + int index, state, ret; first_dot = strstr(varname, "."); next_dot = strstr(first_dot + 1, "."); + if (!next_dot) { + upslogx(LOG_NOTICE, "FAILED to get outlet index from '%s' (no second dot)", varname); + return STAT_SET_UNKNOWN; + } index_chars = next_dot - (first_dot + 1); - if(index_chars > 9) return STAT_SET_UNKNOWN; + if(index_chars > 9 || index_chars < 0) return STAT_SET_UNKNOWN; if(strcmp(next_dot, ".switch")) return STAT_SET_UNKNOWN; - strncpy(index_str, first_dot + 1, index_chars); + strncpy(index_str, first_dot + 1, (size_t)index_chars); index_str[index_chars] = 0; index = atoi(index_str); @@ -882,7 +991,8 @@ void upsdrv_initinfo(void) char *model, *model_end; unsigned char proto_value[9], f_value[9], p_value[9], s_value[9], u_value[9], v_value[9], w_value[9]; - int va, ret; + long va; + ssize_t ret; unsigned int proto_number = 0; /* Read protocol: */ @@ -891,8 +1001,8 @@ void upsdrv_initinfo(void) fatalx(EXIT_FAILURE, "Error reading protocol"); } - proto_number = ((unsigned)(proto_value[1]) << 8) - | (unsigned)(proto_value[2]); + proto_number = ((unsigned)(proto_value[1]) << 8) + | (unsigned)(proto_value[2]); tl_model = decode_protocol(proto_number); if(tl_model == TRIPP_LITE_UNKNOWN) @@ -907,7 +1017,7 @@ void upsdrv_initinfo(void) if(tl_model != TRIPP_LITE_SMARTPRO ) { ret = send_cmd(w_msg, sizeof(w_msg), w_value, sizeof(w_value)-1); if(ret <= 0) { - if(ret == -EPIPE) { + if(ret == ERROR_PIPE) { fatalx(EXIT_FAILURE, "Could not reset watchdog. Please check and" "see if usbhid-ups(8) works with this UPS."); } else { @@ -957,11 +1067,11 @@ void upsdrv_initinfo(void) dstate_setinfo("ups.model", "%s", model); - dstate_setinfo("ups.power.nominal", "%d", va); + dstate_setinfo("ups.power.nominal", "%ld", va); /* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - */ - /* Fetch firmware version: */ + /* Fetch firmware version: */ ret = send_cmd(f_msg, sizeof(f_msg), f_value, sizeof(f_value)-1); toprint_str((char *)(f_value+1), 6); @@ -1020,8 +1130,8 @@ void upsdrv_initinfo(void) if(ret <= 0) { upslogx(LOG_INFO, "Unit ID not retrieved (not available on all models)"); } else { - unit_id = (int)((unsigned)(u_value[1]) << 8) - | (unsigned)(u_value[2]); + unit_id = (long)((unsigned)(u_value[1]) << 8) + | (unsigned)(u_value[2]); } if(tl_model == TRIPP_LITE_SMART_0004) { @@ -1030,28 +1140,28 @@ void upsdrv_initinfo(void) } if(unit_id >= 0) { - dstate_setinfo("ups.id", "%d", unit_id); + dstate_setinfo("ups.id", "%ld", unit_id); dstate_setflags("ups.id", ST_FLAG_RW | ST_FLAG_STRING); dstate_setaux("ups.id", 5); - upslogx(LOG_DEBUG,"Unit ID: %d", unit_id); + upslogx(LOG_DEBUG,"Unit ID: %ld", unit_id); } /* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - */ - dstate_setinfo("input.voltage.nominal", "%d", input_voltage_nominal); - dstate_setinfo("battery.voltage.nominal", "%d", battery_voltage_nominal); - dstate_setinfo("ups.debug.load_banks", "%d", switchable_load_banks); + dstate_setinfo("input.voltage.nominal", "%ld", input_voltage_nominal); + dstate_setinfo("battery.voltage.nominal", "%ld", battery_voltage_nominal); + dstate_setinfo("ups.debug.load_banks", "%ld", switchable_load_banks); - dstate_setinfo("ups.delay.shutdown", "%d", offdelay); + dstate_setinfo("ups.delay.shutdown", "%u", offdelay); dstate_setflags("ups.delay.shutdown", ST_FLAG_RW | ST_FLAG_STRING); dstate_setaux("ups.delay.shutdown", 3); #if 0 - dstate_setinfo("ups.delay.start", "%d", startdelay); + dstate_setinfo("ups.delay.start", "%u", startdelay); dstate_setflags("ups.delay.start", ST_FLAG_RW | ST_FLAG_STRING); dstate_setaux("ups.delay.start", 8); - dstate_setinfo("ups.delay.reboot", "%d", bootdelay); + dstate_setinfo("ups.delay.reboot", "%u", bootdelay); dstate_setflags("ups.delay.reboot", ST_FLAG_RW | ST_FLAG_STRING); dstate_setaux("ups.delay.reboot", 3); #endif @@ -1093,7 +1203,8 @@ void upsdrv_updateinfo(void) s_msg[] = "S", m_msg[] = "M", t_msg[] = "T"; unsigned char b_value[9], d_value[9], l_value[9], s_value[9], m_value[9], t_value[9]; - int bp, freq; + int bp; + long freq; double bv_12V = 0.0; /*!< battery voltage, relative to a 12V battery */ double battery_voltage; /*!< the total battery voltage */ @@ -1227,7 +1338,9 @@ void upsdrv_updateinfo(void) status_set("RB"); break; } /* else fall through: */ + goto fallthrough_case_default; default: + fallthrough_case_default: upslogx(LOG_ERR, "Unknown value for s[1]: 0x%02x", s_value[1]); dstate_datastale(); break; @@ -1264,7 +1377,7 @@ void upsdrv_updateinfo(void) return; } - dstate_setinfo("input.voltage", "%d", + dstate_setinfo("input.voltage", "%ld", hex_or_bin2d(d_value+1, 2) * input_voltage_scaled / 120); /* TODO: factor out the two constants */ @@ -1277,7 +1390,7 @@ void upsdrv_updateinfo(void) ret = send_cmd(m_msg, sizeof(m_msg), m_value, sizeof(m_value)); - if(m_value[5] != 0x0d) { /* we only expect 4 hex/binary digits */ + if(m_value[5] != 0x0d) { /* we only expect 4 hex/binary digits */ dstate_setinfo("ups.debug.M", "%s", hexascdump(m_value+1, 7)); } @@ -1287,8 +1400,10 @@ void upsdrv_updateinfo(void) return; } - dstate_setinfo("input.voltage.minimum", "%3d", hex_or_bin2d(m_value+1, 2) * input_voltage_scaled / 120); - dstate_setinfo("input.voltage.maximum", "%3d", hex_or_bin2d(m_value+3, 2) * input_voltage_scaled / 120); + dstate_setinfo("input.voltage.minimum", "%3ld", + hex_or_bin2d(m_value+1, 2) * input_voltage_scaled / 120); + dstate_setinfo("input.voltage.maximum", "%3ld", + hex_or_bin2d(m_value+3, 2) * input_voltage_scaled / 120); /* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - */ @@ -1312,7 +1427,7 @@ void upsdrv_updateinfo(void) dstate_setinfo("input.frequency.nominal", "%d", 50); break; } - } + } if( tl_model == TRIPP_LITE_SMART_0004 ) { freq = hex2d(t_value + 3, 4); @@ -1320,17 +1435,19 @@ void upsdrv_updateinfo(void) } if( tl_model == TRIPP_LITE_SMART_3005 ) { - dstate_setinfo("ups.temperature", "%d", (unsigned)(hex2d(t_value+1, 1))); + dstate_setinfo("ups.temperature", "%d", + (unsigned)(hex2d(t_value+1, 1))); } else { /* I'm guessing this is a calibration constant of some sort. */ - dstate_setinfo("ups.temperature", "%.1f", (unsigned)(hex2d(t_value+1, 2)) * 0.3636 - 21); + dstate_setinfo("ups.temperature", "%.1f", + (unsigned)(hex2d(t_value+1, 2)) * 0.3636 - 21); } } /* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - */ if( tl_model == TRIPP_LITE_OMNIVS || tl_model == TRIPP_LITE_OMNIVS_2001 || - tl_model == TRIPP_LITE_SMARTPRO || tl_model == TRIPP_LITE_SMART_0004 ) { + tl_model == TRIPP_LITE_SMARTPRO || tl_model == TRIPP_LITE_SMART_0004 || tl_model == TRIPP_LITE_SMART_3005) { /* dq ~= sqrt(dV) is a reasonable approximation * Results fit well against the discrete function used in the Tripp Lite * source, but give a continuous result. */ @@ -1357,16 +1474,32 @@ void upsdrv_updateinfo(void) switch(tl_model) { case TRIPP_LITE_OMNIVS: case TRIPP_LITE_OMNIVS_2001: - dstate_setinfo("output.voltage", "%.1f", hex2d(l_value+1, 4)/240.0*input_voltage_scaled); + dstate_setinfo("output.voltage", "%.1f", + hex2d(l_value+1, 4)/240.0*input_voltage_scaled); break; case TRIPP_LITE_SMARTPRO: - dstate_setinfo("ups.load", "%d", hex2d(l_value+1, 2)); + dstate_setinfo("ups.load", "%ld", hex2d(l_value+1, 2)); + break; + case TRIPP_LITE_SMART_3005: + dstate_setinfo("ups.load", "%ld", hex_or_bin2d(l_value+1, 1)); break; case TRIPP_LITE_SMART_0004: - dstate_setinfo("ups.load", "%d", hex2d(l_value+1, 2)); + dstate_setinfo("ups.load", "%ld", hex2d(l_value+1, 2)); dstate_setinfo("ups.debug.L","%s", hexascdump(l_value+1, 7)); break; + case TRIPP_LITE_UNKNOWN: +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wcovered-switch-default" +#endif + /* All enum cases defined as of the time of coding + * have been covered above. Handle later definitions, + * memory corruptions and buggy inputs below... + */ default: +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT) +# pragma GCC diagnostic pop +#endif dstate_setinfo("ups.debug.L","%s", hexascdump(l_value+1, 7)); break; } @@ -1429,10 +1562,12 @@ void upsdrv_makevartable(void) */ void upsdrv_initups(void) { - char *regex_array[6]; + char *regex_array[7]; char *value; int r; + warn_if_bad_usb_port_filename(device_path); + /* process the UPS selection options */ regex_array[0] = NULL; /* handled by USB IDs device table */ regex_array[1] = getval("productid"); @@ -1440,6 +1575,7 @@ void upsdrv_initups(void) regex_array[3] = getval("product"); /* product string */ regex_array[4] = getval("serial"); /* probably won't see this */ regex_array[5] = getval("bus"); + regex_array[6] = getval("device"); r = USBNewRegexMatcher(®ex_matcher, regex_array, REG_ICASE | REG_EXTENDED); if (r==-1) { @@ -1452,14 +1588,14 @@ void upsdrv_initups(void) regex_matcher->next = &subdriver_matcher; /* Search for the first supported UPS matching the regular - * expression */ + * expression */ r = comm_driver->open(&udev, &curDevice, regex_matcher, NULL); if (r < 1) { fatalx(EXIT_FAILURE, "No matching USB/HID UPS found"); } hd = &curDevice; - + upslogx(1, "Detected a UPS: %s/%s", hd->Vendor ? hd->Vendor : "unknown", hd->Product ? hd->Product : "unknown"); dstate_setinfo("ups.vendorid", "%04x", hd->VendorID); @@ -1475,8 +1611,13 @@ void upsdrv_initups(void) value = getval("offdelay"); if (value) { - offdelay = atoi(value); - upsdebugx(2, "Setting 'offdelay' to %d", offdelay); + int ival = atoi(value); + if (ival >= 0) { + offdelay = (unsigned int)ival; + upsdebugx(2, "Setting 'offdelay' to %u", offdelay); + } else { + upsdebugx(2, "FAILED to set 'offdelay' to %d", ival); + } } value = getval("battery_min"); @@ -1504,4 +1645,9 @@ void upsdrv_cleanup(void) comm_driver->close(udev); USBFreeExactMatcher(reopen_matcher); USBFreeRegexMatcher(regex_matcher); + free(curDevice.Vendor); + free(curDevice.Product); + free(curDevice.Serial); + free(curDevice.Bus); + free(curDevice.Device); } diff --git a/drivers/tripplitesu.c b/drivers/tripplitesu.c index 2f6dd2b..05e8972 100644 --- a/drivers/tripplitesu.c +++ b/drivers/tripplitesu.c @@ -125,7 +125,7 @@ #include "serial.h" #define DRIVER_NAME "Tripp Lite SmartOnline driver" -#define DRIVER_VERSION "0.05" +#define DRIVER_VERSION "0.06" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -215,10 +215,11 @@ static struct { #define WATCHDOG "WDG" /* poll/set */ -static int do_command(char type, const char *command, const char *parameters, char *response) +static ssize_t do_command(char type, const char *command, const char *parameters, char *response) { char buffer[SMALLBUF]; - int count, ret; + size_t count; + ssize_t ret; ser_flush_io(upsfd); @@ -234,7 +235,7 @@ static int do_command(char type, const char *command, const char *parameters, ch return -1; } - upsdebugx(3, "do_command: %d bytes sent [%s] -> OK", ret, buffer); + upsdebugx(3, "do_command: %zd bytes sent [%s] -> OK", ret, buffer); ret = ser_get_buf_len(upsfd, (unsigned char *)buffer, 4, 3, 0); if (ret < 0) { @@ -247,7 +248,7 @@ static int do_command(char type, const char *command, const char *parameters, ch } buffer[ret] = '\0'; - upsdebugx(3, "do_command: %d byted read [%s]", ret, buffer); + upsdebugx(3, "do_command: %zd byted read [%s]", ret, buffer); if (!strcmp(buffer, "~00D")) { @@ -262,9 +263,15 @@ static int do_command(char type, const char *command, const char *parameters, ch } buffer[ret] = '\0'; - upsdebugx(3, "do_command: %d bytes read [%s]", ret, buffer); + upsdebugx(3, "do_command: %zd bytes read [%s]", ret, buffer); - count = atoi(buffer); + int c = atoi(buffer); + if (c < 0) { + upsdebugx(3, "do_command: response not expected to be a negative count!"); + return -1; + } + + count = (size_t)c; if (count >= MAX_RESPONSE_LENGTH) { upsdebugx(3, "do_command: response exceeds expected size!"); return -1; @@ -290,7 +297,7 @@ static int do_command(char type, const char *command, const char *parameters, ch } response[ret] = '\0'; - upsdebugx(3, "do_command: %d bytes read [%s]", ret, response); + upsdebugx(3, "do_command: %zd bytes read [%s]", ret, response); /* Tripp Lite pads their string responses with spaces. I don't like that, so I remove them. This is safe to @@ -432,7 +439,7 @@ static void set_sensitivity(const char *val) { for (i = 0; i < sizeof(sensitivity) / sizeof(sensitivity[0]); i++) { if (!strcasecmp(val, sensitivity[i].name)) { - snprintf(parm, sizeof(parm), "%d", i); + snprintf(parm, sizeof(parm), "%u", i); do_command(SET, VOLTAGE_SENSITIVITY, parm, NULL); break; } @@ -514,7 +521,7 @@ static int instcmd(const char *cmdname, const char *extra) do_command(SET, TEST, "0", NULL); return STAT_INSTCMD_HANDLED; } - upslogx(LOG_NOTICE, "instcmd: unknown command [%s]", cmdname); + upslogx(LOG_NOTICE, "instcmd: unknown command [%s] [%s]", cmdname, extra); return STAT_INSTCMD_UNKNOWN; } @@ -548,7 +555,7 @@ static int setvar(const char *varname, const char *val) static int init_comm(void) { - int i, bit; + size_t i, bit; char response[MAX_RESPONSE_LENGTH]; ups.commands_available = 0; @@ -608,17 +615,29 @@ void upsdrv_initinfo(void) dstate_setinfo("battery.voltage.nominal", "%d", atoi(ptr)); ptr = field(response, 10); - if (ptr) - min_low_transfer = atoi(ptr); + if (ptr) { + int ipv = atoi(ptr); + if (ipv >= 0) + min_low_transfer = (unsigned int)ipv; + } ptr = field(response, 9); - if (ptr) - max_low_transfer = atoi(ptr); + if (ptr) { + int ipv = atoi(ptr); + if (ipv >= 0) + max_low_transfer = (unsigned int)ipv; + } ptr = field(response, 12); - if (ptr) - min_high_transfer = atoi(ptr); + if (ptr) { + int ipv = atoi(ptr); + if (ipv >= 0) + min_high_transfer = (unsigned int)ipv; + } ptr = field(response, 11); - if (ptr) - max_high_transfer = atoi(ptr); + if (ptr) { + int ipv = atoi(ptr); + if (ipv >= 0) + max_high_transfer = (unsigned int)ipv; + } } if (do_command(POLL, OUTLET_RELAYS, "", response) > 0) ups.outlet_banks = atoi(response); @@ -723,15 +742,15 @@ void upsdrv_updateinfo(void) ptr = field(response, 3); if (ptr) dstate_setinfo("output.voltage", "%03.1f", - (double) atoi(ptr) / 10.0); + (double) (atoi(ptr)) / 10.0); ptr = field(response, 1); if (ptr) dstate_setinfo("output.frequency", "%03.1f", - (double) atoi(ptr) / 10.0); + (double) (atoi(ptr)) / 10.0); ptr = field(response, 4); if (ptr) dstate_setinfo("output.current", "%03.1f", - (double) atoi(ptr) / 10.0); + (double) (atoi(ptr)) / 10.0); low_battery = 0; if (do_command(POLL, STATUS_BATTERY, "", response) <= 0) { @@ -758,11 +777,11 @@ void upsdrv_updateinfo(void) ptr = field(response, 6); if (ptr) dstate_setinfo("battery.voltage", "%03.1f", - (double) atoi(ptr) / 10.0); + (double) (atoi(ptr)) / 10.0); ptr = field(response, 7); if (ptr) dstate_setinfo("battery.current", "%03.1f", - (double) atoi(ptr) / 10.0); + (double) (atoi(ptr)) / 10.0); if (low_battery) status_set("LB"); @@ -778,11 +797,11 @@ void upsdrv_updateinfo(void) ptr = field(response, 2); if (ptr) dstate_setinfo("input.voltage", "%03.1f", - (double) atoi(ptr) / 10.0); + (double) (atoi(ptr)) / 10.0); ptr = field(response, 1); if (ptr) - dstate_setinfo("input.frequency", - "%03.1f", (double) atoi(ptr) / 10.0); + dstate_setinfo("input.frequency", "%03.1f", + (double) (atoi(ptr)) / 10.0); } if (do_command(POLL, TEST_RESULT, "", response) > 0) { @@ -790,7 +809,7 @@ void upsdrv_updateinfo(void) size_t trsize; r = atoi(response); - trsize = sizeof(test_result_names) / + trsize = sizeof(test_result_names) / sizeof(test_result_names[0]); if ((r < 0) || (r >= (int) trsize)) diff --git a/drivers/upscode2.c b/drivers/upscode2.c index 3de16d9..50a4764 100644 --- a/drivers/upscode2.c +++ b/drivers/upscode2.c @@ -40,11 +40,10 @@ #include "serial.h" #include "timehead.h" #include "nut_stdint.h" - -#include +#include "nut_float.h" #define DRIVER_NAME "UPScode II UPS driver" -#define DRIVER_VERSION "0.89" +#define DRIVER_VERSION "0.90" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -83,7 +82,7 @@ upsdrv_info_t upsdrv_info = { typedef enum { t_ignore, /* Ignore this response */ t_value, /* Sets a NUT variable */ - t_final, /* Marks the end of UPS data for this command */ + t_final, /* Marks the end of UPS data for this command */ t_string, /* Set a NUT string variable */ t_finstr, /* Set a NUT string variable, and marks end of data */ t_setval, /* Sets a variable in the driver and possibly in NUT */ @@ -100,7 +99,7 @@ typedef struct simple_s { const char *code; type_t type; const char *desc; - int status; + uint32_t status; float *aux; struct simple_s *stats; } simple_t; @@ -127,12 +126,14 @@ static char has_uppm_p[100]; static int input_timeout_sec = INP_TIMO_SEC, - output_pace_usec = OUT_PACE_USEC, full_update_timer = FULL_UPDATE_TIMER, use_crlf = 0, use_pre_lf = 0, buffer_empty = 0; +static useconds_t + output_pace_usec = OUT_PACE_USEC; + static uint32_t status = UPSC_STAT_NOTINIT; @@ -168,287 +169,287 @@ static int /* Status codes for the STAT and STMF status responses */ static simple_t att[] = { - { "00", t_ignore }, - { "AC", t_alarm, "Aux contact failure", 0 }, - { "BA", t_alarm, "Batteries disconnected", 0 }, - { "BC", t_alarm, "Backfeed contact failure", 0 }, - { "BD", t_alarm, "Abnormal battery discharge", 0 }, - { "BF", t_alarm, "Battery fuse failure", 0 }, - { "BL", t_status, "Battery low limit", UPSC_STAT_LOBATT }, - { "BO", t_alarm, "Battery over voltage", 0 }, - { "BP", t_alarm, "Bypass fuse failure", 0 }, - { "BR", t_alarm, "Abnormal battery recharge", 0 }, - { "BT", t_alarm, "Battery over temperature", 0 }, - { "BX", t_alarm, "Bypass unavailable", 0 }, - { "BY", t_alarm, "Battery failure", 0 }, - { "CE", t_alarm, "Configuration error", 0 }, - { "CM", t_alarm, "Battery converter failure", 0 }, - { "CT", t_alarm, "Cabinet over temperature", 0 }, - { "DO", t_alarm, "DC over voltage", 0 }, - { "DU", t_alarm, "DC under voltage", 0 }, - { "EP", t_alarm, "Emergency power off", 0 }, - { "FF", t_alarm, "Fan failure", 0 }, - { "FH", t_alarm, "Line frequency high", 0 }, - { "FL", t_alarm, "Line frequency low", 0 }, - { "FT", t_alarm, "Filter over temperature", 0 }, - { "GF", t_alarm, "Ground failure", 0 }, - { "HT", t_alarm, "Charger over temperature", 0 }, - { "IB", t_alarm, "Internal data bus failure", 0 }, - { "IF", t_alarm, "Inverter fuse failure", 0 }, - { "IM", t_alarm, "Inverter failure", 0 }, - { "IO", t_alarm, "Inverter over voltage", 0 }, - { "IP", t_alarm, "Internal power supply failure", 0 }, - { "IT", t_alarm, "Inverter over temperature", 0 }, - { "IU", t_alarm, "Inverter under voltage", 0 }, - { "IV", t_alarm, "Inverter off", 0 }, - { "LR", t_alarm, "Loss of redundancy", 0 }, - { "NF", t_alarm, "Neutral fault", 0 }, - { "OD", t_status, "UPS not supplying load", UPSC_STAT_OFF }, - { "OF", t_alarm, "Oscillator failure", 0 }, - { "OL", t_status, "Overload", UPSC_STAT_OVERLOAD }, - { "OR", t_alarm, "Redundancy overload", 0 }, - { "OV", t_alarm, "Abnormal output voltage", 0 }, - { "OW", t_alarm, "Output failure", 0 }, - { "PB", t_alarm, "Parallel bus failure", 0 }, - { "PE", t_alarm, "Phase rotation error", 0 }, - { "RE", t_alarm, "Rectifier off", 0 }, - { "RF", t_alarm, "Rectifier fuse failure", 0 }, - { "RM", t_alarm, "Rectifier failure", 0 }, - { "RT", t_alarm, "Rectifier over temperature", 0 }, - { "SM", t_alarm, "Static switch failure", 0 }, - { "ST", t_alarm, "Static switch over temperature", 0 }, - { "TT", t_alarm, "Trafo over temperature", 0 }, - { "UD", t_alarm, "UPS disabled", 0 }, - { "UO", t_alarm, "Utility over voltage", 0 }, - { "US", t_alarm, "Unsynchronized", 0 }, - { "UU", t_alarm, "Utility under voltage", 0 }, - { "VE", t_alarm, "internal voltage error", 0 }, - { NULL } + { "00", t_ignore, NULL, 0, NULL, NULL }, + { "AC", t_alarm, "Aux contact failure", 0, NULL, NULL }, + { "BA", t_alarm, "Batteries disconnected", 0, NULL, NULL }, + { "BC", t_alarm, "Backfeed contact failure", 0, NULL, NULL }, + { "BD", t_alarm, "Abnormal battery discharge", 0, NULL, NULL }, + { "BF", t_alarm, "Battery fuse failure", 0, NULL, NULL }, + { "BL", t_status, "Battery low limit", UPSC_STAT_LOBATT, NULL, NULL }, + { "BO", t_alarm, "Battery over voltage", 0, NULL, NULL }, + { "BP", t_alarm, "Bypass fuse failure", 0, NULL, NULL }, + { "BR", t_alarm, "Abnormal battery recharge", 0, NULL, NULL }, + { "BT", t_alarm, "Battery over temperature", 0, NULL, NULL }, + { "BX", t_alarm, "Bypass unavailable", 0, NULL, NULL }, + { "BY", t_alarm, "Battery failure", 0, NULL, NULL }, + { "CE", t_alarm, "Configuration error", 0, NULL, NULL }, + { "CM", t_alarm, "Battery converter failure", 0, NULL, NULL }, + { "CT", t_alarm, "Cabinet over temperature", 0, NULL, NULL }, + { "DO", t_alarm, "DC over voltage", 0, NULL, NULL }, + { "DU", t_alarm, "DC under voltage", 0, NULL, NULL }, + { "EP", t_alarm, "Emergency power off", 0, NULL, NULL }, + { "FF", t_alarm, "Fan failure", 0, NULL, NULL }, + { "FH", t_alarm, "Line frequency high", 0, NULL, NULL }, + { "FL", t_alarm, "Line frequency low", 0, NULL, NULL }, + { "FT", t_alarm, "Filter over temperature", 0, NULL, NULL }, + { "GF", t_alarm, "Ground failure", 0, NULL, NULL }, + { "HT", t_alarm, "Charger over temperature", 0, NULL, NULL }, + { "IB", t_alarm, "Internal data bus failure", 0, NULL, NULL }, + { "IF", t_alarm, "Inverter fuse failure", 0, NULL, NULL }, + { "IM", t_alarm, "Inverter failure", 0, NULL, NULL }, + { "IO", t_alarm, "Inverter over voltage", 0, NULL, NULL }, + { "IP", t_alarm, "Internal power supply failure", 0, NULL, NULL }, + { "IT", t_alarm, "Inverter over temperature", 0, NULL, NULL }, + { "IU", t_alarm, "Inverter under voltage", 0, NULL, NULL }, + { "IV", t_alarm, "Inverter off", 0, NULL, NULL }, + { "LR", t_alarm, "Loss of redundancy", 0, NULL, NULL }, + { "NF", t_alarm, "Neutral fault", 0, NULL, NULL }, + { "OD", t_status, "UPS not supplying load", UPSC_STAT_OFF, NULL, NULL }, + { "OF", t_alarm, "Oscillator failure", 0, NULL, NULL }, + { "OL", t_status, "Overload", UPSC_STAT_OVERLOAD, NULL, NULL }, + { "OR", t_alarm, "Redundancy overload", 0, NULL, NULL }, + { "OV", t_alarm, "Abnormal output voltage", 0, NULL, NULL }, + { "OW", t_alarm, "Output failure", 0, NULL, NULL }, + { "PB", t_alarm, "Parallel bus failure", 0, NULL, NULL }, + { "PE", t_alarm, "Phase rotation error", 0, NULL, NULL }, + { "RE", t_alarm, "Rectifier off", 0, NULL, NULL }, + { "RF", t_alarm, "Rectifier fuse failure", 0, NULL, NULL }, + { "RM", t_alarm, "Rectifier failure", 0, NULL, NULL }, + { "RT", t_alarm, "Rectifier over temperature", 0, NULL, NULL }, + { "SM", t_alarm, "Static switch failure", 0, NULL, NULL }, + { "ST", t_alarm, "Static switch over temperature", 0, NULL, NULL }, + { "TT", t_alarm, "Trafo over temperature", 0, NULL, NULL }, + { "UD", t_alarm, "UPS disabled", 0, NULL, NULL }, + { "UO", t_alarm, "Utility over voltage", 0, NULL, NULL }, + { "US", t_alarm, "Unsynchronized", 0, NULL, NULL }, + { "UU", t_alarm, "Utility under voltage", 0, NULL, NULL }, + { "VE", t_alarm, "internal voltage error", 0, NULL, NULL }, + { NULL, t_ignore, NULL, 0, NULL, NULL } }; /* Status code for the STLR response */ static simple_t stlr[] = { - { "NO", t_ignore }, - { "SD", t_status, NULL, UPSC_STAT_TRIM }, - { "SU", t_status, NULL, UPSC_STAT_BOOST }, - { "DU", t_status, NULL, UPSC_STAT_BOOST }, - { NULL } + { "NO", t_ignore, NULL, 0, NULL, NULL }, + { "SD", t_status, NULL, UPSC_STAT_TRIM, NULL, NULL }, + { "SU", t_status, NULL, UPSC_STAT_BOOST, NULL, NULL }, + { "DU", t_status, NULL, UPSC_STAT_BOOST, NULL, NULL }, + { NULL, t_ignore, NULL, 0, NULL, NULL } }; /* Status code for the STEA and STEM responses */ static simple_t env[] = { - { "HH", t_ignore, "Humidity high", 0 }, - { "HL", t_ignore, "Humidity low", 0 }, - { "TH", t_ignore, "Temperature high", 0 }, - { "TL", t_ignore, "Temperature low", 0 }, - { "01", t_ignore, "Environment alarm 1", 0 }, - { "02", t_ignore, "Environment alarm 2", 0 }, - { "03", t_ignore, "Environment alarm 3", 0 }, - { "04", t_ignore, "Environment alarm 4", 0 }, - { "05", t_ignore, "Environment alarm 5", 0 }, - { "06", t_ignore, "Environment alarm 6", 0 }, - { "07", t_ignore, "Environment alarm 7", 0 }, - { "08", t_ignore, "Environment alarm 8", 0 }, - { "09", t_ignore, "Environment alarm 9", 0 }, - { NULL } + { "HH", t_ignore, "Humidity high", 0, NULL, NULL }, + { "HL", t_ignore, "Humidity low", 0, NULL, NULL }, + { "TH", t_ignore, "Temperature high", 0, NULL, NULL }, + { "TL", t_ignore, "Temperature low", 0, NULL, NULL }, + { "01", t_ignore, "Environment alarm 1", 0, NULL, NULL }, + { "02", t_ignore, "Environment alarm 2", 0, NULL, NULL }, + { "03", t_ignore, "Environment alarm 3", 0, NULL, NULL }, + { "04", t_ignore, "Environment alarm 4", 0, NULL, NULL }, + { "05", t_ignore, "Environment alarm 5", 0, NULL, NULL }, + { "06", t_ignore, "Environment alarm 6", 0, NULL, NULL }, + { "07", t_ignore, "Environment alarm 7", 0, NULL, NULL }, + { "08", t_ignore, "Environment alarm 8", 0, NULL, NULL }, + { "09", t_ignore, "Environment alarm 9", 0, NULL, NULL }, + { NULL, t_ignore, NULL, 0, NULL, NULL } }; /* Responses for UPSS and UPDS */ static simple_t simple[] = { - { "STAT", t_list, NULL, 0, 0, att }, - { "STBO", t_status, NULL, UPSC_STAT_ONBATT }, - { "STBL", t_status, NULL, UPSC_STAT_LOBATT }, - { "STBM", t_ignore }, - { "STBP", t_status, NULL, UPSC_STAT_BYPASS }, - { "STEA", t_list, NULL, 0, 0, env }, - { "STEM", t_list, NULL, 0, 0, env }, - { "STLR", t_list, NULL, 0, 0, stlr }, - { "STMF", t_list, NULL, 0, 0, att }, - { "STOK", t_ignore }, - { "STUF", t_status, NULL, UPSC_STAT_ONBATT }, + { "STAT", t_list, NULL, 0, NULL, att }, + { "STBO", t_status, NULL, UPSC_STAT_ONBATT, NULL, NULL }, + { "STBL", t_status, NULL, UPSC_STAT_LOBATT, NULL, NULL }, + { "STBM", t_ignore, NULL, 0, NULL, NULL }, + { "STBP", t_status, NULL, UPSC_STAT_BYPASS, NULL, NULL }, + { "STEA", t_list, NULL, 0, NULL, env }, + { "STEM", t_list, NULL, 0, NULL, env }, + { "STLR", t_list, NULL, 0, NULL, stlr }, + { "STMF", t_list, NULL, 0, NULL, att }, + { "STOK", t_ignore, NULL, 0, NULL, NULL }, + { "STUF", t_status, NULL, UPSC_STAT_ONBATT, NULL, NULL }, - { "BTIME", t_setval, NULL, 0, &batt_runtime }, + { "BTIME", t_setval, NULL, 0, &batt_runtime, NULL }, - { "METE1", t_value, "ambient.temperature" }, - { "MERH1", t_value, "ambient.humidity" }, + { "METE1", t_value, "ambient.temperature", 0, NULL, NULL }, + { "MERH1", t_value, "ambient.humidity", 0, NULL, NULL }, - { "MIFFF", t_value, "input.frequency" }, - { "MIIL1", t_value, "input.current" }, - { "MIIL2", t_value, "input.L2.current" }, - { "MIIL3", t_value, "input.L3.current" }, - { "MIPL1", t_value, "input.realpower" }, - { "MIPL2", t_value, "input.L2.realpower" }, - { "MIPL3", t_value, "input.L3.realpower" }, - { "MISL1", t_value, "input.power" }, - { "MISL2", t_value, "input.L2.power" }, - { "MISL3", t_value, "input.L3.power" }, - { "MIUL1", t_value, "input.voltage" }, - { "MIUL2", t_value, "input.L2-N.voltage" }, - { "MIUL3", t_value, "input.L3-N.voltage" }, - { "MIU12", t_value, "input.L1-L2.voltage" }, - { "MIU23", t_value, "input.L2-L3.voltage" }, - { "MIU31", t_value, "input.L3-L1.voltage" }, + { "MIFFF", t_value, "input.frequency", 0, NULL, NULL }, + { "MIIL1", t_value, "input.current", 0, NULL, NULL }, + { "MIIL2", t_value, "input.L2.current", 0, NULL, NULL }, + { "MIIL3", t_value, "input.L3.current", 0, NULL, NULL }, + { "MIPL1", t_value, "input.realpower", 0, NULL, NULL }, + { "MIPL2", t_value, "input.L2.realpower", 0, NULL, NULL }, + { "MIPL3", t_value, "input.L3.realpower", 0, NULL, NULL }, + { "MISL1", t_value, "input.power", 0, NULL, NULL }, + { "MISL2", t_value, "input.L2.power", 0, NULL, NULL }, + { "MISL3", t_value, "input.L3.power", 0, NULL, NULL }, + { "MIUL1", t_value, "input.voltage", 0, NULL, NULL }, + { "MIUL2", t_value, "input.L2-N.voltage", 0, NULL, NULL }, + { "MIUL3", t_value, "input.L3-N.voltage", 0, NULL, NULL }, + { "MIU12", t_value, "input.L1-L2.voltage", 0, NULL, NULL }, + { "MIU23", t_value, "input.L2-L3.voltage", 0, NULL, NULL }, + { "MIU31", t_value, "input.L3-L1.voltage", 0, NULL, NULL }, - { "MBCH1", t_setval, NULL, 0, &batt_charge }, /* battery.charge */ - { "MBIII", t_setval, "battery.current", 0, &batt_current }, - { "MBINE", t_ignore, /* "battery.current.negative" */ }, - { "MBIPO", t_ignore, /* "battery.current.positive" */ }, - { "MBUNE", t_ignore, /* "battery.voltage.negative" */ }, - { "MBUPO", t_ignore, /* "battery.voltage.positive" */}, - { "MBUUU", t_setval, "battery.voltage", 0, &batt_volt }, + { "MBCH1", t_setval, NULL, 0, &batt_charge, NULL }, /* battery.charge */ + { "MBIII", t_setval, "battery.current", 0, &batt_current, NULL }, + { "MBINE", t_ignore, /* "battery.current.negative" */ NULL, 0, NULL, NULL }, + { "MBIPO", t_ignore, /* "battery.current.positive" */ NULL, 0, NULL, NULL }, + { "MBUNE", t_ignore, /* "battery.voltage.negative" */ NULL, 0, NULL, NULL }, + { "MBUPO", t_ignore, /* "battery.voltage.positive" */ NULL, 0, NULL, NULL }, + { "MBUUU", t_setval, "battery.voltage", 0, &batt_volt, NULL }, - { "MLUNE", t_ignore, /* "dc.voltage.negative" */ }, - { "MLUPO", t_ignore, /* "dc.voltage.positive" */ }, - { "MLUUU", t_ignore, /* "dc.voltage" */ }, + { "MLUNE", t_ignore, /* "dc.voltage.negative" */ NULL, 0, NULL, NULL }, + { "MLUPO", t_ignore, /* "dc.voltage.positive" */ NULL, 0, NULL, NULL }, + { "MLUUU", t_ignore, /* "dc.voltage" */ NULL, 0, NULL, NULL }, - { "MOFFF", t_final, "output.frequency" }, - { "MOIL1", t_value, "output.current" }, - { "MOIL2", t_value, "output.L2.current" }, - { "MOIL3", t_value, "output.L3.current" }, - { "MOIP1", t_value, "output.current.peak" }, - { "MOIP2", t_value, "output.L2.current.peak" }, - { "MOIP3", t_value, "output.L3.current.peak" }, - { "MOPL1", t_value, "output.realpower", 0, &kilo_to_unity }, - { "MOPL2", t_value, "output.L2.realpower", 0, &kilo_to_unity }, - { "MOPL3", t_value, "output.L3.realpower", 0, &kilo_to_unity }, - { "MOSL1", t_value, "output.power" }, - { "MOSL2", t_value, "output.L2.power" }, - { "MOSL3", t_value, "output.L3.power" }, - { "MOUL1", t_value, "output.voltage" }, - { "MOUL2", t_value, "output.L2-N.voltage" }, - { "MOUL3", t_value, "output.L3-N.voltage" }, - { "MOU12", t_value, "output.L1-L2.voltage" }, - { "MOU23", t_value, "output.L2-L3.voltage" }, - { "MOU31", t_value, "output.L3-L1.voltage" }, + { "MOFFF", t_final, "output.frequency", 0, NULL, NULL }, + { "MOIL1", t_value, "output.current", 0, NULL, NULL }, + { "MOIL2", t_value, "output.L2.current", 0, NULL, NULL }, + { "MOIL3", t_value, "output.L3.current", 0, NULL, NULL }, + { "MOIP1", t_value, "output.current.peak", 0, NULL, NULL }, + { "MOIP2", t_value, "output.L2.current.peak", 0, NULL, NULL }, + { "MOIP3", t_value, "output.L3.current.peak", 0, NULL, NULL }, + { "MOPL1", t_value, "output.realpower", 0, &kilo_to_unity, NULL }, + { "MOPL2", t_value, "output.L2.realpower", 0, &kilo_to_unity, NULL }, + { "MOPL3", t_value, "output.L3.realpower", 0, &kilo_to_unity, NULL }, + { "MOSL1", t_value, "output.power", 0, NULL, NULL }, + { "MOSL2", t_value, "output.L2.power", 0, NULL, NULL }, + { "MOSL3", t_value, "output.L3.power", 0, NULL, NULL }, + { "MOUL1", t_value, "output.voltage", 0, NULL, NULL }, + { "MOUL2", t_value, "output.L2-N.voltage", 0, NULL, NULL }, + { "MOUL3", t_value, "output.L3-N.voltage", 0, NULL, NULL }, + { "MOU12", t_value, "output.L1-L2.voltage", 0, NULL, NULL }, + { "MOU23", t_value, "output.L2-L3.voltage", 0, NULL, NULL }, + { "MOU31", t_value, "output.L3-L1.voltage", 0, NULL, NULL }, - { "MPUL1", t_value, "input.bypass.L1-N.voltage" }, - { "MPUL2", t_value, "input.bypass.L2-N.voltage" }, - { "MPUL3", t_value, "input.bypass.L3-N.voltage" }, + { "MPUL1", t_value, "input.bypass.L1-N.voltage", 0, NULL, NULL }, + { "MPUL2", t_value, "input.bypass.L2-N.voltage", 0, NULL, NULL }, + { "MPUL3", t_value, "input.bypass.L3-N.voltage", 0, NULL, NULL }, - { "MUTE1", t_value, "ups.temperature" }, - { NULL } + { "MUTE1", t_value, "ups.temperature", 0, NULL, NULL }, + { NULL, t_ignore, NULL, 0, NULL, NULL } }; /* Responses for UPDV */ static simple_t nominal[] = { - { "NIUHH", t_value, "input.voltage.maximum" }, - { "NIULL", t_value, "input.voltage.minimum" }, - { "NIUNN", t_value, "input.voltage.nominal" }, + { "NIUHH", t_value, "input.voltage.maximum", 0, NULL, NULL }, + { "NIULL", t_value, "input.voltage.minimum", 0, NULL, NULL }, + { "NIUNN", t_value, "input.voltage.nominal", 0, NULL, NULL }, - { "NIIHH", t_value, "input.current.maximum" }, - { "NIILL", t_value, "input.current.minimum" }, - { "NIINN", t_value, "input.current.nominal" }, + { "NIIHH", t_value, "input.current.maximum", 0, NULL, NULL }, + { "NIILL", t_value, "input.current.minimum", 0, NULL, NULL }, + { "NIINN", t_value, "input.current.nominal", 0, NULL, NULL }, - { "NIPHH", t_value, "input.realpower.maximum" }, - { "NIPNN", t_value, "input.realpower.nominal" }, + { "NIPHH", t_value, "input.realpower.maximum", 0, NULL, NULL }, + { "NIPNN", t_value, "input.realpower.nominal", 0, NULL, NULL }, - { "NISHH", t_value, "input.power.maximum" }, - { "NISNN", t_value, "input.power.nominal" }, + { "NISHH", t_value, "input.power.maximum", 0, NULL, NULL }, + { "NISNN", t_value, "input.power.nominal", 0, NULL, NULL }, - { "NBAHN", t_setval, "battery.capacity.nominal", 0, &batt_cap_nom }, - { "NBIHH", t_ignore, "battery charge current maximum" }, - { "NBILL", t_setval, NULL, 0, &batt_disch_curr_max}, - { "NBINN", t_value, "battery.current.nominal" }, - { "NBTHH", t_setval, NULL, 0, &batt_runtime_max}, - { "NBUHH", t_setval, "battery.voltage.maximum", 0, &batt_volt_high }, - { "NBULL", t_setval, "battery.voltage.minimum", 0, &batt_volt_low }, - { "NBUNN", t_setval, "battery.voltage.nominal", 0, &batt_volt_nom }, + { "NBAHN", t_setval, "battery.capacity.nominal", 0, &batt_cap_nom, NULL }, + { "NBIHH", t_ignore, "battery charge current maximum", 0, NULL, NULL }, + { "NBILL", t_setval, NULL, 0, &batt_disch_curr_max, NULL }, + { "NBINN", t_value, "battery.current.nominal", 0, NULL, NULL }, + { "NBTHH", t_setval, NULL, 0, &batt_runtime_max, NULL }, + { "NBUHH", t_setval, "battery.voltage.maximum", 0, &batt_volt_high, NULL }, + { "NBULL", t_setval, "battery.voltage.minimum", 0, &batt_volt_low, NULL }, + { "NBUNN", t_setval, "battery.voltage.nominal", 0, &batt_volt_nom, NULL }, - { "NOFHH", t_value, "output.frequency.maximum" }, - { "NOFLL", t_final, "output.frequency.minimum" }, - { "NOIHH", t_setval, "output.current.maximum", 0, &max_out_current }, - { "NOINN", t_setval, "output.current.nominal", 0, &nom_out_current }, - { "NOPNN", t_value, "output.realpower.nominal", 0, &outpwr_factor }, - { "NOSNN", t_value, "ups.power.nominal", 0, &outpwr_factor }, - { "NOUHH", t_value, "output.voltage.maximum" }, - { "NOULL", t_value, "output.voltage.minimum" }, - { "NOUNN", t_value, "output.voltage.nominal" }, + { "NOFHH", t_value, "output.frequency.maximum", 0, NULL, NULL }, + { "NOFLL", t_final, "output.frequency.minimum", 0, NULL, NULL }, + { "NOIHH", t_setval, "output.current.maximum", 0, &max_out_current, NULL }, + { "NOINN", t_setval, "output.current.nominal", 0, &nom_out_current, NULL }, + { "NOPNN", t_value, "output.realpower.nominal", 0, &outpwr_factor, NULL }, + { "NOSNN", t_value, "ups.power.nominal", 0, &outpwr_factor, NULL }, + { "NOUHH", t_value, "output.voltage.maximum", 0, NULL, NULL }, + { "NOULL", t_value, "output.voltage.minimum", 0, NULL, NULL }, + { "NOUNN", t_value, "output.voltage.nominal", 0, NULL, NULL }, - { "NUTEH", t_value, "ups.temperature.maximum" }, - { NULL } + { "NUTEH", t_value, "ups.temperature.maximum", 0, NULL, NULL }, + { NULL, t_ignore, NULL, 0, NULL, NULL } }; /* Status responses for UPBS command */ static simple_t battery[] = { - { "MBTE1", t_value, "battery.1.temperature" }, - { "MBIN1", t_ignore, NULL /* aging index */ }, - { "BDAT1", t_string, "battery.1.date" }, - { "MBTE2", t_value, "battery.2.temperature.2" }, - { "MBIN2", t_ignore, NULL }, - { "BDAT2", t_string, "battery.2.date" }, - { "MBTE3", t_value, "battery.3.temperature" }, - { "MBIN3", t_ignore, NULL }, - { "BDAT3", t_string, "battery.3.date" }, - { "MBTE4", t_value, "battery.4.temperature" }, - { "MBIN4", t_ignore, NULL }, - { "BDAT4", t_string, "battery.4.date" }, - { "MBTE5", t_value, "battery.5.temperature" }, - { "MBIN5", t_ignore, NULL }, - { "BDAT5", t_string, "battery.5.date" }, - { "MBTE6", t_value, "battery.6.temperature" }, - { "MBIN6", t_ignore, NULL }, - { "BDAT6", t_string, "battery.6.date" }, - { "MBTE7", t_value, "battery.7.temperature" }, - { "MBIN7", t_ignore, NULL }, - { "BDAT7", t_string, "battery.7.date" }, - { "MBTE8", t_value, "battery.8.temperature" }, - { "MBIN8", t_ignore, NULL }, - { "BDAT8", t_finstr, "battery.8.date" }, - { NULL } + { "MBTE1", t_value, "battery.1.temperature", 0, NULL, NULL }, + { "MBIN1", t_ignore, NULL /* aging index */, 0, NULL, NULL }, + { "BDAT1", t_string, "battery.1.date", 0, NULL, NULL }, + { "MBTE2", t_value, "battery.2.temperature.2", 0, NULL, NULL }, + { "MBIN2", t_ignore, NULL, 0, NULL, NULL }, + { "BDAT2", t_string, "battery.2.date", 0, NULL, NULL }, + { "MBTE3", t_value, "battery.3.temperature", 0, NULL, NULL }, + { "MBIN3", t_ignore, NULL, 0, NULL, NULL }, + { "BDAT3", t_string, "battery.3.date", 0, NULL, NULL }, + { "MBTE4", t_value, "battery.4.temperature", 0, NULL, NULL }, + { "MBIN4", t_ignore, NULL, 0, NULL, NULL }, + { "BDAT4", t_string, "battery.4.date", 0, NULL, NULL }, + { "MBTE5", t_value, "battery.5.temperature", 0, NULL, NULL }, + { "MBIN5", t_ignore, NULL, 0, NULL, NULL }, + { "BDAT5", t_string, "battery.5.date", 0, NULL, NULL }, + { "MBTE6", t_value, "battery.6.temperature", 0, NULL, NULL }, + { "MBIN6", t_ignore, NULL, 0, NULL, NULL }, + { "BDAT6", t_string, "battery.6.date", 0, NULL, NULL }, + { "MBTE7", t_value, "battery.7.temperature", 0, NULL, NULL }, + { "MBIN7", t_ignore, NULL, 0, NULL, NULL }, + { "BDAT7", t_string, "battery.7.date", 0, NULL, NULL }, + { "MBTE8", t_value, "battery.8.temperature", 0, NULL, NULL }, + { "MBIN8", t_ignore, NULL, 0, NULL, NULL }, + { "BDAT8", t_finstr, "battery.8.date", 0, NULL, NULL }, + { NULL, t_ignore, NULL, 0, NULL, NULL } }; static cmd_t commands[] = { - { "load.off", NULL, NULL }, - { "load.on", NULL, NULL }, - { "shutdown.return", "UPPF", "IJHLDMGCIU" }, - { "shutdown.stayoff", "UPPD", "LGGNLMDPGV" }, - { "shutdown.stop", "UPPU", NULL }, - { "shutdown.reboot", "UPPC", "IJHLDMGCIU" }, - { "shutdown.reboot.graceful", NULL, NULL }, - { "test.panel.start", "UPIS", NULL }, - { "test.panel.stop", NULL, NULL }, - { "test.failure.start", NULL, NULL }, - { "test.failure.stop", NULL, NULL }, - { "test.battery.start", "UPBT", "1" }, - { "test.battery.stop", NULL, NULL }, - { "calibrate.start", NULL, NULL }, - { "calibrate.stop", NULL, NULL }, - { "bypass.start", NULL, NULL }, - { "bypass.stop", NULL, NULL }, - { "reset.input.minmax", NULL, NULL }, - { "reset.watchdog", NULL, NULL }, - { "beeper.enable", NULL, NULL }, - { "beeper.disable", NULL, NULL }, - { "beeper.on", NULL, NULL }, - { "beeper.off", NULL, NULL }, - { NULL } + { "load.off", NULL, NULL, 0 }, + { "load.on", NULL, NULL, 0 }, + { "shutdown.return", "UPPF", "IJHLDMGCIU", 0 }, + { "shutdown.stayoff", "UPPD", "LGGNLMDPGV", 0 }, + { "shutdown.stop", "UPPU", NULL, 0 }, + { "shutdown.reboot", "UPPC", "IJHLDMGCIU", 0 }, + { "shutdown.reboot.graceful", NULL, NULL, 0 }, + { "test.panel.start", "UPIS", NULL, 0 }, + { "test.panel.stop", NULL, NULL, 0 }, + { "test.failure.start", NULL, NULL, 0 }, + { "test.failure.stop", NULL, NULL, 0 }, + { "test.battery.start", "UPBT", "1", 0 }, + { "test.battery.stop", NULL, NULL, 0 }, + { "calibrate.start", NULL, NULL, 0 }, + { "calibrate.stop", NULL, NULL, 0 }, + { "bypass.start", NULL, NULL, 0 }, + { "bypass.stop", NULL, NULL, 0 }, + { "reset.input.minmax", NULL, NULL, 0 }, + { "reset.watchdog", NULL, NULL, 0 }, + { "beeper.enable", NULL, NULL, 0 }, + { "beeper.disable", NULL, NULL, 0 }, + { "beeper.on", NULL, NULL, 0 }, + { "beeper.off", NULL, NULL, 0 }, + { NULL, NULL, NULL, 0 } }; static cmd_t variables[] = { - { "ups.delay.reboot", "UPCD", "ACCD" }, - { "ups.delay.shutdown", "UPSD", "ACSD" }, - { NULL } + { "ups.delay.reboot", "UPCD", "ACCD", 0 }, + { "ups.delay.shutdown", "UPSD", "ACSD", 0 }, + { NULL, NULL, NULL, 0 } }; static int instcmd (const char *auxcmd, const char *data); static int setvar (const char *var, const char *data); -static void upsc_setstatus(unsigned int status); +static void upsc_setstatus(unsigned int upsc_status); static void upsc_flush_input(void); static void upsc_getbaseinfo(void); static int upsc_commandlist(void); static int upsc_getparams(const char *cmd, const simple_t *table); static int upsc_getvalue(const char *cmd, const char *param, const char *resp, const char *var, char *ret); -static int upscsend(const char *cmd); -static int upscrecv(char *buf); +static ssize_t upscsend(const char *cmd); +static ssize_t upscrecv(char *buf); static int upsc_simple(const simple_t *sp, const char *var, const char *val); static void check_uppm(void); static float batt_charge_pct(void); @@ -463,7 +464,7 @@ void upsdrv_help(void) void upsdrv_initups(void) { struct termios tio; - int baud = B1200; + speed_t baud = B1200; char *str; if ((str = getval("baudrate")) != NULL) { @@ -510,12 +511,13 @@ void upsdrv_initups(void) upsdebugx(1, "input_timeout = %d Sec", input_timeout_sec); if ((str = getval("output_pace")) != NULL) { - int temp = atoi(str); + /* Range should be at least up to 1000000; a C99+ long guarantees that */ + long temp = atol(str); if (temp <= 0) fatalx(EXIT_FAILURE, "Bad output_pace parameter: %s", str); - output_pace_usec = temp; + output_pace_usec = (useconds_t)temp; } - upsdebugx(1, "output_pace = %d uSec", output_pace_usec); + upsdebugx(1, "output_pace = %ju uSec", (uintmax_t)output_pace_usec); if ((str = getval("full_update_timer")) != NULL) { int temp = atoi(str); @@ -837,8 +839,8 @@ void upsdrv_updateinfo(void) if (batt_runtime >= 0 && batt_runtime < 9999) { dstate_setinfo("battery.runtime", "%.0f", batt_runtime*60); } - else if (load > 0 && batt_disch_curr_max != 0) { - float est_battcurr = load * abs(batt_disch_curr_max); + else if (load > 0 && ! f_equal(batt_disch_curr_max, 0)) { + float est_battcurr = load * fabs(batt_disch_curr_max); /* Peukert equation */ float runtime = (batt_cap_nom*3600)/pow(est_battcurr, 1.35); @@ -963,8 +965,10 @@ void upsdrv_cleanup(void) /* * Generate status string from bitfield */ -static void upsc_setstatus(unsigned int status) +static void upsc_setstatus(unsigned int upsc_status) { + /* Save into global state variable for the driver instance */ + status = upsc_status; /* * I'll look for all available statuses, even though they might not be @@ -1000,9 +1004,9 @@ static void upsc_setstatus(unsigned int status) /* Add \r to end of command and send to UPS */ /* returns < 0 on errors, 0 on timeout and > 0 on success. */ -static int upscsend(const char *cmd) +static ssize_t upscsend(const char *cmd) { - int res; + ssize_t res; res = ser_send_pace(upsfd, output_pace_usec, "%s%s%s", use_pre_lf ? "\n" : "", @@ -1023,9 +1027,9 @@ static int upscsend(const char *cmd) /* Return a string read from UPS */ /* returns < 0 on errors, 0 on timeout and > 0 on success. */ -static int upscrecv(char *buf) +static ssize_t upscrecv(char *buf) { - int res; + ssize_t res; /* NOTE: the serial port is set to use Canonical Mode Input Processing, which means ser_get_buf() either returns one line terminated with @@ -1046,7 +1050,7 @@ static int upscrecv(char *buf) } else if (res == 0) { upsdebugx(3, "upscrecv: Timeout"); } else { - upsdebugx(3, "upscrecv: %u bytes:\t'%s'", res-1, str_rtrim(buf, ENDCHAR)); + upsdebugx(3, "upscrecv: %zd bytes:\t'%s'", res-1, str_rtrim(buf, ENDCHAR)); } return res; @@ -1185,19 +1189,19 @@ static void check_uppm(void) if (strcmp(var, "ACPM")) upslogx(LOG_ERR, "Bad response to UPPM: %s", var); while (1) { - int val, stat; + int intval, stat; upscrecv(var); if (strlen(var) == 0) break; upsdebugx(2, "UPPM available: %s", var); - stat = sscanf(var, "P%2d", &val); + stat = sscanf(var, "P%2d", &intval); if (stat != 1) { upslogx(LOG_ERR, "Bad response to UPPM: %s", var); return; } - has_uppm_p[val] = 1; - if (val > last) - last = val; + has_uppm_p[intval] = 1; + if (intval > last) + last = intval; } for (i = 0; i <= last; i++) { @@ -1300,7 +1304,10 @@ static int upsc_simple(const simple_t *sp, const char *var, const char *val) break; case t_final: buffer_empty = 1; + /* FIXME? Should this really fall through, or should break? */ + goto fallthrough_bufempty_processing_1; case t_value: + fallthrough_bufempty_processing_1: if (!sp->desc) { break; } @@ -1317,7 +1324,10 @@ static int upsc_simple(const simple_t *sp, const char *var, const char *val) break; case t_finstr: buffer_empty = 1; + /* FIXME? Should this really fall through, or should break? */ + goto fallthrough_bufempty_processing_2; case t_string: + fallthrough_bufempty_processing_2: if (!sp->desc) { break; } @@ -1347,9 +1357,36 @@ static int upsc_simple(const simple_t *sp, const char *var, const char *val) upslogx(LOG_ERR, "Unknown value: %s %s", var, val); break; + +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) ) +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT +# pragma GCC diagnostic ignored "-Wcovered-switch-default" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic ignored "-Wunreachable-code" +#endif +/* Older CLANG (e.g. clang-3.4) seems to not support the GCC pragmas above */ +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" +#pragma clang diagnostic ignored "-Wcovered-switch-default" +#endif + /* All enum cases defined as of the time of coding + * have been covered above. Handle later definitions, + * memory corruptions and buggy inputs below... + */ default: upslogx(LOG_ERR, "Unknown type for %s", var); break; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) ) +# pragma GCC diagnostic pop +#endif + } return 1; } diff --git a/drivers/upsdrvctl.c b/drivers/upsdrvctl.c index 0cdaa2c..a33fcd1 100644 --- a/drivers/upsdrvctl.c +++ b/drivers/upsdrvctl.c @@ -17,6 +17,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "config.h" /* must be the first header */ + #include #include #include @@ -24,10 +26,11 @@ #include #include -#include "config.h" #include "proto.h" #include "common.h" #include "upsconf.h" +#include "attribute.h" +#include "nut_stdint.h" typedef struct { char *upsname; @@ -42,6 +45,9 @@ static ups_t *upstable = NULL; static int maxsdorder = 0, testmode = 0, exec_error = 0; + /* Should we wait for driver (1) or "parallelize" drivers start (0) */ +static int waitfordrivers = 1; + /* timer - keeps us from getting stuck if a driver hangs */ static int maxstartdelay = 45; @@ -57,6 +63,9 @@ static char *driverpath = NULL; /* passthrough to the drivers: chroot path and new user name */ static char *pt_root = NULL, *pt_user = NULL; + /* flag to pass nut_debug_level to launched drivers (as their -D... args) */ +static int nut_debug_level_passthrough = 0; + void do_upsconf_args(char *upsname, char *var, char *val) { ups_t *tmp, *last; @@ -77,6 +86,9 @@ void do_upsconf_args(char *upsname, char *var, char *val) if (!strcmp(var, "retrydelay")) retrydelay = atoi(val); + if (!strcmp(var, "nowait")) + waitfordrivers = 0; + /* ignore anything else - it's probably for main */ return; @@ -144,13 +156,14 @@ static void stop_driver(const ups_t *ups) ret = stat(pidfn, &fs); if ((ret != 0) && (ups->port != NULL)) { + upslog_with_errno(LOG_ERR, "Can't open %s", pidfn); snprintf(pidfn, sizeof(pidfn), "%s/%s-%s.pid", altpidpath(), ups->driver, xbasename(ups->port)); ret = stat(pidfn, &fs); } if (ret != 0) { - upslog_with_errno(LOG_ERR, "Can't open %s", pidfn); + upslog_with_errno(LOG_ERR, "Can't open %s either", pidfn); exec_error++; return; } @@ -171,6 +184,8 @@ static void stop_driver(const ups_t *ups) static void waitpid_timeout(const int sig) { + NUT_UNUSED_VARIABLE(sig); + /* do nothing */ return; } @@ -203,15 +218,25 @@ static void forkexec(char *const argv[], const ups_t *ups) int wstat; struct sigaction sa; + /* Handle "parallel" drivers startup */ + if (waitfordrivers == 0) { + upsdebugx(2, "'nowait' set, continuing..."); + return; + } + sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sa.sa_handler = waitpid_timeout; sigaction(SIGALRM, &sa, NULL); - if (ups->maxstartdelay != -1) - alarm(ups->maxstartdelay); - else - alarm(maxstartdelay); + /* Use the local maxstartdelay, if available */ + if (ups->maxstartdelay != -1) { + if (ups->maxstartdelay >= 0) + alarm((unsigned int)ups->maxstartdelay); + } else { /* Otherwise, use the global (or default) value */ + if (maxstartdelay >= 0) + alarm((unsigned int)maxstartdelay); + } ret = waitpid(pid, &wstat, 0); @@ -257,8 +282,8 @@ static void forkexec(char *const argv[], const ups_t *ups) static void start_driver(const ups_t *ups) { - char *argv[8]; - char dfn[SMALLBUF]; + char *argv[9]; + char dfn[SMALLBUF], dbg[SMALLBUF]; int ret, arg = 0; int initial_exec_error = exec_error, drv_maxretry = maxretry; struct stat fs; @@ -272,6 +297,63 @@ static void start_driver(const ups_t *ups) fatal_with_errno(EXIT_FAILURE, "Can't start %s", dfn); argv[arg++] = dfn; + + if (nut_debug_level_passthrough > 0 + && nut_debug_level > 0 + && sizeof(dbg) > 3 + ) { + size_t d, m; + + /* cut-off point: buffer size or requested debug level */ + m = sizeof(dbg) - 1; /* leave a place for '\0' */ + +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) ) +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +# pragma GCC diagnostic ignored "-Wunreachable-code" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE +# pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wunreachable-code" +# pragma clang diagnostic ignored "-Wtautological-compare" +# pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif + /* Different platforms, different sizes, none fits all... */ + /* can we fit this many 'D's? */ + if ((uintmax_t)SIZE_MAX > (uintmax_t)nut_debug_level /* else can't assign, requested debug level is huge */ + && (size_t)nut_debug_level + 1 < m + ) { +#ifdef __clang__ +# pragma clang diagnostic pop +#endif +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) ) +# pragma GCC diagnostic pop +#endif + /* need even fewer (leave a place for '-'): */ + m = (size_t)nut_debug_level + 1; + } else { + upsdebugx(1, "Requested debugging level %d is too " + "high for pass-through args, truncated to %zu", + nut_debug_level, + (m - 1) /* count off '-' (and '\0' already) chars */ + ); + } + + dbg[0] = '-'; + for (d = 1; d < m ; d++) { + dbg[d] = 'D'; + } + dbg[d] = '\0'; + argv[arg++] = dbg; + } + argv[arg++] = (char *)"-a"; /* FIXME: cast away const */ argv[arg++] = ups->upsname; @@ -309,11 +391,15 @@ static void start_driver(const ups_t *ups) else { /* otherwise, retry if still needed */ if (drv_maxretry > 0) - sleep (retrydelay); + if (retrydelay >= 0) + sleep ((unsigned int)retrydelay); } } } +static void help(const char *progname) + __attribute__((noreturn)); + static void help(const char *progname) { printf("Starts and stops UPS drivers via ups.conf.\n\n"); @@ -324,6 +410,7 @@ static void help(const char *progname) printf(" -t testing mode - prints actions without doing them\n"); printf(" -u drivers started will switch from root to \n"); printf(" -D raise debugging level\n"); + printf(" -d pass debugging level from upsdrvctl to driver\n"); printf(" start start all UPS drivers in ups.conf\n"); printf(" start only start driver for UPS \n"); printf(" stop stop all UPS drivers in ups.conf\n"); @@ -415,7 +502,7 @@ static void send_all_drivers(void (*command)(const ups_t *)) while (ups) { if (ups->sdorder == i) command(ups); - + ups = ups->next; } } @@ -451,7 +538,7 @@ int main(int argc, char **argv) UPS_VERSION); prog = argv[0]; - while ((i = getopt(argc, argv, "+htu:r:DV")) != -1) { + while ((i = getopt(argc, argv, "+htu:r:DdV")) != -1) { switch(i) { case 'r': pt_root = optarg; @@ -472,10 +559,13 @@ int main(int argc, char **argv) nut_debug_level++; break; + case 'd': + nut_debug_level_passthrough = 1; + break; + case 'h': default: help(prog); - break; } } @@ -492,14 +582,18 @@ int main(int argc, char **argv) nut_debug_level = 2; } - upsdebugx(2, "\n" - "If you're not a NUT core developer, chances are that you're told to enable debugging\n" - "to see why a driver isn't working for you. We're sorry for the confusion, but this is\n" - "the 'upsdrvctl' wrapper, not the driver you're interested in.\n\n" - "Below you'll find one or more lines starting with 'exec:' followed by an absolute\n" - "path to the driver binary and some command line option. This is what the driver\n" - "starts and you need to copy and paste that line and append the debug flags to that\n" - "line (less the 'exec:' prefix).\n"); + if (nut_debug_level_passthrough == 0) { + upsdebugx(2, "\n" + "If you're not a NUT core developer, chances are that you're told to enable debugging\n" + "to see why a driver isn't working for you. We're sorry for the confusion, but this is\n" + "the 'upsdrvctl' wrapper, not the driver you're interested in.\n\n" + "Below you'll find one or more lines starting with 'exec:' followed by an absolute\n" + "path to the driver binary and some command line option. This is what the driver\n" + "starts and you need to copy and paste that line and append the debug flags to that\n" + "line (less the 'exec:' prefix).\n\n" + "Alternately, provide an additional '-d' (lower-case) parameter to 'upsdrvctl' to\n" + "pass its current debug level to the launched driver.\n"); + } if (!strcmp(argv[0], "start")) command = &start_driver; diff --git a/drivers/upshandler.h b/drivers/upshandler.h index ca9a349..fea10bc 100644 --- a/drivers/upshandler.h +++ b/drivers/upshandler.h @@ -25,15 +25,15 @@ enum { STAT_INSTCMD_HANDLED = 0, /* completed successfully */ STAT_INSTCMD_UNKNOWN, /* unspecified error */ STAT_INSTCMD_INVALID, /* invalid command */ - STAT_INSTCMD_FAILED /* command failed */ + STAT_INSTCMD_FAILED /* command failed */ }; /* return values for setvar */ enum { STAT_SET_HANDLED = 0, /* completed successfully */ - STAT_SET_UNKNOWN, /* unspecified error */ - STAT_SET_INVALID, /* not writeable */ - STAT_SET_FAILED /* writing failed */ + STAT_SET_UNKNOWN, /* unspecified error */ + STAT_SET_INVALID, /* not writeable */ + STAT_SET_FAILED /* writing failed */ }; /* structure for funcs that get called by msg parse routine */ diff --git a/drivers/usb-common.c b/drivers/usb-common.c index 4fc88b6..5f2dc16 100644 --- a/drivers/usb-common.c +++ b/drivers/usb-common.c @@ -25,8 +25,10 @@ int is_usb_device_supported(usb_device_id_t *usb_device_id_list, USBDevice_t *de int retval = NOT_SUPPORTED; usb_device_id_t *usbdev; - for (usbdev = usb_device_id_list; usbdev->vendorID != -1; usbdev++) { - + for (usbdev = usb_device_id_list; + (usbdev->vendorID != 0 || usbdev->productID != 0 || usbdev->fun != NULL); + usbdev++ + ) { if (usbdev->vendorID != device->VendorID) { continue; } @@ -78,28 +80,49 @@ static int strcmp_null(char *s1, char *s2) static int match_function_exact(USBDevice_t *hd, void *privdata) { USBDevice_t *data = (USBDevice_t *)privdata; - + + upsdebugx(3, "%s: matching a device...", __func__); + if (hd->VendorID != data->VendorID) { + upsdebugx(2, "%s: failed match of %s: %4x != %4x", + __func__, "VendorID", hd->VendorID, data->VendorID); return 0; } if (hd->ProductID != data->ProductID) { + upsdebugx(2, "%s: failed match of %s: %4x != %4x", + __func__, "ProductID", hd->ProductID, data->ProductID); return 0; } if (strcmp_null(hd->Vendor, data->Vendor) != 0) { + upsdebugx(2, "%s: failed match of %s: %s != %s", + __func__, "Vendor", hd->Vendor, data->Vendor); return 0; } if (strcmp_null(hd->Product, data->Product) != 0) { + upsdebugx(2, "%s: failed match of %s: %s != %s", + __func__, "Product", hd->Product, data->Product); return 0; } if (strcmp_null(hd->Serial, data->Serial) != 0) { + upsdebugx(2, "%s: failed match of %s: %s != %s", + __func__, "Serial", hd->Serial, data->Serial); return 0; } #ifdef DEBUG_EXACT_MATCH_BUS if (strcmp_null(hd->Bus, data->Bus) != 0) { + upsdebugx(2, "%s: failed match of %s: %s != %s", + __func__, "Bus", hd->Bus, data->Bus); + return 0; + } +#endif +#ifdef DEBUG_EXACT_MATCH_DEVICE + if (strcmp_null(hd->Device, data->Device) != 0) { + upsdebugx(2, "%s: failed match of %s: %s != %s", + __func__, "Device", hd->Device, data->Device); return 0; } #endif @@ -137,6 +160,9 @@ int USBNewExactMatcher(USBDeviceMatcher_t **matcher, USBDevice_t *hd) data->Serial = hd->Serial ? strdup(hd->Serial) : NULL; #ifdef DEBUG_EXACT_MATCH_BUS data->Bus = hd->Bus ? strdup(hd->Bus) : NULL; +#endif +#ifdef DEBUG_EXACT_MATCH_DEVICE + data->Device = hd->Device ? strdup(hd->Device) : NULL; #endif *matcher = m; @@ -159,6 +185,9 @@ void USBFreeExactMatcher(USBDeviceMatcher_t *matcher) free(data->Serial); #ifdef DEBUG_EXACT_MATCH_BUS free(data->Bus); +#endif +#ifdef DEBUG_EXACT_MATCH_DEVICE + free(data->Device); #endif free(data); free(matcher); @@ -271,7 +300,7 @@ static int match_regex_hex(regex_t *preg, int n) /* private data type: hold a set of compiled regular expressions. */ typedef struct regex_matcher_data_s { - regex_t *regex[6]; + regex_t *regex[7]; } regex_matcher_data_t; /* private callback function for regex matches */ @@ -279,48 +308,97 @@ static int match_function_regex(USBDevice_t *hd, void *privdata) { regex_matcher_data_t *data = (regex_matcher_data_t *)privdata; int r; - + + upsdebugx(3, "%s: matching a device...", __func__); + r = match_regex_hex(data->regex[0], hd->VendorID); if (r != 1) { +/* + upsdebugx(2, "%s: failed match of %s: %4x !~ %s", + __func__, "VendorID", hd->VendorID, data->regex[0]); +*/ + upsdebugx(2, "%s: failed match of %s: %4x", + __func__, "VendorID", hd->VendorID); return r; } r = match_regex_hex(data->regex[1], hd->ProductID); if (r != 1) { +/* + upsdebugx(2, "%s: failed match of %s: %4x !~ %s", + __func__, "ProductID", hd->ProductID, data->regex[1]); +*/ + upsdebugx(2, "%s: failed match of %s: %4x", + __func__, "ProductID", hd->ProductID); return r; } r = match_regex(data->regex[2], hd->Vendor); if (r != 1) { +/* + upsdebugx(2, "%s: failed match of %s: %s !~ %s", + __func__, "Vendor", hd->Vendor, data->regex[2]); +*/ + upsdebugx(2, "%s: failed match of %s: %s", + __func__, "Vendor", hd->Vendor); return r; } r = match_regex(data->regex[3], hd->Product); if (r != 1) { +/* + upsdebugx(2, "%s: failed match of %s: %s !~ %s", + __func__, "Product", hd->Product, data->regex[3]); +*/ + upsdebugx(2, "%s: failed match of %s: %s", + __func__, "Product", hd->Product); return r; } r = match_regex(data->regex[4], hd->Serial); if (r != 1) { +/* + upsdebugx(2, "%s: failed match of %s: %s !~ %s", + __func__, "Serial", hd->Serial, data->regex[4]); +*/ + upsdebugx(2, "%s: failed match of %s: %s", + __func__, "Serial", hd->Serial); return r; } r = match_regex(data->regex[5], hd->Bus); if (r != 1) { +/* + upsdebugx(2, "%s: failed match of %s: %s !~ %s", + __func__, "Bus", hd->Bus, data->regex[5]); +*/ + upsdebugx(2, "%s: failed match of %s: %s", + __func__, "Bus", hd->Bus); + return r; + } + + r = match_regex(data->regex[6], hd->Device); + if (r != 1) { +/* + upsdebugx(2, "%s: failed match of %s: %s !~ %s", + __func__, "Device", hd->Device, data->regex[6]); +*/ + upsdebugx(2, "%s: failed match of %s: %s", + __func__, "Device", hd->Device); return r; } return 1; } /* constructor: create a regular expression matcher. This matcher is - * based on six regular expression strings in regex_array[0..5], + * based on seven regular expression strings in regex_array[0..6], * corresponding to: vendorid, productid, vendor, product, serial, - * bus. Any of these strings can be NULL, which matches + * bus, device. Any of these strings can be NULL, which matches * everything. Cflags are as in regcomp(3). Typical values for cflags * are REG_ICASE (case insensitive matching) and REG_EXTENDED (use * extended regular expressions). On success, return 0 and store the * matcher in *matcher. On error, return -1 with errno set, or return - * i=1--6 to indicate that the regular expression regex_array[i-1] was + * i=1--7 to indicate that the regular expression regex_array[i-1] was * ill-formed (an error message can then be retrieved with * regerror(3)). */ @@ -345,7 +423,7 @@ int USBNewRegexMatcher(USBDeviceMatcher_t **matcher, char **regex, int cflags) m->privdata = (void *)data; m->next = NULL; - for (i=0; i<6; i++) { + for (i=0; i<7; i++) { r = compile_regex(&data->regex[i], regex[i], cflags); if (r == -2) { r = i+1; @@ -365,14 +443,14 @@ void USBFreeRegexMatcher(USBDeviceMatcher_t *matcher) { int i; regex_matcher_data_t *data; - + if (!matcher) { return; } data = (regex_matcher_data_t *)matcher->privdata; - for (i = 0; i < 6; i++) { + for (i = 0; i < 7; i++) { if (!data->regex[i]) { continue; } @@ -384,3 +462,38 @@ void USBFreeRegexMatcher(USBDeviceMatcher_t *matcher) free(data); free(matcher); } + +void warn_if_bad_usb_port_filename(const char *fn) { + /* USB drivers ignore the 'port' setting - log a notice + * if it is not "auto". Note: per se, ignoring the port + * (or internally the device_path variable from main.c) + * is currently not a bug and is actually documented at + * docs/config-notes.txt; however it is not something + * evident to users during troubleshooting a device. + * Documentation and common practice recommend port=auto + * so here we warn during driver start if it has some + * other value and users might think it is honoured. + */ + + if (!fn) { + upslogx(LOG_WARNING, + "WARNING: %s(): port argument was not " + "specified to the driver", + __func__); + return; + } + + if (!strcmp(fn, "auto")) + return; + + upslogx(LOG_WARNING, + "WARNING: %s(): port argument specified to\n" + " the driver is \"%s\" but USB drivers do " + "not use it and rely on\n" + " libusb walking all devices and matching " + "their identification metadata.\n" + " NUT documentation recommends port=\"auto\" " + "for USB devices to avoid confusion.", + __func__, fn); + return; +} diff --git a/drivers/usb-common.h b/drivers/usb-common.h index c9d8a85..cc9e8ce 100644 --- a/drivers/usb-common.h +++ b/drivers/usb-common.h @@ -1,6 +1,43 @@ /* usb-common.h - prototypes for the common useful USB functions + * NOTE that it aims to consolidate use of different USB-related APIs + * such as libusb-0.1 and libusb-1.0 in a way that minimizes the coding + * difference for majority of NUT - so typedef'ing or converting various + * data types and method signatures. + * + * Beside your system headers (content varies between distros) you can + * find some documentation online: + * - libusb-1.0: + * https://github.com/libusb/libusb/blob/master/libusb/libusb.h + * https://libusb.sourceforge.io/api-1.0/ + * https://libusb.sourceforge.io/api-1.0/libusb_api.html + * https://github.com/libusb/libusb/wiki + * https://nxmnpg.lemoda.net/3/libusb (one page, easy to search) + * - libusb-0.1 is nowadays hard to find, original web-site and + * sourceforge project were discontinued over the past years. + * A rendered copy of the libusb-0.1 Developers Guide was noted at: + * http://transit.iut2.upmf-grenoble.fr/doc/libusb-dev/html/index.html + * http://transit.iut2.upmf-grenoble.fr/doc/libusb-dev/html/functions.html + * Original SGML for that seems to be in source tarball such as + * http://deb.debian.org/debian/pool/main/libu/libusb/libusb_0.1.12.orig.tar.gz + * + * Related (but currently not directly used) projects include: + * - libusb-win32 port based on libusb-0.1 API (bug-fix-only mode, + * new projects should use libusb Windows backend): + * https://sourceforge.net/p/libusb-win32/wiki/Documentation/ + * - (Currently not in NUT codebase scope, but might help...) + * > A compatibility layer allowing applications written for + * > libusb-0.1 to work with libusb-1.0. libusb-compat-0.1 + * > attempts to look, feel, smell and walk like libusb-0.1. + * Mostly. Details (and known differences) documented at: + * https://github.com/libusb/libusb-compat-0.1 + * + * Also note that at least currently this does not deal with non-libusb + * APIs (important when looking for method signatures in documentation, + * since e.g. Linux Kernel USB subsystem uses some of libusb-0.1 method + * names, but with different set, type and order of arguments!) - Copyright (C) 2008 Arnaud Quette + Copyright (C) 2008 - 2016 Arnaud Quette + Copyright (C) 2021 Jim Klimov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,10 +57,386 @@ #ifndef NUT_USB_COMMON_H #define NUT_USB_COMMON_H -#include "nut_stdint.h" /* for uint16_t */ +#include "config.h" /* be sure to know all about the system config */ + +/* Note: usb-common.h (this file) is included by nut_libusb.h, + * so not looping the includes ;) + */ +#include "nut_stdint.h" /* for uint16_t, UINT16_MAX, PRIsize, etc. */ +#include "common.h" /* for fatalx() etc. */ + +#if defined HAVE_LIMITS_H +# include /* PATH_MAX for usb.h, among other stuff */ +#endif + +#if defined HAVE_SYS_PARAM_H +# include +#endif #include -#include + +#if (!WITH_LIBUSB_1_0) && (!WITH_LIBUSB_0_1) +#error "configure script error: Neither WITH_LIBUSB_1_0 nor WITH_LIBUSB_0_1 is set" +#endif + +#if (WITH_LIBUSB_1_0) && (WITH_LIBUSB_0_1) +#error "configure script error: Both WITH_LIBUSB_1_0 and WITH_LIBUSB_0_1 are set" +#endif + +/* Select version-specific libusb header file and define a sort of + * "Compatibility layer" between libusb 0.1 and 1.0 + */ +#if WITH_LIBUSB_1_0 +# include + + /* Simply remap libusb functions/structures from 0.1 to 1.0 */ + + /* Structures */ + /* #define usb_dev_handle libusb_device_handle */ + typedef libusb_device_handle usb_dev_handle; +/* These typedefs are also named in libshut.h, so we can consistenly + * handle the "ifdef SHUT_MODE" handling in libhid.c and some drivers. + * These symbolic names are used in all the headers and are expected to + * match binary code of object files at (monolithic) driver build time. + * + * The MIN/MAX definitions here are primarily to generalize range-check + * code (especially if anything is done outside the libraries). + * FIXME: It may make sense to constrain the limits to lowest common + * denominator that should fit alll of libusb-0.1, libusb-1.0 and libshut, + * so that any build of the practical (driver) code knows to not exceed + * any use-case. + */ + typedef uint8_t usb_ctrl_requesttype; + #define USB_CTRL_REQUESTTYPE_MIN 0 + #define USB_CTRL_REQUESTTYPE_MAX UINT8_MAX + + typedef uint8_t usb_ctrl_request; + #define USB_CTRL_REQUEST_MIN 0 + #define USB_CTRL_REQUEST_MAX UINT8_MAX + + typedef unsigned char usb_ctrl_endpoint; + #define USB_CTRL_ENDPOINT_MIN 0 + #define USB_CTRL_ENDPOINT_MAX UCHAR_MAX + + typedef uint16_t usb_ctrl_msgvalue; + #define USB_CTRL_MSGVALUE_MIN 0 + #define USB_CTRL_MSGVALUE_MAX UINT16_MAX + + typedef uint16_t usb_ctrl_repindex; + #define USB_CTRL_REPINDEX_MIN 0 + #define USB_CTRL_REPINDEX_MAX UINT16_MAX + + typedef uint8_t usb_ctrl_strindex; + #define USB_CTRL_STRINDEX_MIN 0 + #define USB_CTRL_STRINDEX_MAX UINT8_MAX + + typedef uint8_t usb_ctrl_descindex; + #define USB_CTRL_DESCINDEX_MIN 0 + #define USB_CTRL_DESCINDEX_MAX UINT8_MAX + + typedef unsigned char* usb_ctrl_charbuf; + typedef unsigned char usb_ctrl_char; + #define USB_CTRL_CHAR_MIN 0 + #define USB_CTRL_CHAR_MAX UCHAR_MAX + + /* Here MIN/MAX should not matter much, type mostly used for casting */ + typedef uint16_t usb_ctrl_charbufsize; + #define USB_CTRL_CHARBUFSIZE_MIN 0 + #define USB_CTRL_CHARBUFSIZE_MAX UINT16_MAX + #define PRI_NUT_USB_CTRL_CHARBUFSIZE PRIu16 + + typedef unsigned int usb_ctrl_timeout_msec; /* in milliseconds */ + /* Note: there does not seem to be a standard type + * for milliseconds, like there is an useconds_t */ + #define USB_CTRL_TIMEOUTMSEC_MIN 0 + #define USB_CTRL_TIMEOUTMSEC_MAX UINT_MAX + + /* defines */ + #define USB_CLASS_PER_INTERFACE LIBUSB_CLASS_PER_INTERFACE + #define USB_DT_STRING LIBUSB_DT_STRING + #define USB_ENDPOINT_IN LIBUSB_ENDPOINT_IN + #define USB_ENDPOINT_OUT LIBUSB_ENDPOINT_OUT + #define USB_RECIP_ENDPOINT LIBUSB_RECIPIENT_ENDPOINT + #define USB_RECIP_INTERFACE LIBUSB_RECIPIENT_INTERFACE + #define USB_REQ_SET_DESCRIPTOR LIBUSB_REQUEST_SET_DESCRIPTOR + #define USB_TYPE_CLASS LIBUSB_REQUEST_TYPE_CLASS + #define USB_TYPE_VENDOR LIBUSB_REQUEST_TYPE_VENDOR + + #define ERROR_ACCESS LIBUSB_ERROR_ACCESS + #define ERROR_BUSY LIBUSB_ERROR_BUSY + #define ERROR_IO LIBUSB_ERROR_IO + #define ERROR_NO_DEVICE LIBUSB_ERROR_NO_DEVICE + #define ERROR_NOT_FOUND LIBUSB_ERROR_NOT_FOUND + #define ERROR_OVERFLOW LIBUSB_ERROR_OVERFLOW + #define ERROR_PIPE LIBUSB_ERROR_PIPE + #define ERROR_TIMEOUT LIBUSB_ERROR_TIMEOUT + + /* Functions, including range-checks to convert data types of the two APIs. + * Follows an example from libusb-1.0 headers that liberally cast int args + * of one method to uint16_t to call another; at least we do so with checks: */ +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNUSED_FUNCTION) +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNUSED_FUNCTION +# pragma GCC diagnostic ignored "-Wunused-function" +#endif + /* #define usb_control_msg libusb_control_transfer */ + static inline int usb_control_msg(usb_dev_handle *dev, int requesttype, + int request, int value, int index, + usb_ctrl_charbuf bytes, int size, int timeout) + { + /* + Map from libusb-0.1 API => libusb-1.0 API: + int LIBUSB_CALL libusb_control_transfer( + libusb_device_handle *dev_handle, uint8_t request_type, + uint8_t bRequest, uint16_t wValue, uint16_t wIndex, + unsigned char *data, uint16_t wLength, unsigned int timeout); + Note: In libusb-0.1 bytes was a (char*) but our consumer code + was already fixed to use "usb_ctrl_charbuf" to match other methods. + */ + + if (requesttype < 0 || (uintmax_t)requesttype > UINT8_MAX + || request < 0 || (uintmax_t)request > UINT8_MAX + || value < 0 || (uintmax_t)value > UINT16_MAX + || index < 0 || (uintmax_t)index > UINT16_MAX + || size < 0 || (uintmax_t)size > UINT16_MAX + || timeout < 0 + ) { + fatalx(EXIT_FAILURE, + "usb_control_msg() args out of range for libusb_control_transfer() implementation"); + } + + return libusb_control_transfer( + dev, + (uint8_t)requesttype, + (uint8_t)request, + (uint16_t)value, + (uint16_t)index, + (unsigned char *)bytes, + (uint16_t)size, + (unsigned int) timeout + ); + } + + static inline int usb_interrupt_read(usb_dev_handle *dev, int ep, + usb_ctrl_charbuf bytes, int size, int timeout) + { + /* NOTE: Also for routines below: + Map from libusb-0.1 API => libusb-1.0 API plus change of logic per below code: + int LIBUSB_CALL libusb_interrupt_transfer(libusb_device_handle *dev_handle, + unsigned char endpoint, unsigned char *data, int length, + int *actual_length, unsigned int timeout); + Note: In libusb-0.1 bytes was a (char*) but our consumer code + was already fixed to use "usb_ctrl_charbuf" to match other methods. + */ + int ret; + + if (ep < 0 || (uintmax_t)ep > UCHAR_MAX + || timeout < 0 + ) { + fatalx(EXIT_FAILURE, + "usb_interrupt_read() args out of range for libusb_interrupt_transfer() implementation"); + } + + ret = libusb_interrupt_transfer(dev, (unsigned char)ep, (unsigned char *) bytes, + size, &size, (unsigned int)timeout); + /* In case of success, return the operation size, as done with libusb 0.1 */ + return (ret == LIBUSB_SUCCESS)?size:ret; + } + + static inline int usb_interrupt_write(usb_dev_handle *dev, int ep, + const usb_ctrl_charbuf bytes, int size, int timeout) + { + /* See conversion comments above */ + int ret; + + if (ep < 0 || (uintmax_t)ep > UCHAR_MAX + || timeout < 0 + ) { + fatalx(EXIT_FAILURE, + "usb_interrupt_write() args out of range for libusb_interrupt_transfer() implementation"); + } + + ret = libusb_interrupt_transfer(dev, (unsigned char)ep, (unsigned char *) bytes, + size, &size, (unsigned int)timeout); + /* In case of success, return the operation size, as done with libusb 0.1 */ + return (ret == LIBUSB_SUCCESS)?size:ret; + } + + static inline int usb_bulk_read(usb_dev_handle *dev, int ep, + usb_ctrl_charbuf bytes, int size, int timeout) + { + /* See conversion comments above */ + int ret; + + if (ep < 0 || (uintmax_t)ep > UCHAR_MAX + || timeout < 0 + ) { + fatalx(EXIT_FAILURE, + "usb_bulk_read() args out of range for libusb_interrupt_transfer() implementation"); + } + + ret = libusb_interrupt_transfer(dev, (unsigned char)ep, (unsigned char *) bytes, + size, &size, (unsigned int)timeout); + /* In case of success, return the operation size, as done with libusb 0.1 */ + return (ret == LIBUSB_SUCCESS)?size:ret; + } + + static inline int usb_bulk_write(usb_dev_handle *dev, int ep, + usb_ctrl_charbuf bytes, int size, int timeout) + { + /* See conversion comments above */ + int ret; + + if (ep < 0 || (uintmax_t)ep > UCHAR_MAX + || timeout < 0 + ) { + fatalx(EXIT_FAILURE, + "usb_bulk_write() args out of range for libusb_interrupt_transfer() implementation"); + } + + ret = libusb_interrupt_transfer(dev, (unsigned char)ep, (unsigned char *) bytes, + size, &size, (unsigned int)timeout); + /* In case of success, return the operation size, as done with libusb 0.1 */ + return (ret == LIBUSB_SUCCESS)?size:ret; + } + + static inline int usb_get_string(usb_dev_handle *dev, int index, int langid, + usb_ctrl_charbuf buf, size_t buflen) + { + /* + Map from libusb-0.1 API (originally "char* buf") => libusb-1.0 API: + int libusb_get_string_descriptor(libusb_device_handle *dev_handle, + uint8_t desc_index, uint16_t langid, unsigned char *data, int length) + */ + + if (index < 0 || (uintmax_t)index > UINT8_MAX + || langid < 0 || (uintmax_t)langid > UINT16_MAX + || (uintmax_t)buflen > INT_MAX + ) { + fatalx(EXIT_FAILURE, + "usb_get_string() args out of range for libusb_get_string_descriptor() implementation"); + } + + return libusb_get_string_descriptor( + dev, + (uint8_t)index, + (uint16_t)langid, + (unsigned char *)buf, + (int) buflen + ); + + } + + static inline int usb_get_string_simple(usb_dev_handle *dev, int index, + usb_ctrl_charbuf buf, size_t buflen) + { + /* + Map from libusb-0.1 API (originally "char* buf") => libusb-1.0 API: + int LIBUSB_CALL libusb_get_string_descriptor_ascii(libusb_device_handle *dev_handle, + uint8_t desc_index, unsigned char *data, int length); + */ + + if (index < 0 || (uintmax_t)index > UINT8_MAX + || (uintmax_t)buflen > INT_MAX + ) { + fatalx(EXIT_FAILURE, + "usb_get_string_simple() args out of range for libusb_get_string_descriptor_ascii() implementation"); + } + + return libusb_get_string_descriptor_ascii( + dev, + (uint8_t)index, + (unsigned char *)buf, + (int) buflen + ); + } +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNUSED_FUNCTION) +# pragma GCC diagnostic pop +#endif + + /* Functions for which simple mappings seem to suffice (no build warnings emitted): */ + #define usb_claim_interface libusb_claim_interface + #define usb_clear_halt libusb_clear_halt + #define usb_close libusb_close + #define usb_set_configuration libusb_set_configuration + #define usb_release_interface libusb_release_interface + #define usb_reset libusb_reset_device + + /* FIXME: some original libusb1.c code cast the (int) argument + * as (enum libusb_error) - should we force that in the macro? */ + #define nut_usb_strerror(a) libusb_strerror(a) +#endif /* WITH_LIBUSB_1_0 */ + +/* Note: Checked above that in practice we handle some one libusb API */ +#if WITH_LIBUSB_0_1 +# include + /* Structures */ + /* See detailed comments above, in libusb-1.0 definitions + * FIXME: It may make sense to constrain the limits to lowest common + * denominator that should fit alll of libusb-0.1, libusb-1.0 and libshut, + * so that any build of the practical (driver) code knows to not exceed + * any use-case. + */ + /* no typedef for usb_dev_handle - part of libusb-0.1 API names */ + + typedef int usb_ctrl_requesttype; + #define USB_CTRL_REQUESTTYPE_MIN INT_MIN + #define USB_CTRL_REQUESTTYPE_MAX INT_MAX + + typedef int usb_ctrl_request; + #define USB_CTRL_REQUEST_MIN INT_MIN + #define USB_CTRL_REQUEST_MAX INT_MAX + + typedef int usb_ctrl_endpoint; + #define USB_CTRL_ENDPOINT_MIN INT_MIN + #define USB_CTRL_ENDPOINT_MAX INT_MAX + + typedef int usb_ctrl_msgvalue; + #define USB_CTRL_MSGVALUE_MIN INT_MIN + #define USB_CTRL_MSGVALUE_MAX INT_MAX + + typedef int usb_ctrl_repindex; + #define USB_CTRL_REPINDEX_MIN INT_MIN + #define USB_CTRL_REPINDEX_MAX INT_MAX + + typedef int usb_ctrl_strindex; + #define USB_CTRL_STRINDEX_MIN INT_MIN + #define USB_CTRL_STRINDEX_MAX INT_MAX + + typedef int usb_ctrl_descindex; + #define USB_CTRL_DESCINDEX_MIN INT_MIN + #define USB_CTRL_DESCINDEX_MAX INT_MAX + + /* Here MIN/MAX should not matter much, type mostly used for casting */ + typedef char* usb_ctrl_charbuf; + typedef char usb_ctrl_char; + #define USB_CTRL_CHAR_MIN CHAR_MIN + #define USB_CTRL_CHAR_MAX CHAR_MAX + + typedef int usb_ctrl_charbufsize; + #define USB_CTRL_CHARBUFSIZE_MIN INT_MIN + #define USB_CTRL_CHARBUFSIZE_MAX INT_MAX + /* There is no PRIi :) So we define directly by spec */ + #define PRI_NUT_USB_CTRL_CHARBUFSIZE "i" + + typedef int usb_ctrl_timeout_msec; /* in milliseconds */ + #define USB_CTRL_TIMEOUTMSEC_MIN INT_MIN + #define USB_CTRL_TIMEOUTMSEC_MAX INT_MAX + + /* defines */ + #define ERROR_ACCESS -EACCES + #define ERROR_BUSY -EBUSY + #define ERROR_IO -EIO + #define ERROR_NO_DEVICE -ENODEV + #define ERROR_NOT_FOUND -ENOENT + #define ERROR_OVERFLOW -EOVERFLOW + #define ERROR_PIPE -EPIPE + #define ERROR_TIMEOUT -ETIMEDOUT + + /* Functions for which simple mappings seem to suffice (no build warnings emitted): */ + #define nut_usb_strerror(a) usb_strerror() +#endif /* WITH_LIBUSB_0_1 */ /* USB standard timeout [ms] */ #define USB_TIMEOUT 5000 @@ -38,13 +451,17 @@ * corresponding string did not exist or could not be retrieved. */ typedef struct USBDevice_s { + /* These 5 data points are common properties of an USB device: */ uint16_t VendorID; /*!< Device's Vendor ID */ uint16_t ProductID; /*!< Device's Product ID */ char *Vendor; /*!< Device's Vendor Name */ char *Product; /*!< Device's Product Name */ char *Serial; /*!< Product serial number */ + /* These data points can be determined by the driver for some devices + or by libusb to detail its connection topology: */ char *Bus; /*!< Bus name, e.g. "003" */ uint16_t bcdDevice; /*!< Device release number */ + char *Device; /*!< Device name on the bus, e.g. "001" */ } USBDevice_t; /*! @@ -79,8 +496,8 @@ void USBFreeRegexMatcher(USBDeviceMatcher_t *matcher); #define USB_DEVICE(vendorID, productID) vendorID, productID typedef struct { - int vendorID; - int productID; + uint16_t vendorID; + uint16_t productID; void *(*fun)(USBDevice_t *); /* handler for specific processing */ } usb_device_id_t; @@ -91,9 +508,14 @@ typedef struct { /* Function used to match a VendorID/ProductID pair against a list of * supported devices. Return values: * NOT_SUPPORTED (0), POSSIBLY_SUPPORTED (1) or SUPPORTED (2) */ -int is_usb_device_supported(usb_device_id_t *usb_device_id_list, +int is_usb_device_supported(usb_device_id_t *usb_device_id_list, USBDevice_t *device); void nut_usb_addvars(void); +/* Tell the users that port="auto" should be used for USB, + * and other values are quietly ignored. Implemented once + * here, to use in several USB-capable drivers. */ +void warn_if_bad_usb_port_filename(const char *fn); + #endif /* NUT_USB_COMMON_H */ diff --git a/drivers/usbhid-ups.c b/drivers/usbhid-ups.c index 1e87de4..dfe65a3 100644 --- a/drivers/usbhid-ups.c +++ b/drivers/usbhid-ups.c @@ -1,10 +1,11 @@ /* usbhid-ups.c - Driver for USB and serial (MGE SHUT) HID UPS units * * Copyright (C) - * 2003-2012 Arnaud Quette + * 2003-2022 Arnaud Quette * 2005 John Stamp * 2005-2006 Peter Selinger * 2007-2009 Arjen de Korte + * 2016 Eaton / Arnaud Quette * * This program was sponsored by MGE UPS SYSTEMS, and now Eaton * @@ -27,7 +28,7 @@ */ #define DRIVER_NAME "Generic HID driver" -#define DRIVER_VERSION "0.41" +#define DRIVER_VERSION "0.47" #include "main.h" #include "libhid.h" @@ -39,18 +40,25 @@ #include "mge-hid.h" #ifndef SHUT_MODE + /* explore stub goes first, others alphabetically */ #include "explore-hid.h" #include "apc-hid.h" + #include "arduino-hid.h" #include "belkin-hid.h" #include "cps-hid.h" - #include "liebert-hid.h" - #include "powercom-hid.h" - #include "tripplite-hid.h" + #include "delta_ups-hid.h" + #include "ever-hid.h" #include "idowell-hid.h" + #include "legrand-hid.h" + #include "liebert-hid.h" #include "openups-hid.h" + #include "powercom-hid.h" + #include "powervar-hid.h" + #include "salicru-hid.h" + #include "tripplite-hid.h" #endif -/* master list of avaiable subdrivers */ +/* Reference list of avaiable subdrivers */ static subdriver_t *subdriver_list[] = { #ifndef SHUT_MODE &explore_subdriver, @@ -58,13 +66,19 @@ static subdriver_t *subdriver_list[] = { &mge_subdriver, #ifndef SHUT_MODE &apc_subdriver, + &arduino_subdriver, &belkin_subdriver, &cps_subdriver, - &liebert_subdriver, - &powercom_subdriver, - &tripplite_subdriver, + &delta_ups_subdriver, + &ever_subdriver, &idowell_subdriver, + &legrand_subdriver, + &liebert_subdriver, &openups_subdriver, + &powercom_subdriver, + &powervar_subdriver, + &salicru_subdriver, + &tripplite_subdriver, #endif NULL }; @@ -92,19 +106,40 @@ typedef enum { HU_WALKMODE_FULL_UPDATE } walkmode_t; +/* Compatibility layer between libusb 0.1 and 1.0, for errno/return codes */ +#if WITH_LIBUSB_0_1 || (defined SHUT_MODE) + #define ERROR_BUSY -EBUSY + #define ERROR_NO_DEVICE -ENODEV + #define ERROR_ACCESS -EACCES + #define ERROR_IO -EIO + #define ERROR_NOT_FOUND -ENOENT + #define ERROR_TIMEOUT -ETIMEDOUT + #define ERROR_OVERFLOW -EOVERFLOW + #define ERROR_PIPE -EPIPE +#else /* for libusb 1.0 */ + #define ERROR_BUSY LIBUSB_ERROR_BUSY + #define ERROR_NO_DEVICE LIBUSB_ERROR_NO_DEVICE + #define ERROR_ACCESS LIBUSB_ERROR_ACCESS + #define ERROR_IO LIBUSB_ERROR_IO + #define ERROR_NOT_FOUND LIBUSB_ERROR_NOT_FOUND + #define ERROR_TIMEOUT LIBUSB_ERROR_TIMEOUT + #define ERROR_OVERFLOW LIBUSB_ERROR_OVERFLOW + #define ERROR_PIPE LIBUSB_ERROR_PIPE +#endif + /* pointer to the active subdriver object (changed in callback() function) */ static subdriver_t *subdriver = NULL; /* Global vars */ static HIDDevice_t *hd = NULL; -static HIDDevice_t curDevice = { 0x0000, 0x0000, NULL, NULL, NULL, NULL }; +static HIDDevice_t curDevice = { 0x0000, 0x0000, NULL, NULL, NULL, NULL, 0, NULL }; static HIDDeviceMatcher_t *subdriver_matcher = NULL; #ifndef SHUT_MODE static HIDDeviceMatcher_t *exact_matcher = NULL; static HIDDeviceMatcher_t *regex_matcher = NULL; #endif static int pollfreq = DEFAULT_POLLFREQ; -static int ups_status = 0; +static unsigned ups_status = 0; static bool_t data_has_changed = FALSE; /* for SEMI_STATIC data polling */ #ifndef SUN_LIBUSB bool_t use_interrupt_pipe = TRUE; @@ -112,7 +147,14 @@ bool_t use_interrupt_pipe = TRUE; bool_t use_interrupt_pipe = FALSE; #endif static time_t lastpoll; /* Timestamp the last polling */ -hid_dev_handle_t udev; +hid_dev_handle_t udev = HID_DEV_HANDLE_CLOSED; + +/** + * CyberPower UT series sometime need a bit of help deciding their online status. + * This quirk is to enable the special handling of OL & DISCHRG at the same time + * as being OB (on battery power/no mains power). Enabled by device config flag. + */ +static int onlinedischarge = 0; /* support functions */ static hid_info_t *find_nut_info(const char *varname); @@ -125,7 +167,8 @@ static void ups_status_set(void); static bool_t hid_ups_walk(walkmode_t mode); static int reconnect_ups(void); static int ups_infoval_set(hid_info_t *item, double value); -static int callback(hid_dev_handle_t udev, HIDDevice_t *hd, unsigned char *rdbuf, int rdlen); +static int callback(hid_dev_handle_t argudev, HIDDevice_t *arghd, + usb_ctrl_charbuf rdbuf, usb_ctrl_charbufsize rdlen); #ifdef DEBUG static double interval(void); #endif @@ -134,40 +177,6 @@ static double interval(void); HIDDesc_t *pDesc = NULL; /* parsed Report Descriptor */ reportbuf_t *reportbuf = NULL; /* buffer for most recent reports */ -/* ---------------------------------------------------------------------- */ -/* data for processing boolean values from UPS */ - -#define STATUS(x) ((unsigned)1<> 9); /* negative value represents pre-1980 date */ + /* TOTHINK: About the comment below... + * Does bit-shift keep the negativeness on all architectures? + */ + /* negative value represents pre-1980 date: */ + year = 1980 + ((long)value >> 9); month = ((long)value >> 5) & 0x0f; day = (long)value & 0x1f; - snprintf(buf, sizeof(buf), "%04d/%02d/%02d", year, month, day); + snprintf(buf, sizeof(buf), "%04ld/%02ld/%02ld", year, month, day); return buf; } +static double date_conversion_reverse(const char* date_string) +{ + long year, month, day; + long date; + + sscanf(date_string, "%04ld/%02ld/%02ld", &year, &month, &day); + if(year - 1980 > 127 || month > 12 || day > 31) + return 0; + date = (year - 1980) << 9; + date += month << 5; + date += day; + + return (double) date; +} + info_lkp_t date_conversion[] = { - { 0, NULL, date_conversion_fun } + { 0, NULL, date_conversion_fun, date_conversion_reverse } }; /* returns statically allocated string - must not use it again before @@ -445,8 +473,9 @@ static const char *hex_conversion_fun(double value) return buf; } +/* FIXME? Do we need an inverse "nuf()" here? */ info_lkp_t hex_conversion[] = { - { 0, NULL, hex_conversion_fun } + { 0, NULL, hex_conversion_fun, NULL } }; /* returns statically allocated string - must not use it again before @@ -458,8 +487,9 @@ static const char *stringid_conversion_fun(double value) return HIDGetIndexString(udev, (int)value, buf, sizeof(buf)); } +/* FIXME? Do we need an inverse "nuf()" here? */ info_lkp_t stringid_conversion[] = { - { 0, NULL, stringid_conversion_fun } + { 0, NULL, stringid_conversion_fun, NULL } }; /* returns statically allocated string - must not use it again before @@ -473,8 +503,9 @@ static const char *divide_by_10_conversion_fun(double value) return buf; } +/* FIXME? Do we need an inverse "nuf()" here? */ info_lkp_t divide_by_10_conversion[] = { - { 0, NULL, divide_by_10_conversion_fun } + { 0, NULL, divide_by_10_conversion_fun, NULL } }; /* returns statically allocated string - must not use it again before @@ -498,8 +529,9 @@ static const char *kelvin_celsius_conversion_fun(double value) return buf; } +/* FIXME? Do we need an inverse "nuf()" here? */ info_lkp_t kelvin_celsius_conversion[] = { - { 0, NULL, kelvin_celsius_conversion_fun } + { 0, NULL, kelvin_celsius_conversion_fun, NULL } }; /*! @@ -510,12 +542,19 @@ info_lkp_t kelvin_celsius_conversion[] = { #ifndef SHUT_MODE static int match_function_subdriver(HIDDevice_t *d, void *privdata) { int i; + NUT_UNUSED_VARIABLE(privdata); + + upsdebugx(2, "%s (non-SHUT mode): matching a device...", __func__); for (i=0; subdriver_list[i] != NULL; i++) { if (subdriver_list[i]->claim(d)) { return 1; } } + + upsdebugx(2, "%s (non-SHUT mode): failed to match a subdriver " + "to vendor and/or product ID", + __func__); return 0; } @@ -539,24 +578,31 @@ int instcmd(const char *cmdname, const char *extradata) if (!strcasecmp(cmdname, "beeper.off")) { /* compatibility mode for old command */ upslogx(LOG_WARNING, - "The 'beeper.off' command has been renamed to 'beeper.disable'"); + "The 'beeper.off' command has been " + "renamed to 'beeper.disable'"); return instcmd("beeper.disable", NULL); } if (!strcasecmp(cmdname, "beeper.on")) { /* compatibility mode for old command */ upslogx(LOG_WARNING, - "The 'beeper.on' command has been renamed to 'beeper.enable'"); + "The 'beeper.on' command has been " + "renamed to 'beeper.enable'"); return instcmd("beeper.enable", NULL); } - upsdebugx(1, "instcmd(%s, %s)", cmdname, extradata ? extradata : "[NULL]"); + upsdebugx(1, "instcmd(%s, %s)", + cmdname, + extradata ? extradata : "[NULL]"); /* Retrieve and check netvar & item_path */ hidups_item = find_nut_info(cmdname); /* Check for fallback if not found */ if (hidups_item == NULL) { + upsdebugx(3, "%s: cmdname '%s' not found; " + "checking for alternatives", + __func__, cmdname); if (!strcasecmp(cmdname, "load.on")) { return instcmd("load.on.delay", "0"); @@ -569,7 +615,8 @@ int instcmd(const char *cmdname, const char *extradata) if (!strcasecmp(cmdname, "shutdown.return")) { int ret; - /* Ensure "ups.start.auto" is set to "yes", if supported */ + /* Ensure "ups.start.auto" is set to "yes", + * if supported */ if (dstate_getinfo("ups.start.auto")) { setvar("ups.start.auto", "yes"); } @@ -579,6 +626,11 @@ int instcmd(const char *cmdname, const char *extradata) return ret; } + /* Some UPS's (e.g. TrippLive AVR750U w/ 3024 protocol) don't accept + * commands that arrive too rapidly, so add this arbitary wait, + * which has proven to be long enough to avoid this problem in practice */ + usleep(125000); + return instcmd("load.off.delay", dstate_getinfo("ups.delay.shutdown")); } @@ -595,6 +647,11 @@ int instcmd(const char *cmdname, const char *extradata) return ret; } + /* Some UPS's (e.g. TrippLive AVR750U w/ 3024 protocol) don't accept + * commands that arrive too rapidly, so add this arbitary wait, + * which has proven to be long enough to avoid this problem in practice */ + usleep(125000); + return instcmd("load.off.delay", dstate_getinfo("ups.delay.shutdown")); } @@ -602,6 +659,11 @@ int instcmd(const char *cmdname, const char *extradata) return STAT_INSTCMD_INVALID; } + upsdebugx(3, "%s: using Path '%s'", + __func__, + (hidups_item->hidpath ? hidups_item->hidpath : "[NULL]") + ); + /* Check if the item is an instant command */ if (!(hidups_item->hidflags & HU_TYPE_CMD)) { upsdebugx(2, "instcmd: %s is not an instant command\n", cmdname); @@ -620,7 +682,7 @@ int instcmd(const char *cmdname, const char *extradata) /* Actual variable setting */ if (HIDSetDataValue(udev, hidups_item->hiddata, value) == 1) { - upsdebugx(5, "instcmd: SUCCEED\n"); + upsdebugx(3, "instcmd: SUCCEED\n"); /* Set the status so that SEMI_STATIC vars are polled */ data_has_changed = TRUE; return STAT_INSTCMD_HANDLED; @@ -720,31 +782,46 @@ void upsdrv_makevartable(void) upsdebugx(1, "upsdrv_makevartable..."); - snprintf(temp, sizeof(temp), "Set low battery level, in %% (default=%s).", DEFAULT_LOWBATT); + snprintf(temp, sizeof(temp), + "Set low battery level, in %% (default=%s)", + DEFAULT_LOWBATT); addvar (VAR_VALUE, HU_VAR_LOWBATT, temp); - snprintf(temp, sizeof(temp), "Set shutdown delay, in seconds (default=%s)", DEFAULT_OFFDELAY); + snprintf(temp, sizeof(temp), + "Set shutdown delay, in seconds (default=%s)", + DEFAULT_OFFDELAY); addvar(VAR_VALUE, HU_VAR_OFFDELAY, temp); - snprintf(temp, sizeof(temp), "Set startup delay, in seconds (default=%s)", DEFAULT_ONDELAY); + snprintf(temp, sizeof(temp), + "Set startup delay, in seconds (default=%s)", + DEFAULT_ONDELAY); addvar(VAR_VALUE, HU_VAR_ONDELAY, temp); - snprintf(temp, sizeof(temp), "Set polling frequency, in seconds, to reduce data flow (default=%d)", + snprintf(temp, sizeof(temp), + "Set polling frequency, in seconds, to reduce data flow (default=%d)", DEFAULT_POLLFREQ); addvar(VAR_VALUE, HU_VAR_POLLFREQ, temp); addvar(VAR_FLAG, "pollonly", "Don't use interrupt pipe, only use polling"); + addvar(VAR_FLAG, "onlinedischarge", + "Set to treat discharging while online as being offline"); + #ifndef SHUT_MODE /* allow -x vendor=X, vendorid=X, product=X, productid=X, serial=X */ nut_usb_addvars(); - addvar(VAR_FLAG, "explore", "Diagnostic matching of unsupported UPS"); - addvar(VAR_FLAG, "maxreport", "Activate tweak for buggy APC Back-UPS firmware"); - addvar(VAR_FLAG, "interruptonly", "Don't use polling, only use interrupt pipe"); - addvar(VAR_VALUE, "interruptsize", "Number of bytes to read from interrupt pipe"); + addvar(VAR_FLAG, "explore", + "Diagnostic matching of unsupported UPS"); + addvar(VAR_FLAG, "maxreport", + "Activate tweak for buggy APC Back-UPS firmware"); + addvar(VAR_FLAG, "interruptonly", + "Don't use polling, only use interrupt pipe"); + addvar(VAR_VALUE, "interruptsize", + "Number of bytes to read from interrupt pipe"); #else - addvar(VAR_VALUE, "notification", "Set notification type, (ignored, only for backward compatibility)"); + addvar(VAR_VALUE, "notification", + "Set notification type, (ignored, only for backward compatibility)"); #endif } @@ -765,7 +842,7 @@ void upsdrv_updateinfo(void) /* check for device availability to set datastale! */ if (hd == NULL) { /* don't flood reconnection attempts */ - if (now < (int)(lastpoll + poll_interval)) { + if (now < (lastpoll + poll_interval)) { return; } @@ -792,14 +869,20 @@ void upsdrv_updateinfo(void) evtCount = HIDGetEvents(udev, event, MAX_EVENT_NUM); switch (evtCount) { - case -EBUSY: /* Device or resource busy */ + case ERROR_BUSY: /* Device or resource busy */ upslog_with_errno(LOG_CRIT, "Got disconnected by another driver"); + goto fallthrough_reconnect; +#if WITH_LIBUSB_0_1 /* limit to libusb 0.1 implementation */ case -EPERM: /* Operation not permitted */ - case -ENODEV: /* No such device */ - case -EACCES: /* Permission denied */ - case -EIO: /* I/O error */ +#endif + case ERROR_NO_DEVICE: /* No such device */ + case ERROR_ACCESS: /* Permission denied */ + case ERROR_IO: /* I/O error */ +#if WITH_LIBUSB_0_1 /* limit to libusb 0.1 implementation */ case -ENXIO: /* No such device or address */ - case -ENOENT: /* No such file or directory */ +#endif + case ERROR_NOT_FOUND: /* No such file or directory */ + fallthrough_reconnect: /* Uh oh, got to reconnect! */ hd = NULL; return; @@ -819,7 +902,9 @@ void upsdrv_updateinfo(void) continue; if (nut_debug_level >= 2) { - upsdebugx(2, "Path: %s, Type: %s, ReportID: 0x%02x, Offset: %i, Size: %i, Value: %g", + upsdebugx(2, + "Path: %s, Type: %s, ReportID: 0x%02x, " + "Offset: %i, Size: %i, Value: %g", HIDGetDataItem(event[i], subdriver->utab), HIDDataType(event[i]), event[i]->ReportID, event[i]->Offset, event[i]->Size, value); @@ -827,7 +912,7 @@ void upsdrv_updateinfo(void) /* Skip Input reports, if we don't use the Feature report */ found_data = FindObject_with_Path(pDesc, &(event[i]->Path), interrupt_only ? ITEM_INPUT:ITEM_FEATURE); - if(!found_data && !interrupt_only) { + if(!found_data && !interrupt_only) { found_data = FindObject_with_Path(pDesc, &(event[i]->Path), ITEM_INPUT); } if(!found_data) { @@ -843,12 +928,14 @@ void upsdrv_updateinfo(void) ups_infoval_set(item, value); } #ifdef DEBUG - upsdebugx(1, "took %.3f seconds handling interrupt reports...\n", interval()); + upsdebugx(1, "took %.3f seconds handling interrupt reports...\n", + interval()); #endif /* clear status buffer before begining */ status_init(); - /* Do a full update (polling) every pollfreq or upon data change (ie setvar/instcmd) */ + /* Do a full update (polling) every pollfreq + * or upon data change (ie setvar/instcmd) */ if ((now > (lastpoll + pollfreq)) || (data_has_changed == TRUE)) { upsdebugx(1, "Full update..."); @@ -875,7 +962,8 @@ void upsdrv_updateinfo(void) dstate_dataok(); #ifdef DEBUG - upsdebugx(1, "took %.3f seconds handling feature reports...\n", interval()); + upsdebugx(1, "took %.3f seconds handling feature reports...\n", + interval()); #endif } @@ -911,18 +999,25 @@ void upsdrv_initups(void) { int ret; char *val; + + upsdebugx(2, "Initializing an USB-connected UPS with library %s " \ + "(NUT subdriver name='%s' ver='%s')", + dstate_getinfo("driver.version.usb"), + comm_driver->name, comm_driver->version ); + #ifdef SHUT_MODE /*! * SHUT is a serial protocol, so it needs * only the device path */ - upsdebugx(1, "upsdrv_initups..."); + upsdebugx(1, "upsdrv_initups (SHUT)..."); subdriver_matcher = device_path; #else - char *regex_array[6]; + char *regex_array[7]; - upsdebugx(1, "upsdrv_initups..."); + upsdebugx(1, "upsdrv_initups (non-SHUT)..."); + warn_if_bad_usb_port_filename(device_path); subdriver_matcher = &subdriver_matcher_struct; @@ -943,6 +1038,7 @@ void upsdrv_initups(void) regex_array[3] = getval("product"); regex_array[4] = getval("serial"); regex_array[5] = getval("bus"); + regex_array[6] = getval("device"); ret = USBNewRegexMatcher(®ex_matcher, regex_array, REG_ICASE | REG_EXTENDED); switch(ret) @@ -951,8 +1047,18 @@ void upsdrv_initups(void) break; case -1: fatal_with_errno(EXIT_FAILURE, "HIDNewRegexMatcher()"); +#ifndef HAVE___ATTRIBUTE__NORETURN + exit(EXIT_FAILURE); + /* Should not get here in practice, but + * compiler is afraid we can fall through */ +#endif default: fatalx(EXIT_FAILURE, "invalid regular expression: %s", regex_array[ret]); +#ifndef HAVE___ATTRIBUTE__NORETURN + exit(EXIT_FAILURE); + /* Should not get here in practice, but + * compiler is afraid we can fall through */ +#endif } /* link the matchers */ @@ -967,16 +1073,28 @@ void upsdrv_initups(void) hd = &curDevice; - upsdebugx(1, "Detected a UPS: %s/%s", hd->Vendor ? hd->Vendor : "unknown", + upsdebugx(1, "Detected a UPS: %s/%s", + hd->Vendor ? hd->Vendor : "unknown", hd->Product ? hd->Product : "unknown"); /* Activate Powercom tweaks */ if (testvar("interruptonly")) { interrupt_only = 1; } + + /* Activate Cyberpower tweaks */ + if (testvar("onlinedischarge")) { + onlinedischarge = 1; + } + val = getval("interruptsize"); if (val) { - interrupt_size = atoi(val); + int ipv = atoi(val); + if (ipv > 0) { + interrupt_size = (unsigned int)ipv; + } else { + fatalx(EXIT_FAILURE, "Error: invalid interruptsize: %d", ipv); + } } if (hid_ups_walk(HU_WALKMODE_INIT) == FALSE) { @@ -1039,6 +1157,7 @@ void upsdrv_cleanup(void) free(curDevice.Product); free(curDevice.Serial); free(curDevice.Bus); + free(curDevice.Device); #endif } @@ -1046,7 +1165,7 @@ void upsdrv_cleanup(void) * Support functions *********************************************************************/ -void possibly_supported(const char *mfr, HIDDevice_t *hd) +void possibly_supported(const char *mfr, HIDDevice_t *arghd) { upsdebugx(0, "This %s device (%04x:%04x) is not (or perhaps not yet) supported\n" @@ -1054,7 +1173,7 @@ void possibly_supported(const char *mfr, HIDDevice_t *hd) "this does not fix the problem, try running the driver with the\n" "'-x productid=%04x' option. Please report your results to the NUT user's\n" "mailing list .\n", - mfr, hd->VendorID, hd->ProductID, hd->ProductID); + mfr, arghd->VendorID, arghd->ProductID, arghd->ProductID); } /* Update ups_status to remember this status item. Interpretation is @@ -1088,15 +1207,41 @@ static void process_boolean_info(const char *nutvalue) upsdebugx(5, "Warning: %s not in list of known values", nutvalue); } -static int callback(hid_dev_handle_t udev, HIDDevice_t *hd, unsigned char *rdbuf, int rdlen) +static int callback( + hid_dev_handle_t argudev, + HIDDevice_t *arghd, + usb_ctrl_charbuf rdbuf, + usb_ctrl_charbufsize rdlen) { int i; const char *mfr = NULL, *model = NULL, *serial = NULL; #ifndef SHUT_MODE int ret; #endif - upsdebugx(2, "Report Descriptor size = %d", rdlen); - upsdebug_hex(3, "Report Descriptor", rdbuf, rdlen); + upsdebugx(2, "Report Descriptor size = %" PRI_NUT_USB_CTRL_CHARBUFSIZE, rdlen); + +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_UNSIGNED_ZERO_COMPARE) ) +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE +# pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_UNSIGNED_ZERO_COMPARE +# pragma GCC diagnostic ignored "-Wtautological-unsigned-zero-compare" +#endif + if ((uintmax_t)rdlen < (uintmax_t)SIZE_MAX) { + upsdebug_hex(3, "Report Descriptor", rdbuf, (size_t)rdlen); + } +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_UNSIGNED_ZERO_COMPARE) ) +# pragma GCC diagnostic pop +#endif + + /* Save the global "hd" for this driver instance */ + hd = arghd; + udev = argudev; /* Parse Report Descriptor */ Free_ReportDesc(pDesc); @@ -1130,7 +1275,10 @@ static int callback(hid_dev_handle_t udev, HIDDevice_t *hd, unsigned char *rdbuf upslogx(2, "Using subdriver: %s", subdriver->name); - HIDDumpTree(udev, subdriver->utab); + if (subdriver->fix_report_desc(arghd, pDesc)) { + upsdebugx(2, "Report Descriptor Fixed"); + } + HIDDumpTree(udev, arghd, subdriver->utab); #ifndef SHUT_MODE /* create a new matcher for later matching */ @@ -1189,6 +1337,15 @@ static double interval(void) } #endif +/* default subdriver function which doesn't attempt to fix + * any issues in the parsed HID Report Descriptor */ +int fix_report_desc(HIDDevice_t *arg_pDev, HIDDesc_t *arg_pDesc) { + NUT_UNUSED_VARIABLE(arg_pDev); + NUT_UNUSED_VARIABLE(arg_pDesc); + + return 0; +} + /* walk ups variables and set elements of the info array. */ static bool_t hid_ups_walk(walkmode_t mode) { @@ -1196,7 +1353,14 @@ static bool_t hid_ups_walk(walkmode_t mode) double value; int retcode; - /* 3 modes: HU_WALKMODE_INIT, HU_WALKMODE_QUICK_UPDATE and HU_WALKMODE_FULL_UPDATE */ +#ifndef SHUT_MODE + /* extract the VendorId for further testing */ + int vendorID = curDevice.VendorID; + int productID = curDevice.ProductID; +#endif + + /* 3 modes: HU_WALKMODE_INIT, HU_WALKMODE_QUICK_UPDATE + * and HU_WALKMODE_FULL_UPDATE */ /* Device data walk ----------------------------- */ for (item = subdriver->hid2nut; item->info_type != NULL; item++) { @@ -1272,22 +1436,62 @@ static bool_t hid_ups_walk(walkmode_t mode) break; +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) ) +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT +# pragma GCC diagnostic ignored "-Wcovered-switch-default" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +# pragma GCC diagnostic ignored "-Wunreachable-code" +#endif +/* Older CLANG (e.g. clang-3.4) seems to not support the GCC pragmas above */ +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wcovered-switch-default" +# pragma clang diagnostic ignored "-Wunreachable-code" +#endif + /* All enum cases defined as of the time of coding + * have been covered above. Handle later definitions, + * memory corruptions and buggy inputs below... + */ default: fatalx(EXIT_FAILURE, "hid_ups_walk: unknown update mode!"); } +#ifdef __clang__ +# pragma clang diagnostic pop +#endif +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) ) +# pragma GCC diagnostic pop +#endif + +#ifndef SHUT_MODE + /* skip report 0x54 for Tripplite SU3000LCD2UHV due to firmware bug */ + if ((vendorID == 0x09ae) && (productID == 0x1330)) { + if (item->hiddata && (item->hiddata->ReportID == 0x54)) { + continue; + } + } +#endif retcode = HIDGetDataValue(udev, item->hiddata, &value, poll_interval); switch (retcode) { - case -EBUSY: /* Device or resource busy */ + case ERROR_BUSY: /* Device or resource busy */ upslog_with_errno(LOG_CRIT, "Got disconnected by another driver"); + goto fallthrough_reconnect; +#if WITH_LIBUSB_0_1 /* limit to libusb 0.1 implementation */ case -EPERM: /* Operation not permitted */ - case -ENODEV: /* No such device */ - case -EACCES: /* Permission denied */ - case -EIO: /* I/O error */ +#endif + case ERROR_NO_DEVICE: /* No such device */ + case ERROR_ACCESS: /* Permission denied */ + case ERROR_IO: /* I/O error */ +#if WITH_LIBUSB_0_1 /* limit to libusb 0.1 implementation */ case -ENXIO: /* No such device or address */ - case -ENOENT: /* No such file or directory */ +#endif + case ERROR_NOT_FOUND: /* No such file or directory */ + fallthrough_reconnect: /* Uh oh, got to reconnect! */ hd = NULL; return FALSE; @@ -1298,22 +1502,27 @@ static bool_t hid_ups_walk(walkmode_t mode) case 0: continue; - case -ETIMEDOUT: /* Connection timed out */ - case -EOVERFLOW: /* Value too large for defined data type */ -#ifdef EPROTO + case ERROR_TIMEOUT: /* Connection timed out */ + case ERROR_OVERFLOW: /* Value too large for defined data type */ +#if EPROTO && WITH_LIBUSB_0_1 case -EPROTO: /* Protocol error */ #endif - case -EPIPE: /* Broken pipe */ + case ERROR_PIPE: /* Broken pipe */ default: /* Don't know what happened, try again later... */ continue; } - upsdebugx(2, "Path: %s, Type: %s, ReportID: 0x%02x, Offset: %i, Size: %i, Value: %g", - item->hidpath, HIDDataType(item->hiddata), item->hiddata->ReportID, + upsdebugx(2, + "Path: %s, Type: %s, ReportID: 0x%02x, " + "Offset: %i, Size: %i, Value: %g", + item->hidpath, HIDDataType(item->hiddata), + item->hiddata->ReportID, item->hiddata->Offset, item->hiddata->Size, value); if (item->hidflags & HU_TYPE_CMD) { + upsdebugx(3, "Adding command '%s' using Path '%s'", + item->info_type, item->hidpath); dstate_addcmd(item->info_type); continue; } @@ -1360,6 +1569,10 @@ static int reconnect_ups(void) upsdebugx(4, "= device has been disconnected, try to reconnect ="); upsdebugx(4, "=================================================="); + /* Try to close the previous handle */ + if (udev) + comm_driver->close(udev); + ret = comm_driver->open(&udev, &curDevice, subdriver_matcher, NULL); if (ret > 0) { @@ -1411,6 +1624,12 @@ static void ups_alarm_set(void) } } +/* Return the current value of ups_status */ +unsigned ups_status_get(void) +{ + return ups_status; +} + /* Convert the local status information to NUT format and set NUT status. */ static void ups_status_set(void) @@ -1423,10 +1642,27 @@ static void ups_status_set(void) dstate_delinfo("input.transfer.reason"); } - if (ups_status & STATUS(ONLINE)) { - status_set("OL"); /* on line */ - } else { + + if (!(ups_status & STATUS(ONLINE))) { status_set("OB"); /* on battery */ + } else if ((ups_status & STATUS(DISCHRG))) { + /* if online */ + if (onlinedischarge) { + /* if we treat OL+DISCHRG as being offline */ + status_set("OB"); /* on battery */ + } else { + if (!(ups_status & STATUS(CAL))) { + /* if in OL+DISCHRG unknowingly, warn user */ + upslogx(LOG_WARNING, "%s: seems that UPS [%s] is in OL+DISCHRG state now. " + "Is it calibrating or do you perhaps want to set 'onlinedischarge' option? " + "Some UPS models (e.g. CyberPower UT series) emit OL+DISCHRG when offline.", + __func__, upsname); + } + /* if we're calibrating */ + status_set("OL"); /* on line */ + } + } else if ((ups_status & STATUS(ONLINE))) { + status_set("OL"); } if ((ups_status & STATUS(DISCHRG)) && !(ups_status & STATUS(DEPLETED))) { @@ -1523,12 +1759,16 @@ static long hu_find_valinfo(info_lkp_t *hid2info, const char* value) for (info_lkp = hid2info; info_lkp->nut_value != NULL; info_lkp++) { if (!(strcmp(info_lkp->nut_value, value))) { - upsdebugx(5, "hu_find_valinfo: found %s (value: %ld)", info_lkp->nut_value, info_lkp->hid_value); + upsdebugx(5, + "hu_find_valinfo: found %s (value: %ld)", + info_lkp->nut_value, info_lkp->hid_value); return info_lkp->hid_value; } } - upsdebugx(3, "hu_find_valinfo: no matching HID value for this INFO_* value (%s)", value); + upsdebugx(3, + "hu_find_valinfo: no matching HID value for this INFO_* value (%s)", + value); return -1; } @@ -1545,12 +1785,16 @@ static const char *hu_find_infoval(info_lkp_t *hid2info, const double value) /* use 'value' as an index for a lookup in an array */ for (info_lkp = hid2info; info_lkp->nut_value != NULL; info_lkp++) { if (info_lkp->hid_value == (long)value) { - upsdebugx(5, "hu_find_infoval: found %s (value: %ld)", info_lkp->nut_value, (long)value); + upsdebugx(5, + "hu_find_infoval: found %s (value: %ld)", + info_lkp->nut_value, (long)value); return info_lkp->nut_value; } } - upsdebugx(3, "hu_find_infoval: no matching INFO_* value for this HID value (%g)", value); + upsdebugx(3, + "hu_find_infoval: no matching INFO_* value for this HID value (%g)", + value); return NULL; } @@ -1581,7 +1825,19 @@ static int ups_infoval_set(hid_info_t *item, double value) dstate_setinfo(item->info_type, "%s", nutvalue); } else { +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif dstate_setinfo(item->info_type, item->dfl, value); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif } return 1; diff --git a/drivers/usbhid-ups.h b/drivers/usbhid-ups.h index 4f4b3c3..5cdf7e6 100644 --- a/drivers/usbhid-ups.h +++ b/drivers/usbhid-ups.h @@ -52,7 +52,9 @@ extern bool_t use_interrupt_pipe; /* Set to FALSE if interrupt reports should /* The driver will wait for Interrupt */ /* and do "light poll" in the meantime */ -#define MAX_STRING_SIZE 128 +#ifndef MAX_STRING_SIZE +#define MAX_STRING_SIZE 128 +#endif /* --------------------------------------------------------------- */ @@ -67,6 +69,9 @@ typedef struct { double (*nuf)(const char *nut_value); /* optional NUT to HID mapping */ } info_lkp_t; +/* accessor on the status */ +extern unsigned ups_status_get(void); + /* declarations of public lookup tables */ /* boolean status values from UPS */ extern info_lkp_t online_info[]; @@ -111,6 +116,40 @@ extern info_lkp_t stringid_conversion[]; extern info_lkp_t divide_by_10_conversion[]; extern info_lkp_t kelvin_celsius_conversion[]; +/* ---------------------------------------------------------------------- */ +/* data for processing boolean values from UPS */ + +#define STATUS(x) ((unsigned)1<%s<>%s<\n",temp,temp+3); + upsdebugx(1, "ups.model >%s<>%s<\n",temp,temp+3); } - + /* ups.mfr */ if (get_data("vDm?",temp)) return; dstate_setinfo("ups.mfr", "%s", temp+3); - upsdebugx(1, "ups.mfr >%s<>%s<\n",temp,temp+3); + upsdebugx(1, "ups.mfr >%s<>%s<\n",temp,temp+3); + - /* ups.serial */ if (exist_ups_serial) - { + { if (get_data("vDS?",temp)) return; dstate_setinfo("ups.serial", "%s", temp+3); - } - upsdebugx(1, "ups.serial >%s<>%s<\n",temp,temp+3); + } + upsdebugx(1, "ups.serial >%s<>%s<\n",temp,temp+3); - /* ups.firmware */ + /* ups.firmware */ if (get_data("vDV?",temp)) return; dstate_setinfo("ups.firmware", "%s", temp+3); - upsdebugx(1, "ups.firmware >%s<>%s<\n",temp,temp+3); + upsdebugx(1, "ups.firmware >%s<>%s<\n",temp,temp+3); /* ups.temperature */ if (exist_ups_temperature) - { + { if (get_data("vBT?",temp)) return; dstate_setinfo("ups.temperature", "%s", temp+3); - } - upsdebugx(1, "ups.temperature >%s<>%s<\n",temp,temp+3); + } + upsdebugx(1, "ups.temperature >%s<>%s<\n",temp,temp+3); /* ups.load */ if (get_data("vO0L?",temp)) return; dstate_setinfo("ups.load", "%s", temp+4); - upsdebugx(1, "ups.load >%s<>%s<\n",temp,temp+4); + upsdebugx(1, "ups.load >%s<>%s<\n",temp,temp+4); - /* ups protocol */ - /*if (get_data("vDC?",temp)) return; + /* ups protocol */ + /* + if (get_data("vDC?",temp)) return; dstate_setinfo("ups.protocol", "%s", temp+3; - upsdebugx(1, "ups.protocol >%s<>%s<\n",temp,temp+3; + upsdebugx(1, "ups.protocol >%s<>%s<\n",temp,temp+3; */ /************** input.x *****************/ - + /* input.voltage */ if (get_data("vI0U?",temp)) return; dstate_setinfo("input.voltage", "%s", temp+4); - upsdebugx(1, "input.voltage >%s<>%s<\n",temp,temp+4); + upsdebugx(1, "input.voltage >%s<>%s<\n",temp,temp+4); + - /* input.transfer.low */ if (get_data("vFi?",temp)) return; dstate_setinfo("input.transfer.low", "%s", temp+3); - upsdebugx(1, "input.transfer.low >%s<>%s<\n",temp,temp+3); + upsdebugx(1, "input.transfer.low >%s<>%s<\n",temp,temp+3); + - /* input.transfer.high */ if (get_data("vFj?",temp)) return; dstate_setinfo("input.transfer.high", "%s", temp+3); @@ -422,75 +423,75 @@ void upsdrv_updateinfo(void) /* input.frequency */ if (get_data("vI0f?",temp)) return; dstate_setinfo("input.frequency", "%2.1f", atof(temp+4) / 10.0); - upsdebugx(1, "input.frequency >%s<>%s<\n",temp,temp+4); + upsdebugx(1, "input.frequency >%s<>%s<\n",temp,temp+4); + + + /*************** output.x ********************************/ - /*************** output.x ********************************/ - - /* output.voltage */ if (get_data("vO0U?",temp)) return; dstate_setinfo("output.voltage", "%s", temp+4); - upsdebugx(1, "output.voltage >%s<>%s<\n",temp,temp+4); + upsdebugx(1, "output.voltage >%s<>%s<\n",temp,temp+4); + - /* output.frequency */ if (get_data("vOf?",temp)) return; dstate_setinfo("output.frequency", "%2.1f", atof(temp+3) / 10.0); - upsdebugx(1, "output.frequency >%s<>%s<\n",temp,temp+3); + upsdebugx(1, "output.frequency >%s<>%s<\n",temp,temp+3); /* output.current */ if (exist_output_current) - { + { if (get_data("vO0I?",temp)) return; dstate_setinfo("output.current", "%2.1f", atof(temp+4) / 10.0); - } - upsdebugx(1, "output.current >%s<>%s<\n",temp,temp+4); - - + } + upsdebugx(1, "output.current >%s<>%s<\n",temp,temp+4); + + /*************** battery.x *******************************/ - + /* battery charge */ if (exist_battery_charge) - { + { if (get_data("vBC?",temp)) return; dstate_setinfo("battery.charge", "%s", temp+3); - } - upsdebugx(1, "battery.charge >%s<>%s<\n",temp,temp+3); - + } + upsdebugx(1, "battery.charge >%s<>%s<\n",temp,temp+3); + /* battery.voltage */ if (get_data("vBU?",temp)) return; dstate_setinfo("battery.voltage", "%2.1f", atof(temp+3) / 10.0); - upsdebugx(1, "battery.voltage >%s<>%s<\n",temp,temp+3); - + upsdebugx(1, "battery.voltage >%s<>%s<\n",temp,temp+3); + /* battery.current */ if (exist_battery_current) - { + { if (get_data("vBI?",temp)) return; dstate_setinfo("battery.current", "%2.1f", atof(temp+3) / 10.0); - } - upsdebugx(1, "battery.current >%s<>%s<\n",temp,temp+3); + } + upsdebugx(1, "battery.current >%s<>%s<\n",temp,temp+3); /* battery.temperature */ if (exist_battery_temperature) - { + { if (get_data("vBT?",temp)) return; dstate_setinfo("battery.temperature", "%s", temp+3); - } - upsdebugx(1, "battery.temperature >%s<>%s<\n",temp,temp+3); + } + upsdebugx(1, "battery.temperature >%s<>%s<\n",temp,temp+3); /* battery.runtime */ if (exist_battery_runtime) - { + { if (get_data("vBt?",temp)) return; runtime_sec = strtol(temp+3, NULL, 10)*60; - snprintf(temp, sizeof(temp), "%d", runtime_sec); + snprintf(temp, sizeof(temp), "%ld", runtime_sec); dstate_setinfo("battery.runtime", "%s", temp); - } - upsdebugx(1, "battery.runtime >%s<>%d<\n",temp,runtime_sec); + } + upsdebugx(1, "battery.runtime >%s<>%ld<\n",temp,runtime_sec); dstate_dataok(); } @@ -500,7 +501,7 @@ void upsdrv_shutdown(void) ser_send(upsfd, "vCc0!%c", ENDCHAR); usleep(UPS_DELAY); - ser_send(upsfd, "vCb%i!%c", sdwdelay, ENDCHAR); + ser_send(upsfd, "vCb%i!%c", sdwdelay, ENDCHAR); } void upsdrv_help(void) @@ -511,25 +512,27 @@ void upsdrv_help(void) void upsdrv_makevartable(void) { addvar(VAR_VALUE, "usd", "Seting delay before shutdown"); - addvar(VAR_VALUE, "modelname", "Seting model name"); + addvar(VAR_VALUE, "modelname", "Seting model name"); } void upsdrv_initups(void) { char temp[ LENGTH_TEMP ], *usd = NULL; /* = NULL je dulezite jen pro prekladac */ - - + + upsfd = ser_open(device_path); ser_set_speed(upsfd, device_path, B1200); - if ((usd = getval("usd"))) { + if ((usd = getval("usd"))) + { sdwdelay=atoi(usd); upsdebugx(1, "(-x) Delay before shutdown %i",sdwdelay); } - if ((model_name = getval("modelname"))) { - /* kdyz modelname nebylo zadano je vraceno NULL*/ + if ((model_name = getval("modelname"))) + { + /* kdyz modelname nebylo zadano je vraceno NULL*/ upsdebugx(1, "(-x) UPS Name %s",model_name); } diff --git a/drivers/xppc-mib.c b/drivers/xppc-mib.c index c00655c..cfbc450 100644 --- a/drivers/xppc-mib.c +++ b/drivers/xppc-mib.c @@ -24,27 +24,28 @@ #include "xppc-mib.h" -#define XPPC_MIB_VERSION "0.2" +#define XPPC_MIB_VERSION "0.4" #define XPPC_SYSOID ".1.3.6.1.4.1.935" /* To create a value lookup structure (as needed on the 2nd line of the example * below), use the following kind of declaration, outside of the present snmp_info_t[]: - * static info_lkp_t onbatt_info[] = { - * { 1, "OB" }, - * { 2, "OL" }, - * { 0, NULL } + * static info_lkp_t xpcc_onbatt_info[] = { + * { 1, "OB", NULL, NULL }, + * { 2, "OL", NULL, NULL }, + * { 0, NULL, NULL, NULL } * }; */ /* upsBaseBatteryStatus */ static info_lkp_t xpcc_onbatt_info[] = { - { 1, "" }, /* unknown */ - { 2, "" }, /* batteryNormal */ - { 3, "LB" } /* batteryLow */ + { 1, "", NULL, NULL }, /* unknown */ + { 2, "", NULL, NULL }, /* batteryNormal */ + { 3, "LB", NULL, NULL }, /* batteryLow */ + { 0, NULL, NULL, NULL } }; -/* +/* upsBaseOutputStatus OBJECT-TYPE SYNTAX INTEGER { unknown(1), @@ -58,15 +59,16 @@ upsBaseOutputStatus OBJECT-TYPE onBuck(9) } */ static info_lkp_t xpcc_power_info[] = { - { 1, "" }, /* unknown */ - { 2, "OL" }, /* onLine */ - { 3, "OB" }, /* onBattery */ - { 4, "OL BOOST" }, /* onBoost */ - { 5, "OFF" }, /* sleeping */ - { 6, "BYPASS"}, /* onBypass */ - { 7, "" }, /* rebooting */ - { 8, "OFF" }, /* standBy */ - { 9, "OL TRIM"} /* onBuck */ + { 1, "", NULL, NULL }, /* unknown */ + { 2, "OL", NULL, NULL }, /* onLine */ + { 3, "OB", NULL, NULL }, /* onBattery */ + { 4, "OL BOOST", NULL, NULL }, /* onBoost */ + { 5, "OFF", NULL, NULL }, /* sleeping */ + { 6, "BYPASS", NULL, NULL }, /* onBypass */ + { 7, "", NULL, NULL }, /* rebooting */ + { 8, "OFF", NULL, NULL }, /* standBy */ + { 9, "OL TRIM", NULL, NULL }, /* onBuck */ + { 0, NULL, NULL, NULL } }; /* XPPC Snmp2NUT lookup table */ @@ -83,22 +85,27 @@ static snmp_info_t xppc_mib[] = { * dfl: default value * flags: snmp-ups internal flags (FIXME: ...) * oid2info: lookup table between OID and NUT values - * setvar: variable to set for SU_FLAG_SETINT * * Example: * { "input.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.2.1", "", SU_INPUT_1, NULL }, - * { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.7.3.0", "", SU_FLAG_OK | SU_STATUS_BATT, onbatt_info }, + * { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.7.3.0", "", SU_FLAG_OK | SU_STATUS_BATT, xpcc_onbatt_info }, * * To create a value lookup structure (as needed on the 2nd line), use the * following kind of declaration, outside of the present snmp_info_t[]: - * static info_lkp_t onbatt_info[] = { + * static info_lkp_t xpcc_onbatt_info[] = { * { 1, "OB" }, * { 2, "OL" }, * { 0, NULL } * }; */ - { "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "Tripp Lite / Phoenixtec", - SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, + + /* standard MIB items */ + { "device.description", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.1.0", NULL, SU_FLAG_OK, NULL }, + { "device.contact", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.4.0", NULL, SU_FLAG_OK, NULL }, + { "device.location", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.6.0", NULL, SU_FLAG_OK, NULL }, + + { "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "Tripp Lite / Phoenixtec", + SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, /* upsBaseIdentModel.0 = STRING: "Intelligent" */ { "ups.model", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.935.1.1.1.1.1.1.0", "Generic Phoenixtec SNMP device", SU_FLAG_OK, NULL }, @@ -123,4 +130,4 @@ static snmp_info_t xppc_mib[] = { { NULL, 0, 0, NULL, NULL, 0, NULL } }; -mib2nut_info_t xppc = { "xppc", XPPC_MIB_VERSION, NULL, NULL, xppc_mib, XPPC_SYSOID }; +mib2nut_info_t xppc = { "xppc", XPPC_MIB_VERSION, NULL, NULL, xppc_mib, XPPC_SYSOID, NULL }; diff --git a/include/Makefile.am b/include/Makefile.am index 41f47ba..c16d8c3 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,32 +1,39 @@ dist_noinst_HEADERS = attribute.h common.h extstate.h parseconf.h proto.h \ - state.h str.h timehead.h upsconf.h nut_stdint.h nut_platform.h + state.h str.h timehead.h upsconf.h nut_float.h nut_stdint.h nut_platform.h # http://www.gnu.org/software/automake/manual/automake.html#Clean BUILT_SOURCES = nut_version.h CLEANFILES = nut_version.h +MAINTAINERCLEANFILES = Makefile.in .dirstamp # magic to include Git version information in NUT version string +# (for builds not made from the tagged commit in a Git workspace) nut_version.h: FORCE - @GITREV=`git describe --tags 2>/dev/null | sed -e 's/^v\([0-9]\)/\1/' -e 's,^.*/,,' ` || GITREV=""; \ - echo '/* Autogenerated file. Do not change. */' > _nut_version.h ; \ - echo '/* This file was generated by "make". */' >> _nut_version.h ; \ - if [ -z "$$GITREV" ]; \ - then NUT_VERSION="$(PACKAGE_VERSION)"; \ - echo '/* The version number is set by AC_INIT in configure.in. */' >> _nut_version.h ; \ - else NUT_VERSION="$$GITREV"; \ - echo '/* The version number is determined by the most recent Git tag. */' >> _nut_version.h ; \ - fi ; \ - echo "#define NUT_VERSION_MACRO \"$$NUT_VERSION\"" >> _nut_version.h ; \ - echo "NUT_VERSION: \"$$NUT_VERSION\"" - -test -f nut_version.h || cp _nut_version.h nut_version.h - -cmp -s _nut_version.h nut_version.h || cp _nut_version.h nut_version.h - -rm -f _nut_version.h + @GITREV="`git describe --tags 2>/dev/null | sed -e 's/^v\([0-9]\)/\1/' -e 's,^.*/,,'`" || GITREV=""; \ + { echo '/* Autogenerated file. Do not change. */' ; \ + echo '/* This file was generated by "make". */' ; \ + if [ -z "$$GITREV" ]; then \ + NUT_VERSION="$(PACKAGE_VERSION)"; \ + echo '/* The version number is set by AC_INIT in configure.ac. */' ; \ + else \ + NUT_VERSION="$$GITREV"; \ + echo '/* The version number is determined by Git source commit hash' ; \ + echo ' * and number of commits since the most recent Git tag (if not' ; \ + echo ' * building the newest tagged commit itself - then just the tag).'; \ + echo ' */' ; \ + fi ; \ + echo "#define NUT_VERSION_MACRO \"$$NUT_VERSION\"" ; \ + } > "$@.tmp" ; \ + echo "NUT_VERSION: \"$$NUT_VERSION\"" + -test -f "$@" || cp "$@.tmp" "$@" + -cmp -s "$@.tmp" "$@" || cp "$@.tmp" "$@" + -rm -f "$@.tmp" FORCE: # counter part of BUILT_SOURCES: since nut_version is not a direct -# deps of a local target, we must clean it by ourself before the +# deps of a local target, we must clean it by ourselves before the # distribution dist-hook: rm -f $(distdir)/nut_version.h diff --git a/include/Makefile.in b/include/Makefile.in index 05faa88..fed410a 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.16.3 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -15,7 +15,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -80,19 +90,24 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = include -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(srcdir)/config.h.in $(dist_noinst_HEADERS) ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nut_arg_with.m4 \ $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ $(top_srcdir)/m4/nut_check_libavahi.m4 \ $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ $(top_srcdir)/m4/nut_check_libgd.m4 \ $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ $(top_srcdir)/m4/nut_check_libneon.m4 \ $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ $(top_srcdir)/m4/nut_check_libnss.m4 \ @@ -101,11 +116,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ $(top_srcdir)/m4/nut_check_libusb.m4 \ $(top_srcdir)/m4/nut_check_libwrap.m4 \ $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ $(top_srcdir)/m4/nut_type_socklen_t.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(dist_noinst_HEADERS) \ + $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = @@ -130,8 +152,8 @@ am__can_run_installinfo = \ *) (install-info --version) >/dev/null 2>&1;; \ esac HEADERS = $(dist_noinst_HEADERS) -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ - $(LISP)config.h.in +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \ + config.h.in # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. @@ -150,6 +172,7 @@ am__define_uniq_tagged_files = \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) A2X = @A2X@ ACLOCAL = @ACLOCAL@ @@ -158,6 +181,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -168,6 +192,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -181,6 +206,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -193,6 +219,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -210,6 +237,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -220,21 +249,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -254,6 +291,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -267,6 +307,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -284,6 +325,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -297,6 +339,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -322,12 +367,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -338,12 +385,13 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ udevdir = @udevdir@ dist_noinst_HEADERS = attribute.h common.h extstate.h parseconf.h proto.h \ - state.h str.h timehead.h upsconf.h nut_stdint.h nut_platform.h + state.h str.h timehead.h upsconf.h nut_float.h nut_stdint.h nut_platform.h # http://www.gnu.org/software/automake/manual/automake.html#Clean BUILT_SOURCES = nut_version.h CLEANFILES = nut_version.h +MAINTAINERCLEANFILES = Makefile.in .dirstamp all: $(BUILT_SOURCES) config.h $(MAKE) $(AM_MAKEFLAGS) all-am @@ -360,14 +408,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu include/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu include/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -452,7 +499,10 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -492,7 +542,8 @@ all-am: Makefile $(HEADERS) config.h installdirs: install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) install-am -install-exec: install-exec-am +install-exec: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data: install-data-am uninstall: uninstall-am @@ -523,6 +574,7 @@ maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am @@ -589,7 +641,7 @@ ps-am: uninstall-am: -.MAKE: all check install install-am install-strip +.MAKE: all check install install-am install-exec install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool cscopelist-am ctags ctags-am dist-hook distclean \ @@ -604,29 +656,37 @@ uninstall-am: mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am +.PRECIOUS: Makefile + # magic to include Git version information in NUT version string +# (for builds not made from the tagged commit in a Git workspace) nut_version.h: FORCE - @GITREV=`git describe --tags 2>/dev/null | sed -e 's/^v\([0-9]\)/\1/' -e 's,^.*/,,' ` || GITREV=""; \ - echo '/* Autogenerated file. Do not change. */' > _nut_version.h ; \ - echo '/* This file was generated by "make". */' >> _nut_version.h ; \ - if [ -z "$$GITREV" ]; \ - then NUT_VERSION="$(PACKAGE_VERSION)"; \ - echo '/* The version number is set by AC_INIT in configure.in. */' >> _nut_version.h ; \ - else NUT_VERSION="$$GITREV"; \ - echo '/* The version number is determined by the most recent Git tag. */' >> _nut_version.h ; \ - fi ; \ - echo "#define NUT_VERSION_MACRO \"$$NUT_VERSION\"" >> _nut_version.h ; \ - echo "NUT_VERSION: \"$$NUT_VERSION\"" - -test -f nut_version.h || cp _nut_version.h nut_version.h - -cmp -s _nut_version.h nut_version.h || cp _nut_version.h nut_version.h - -rm -f _nut_version.h + @GITREV="`git describe --tags 2>/dev/null | sed -e 's/^v\([0-9]\)/\1/' -e 's,^.*/,,'`" || GITREV=""; \ + { echo '/* Autogenerated file. Do not change. */' ; \ + echo '/* This file was generated by "make". */' ; \ + if [ -z "$$GITREV" ]; then \ + NUT_VERSION="$(PACKAGE_VERSION)"; \ + echo '/* The version number is set by AC_INIT in configure.ac. */' ; \ + else \ + NUT_VERSION="$$GITREV"; \ + echo '/* The version number is determined by Git source commit hash' ; \ + echo ' * and number of commits since the most recent Git tag (if not' ; \ + echo ' * building the newest tagged commit itself - then just the tag).'; \ + echo ' */' ; \ + fi ; \ + echo "#define NUT_VERSION_MACRO \"$$NUT_VERSION\"" ; \ + } > "$@.tmp" ; \ + echo "NUT_VERSION: \"$$NUT_VERSION\"" + -test -f "$@" || cp "$@.tmp" "$@" + -cmp -s "$@.tmp" "$@" || cp "$@.tmp" "$@" + -rm -f "$@.tmp" FORCE: # counter part of BUILT_SOURCES: since nut_version is not a direct -# deps of a local target, we must clean it by ourself before the +# deps of a local target, we must clean it by ourselves before the # distribution dist-hook: rm -f $(distdir)/nut_version.h diff --git a/include/attribute.h b/include/attribute.h index 3fe3f4a..f6ce29b 100644 --- a/include/attribute.h +++ b/include/attribute.h @@ -1,12 +1,71 @@ -/* portability hacks for __attribute__ usage in other header files */ +/* attribute.h - portability hacks for __attribute__ usage in other header files -#ifndef ATTRIBUTE_H_SEEN -#define ATTRIBUTE_H_SEEN 1 + Copyright (C) 2001 Russell Kroll + 2005 Arnaud Quette + 2020 Jim Klimov -#ifndef __attribute__ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__ -# define __attribute__(x) + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef NUT_ATTRIBUTE_H_SEEN +#define NUT_ATTRIBUTE_H_SEEN 1 + +/* To complicate matters, compilers with native support + * for the keyword may expose or not expose it as a macro... + * but for those that perform such courtesy, or are known + * supporters, we can put up the flag. For others, someone + * with those compilers should check and file PRs to NUT. + */ +#if (!defined HAVE___ATTRIBUTE__) || (HAVE___ATTRIBUTE__ == 0) +# if ( defined(__GNUC__) && ( __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) ) ) || ( defined(__STRICT_ANSI__) && __STRICT_ANSI__ ) +# ifndef __attribute__ +# define __attribute__(x) +# endif +# ifndef HAVE___ATTRIBUTE__ +# define HAVE___ATTRIBUTE__ 0 +# endif +# else +# if defined(__clang__) || defined(__GNUC__) || defined(__SUNPRO_C) +# ifndef HAVE___ATTRIBUTE__ +# define HAVE___ATTRIBUTE__ 1 +# endif +# else +# ifndef HAVE___ATTRIBUTE__ +# define HAVE___ATTRIBUTE__ 0 +# endif +# endif # endif #endif -#endif /* ATTRIBUTE_H_SEEN */ +#if (!defined HAVE___ATTRIBUTE__) || (HAVE___ATTRIBUTE__ == 0) +# ifdef HAVE___ATTRIBUTE__UNUSED_ARG +# undef HAVE___ATTRIBUTE__UNUSED_ARG +# endif +# ifdef HAVE___ATTRIBUTE__UNUSED_FUNC +# undef HAVE___ATTRIBUTE__UNUSED_FUNC +# endif +# ifdef HAVE___ATTRIBUTE__NORETURN +# undef HAVE___ATTRIBUTE__NORETURN +# endif +# ifdef HAVE___ATTRIBUTE__ +# undef HAVE___ATTRIBUTE__ +# endif +#endif + +/* Other source files now can simply check for `ifdef HAVE___ATTRIBUTE__*` + * as usual, and not bother about 0/1 values of the macro as well. + */ + +#endif /* NUT_ATTRIBUTE_H_SEEN */ diff --git a/include/common.h b/include/common.h index f893657..ff48ecd 100644 --- a/include/common.h +++ b/include/common.h @@ -1,6 +1,3 @@ -#ifndef NUT_COMMON_H -#define NUT_COMMON_H - /* common.h - prototypes for the common useful functions Copyright (C) 2000 Russell Kroll @@ -20,6 +17,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef NUT_COMMON_H_SEEN +#define NUT_COMMON_H_SEEN 1 + #include "config.h" /* must be the first header */ /* Need this on AIX when using xlc to get alloca */ @@ -33,9 +33,23 @@ #include #include #include + +#ifdef HAVE_SYS_SIGNAL_H +#include +#endif +#ifdef HAVE_SIGNAL_H #include +#endif + #include -#include + +#ifdef HAVE_STRINGS_H +#include /* for strncasecmp() and strcasecmp() */ +#endif +#ifdef HAVE_STRING_H +#include /* for strdup() and many others */ +#endif + #include #include #include @@ -53,6 +67,24 @@ extern "C" { extern const char *UPS_VERSION; +/* Use in code to notify the developers and quiesce the compiler that + * (for this codepath) the argument or variable is unused intentionally. + * void f(int x) { + * NUT_UNUSED_VARIABLE(x); + * ... + * } + * + * Note that solutions which mark up function arguments or employ this or + * that __attribute__ proved not portable enough for wherever NUT builds. + */ +#define NUT_UNUSED_VARIABLE(x) (void)(x) + +/** @brief Default timeout (in seconds) for network operations, as used by `upsclient` and `nut-scanner`. */ +#define DEFAULT_NETWORK_TIMEOUT 5 + +/** @brief Default timeout (in seconds) for retrieving the result of a `TRACKING`-enabled operation (e.g. `INSTCMD`, `SET VAR`). */ +#define DEFAULT_TRACKING_TIMEOUT 10 + /* get the syslog ready for us */ void open_syslog(const char *progname); @@ -71,13 +103,30 @@ void chroot_start(const char *path); /* write a pid file - is a full pathname *or* just the program name */ void writepid(const char *name); +/* parses string buffer into a pid_t if it passes + * a few sanity checks; returns -1 on error */ +pid_t parsepid(const char *buf); + /* send a signal to another running process */ int sendsignal(const char *progname, int sig); int snprintfcat(char *dst, size_t size, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4))); -/* open , get the pid, then send it */ +/* Report maximum platform value for the pid_t */ +pid_t get_max_pid_t(void); + +/* send sig to pid after some sanity checks, returns + * -1 for error, or zero for a successfully sent signal */ +int sendsignalpid(pid_t pid, int sig); + +/* open , get the pid, then send it + * returns zero for successfully sent signal, + * negative for errors: + * -3 PID file not found + * -2 PID file not parsable + * -1 Error sending signal + */ int sendsignalfn(const char *pidfn, int sig); const char *xbasename(const char *file); @@ -95,16 +144,53 @@ const char * dflt_statepath(void); /* Return the alternate path for pid files */ const char * altpidpath(void); +/* Die with a standard message if socket filename is too long */ +void check_unix_socket_filename(const char *fn); + +/* upslog*() messages are sent to syslog always; + * their life after that is out of NUT's control */ void upslog_with_errno(int priority, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); void upslogx(int priority, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); -void upsdebug_with_errno(int level, const char *fmt, ...) + +/* upsdebug*() messages are only logged if debugging + * level is high enough. To speed up a bit (minimize + * passing of ultimately ignored data trough the stack) + * these are "hidden" implementations wrapped into + * macros for earlier routine names spread around the + * codebase, they would check debug level first and + * only if logging should happen - call the routine + * and pass around pointers and other data. + */ +void s_upsdebug_with_errno(int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); -void upsdebugx(int level, const char *fmt, ...) +void s_upsdebugx(int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); -void upsdebug_hex(int level, const char *msg, const void *buf, int len); -void upsdebug_ascii(int level, const char *msg, const void *buf, int len); +void s_upsdebug_hex(int level, const char *msg, const void *buf, size_t len); +void s_upsdebug_ascii(int level, const char *msg, const void *buf, size_t len); +/* These macros should help avoid run-time overheads + * passing data for messages nobody would ever see. + * + * Also NOTE: the "level" may be specified by callers in various ways, + * e.g. as a "X ? Y : Z" style expression; to catch those expansions + * transparently we hide them into parentheses as "(label)". + * + * For stricter C99 compatibility, all parameters specified to a macro + * must be populated by caller (so we do not handle "fmt, args..." where + * the args part may be skipped by caller because fmt is a fixed string). + * Note it is then up to the caller (and compiler checks) that at least + * one argument is provided, the format string (maybe fixed) -- as would + * be required by the actual s_upsdebugx*() method after macro evaluation. + */ +#define upsdebug_with_errno(level, ...) \ + do { if (nut_debug_level >= (level)) { s_upsdebug_with_errno((level), __VA_ARGS__); } } while(0) +#define upsdebugx(level, ...) \ + do { if (nut_debug_level >= (level)) { s_upsdebugx((level), __VA_ARGS__); } } while(0) +#define upsdebug_hex(level, msg, buf, len) \ + do { if (nut_debug_level >= (level)) { s_upsdebug_hex((level), msg, buf, len); } } while(0) +#define upsdebug_ascii(level, msg, buf, len) \ + do { if (nut_debug_level >= (level)) { s_upsdebug_ascii((level), msg, buf, len); } } while(0) void fatal_with_errno(int status, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))) __attribute__((noreturn)); @@ -119,13 +205,18 @@ void *xcalloc(size_t number, size_t size); void *xrealloc(void *ptr, size_t size); char *xstrdup(const char *string); -int select_read(const int fd, void *buf, const size_t buflen, const long d_sec, const long d_usec); -int select_write(const int fd, const void *buf, const size_t buflen, const long d_sec, const long d_usec); +ssize_t select_read(const int fd, void *buf, const size_t buflen, const time_t d_sec, const suseconds_t d_usec); +ssize_t select_write(const int fd, const void *buf, const size_t buflen, const time_t d_sec, const suseconds_t d_usec); + +char * get_libname(const char* base_libname); /* Buffer sizes used for various functions */ #define SMALLBUF 512 #define LARGEBUF 1024 +/** @brief (Minimum) Size that a string must have to hold a UUID4 (i.e. UUID4 length + the terminating null character). */ +#define UUID4_LEN 37 + /* Provide declarations for getopt() global variables */ #ifdef NEED_GETOPT_H @@ -155,4 +246,4 @@ extern int optind; /* *INDENT-ON* */ #endif -#endif /* NUT_COMMON_H */ +#endif /* NUT_COMMON_H_SEEN */ diff --git a/include/config.h.in b/include/config.h.in index faa62ff..1f0b9a8 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -6,6 +6,24 @@ /* Path for pid files of drivers and upsd (usually STATEPATH) */ #undef ALTPIDPATH +/* host env spec we built on */ +#undef AUTOTOOLS_BUILD_ALIAS + +/* host OS short spec we built on */ +#undef AUTOTOOLS_BUILD_SHORT_ALIAS + +/* host env spec we run on */ +#undef AUTOTOOLS_HOST_ALIAS + +/* host OS short spec we run on */ +#undef AUTOTOOLS_HOST_SHORT_ALIAS + +/* host env spec we built for */ +#undef AUTOTOOLS_TARGET_ALIAS + +/* host OS short spec we built for */ +#undef AUTOTOOLS_TARGET_SHORT_ALIAS + /* Default path for user executables */ #undef BINDIR @@ -15,9 +33,15 @@ /* Default path for configuration files */ #undef CONFPATH +/* Compiler flags for cppunit tests */ +#undef CPPUNIT_NUT_CXXFLAGS + /* Define processor type */ #undef CPU_TYPE +/* Define to 1 if your C++ compiler doesn't accept -c and -o together. */ +#undef CXX_NO_MINUS_C_MINUS_O + /* Default path for data files */ #undef DATADIR @@ -33,6 +57,24 @@ MSVC and with C++ compilers. */ #undef FLEXIBLE_ARRAY_MEMBER +/* Define to the type of arg 1 for getnameinfo. */ +#undef GETNAMEINFO_TYPE_ARG1 + +/* Define to the type of arg 2 for getnameinfo. */ +#undef GETNAMEINFO_TYPE_ARG2 + +/* Define to the type of args 4 and 6 for getnameinfo. */ +#undef GETNAMEINFO_TYPE_ARG46 + +/* Define to the type of arg 7 for getnameinfo. */ +#undef GETNAMEINFO_TYPE_ARG7 + +/* Define to 1 if you have the `abs' function. */ +#undef HAVE_ABS + +/* Define to 1 if you have the `abs_val' function. */ +#undef HAVE_ABS_VAL + /* Define to 1 if you have the `atexit' function. */ #undef HAVE_ATEXIT @@ -54,14 +96,26 @@ /* Define to 1 if C supports variable-length arrays. */ #undef HAVE_C_VARARRAYS +/* Define to 1 if you have the declaration of `i2c_smbus_access', and to 0 if + you don't. */ +#undef HAVE_DECL_I2C_SMBUS_ACCESS + /* Define to 1 if you have the declaration of `i2c_smbus_read_block_data', and to 0 if you don't. */ #undef HAVE_DECL_I2C_SMBUS_READ_BLOCK_DATA +/* Define to 1 if you have the declaration of `i2c_smbus_read_byte_data', and + to 0 if you don't. */ +#undef HAVE_DECL_I2C_SMBUS_READ_BYTE_DATA + /* Define to 1 if you have the declaration of `i2c_smbus_read_word_data', and to 0 if you don't. */ #undef HAVE_DECL_I2C_SMBUS_READ_WORD_DATA +/* Define to 1 if you have the declaration of `i2c_smbus_write_byte_data', and + to 0 if you don't. */ +#undef HAVE_DECL_I2C_SMBUS_WRITE_BYTE_DATA + /* Define to 1 if you have the declaration of `i2c_smbus_write_word_data', and to 0 if you don't. */ #undef HAVE_DECL_I2C_SMBUS_WRITE_WORD_DATA @@ -89,12 +143,27 @@ /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H +/* Define to 1 if you have the `fabs' function. */ +#undef HAVE_FABS + +/* Define to 1 if you have the `fabsf' function. */ +#undef HAVE_FABSF + +/* Define to 1 if you have the `fabsl' function. */ +#undef HAVE_FABSL + /* Define to 1 if you have the `fcvt' function. */ #undef HAVE_FCVT /* Define to 1 if you have the `fcvtl' function. */ #undef HAVE_FCVTL +/* Define to 1 if you have the `fileno' function. */ +#undef HAVE_FILENO + +/* Define to 1 if you have . */ +#undef HAVE_FLOAT_H + /* Define to 1 if you have the `flock' function. */ #undef HAVE_FLOCK @@ -143,21 +212,76 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LIBPOWERMAN_H +/* Define to 1 if you have the `libusb_detach_kernel_driver' function. */ +#undef HAVE_LIBUSB_DETACH_KERNEL_DRIVER + +/* Define to 1 if you have the `libusb_detach_kernel_driver_np' function. */ +#undef HAVE_LIBUSB_DETACH_KERNEL_DRIVER_NP + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBUSB_H + +/* Define to 1 if you have the `libusb_init' function. */ +#undef HAVE_LIBUSB_INIT + +/* Define to 1 if you have the `libusb_kernel_driver_active' function. */ +#undef HAVE_LIBUSB_KERNEL_DRIVER_ACTIVE + +/* Define to 1 if you have the `libusb_set_auto_detach_kernel_driver' + function. */ +#undef HAVE_LIBUSB_SET_AUTO_DETACH_KERNEL_DRIVER + +/* Define to 1 if you have the `libusb_strerror' function. */ +#undef HAVE_LIBUSB_STRERROR + +/* Define to 1 if you have . */ +#undef HAVE_LIMITS_H + +/* Define to 1 if you have . */ +#undef HAVE_LINUX_I2C_DEV_H + +/* Define to 1 if you have . */ +#undef HAVE_LINUX_SMBUS_H + +/* Define to 1 if you have the `localtime_r' function. */ +#undef HAVE_LOCALTIME_R + /* Define to 1 if you have the `lockf' function. */ #undef HAVE_LOCKF /* Define to 1 if the system has the type `long double'. */ #undef HAVE_LONG_DOUBLE -/* Define to 1 if the system has the type 'long long int'. */ +/* Define to 1 if the system has the type `long long int'. */ #undef HAVE_LONG_LONG_INT /* Define to 1 if you have the header file. */ #undef HAVE_LTDL_H +/* Define to 1 if you have . */ +#undef HAVE_MATH_H + /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H +/* Define to 1 if you have the header file. */ +#undef HAVE_MODBUS_H + +/* Define to 1 if you have the `modbus_new_rtu' function. */ +#undef HAVE_MODBUS_NEW_RTU + +/* Define to 1 if you have the `modbus_new_tcp' function. */ +#undef HAVE_MODBUS_NEW_TCP + +/* Define to 1 if you have the `modbus_set_byte_timeout' function. */ +#undef HAVE_MODBUS_SET_BYTE_TIMEOUT + +/* Define to 1 if you have the `modbus_set_response_timeout' function. */ +#undef HAVE_MODBUS_SET_RESPONSE_TIMEOUT + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETDB_H + /* Define to 1 if you have the header file. */ #undef HAVE_NET_SNMP_NET_SNMP_CONFIG_H @@ -188,9 +312,299 @@ /* Define to 1 if you have the `pm_connect' function. */ #undef HAVE_PM_CONNECT +/* Define to 1 if you have the `pow10' function. */ +#undef HAVE_POW10 + +/* define if your compiler has pragmas for GCC diagnostic ignored + "-Wc++98-compat(-pedantic)" and for push-pop support */ +#undef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT + +/* define if your compiler has pragmas for GCC diagnostic ignored + "-Wc++98-compat(-pedantic)" and for push-pop support (outside function + bodies) */ +#undef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT_BESIDEFUNC + +/* define if your compiler has pragmas for GCC diagnostic ignored + "-Wformat-nonliteral" or "-Wformat-security" and for push-pop support */ +#undef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL + +/* define if your compiler has pragmas for GCC diagnostic ignored + "-Wformat-nonliteral" or "-Wformat-security" and for push-pop support + (outside function bodies) */ +#undef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL_BESIDEFUNC + +/* define if your compiler has pragmas for GCC diagnostic ignored + "-Wformat-truncation" or "-Werror=stringop-truncation" and for push-pop + support */ +#undef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION + +/* define if your compiler has pragmas for GCC diagnostic ignored + "-Wformat-truncation" or "-Werror=stringop-truncation" and for push-pop + support (outside function bodies) */ +#undef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION_BESIDEFUNC + +/* define if your compiler has pragmas for GCC diagnostic ignored + "-Wunreachable-code(-break)" and for push-pop support */ +#undef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE + +/* define if your compiler has pragmas for GCC diagnostic ignored + "-Wunreachable-code(-break)" and for push-pop support (outside function + bodies) */ +#undef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_BESIDEFUNC + +/* define if your compiler has #pragma clang diagnostic ignored + "-Wunreachable-code-return" */ +#undef HAVE_PRAGMA_CLANG_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN + +/* define if your compiler has #pragma clang diagnostic ignored + "-Wunreachable-code-return" (outside functions) */ +#undef HAVE_PRAGMA_CLANG_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN_BESIDEFUNC + +/* define if your compiler has #pragma clang diagnostic push and pop */ +#undef HAVE_PRAGMA_CLANG_DIAGNOSTIC_PUSH_POP + +/* define if your compiler has #pragma clang diagnostic push and pop outside + function bodies */ +#undef HAVE_PRAGMA_CLANG_DIAGNOSTIC_PUSH_POP_BESIDEFUNC + +/* define if your compiler has #pragma clang diagnostic push and pop inside + function bodies */ +#undef HAVE_PRAGMA_CLANG_DIAGNOSTIC_PUSH_POP_INSIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored "-Warray-bounds" + */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ARRAY_BOUNDS + +/* define if your compiler has #pragma GCC diagnostic ignored "-Warray-bounds" + (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ARRAY_BOUNDS_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored "-Wassign-enum" + */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ASSIGN_ENUM + +/* define if your compiler has #pragma GCC diagnostic ignored "-Wassign-enum" + (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ASSIGN_ENUM_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored "-Wcast-align" + */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN + +/* define if your compiler has #pragma GCC diagnostic ignored "-Wcast-align" + (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wcovered-switch-default" */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wcovered-switch-default" (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored "-Wc++98-compat" + */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT + +/* define if your compiler has #pragma GCC diagnostic ignored "-Wc++98-compat" + (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wc++98-compat-pedantic" */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT_PEDANTIC + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wc++98-compat-pedantic" (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT_PEDANTIC_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wexit-time-destructors" */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wexit-time-destructors" (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wextra-semi-stmt" */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXTRA_SEMI_STMT + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wextra-semi-stmt" (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXTRA_SEMI_STMT_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wformat-nonliteral" */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wformat-nonliteral" (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wformat-overflow" */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_OVERFLOW + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wformat-overflow" (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_OVERFLOW_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wformat-security" */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wformat-security" (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wformat-truncation" */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wformat-truncation" (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wglobal-constructors" */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wglobal-constructors" (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored "-Wsign-compare" + */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_COMPARE + +/* define if your compiler has #pragma GCC diagnostic ignored "-Wsign-compare" + (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_COMPARE_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wsign-conversion" */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_CONVERSION + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wsign-conversion" (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_CONVERSION_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wstrict-prototypes" */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wstrict-prototypes" (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wstringop-truncation" */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRINGOP_TRUNCATION + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wstringop-truncation" (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRINGOP_TRUNCATION_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wtautological-compare" */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_COMPARE + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wtautological-compare" (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_COMPARE_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wtautological-constant-out-of-range-compare" */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wtautological-constant-out-of-range-compare" (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wtautological-type-limit-compare" */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_TYPE_LIMIT_COMPARE + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wtautological-type-limit-compare" (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_TYPE_LIMIT_COMPARE_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wtautological-unsigned-zero-compare" */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_UNSIGNED_ZERO_COMPARE + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wtautological-unsigned-zero-compare" (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_UNSIGNED_ZERO_COMPARE_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored "-Wtype-limits" + */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS + +/* define if your compiler has #pragma GCC diagnostic ignored "-Wtype-limits" + (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wunreachable-code" */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wunreachable-code" (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wunreachable-code-break" */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_BREAK + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wunreachable-code-break" (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_BREAK_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wunreachable-code-return" */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wunreachable-code-return" (outside functions) */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic ignored + "-Wunused-function" */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNUSED_FUNCTION + +/* define if your compiler has #pragma GCC diagnostic push and pop */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP + +/* define if your compiler has #pragma GCC diagnostic push and pop outside + function bodies */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC + +/* define if your compiler has #pragma GCC diagnostic push and pop inside + function bodies */ +#undef HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_INSIDEFUNC + +/* define if your libc can printf("%s", NULL) sanely */ +#undef HAVE_PRINTF_STRING_NULL + /* Define to enable pthread support code */ #undef HAVE_PTHREAD +/* Define to enable pthread_tryjoin support code */ +#undef HAVE_PTHREAD_TRYJOIN + +/* Define to 1 if you have the `round' function. */ +#undef HAVE_ROUND + +/* Define to 1 if you have with usable sem_t sem_init() and + sem_destroy(). */ +#undef HAVE_SEMAPHORE + +/* Define to 1 if you have . */ +#undef HAVE_SEMAPHORE_H + /* Define to 1 if you have the `setenv' function. */ #undef HAVE_SETENV @@ -203,15 +617,24 @@ /* Define to 1 if you have the `setsid' function. */ #undef HAVE_SETSID +/* Define to 1 if you have the `sigaction' function. */ +#undef HAVE_SIGACTION + +/* Define to 1 if you have the `sigemptyset' function. */ +#undef HAVE_SIGEMPTYSET + +/* Define to 1 if you have . */ +#undef HAVE_SIGNAL_H + /* Define to 1 if you have the `snprintf' function. */ #undef HAVE_SNPRINTF +/* Define to 1 if you have the `SSL_CTX_new' function. */ +#undef HAVE_SSL_CTX_NEW + /* Define to 1 if you have the header file. */ #undef HAVE_SSL_H -/* Define to 1 if you have the `SSL_library_init' function. */ -#undef HAVE_SSL_LIBRARY_INIT - /* Define to 1 if you have the header file. */ #undef HAVE_STDARG_H @@ -221,21 +644,46 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H +/* defined if standard library has, and C standard allows, the + strcasecmp(s1,s2) method */ +#undef HAVE_STRCASECMP + +/* defined if standard library has, and C standard allows, the strdup(s) + method */ +#undef HAVE_STRDUP + /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR -/* Define to 1 if you have the header file. */ +/* Define to 1 if you have . */ #undef HAVE_STRINGS_H -/* Define to 1 if you have the header file. */ +/* Define to 1 if you have . */ #undef HAVE_STRING_H +/* defined if standard library has, and C standard allows, the + strncasecmp(s1,s2,n) method */ +#undef HAVE_STRNCASECMP + /* Define to 1 if you have the `strptime' function. */ #undef HAVE_STRPTIME +/* Define to 1 if you have the `strtok_r' function. */ +#undef HAVE_STRTOK_R + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_MODEM_H +/* Define to 1 if you have with usable struct rlimit and + getrlimit(). */ +#undef HAVE_SYS_RESOURCE_H + +/* Define to 1 if you have . */ +#undef HAVE_SYS_SIGNAL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SOCKET_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H @@ -254,10 +702,16 @@ /* Define to 1 if you have the `tcsendbreak' function. */ #undef HAVE_TCSENDBREAK +/* Define to 1 if you have the header file. */ +#undef HAVE_TERMIOS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_TIME_H + /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H -/* Define to 1 if the system has the type 'unsigned long long int'. */ +/* Define to 1 if the system has the type `unsigned long long int'. */ #undef HAVE_UNSIGNED_LONG_LONG_INT /* Define to 1 if you have the `usb_detach_kernel_driver_np' function. */ @@ -269,6 +723,10 @@ /* Define to 1 if you have the `usb_init' function. */ #undef HAVE_USB_INIT +/* defined if standard library has, and C standard allows, the usleep(us) + method */ +#undef HAVE_USLEEP + /* Use uu_lock for locking (FreeBSD) */ #undef HAVE_UU_LOCK @@ -278,20 +736,44 @@ /* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF +/* Define to 1 if you have the windows.h header file. */ +#undef HAVE_WINDOWS_H + +/* Define to 1 if you have the winsock2.h header file. */ +#undef HAVE_WINSOCK2_H + /* Define to enable libwrap support */ #undef HAVE_WRAP +/* Define to 1 if you have the ws2tcpip.h header file. */ +#undef HAVE_WS2TCPIP_H + +/* define if your compiler has __attribute__ */ +#undef HAVE___ATTRIBUTE__ + +/* define if your compiler has __attribute__((noreturn)) */ +#undef HAVE___ATTRIBUTE__NORETURN + +/* define if your compiler has __attribute__((unused)) for function arguments + */ +#undef HAVE___ATTRIBUTE__UNUSED_ARG + +/* define if your compiler has __attribute__((unused)) for functions */ +#undef HAVE___ATTRIBUTE__UNUSED_FUNC + /* Default path for HTML files */ #undef HTMLPATH /* Default path for system libraries */ #undef LIBDIR +/* Default path for system exec-libraries */ +#undef LIBEXECDIR + /* Desired syslog facility - see syslog(3) */ #undef LOG_FACILITY -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ +/* Define to the sub-directory where libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Define to use explicit getopt declarations */ @@ -300,6 +782,51 @@ /* Define if getopt.h is needed */ #undef NEED_GETOPT_H +/* Variable or macro by this name is not resolvable */ +#undef NUT_HAVE_LIBNETSNMP_DRAFT_BLUMENTHAL_AES_04 + +/* Variable or macro by this name is not resolvable */ +#undef NUT_HAVE_LIBNETSNMP_usmAES128PrivProtocol + +/* Variable or macro by this name is not resolvable */ +#undef NUT_HAVE_LIBNETSNMP_usmAES192PrivProtocol + +/* Variable or macro by this name is not resolvable */ +#undef NUT_HAVE_LIBNETSNMP_usmAES256PrivProtocol + +/* Variable or macro by this name is not resolvable */ +#undef NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol + +/* Variable or macro by this name is not resolvable */ +#undef NUT_HAVE_LIBNETSNMP_usmDESPrivProtocol + +/* Variable or macro by this name is not resolvable */ +#undef NUT_HAVE_LIBNETSNMP_usmHMAC192SHA256AuthProtocol + +/* Variable or macro by this name is not resolvable */ +#undef NUT_HAVE_LIBNETSNMP_usmHMAC256SHA384AuthProtocol + +/* Variable or macro by this name is not resolvable */ +#undef NUT_HAVE_LIBNETSNMP_usmHMAC384SHA512AuthProtocol + +/* Variable or macro by this name is not resolvable */ +#undef NUT_HAVE_LIBNETSNMP_usmHMACMD5AuthProtocol + +/* Variable or macro by this name is not resolvable */ +#undef NUT_HAVE_LIBNETSNMP_usmHMACSHA1AuthProtocol + +/* ${COMMENT} */ +#undef NUT_MODBUS_TIMEOUT_ARG_sec_usec_uint32 + +/* ${COMMENT} */ +#undef NUT_MODBUS_TIMEOUT_ARG_sec_usec_uint32_cast_timeval_fields + +/* ${COMMENT} */ +#undef NUT_MODBUS_TIMEOUT_ARG_timeval + +/* ${COMMENT} */ +#undef NUT_MODBUS_TIMEOUT_ARG_timeval_numeric_fields + /* NUT network protocol version */ #undef NUT_NETVERSION @@ -339,6 +866,9 @@ /* Default path for system executables */ #undef SBINDIR +/* The size of `void *', as computed by sizeof. */ +#undef SIZEOF_VOID_P + /* Path for UPS driver state files */ #undef STATEPATH @@ -348,7 +878,8 @@ /* Define to 1 for Sun version of the libusb. */ #undef SUN_LIBUSB -/* Define to 1 if you can safely include both and . */ +/* Define to 1 if you can safely include both and . This + macro is deemed obsolete by autotools. */ #undef TIME_WITH_SYS_TIME /* NUT tree version */ @@ -391,6 +922,9 @@ /* Define to enable development files support */ #undef WITH_DEV +/* Define to enable overall documentation generation */ +#undef WITH_DOCS + /* Define to enable IPMI support using FreeIPMI */ #undef WITH_FREEIPMI @@ -403,12 +937,22 @@ /* Define to enable Powerman PDU support */ #undef WITH_LIBPOWERMAN +/* Define to 1 for version 0.1 of the libusb (via pkg-config or + libusb-config). */ +#undef WITH_LIBUSB_0_1 + +/* Define to 1 for version 1.0 of the libusb (via pkg-config). */ +#undef WITH_LIBUSB_1_0 + /* Define to enable I2C support */ #undef WITH_LINUX_I2C /* Define to enable Mac OS X meta-driver */ #undef WITH_MACOSX +/* Define to enable Modbus support */ +#undef WITH_MODBUS + /* Define to enable Neon HTTP support */ #undef WITH_NEON diff --git a/include/extstate.h b/include/extstate.h index c4cc973..a511d62 100644 --- a/include/extstate.h +++ b/include/extstate.h @@ -1,7 +1,29 @@ -/* external state structures used by things like upsd */ +/* extstate.h - external state structures used by things like upsd -#ifndef EXTSTATE_H_SEEN -#define EXTSTATE_H_SEEN 1 + Copyright (C) 2001 Russell Kroll + 2005 Arnaud Quette + 2007 Peter Selinger + 2008 Arjen de Korte + 2013 Emilien Kia + 2020 Jim Klimov + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef NUT_EXTSTATE_H_SEEN +#define NUT_EXTSTATE_H_SEEN 1 #ifdef __cplusplus /* *INDENT-OFF* */ @@ -13,13 +35,15 @@ extern "C" { #define ST_MAX_VALUE_LEN 256 /* state tree flags */ -#define ST_FLAG_RW 0x0001 -#define ST_FLAG_STRING 0x0002 -#define ST_FLAG_IMMUTABLE 0x0004 +#define ST_FLAG_NONE 0x0000 +#define ST_FLAG_RW 0x0001 +#define ST_FLAG_STRING 0x0002 /* not STRING implies NUMBER */ +#define ST_FLAG_NUMBER 0x0004 +#define ST_FLAG_IMMUTABLE 0x0008 /* list of possible ENUM values */ typedef struct enum_s { - char *val; + char *val; struct enum_s *next; } enum_t; @@ -32,8 +56,8 @@ typedef struct range_s { /* list of instant commands */ typedef struct cmdlist_s { - char *name; - struct cmdlist_s *next; + char *name; + struct cmdlist_s *next; } cmdlist_t; #ifdef __cplusplus @@ -42,4 +66,4 @@ typedef struct cmdlist_s { /* *INDENT-ON* */ #endif -#endif /* EXTSTATE_H_SEEN */ +#endif /* NUT_EXTSTATE_H_SEEN */ diff --git a/include/nut_float.h b/include/nut_float.h new file mode 100644 index 0000000..290edb4 --- /dev/null +++ b/include/nut_float.h @@ -0,0 +1,54 @@ +/* + * nut_float.h - Network UPS Tools include files for floating point routines + * and ways to compare if non-integers are close enough to assume equal + * + * Copyright (C) 2020 Jim Klimov + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef NUT_FLOAT_H_SEEN +#define NUT_FLOAT_H_SEEN 1 + +#include "config.h" + +#if defined HAVE_FLOAT_H +# include +#endif + +#if defined HAVE_MATH_H +# include +#endif + +/* Modern compilers frown upon direct comparisons of floating point numbers + * since their imprecise internal representations can misfire, and really we + * care if they are indiscernably close. To aviod warnings like -Wfloat-equal + * we prefer to compare with methods defined below. Note: despite the "floating" + * name, fabs() seems to be defined over doubles or wider types, e.g.: + * double fabs(double x); + * float fabsf(float x); + * long double fabsl(long double x); + * To be on the safer side, we compare the difference to be smaller or equal to + * the Epsilon for the respective numeric type, in order to be equivalent to a + * zero for our needs. Various libs define it as "the next representable number + * after 1.0 which is not equal to 1.0" for the discrete maths involved; no talk + * about exactly comparing it to zero or whether it is the smallest representable + * non-zero value... + */ +#define f_equal(x, y) ( fabsf((float)(x) - (float)(y)) <= FLT_EPSILON ) +#define d_equal(x, y) ( fabs((double)(x) - (double)(y)) <= DBL_EPSILON ) +#define ld_equal(x, y) ( fabsl((long double)(x) - (long double)(y)) <= LDBL_EPSILON ) + +#endif /* NUT_FLOAT_H_SEEN */ diff --git a/include/nut_platform.h b/include/nut_platform.h index b7bf937..ba640c5 100644 --- a/include/nut_platform.h +++ b/include/nut_platform.h @@ -1,6 +1,3 @@ -#ifndef nut_platform_h -#define nut_platform_h - /** * \brief Platform-specific checks * @@ -17,6 +14,9 @@ * \date 2012/10/12 */ +#ifndef NUT_PLATFORM_H_SEEN +#define NUT_PLATFORM_H_SEEN 1 + /* * In case doxygen source doc isn't generated * (which is the case at time of writing this), @@ -121,5 +121,5 @@ #endif #endif -#endif /* end of #ifndef nut_platform_h */ +#endif /* NUT_PLATFORM_H_SEEN */ diff --git a/include/nut_stdint.h b/include/nut_stdint.h index 35292ee..722038a 100644 --- a/include/nut_stdint.h +++ b/include/nut_stdint.h @@ -19,10 +19,18 @@ */ #ifndef NUT_STDINT_H_SEEN -#define NUT_STDINT_H_SEEN +#define NUT_STDINT_H_SEEN 1 #include "config.h" +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#ifndef __STDC_CONSTANT_MACROS +#define __STDC_CONSTANT_MACROS 1 +#endif + #if defined HAVE_INTTYPES_H # include #endif @@ -31,4 +39,33 @@ # include #endif +#if defined HAVE_LIMITS_H +# include +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX ((size_t)(-1LL)) +#endif + +#ifndef SSIZE_MAX +#define SSIZE_MAX ((ssize_t)(-1LL)) +#endif + +/* Printing format for size_t and ssize_t */ +#ifndef PRIsize +# if defined(__MINGW32__) +# define PRIsize "u" +# else +# define PRIsize "zu" +# endif +#endif + +#ifndef PRIssize +# if defined(__MINGW32__) +# define PRIssize "d" +# else +# define PRIssize "zd" +# endif +#endif /* format for size_t and ssize_t */ + #endif /* NUT_STDINT_H_SEEN */ diff --git a/include/parseconf.h b/include/parseconf.h index d85c89d..bb7584b 100644 --- a/include/parseconf.h +++ b/include/parseconf.h @@ -39,7 +39,7 @@ typedef struct { FILE *f; /* stream to current file */ int state; /* current parser state */ int ch; /* last character read */ - + char **arglist; /* array of pointers to words */ size_t *argsize; /* list of sizes for realloc */ size_t numargs; /* max usable in arglist */ diff --git a/include/proto.h b/include/proto.h index 9c69114..c783755 100644 --- a/include/proto.h +++ b/include/proto.h @@ -1,5 +1,28 @@ -#ifndef PROTO_H -#define PROTO_H +/* proto.h - fill in the gaps about prototypes and definitions for portability + + Copyright (C) 2001 Russell Kroll + 2005 Arnaud Quette + 2006 Peter Selinger + 2013 Emilien Kia + 2020 Jim Klimov + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef NUT_PROTO_H_SEEN +#define NUT_PROTO_H_SEEN 1 #include "attribute.h" @@ -91,4 +114,4 @@ int putenv(char *); /* *INDENT-ON* */ #endif -#endif /* PROTO_H */ +#endif /* NUT_PROTO_H_SEEN */ diff --git a/include/state.h b/include/state.h index c6ea555..97249a2 100644 --- a/include/state.h +++ b/include/state.h @@ -19,8 +19,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef STATE_H_SEEN -#define STATE_H_SEEN +#ifndef NUT_STATE_H_SEEN +#define NUT_STATE_H_SEEN 1 #include "extstate.h" @@ -43,7 +43,7 @@ typedef struct st_tree_s { size_t safesize; int flags; - int aux; + long aux; struct enum_s *enum_list; struct range_s *range_list; @@ -58,10 +58,10 @@ int state_addrange(st_tree_t *root, const char *var, const int min, const int ma int state_setaux(st_tree_t *root, const char *var, const char *auxs); const char *state_getinfo(st_tree_t *root, const char *var); int state_getflags(st_tree_t *root, const char *var); -int state_getaux(st_tree_t *root, const char *var); +long state_getaux(st_tree_t *root, const char *var); const enum_t *state_getenumlist(st_tree_t *root, const char *var); const range_t *state_getrangelist(st_tree_t *root, const char *var); -void state_setflags(st_tree_t *root, const char *var, int numflags, char **flags); +void state_setflags(st_tree_t *root, const char *var, size_t numflags, char **flags); int state_addcmd(cmdlist_t **list, const char *cmd); void state_infofree(st_tree_t *node); void state_cmdfree(cmdlist_t *list); @@ -77,4 +77,4 @@ st_tree_t *state_tree_find(st_tree_t *node, const char *var); /* *INDENT-ON* */ #endif -#endif /* STATE_H_SEEN */ +#endif /* NUT_STATE_H_SEEN */ diff --git a/include/str.h b/include/str.h index 57955fd..500c078 100644 --- a/include/str.h +++ b/include/str.h @@ -20,8 +20,8 @@ * */ -#ifndef STR_H -#define STR_H +#ifndef NUT_STR_H_SEEN +#define NUT_STR_H_SEEN 1 #ifdef __cplusplus /* *INDENT-OFF* */ @@ -29,6 +29,15 @@ extern "C" { /* *INDENT-ON* */ #endif +/* Some compilers and/or C libraries do not handle printf("%s", NULL) correctly */ +#ifndef NUT_STRARG +# ifdef HAVE_PRINTF_STRING_NULL +# define NUT_STRARG(x) x +# else +# define NUT_STRARG(x) (x?x:"(null)") +# endif +#endif + /* Remove all * - leading and trailing (str_trim[_m]()) * - leading (str_ltrim[_m]()) @@ -120,10 +129,14 @@ int str_to_ulong_strict(const char *string, unsigned long *number, const int bas int str_to_double(const char *string, double *number, const int base); int str_to_double_strict(const char *string, double *number, const int base); +/* Return non-zero if string s ends exactly with suff + * Note: s=NULL always fails the test; otherwise suff=NULL always matches + */ +int str_ends_with(const char *s, const char *suff); #ifdef __cplusplus /* *INDENT-OFF* */ } /* *INDENT-ON* */ #endif -#endif /* STR_H */ +#endif /* NUT_STR_H_SEEN */ diff --git a/include/timehead.h b/include/timehead.h index 13182b7..aabcf2a 100644 --- a/include/timehead.h +++ b/include/timehead.h @@ -1,13 +1,36 @@ -/* from the autoconf docs: sanely include the right time headers everywhere */ +/* timehead.h - from the autoconf docs: sanely include the right time headers everywhere -#if TIME_WITH_SYS_TIME + Copyright (C) 2001 Russell Kroll + 2005 Arnaud Quette + 2020 Jim Klimov + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef NUT_TIMEHEAD_H_SEEN +#define NUT_TIMEHEAD_H_SEEN 1 + +#ifdef TIME_WITH_SYS_TIME # include # include #else -# if HAVE_SYS_TIME_H +# ifdef HAVE_SYS_TIME_H # include # else # include # endif #endif +#endif /* NUT_TIMEHEAD_H_SEEN */ diff --git a/include/upsconf.h b/include/upsconf.h index 4667593..4ae1b27 100644 --- a/include/upsconf.h +++ b/include/upsconf.h @@ -1,3 +1,27 @@ +/* upsconf.h - prototypes for upsconf.c + + Copyright (C) 2001 Russell Kroll + 2005 Arnaud Quette + 2013 Emilien Kia + 2020 Jim Klimov + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef NUT_UPSCONF_H_SEEN +#define NUT_UPSCONF_H_SEEN 1 #ifdef __cplusplus /* *INDENT-OFF* */ @@ -7,13 +31,14 @@ extern "C" { /* callback function from read_upsconf */ void do_upsconf_args(char *upsname, char *var, char *val); - + /* open the ups.conf, parse it, and call back do_upsconf_args() */ void read_upsconf(void); - + #ifdef __cplusplus /* *INDENT-OFF* */ } /* *INDENT-ON* */ #endif +#endif /* NUT_UPSCONF_H_SEEN */ diff --git a/install-sh b/install-sh index 377bb86..ec298b5 100755 --- a/install-sh +++ b/install-sh @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2011-11-20.07; # UTC +scriptversion=2020-11-14.01; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -41,19 +41,15 @@ scriptversion=2011-11-20.07; # UTC # This script is compatible with the BSD install script, but was written # from scratch. +tab=' ' nl=' ' -IFS=" "" $nl" +IFS=" $tab$nl" -# set DOITPROG to echo to test this script +# Set DOITPROG to "echo" to test this script. -# Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} -if test -z "$doit"; then - doit_exec=exec -else - doit_exec=$doit -fi +doit_exec=${doit:-exec} # Put in absolute file names if you don't have them in your path; # or use environment vars. @@ -68,22 +64,16 @@ mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} -posix_glob='?' -initialize_posix_glob=' - test "$posix_glob" != "?" || { - if (set -f) 2>/dev/null; then - posix_glob= - else - posix_glob=: - fi - } -' - posix_mkdir= # Desired mode of installed file. mode=0755 +# Create dirs (including intermediate dirs) using mode 755. +# This is like GNU 'install' as of coreutils 8.32 (2020). +mkdir_umask=22 + +backupsuffix= chgrpcmd= chmodcmd=$chmodprog chowncmd= @@ -97,7 +87,7 @@ dir_arg= dst_arg= copy_on_change=false -no_target_directory= +is_target_a_directory=possibly usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE @@ -114,18 +104,28 @@ Options: --version display version info and exit. -c (ignored) - -C install only if different (preserve the last data modification time) + -C install only if different (preserve data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. + -p pass -p to $cpprog. -s $stripprog installed files. + -S SUFFIX attempt to back up existing files, with suffix SUFFIX. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG + +By default, rm is invoked with -f; when overridden with RMPROG, +it's up to you to specify -f if you want it. + +If -S is not specified, no backups are attempted. + +Email bug reports to bug-automake@gnu.org. +Automake home page: https://www.gnu.org/software/automake/ " while test $# -ne 0; do @@ -137,46 +137,62 @@ while test $# -ne 0; do -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" - shift;; + shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 - case $mode in - *' '* | *' '* | *' -'* | *'*'* | *'?'* | *'['*) - echo "$0: invalid mode: $mode" >&2 - exit 1;; - esac - shift;; + case $mode in + *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; -o) chowncmd="$chownprog $2" - shift;; + shift;; + + -p) cpprog="$cpprog -p";; -s) stripcmd=$stripprog;; - -t) dst_arg=$2 - # Protect names problematic for 'test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac - shift;; + -S) backupsuffix="$2" + shift;; - -T) no_target_directory=true;; + -t) + is_target_a_directory=always + dst_arg=$2 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + shift;; + + -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; - --) shift - break;; + --) shift + break;; - -*) echo "$0: invalid option: $1" >&2 - exit 1;; + -*) echo "$0: invalid option: $1" >&2 + exit 1;; *) break;; esac shift done +# We allow the use of options -d and -T together, by making -d +# take the precedence; this is for compatibility with GNU install. + +if test -n "$dir_arg"; then + if test -n "$dst_arg"; then + echo "$0: target directory not allowed when installing a directory." >&2 + exit 1 + fi +fi + if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. @@ -207,6 +223,15 @@ if test $# -eq 0; then exit 0 fi +if test -z "$dir_arg"; then + if test $# -gt 1 || test "$is_target_a_directory" = always; then + if test ! -d "$dst_arg"; then + echo "$0: $dst_arg: Is not a directory." >&2 + exit 1 + fi + fi +fi + if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 @@ -223,16 +248,16 @@ if test -z "$dir_arg"; then *[0-7]) if test -z "$stripcmd"; then - u_plus_rw= + u_plus_rw= else - u_plus_rw='% 200' + u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then - u_plus_rw= + u_plus_rw= else - u_plus_rw=,u+rw + u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac @@ -250,6 +275,10 @@ do dstdir=$dst test -d "$dstdir" dstdir_status=$? + # Don't chown directories that already exist. + if test $dstdir_status = 0; then + chowncmd="" + fi else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command @@ -266,178 +295,148 @@ do fi dst=$dst_arg - # If destination is a directory, append the input filename; won't work - # if double slashes aren't ignored. + # If destination is a directory, append the input filename. if test -d "$dst"; then - if test -n "$no_target_directory"; then - echo "$0: $dst_arg: Is a directory" >&2 - exit 1 + if test "$is_target_a_directory" = never; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 fi dstdir=$dst - dst=$dstdir/`basename "$src"` + dstbase=`basename "$src"` + case $dst in + */) dst=$dst$dstbase;; + *) dst=$dst/$dstbase;; + esac dstdir_status=0 else - # Prefer dirname, but fall back on a substitute if dirname fails. - dstdir=` - (dirname "$dst") 2>/dev/null || - expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$dst" : 'X\(//\)[^/]' \| \ - X"$dst" : 'X\(//\)$' \| \ - X"$dst" : 'X\(/\)' \| . 2>/dev/null || - echo X"$dst" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q' - ` - + dstdir=`dirname "$dst"` test -d "$dstdir" dstdir_status=$? fi fi + case $dstdir in + */) dstdirslash=$dstdir;; + *) dstdirslash=$dstdir/;; + esac + obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') - # Create intermediate dirs using mode 755 as modified by the umask. - # This is like FreeBSD 'install' as of 1997-10-28. - umask=`umask` - case $stripcmd.$umask in - # Optimize common cases. - *[2367][2367]) mkdir_umask=$umask;; - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi - *[0-7]) - mkdir_umask=`expr $umask + 22 \ - - $umask % 100 % 40 + $umask % 20 \ - - $umask % 10 % 4 + $umask % 2 - `;; - *) mkdir_umask=$umask,go-w;; - esac + posix_mkdir=false + # The $RANDOM variable is not portable (e.g., dash). Use it + # here however when possible just to lower collision chance. + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - # With -d, create the new directory with the user-specified mode. - # Otherwise, rely on $mkdir_umask. - if test -n "$dir_arg"; then - mkdir_mode=-m$mode + trap ' + ret=$? + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null + exit $ret + ' 0 + + # Because "mkdir -p" follows existing symlinks and we likely work + # directly in world-writeable /tmp, make sure that the '$tmpdir' + # directory is successfully created first before we actually test + # 'mkdir -p'. + if (umask $mkdir_umask && + $mkdirprog $mkdir_mode "$tmpdir" && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + test_tmpdir="$tmpdir/a" + ls_ld_tmpdir=`ls -ld "$test_tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" else - mkdir_mode= + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null fi - - posix_mkdir=false - case $umask in - *[123567][0-7][0-7]) - # POSIX mkdir -p sets u+wx bits regardless of umask, which - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. - ;; - *) - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 - - if (umask $mkdir_umask && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 - then - if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writable bit of parent directory when it shouldn't. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - ls_ld_tmpdir=`ls -ld "$tmpdir"` - case $ls_ld_tmpdir in - d????-?r-*) different_mode=700;; - d????-?--*) different_mode=755;; - *) false;; - esac && - $mkdirprog -m$different_mode -p -- "$tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" - } - } - then posix_mkdir=: - fi - rmdir "$tmpdir/d" "$tmpdir" - else - # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null - fi - trap '' 0;; - esac;; + trap '' 0;; esac if $posix_mkdir && ( - umask $mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else - # The umask is ridiculous, or mkdir does not conform to POSIX, + # mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in - /*) prefix='/';; - [-=\(\)!]*) prefix='./';; - *) prefix='';; + /*) prefix='/';; + [-=\(\)!]*) prefix='./';; + *) prefix='';; esac - eval "$initialize_posix_glob" - oIFS=$IFS IFS=/ - $posix_glob set -f + set -f set fnord $dstdir shift - $posix_glob set +f + set +f IFS=$oIFS prefixes= for d do - test X"$d" = X && continue + test X"$d" = X && continue - prefix=$prefix$d - if test -d "$prefix"; then - prefixes= - else - if $posix_mkdir; then - (umask=$mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break - # Don't fail if two instances are running concurrently. - test -d "$prefix" || exit 1 - else - case $prefix in - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; - *) qprefix=$prefix;; - esac - prefixes="$prefixes '$qprefix'" - fi - fi - prefix=$prefix/ + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ done if test -n "$prefixes"; then - # Don't fail if two instances are running concurrently. - (umask $mkdir_umask && - eval "\$doit_exec \$mkdirprog $prefixes") || - test -d "$dstdir" || exit 1 - obsolete_mkdir_used=true + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true fi fi fi @@ -450,14 +449,25 @@ do else # Make a couple of temp file names in the proper directory. - dsttmp=$dstdir/_inst.$$_ - rmtmp=$dstdir/_rm.$$_ + dsttmp=${dstdirslash}_inst.$$_ + rmtmp=${dstdirslash}_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. - (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + (umask $cp_umask && + { test -z "$stripcmd" || { + # Create $dsttmp read-write so that cp doesn't create it read-only, + # which would cause strip to fail. + if test -z "$doit"; then + : >"$dsttmp" # No need to fork-exec 'touch'. + else + $doit touch "$dsttmp" + fi + } + } && + $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # @@ -472,20 +482,24 @@ do # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && - old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && - new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && - - eval "$initialize_posix_glob" && - $posix_glob set -f && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && - $posix_glob set +f && - + set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else + # If $backupsuffix is set, and the file being installed + # already exists, attempt a backup. Don't worry if it fails, + # e.g., if mv doesn't support -f. + if test -n "$backupsuffix" && test -f "$dst"; then + $doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null + fi + # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || @@ -493,24 +507,24 @@ do # to itself, or perhaps because mv is so ancient that it does not # support -f. { - # Now remove or move aside any old file at destination location. - # We try this two ways since rm can't unlink itself on some - # systems and the destination file might be busy for other - # reasons. In this case, the final cleanup might fail but the new - # file should still install successfully. - { - test ! -f "$dst" || - $doit $rmcmd -f "$dst" 2>/dev/null || - { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } - } || - { echo "$0: cannot unlink or rename $dst" >&2 - (exit 1); exit 1 - } - } && + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dst" + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 @@ -519,9 +533,9 @@ do done # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: diff --git a/lib/Makefile.am b/lib/Makefile.am index d164e1b..f4d36cc 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -2,8 +2,11 @@ if WITH_DEV if WITH_PKG_CONFIG - pkgconfig_DATA = libupsclient.pc libnutscan.pc libnutclient.pc + pkgconfig_DATA = libupsclient.pc libnutscan.pc libnutclient.pc libnutclientstub.pc else bin_SCRIPTS = libupsclient-config endif endif + +CLEANFILES = *-spellchecked +MAINTAINERCLEANFILES = Makefile.in .dirstamp diff --git a/lib/Makefile.in b/lib/Makefile.in index da3c235..6414edd 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.16.3 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -18,7 +18,17 @@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -83,20 +93,24 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = lib -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(srcdir)/libupsclient-config.in $(srcdir)/libupsclient.pc.in \ - $(srcdir)/libnutclient.pc.in $(srcdir)/libnutscan.pc.in README ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nut_arg_with.m4 \ $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ $(top_srcdir)/m4/nut_check_libavahi.m4 \ $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ $(top_srcdir)/m4/nut_check_libgd.m4 \ $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ $(top_srcdir)/m4/nut_check_libneon.m4 \ $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ $(top_srcdir)/m4/nut_check_libnss.m4 \ @@ -105,15 +119,21 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ $(top_srcdir)/m4/nut_check_libusb.m4 \ $(top_srcdir)/m4/nut_check_libwrap.m4 \ $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ $(top_srcdir)/m4/nut_type_socklen_t.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = libupsclient-config libupsclient.pc \ - libnutclient.pc libnutscan.pc + libnutclient.pc libnutclientstub.pc libnutscan.pc CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ @@ -165,6 +185,10 @@ am__can_run_installinfo = \ esac DATA = $(pkgconfig_DATA) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/libnutclient.pc.in \ + $(srcdir)/libnutclientstub.pc.in $(srcdir)/libnutscan.pc.in \ + $(srcdir)/libupsclient-config.in $(srcdir)/libupsclient.pc.in \ + README DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) A2X = @A2X@ ACLOCAL = @ACLOCAL@ @@ -173,6 +197,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -183,6 +208,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -196,6 +222,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -208,6 +235,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -225,6 +253,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -235,21 +265,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -269,6 +307,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -282,6 +323,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -299,6 +341,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -312,6 +355,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -337,12 +383,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -352,8 +400,10 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ udevdir = @udevdir@ -@WITH_DEV_TRUE@@WITH_PKG_CONFIG_TRUE@pkgconfig_DATA = libupsclient.pc libnutscan.pc libnutclient.pc +@WITH_DEV_TRUE@@WITH_PKG_CONFIG_TRUE@pkgconfig_DATA = libupsclient.pc libnutscan.pc libnutclient.pc libnutclientstub.pc @WITH_DEV_TRUE@@WITH_PKG_CONFIG_FALSE@bin_SCRIPTS = libupsclient-config +CLEANFILES = *-spellchecked +MAINTAINERCLEANFILES = Makefile.in .dirstamp all: all-am .SUFFIXES: @@ -369,14 +419,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu lib/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu lib/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -393,6 +442,8 @@ libupsclient.pc: $(top_builddir)/config.status $(srcdir)/libupsclient.pc.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ libnutclient.pc: $(top_builddir)/config.status $(srcdir)/libnutclient.pc.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +libnutclientstub.pc: $(top_builddir)/config.status $(srcdir)/libnutclientstub.pc.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ libnutscan.pc: $(top_builddir)/config.status $(srcdir)/libnutscan.pc.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ install-binSCRIPTS: $(bin_SCRIPTS) @@ -464,7 +515,10 @@ ctags CTAGS: cscope cscopelist: -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -523,6 +577,7 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) @@ -531,6 +586,7 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am @@ -612,6 +668,8 @@ uninstall-am: uninstall-binSCRIPTS uninstall-pkgconfigDATA mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ uninstall-am uninstall-binSCRIPTS uninstall-pkgconfigDATA +.PRECIOUS: Makefile + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/lib/README b/lib/README index 600a4cb..6e3fac7 100644 --- a/lib/README +++ b/lib/README @@ -45,7 +45,7 @@ To get LD_FLAGS, use: References: linkman:libupsclient-config[1] manual page, -NOTE: this feature may evolve (name change), or even disapear in the future. +NOTE: this feature may evolve (name change), or even disappear in the future. pkgconfig support ----------------- @@ -112,7 +112,7 @@ to libupsclient-config if not available. It will issue an error if none is found! The same is also valid for other NUT libraries, such as libnutscan. -Simply replace 'libupsclient' occurences in the above example, by the name +Simply replace 'libupsclient' occurrences in the above example, by the name of the desired library (for example, 'libnutscan'). NOTE: this is an alternate method. Use of PKG_CHECK_MODULES macro should be diff --git a/lib/libnutclientstub.pc.in b/lib/libnutclientstub.pc.in new file mode 100644 index 0000000..b730a63 --- /dev/null +++ b/lib/libnutclientstub.pc.in @@ -0,0 +1,13 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ +sysconfdir=@CONFPATH@ +statepath=@STATEPATH@ +nutuser=@RUN_AS_USER@ + +Name: libnutclientstub +Description: Stub for UPS monitoring with Network UPS Tools +Version: @PACKAGE_VERSION@ +Libs: -L${libdir} -lnutclientstub +Cflags: -I${includedir} diff --git a/lib/libupsclient.pc.in b/lib/libupsclient.pc.in index 4ad31fb..8efce40 100644 --- a/lib/libupsclient.pc.in +++ b/lib/libupsclient.pc.in @@ -9,5 +9,6 @@ nutuser=@RUN_AS_USER@ Name: libupsclient Description: UPS monitoring with Network UPS Tools Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lupsclient @LIBSSL_LIBS@ -Cflags: -I${includedir} @LIBSSL_CFLAGS@ +Libs: -L${libdir} -lupsclient +Cflags: -I${includedir} +Requires: @LIBSSL_REQUIRES@ diff --git a/ltmain.sh b/ltmain.sh old mode 100644 new mode 100755 index bffda54..21e5e07 --- a/ltmain.sh +++ b/ltmain.sh @@ -1,9 +1,12 @@ +#! /bin/sh +## DO NOT EDIT - This file generated from ./build-aux/ltmain.in +## by inline-source v2014-01-03.01 -# libtool (GNU libtool) 2.4.2 +# libtool (GNU libtool) 2.4.6 +# Provide generalized library-building support services. # Written by Gordon Matzigkeit , 1996 -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, -# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +# Copyright (C) 1996-2015 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. @@ -23,166 +26,670 @@ # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with GNU Libtool; see the file COPYING. If not, a copy -# can be downloaded from http://www.gnu.org/licenses/gpl.html, -# or obtained by writing to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# along with this program. If not, see . -# Usage: $progname [OPTION]... [MODE-ARG]... -# -# Provide generalized library-building support services. -# -# --config show all configuration variables -# --debug enable verbose shell tracing -# -n, --dry-run display commands without modifying any files -# --features display basic configuration information and exit -# --mode=MODE use operation mode MODE -# --preserve-dup-deps don't remove duplicate dependency libraries -# --quiet, --silent don't print informational messages -# --no-quiet, --no-silent -# print informational messages (default) -# --no-warn don't display warning messages -# --tag=TAG use configuration variables from tag TAG -# -v, --verbose print more informational messages than default -# --no-verbose don't print the extra informational messages -# --version print version information -# -h, --help, --help-all print short, long, or detailed help message -# -# MODE must be one of the following: -# -# clean remove files from the build directory -# compile compile a source file into a libtool object -# execute automatically set library path, then run a program -# finish complete the installation of libtool libraries -# install install libraries or executables -# link create a library or an executable -# uninstall remove libraries from an installed directory -# -# MODE-ARGS vary depending on the MODE. When passed as first option, -# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. -# Try `$progname --help --mode=MODE' for a more detailed description of MODE. -# -# When reporting a bug, please describe a test case to reproduce it and -# include the following information: -# -# host-triplet: $host -# shell: $SHELL -# compiler: $LTCC -# compiler flags: $LTCFLAGS -# linker: $LD (gnu? $with_gnu_ld) -# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.11 -# automake: $automake_version -# autoconf: $autoconf_version -# -# Report bugs to . -# GNU libtool home page: . -# General help using GNU software: . PROGRAM=libtool PACKAGE=libtool -VERSION="2.4.2 Debian-2.4.2-1.11" -TIMESTAMP="" -package_revision=1.3337 +VERSION="2.4.6 Debian-2.4.6-15" +package_revision=2.4.6 -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + +## ------ ## +## Usage. ## +## ------ ## + +# Run './libtool --help' for help with using this script from the +# command line. + + +## ------------------------------- ## +## User overridable command paths. ## +## ------------------------------- ## + +# After configure completes, it has a better idea of some of the +# shell tools we need than the defaults used by the functions shared +# with bootstrap, so set those here where they can still be over- +# ridden by the user, but otherwise take precedence. + +: ${AUTOCONF="autoconf"} +: ${AUTOMAKE="automake"} + + +## -------------------------- ## +## Source external libraries. ## +## -------------------------- ## + +# Much of our low-level functionality needs to be sourced from external +# libraries, which are installed to $pkgauxdir. + +# Set a version string for this script. +scriptversion=2015-01-20.17; # UTC + +# General shell script boiler plate, and helper functions. +# Written by Gary V. Vaughan, 2004 + +# Copyright (C) 2004-2015 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +# As a special exception to the GNU General Public License, if you distribute +# this file as part of a program or library that is built using GNU Libtool, +# you may include this file under the same distribution terms that you use +# for the rest of that program. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Please report bugs or propose patches to gary@gnu.org. + + +## ------ ## +## Usage. ## +## ------ ## + +# Evaluate this file near the top of your script to gain access to +# the functions and variables defined here: +# +# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh +# +# If you need to override any of the default environment variable +# settings, do that before evaluating this file. + + +## -------------------- ## +## Shell normalisation. ## +## -------------------- ## + +# Some shells need a little help to be as Bourne compatible as possible. +# Before doing anything else, make sure all that help has been provided! + +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else - case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac + case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -$1 -_LTECHO_EOF' -} - -# NLS nuisances: We save the old values to restore during execute mode. -lt_user_locale= -lt_safe_locale= -for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES +# NLS nuisances: We save the old values in case they are required later. +_G_user_locale= +_G_safe_locale= +for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do - eval "if test \"\${$lt_var+set}\" = set; then - save_$lt_var=\$$lt_var - $lt_var=C - export $lt_var - lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" - lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" + eval "if test set = \"\${$_G_var+set}\"; then + save_$_G_var=\$$_G_var + $_G_var=C + export $_G_var + _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" + _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" fi" done -LC_ALL=C -LANGUAGE=C -export LANGUAGE LC_ALL -$lt_unset CDPATH +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH +# Make sure IFS has a sensible default +sp=' ' +nl=' +' +IFS="$sp $nl" + +# There are apparently some retarded systems that use ';' as a PATH separator! +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + + +## ------------------------- ## +## Locate command utilities. ## +## ------------------------- ## + + +# func_executable_p FILE +# ---------------------- +# Check that FILE is an executable regular file. +func_executable_p () +{ + test -f "$1" && test -x "$1" +} + + +# func_path_progs PROGS_LIST CHECK_FUNC [PATH] +# -------------------------------------------- +# Search for either a program that responds to --version with output +# containing "GNU", or else returned by CHECK_FUNC otherwise, by +# trying all the directories in PATH with each of the elements of +# PROGS_LIST. +# +# CHECK_FUNC should accept the path to a candidate program, and +# set $func_check_prog_result if it truncates its output less than +# $_G_path_prog_max characters. +func_path_progs () +{ + _G_progs_list=$1 + _G_check_func=$2 + _G_PATH=${3-"$PATH"} + + _G_path_prog_max=0 + _G_path_prog_found=false + _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} + for _G_dir in $_G_PATH; do + IFS=$_G_save_IFS + test -z "$_G_dir" && _G_dir=. + for _G_prog_name in $_G_progs_list; do + for _exeext in '' .EXE; do + _G_path_prog=$_G_dir/$_G_prog_name$_exeext + func_executable_p "$_G_path_prog" || continue + case `"$_G_path_prog" --version 2>&1` in + *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; + *) $_G_check_func $_G_path_prog + func_path_progs_result=$func_check_prog_result + ;; + esac + $_G_path_prog_found && break 3 + done + done + done + IFS=$_G_save_IFS + test -z "$func_path_progs_result" && { + echo "no acceptable sed could be found in \$PATH" >&2 + exit 1 + } +} + + +# We want to be able to use the functions in this file before configure +# has figured out where the best binaries are kept, which means we have +# to search for them ourselves - except when the results are already set +# where we skip the searches. + +# Unless the user overrides by setting SED, search the path for either GNU +# sed, or the sed that truncates its output the least. +test -z "$SED" && { + _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ + for _G_i in 1 2 3 4 5 6 7; do + _G_sed_script=$_G_sed_script$nl$_G_sed_script + done + echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed + _G_sed_script= + + func_check_prog_sed () + { + _G_path_prog=$1 + + _G_count=0 + printf 0123456789 >conftest.in + while : + do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo '' >> conftest.nl + "$_G_path_prog" -f conftest.sed conftest.out 2>/dev/null || break + diff conftest.out conftest.nl >/dev/null 2>&1 || break + _G_count=`expr $_G_count + 1` + if test "$_G_count" -gt "$_G_path_prog_max"; then + # Best one so far, save it but keep looking for a better one + func_check_prog_result=$_G_path_prog + _G_path_prog_max=$_G_count + fi + # 10*(2^10) chars as input seems more than enough + test 10 -lt "$_G_count" && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out + } + + func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin + rm -f conftest.sed + SED=$func_path_progs_result +} + + +# Unless the user overrides by setting GREP, search the path for either GNU +# grep, or the grep that truncates its output the least. +test -z "$GREP" && { + func_check_prog_grep () + { + _G_path_prog=$1 + + _G_count=0 + _G_path_prog_max=0 + printf 0123456789 >conftest.in + while : + do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo 'GREP' >> conftest.nl + "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' conftest.out 2>/dev/null || break + diff conftest.out conftest.nl >/dev/null 2>&1 || break + _G_count=`expr $_G_count + 1` + if test "$_G_count" -gt "$_G_path_prog_max"; then + # Best one so far, save it but keep looking for a better one + func_check_prog_result=$_G_path_prog + _G_path_prog_max=$_G_count + fi + # 10*(2^10) chars as input seems more than enough + test 10 -lt "$_G_count" && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out + } + + func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin + GREP=$func_path_progs_result +} + + +## ------------------------------- ## +## User overridable command paths. ## +## ------------------------------- ## + +# All uppercase variable names are used for environment variables. These +# variables can be overridden by the user before calling a script that +# uses them if a suitable command of that name is not already available +# in the command search PATH. + +: ${CP="cp -f"} +: ${ECHO="printf %s\n"} +: ${EGREP="$GREP -E"} +: ${FGREP="$GREP -F"} +: ${LN_S="ln -s"} +: ${MAKE="make"} +: ${MKDIR="mkdir"} +: ${MV="mv -f"} +: ${RM="rm -f"} +: ${SHELL="${CONFIG_SHELL-/bin/sh}"} + + +## -------------------- ## +## Useful sed snippets. ## +## -------------------- ## + +sed_dirname='s|/[^/]*$||' +sed_basename='s|^.*/||' + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s|\([`"$\\]\)|\\\1|g' + +# Same as above, but do not quote variable references. +sed_double_quote_subst='s/\(["`\\]\)/\\\1/g' + +# Sed substitution that turns a string into a regex matching for the +# string literally. +sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' + +# Sed substitution that converts a w32 file name or path +# that contains forward slashes, into one that contains +# (escaped) backslashes. A very naive implementation. +sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' + +# Re-'\' parameter expansions in output of sed_double_quote_subst that +# were '\'-ed in input to the same. If an odd number of '\' preceded a +# '$' in input to sed_double_quote_subst, that '$' was protected from +# expansion. Since each input '\' is now two '\'s, look for any number +# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. +_G_bs='\\' +_G_bs2='\\\\' +_G_bs4='\\\\\\\\' +_G_dollar='\$' +sed_double_backslash="\ + s/$_G_bs4/&\\ +/g + s/^$_G_bs2$_G_dollar/$_G_bs&/ + s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g + s/\n//g" + + +## ----------------- ## +## Global variables. ## +## ----------------- ## + +# Except for the global variables explicitly listed below, the following +# functions in the '^func_' namespace, and the '^require_' namespace +# variables initialised in the 'Resource management' section, sourcing +# this file will not pollute your global namespace with anything +# else. There's no portable way to scope variables in Bourne shell +# though, so actually running these functions will sometimes place +# results into a variable named after the function, and often use +# temporary variables in the '^_G_' namespace. If you are careful to +# avoid using those namespaces casually in your sourcing script, things +# should continue to work as you expect. And, of course, you can freely +# overwrite any of the functions or variables defined here before +# calling anything to customize them. + +EXIT_SUCCESS=0 +EXIT_FAILURE=1 +EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. +EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. + +# Allow overriding, eg assuming that you follow the convention of +# putting '$debug_cmd' at the start of all your functions, you can get +# bash to show function call trace with: +# +# debug_cmd='echo "${FUNCNAME[0]} $*" >&2' bash your-script-name +debug_cmd=${debug_cmd-":"} +exit_cmd=: + +# By convention, finish your script with: +# +# exit $exit_status +# +# so that you can set exit_status to non-zero if you want to indicate +# something went wrong during execution without actually bailing out at +# the point of failure. +exit_status=$EXIT_SUCCESS # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. -progpath="$0" +progpath=$0 + +# The name of this program. +progname=`$ECHO "$progpath" |$SED "$sed_basename"` + +# Make sure we have an absolute progpath for reexecution: +case $progpath in + [\\/]*|[A-Za-z]:\\*) ;; + *[\\/]*) + progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` + progdir=`cd "$progdir" && pwd` + progpath=$progdir/$progname + ;; + *) + _G_IFS=$IFS + IFS=${PATH_SEPARATOR-:} + for progdir in $PATH; do + IFS=$_G_IFS + test -x "$progdir/$progname" && break + done + IFS=$_G_IFS + test -n "$progdir" || progdir=`pwd` + progpath=$progdir/$progname + ;; +esac +## ----------------- ## +## Standard options. ## +## ----------------- ## -: ${CP="cp -f"} -test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} -: ${MAKE="make"} -: ${MKDIR="mkdir"} -: ${MV="mv -f"} -: ${RM="rm -f"} -: ${SHELL="${CONFIG_SHELL-/bin/sh}"} -: ${Xsed="$SED -e 1s/^X//"} +# The following options affect the operation of the functions defined +# below, and should be set appropriately depending on run-time para- +# meters passed on the command line. -# Global variables: -EXIT_SUCCESS=0 -EXIT_FAILURE=1 -EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. -EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. +opt_dry_run=false +opt_quiet=false +opt_verbose=false -exit_status=$EXIT_SUCCESS +# Categories 'all' and 'none' are always available. Append any others +# you will pass as the first argument to func_warning from your own +# code. +warning_categories= -# Make sure IFS has a sensible default -lt_nl=' -' -IFS=" $lt_nl" +# By default, display warnings according to 'opt_warning_types'. Set +# 'warning_func' to ':' to elide all warnings, or func_fatal_error to +# treat the next displayed warning as a fatal error. +warning_func=func_warn_and_continue -dirname="s,/[^/]*$,," -basename="s,^.*/,," +# Set to 'all' to display all warnings, 'none' to suppress all +# warnings, or a space delimited list of some subset of +# 'warning_categories' to display only the listed warnings. +opt_warning_types=all -# func_dirname file append nondir_replacement + +## -------------------- ## +## Resource management. ## +## -------------------- ## + +# This section contains definitions for functions that each ensure a +# particular resource (a file, or a non-empty configuration variable for +# example) is available, and if appropriate to extract default values +# from pertinent package files. Call them using their associated +# 'require_*' variable to ensure that they are executed, at most, once. +# +# It's entirely deliberate that calling these functions can set +# variables that don't obey the namespace limitations obeyed by the rest +# of this file, in order that that they be as useful as possible to +# callers. + + +# require_term_colors +# ------------------- +# Allow display of bold text on terminals that support it. +require_term_colors=func_require_term_colors +func_require_term_colors () +{ + $debug_cmd + + test -t 1 && { + # COLORTERM and USE_ANSI_COLORS environment variables take + # precedence, because most terminfo databases neglect to describe + # whether color sequences are supported. + test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} + + if test 1 = "$USE_ANSI_COLORS"; then + # Standard ANSI escape sequences + tc_reset='' + tc_bold=''; tc_standout='' + tc_red=''; tc_green='' + tc_blue=''; tc_cyan='' + else + # Otherwise trust the terminfo database after all. + test -n "`tput sgr0 2>/dev/null`" && { + tc_reset=`tput sgr0` + test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` + tc_standout=$tc_bold + test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` + test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` + test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` + test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` + test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` + } + fi + } + + require_term_colors=: +} + + +## ----------------- ## +## Function library. ## +## ----------------- ## + +# This section contains a variety of useful functions to call in your +# scripts. Take note of the portable wrappers for features provided by +# some modern shells, which will fall back to slower equivalents on +# less featureful shells. + + +# func_append VAR VALUE +# --------------------- +# Append VALUE onto the existing contents of VAR. + + # We should try to minimise forks, especially on Windows where they are + # unreasonably slow, so skip the feature probes when bash or zsh are + # being used: + if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then + : ${_G_HAVE_ARITH_OP="yes"} + : ${_G_HAVE_XSI_OPS="yes"} + # The += operator was introduced in bash 3.1 + case $BASH_VERSION in + [12].* | 3.0 | 3.0*) ;; + *) + : ${_G_HAVE_PLUSEQ_OP="yes"} + ;; + esac + fi + + # _G_HAVE_PLUSEQ_OP + # Can be empty, in which case the shell is probed, "yes" if += is + # useable or anything else if it does not work. + test -z "$_G_HAVE_PLUSEQ_OP" \ + && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ + && _G_HAVE_PLUSEQ_OP=yes + +if test yes = "$_G_HAVE_PLUSEQ_OP" +then + # This is an XSI compatible shell, allowing a faster implementation... + eval 'func_append () + { + $debug_cmd + + eval "$1+=\$2" + }' +else + # ...otherwise fall back to using expr, which is often a shell builtin. + func_append () + { + $debug_cmd + + eval "$1=\$$1\$2" + } +fi + + +# func_append_quoted VAR VALUE +# ---------------------------- +# Quote VALUE and append to the end of shell variable VAR, separated +# by a space. +if test yes = "$_G_HAVE_PLUSEQ_OP"; then + eval 'func_append_quoted () + { + $debug_cmd + + func_quote_for_eval "$2" + eval "$1+=\\ \$func_quote_for_eval_result" + }' +else + func_append_quoted () + { + $debug_cmd + + func_quote_for_eval "$2" + eval "$1=\$$1\\ \$func_quote_for_eval_result" + } +fi + + +# func_append_uniq VAR VALUE +# -------------------------- +# Append unique VALUE onto the existing contents of VAR, assuming +# entries are delimited by the first character of VALUE. For example: +# +# func_append_uniq options " --another-option option-argument" +# +# will only append to $options if " --another-option option-argument " +# is not already present somewhere in $options already (note spaces at +# each end implied by leading space in second argument). +func_append_uniq () +{ + $debug_cmd + + eval _G_current_value='`$ECHO $'$1'`' + _G_delim=`expr "$2" : '\(.\)'` + + case $_G_delim$_G_current_value$_G_delim in + *"$2$_G_delim"*) ;; + *) func_append "$@" ;; + esac +} + + +# func_arith TERM... +# ------------------ +# Set func_arith_result to the result of evaluating TERMs. + test -z "$_G_HAVE_ARITH_OP" \ + && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ + && _G_HAVE_ARITH_OP=yes + +if test yes = "$_G_HAVE_ARITH_OP"; then + eval 'func_arith () + { + $debug_cmd + + func_arith_result=$(( $* )) + }' +else + func_arith () + { + $debug_cmd + + func_arith_result=`expr "$@"` + } +fi + + +# func_basename FILE +# ------------------ +# Set func_basename_result to FILE with everything up to and including +# the last / stripped. +if test yes = "$_G_HAVE_XSI_OPS"; then + # If this shell supports suffix pattern removal, then use it to avoid + # forking. Hide the definitions single quotes in case the shell chokes + # on unsupported syntax... + _b='func_basename_result=${1##*/}' + _d='case $1 in + */*) func_dirname_result=${1%/*}$2 ;; + * ) func_dirname_result=$3 ;; + esac' + +else + # ...otherwise fall back to using sed. + _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' + _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` + if test "X$func_dirname_result" = "X$1"; then + func_dirname_result=$3 + else + func_append func_dirname_result "$2" + fi' +fi + +eval 'func_basename () +{ + $debug_cmd + + '"$_b"' +}' + + +# func_dirname FILE APPEND NONDIR_REPLACEMENT +# ------------------------------------------- # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. -func_dirname () +eval 'func_dirname () { - func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi -} # func_dirname may be replaced by extended shell implementation + $debug_cmd + + '"$_d"' +}' -# func_basename file -func_basename () -{ - func_basename_result=`$ECHO "${1}" | $SED "$basename"` -} # func_basename may be replaced by extended shell implementation - - -# func_dirname_and_basename file append nondir_replacement -# perform func_basename and func_dirname in a single function +# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT +# -------------------------------------------------------- +# Perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result @@ -190,263 +697,327 @@ func_basename () # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" -# Implementation must be kept synchronized with func_dirname -# and func_basename. For efficiency, we do not delegate to -# those functions but instead duplicate the functionality here. -func_dirname_and_basename () +# For efficiency, we do not delegate to the functions above but instead +# duplicate the functionality here. +eval 'func_dirname_and_basename () { - # Extract subdirectory from the argument. - func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" + $debug_cmd + + '"$_b"' + '"$_d"' +}' + + +# func_echo ARG... +# ---------------- +# Echo program name prefixed message. +func_echo () +{ + $debug_cmd + + _G_message=$* + + func_echo_IFS=$IFS + IFS=$nl + for _G_line in $_G_message; do + IFS=$func_echo_IFS + $ECHO "$progname: $_G_line" + done + IFS=$func_echo_IFS +} + + +# func_echo_all ARG... +# -------------------- +# Invoke $ECHO with all args, space-separated. +func_echo_all () +{ + $ECHO "$*" +} + + +# func_echo_infix_1 INFIX ARG... +# ------------------------------ +# Echo program name, followed by INFIX on the first line, with any +# additional lines not showing INFIX. +func_echo_infix_1 () +{ + $debug_cmd + + $require_term_colors + + _G_infix=$1; shift + _G_indent=$_G_infix + _G_prefix="$progname: $_G_infix: " + _G_message=$* + + # Strip color escape sequences before counting printable length + for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" + do + test -n "$_G_tc" && { + _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` + _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` + } + done + _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes + + func_echo_infix_1_IFS=$IFS + IFS=$nl + for _G_line in $_G_message; do + IFS=$func_echo_infix_1_IFS + $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 + _G_prefix=$_G_indent + done + IFS=$func_echo_infix_1_IFS +} + + +# func_error ARG... +# ----------------- +# Echo program name prefixed message to standard error. +func_error () +{ + $debug_cmd + + $require_term_colors + + func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 +} + + +# func_fatal_error ARG... +# ----------------------- +# Echo program name prefixed message to standard error, and exit. +func_fatal_error () +{ + $debug_cmd + + func_error "$*" + exit $EXIT_FAILURE +} + + +# func_grep EXPRESSION FILENAME +# ----------------------------- +# Check whether EXPRESSION matches any line of FILENAME, without output. +func_grep () +{ + $debug_cmd + + $GREP "$1" "$2" >/dev/null 2>&1 +} + + +# func_len STRING +# --------------- +# Set func_len_result to the length of STRING. STRING may not +# start with a hyphen. + test -z "$_G_HAVE_XSI_OPS" \ + && (eval 'x=a/b/c; + test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ + && _G_HAVE_XSI_OPS=yes + +if test yes = "$_G_HAVE_XSI_OPS"; then + eval 'func_len () + { + $debug_cmd + + func_len_result=${#1} + }' +else + func_len () + { + $debug_cmd + + func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` + } +fi + + +# func_mkdir_p DIRECTORY-PATH +# --------------------------- +# Make sure the entire path to DIRECTORY-PATH is available. +func_mkdir_p () +{ + $debug_cmd + + _G_directory_path=$1 + _G_dir_list= + + if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then + + # Protect directory names starting with '-' + case $_G_directory_path in + -*) _G_directory_path=./$_G_directory_path ;; + esac + + # While some portion of DIR does not yet exist... + while test ! -d "$_G_directory_path"; do + # ...make a list in topmost first order. Use a colon delimited + # list incase some portion of path contains whitespace. + _G_dir_list=$_G_directory_path:$_G_dir_list + + # If the last portion added has no slash in it, the list is done + case $_G_directory_path in */*) ;; *) break ;; esac + + # ...otherwise throw away the child directory and loop + _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` + done + _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` + + func_mkdir_p_IFS=$IFS; IFS=: + for _G_dir in $_G_dir_list; do + IFS=$func_mkdir_p_IFS + # mkdir can fail with a 'File exist' error if two processes + # try to create one of the directories concurrently. Don't + # stop in that case! + $MKDIR "$_G_dir" 2>/dev/null || : + done + IFS=$func_mkdir_p_IFS + + # Bail out if we (or some other process) failed to create a directory. + test -d "$_G_directory_path" || \ + func_fatal_error "Failed to create '$1'" fi - func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` -} # func_dirname_and_basename may be replaced by extended shell implementation +} -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -# func_strip_suffix prefix name -func_stripname () +# func_mktempdir [BASENAME] +# ------------------------- +# Make a temporary directory that won't clash with other running +# libtool processes, and avoids race conditions if possible. If +# given, BASENAME is the basename for that directory. +func_mktempdir () { - case ${2} in - .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; - esac -} # func_stripname may be replaced by extended shell implementation + $debug_cmd + _G_template=${TMPDIR-/tmp}/${1-$progname} + + if test : = "$opt_dry_run"; then + # Return a directory name, but don't create it in dry-run mode + _G_tmpdir=$_G_template-$$ + else + + # If mktemp works, use that first and foremost + _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` + + if test ! -d "$_G_tmpdir"; then + # Failing that, at least try and use $RANDOM to avoid a race + _G_tmpdir=$_G_template-${RANDOM-0}$$ + + func_mktempdir_umask=`umask` + umask 0077 + $MKDIR "$_G_tmpdir" + umask $func_mktempdir_umask + fi + + # If we're not in dry-run mode, bomb out on failure + test -d "$_G_tmpdir" || \ + func_fatal_error "cannot create temporary directory '$_G_tmpdir'" + fi + + $ECHO "$_G_tmpdir" +} -# These SED scripts presuppose an absolute path with a trailing slash. -pathcar='s,^/\([^/]*\).*$,\1,' -pathcdr='s,^/[^/]*,,' -removedotparts=':dotsl - s@/\./@/@g - t dotsl - s,/\.$,/,' -collapseslashes='s@/\{1,\}@/@g' -finalslash='s,/*$,/,' # func_normal_abspath PATH +# ------------------------ # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. -# value returned in "$func_normal_abspath_result" func_normal_abspath () { - # Start from root dir and reassemble the path. - func_normal_abspath_result= - func_normal_abspath_tpath=$1 - func_normal_abspath_altnamespace= - case $func_normal_abspath_tpath in - "") - # Empty path, that just means $cwd. - func_stripname '' '/' "`pwd`" - func_normal_abspath_result=$func_stripname_result - return - ;; - # The next three entries are used to spot a run of precisely - # two leading slashes without using negated character classes; - # we take advantage of case's first-match behaviour. - ///*) - # Unusual form of absolute path, do nothing. - ;; - //*) - # Not necessarily an ordinary path; POSIX reserves leading '//' - # and for example Cygwin uses it to access remote file shares - # over CIFS/SMB, so we conserve a leading double slash if found. - func_normal_abspath_altnamespace=/ - ;; - /*) - # Absolute path, do nothing. - ;; - *) - # Relative path, prepend $cwd. - func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath - ;; - esac - # Cancel out all the simple stuff to save iterations. We also want - # the path to end with a slash for ease of parsing, so make sure - # there is one (and only one) here. - func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` - while :; do - # Processed it all yet? - if test "$func_normal_abspath_tpath" = / ; then - # If we ascended to the root using ".." the result may be empty now. - if test -z "$func_normal_abspath_result" ; then - func_normal_abspath_result=/ - fi - break - fi - func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$pathcar"` - func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$pathcdr"` - # Figure out what to do with it - case $func_normal_abspath_tcomponent in + $debug_cmd + + # These SED scripts presuppose an absolute path with a trailing slash. + _G_pathcar='s|^/\([^/]*\).*$|\1|' + _G_pathcdr='s|^/[^/]*||' + _G_removedotparts=':dotsl + s|/\./|/|g + t dotsl + s|/\.$|/|' + _G_collapseslashes='s|/\{1,\}|/|g' + _G_finalslash='s|/*$|/|' + + # Start from root dir and reassemble the path. + func_normal_abspath_result= + func_normal_abspath_tpath=$1 + func_normal_abspath_altnamespace= + case $func_normal_abspath_tpath in "") - # Trailing empty path component, ignore it. - ;; - ..) - # Parent dir; strip last assembled component from result. - func_dirname "$func_normal_abspath_result" - func_normal_abspath_result=$func_dirname_result - ;; - *) - # Actual path component, append it. - func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent - ;; - esac - done - # Restore leading double-slash if one was found on entry. - func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result -} - -# func_relative_path SRCDIR DSTDIR -# generates a relative path from SRCDIR to DSTDIR, with a trailing -# slash if non-empty, suitable for immediately appending a filename -# without needing to append a separator. -# value returned in "$func_relative_path_result" -func_relative_path () -{ - func_relative_path_result= - func_normal_abspath "$1" - func_relative_path_tlibdir=$func_normal_abspath_result - func_normal_abspath "$2" - func_relative_path_tbindir=$func_normal_abspath_result - - # Ascend the tree starting from libdir - while :; do - # check if we have found a prefix of bindir - case $func_relative_path_tbindir in - $func_relative_path_tlibdir) - # found an exact match - func_relative_path_tcancelled= - break + # Empty path, that just means $cwd. + func_stripname '' '/' "`pwd`" + func_normal_abspath_result=$func_stripname_result + return ;; - $func_relative_path_tlibdir*) - # found a matching prefix - func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" - func_relative_path_tcancelled=$func_stripname_result - if test -z "$func_relative_path_result"; then - func_relative_path_result=. - fi - break + # The next three entries are used to spot a run of precisely + # two leading slashes without using negated character classes; + # we take advantage of case's first-match behaviour. + ///*) + # Unusual form of absolute path, do nothing. + ;; + //*) + # Not necessarily an ordinary path; POSIX reserves leading '//' + # and for example Cygwin uses it to access remote file shares + # over CIFS/SMB, so we conserve a leading double slash if found. + func_normal_abspath_altnamespace=/ + ;; + /*) + # Absolute path, do nothing. ;; *) - func_dirname $func_relative_path_tlibdir - func_relative_path_tlibdir=${func_dirname_result} - if test "x$func_relative_path_tlibdir" = x ; then - # Have to descend all the way to the root! - func_relative_path_result=../$func_relative_path_result - func_relative_path_tcancelled=$func_relative_path_tbindir - break - fi - func_relative_path_result=../$func_relative_path_result + # Relative path, prepend $cwd. + func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac - done - # Now calculate path; take care to avoid doubling-up slashes. - func_stripname '' '/' "$func_relative_path_result" - func_relative_path_result=$func_stripname_result - func_stripname '/' '/' "$func_relative_path_tcancelled" - if test "x$func_stripname_result" != x ; then - func_relative_path_result=${func_relative_path_result}/${func_stripname_result} - fi - - # Normalisation. If bindir is libdir, return empty string, - # else relative path ending with a slash; either way, target - # file name can be directly appended. - if test ! -z "$func_relative_path_result"; then - func_stripname './' '' "$func_relative_path_result/" - func_relative_path_result=$func_stripname_result - fi + # Cancel out all the simple stuff to save iterations. We also want + # the path to end with a slash for ease of parsing, so make sure + # there is one (and only one) here. + func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ + -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` + while :; do + # Processed it all yet? + if test / = "$func_normal_abspath_tpath"; then + # If we ascended to the root using ".." the result may be empty now. + if test -z "$func_normal_abspath_result"; then + func_normal_abspath_result=/ + fi + break + fi + func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ + -e "$_G_pathcar"` + func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ + -e "$_G_pathcdr"` + # Figure out what to do with it + case $func_normal_abspath_tcomponent in + "") + # Trailing empty path component, ignore it. + ;; + ..) + # Parent dir; strip last assembled component from result. + func_dirname "$func_normal_abspath_result" + func_normal_abspath_result=$func_dirname_result + ;; + *) + # Actual path component, append it. + func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" + ;; + esac + done + # Restore leading double-slash if one was found on entry. + func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } -# The name of this program: -func_dirname_and_basename "$progpath" -progname=$func_basename_result -# Make sure we have an absolute path for reexecution: -case $progpath in - [\\/]*|[A-Za-z]:\\*) ;; - *[\\/]*) - progdir=$func_dirname_result - progdir=`cd "$progdir" && pwd` - progpath="$progdir/$progname" - ;; - *) - save_IFS="$IFS" - IFS=${PATH_SEPARATOR-:} - for progdir in $PATH; do - IFS="$save_IFS" - test -x "$progdir/$progname" && break - done - IFS="$save_IFS" - test -n "$progdir" || progdir=`pwd` - progpath="$progdir/$progname" - ;; -esac - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed="${SED}"' -e 1s/^X//' -sed_quote_subst='s/\([`"$\\]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\(["`\\]\)/\\\1/g' - -# Sed substitution that turns a string into a regex matching for the -# string literally. -sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' - -# Sed substitution that converts a w32 file name or path -# which contains forward slashes, into one that contains -# (escaped) backslashes. A very naive implementation. -lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' - -# Re-`\' parameter expansions in output of double_quote_subst that were -# `\'-ed in input to the same. If an odd number of `\' preceded a '$' -# in input to double_quote_subst, that '$' was protected from expansion. -# Since each input `\' is now two `\'s, look for any number of runs of -# four `\'s followed by two `\'s and then a '$'. `\' that '$'. -bs='\\' -bs2='\\\\' -bs4='\\\\\\\\' -dollar='\$' -sed_double_backslash="\ - s/$bs4/&\\ -/g - s/^$bs2$dollar/$bs&/ - s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g - s/\n//g" - -# Standard options: -opt_dry_run=false -opt_help=false -opt_quiet=false -opt_verbose=false -opt_warning=: - -# func_echo arg... -# Echo program name prefixed message, along with the current mode -# name if it has been set yet. -func_echo () +# func_notquiet ARG... +# -------------------- +# Echo program name prefixed message only when not in quiet mode. +func_notquiet () { - $ECHO "$progname: ${opt_mode+$opt_mode: }$*" -} + $debug_cmd -# func_verbose arg... -# Echo program name prefixed message in verbose mode only. -func_verbose () -{ - $opt_verbose && func_echo ${1+"$@"} + $opt_quiet || func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to @@ -454,450 +1025,1186 @@ func_verbose () : } -# func_echo_all arg... -# Invoke $ECHO with all args, space-separated. -func_echo_all () -{ - $ECHO "$*" -} -# func_error arg... -# Echo program name prefixed message to standard error. -func_error () +# func_relative_path SRCDIR DSTDIR +# -------------------------------- +# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. +func_relative_path () { - $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 -} + $debug_cmd -# func_warning arg... -# Echo program name prefixed warning message to standard error. -func_warning () -{ - $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 + func_relative_path_result= + func_normal_abspath "$1" + func_relative_path_tlibdir=$func_normal_abspath_result + func_normal_abspath "$2" + func_relative_path_tbindir=$func_normal_abspath_result + + # Ascend the tree starting from libdir + while :; do + # check if we have found a prefix of bindir + case $func_relative_path_tbindir in + $func_relative_path_tlibdir) + # found an exact match + func_relative_path_tcancelled= + break + ;; + $func_relative_path_tlibdir*) + # found a matching prefix + func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" + func_relative_path_tcancelled=$func_stripname_result + if test -z "$func_relative_path_result"; then + func_relative_path_result=. + fi + break + ;; + *) + func_dirname $func_relative_path_tlibdir + func_relative_path_tlibdir=$func_dirname_result + if test -z "$func_relative_path_tlibdir"; then + # Have to descend all the way to the root! + func_relative_path_result=../$func_relative_path_result + func_relative_path_tcancelled=$func_relative_path_tbindir + break + fi + func_relative_path_result=../$func_relative_path_result + ;; + esac + done + + # Now calculate path; take care to avoid doubling-up slashes. + func_stripname '' '/' "$func_relative_path_result" + func_relative_path_result=$func_stripname_result + func_stripname '/' '/' "$func_relative_path_tcancelled" + if test -n "$func_stripname_result"; then + func_append func_relative_path_result "/$func_stripname_result" + fi + + # Normalisation. If bindir is libdir, return '.' else relative path. + if test -n "$func_relative_path_result"; then + func_stripname './' '' "$func_relative_path_result" + func_relative_path_result=$func_stripname_result + fi + + test -n "$func_relative_path_result" || func_relative_path_result=. - # bash bug again: : } -# func_fatal_error arg... -# Echo program name prefixed message to standard error, and exit. -func_fatal_error () -{ - func_error ${1+"$@"} - exit $EXIT_FAILURE -} -# func_fatal_help arg... -# Echo program name prefixed message to standard error, followed by -# a help hint, and exit. -func_fatal_help () -{ - func_error ${1+"$@"} - func_fatal_error "$help" -} -help="Try \`$progname --help' for more information." ## default - - -# func_grep expression filename -# Check whether EXPRESSION matches any line of FILENAME, without output. -func_grep () -{ - $GREP "$1" "$2" >/dev/null 2>&1 -} - - -# func_mkdir_p directory-path -# Make sure the entire path to DIRECTORY-PATH is available. -func_mkdir_p () -{ - my_directory_path="$1" - my_dir_list= - - if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then - - # Protect directory names starting with `-' - case $my_directory_path in - -*) my_directory_path="./$my_directory_path" ;; - esac - - # While some portion of DIR does not yet exist... - while test ! -d "$my_directory_path"; do - # ...make a list in topmost first order. Use a colon delimited - # list incase some portion of path contains whitespace. - my_dir_list="$my_directory_path:$my_dir_list" - - # If the last portion added has no slash in it, the list is done - case $my_directory_path in */*) ;; *) break ;; esac - - # ...otherwise throw away the child directory and loop - my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` - done - my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` - - save_mkdir_p_IFS="$IFS"; IFS=':' - for my_dir in $my_dir_list; do - IFS="$save_mkdir_p_IFS" - # mkdir can fail with a `File exist' error if two processes - # try to create one of the directories concurrently. Don't - # stop in that case! - $MKDIR "$my_dir" 2>/dev/null || : - done - IFS="$save_mkdir_p_IFS" - - # Bail out if we (or some other process) failed to create a directory. - test -d "$my_directory_path" || \ - func_fatal_error "Failed to create \`$1'" - fi -} - - -# func_mktempdir [string] -# Make a temporary directory that won't clash with other running -# libtool processes, and avoids race conditions if possible. If -# given, STRING is the basename for that directory. -func_mktempdir () -{ - my_template="${TMPDIR-/tmp}/${1-$progname}" - - if test "$opt_dry_run" = ":"; then - # Return a directory name, but don't create it in dry-run mode - my_tmpdir="${my_template}-$$" - else - - # If mktemp works, use that first and foremost - my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` - - if test ! -d "$my_tmpdir"; then - # Failing that, at least try and use $RANDOM to avoid a race - my_tmpdir="${my_template}-${RANDOM-0}$$" - - save_mktempdir_umask=`umask` - umask 0077 - $MKDIR "$my_tmpdir" - umask $save_mktempdir_umask - fi - - # If we're not in dry-run mode, bomb out on failure - test -d "$my_tmpdir" || \ - func_fatal_error "cannot create temporary directory \`$my_tmpdir'" - fi - - $ECHO "$my_tmpdir" -} - - -# func_quote_for_eval arg -# Aesthetically quote ARG to be evaled later. -# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT -# is double-quoted, suitable for a subsequent eval, whereas -# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters -# which are still active within double quotes backslashified. +# func_quote_for_eval ARG... +# -------------------------- +# Aesthetically quote ARGs to be evaled later. +# This function returns two values: +# i) func_quote_for_eval_result +# double-quoted, suitable for a subsequent eval +# ii) func_quote_for_eval_unquoted_result +# has all characters that are still active within double +# quotes backslashified. func_quote_for_eval () { - case $1 in - *[\\\`\"\$]*) - func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; - *) - func_quote_for_eval_unquoted_result="$1" ;; - esac + $debug_cmd - case $func_quote_for_eval_unquoted_result in - # Double-quote args containing shell metacharacters to delay - # word splitting, command substitution and and variable - # expansion for a subsequent eval. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" - ;; - *) - func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" - esac + func_quote_for_eval_unquoted_result= + func_quote_for_eval_result= + while test 0 -lt $#; do + case $1 in + *[\\\`\"\$]*) + _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; + *) + _G_unquoted_arg=$1 ;; + esac + if test -n "$func_quote_for_eval_unquoted_result"; then + func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" + else + func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" + fi + + case $_G_unquoted_arg in + # Double-quote args containing shell metacharacters to delay + # word splitting, command substitution and variable expansion + # for a subsequent eval. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + _G_quoted_arg=\"$_G_unquoted_arg\" + ;; + *) + _G_quoted_arg=$_G_unquoted_arg + ;; + esac + + if test -n "$func_quote_for_eval_result"; then + func_append func_quote_for_eval_result " $_G_quoted_arg" + else + func_append func_quote_for_eval_result "$_G_quoted_arg" + fi + shift + done } -# func_quote_for_expand arg +# func_quote_for_expand ARG +# ------------------------- # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { + $debug_cmd + case $1 in *[\\\`\"]*) - my_arg=`$ECHO "$1" | $SED \ - -e "$double_quote_subst" -e "$sed_double_backslash"` ;; + _G_arg=`$ECHO "$1" | $SED \ + -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; *) - my_arg="$1" ;; + _G_arg=$1 ;; esac - case $my_arg in + case $_G_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - my_arg="\"$my_arg\"" + _G_arg=\"$_G_arg\" ;; esac - func_quote_for_expand_result="$my_arg" + func_quote_for_expand_result=$_G_arg } -# func_show_eval cmd [fail_exp] -# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is +# func_stripname PREFIX SUFFIX NAME +# --------------------------------- +# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +if test yes = "$_G_HAVE_XSI_OPS"; then + eval 'func_stripname () + { + $debug_cmd + + # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are + # positional parameters, so assign one to ordinary variable first. + func_stripname_result=$3 + func_stripname_result=${func_stripname_result#"$1"} + func_stripname_result=${func_stripname_result%"$2"} + }' +else + func_stripname () + { + $debug_cmd + + case $2 in + .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; + *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; + esac + } +fi + + +# func_show_eval CMD [FAIL_EXP] +# ----------------------------- +# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { - my_cmd="$1" - my_fail_exp="${2-:}" + $debug_cmd - ${opt_silent-false} || { - func_quote_for_expand "$my_cmd" - eval "func_echo $func_quote_for_expand_result" - } + _G_cmd=$1 + _G_fail_exp=${2-':'} - if ${opt_dry_run-false}; then :; else - eval "$my_cmd" - my_status=$? - if test "$my_status" -eq 0; then :; else - eval "(exit $my_status); $my_fail_exp" + func_quote_for_expand "$_G_cmd" + eval "func_notquiet $func_quote_for_expand_result" + + $opt_dry_run || { + eval "$_G_cmd" + _G_status=$? + if test 0 -ne "$_G_status"; then + eval "(exit $_G_status); $_G_fail_exp" fi - fi + } } -# func_show_eval_locale cmd [fail_exp] -# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is +# func_show_eval_locale CMD [FAIL_EXP] +# ------------------------------------ +# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { - my_cmd="$1" - my_fail_exp="${2-:}" + $debug_cmd - ${opt_silent-false} || { - func_quote_for_expand "$my_cmd" + _G_cmd=$1 + _G_fail_exp=${2-':'} + + $opt_quiet || { + func_quote_for_expand "$_G_cmd" eval "func_echo $func_quote_for_expand_result" } - if ${opt_dry_run-false}; then :; else - eval "$lt_user_locale - $my_cmd" - my_status=$? - eval "$lt_safe_locale" - if test "$my_status" -eq 0; then :; else - eval "(exit $my_status); $my_fail_exp" + $opt_dry_run || { + eval "$_G_user_locale + $_G_cmd" + _G_status=$? + eval "$_G_safe_locale" + if test 0 -ne "$_G_status"; then + eval "(exit $_G_status); $_G_fail_exp" fi - fi + } } + # func_tr_sh +# ---------- # Turn $1 into a string suitable for a shell variable name. # Result is stored in $func_tr_sh_result. All characters # not in the set a-zA-Z0-9_ are replaced with '_'. Further, # if $1 begins with a digit, a '_' is prepended as well. func_tr_sh () { - case $1 in - [0-9]* | *[!a-zA-Z0-9_]*) - func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` - ;; - * ) - func_tr_sh_result=$1 - ;; - esac + $debug_cmd + + case $1 in + [0-9]* | *[!a-zA-Z0-9_]*) + func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` + ;; + * ) + func_tr_sh_result=$1 + ;; + esac } -# func_version -# Echo version message to standard output and exit. -func_version () +# func_verbose ARG... +# ------------------- +# Echo program name prefixed message in verbose mode only. +func_verbose () { - $opt_debug + $debug_cmd - $SED -n '/(C)/!b go - :more - /\./!{ - N - s/\n# / / - b more - } - :go - /^# '$PROGRAM' (GNU /,/# warranty; / { - s/^# // - s/^# *$// - s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ - p - }' < "$progpath" - exit $? + $opt_verbose && func_echo "$*" + + : } -# func_usage -# Echo short help message to standard output and exit. -func_usage () + +# func_warn_and_continue ARG... +# ----------------------------- +# Echo program name prefixed warning message to standard error. +func_warn_and_continue () { - $opt_debug + $debug_cmd - $SED -n '/^# Usage:/,/^# *.*--help/ { - s/^# // - s/^# *$// - s/\$progname/'$progname'/ - p - }' < "$progpath" - echo - $ECHO "run \`$progname --help | more' for full usage" - exit $? + $require_term_colors + + func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 } -# func_help [NOEXIT] -# Echo long help message to standard output and exit, -# unless 'noexit' is passed as argument. + +# func_warning CATEGORY ARG... +# ---------------------------- +# Echo program name prefixed warning message to standard error. Warning +# messages can be filtered according to CATEGORY, where this function +# elides messages where CATEGORY is not listed in the global variable +# 'opt_warning_types'. +func_warning () +{ + $debug_cmd + + # CATEGORY must be in the warning_categories list! + case " $warning_categories " in + *" $1 "*) ;; + *) func_internal_error "invalid warning category '$1'" ;; + esac + + _G_category=$1 + shift + + case " $opt_warning_types " in + *" $_G_category "*) $warning_func ${1+"$@"} ;; + esac +} + + +# func_sort_ver VER1 VER2 +# ----------------------- +# 'sort -V' is not generally available. +# Note this deviates from the version comparison in automake +# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a +# but this should suffice as we won't be specifying old +# version formats or redundant trailing .0 in bootstrap.conf. +# If we did want full compatibility then we should probably +# use m4_version_compare from autoconf. +func_sort_ver () +{ + $debug_cmd + + printf '%s\n%s\n' "$1" "$2" \ + | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n +} + +# func_lt_ver PREV CURR +# --------------------- +# Return true if PREV and CURR are in the correct order according to +# func_sort_ver, otherwise false. Use it like this: +# +# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." +func_lt_ver () +{ + $debug_cmd + + test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` +} + + +# Local variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" +# time-stamp-time-zone: "UTC" +# End: +#! /bin/sh + +# Set a version string for this script. +scriptversion=2015-10-07.11; # UTC + +# A portable, pluggable option parser for Bourne shell. +# Written by Gary V. Vaughan, 2010 + +# Copyright (C) 2010-2015 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Please report bugs or propose patches to gary@gnu.org. + + +## ------ ## +## Usage. ## +## ------ ## + +# This file is a library for parsing options in your shell scripts along +# with assorted other useful supporting features that you can make use +# of too. +# +# For the simplest scripts you might need only: +# +# #!/bin/sh +# . relative/path/to/funclib.sh +# . relative/path/to/options-parser +# scriptversion=1.0 +# func_options ${1+"$@"} +# eval set dummy "$func_options_result"; shift +# ...rest of your script... +# +# In order for the '--version' option to work, you will need to have a +# suitably formatted comment like the one at the top of this file +# starting with '# Written by ' and ending with '# warranty; '. +# +# For '-h' and '--help' to work, you will also need a one line +# description of your script's purpose in a comment directly above the +# '# Written by ' line, like the one at the top of this file. +# +# The default options also support '--debug', which will turn on shell +# execution tracing (see the comment above debug_cmd below for another +# use), and '--verbose' and the func_verbose function to allow your script +# to display verbose messages only when your user has specified +# '--verbose'. +# +# After sourcing this file, you can plug processing for additional +# options by amending the variables from the 'Configuration' section +# below, and following the instructions in the 'Option parsing' +# section further down. + +## -------------- ## +## Configuration. ## +## -------------- ## + +# You should override these variables in your script after sourcing this +# file so that they reflect the customisations you have added to the +# option parser. + +# The usage line for option parsing errors and the start of '-h' and +# '--help' output messages. You can embed shell variables for delayed +# expansion at the time the message is displayed, but you will need to +# quote other shell meta-characters carefully to prevent them being +# expanded when the contents are evaled. +usage='$progpath [OPTION]...' + +# Short help message in response to '-h' and '--help'. Add to this or +# override it after sourcing this library to reflect the full set of +# options your script accepts. +usage_message="\ + --debug enable verbose shell tracing + -W, --warnings=CATEGORY + report the warnings falling in CATEGORY [all] + -v, --verbose verbosely report processing + --version print version information and exit + -h, --help print short or long help message and exit +" + +# Additional text appended to 'usage_message' in response to '--help'. +long_help_message=" +Warning categories include: + 'all' show all warnings + 'none' turn off all the warnings + 'error' warnings are treated as fatal errors" + +# Help message printed before fatal option parsing errors. +fatal_help="Try '\$progname --help' for more information." + + + +## ------------------------- ## +## Hook function management. ## +## ------------------------- ## + +# This section contains functions for adding, removing, and running hooks +# to the main code. A hook is just a named list of of function, that can +# be run in order later on. + +# func_hookable FUNC_NAME +# ----------------------- +# Declare that FUNC_NAME will run hooks added with +# 'func_add_hook FUNC_NAME ...'. +func_hookable () +{ + $debug_cmd + + func_append hookable_fns " $1" +} + + +# func_add_hook FUNC_NAME HOOK_FUNC +# --------------------------------- +# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must +# first have been declared "hookable" by a call to 'func_hookable'. +func_add_hook () +{ + $debug_cmd + + case " $hookable_fns " in + *" $1 "*) ;; + *) func_fatal_error "'$1' does not accept hook functions." ;; + esac + + eval func_append ${1}_hooks '" $2"' +} + + +# func_remove_hook FUNC_NAME HOOK_FUNC +# ------------------------------------ +# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. +func_remove_hook () +{ + $debug_cmd + + eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' +} + + +# func_run_hooks FUNC_NAME [ARG]... +# --------------------------------- +# Run all hook functions registered to FUNC_NAME. +# It is assumed that the list of hook functions contains nothing more +# than a whitespace-delimited list of legal shell function names, and +# no effort is wasted trying to catch shell meta-characters or preserve +# whitespace. +func_run_hooks () +{ + $debug_cmd + + _G_rc_run_hooks=false + + case " $hookable_fns " in + *" $1 "*) ;; + *) func_fatal_error "'$1' does not support hook funcions.n" ;; + esac + + eval _G_hook_fns=\$$1_hooks; shift + + for _G_hook in $_G_hook_fns; do + if eval $_G_hook '"$@"'; then + # store returned options list back into positional + # parameters for next 'cmd' execution. + eval _G_hook_result=\$${_G_hook}_result + eval set dummy "$_G_hook_result"; shift + _G_rc_run_hooks=: + fi + done + + $_G_rc_run_hooks && func_run_hooks_result=$_G_hook_result +} + + + +## --------------- ## +## Option parsing. ## +## --------------- ## + +# In order to add your own option parsing hooks, you must accept the +# full positional parameter list in your hook function, you may remove/edit +# any options that you action, and then pass back the remaining unprocessed +# options in '_result', escaped suitably for +# 'eval'. In this case you also must return $EXIT_SUCCESS to let the +# hook's caller know that it should pay attention to +# '_result'. Returning $EXIT_FAILURE signalizes that +# arguments are left untouched by the hook and therefore caller will ignore the +# result variable. +# +# Like this: +# +# my_options_prep () +# { +# $debug_cmd +# +# # Extend the existing usage message. +# usage_message=$usage_message' +# -s, --silent don'\''t print informational messages +# ' +# # No change in '$@' (ignored completely by this hook). There is +# # no need to do the equivalent (but slower) action: +# # func_quote_for_eval ${1+"$@"} +# # my_options_prep_result=$func_quote_for_eval_result +# false +# } +# func_add_hook func_options_prep my_options_prep +# +# +# my_silent_option () +# { +# $debug_cmd +# +# args_changed=false +# +# # Note that for efficiency, we parse as many options as we can +# # recognise in a loop before passing the remainder back to the +# # caller on the first unrecognised argument we encounter. +# while test $# -gt 0; do +# opt=$1; shift +# case $opt in +# --silent|-s) opt_silent=: +# args_changed=: +# ;; +# # Separate non-argument short options: +# -s*) func_split_short_opt "$_G_opt" +# set dummy "$func_split_short_opt_name" \ +# "-$func_split_short_opt_arg" ${1+"$@"} +# shift +# args_changed=: +# ;; +# *) # Make sure the first unrecognised option "$_G_opt" +# # is added back to "$@", we could need that later +# # if $args_changed is true. +# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; +# esac +# done +# +# if $args_changed; then +# func_quote_for_eval ${1+"$@"} +# my_silent_option_result=$func_quote_for_eval_result +# fi +# +# $args_changed +# } +# func_add_hook func_parse_options my_silent_option +# +# +# my_option_validation () +# { +# $debug_cmd +# +# $opt_silent && $opt_verbose && func_fatal_help "\ +# '--silent' and '--verbose' options are mutually exclusive." +# +# false +# } +# func_add_hook func_validate_options my_option_validation +# +# You'll also need to manually amend $usage_message to reflect the extra +# options you parse. It's preferable to append if you can, so that +# multiple option parsing hooks can be added safely. + + +# func_options_finish [ARG]... +# ---------------------------- +# Finishing the option parse loop (call 'func_options' hooks ATM). +func_options_finish () +{ + $debug_cmd + + _G_func_options_finish_exit=false + if func_run_hooks func_options ${1+"$@"}; then + func_options_finish_result=$func_run_hooks_result + _G_func_options_finish_exit=: + fi + + $_G_func_options_finish_exit +} + + +# func_options [ARG]... +# --------------------- +# All the functions called inside func_options are hookable. See the +# individual implementations for details. +func_hookable func_options +func_options () +{ + $debug_cmd + + _G_rc_options=false + + for my_func in options_prep parse_options validate_options options_finish + do + if eval func_$my_func '${1+"$@"}'; then + eval _G_res_var='$'"func_${my_func}_result" + eval set dummy "$_G_res_var" ; shift + _G_rc_options=: + fi + done + + # Save modified positional parameters for caller. As a top-level + # options-parser function we always need to set the 'func_options_result' + # variable (regardless the $_G_rc_options value). + if $_G_rc_options; then + func_options_result=$_G_res_var + else + func_quote_for_eval ${1+"$@"} + func_options_result=$func_quote_for_eval_result + fi + + $_G_rc_options +} + + +# func_options_prep [ARG]... +# -------------------------- +# All initialisations required before starting the option parse loop. +# Note that when calling hook functions, we pass through the list of +# positional parameters. If a hook function modifies that list, and +# needs to propagate that back to rest of this script, then the complete +# modified list must be put in 'func_run_hooks_result' before +# returning $EXIT_SUCCESS (otherwise $EXIT_FAILURE is returned). +func_hookable func_options_prep +func_options_prep () +{ + $debug_cmd + + # Option defaults: + opt_verbose=false + opt_warning_types= + + _G_rc_options_prep=false + if func_run_hooks func_options_prep ${1+"$@"}; then + _G_rc_options_prep=: + # save modified positional parameters for caller + func_options_prep_result=$func_run_hooks_result + fi + + $_G_rc_options_prep +} + + +# func_parse_options [ARG]... +# --------------------------- +# The main option parsing loop. +func_hookable func_parse_options +func_parse_options () +{ + $debug_cmd + + func_parse_options_result= + + _G_rc_parse_options=false + # this just eases exit handling + while test $# -gt 0; do + # Defer to hook functions for initial option parsing, so they + # get priority in the event of reusing an option name. + if func_run_hooks func_parse_options ${1+"$@"}; then + eval set dummy "$func_run_hooks_result"; shift + _G_rc_parse_options=: + fi + + # Break out of the loop if we already parsed every option. + test $# -gt 0 || break + + _G_match_parse_options=: + _G_opt=$1 + shift + case $_G_opt in + --debug|-x) debug_cmd='set -x' + func_echo "enabling shell trace mode" + $debug_cmd + ;; + + --no-warnings|--no-warning|--no-warn) + set dummy --warnings none ${1+"$@"} + shift + ;; + + --warnings|--warning|-W) + if test $# = 0 && func_missing_arg $_G_opt; then + _G_rc_parse_options=: + break + fi + case " $warning_categories $1" in + *" $1 "*) + # trailing space prevents matching last $1 above + func_append_uniq opt_warning_types " $1" + ;; + *all) + opt_warning_types=$warning_categories + ;; + *none) + opt_warning_types=none + warning_func=: + ;; + *error) + opt_warning_types=$warning_categories + warning_func=func_fatal_error + ;; + *) + func_fatal_error \ + "unsupported warning category: '$1'" + ;; + esac + shift + ;; + + --verbose|-v) opt_verbose=: ;; + --version) func_version ;; + -\?|-h) func_usage ;; + --help) func_help ;; + + # Separate optargs to long options (plugins may need this): + --*=*) func_split_equals "$_G_opt" + set dummy "$func_split_equals_lhs" \ + "$func_split_equals_rhs" ${1+"$@"} + shift + ;; + + # Separate optargs to short options: + -W*) + func_split_short_opt "$_G_opt" + set dummy "$func_split_short_opt_name" \ + "$func_split_short_opt_arg" ${1+"$@"} + shift + ;; + + # Separate non-argument short options: + -\?*|-h*|-v*|-x*) + func_split_short_opt "$_G_opt" + set dummy "$func_split_short_opt_name" \ + "-$func_split_short_opt_arg" ${1+"$@"} + shift + ;; + + --) _G_rc_parse_options=: ; break ;; + -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; + *) set dummy "$_G_opt" ${1+"$@"}; shift + _G_match_parse_options=false + break + ;; + esac + + $_G_match_parse_options && _G_rc_parse_options=: + done + + + if $_G_rc_parse_options; then + # save modified positional parameters for caller + func_quote_for_eval ${1+"$@"} + func_parse_options_result=$func_quote_for_eval_result + fi + + $_G_rc_parse_options +} + + +# func_validate_options [ARG]... +# ------------------------------ +# Perform any sanity checks on option settings and/or unconsumed +# arguments. +func_hookable func_validate_options +func_validate_options () +{ + $debug_cmd + + _G_rc_validate_options=false + + # Display all warnings if -W was not given. + test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" + + if func_run_hooks func_validate_options ${1+"$@"}; then + # save modified positional parameters for caller + func_validate_options_result=$func_run_hooks_result + _G_rc_validate_options=: + fi + + # Bail if the options were screwed! + $exit_cmd $EXIT_FAILURE + + $_G_rc_validate_options +} + + + +## ----------------- ## +## Helper functions. ## +## ----------------- ## + +# This section contains the helper functions used by the rest of the +# hookable option parser framework in ascii-betical order. + + +# func_fatal_help ARG... +# ---------------------- +# Echo program name prefixed message to standard error, followed by +# a help hint, and exit. +func_fatal_help () +{ + $debug_cmd + + eval \$ECHO \""Usage: $usage"\" + eval \$ECHO \""$fatal_help"\" + func_error ${1+"$@"} + exit $EXIT_FAILURE +} + + +# func_help +# --------- +# Echo long help message to standard output and exit. func_help () { - $opt_debug + $debug_cmd - $SED -n '/^# Usage:/,/# Report bugs to/ { - :print - s/^# // - s/^# *$// - s*\$progname*'$progname'* - s*\$host*'"$host"'* - s*\$SHELL*'"$SHELL"'* - s*\$LTCC*'"$LTCC"'* - s*\$LTCFLAGS*'"$LTCFLAGS"'* - s*\$LD*'"$LD"'* - s/\$with_gnu_ld/'"$with_gnu_ld"'/ - s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ - s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ - p - d - } - /^# .* home page:/b print - /^# General help using/b print - ' < "$progpath" - ret=$? - if test -z "$1"; then - exit $ret - fi + func_usage_message + $ECHO "$long_help_message" + exit 0 } -# func_missing_arg argname + +# func_missing_arg ARGNAME +# ------------------------ # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { - $opt_debug + $debug_cmd - func_error "missing argument for $1." + func_error "Missing argument for '$1'." exit_cmd=exit } -# func_split_short_opt shortopt +# func_split_equals STRING +# ------------------------ +# Set func_split_equals_lhs and func_split_equals_rhs shell variables after +# splitting STRING at the '=' sign. +test -z "$_G_HAVE_XSI_OPS" \ + && (eval 'x=a/b/c; + test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ + && _G_HAVE_XSI_OPS=yes + +if test yes = "$_G_HAVE_XSI_OPS" +then + # This is an XSI compatible shell, allowing a faster implementation... + eval 'func_split_equals () + { + $debug_cmd + + func_split_equals_lhs=${1%%=*} + func_split_equals_rhs=${1#*=} + test "x$func_split_equals_lhs" = "x$1" \ + && func_split_equals_rhs= + }' +else + # ...otherwise fall back to using expr, which is often a shell builtin. + func_split_equals () + { + $debug_cmd + + func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` + func_split_equals_rhs= + test "x$func_split_equals_lhs" = "x$1" \ + || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` + } +fi #func_split_equals + + +# func_split_short_opt SHORTOPT +# ----------------------------- # Set func_split_short_opt_name and func_split_short_opt_arg shell # variables after splitting SHORTOPT after the 2nd character. -func_split_short_opt () +if test yes = "$_G_HAVE_XSI_OPS" +then + # This is an XSI compatible shell, allowing a faster implementation... + eval 'func_split_short_opt () + { + $debug_cmd + + func_split_short_opt_arg=${1#??} + func_split_short_opt_name=${1%"$func_split_short_opt_arg"} + }' +else + # ...otherwise fall back to using expr, which is often a shell builtin. + func_split_short_opt () + { + $debug_cmd + + func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` + func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` + } +fi #func_split_short_opt + + +# func_usage +# ---------- +# Echo short help message to standard output and exit. +func_usage () { - my_sed_short_opt='1s/^\(..\).*$/\1/;q' - my_sed_short_rest='1s/^..\(.*\)$/\1/;q' + $debug_cmd - func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` - func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` -} # func_split_short_opt may be replaced by extended shell implementation + func_usage_message + $ECHO "Run '$progname --help |${PAGER-more}' for full usage" + exit 0 +} -# func_split_long_opt longopt -# Set func_split_long_opt_name and func_split_long_opt_arg shell -# variables after splitting LONGOPT at the `=' sign. -func_split_long_opt () +# func_usage_message +# ------------------ +# Echo short help message to standard output. +func_usage_message () { - my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' - my_sed_long_arg='1s/^--[^=]*=//' + $debug_cmd - func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` - func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` -} # func_split_long_opt may be replaced by extended shell implementation - -exit_cmd=: + eval \$ECHO \""Usage: $usage"\" + echo + $SED -n 's|^# || + /^Written by/{ + x;p;x + } + h + /^Written by/q' < "$progpath" + echo + eval \$ECHO \""$usage_message"\" +} - - - -magic="%%%MAGIC variable%%%" -magic_exe="%%%MAGIC EXE variable%%%" - -# Global variables. -nonopt= -preserve_args= -lo2o="s/\\.lo\$/.${objext}/" -o2lo="s/\\.${objext}\$/.lo/" -extracted_archives= -extracted_serial=0 - -# If this variable is set in any of the actions, the command in it -# will be execed at the end. This prevents here-documents from being -# left over by shells. -exec_cmd= - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () +# func_version +# ------------ +# Echo version message to standard output and exit. +func_version () { - eval "${1}=\$${1}\${2}" -} # func_append may be replaced by extended shell implementation + $debug_cmd -# func_append_quoted var value -# Quote VALUE and append to the end of shell variable VAR, separated -# by a space. -func_append_quoted () + printf '%s\n' "$progname $scriptversion" + $SED -n ' + /(C)/!b go + :more + /\./!{ + N + s|\n# | | + b more + } + :go + /^# Written by /,/# warranty; / { + s|^# || + s|^# *$|| + s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| + p + } + /^# Written by / { + s|^# || + p + } + /^warranty; /q' < "$progpath" + + exit $? +} + + +# Local variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" +# time-stamp-time-zone: "UTC" +# End: + +# Set a version string. +scriptversion='(GNU libtool) 2.4.6' + + +# func_echo ARG... +# ---------------- +# Libtool also displays the current mode in messages, so override +# funclib.sh func_echo with this custom definition. +func_echo () { - func_quote_for_eval "${2}" - eval "${1}=\$${1}\\ \$func_quote_for_eval_result" -} # func_append_quoted may be replaced by extended shell implementation + $debug_cmd + + _G_message=$* + + func_echo_IFS=$IFS + IFS=$nl + for _G_line in $_G_message; do + IFS=$func_echo_IFS + $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" + done + IFS=$func_echo_IFS +} -# func_arith arithmetic-term... -func_arith () +# func_warning ARG... +# ------------------- +# Libtool warnings are not categorized, so override funclib.sh +# func_warning with this simpler definition. +func_warning () { - func_arith_result=`expr "${@}"` -} # func_arith may be replaced by extended shell implementation + $debug_cmd + + $warning_func ${1+"$@"} +} -# func_len string -# STRING may not start with a hyphen. -func_len () +## ---------------- ## +## Options parsing. ## +## ---------------- ## + +# Hook in the functions to make sure our own options are parsed during +# the option parsing loop. + +usage='$progpath [OPTION]... [MODE-ARG]...' + +# Short help message in response to '-h'. +usage_message="Options: + --config show all configuration variables + --debug enable verbose shell tracing + -n, --dry-run display commands without modifying any files + --features display basic configuration information and exit + --mode=MODE use operation mode MODE + --no-warnings equivalent to '-Wnone' + --preserve-dup-deps don't remove duplicate dependency libraries + --quiet, --silent don't print informational messages + --tag=TAG use configuration variables from tag TAG + -v, --verbose print more informational messages than default + --version print version information + -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] + -h, --help, --help-all print short, long, or detailed help message +" + +# Additional text appended to 'usage_message' in response to '--help'. +func_help () { - func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` -} # func_len may be replaced by extended shell implementation + $debug_cmd + + func_usage_message + $ECHO "$long_help_message + +MODE must be one of the following: + + clean remove files from the build directory + compile compile a source file into a libtool object + execute automatically set library path, then run a program + finish complete the installation of libtool libraries + install install libraries or executables + link create a library or an executable + uninstall remove libraries from an installed directory + +MODE-ARGS vary depending on the MODE. When passed as first option, +'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. +Try '$progname --help --mode=MODE' for a more detailed description of MODE. + +When reporting a bug, please describe a test case to reproduce it and +include the following information: + + host-triplet: $host + shell: $SHELL + compiler: $LTCC + compiler flags: $LTCFLAGS + linker: $LD (gnu? $with_gnu_ld) + version: $progname $scriptversion Debian-2.4.6-15 + automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` + autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` + +Report bugs to . +GNU libtool home page: . +General help using GNU software: ." + exit 0 +} -# func_lo2o object -func_lo2o () -{ - func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` -} # func_lo2o may be replaced by extended shell implementation +# func_lo2o OBJECT-NAME +# --------------------- +# Transform OBJECT-NAME from a '.lo' suffix to the platform specific +# object suffix. + +lo2o=s/\\.lo\$/.$objext/ +o2lo=s/\\.$objext\$/.lo/ + +if test yes = "$_G_HAVE_XSI_OPS"; then + eval 'func_lo2o () + { + case $1 in + *.lo) func_lo2o_result=${1%.lo}.$objext ;; + * ) func_lo2o_result=$1 ;; + esac + }' + + # func_xform LIBOBJ-OR-SOURCE + # --------------------------- + # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) + # suffix to a '.lo' libtool-object suffix. + eval 'func_xform () + { + func_xform_result=${1%.*}.lo + }' +else + # ...otherwise fall back to using sed. + func_lo2o () + { + func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` + } + + func_xform () + { + func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` + } +fi -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` -} # func_xform may be replaced by extended shell implementation - - -# func_fatal_configuration arg... +# func_fatal_configuration ARG... +# ------------------------------- # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { - func_error ${1+"$@"} - func_error "See the $PACKAGE documentation for more information." - func_fatal_error "Fatal configuration error." + func__fatal_error ${1+"$@"} \ + "See the $PACKAGE documentation for more information." \ + "Fatal configuration error." } # func_config +# ----------- # Display the configuration for all the tags in this script. func_config () { @@ -915,17 +2222,19 @@ func_config () exit $? } + # func_features +# ------------- # Display the features supported by this script. func_features () { echo "host: $host" - if test "$build_libtool_libs" = yes; then + if test yes = "$build_libtool_libs"; then echo "enable shared libraries" else echo "disable shared libraries" fi - if test "$build_old_libs" = yes; then + if test yes = "$build_old_libs"; then echo "enable static libraries" else echo "disable static libraries" @@ -934,314 +2243,369 @@ func_features () exit $? } -# func_enable_tag tagname + +# func_enable_tag TAGNAME +# ----------------------- # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { - # Global variable: - tagname="$1" + # Global variable: + tagname=$1 - re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" - re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" - sed_extractcf="/$re_begincf/,/$re_endcf/p" + re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" + re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" + sed_extractcf=/$re_begincf/,/$re_endcf/p - # Validate tagname. - case $tagname in - *[!-_A-Za-z0-9,/]*) - func_fatal_error "invalid tag name: $tagname" - ;; - esac + # Validate tagname. + case $tagname in + *[!-_A-Za-z0-9,/]*) + func_fatal_error "invalid tag name: $tagname" + ;; + esac - # Don't test for the "default" C tag, as we know it's - # there but not specially marked. - case $tagname in - CC) ;; + # Don't test for the "default" C tag, as we know it's + # there but not specially marked. + case $tagname in + CC) ;; *) - if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then - taglist="$taglist $tagname" + if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then + taglist="$taglist $tagname" - # Evaluate the configuration. Be careful to quote the path - # and the sed script, to avoid splitting on whitespace, but - # also don't use non-portable quotes within backquotes within - # quotes we have to do it in 2 steps: - extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` - eval "$extractedcf" - else - func_error "ignoring unknown tag $tagname" - fi - ;; - esac + # Evaluate the configuration. Be careful to quote the path + # and the sed script, to avoid splitting on whitespace, but + # also don't use non-portable quotes within backquotes within + # quotes we have to do it in 2 steps: + extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` + eval "$extractedcf" + else + func_error "ignoring unknown tag $tagname" + fi + ;; + esac } + # func_check_version_match +# ------------------------ # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { - if test "$package_revision" != "$macro_revision"; then - if test "$VERSION" != "$macro_version"; then - if test -z "$macro_version"; then - cat >&2 <<_LT_EOF + if test "$package_revision" != "$macro_revision"; then + if test "$VERSION" != "$macro_version"; then + if test -z "$macro_version"; then + cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF - else - cat >&2 <<_LT_EOF + else + cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF - fi - else - cat >&2 <<_LT_EOF + fi + else + cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF - fi + fi - exit $EXIT_MISMATCH - fi + exit $EXIT_MISMATCH + fi } -# Shorthand for --mode=foo, only valid as the first argument -case $1 in -clean|clea|cle|cl) - shift; set dummy --mode clean ${1+"$@"}; shift - ;; -compile|compil|compi|comp|com|co|c) - shift; set dummy --mode compile ${1+"$@"}; shift - ;; -execute|execut|execu|exec|exe|ex|e) - shift; set dummy --mode execute ${1+"$@"}; shift - ;; -finish|finis|fini|fin|fi|f) - shift; set dummy --mode finish ${1+"$@"}; shift - ;; -install|instal|insta|inst|ins|in|i) - shift; set dummy --mode install ${1+"$@"}; shift - ;; -link|lin|li|l) - shift; set dummy --mode link ${1+"$@"}; shift - ;; -uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) - shift; set dummy --mode uninstall ${1+"$@"}; shift - ;; -esac - - - -# Option defaults: -opt_debug=: -opt_dry_run=false -opt_config=false -opt_preserve_dup_deps=false -opt_features=false -opt_finish=false -opt_help=false -opt_help_all=false -opt_silent=: -opt_warning=: -opt_verbose=: -opt_silent=false -opt_verbose=false - - -# Parse options once, thoroughly. This comes as soon as possible in the -# script to make things like `--version' happen as quickly as we can. +# libtool_options_prep [ARG]... +# ----------------------------- +# Preparation for options parsed by libtool. +libtool_options_prep () { - # this just eases exit handling - while test $# -gt 0; do - opt="$1" - shift - case $opt in - --debug|-x) opt_debug='set -x' - func_echo "enabling shell trace mode" - $opt_debug - ;; - --dry-run|--dryrun|-n) - opt_dry_run=: - ;; - --config) - opt_config=: -func_config - ;; - --dlopen|-dlopen) - optarg="$1" - opt_dlopen="${opt_dlopen+$opt_dlopen -}$optarg" - shift - ;; - --preserve-dup-deps) - opt_preserve_dup_deps=: - ;; - --features) - opt_features=: -func_features - ;; - --finish) - opt_finish=: -set dummy --mode finish ${1+"$@"}; shift - ;; - --help) - opt_help=: - ;; - --help-all) - opt_help_all=: -opt_help=': help-all' - ;; - --mode) - test $# = 0 && func_missing_arg $opt && break - optarg="$1" - opt_mode="$optarg" -case $optarg in - # Valid mode arguments: - clean|compile|execute|finish|install|link|relink|uninstall) ;; + $debug_mode - # Catch anything else as an error - *) func_error "invalid argument for $opt" - exit_cmd=exit - break - ;; -esac - shift - ;; - --no-silent|--no-quiet) - opt_silent=false -func_append preserve_args " $opt" - ;; - --no-warning|--no-warn) - opt_warning=false -func_append preserve_args " $opt" - ;; - --no-verbose) - opt_verbose=false -func_append preserve_args " $opt" - ;; - --silent|--quiet) - opt_silent=: -func_append preserve_args " $opt" - opt_verbose=false - ;; - --verbose|-v) - opt_verbose=: -func_append preserve_args " $opt" -opt_silent=false - ;; - --tag) - test $# = 0 && func_missing_arg $opt && break - optarg="$1" - opt_tag="$optarg" -func_append preserve_args " $opt $optarg" -func_enable_tag "$optarg" - shift - ;; + # Option defaults: + opt_config=false + opt_dlopen= + opt_dry_run=false + opt_help=false + opt_mode= + opt_preserve_dup_deps=false + opt_quiet=false - -\?|-h) func_usage ;; - --help) func_help ;; - --version) func_version ;; + nonopt= + preserve_args= - # Separate optargs to long options: - --*=*) - func_split_long_opt "$opt" - set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} - shift - ;; + _G_rc_lt_options_prep=: - # Separate non-argument short options: - -\?*|-h*|-n*|-v*) - func_split_short_opt "$opt" - set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} - shift - ;; - - --) break ;; - -*) func_fatal_help "unrecognized option \`$opt'" ;; - *) set dummy "$opt" ${1+"$@"}; shift; break ;; - esac - done - - # Validate options: - - # save first non-option argument - if test "$#" -gt 0; then - nonopt="$opt" - shift - fi - - # preserve --debug - test "$opt_debug" = : || func_append preserve_args " --debug" - - case $host in - *cygwin* | *mingw* | *pw32* | *cegcc*) - # don't eliminate duplications in $postdeps and $predeps - opt_duplicate_compiler_generated_deps=: + # Shorthand for --mode=foo, only valid as the first argument + case $1 in + clean|clea|cle|cl) + shift; set dummy --mode clean ${1+"$@"}; shift + ;; + compile|compil|compi|comp|com|co|c) + shift; set dummy --mode compile ${1+"$@"}; shift + ;; + execute|execut|execu|exec|exe|ex|e) + shift; set dummy --mode execute ${1+"$@"}; shift + ;; + finish|finis|fini|fin|fi|f) + shift; set dummy --mode finish ${1+"$@"}; shift + ;; + install|instal|insta|inst|ins|in|i) + shift; set dummy --mode install ${1+"$@"}; shift + ;; + link|lin|li|l) + shift; set dummy --mode link ${1+"$@"}; shift + ;; + uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) + shift; set dummy --mode uninstall ${1+"$@"}; shift ;; *) - opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps + _G_rc_lt_options_prep=false ;; - esac + esac - $opt_help || { - # Sanity checks first: - func_check_version_match - - if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then - func_fatal_configuration "not configured to build any kind of library" + if $_G_rc_lt_options_prep; then + # Pass back the list of options. + func_quote_for_eval ${1+"$@"} + libtool_options_prep_result=$func_quote_for_eval_result fi - # Darwin sucks - eval std_shrext=\"$shrext_cmds\" - - # Only execute mode is allowed to have -dlopen flags. - if test -n "$opt_dlopen" && test "$opt_mode" != execute; then - func_error "unrecognized option \`-dlopen'" - $ECHO "$help" 1>&2 - exit $EXIT_FAILURE - fi - - # Change the help message to a mode-specific one. - generic_help="$help" - help="Try \`$progname --help --mode=$opt_mode' for more information." - } - - - # Bail if the options were screwed - $exit_cmd $EXIT_FAILURE + $_G_rc_lt_options_prep } +func_add_hook func_options_prep libtool_options_prep +# libtool_parse_options [ARG]... +# --------------------------------- +# Provide handling for libtool specific options. +libtool_parse_options () +{ + $debug_cmd + + _G_rc_lt_parse_options=false + + # Perform our own loop to consume as many options as possible in + # each iteration. + while test $# -gt 0; do + _G_match_lt_parse_options=: + _G_opt=$1 + shift + case $_G_opt in + --dry-run|--dryrun|-n) + opt_dry_run=: + ;; + + --config) func_config ;; + + --dlopen|-dlopen) + opt_dlopen="${opt_dlopen+$opt_dlopen +}$1" + shift + ;; + + --preserve-dup-deps) + opt_preserve_dup_deps=: ;; + + --features) func_features ;; + + --finish) set dummy --mode finish ${1+"$@"}; shift ;; + + --help) opt_help=: ;; + + --help-all) opt_help=': help-all' ;; + + --mode) test $# = 0 && func_missing_arg $_G_opt && break + opt_mode=$1 + case $1 in + # Valid mode arguments: + clean|compile|execute|finish|install|link|relink|uninstall) ;; + + # Catch anything else as an error + *) func_error "invalid argument for $_G_opt" + exit_cmd=exit + break + ;; + esac + shift + ;; + + --no-silent|--no-quiet) + opt_quiet=false + func_append preserve_args " $_G_opt" + ;; + + --no-warnings|--no-warning|--no-warn) + opt_warning=false + func_append preserve_args " $_G_opt" + ;; + + --no-verbose) + opt_verbose=false + func_append preserve_args " $_G_opt" + ;; + + --silent|--quiet) + opt_quiet=: + opt_verbose=false + func_append preserve_args " $_G_opt" + ;; + + --tag) test $# = 0 && func_missing_arg $_G_opt && break + opt_tag=$1 + func_append preserve_args " $_G_opt $1" + func_enable_tag "$1" + shift + ;; + + --verbose|-v) opt_quiet=false + opt_verbose=: + func_append preserve_args " $_G_opt" + ;; + + # An option not handled by this hook function: + *) set dummy "$_G_opt" ${1+"$@"} ; shift + _G_match_lt_parse_options=false + break + ;; + esac + $_G_match_lt_parse_options && _G_rc_lt_parse_options=: + done + + if $_G_rc_lt_parse_options; then + # save modified positional parameters for caller + func_quote_for_eval ${1+"$@"} + libtool_parse_options_result=$func_quote_for_eval_result + fi + + $_G_rc_lt_parse_options +} +func_add_hook func_parse_options libtool_parse_options + + + +# libtool_validate_options [ARG]... +# --------------------------------- +# Perform any sanity checks on option settings and/or unconsumed +# arguments. +libtool_validate_options () +{ + # save first non-option argument + if test 0 -lt $#; then + nonopt=$1 + shift + fi + + # preserve --debug + test : = "$debug_cmd" || func_append preserve_args " --debug" + + case $host in + # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 + # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 + *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) + # don't eliminate duplications in $postdeps and $predeps + opt_duplicate_compiler_generated_deps=: + ;; + *) + opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps + ;; + esac + + $opt_help || { + # Sanity checks first: + func_check_version_match + + test yes != "$build_libtool_libs" \ + && test yes != "$build_old_libs" \ + && func_fatal_configuration "not configured to build any kind of library" + + # Darwin sucks + eval std_shrext=\"$shrext_cmds\" + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$opt_dlopen" && test execute != "$opt_mode"; then + func_error "unrecognized option '-dlopen'" + $ECHO "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Change the help message to a mode-specific one. + generic_help=$help + help="Try '$progname --help --mode=$opt_mode' for more information." + } + + # Pass back the unparsed argument list + func_quote_for_eval ${1+"$@"} + libtool_validate_options_result=$func_quote_for_eval_result +} +func_add_hook func_validate_options libtool_validate_options + + +# Process options as early as possible so that --help and --version +# can return quickly. +func_options ${1+"$@"} +eval set dummy "$func_options_result"; shift + ## ----------- ## ## Main. ## ## ----------- ## +magic='%%%MAGIC variable%%%' +magic_exe='%%%MAGIC EXE variable%%%' + +# Global variables. +extracted_archives= +extracted_serial=0 + +# If this variable is set in any of the actions, the command in it +# will be execed at the end. This prevents here-documents from being +# left over by shells. +exec_cmd= + + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' +} + +# func_generated_by_libtool +# True iff stdin has been generated by Libtool. This function is only +# a basic sanity check; it will hardly flush out determined imposters. +func_generated_by_libtool_p () +{ + $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 +} + # func_lalib_p file -# True iff FILE is a libtool `.la' library or `.lo' object file. +# True iff FILE is a libtool '.la' library or '.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && - $SED -e 4q "$1" 2>/dev/null \ - | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 + $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p } # func_lalib_unsafe_p file -# True iff FILE is a libtool `.la' library or `.lo' object file. +# True iff FILE is a libtool '.la' library or '.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be -# fatal anyway. Works if `file' does not exist. +# fatal anyway. Works if 'file' does not exist. func_lalib_unsafe_p () { lalib_p=no @@ -1249,13 +2613,13 @@ func_lalib_unsafe_p () for lalib_p_l in 1 2 3 4 do read lalib_p_line - case "$lalib_p_line" in + case $lalib_p_line in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi - test "$lalib_p" = yes + test yes = "$lalib_p" } # func_ltwrapper_script_p file @@ -1264,7 +2628,8 @@ func_lalib_unsafe_p () # determined imposters. func_ltwrapper_script_p () { - func_lalib_p "$1" + test -f "$1" && + $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p } # func_ltwrapper_executable_p file @@ -1289,7 +2654,7 @@ func_ltwrapper_scriptname () { func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" - func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" + func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper } # func_ltwrapper_p file @@ -1308,11 +2673,13 @@ func_ltwrapper_p () # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { - $opt_debug + $debug_cmd + save_ifs=$IFS; IFS='~' for cmd in $1; do - IFS=$save_ifs + IFS=$sp$nl eval cmd=\"$cmd\" + IFS=$save_ifs func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs @@ -1324,10 +2691,11 @@ func_execute_cmds () # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing -# `FILE.' does not work on cygwin managed mounts. +# 'FILE.' does not work on cygwin managed mounts. func_source () { - $opt_debug + $debug_cmd + case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; @@ -1354,10 +2722,10 @@ func_resolve_sysroot () # store the result into func_replace_sysroot_result. func_replace_sysroot () { - case "$lt_sysroot:$1" in + case $lt_sysroot:$1 in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" - func_replace_sysroot_result="=$func_stripname_result" + func_replace_sysroot_result='='$func_stripname_result ;; *) # Including no sysroot. @@ -1374,7 +2742,8 @@ func_replace_sysroot () # arg is usually of the form 'gcc ...' func_infer_tag () { - $opt_debug + $debug_cmd + if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do @@ -1393,7 +2762,7 @@ func_infer_tag () for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. - eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" + eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. @@ -1418,7 +2787,7 @@ func_infer_tag () # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" - func_fatal_error "specify a tag with \`--tag'" + func_fatal_error "specify a tag with '--tag'" # else # func_verbose "using $tagname tagged configuration" fi @@ -1434,15 +2803,15 @@ func_infer_tag () # but don't create it if we're doing a dry run. func_write_libtool_object () { - write_libobj=${1} - if test "$build_libtool_libs" = yes; then - write_lobj=\'${2}\' + write_libobj=$1 + if test yes = "$build_libtool_libs"; then + write_lobj=\'$2\' else write_lobj=none fi - if test "$build_old_libs" = yes; then - write_oldobj=\'${3}\' + if test yes = "$build_old_libs"; then + write_oldobj=\'$3\' else write_oldobj=none fi @@ -1450,7 +2819,7 @@ func_write_libtool_object () $opt_dry_run || { cat >${write_libobj}T </dev/null` - if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then + if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | - $SED -e "$lt_sed_naive_backslashify"` + $SED -e "$sed_naive_backslashify"` else func_convert_core_file_wine_to_w32_result= fi @@ -1514,18 +2884,19 @@ func_convert_core_file_wine_to_w32 () # are convertible, then the result may be empty. func_convert_core_path_wine_to_w32 () { - $opt_debug + $debug_cmd + # unfortunately, winepath doesn't convert paths, only file names - func_convert_core_path_wine_to_w32_result="" + func_convert_core_path_wine_to_w32_result= if test -n "$1"; then oldIFS=$IFS IFS=: for func_convert_core_path_wine_to_w32_f in $1; do IFS=$oldIFS func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" - if test -n "$func_convert_core_file_wine_to_w32_result" ; then + if test -n "$func_convert_core_file_wine_to_w32_result"; then if test -z "$func_convert_core_path_wine_to_w32_result"; then - func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" + func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result else func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" fi @@ -1554,7 +2925,8 @@ func_convert_core_path_wine_to_w32 () # environment variable; do not put it in $PATH. func_cygpath () { - $opt_debug + $debug_cmd + if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` if test "$?" -ne 0; then @@ -1563,7 +2935,7 @@ func_cygpath () fi else func_cygpath_result= - func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" + func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" fi } #end: func_cygpath @@ -1574,10 +2946,11 @@ func_cygpath () # result in func_convert_core_msys_to_w32_result. func_convert_core_msys_to_w32 () { - $opt_debug + $debug_cmd + # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | - $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` + $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` } #end: func_convert_core_msys_to_w32 @@ -1588,13 +2961,14 @@ func_convert_core_msys_to_w32 () # func_to_host_file_result to ARG1). func_convert_file_check () { - $opt_debug - if test -z "$2" && test -n "$1" ; then + $debug_cmd + + if test -z "$2" && test -n "$1"; then func_error "Could not determine host file name corresponding to" - func_error " \`$1'" + func_error " '$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: - func_to_host_file_result="$1" + func_to_host_file_result=$1 fi } # end func_convert_file_check @@ -1606,10 +2980,11 @@ func_convert_file_check () # func_to_host_file_result to a simplistic fallback value (see below). func_convert_path_check () { - $opt_debug + $debug_cmd + if test -z "$4" && test -n "$3"; then func_error "Could not determine the host path corresponding to" - func_error " \`$3'" + func_error " '$3'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This is a deliberately simplistic "conversion" and # should not be "improved". See libtool.info. @@ -1618,7 +2993,7 @@ func_convert_path_check () func_to_host_path_result=`echo "$3" | $SED -e "$lt_replace_pathsep_chars"` else - func_to_host_path_result="$3" + func_to_host_path_result=$3 fi fi } @@ -1630,9 +3005,10 @@ func_convert_path_check () # and appending REPL if ORIG matches BACKPAT. func_convert_path_front_back_pathsep () { - $opt_debug + $debug_cmd + case $4 in - $1 ) func_to_host_path_result="$3$func_to_host_path_result" + $1 ) func_to_host_path_result=$3$func_to_host_path_result ;; esac case $4 in @@ -1646,7 +3022,7 @@ func_convert_path_front_back_pathsep () ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## -# invoked via `$to_host_file_cmd ARG' +# invoked via '$to_host_file_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # Result will be available in $func_to_host_file_result. @@ -1657,7 +3033,8 @@ func_convert_path_front_back_pathsep () # in func_to_host_file_result. func_to_host_file () { - $opt_debug + $debug_cmd + $to_host_file_cmd "$1" } # end func_to_host_file @@ -1669,7 +3046,8 @@ func_to_host_file () # in (the comma separated) LAZY, no conversion takes place. func_to_tool_file () { - $opt_debug + $debug_cmd + case ,$2, in *,"$to_tool_file_cmd",*) func_to_tool_file_result=$1 @@ -1687,7 +3065,7 @@ func_to_tool_file () # Copy ARG to func_to_host_file_result. func_convert_file_noop () { - func_to_host_file_result="$1" + func_to_host_file_result=$1 } # end func_convert_file_noop @@ -1698,11 +3076,12 @@ func_convert_file_noop () # func_to_host_file_result. func_convert_file_msys_to_w32 () { - $opt_debug - func_to_host_file_result="$1" + $debug_cmd + + func_to_host_file_result=$1 if test -n "$1"; then func_convert_core_msys_to_w32 "$1" - func_to_host_file_result="$func_convert_core_msys_to_w32_result" + func_to_host_file_result=$func_convert_core_msys_to_w32_result fi func_convert_file_check "$1" "$func_to_host_file_result" } @@ -1714,8 +3093,9 @@ func_convert_file_msys_to_w32 () # func_to_host_file_result. func_convert_file_cygwin_to_w32 () { - $opt_debug - func_to_host_file_result="$1" + $debug_cmd + + func_to_host_file_result=$1 if test -n "$1"; then # because $build is cygwin, we call "the" cygpath in $PATH; no need to use # LT_CYGPATH in this case. @@ -1731,11 +3111,12 @@ func_convert_file_cygwin_to_w32 () # and a working winepath. Returns result in func_to_host_file_result. func_convert_file_nix_to_w32 () { - $opt_debug - func_to_host_file_result="$1" + $debug_cmd + + func_to_host_file_result=$1 if test -n "$1"; then func_convert_core_file_wine_to_w32 "$1" - func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" + func_to_host_file_result=$func_convert_core_file_wine_to_w32_result fi func_convert_file_check "$1" "$func_to_host_file_result" } @@ -1747,12 +3128,13 @@ func_convert_file_nix_to_w32 () # Returns result in func_to_host_file_result. func_convert_file_msys_to_cygwin () { - $opt_debug - func_to_host_file_result="$1" + $debug_cmd + + func_to_host_file_result=$1 if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_cygpath -u "$func_convert_core_msys_to_w32_result" - func_to_host_file_result="$func_cygpath_result" + func_to_host_file_result=$func_cygpath_result fi func_convert_file_check "$1" "$func_to_host_file_result" } @@ -1765,13 +3147,14 @@ func_convert_file_msys_to_cygwin () # in func_to_host_file_result. func_convert_file_nix_to_cygwin () { - $opt_debug - func_to_host_file_result="$1" + $debug_cmd + + func_to_host_file_result=$1 if test -n "$1"; then # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. func_convert_core_file_wine_to_w32 "$1" func_cygpath -u "$func_convert_core_file_wine_to_w32_result" - func_to_host_file_result="$func_cygpath_result" + func_to_host_file_result=$func_cygpath_result fi func_convert_file_check "$1" "$func_to_host_file_result" } @@ -1781,7 +3164,7 @@ func_convert_file_nix_to_cygwin () ############################################# # $build to $host PATH CONVERSION FUNCTIONS # ############################################# -# invoked via `$to_host_path_cmd ARG' +# invoked via '$to_host_path_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # The result will be available in $func_to_host_path_result. @@ -1805,10 +3188,11 @@ func_convert_file_nix_to_cygwin () to_host_path_cmd= func_init_to_host_path_cmd () { - $opt_debug + $debug_cmd + if test -z "$to_host_path_cmd"; then func_stripname 'func_convert_file_' '' "$to_host_file_cmd" - to_host_path_cmd="func_convert_path_${func_stripname_result}" + to_host_path_cmd=func_convert_path_$func_stripname_result fi } @@ -1818,7 +3202,8 @@ func_init_to_host_path_cmd () # in func_to_host_path_result. func_to_host_path () { - $opt_debug + $debug_cmd + func_init_to_host_path_cmd $to_host_path_cmd "$1" } @@ -1829,7 +3214,7 @@ func_to_host_path () # Copy ARG to func_to_host_path_result. func_convert_path_noop () { - func_to_host_path_result="$1" + func_to_host_path_result=$1 } # end func_convert_path_noop @@ -1840,8 +3225,9 @@ func_convert_path_noop () # func_to_host_path_result. func_convert_path_msys_to_w32 () { - $opt_debug - func_to_host_path_result="$1" + $debug_cmd + + func_to_host_path_result=$1 if test -n "$1"; then # Remove leading and trailing path separator characters from ARG. MSYS # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; @@ -1849,7 +3235,7 @@ func_convert_path_msys_to_w32 () func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" - func_to_host_path_result="$func_convert_core_msys_to_w32_result" + func_to_host_path_result=$func_convert_core_msys_to_w32_result func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" @@ -1863,8 +3249,9 @@ func_convert_path_msys_to_w32 () # func_to_host_file_result. func_convert_path_cygwin_to_w32 () { - $opt_debug - func_to_host_path_result="$1" + $debug_cmd + + func_to_host_path_result=$1 if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" @@ -1883,14 +3270,15 @@ func_convert_path_cygwin_to_w32 () # a working winepath. Returns result in func_to_host_file_result. func_convert_path_nix_to_w32 () { - $opt_debug - func_to_host_path_result="$1" + $debug_cmd + + func_to_host_path_result=$1 if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" - func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" + func_to_host_path_result=$func_convert_core_path_wine_to_w32_result func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" @@ -1904,15 +3292,16 @@ func_convert_path_nix_to_w32 () # Returns result in func_to_host_file_result. func_convert_path_msys_to_cygwin () { - $opt_debug - func_to_host_path_result="$1" + $debug_cmd + + func_to_host_path_result=$1 if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_msys_to_w32_result" - func_to_host_path_result="$func_cygpath_result" + func_to_host_path_result=$func_cygpath_result func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" @@ -1927,8 +3316,9 @@ func_convert_path_msys_to_cygwin () # func_to_host_file_result. func_convert_path_nix_to_cygwin () { - $opt_debug - func_to_host_path_result="$1" + $debug_cmd + + func_to_host_path_result=$1 if test -n "$1"; then # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them @@ -1937,7 +3327,7 @@ func_convert_path_nix_to_cygwin () func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" - func_to_host_path_result="$func_cygpath_result" + func_to_host_path_result=$func_cygpath_result func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" @@ -1946,13 +3336,31 @@ func_convert_path_nix_to_cygwin () # end func_convert_path_nix_to_cygwin +# func_dll_def_p FILE +# True iff FILE is a Windows DLL '.def' file. +# Keep in sync with _LT_DLL_DEF_P in libtool.m4 +func_dll_def_p () +{ + $debug_cmd + + func_dll_def_p_tmp=`$SED -n \ + -e 's/^[ ]*//' \ + -e '/^\(;.*\)*$/d' \ + -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ + -e q \ + "$1"` + test DEF = "$func_dll_def_p_tmp" +} + + # func_mode_compile arg... func_mode_compile () { - $opt_debug + $debug_cmd + # Get the compilation command and the source file. base_compile= - srcfile="$nonopt" # always keep a non-empty value in "srcfile" + srcfile=$nonopt # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal @@ -1965,12 +3373,12 @@ func_mode_compile () case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile - lastarg="$arg" + lastarg=$arg arg_mode=normal ;; target ) - libobj="$arg" + libobj=$arg arg_mode=normal continue ;; @@ -1980,7 +3388,7 @@ func_mode_compile () case $arg in -o) test -n "$libobj" && \ - func_fatal_error "you cannot specify \`-o' more than once" + func_fatal_error "you cannot specify '-o' more than once" arg_mode=target continue ;; @@ -2009,12 +3417,12 @@ func_mode_compile () func_stripname '-Wc,' '' "$arg" args=$func_stripname_result lastarg= - save_ifs="$IFS"; IFS=',' + save_ifs=$IFS; IFS=, for arg in $args; do - IFS="$save_ifs" + IFS=$save_ifs func_append_quoted lastarg "$arg" done - IFS="$save_ifs" + IFS=$save_ifs func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result @@ -2027,8 +3435,8 @@ func_mode_compile () # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # - lastarg="$srcfile" - srcfile="$arg" + lastarg=$srcfile + srcfile=$arg ;; esac # case $arg ;; @@ -2043,13 +3451,13 @@ func_mode_compile () func_fatal_error "you must specify an argument for -Xcompile" ;; target) - func_fatal_error "you must specify a target with \`-o'" + func_fatal_error "you must specify a target with '-o'" ;; *) # Get the name of the library object. test -z "$libobj" && { func_basename "$srcfile" - libobj="$func_basename_result" + libobj=$func_basename_result } ;; esac @@ -2069,7 +3477,7 @@ func_mode_compile () case $libobj in *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; *) - func_fatal_error "cannot determine name of library object from \`$libobj'" + func_fatal_error "cannot determine name of library object from '$libobj'" ;; esac @@ -2078,8 +3486,8 @@ func_mode_compile () for arg in $later; do case $arg in -shared) - test "$build_libtool_libs" != yes && \ - func_fatal_configuration "can not build a shared library" + test yes = "$build_libtool_libs" \ + || func_fatal_configuration "cannot build a shared library" build_old_libs=no continue ;; @@ -2105,17 +3513,17 @@ func_mode_compile () func_quote_for_eval "$libobj" test "X$libobj" != "X$func_quote_for_eval_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ - && func_warning "libobj name \`$libobj' may not contain shell special characters." + && func_warning "libobj name '$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" - objname="$func_basename_result" - xdir="$func_dirname_result" - lobj=${xdir}$objdir/$objname + objname=$func_basename_result + xdir=$func_dirname_result + lobj=$xdir$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. - if test "$build_old_libs" = yes; then + if test yes = "$build_old_libs"; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" @@ -2127,16 +3535,16 @@ func_mode_compile () pic_mode=default ;; esac - if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then + if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c - if test "$compiler_c_o" = no; then - output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} - lockfile="$output_obj.lock" + if test no = "$compiler_c_o"; then + output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext + lockfile=$output_obj.lock else output_obj= need_locks=no @@ -2145,12 +3553,12 @@ func_mode_compile () # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file - if test "$need_locks" = yes; then + if test yes = "$need_locks"; then until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done - elif test "$need_locks" = warn; then + elif test warn = "$need_locks"; then if test -f "$lockfile"; then $ECHO "\ *** ERROR, $lockfile exists and contains: @@ -2158,7 +3566,7 @@ func_mode_compile () This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you +your compiler does not support '-c' and '-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." @@ -2180,11 +3588,11 @@ compiler." qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. - if test "$build_libtool_libs" = yes; then + if test yes = "$build_libtool_libs"; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile - if test "$pic_mode" != no; then + if test no != "$pic_mode"; then command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code @@ -2201,7 +3609,7 @@ compiler." func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' - if test "$need_locks" = warn && + if test warn = "$need_locks" && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: @@ -2212,7 +3620,7 @@ $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you +your compiler does not support '-c' and '-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." @@ -2228,20 +3636,20 @@ compiler." fi # Allow error messages only from the first compilation. - if test "$suppress_opt" = yes; then + if test yes = "$suppress_opt"; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. - if test "$build_old_libs" = yes; then - if test "$pic_mode" != yes; then + if test yes = "$build_old_libs"; then + if test yes != "$pic_mode"; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi - if test "$compiler_c_o" = yes; then + if test yes = "$compiler_c_o"; then func_append command " -o $obj" fi @@ -2250,7 +3658,7 @@ compiler." func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' - if test "$need_locks" = warn && + if test warn = "$need_locks" && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: @@ -2261,7 +3669,7 @@ $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you +your compiler does not support '-c' and '-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." @@ -2281,7 +3689,7 @@ compiler." func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked - if test "$need_locks" != no; then + if test no != "$need_locks"; then removelist=$lockfile $RM "$lockfile" fi @@ -2291,7 +3699,7 @@ compiler." } $opt_help || { - test "$opt_mode" = compile && func_mode_compile ${1+"$@"} + test compile = "$opt_mode" && func_mode_compile ${1+"$@"} } func_mode_help () @@ -2311,7 +3719,7 @@ func_mode_help () Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated @@ -2330,16 +3738,16 @@ This mode accepts the following additional options: -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to build PIC objects only -prefer-non-pic try to build non-PIC objects only - -shared do not build a \`.o' file suitable for static linking - -static only build a \`.o' file suitable for static linking + -shared do not build a '.o' file suitable for static linking + -static only build a '.o' file suitable for static linking -Wc,FLAG pass FLAG directly to the compiler -COMPILE-COMMAND is a command to be used in creating a \`standard' object file +COMPILE-COMMAND is a command to be used in creating a 'standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from -SOURCEFILE, then substituting the C source code suffix \`.c' with the -library object suffix, \`.lo'." +SOURCEFILE, then substituting the C source code suffix '.c' with the +library object suffix, '.lo'." ;; execute) @@ -2352,7 +3760,7 @@ This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path -This mode sets the library path environment variable according to \`-dlopen' +This mode sets the library path environment variable according to '-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated @@ -2371,7 +3779,7 @@ Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use -the \`--dry-run' option if you just want to see what would be executed." +the '--dry-run' option if you just want to see what would be executed." ;; install) @@ -2381,7 +3789,7 @@ the \`--dry-run' option if you just want to see what would be executed." Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be -either the \`install' or \`cp' program. +either the 'install' or 'cp' program. The following components of INSTALL-COMMAND are treated specially: @@ -2407,7 +3815,7 @@ The following components of LINK-COMMAND are treated specially: -avoid-version do not add a version suffix if possible -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) - -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime + -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE @@ -2421,7 +3829,8 @@ The following components of LINK-COMMAND are treated specially: -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects - -objectlist FILE Use a list of object files found in FILE to specify objects + -objectlist FILE use a list of object files found in FILE to specify objects + -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information @@ -2441,20 +3850,20 @@ The following components of LINK-COMMAND are treated specially: -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) -All other options (arguments beginning with \`-') are ignored. +All other options (arguments beginning with '-') are ignored. -Every other argument is treated as a filename. Files ending in \`.la' are +Every other argument is treated as a filename. Files ending in '.la' are treated as uninstalled libtool libraries, other files are standard or library object files. -If the OUTPUT-FILE ends in \`.la', then a libtool library is created, -only library objects (\`.lo' files) may be specified, and \`-rpath' is +If the OUTPUT-FILE ends in '.la', then a libtool library is created, +only library objects ('.lo' files) may be specified, and '-rpath' is required, except when creating a convenience library. -If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created -using \`ar' and \`ranlib', or on Windows using \`lib'. +If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created +using 'ar' and 'ranlib', or on Windows using 'lib'. -If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file +If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file is created, otherwise an executable program is created." ;; @@ -2465,7 +3874,7 @@ is created, otherwise an executable program is created." Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. @@ -2473,17 +3882,17 @@ Otherwise, only FILE itself is deleted using RM." ;; *) - func_fatal_help "invalid operation mode \`$opt_mode'" + func_fatal_help "invalid operation mode '$opt_mode'" ;; esac echo - $ECHO "Try \`$progname --help' for more information about other modes." + $ECHO "Try '$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then - if test "$opt_help" = :; then + if test : = "$opt_help"; then func_mode_help else { @@ -2491,7 +3900,7 @@ if $opt_help; then for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done - } | sed -n '1p; 2,$s/^Usage:/ or: /p' + } | $SED -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do @@ -2499,7 +3908,7 @@ if $opt_help; then func_mode_help done } | - sed '1d + $SED '1d /^When reporting/,/^Report/{ H d @@ -2516,16 +3925,17 @@ fi # func_mode_execute arg... func_mode_execute () { - $opt_debug + $debug_cmd + # The first argument is the command name. - cmd="$nonopt" + cmd=$nonopt test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $opt_dlopen; do test -f "$file" \ - || func_fatal_help "\`$file' is not a file" + || func_fatal_help "'$file' is not a file" dir= case $file in @@ -2535,7 +3945,7 @@ func_mode_execute () # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ - || func_fatal_help "\`$lib' is not a valid libtool archive" + || func_fatal_help "'$lib' is not a valid libtool archive" # Read the libtool library. dlname= @@ -2546,18 +3956,18 @@ func_mode_execute () if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ - func_warning "\`$file' was not linked with \`-export-dynamic'" + func_warning "'$file' was not linked with '-export-dynamic'" continue fi func_dirname "$file" "" "." - dir="$func_dirname_result" + dir=$func_dirname_result if test -f "$dir/$objdir/$dlname"; then func_append dir "/$objdir" else if test ! -f "$dir/$dlname"; then - func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" + func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" fi fi ;; @@ -2565,18 +3975,18 @@ func_mode_execute () *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." - dir="$func_dirname_result" + dir=$func_dirname_result ;; *) - func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" + func_warning "'-dlopen' is ignored for non-libtool libraries and objects" continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` - test -n "$absdir" && dir="$absdir" + test -n "$absdir" && dir=$absdir # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then @@ -2588,7 +3998,7 @@ func_mode_execute () # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. - libtool_execute_magic="$magic" + libtool_execute_magic=$magic # Check if any of the arguments is a wrapper script. args= @@ -2601,12 +4011,12 @@ func_mode_execute () if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. - file="$progdir/$program" + file=$progdir/$program elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. - file="$progdir/$program" + file=$progdir/$program fi ;; esac @@ -2614,7 +4024,15 @@ func_mode_execute () func_append_quoted args "$file" done - if test "X$opt_dry_run" = Xfalse; then + if $opt_dry_run; then + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" + echo "export $shlibpath_var" + fi + $ECHO "$cmd$args" + exit $EXIT_SUCCESS + else if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" @@ -2631,25 +4049,18 @@ func_mode_execute () done # Now prepare to actually exec the command. - exec_cmd="\$cmd$args" - else - # Display what would be done. - if test -n "$shlibpath_var"; then - eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" - echo "export $shlibpath_var" - fi - $ECHO "$cmd$args" - exit $EXIT_SUCCESS + exec_cmd=\$cmd$args fi } -test "$opt_mode" = execute && func_mode_execute ${1+"$@"} +test execute = "$opt_mode" && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { - $opt_debug + $debug_cmd + libs= libdirs= admincmds= @@ -2663,11 +4074,11 @@ func_mode_finish () if func_lalib_unsafe_p "$opt"; then func_append libs " $opt" else - func_warning "\`$opt' is not a valid libtool archive" + func_warning "'$opt' is not a valid libtool archive" fi else - func_fatal_error "invalid argument \`$opt'" + func_fatal_error "invalid argument '$opt'" fi done @@ -2682,12 +4093,12 @@ func_mode_finish () # Remove sysroot references if $opt_dry_run; then for lib in $libs; do - echo "removing references to $lt_sysroot and \`=' prefixes from $lib" + echo "removing references to $lt_sysroot and '=' prefixes from $lib" done else tmpdir=`func_mktempdir` for lib in $libs; do - sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ + $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ > $tmpdir/tmp-la mv -f $tmpdir/tmp-la $lib done @@ -2712,7 +4123,7 @@ func_mode_finish () fi # Exit here if they wanted silent mode. - $opt_silent && exit $EXIT_SUCCESS + $opt_quiet && exit $EXIT_SUCCESS if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then echo "----------------------------------------------------------------------" @@ -2723,27 +4134,27 @@ func_mode_finish () echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" - echo "specify the full pathname of the library, or use the \`-LLIBDIR'" + echo "specify the full pathname of the library, or use the '-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then - echo " - add LIBDIR to the \`$shlibpath_var' environment variable" + echo " - add LIBDIR to the '$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then - echo " - add LIBDIR to the \`$runpath_var' environment variable" + echo " - add LIBDIR to the '$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" - $ECHO " - use the \`$flag' linker flag" + $ECHO " - use the '$flag' linker flag" fi if test -n "$admincmds"; then $ECHO " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then - echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" fi echo @@ -2762,18 +4173,20 @@ func_mode_finish () exit $EXIT_SUCCESS } -test "$opt_mode" = finish && func_mode_finish ${1+"$@"} +test finish = "$opt_mode" && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { - $opt_debug + $debug_cmd + # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). - if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || + if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || # Allow the use of GNU shtool's install command. - case $nonopt in *shtool*) :;; *) false;; esac; then + case $nonopt in *shtool*) :;; *) false;; esac + then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " @@ -2800,7 +4213,7 @@ func_mode_install () opts= prev= install_type= - isdir=no + isdir=false stripme= no_mode=: for arg @@ -2813,7 +4226,7 @@ func_mode_install () fi case $arg in - -d) isdir=yes ;; + -d) isdir=: ;; -f) if $install_cp; then :; else prev=$arg @@ -2831,7 +4244,7 @@ func_mode_install () *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then - if test "x$prev" = x-m && test -n "$install_override_mode"; then + if test X-m = "X$prev" && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi @@ -2856,7 +4269,7 @@ func_mode_install () func_fatal_help "you must specify an install program" test -n "$prev" && \ - func_fatal_help "the \`$prev' option requires an argument" + func_fatal_help "the '$prev' option requires an argument" if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else @@ -2878,19 +4291,19 @@ func_mode_install () dest=$func_stripname_result # Check to see that the destination is a directory. - test -d "$dest" && isdir=yes - if test "$isdir" = yes; then - destdir="$dest" + test -d "$dest" && isdir=: + if $isdir; then + destdir=$dest destname= else func_dirname_and_basename "$dest" "" "." - destdir="$func_dirname_result" - destname="$func_basename_result" + destdir=$func_dirname_result + destname=$func_basename_result # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ - func_fatal_help "\`$dest' is not a directory" + func_fatal_help "'$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; @@ -2899,7 +4312,7 @@ func_mode_install () case $file in *.lo) ;; *) - func_fatal_help "\`$destdir' must be an absolute directory name" + func_fatal_help "'$destdir' must be an absolute directory name" ;; esac done @@ -2908,7 +4321,7 @@ func_mode_install () # This variable tells wrapper scripts just to set variables rather # than running their programs. - libtool_install_magic="$magic" + libtool_install_magic=$magic staticlibs= future_libdirs= @@ -2928,7 +4341,7 @@ func_mode_install () # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ - || func_fatal_help "\`$file' is not a valid libtool archive" + || func_fatal_help "'$file' is not a valid libtool archive" library_names= old_library= @@ -2950,7 +4363,7 @@ func_mode_install () fi func_dirname "$file" "/" "" - dir="$func_dirname_result" + dir=$func_dirname_result func_append dir "$objdir" if test -n "$relink_command"; then @@ -2964,7 +4377,7 @@ func_mode_install () # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ - func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" + func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. @@ -2973,29 +4386,36 @@ func_mode_install () relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` fi - func_warning "relinking \`$file'" + func_warning "relinking '$file'" func_show_eval "$relink_command" \ - 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' + 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then - realname="$1" + realname=$1 shift - srcname="$realname" - test -n "$relink_command" && srcname="$realname"T + srcname=$realname + test -n "$relink_command" && srcname=${realname}T # Install the shared library and build the symlinks. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 'exit $?' - tstripme="$stripme" + tstripme=$stripme case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) - tstripme="" + tstripme= + ;; + esac + ;; + os2*) + case $realname in + *_dll.a) + tstripme= ;; esac ;; @@ -3006,7 +4426,7 @@ func_mode_install () if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. - # Try `ln -sf' first, because the `ln' binary might depend on + # Try 'ln -sf' first, because the 'ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname @@ -3017,14 +4437,14 @@ func_mode_install () fi # Do each command in the postinstall commands. - lib="$destdir/$realname" + lib=$destdir/$realname func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" - name="$func_basename_result" - instname="$dir/$name"i + name=$func_basename_result + instname=$dir/${name}i func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. @@ -3036,11 +4456,11 @@ func_mode_install () # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then - destfile="$destdir/$destname" + destfile=$destdir/$destname else func_basename "$file" - destfile="$func_basename_result" - destfile="$destdir/$destfile" + destfile=$func_basename_result + destfile=$destdir/$destfile fi # Deduce the name of the destination old-style object file. @@ -3050,11 +4470,11 @@ func_mode_install () staticdest=$func_lo2o_result ;; *.$objext) - staticdest="$destfile" + staticdest=$destfile destfile= ;; *) - func_fatal_help "cannot copy a libtool object to \`$destfile'" + func_fatal_help "cannot copy a libtool object to '$destfile'" ;; esac @@ -3063,7 +4483,7 @@ func_mode_install () func_show_eval "$install_prog $file $destfile" 'exit $?' # Install the old object if enabled. - if test "$build_old_libs" = yes; then + if test yes = "$build_old_libs"; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result @@ -3075,23 +4495,23 @@ func_mode_install () *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then - destfile="$destdir/$destname" + destfile=$destdir/$destname else func_basename "$file" - destfile="$func_basename_result" - destfile="$destdir/$destfile" + destfile=$func_basename_result + destfile=$destdir/$destfile fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install - stripped_ext="" + stripped_ext= case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result - stripped_ext=".exe" + stripped_ext=.exe fi ;; esac @@ -3119,19 +4539,19 @@ func_mode_install () # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ - func_fatal_error "invalid libtool wrapper script \`$wrapper'" + func_fatal_error "invalid libtool wrapper script '$wrapper'" - finalize=yes + finalize=: for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi - libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test + libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` if test -n "$libdir" && test ! -f "$libfile"; then - func_warning "\`$lib' has not been installed in \`$libdir'" - finalize=no + func_warning "'$lib' has not been installed in '$libdir'" + finalize=false fi done @@ -3139,29 +4559,29 @@ func_mode_install () func_source "$wrapper" outputname= - if test "$fast_install" = no && test -n "$relink_command"; then + if test no = "$fast_install" && test -n "$relink_command"; then $opt_dry_run || { - if test "$finalize" = yes; then + if $finalize; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" - file="$func_basename_result" - outputname="$tmpdir/$file" + file=$func_basename_result + outputname=$tmpdir/$file # Replace the output file specification. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` - $opt_silent || { + $opt_quiet || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else - func_error "error: relink \`$file' with the above command before installing it" + func_error "error: relink '$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi - file="$outputname" + file=$outputname else - func_warning "cannot relink \`$file'" + func_warning "cannot relink '$file'" fi } else @@ -3198,10 +4618,10 @@ func_mode_install () for file in $staticlibs; do func_basename "$file" - name="$func_basename_result" + name=$func_basename_result # Set up the ranlib parameters. - oldlib="$destdir/$name" + oldlib=$destdir/$name func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result @@ -3216,18 +4636,18 @@ func_mode_install () done test -n "$future_libdirs" && \ - func_warning "remember to run \`$progname --finish$future_libdirs'" + func_warning "remember to run '$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" - exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' + exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } -test "$opt_mode" = install && func_mode_install ${1+"$@"} +test install = "$opt_mode" && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p @@ -3235,16 +4655,17 @@ test "$opt_mode" = install && func_mode_install ${1+"$@"} # a dlpreopen symbol table. func_generate_dlsyms () { - $opt_debug - my_outputname="$1" - my_originator="$2" - my_pic_p="${3-no}" - my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` + $debug_cmd + + my_outputname=$1 + my_originator=$2 + my_pic_p=${3-false} + my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then if test -n "$NM" && test -n "$global_symbol_pipe"; then - my_dlsyms="${my_outputname}S.c" + my_dlsyms=${my_outputname}S.c else func_error "not configured to extract global symbols from dlpreopened files" fi @@ -3255,7 +4676,7 @@ func_generate_dlsyms () "") ;; *.c) # Discover the nlist of each of the dlfiles. - nlist="$output_objdir/${my_outputname}.nm" + nlist=$output_objdir/$my_outputname.nm func_show_eval "$RM $nlist ${nlist}S ${nlist}T" @@ -3263,34 +4684,36 @@ func_generate_dlsyms () func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ -/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ -/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ +/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ +/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif -#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) +#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ -#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) -/* DATA imports from DLLs on WIN32 con't be const, because runtime +#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE +/* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST -#elif defined(__osf__) +#elif defined __osf__ /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif +#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) + /* External symbol declarations for the compiler. */\ " - if test "$dlself" = yes; then - func_verbose "generating symbol list for \`$output'" + if test yes = "$dlself"; then + func_verbose "generating symbol list for '$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" @@ -3298,7 +4721,7 @@ extern \"C\" { progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_to_tool_file "$progfile" func_convert_file_msys_to_w32 - func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" + func_verbose "extracting global C symbols from '$func_to_tool_file_result'" $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" done @@ -3318,10 +4741,10 @@ extern \"C\" { # Prepare the list of exported symbols if test -z "$export_symbols"; then - export_symbols="$output_objdir/$outputname.exp" + export_symbols=$output_objdir/$outputname.exp $opt_dry_run || { $RM $export_symbols - eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' @@ -3331,7 +4754,7 @@ extern \"C\" { } else $opt_dry_run || { - eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' + eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in @@ -3345,22 +4768,22 @@ extern \"C\" { fi for dlprefile in $dlprefiles; do - func_verbose "extracting global C symbols from \`$dlprefile'" + func_verbose "extracting global C symbols from '$dlprefile'" func_basename "$dlprefile" - name="$func_basename_result" + name=$func_basename_result case $host in *cygwin* | *mingw* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" eval "curr_lafile=\$libfile_$func_tr_sh_result" - dlprefile_dlbasename="" + dlprefile_dlbasename= if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then # Use subshell, to avoid clobbering current variable values dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` - if test -n "$dlprefile_dlname" ; then + if test -n "$dlprefile_dlname"; then func_basename "$dlprefile_dlname" - dlprefile_dlbasename="$func_basename_result" + dlprefile_dlbasename=$func_basename_result else # no lafile. user explicitly requested -dlpreopen . $sharedlib_from_linklib_cmd "$dlprefile" @@ -3368,7 +4791,7 @@ extern \"C\" { fi fi $opt_dry_run || { - if test -n "$dlprefile_dlbasename" ; then + if test -n "$dlprefile_dlbasename"; then eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' else func_warning "Could not compute DLL name from $name" @@ -3424,6 +4847,11 @@ extern \"C\" { echo '/* NONE */' >> "$output_objdir/$my_dlsyms" fi + func_show_eval '$RM "${nlist}I"' + if test -n "$global_symbol_to_import"; then + eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' + fi + echo >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ @@ -3432,11 +4860,30 @@ typedef struct { void *address; } lt_dlsymlist; extern LT_DLSYM_CONST lt_dlsymlist -lt_${my_prefix}_LTX_preloaded_symbols[]; +lt_${my_prefix}_LTX_preloaded_symbols[];\ +" + + if test -s "$nlist"I; then + echo >> "$output_objdir/$my_dlsyms" "\ +static void lt_syminit(void) +{ + LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; + for (; symbol->name; ++symbol) + {" + $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" + echo >> "$output_objdir/$my_dlsyms" "\ + } +}" + fi + echo >> "$output_objdir/$my_dlsyms" "\ LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = -{\ - { \"$my_originator\", (void *) 0 }," +{ {\"$my_originator\", (void *) 0}," + + if test -s "$nlist"I; then + echo >> "$output_objdir/$my_dlsyms" "\ + {\"@INIT@\", (void *) <_syminit}," + fi case $need_lib_prefix in no) @@ -3478,9 +4925,7 @@ static const void *lt_preloaded_setup() { *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) - if test "X$my_pic_p" != Xno; then - pic_flag_for_symtable=" $pic_flag" - fi + $my_pic_p && pic_flag_for_symtable=" $pic_flag" ;; esac ;; @@ -3497,10 +4942,10 @@ static const void *lt_preloaded_setup() { func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. - func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' + func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' # Transform the symbol file into the correct name. - symfileobj="$output_objdir/${my_outputname}S.$objext" + symfileobj=$output_objdir/${my_outputname}S.$objext case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then @@ -3518,7 +4963,7 @@ static const void *lt_preloaded_setup() { esac ;; *) - func_fatal_error "unknown suffix for \`$my_dlsyms'" + func_fatal_error "unknown suffix for '$my_dlsyms'" ;; esac else @@ -3532,6 +4977,32 @@ static const void *lt_preloaded_setup() { fi } +# func_cygming_gnu_implib_p ARG +# This predicate returns with zero status (TRUE) if +# ARG is a GNU/binutils-style import library. Returns +# with nonzero status (FALSE) otherwise. +func_cygming_gnu_implib_p () +{ + $debug_cmd + + func_to_tool_file "$1" func_convert_file_msys_to_w32 + func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` + test -n "$func_cygming_gnu_implib_tmp" +} + +# func_cygming_ms_implib_p ARG +# This predicate returns with zero status (TRUE) if +# ARG is an MS-style import library. Returns +# with nonzero status (FALSE) otherwise. +func_cygming_ms_implib_p () +{ + $debug_cmd + + func_to_tool_file "$1" func_convert_file_msys_to_w32 + func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` + test -n "$func_cygming_ms_implib_tmp" +} + # func_win32_libid arg # return the library type of file 'arg' # @@ -3541,8 +5012,9 @@ static const void *lt_preloaded_setup() { # Despite the name, also deal with 64 bit binaries. func_win32_libid () { - $opt_debug - win32_libid_type="unknown" + $debug_cmd + + win32_libid_type=unknown win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import @@ -3552,16 +5024,29 @@ func_win32_libid () # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then - func_to_tool_file "$1" func_convert_file_msys_to_w32 - win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | - $SED -n -e ' + case $nm_interface in + "MS dumpbin") + if func_cygming_ms_implib_p "$1" || + func_cygming_gnu_implib_p "$1" + then + win32_nmres=import + else + win32_nmres= + fi + ;; + *) + func_to_tool_file "$1" func_convert_file_msys_to_w32 + win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | + $SED -n -e ' 1,100{ / I /{ - s,.*,import, + s|.*|import| p q } }'` + ;; + esac case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; @@ -3593,7 +5078,8 @@ func_win32_libid () # $sharedlib_from_linklib_result func_cygming_dll_for_implib () { - $opt_debug + $debug_cmd + sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` } @@ -3610,7 +5096,8 @@ func_cygming_dll_for_implib () # specified import library. func_cygming_dll_for_implib_fallback_core () { - $opt_debug + $debug_cmd + match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` $OBJDUMP -s --section "$1" "$2" 2>/dev/null | $SED '/^Contents of section '"$match_literal"':/{ @@ -3646,8 +5133,8 @@ func_cygming_dll_for_implib_fallback_core () /./p' | # we now have a list, one entry per line, of the stringified # contents of the appropriate section of all members of the - # archive which possess that section. Heuristic: eliminate - # all those which have a first or second character that is + # archive that possess that section. Heuristic: eliminate + # all those that have a first or second character that is # a '.' (that is, objdump's representation of an unprintable # character.) This should work for all archives with less than # 0x302f exports -- but will fail for DLLs whose name actually @@ -3658,30 +5145,6 @@ func_cygming_dll_for_implib_fallback_core () $SED -e '/^\./d;/^.\./d;q' } -# func_cygming_gnu_implib_p ARG -# This predicate returns with zero status (TRUE) if -# ARG is a GNU/binutils-style import library. Returns -# with nonzero status (FALSE) otherwise. -func_cygming_gnu_implib_p () -{ - $opt_debug - func_to_tool_file "$1" func_convert_file_msys_to_w32 - func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` - test -n "$func_cygming_gnu_implib_tmp" -} - -# func_cygming_ms_implib_p ARG -# This predicate returns with zero status (TRUE) if -# ARG is an MS-style import library. Returns -# with nonzero status (FALSE) otherwise. -func_cygming_ms_implib_p () -{ - $opt_debug - func_to_tool_file "$1" func_convert_file_msys_to_w32 - func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` - test -n "$func_cygming_ms_implib_tmp" -} - # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified @@ -3695,16 +5158,17 @@ func_cygming_ms_implib_p () # $sharedlib_from_linklib_result func_cygming_dll_for_implib_fallback () { - $opt_debug - if func_cygming_gnu_implib_p "$1" ; then + $debug_cmd + + if func_cygming_gnu_implib_p "$1"; then # binutils import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` - elif func_cygming_ms_implib_p "$1" ; then + elif func_cygming_ms_implib_p "$1"; then # ms-generated import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` else # unknown - sharedlib_from_linklib_result="" + sharedlib_from_linklib_result= fi } @@ -3712,10 +5176,11 @@ func_cygming_dll_for_implib_fallback () # func_extract_an_archive dir oldlib func_extract_an_archive () { - $opt_debug - f_ex_an_ar_dir="$1"; shift - f_ex_an_ar_oldlib="$1" - if test "$lock_old_archive_extraction" = yes; then + $debug_cmd + + f_ex_an_ar_dir=$1; shift + f_ex_an_ar_oldlib=$1 + if test yes = "$lock_old_archive_extraction"; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" @@ -3724,7 +5189,7 @@ func_extract_an_archive () fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' - if test "$lock_old_archive_extraction" = yes; then + if test yes = "$lock_old_archive_extraction"; then $opt_dry_run || rm -f "$lockfile" fi if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then @@ -3738,22 +5203,23 @@ func_extract_an_archive () # func_extract_archives gentop oldlib ... func_extract_archives () { - $opt_debug - my_gentop="$1"; shift + $debug_cmd + + my_gentop=$1; shift my_oldlibs=${1+"$@"} - my_oldobjs="" - my_xlib="" - my_xabs="" - my_xdir="" + my_oldobjs= + my_xlib= + my_xabs= + my_xdir= for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in - [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; + [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" - my_xlib="$func_basename_result" + my_xlib=$func_basename_result my_xlib_u=$my_xlib while :; do case " $extracted_archives " in @@ -3765,7 +5231,7 @@ func_extract_archives () esac done extracted_archives="$extracted_archives $my_xlib_u" - my_xdir="$my_gentop/$my_xlib_u" + my_xdir=$my_gentop/$my_xlib_u func_mkdir_p "$my_xdir" @@ -3778,22 +5244,23 @@ func_extract_archives () cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` - darwin_base_archive=`basename "$darwin_archive"` + func_basename "$darwin_archive" + darwin_base_archive=$func_basename_result darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" - for darwin_arch in $darwin_arches ; do - func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" - $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" - cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" - func_extract_an_archive "`pwd`" "${darwin_base_archive}" + for darwin_arch in $darwin_arches; do + func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" + $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" + cd "unfat-$$/$darwin_base_archive-$darwin_arch" + func_extract_an_archive "`pwd`" "$darwin_base_archive" cd "$darwin_curdir" - $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" + $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) - darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` + darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do @@ -3815,7 +5282,7 @@ func_extract_archives () my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done - func_extract_archives_result="$my_oldobjs" + func_extract_archives_result=$my_oldobjs } @@ -3830,7 +5297,7 @@ func_extract_archives () # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script -# will assume that the directory in which it is stored is +# will assume that the directory where it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () @@ -3841,7 +5308,7 @@ func_emit_wrapper () #! $SHELL # $output - temporary wrapper script for $objdir/$outputname -# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION +# Generated by $PROGRAM (GNU $PACKAGE) $VERSION # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. @@ -3898,9 +5365,9 @@ _LTECHO_EOF' # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper -# /script/ and the wrapper /executable/ which is used only on +# /script/ and the wrapper /executable/ that is used only on # windows platforms, and (c) all begin with the string "--lt-" -# (application programs are unlikely to have options which match +# (application programs are unlikely to have options that match # this pattern). # # There are only two supported options: --lt-debug and @@ -3933,7 +5400,7 @@ func_parse_lt_options () # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then - echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 + echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 fi } @@ -3944,7 +5411,7 @@ func_lt_dump_args () lt_dump_args_N=1; for lt_arg do - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" + \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } @@ -3958,7 +5425,7 @@ func_exec_program_core () *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 + \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} @@ -3968,7 +5435,7 @@ func_exec_program_core () *) $ECHO "\ if test -n \"\$lt_option_debug\"; then - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 + \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} @@ -4043,13 +5510,13 @@ func_exec_program () test -n \"\$absdir\" && thisdir=\"\$absdir\" " - if test "$fast_install" = yes; then + if test yes = "$fast_install"; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || - { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" @@ -4066,7 +5533,7 @@ func_exec_program () if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else - $ECHO \"\$relink_command_output\" >&2 + \$ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi @@ -4101,7 +5568,7 @@ func_exec_program () fi # Export our shlibpath_var if we have one. - if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" @@ -4121,7 +5588,7 @@ func_exec_program () fi else # The program doesn't exist. - \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 + \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 @@ -4140,7 +5607,7 @@ func_emit_cwrapperexe_src () cat < #include +#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) + /* declarations of non-ANSI functions */ -#if defined(__MINGW32__) +#if defined __MINGW32__ # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif -#elif defined(__CYGWIN__) +#elif defined __CYGWIN__ # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif -/* #elif defined (other platforms) ... */ +/* #elif defined other_platform || defined ... */ #endif /* portability defines, excluding path handling macros */ -#if defined(_MSC_VER) +#if defined _MSC_VER # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC -# ifndef _INTPTR_T_DEFINED -# define _INTPTR_T_DEFINED -# define intptr_t int -# endif -#elif defined(__MINGW32__) +#elif defined __MINGW32__ # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv -#elif defined(__CYGWIN__) +#elif defined __CYGWIN__ # define HAVE_SETENV # define FOPEN_WB "wb" -/* #elif defined (other platforms) ... */ +/* #elif defined other platforms ... */ #endif -#if defined(PATH_MAX) +#if defined PATH_MAX # define LT_PATHMAX PATH_MAX -#elif defined(MAXPATHLEN) +#elif defined MAXPATHLEN # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 @@ -4234,8 +5699,8 @@ int setenv (const char *, const char *, int); # define PATH_SEPARATOR ':' #endif -#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ - defined (__OS2__) +#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ + defined __OS2__ # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 @@ -4268,10 +5733,10 @@ int setenv (const char *, const char *, int); #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ - if (stale) { free ((void *) stale); stale = 0; } \ + if (stale) { free (stale); stale = 0; } \ } while (0) -#if defined(LT_DEBUGWRAPPER) +#if defined LT_DEBUGWRAPPER static int lt_debug = 1; #else static int lt_debug = 0; @@ -4300,11 +5765,16 @@ void lt_dump_script (FILE *f); EOF cat < 0) && IS_PATH_SEPARATOR (new_value[len-1])) + size_t len = strlen (new_value); + while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { - new_value[len-1] = '\0'; + new_value[--len] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); @@ -5082,27 +6552,47 @@ EOF # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { - $opt_debug + $debug_cmd + case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } +# func_suncc_cstd_abi +# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! +# Several compiler flags select an ABI that is incompatible with the +# Cstd library. Avoid specifying it if any are in CXXFLAGS. +func_suncc_cstd_abi () +{ + $debug_cmd + + case " $compile_command " in + *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) + suncc_use_cstd_abi=no + ;; + *) + suncc_use_cstd_abi=yes + ;; + esac +} + # func_mode_link arg... func_mode_link () { - $opt_debug + $debug_cmd + case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out - # which system we are compiling for in order to pass an extra + # what system we are compiling for in order to pass an extra # flag for every libtool invocation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying - # to make a dll which has undefined symbols, in which case not + # to make a dll that has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. @@ -5146,10 +6636,11 @@ func_mode_link () module=no no_install=no objs= + os2dllname= non_pic_objects= precious_files_regex= prefer_static_libs=no - preload=no + preload=false prev= prevarg= release= @@ -5161,7 +6652,7 @@ func_mode_link () vinfo= vinfo_number=no weak_libs= - single_module="${wl}-single_module" + single_module=$wl-single_module func_infer_tag $base_compile # We need to know -static, to get the right output filenames. @@ -5169,15 +6660,15 @@ func_mode_link () do case $arg in -shared) - test "$build_libtool_libs" != yes && \ - func_fatal_configuration "can not build a shared library" + test yes != "$build_libtool_libs" \ + && func_fatal_configuration "cannot build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) - if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then + if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then @@ -5210,7 +6701,7 @@ func_mode_link () # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do - arg="$1" + arg=$1 shift func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result @@ -5227,21 +6718,21 @@ func_mode_link () case $prev in bindir) - bindir="$arg" + bindir=$arg prev= continue ;; dlfiles|dlprefiles) - if test "$preload" = no; then + $preload || { # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" - preload=yes - fi + preload=: + } case $arg in *.la | *.lo) ;; # We handle these cases below. force) - if test "$dlself" = no; then + if test no = "$dlself"; then dlself=needless export_dynamic=yes fi @@ -5249,9 +6740,9 @@ func_mode_link () continue ;; self) - if test "$prev" = dlprefiles; then + if test dlprefiles = "$prev"; then dlself=yes - elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then + elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then dlself=yes else dlself=needless @@ -5261,7 +6752,7 @@ func_mode_link () continue ;; *) - if test "$prev" = dlfiles; then + if test dlfiles = "$prev"; then func_append dlfiles " $arg" else func_append dlprefiles " $arg" @@ -5272,14 +6763,14 @@ func_mode_link () esac ;; expsyms) - export_symbols="$arg" + export_symbols=$arg test -f "$arg" \ - || func_fatal_error "symbol file \`$arg' does not exist" + || func_fatal_error "symbol file '$arg' does not exist" prev= continue ;; expsyms_regex) - export_symbols_regex="$arg" + export_symbols_regex=$arg prev= continue ;; @@ -5297,7 +6788,13 @@ func_mode_link () continue ;; inst_prefix) - inst_prefix_dir="$arg" + inst_prefix_dir=$arg + prev= + continue + ;; + mllvm) + # Clang does not use LLVM to link, so we can simply discard any + # '-mllvm $arg' options when doing the link step. prev= continue ;; @@ -5321,21 +6818,21 @@ func_mode_link () if test -z "$pic_object" || test -z "$non_pic_object" || - test "$pic_object" = none && - test "$non_pic_object" = none; then - func_fatal_error "cannot find name of object for \`$arg'" + test none = "$pic_object" && + test none = "$non_pic_object"; then + func_fatal_error "cannot find name of object for '$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" - xdir="$func_dirname_result" + xdir=$func_dirname_result - if test "$pic_object" != none; then + if test none != "$pic_object"; then # Prepend the subdirectory the object is found in. - pic_object="$xdir$pic_object" + pic_object=$xdir$pic_object - if test "$prev" = dlfiles; then - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + if test dlfiles = "$prev"; then + if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then func_append dlfiles " $pic_object" prev= continue @@ -5346,7 +6843,7 @@ func_mode_link () fi # CHECK ME: I think I busted this. -Ossama - if test "$prev" = dlprefiles; then + if test dlprefiles = "$prev"; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= @@ -5354,23 +6851,23 @@ func_mode_link () # A PIC object. func_append libobjs " $pic_object" - arg="$pic_object" + arg=$pic_object fi # Non-PIC object. - if test "$non_pic_object" != none; then + if test none != "$non_pic_object"; then # Prepend the subdirectory the object is found in. - non_pic_object="$xdir$non_pic_object" + non_pic_object=$xdir$non_pic_object # A standard non-PIC object func_append non_pic_objects " $non_pic_object" - if test -z "$pic_object" || test "$pic_object" = none ; then - arg="$non_pic_object" + if test -z "$pic_object" || test none = "$pic_object"; then + arg=$non_pic_object fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. - non_pic_object="$pic_object" + non_pic_object=$pic_object func_append non_pic_objects " $non_pic_object" fi else @@ -5378,7 +6875,7 @@ func_mode_link () if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" - xdir="$func_dirname_result" + xdir=$func_dirname_result func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result @@ -5386,24 +6883,29 @@ func_mode_link () func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else - func_fatal_error "\`$arg' is not a valid libtool object" + func_fatal_error "'$arg' is not a valid libtool object" fi fi done else - func_fatal_error "link input file \`$arg' does not exist" + func_fatal_error "link input file '$arg' does not exist" fi arg=$save_arg prev= continue ;; + os2dllname) + os2dllname=$arg + prev= + continue + ;; precious_regex) - precious_files_regex="$arg" + precious_files_regex=$arg prev= continue ;; release) - release="-$arg" + release=-$arg prev= continue ;; @@ -5415,7 +6917,7 @@ func_mode_link () func_fatal_error "only absolute run-paths are allowed" ;; esac - if test "$prev" = rpath; then + if test rpath = "$prev"; then case "$rpath " in *" $arg "*) ;; *) func_append rpath " $arg" ;; @@ -5430,7 +6932,7 @@ func_mode_link () continue ;; shrext) - shrext_cmds="$arg" + shrext_cmds=$arg prev= continue ;; @@ -5470,7 +6972,7 @@ func_mode_link () esac fi # test -n "$prev" - prevarg="$arg" + prevarg=$arg case $arg in -all-static) @@ -5484,7 +6986,7 @@ func_mode_link () -allow-undefined) # FIXME: remove this flag sometime in the future. - func_fatal_error "\`-allow-undefined' must not be used because it is the default" + func_fatal_error "'-allow-undefined' must not be used because it is the default" ;; -avoid-version) @@ -5516,7 +7018,7 @@ func_mode_link () if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" fi - if test "X$arg" = "X-export-symbols"; then + if test X-export-symbols = "X$arg"; then prev=expsyms else prev=expsyms_regex @@ -5550,9 +7052,9 @@ func_mode_link () func_stripname "-L" '' "$arg" if test -z "$func_stripname_result"; then if test "$#" -gt 0; then - func_fatal_error "require no space between \`-L' and \`$1'" + func_fatal_error "require no space between '-L' and '$1'" else - func_fatal_error "need path for \`-L' option" + func_fatal_error "need path for '-L' option" fi fi func_resolve_sysroot "$func_stripname_result" @@ -5563,8 +7065,8 @@ func_mode_link () *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ - func_fatal_error "cannot determine absolute directory name of \`$dir'" - dir="$absdir" + func_fatal_error "cannot determine absolute directory name of '$dir'" + dir=$absdir ;; esac case "$deplibs " in @@ -5599,7 +7101,7 @@ func_mode_link () ;; -l*) - if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then + if test X-lc = "X$arg" || test X-lm = "X$arg"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) @@ -5607,11 +7109,11 @@ func_mode_link () ;; *-*-os2*) # These systems don't actually have a C library (as such) - test "X$arg" = "X-lc" && continue + test X-lc = "X$arg" && continue ;; - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) # Do not include libc due to us having libc/libc_r. - test "X$arg" = "X-lc" && continue + test X-lc = "X$arg" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework @@ -5620,16 +7122,16 @@ func_mode_link () ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype - test "X$arg" = "X-lc" && continue + test X-lc = "X$arg" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work - test "X$arg" = "X-lc" && continue + test X-lc = "X$arg" && continue ;; esac - elif test "X$arg" = "X-lc_r"; then + elif test X-lc_r = "X$arg"; then case $host in - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) # Do not include libc_r directly, use -pthread flag. continue ;; @@ -5639,6 +7141,11 @@ func_mode_link () continue ;; + -mllvm) + prev=mllvm + continue + ;; + -module) module=yes continue @@ -5668,7 +7175,7 @@ func_mode_link () ;; -multi_module) - single_module="${wl}-multi_module" + single_module=$wl-multi_module continue ;; @@ -5682,8 +7189,8 @@ func_mode_link () *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. - func_warning "\`-no-install' is ignored for $host" - func_warning "assuming \`-no-fast-install' instead" + func_warning "'-no-install' is ignored for $host" + func_warning "assuming '-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; @@ -5701,6 +7208,11 @@ func_mode_link () continue ;; + -os2dllname) + prev=os2dllname + continue + ;; + -o) prev=output ;; -precious-files-regex) @@ -5788,14 +7300,14 @@ func_mode_link () func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= - save_ifs="$IFS"; IFS=',' + save_ifs=$IFS; IFS=, for flag in $args; do - IFS="$save_ifs" + IFS=$save_ifs func_quote_for_eval "$flag" func_append arg " $func_quote_for_eval_result" func_append compiler_flags " $func_quote_for_eval_result" done - IFS="$save_ifs" + IFS=$save_ifs func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; @@ -5804,15 +7316,15 @@ func_mode_link () func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= - save_ifs="$IFS"; IFS=',' + save_ifs=$IFS; IFS=, for flag in $args; do - IFS="$save_ifs" + IFS=$save_ifs func_quote_for_eval "$flag" func_append arg " $wl$func_quote_for_eval_result" func_append compiler_flags " $wl$func_quote_for_eval_result" func_append linker_flags " $func_quote_for_eval_result" done - IFS="$save_ifs" + IFS=$save_ifs func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; @@ -5835,7 +7347,7 @@ func_mode_link () # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" + arg=$func_quote_for_eval_result ;; # Flags to be passed through unchanged, with rationale: @@ -5847,25 +7359,52 @@ func_mode_link () # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC + # -fstack-protector* stack protector flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support - # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization + # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization + # -specs=* GCC specs files + # -stdlib=* select c++ std lib with clang + # -fsanitize=* Clang/GCC memory and address sanitizer + # -fuse-ld=* Linker select flags for GCC + # -static-* direct GCC to link specific libraries statically + # -fcilkplus Cilk Plus language extension features for C/C++ -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ - -O*|-flto*|-fwhopr*|-fuse-linker-plugin) + -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ + -specs=*|-fsanitize=*|-fuse-ld=*|-static-*|-fcilkplus) func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" + arg=$func_quote_for_eval_result func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" continue ;; + -Z*) + if test os2 = "`expr $host : '.*\(os2\)'`"; then + # OS/2 uses -Zxxx to specify OS/2-specific options + compiler_flags="$compiler_flags $arg" + func_append compile_command " $arg" + func_append finalize_command " $arg" + case $arg in + -Zlinker | -Zstack) + prev=xcompiler + ;; + esac + continue + else + # Otherwise treat like 'Some other compiler flag' below + func_quote_for_eval "$arg" + arg=$func_quote_for_eval_result + fi + ;; + # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" + arg=$func_quote_for_eval_result ;; *.$objext) @@ -5886,21 +7425,21 @@ func_mode_link () if test -z "$pic_object" || test -z "$non_pic_object" || - test "$pic_object" = none && - test "$non_pic_object" = none; then - func_fatal_error "cannot find name of object for \`$arg'" + test none = "$pic_object" && + test none = "$non_pic_object"; then + func_fatal_error "cannot find name of object for '$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" - xdir="$func_dirname_result" + xdir=$func_dirname_result - if test "$pic_object" != none; then + test none = "$pic_object" || { # Prepend the subdirectory the object is found in. - pic_object="$xdir$pic_object" + pic_object=$xdir$pic_object - if test "$prev" = dlfiles; then - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + if test dlfiles = "$prev"; then + if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then func_append dlfiles " $pic_object" prev= continue @@ -5911,7 +7450,7 @@ func_mode_link () fi # CHECK ME: I think I busted this. -Ossama - if test "$prev" = dlprefiles; then + if test dlprefiles = "$prev"; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= @@ -5919,23 +7458,23 @@ func_mode_link () # A PIC object. func_append libobjs " $pic_object" - arg="$pic_object" - fi + arg=$pic_object + } # Non-PIC object. - if test "$non_pic_object" != none; then + if test none != "$non_pic_object"; then # Prepend the subdirectory the object is found in. - non_pic_object="$xdir$non_pic_object" + non_pic_object=$xdir$non_pic_object # A standard non-PIC object func_append non_pic_objects " $non_pic_object" - if test -z "$pic_object" || test "$pic_object" = none ; then - arg="$non_pic_object" + if test -z "$pic_object" || test none = "$pic_object"; then + arg=$non_pic_object fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. - non_pic_object="$pic_object" + non_pic_object=$pic_object func_append non_pic_objects " $non_pic_object" fi else @@ -5943,7 +7482,7 @@ func_mode_link () if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" - xdir="$func_dirname_result" + xdir=$func_dirname_result func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result @@ -5951,7 +7490,7 @@ func_mode_link () func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else - func_fatal_error "\`$arg' is not a valid libtool object" + func_fatal_error "'$arg' is not a valid libtool object" fi fi ;; @@ -5967,11 +7506,11 @@ func_mode_link () # A libtool-controlled library. func_resolve_sysroot "$arg" - if test "$prev" = dlfiles; then + if test dlfiles = "$prev"; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= - elif test "$prev" = dlprefiles; then + elif test dlprefiles = "$prev"; then # The library was specified with -dlpreopen. func_append dlprefiles " $func_resolve_sysroot_result" prev= @@ -5986,7 +7525,7 @@ func_mode_link () # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" + arg=$func_quote_for_eval_result ;; esac # arg @@ -5998,9 +7537,9 @@ func_mode_link () done # argument parsing loop test -n "$prev" && \ - func_fatal_help "the \`$prevarg' option requires an argument" + func_fatal_help "the '$prevarg' option requires an argument" - if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then + if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" @@ -6009,20 +7548,23 @@ func_mode_link () oldlibs= # calculate the name of the file, without its directory func_basename "$output" - outputname="$func_basename_result" - libobjs_save="$libobjs" + outputname=$func_basename_result + libobjs_save=$libobjs if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var - eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` + eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" + # Definition is injected by LT_CONFIG during libtool generation. + func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" + func_dirname "$output" "/" "" - output_objdir="$func_dirname_result$objdir" + output_objdir=$func_dirname_result$objdir func_to_tool_file "$output_objdir/" tool_output_objdir=$func_to_tool_file_result # Create the object directory. @@ -6045,7 +7587,7 @@ func_mode_link () # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do - if $opt_preserve_dup_deps ; then + if $opt_preserve_dup_deps; then case "$libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac @@ -6053,7 +7595,7 @@ func_mode_link () func_append libs " $deplib" done - if test "$linkmode" = lib; then + if test lib = "$linkmode"; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps @@ -6085,7 +7627,7 @@ func_mode_link () case $file in *.la) ;; *) - func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" + func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" ;; esac done @@ -6093,7 +7635,7 @@ func_mode_link () prog) compile_deplibs= finalize_deplibs= - alldeplibs=no + alldeplibs=false newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" @@ -6105,32 +7647,32 @@ func_mode_link () for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... - if test "$linkmode,$pass" = "lib,link"; then + if test lib,link = "$linkmode,$pass"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done - deplibs="$tmp_deplibs" + deplibs=$tmp_deplibs fi - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan"; then - libs="$deplibs" + if test lib,link = "$linkmode,$pass" || + test prog,scan = "$linkmode,$pass"; then + libs=$deplibs deplibs= fi - if test "$linkmode" = prog; then + if test prog = "$linkmode"; then case $pass in - dlopen) libs="$dlfiles" ;; - dlpreopen) libs="$dlprefiles" ;; + dlopen) libs=$dlfiles ;; + dlpreopen) libs=$dlprefiles ;; link) libs="$deplibs %DEPLIBS%" test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" ;; esac fi - if test "$linkmode,$pass" = "lib,dlpreopen"; then + if test lib,dlpreopen = "$linkmode,$pass"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs @@ -6151,26 +7693,26 @@ func_mode_link () esac done done - libs="$dlprefiles" + libs=$dlprefiles fi - if test "$pass" = dlopen; then + if test dlopen = "$pass"; then # Collect dlpreopened libraries - save_deplibs="$deplibs" + save_deplibs=$deplibs deplibs= fi for deplib in $libs; do lib= - found=no + found=false case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) - if test "$linkmode,$pass" = "prog,link"; then + if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" - if test "$linkmode" = lib ; then + if test lib = "$linkmode"; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; @@ -6180,13 +7722,13 @@ func_mode_link () continue ;; -l*) - if test "$linkmode" != lib && test "$linkmode" != prog; then - func_warning "\`-l' is ignored for archives/objects" + if test lib != "$linkmode" && test prog != "$linkmode"; then + func_warning "'-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result - if test "$linkmode" = lib; then + if test lib = "$linkmode"; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" @@ -6194,31 +7736,22 @@ func_mode_link () for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library - lib="$searchdir/lib${name}${search_ext}" + lib=$searchdir/lib$name$search_ext if test -f "$lib"; then - if test "$search_ext" = ".la"; then - found=yes + if test .la = "$search_ext"; then + found=: else - found=no + found=false fi break 2 fi done done - if test "$found" != yes; then - # deplib doesn't seem to be a libtool library - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" - fi - continue - else # deplib is a libtool library + if $found; then + # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + if test yes = "$allow_libtool_libs_with_static_runtimes"; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then @@ -6226,19 +7759,19 @@ func_mode_link () old_library= func_source "$lib" for l in $old_library $library_names; do - ll="$l" + ll=$l done - if test "X$ll" = "X$old_library" ; then # only static version available - found=no + if test "X$ll" = "X$old_library"; then # only static version available + found=false func_dirname "$lib" "" "." - ladir="$func_dirname_result" + ladir=$func_dirname_result lib=$ladir/$old_library - if test "$linkmode,$pass" = "prog,link"; then + if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" - test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" fi continue fi @@ -6247,15 +7780,25 @@ func_mode_link () *) ;; esac fi + else + # deplib doesn't seem to be a libtool library + if test prog,link = "$linkmode,$pass"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" + fi + continue fi ;; # -l *.ltframework) - if test "$linkmode,$pass" = "prog,link"; then + if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" - if test "$linkmode" = lib ; then + if test lib = "$linkmode"; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; @@ -6268,18 +7811,18 @@ func_mode_link () case $linkmode in lib) deplibs="$deplib $deplibs" - test "$pass" = conv && continue + test conv = "$pass" && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; prog) - if test "$pass" = conv; then + if test conv = "$pass"; then deplibs="$deplib $deplibs" continue fi - if test "$pass" = scan; then + if test scan = "$pass"; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" @@ -6290,13 +7833,13 @@ func_mode_link () func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) - func_warning "\`-L' is ignored for archives/objects" + func_warning "'-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) - if test "$pass" = link; then + if test link = "$pass"; then func_stripname '-R' '' "$deplib" func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result @@ -6314,7 +7857,7 @@ func_mode_link () lib=$func_resolve_sysroot_result ;; *.$libext) - if test "$pass" = conv; then + if test conv = "$pass"; then deplibs="$deplib $deplibs" continue fi @@ -6325,21 +7868,26 @@ func_mode_link () case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) - valid_a_lib=no + valid_a_lib=false case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then - valid_a_lib=yes + valid_a_lib=: fi ;; pass_all) - valid_a_lib=yes + valid_a_lib=: ;; esac - if test "$valid_a_lib" != yes; then + if $valid_a_lib; then + echo + $ECHO "*** Warning: Linking the shared library $output against the" + $ECHO "*** static library $deplib is not portable!" + deplibs="$deplib $deplibs" + else echo $ECHO "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" @@ -6347,18 +7895,13 @@ func_mode_link () echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not use here." - else - echo - $ECHO "*** Warning: Linking the shared library $output against the" - $ECHO "*** static library $deplib is not portable!" - deplibs="$deplib $deplibs" fi ;; esac continue ;; prog) - if test "$pass" != link; then + if test link != "$pass"; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" @@ -6369,10 +7912,10 @@ func_mode_link () esac # linkmode ;; # *.$libext *.lo | *.$objext) - if test "$pass" = conv; then + if test conv = "$pass"; then deplibs="$deplib $deplibs" - elif test "$linkmode" = prog; then - if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then + elif test prog = "$linkmode"; then + if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then # If there is no dlopen support or we're linking statically, # we need to preload. func_append newdlprefiles " $deplib" @@ -6385,22 +7928,20 @@ func_mode_link () continue ;; %DEPLIBS%) - alldeplibs=yes + alldeplibs=: continue ;; esac # case $deplib - if test "$found" = yes || test -f "$lib"; then : - else - func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" - fi + $found || test -f "$lib" \ + || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ - || func_fatal_error "\`$lib' is not a valid libtool archive" + || func_fatal_error "'$lib' is not a valid libtool archive" func_dirname "$lib" "" "." - ladir="$func_dirname_result" + ladir=$func_dirname_result dlname= dlopen= @@ -6430,19 +7971,19 @@ func_mode_link () done fi dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan" || - { test "$linkmode" != prog && test "$linkmode" != lib; }; then + if test lib,link = "$linkmode,$pass" || + test prog,scan = "$linkmode,$pass" || + { test prog != "$linkmode" && test lib != "$linkmode"; }; then test -n "$dlopen" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" fi - if test "$pass" = conv; then + if test conv = "$pass"; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then - func_fatal_error "cannot find name of link library for \`$lib'" + func_fatal_error "cannot find name of link library for '$lib'" fi # It is a libtool convenience library, so add in its objects. func_append convenience " $ladir/$objdir/$old_library" @@ -6450,15 +7991,15 @@ func_mode_link () tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" - if $opt_preserve_dup_deps ; then + if $opt_preserve_dup_deps; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done - elif test "$linkmode" != prog && test "$linkmode" != lib; then - func_fatal_error "\`$lib' is not a convenience library" + elif test prog != "$linkmode" && test lib != "$linkmode"; then + func_fatal_error "'$lib' is not a convenience library" fi continue fi # $pass = conv @@ -6467,26 +8008,26 @@ func_mode_link () # Get the name of the library we link against. linklib= if test -n "$old_library" && - { test "$prefer_static_libs" = yes || - test "$prefer_static_libs,$installed" = "built,no"; }; then + { test yes = "$prefer_static_libs" || + test built,no = "$prefer_static_libs,$installed"; }; then linklib=$old_library else for l in $old_library $library_names; do - linklib="$l" + linklib=$l done fi if test -z "$linklib"; then - func_fatal_error "cannot find name of link library for \`$lib'" + func_fatal_error "cannot find name of link library for '$lib'" fi # This library was specified with -dlopen. - if test "$pass" = dlopen; then - if test -z "$libdir"; then - func_fatal_error "cannot -dlopen a convenience library: \`$lib'" - fi + if test dlopen = "$pass"; then + test -z "$libdir" \ + && func_fatal_error "cannot -dlopen a convenience library: '$lib'" if test -z "$dlname" || - test "$dlopen_support" != yes || - test "$build_libtool_libs" = no; then + test yes != "$dlopen_support" || + test no = "$build_libtool_libs" + then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't @@ -6500,40 +8041,40 @@ func_mode_link () # We need an absolute path. case $ladir in - [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; + [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then - func_warning "cannot determine absolute directory name of \`$ladir'" + func_warning "cannot determine absolute directory name of '$ladir'" func_warning "passing it literally to the linker, although it might fail" - abs_ladir="$ladir" + abs_ladir=$ladir fi ;; esac func_basename "$lib" - laname="$func_basename_result" + laname=$func_basename_result # Find the relevant object directory and library name. - if test "X$installed" = Xyes; then + if test yes = "$installed"; then if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then - func_warning "library \`$lib' was moved." - dir="$ladir" - absdir="$abs_ladir" - libdir="$abs_ladir" + func_warning "library '$lib' was moved." + dir=$ladir + absdir=$abs_ladir + libdir=$abs_ladir else - dir="$lt_sysroot$libdir" - absdir="$lt_sysroot$libdir" + dir=$lt_sysroot$libdir + absdir=$lt_sysroot$libdir fi - test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes + test yes = "$hardcode_automatic" && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then - dir="$ladir" - absdir="$abs_ladir" + dir=$ladir + absdir=$abs_ladir # Remove this search path later func_append notinst_path " $abs_ladir" else - dir="$ladir/$objdir" - absdir="$abs_ladir/$objdir" + dir=$ladir/$objdir + absdir=$abs_ladir/$objdir # Remove this search path later func_append notinst_path " $abs_ladir" fi @@ -6542,11 +8083,11 @@ func_mode_link () name=$func_stripname_result # This library was specified with -dlpreopen. - if test "$pass" = dlpreopen; then - if test -z "$libdir" && test "$linkmode" = prog; then - func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" + if test dlpreopen = "$pass"; then + if test -z "$libdir" && test prog = "$linkmode"; then + func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" fi - case "$host" in + case $host in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both @@ -6590,9 +8131,9 @@ func_mode_link () if test -z "$libdir"; then # Link the convenience library - if test "$linkmode" = lib; then + if test lib = "$linkmode"; then deplibs="$dir/$old_library $deplibs" - elif test "$linkmode,$pass" = "prog,link"; then + elif test prog,link = "$linkmode,$pass"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else @@ -6602,14 +8143,14 @@ func_mode_link () fi - if test "$linkmode" = prog && test "$pass" != link; then + if test prog = "$linkmode" && test link != "$pass"; then func_append newlib_search_path " $ladir" deplibs="$lib $deplibs" - linkalldeplibs=no - if test "$link_all_deplibs" != no || test -z "$library_names" || - test "$build_libtool_libs" = no; then - linkalldeplibs=yes + linkalldeplibs=false + if test no != "$link_all_deplibs" || test -z "$library_names" || + test no = "$build_libtool_libs"; then + linkalldeplibs=: fi tmp_libs= @@ -6621,14 +8162,14 @@ func_mode_link () ;; esac # Need to link against all dependency_libs? - if test "$linkalldeplibs" = yes; then + if $linkalldeplibs; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi - if $opt_preserve_dup_deps ; then + if $opt_preserve_dup_deps; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac @@ -6638,15 +8179,15 @@ func_mode_link () continue fi # $linkmode = prog... - if test "$linkmode,$pass" = "prog,link"; then + if test prog,link = "$linkmode,$pass"; then if test -n "$library_names" && - { { test "$prefer_static_libs" = no || - test "$prefer_static_libs,$installed" = "built,yes"; } || + { { test no = "$prefer_static_libs" || + test built,yes = "$prefer_static_libs,$installed"; } || test -z "$old_library"; }; then # We need to hardcode the library path - if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then + if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then # Make sure the rpath contains only unique directories. - case "$temp_rpath:" in + case $temp_rpath: in *"$absdir:"*) ;; *) func_append temp_rpath "$absdir:" ;; esac @@ -6675,9 +8216,9 @@ func_mode_link () esac fi # $linkmode,$pass = prog,link... - if test "$alldeplibs" = yes && - { test "$deplibs_check_method" = pass_all || - { test "$build_libtool_libs" = yes && + if $alldeplibs && + { test pass_all = "$deplibs_check_method" || + { test yes = "$build_libtool_libs" && test -n "$library_names"; }; }; then # We only need to search for static libraries continue @@ -6686,19 +8227,19 @@ func_mode_link () link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs - if test "$use_static_libs" = built && test "$installed" = yes; then + if test built = "$use_static_libs" && test yes = "$installed"; then use_static_libs=no fi if test -n "$library_names" && - { test "$use_static_libs" = no || test -z "$old_library"; }; then + { test no = "$use_static_libs" || test -z "$old_library"; }; then case $host in - *cygwin* | *mingw* | *cegcc*) + *cygwin* | *mingw* | *cegcc* | *os2*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no ;; *) - if test "$installed" = no; then + if test no = "$installed"; then func_append notinst_deplibs " $lib" need_relink=yes fi @@ -6708,24 +8249,24 @@ func_mode_link () # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! - dlopenmodule="" + dlopenmodule= for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then - dlopenmodule="$dlpremoduletest" + dlopenmodule=$dlpremoduletest break fi done - if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then + if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then echo - if test "$linkmode" = prog; then + if test prog = "$linkmode"; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi - if test "$linkmode" = lib && - test "$hardcode_into_libs" = yes; then + if test lib = "$linkmode" && + test yes = "$hardcode_into_libs"; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. @@ -6753,43 +8294,43 @@ func_mode_link () # figure out the soname set dummy $library_names shift - realname="$1" + realname=$1 shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then - soname="$dlname" + soname=$dlname elif test -n "$soname_spec"; then # bleh windows case $host in - *cygwin* | mingw* | *cegcc*) + *cygwin* | mingw* | *cegcc* | *os2*) func_arith $current - $age major=$func_arith_result - versuffix="-$major" + versuffix=-$major ;; esac eval soname=\"$soname_spec\" else - soname="$realname" + soname=$realname fi # Make a new name for the extract_expsyms_cmds to use - soroot="$soname" + soroot=$soname func_basename "$soroot" - soname="$func_basename_result" + soname=$func_basename_result func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else - func_verbose "extracting exported symbol list from \`$soname'" + func_verbose "extracting exported symbol list from '$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else - func_verbose "generating import library for \`$soname'" + func_verbose "generating import library for '$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library @@ -6797,58 +8338,58 @@ func_mode_link () linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" - if test "$linkmode" = prog || test "$opt_mode" != relink; then + if test prog = "$linkmode" || test relink != "$opt_mode"; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) - if test "$hardcode_direct" = no; then - add="$dir/$linklib" + if test no = "$hardcode_direct"; then + add=$dir/$linklib case $host in - *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; - *-*-sysv4*uw2*) add_dir="-L$dir" ;; + *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; + *-*-sysv4*uw2*) add_dir=-L$dir ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ - *-*-unixware7*) add_dir="-L$dir" ;; + *-*-unixware7*) add_dir=-L$dir ;; *-*-darwin* ) - # if the lib is a (non-dlopened) module then we can not + # if the lib is a (non-dlopened) module then we cannot # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | - $GREP ": [^:]* bundle" >/dev/null ; then + $GREP ": [^:]* bundle" >/dev/null; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" - if test -z "$old_library" ; then + if test -z "$old_library"; then echo echo "*** And there doesn't seem to be a static archive available" echo "*** The link will probably fail, sorry" else - add="$dir/$old_library" + add=$dir/$old_library fi elif test -n "$old_library"; then - add="$dir/$old_library" + add=$dir/$old_library fi fi esac - elif test "$hardcode_minus_L" = no; then + elif test no = "$hardcode_minus_L"; then case $host in - *-*-sunos*) add_shlibpath="$dir" ;; + *-*-sunos*) add_shlibpath=$dir ;; esac - add_dir="-L$dir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = no; then - add_shlibpath="$dir" - add="-l$name" + add_dir=-L$dir + add=-l$name + elif test no = "$hardcode_shlibpath_var"; then + add_shlibpath=$dir + add=-l$name else lib_linked=no fi ;; relink) - if test "$hardcode_direct" = yes && - test "$hardcode_direct_absolute" = no; then - add="$dir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$absdir" + if test yes = "$hardcode_direct" && + test no = "$hardcode_direct_absolute"; then + add=$dir/$linklib + elif test yes = "$hardcode_minus_L"; then + add_dir=-L$absdir # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in @@ -6857,10 +8398,10 @@ func_mode_link () ;; esac fi - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - add_shlibpath="$dir" - add="-l$name" + add=-l$name + elif test yes = "$hardcode_shlibpath_var"; then + add_shlibpath=$dir + add=-l$name else lib_linked=no fi @@ -6868,7 +8409,7 @@ func_mode_link () *) lib_linked=no ;; esac - if test "$lib_linked" != yes; then + if test yes != "$lib_linked"; then func_fatal_configuration "unsupported hardcode properties" fi @@ -6878,15 +8419,15 @@ func_mode_link () *) func_append compile_shlibpath "$add_shlibpath:" ;; esac fi - if test "$linkmode" = prog; then + if test prog = "$linkmode"; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" - if test "$hardcode_direct" != yes && - test "$hardcode_minus_L" != yes && - test "$hardcode_shlibpath_var" = yes; then + if test yes != "$hardcode_direct" && + test yes != "$hardcode_minus_L" && + test yes = "$hardcode_shlibpath_var"; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; @@ -6895,33 +8436,33 @@ func_mode_link () fi fi - if test "$linkmode" = prog || test "$opt_mode" = relink; then + if test prog = "$linkmode" || test relink = "$opt_mode"; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. - if test "$hardcode_direct" = yes && - test "$hardcode_direct_absolute" = no; then - add="$libdir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$libdir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then + if test yes = "$hardcode_direct" && + test no = "$hardcode_direct_absolute"; then + add=$libdir/$linklib + elif test yes = "$hardcode_minus_L"; then + add_dir=-L$libdir + add=-l$name + elif test yes = "$hardcode_shlibpath_var"; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac - add="-l$name" - elif test "$hardcode_automatic" = yes; then + add=-l$name + elif test yes = "$hardcode_automatic"; then if test -n "$inst_prefix_dir" && - test -f "$inst_prefix_dir$libdir/$linklib" ; then - add="$inst_prefix_dir$libdir/$linklib" + test -f "$inst_prefix_dir$libdir/$linklib"; then + add=$inst_prefix_dir$libdir/$linklib else - add="$libdir/$linklib" + add=$libdir/$linklib fi else # We cannot seem to hardcode it, guess we'll fake it. - add_dir="-L$libdir" + add_dir=-L$libdir # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in @@ -6930,10 +8471,10 @@ func_mode_link () ;; esac fi - add="-l$name" + add=-l$name fi - if test "$linkmode" = prog; then + if test prog = "$linkmode"; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else @@ -6941,43 +8482,43 @@ func_mode_link () test -n "$add" && deplibs="$add $deplibs" fi fi - elif test "$linkmode" = prog; then + elif test prog = "$linkmode"; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. - if test "$hardcode_direct" != unsupported; then - test -n "$old_library" && linklib="$old_library" + if test unsupported != "$hardcode_direct"; then + test -n "$old_library" && linklib=$old_library compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi - elif test "$build_libtool_libs" = yes; then + elif test yes = "$build_libtool_libs"; then # Not a shared library - if test "$deplibs_check_method" != pass_all; then + if test pass_all != "$deplibs_check_method"; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo - $ECHO "*** Warning: This system can not link to static lib archive $lib." + $ECHO "*** Warning: This system cannot link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." - if test "$module" = yes; then + if test yes = "$module"; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + echo "*** lists from a program, using 'nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." - echo "*** \`nm' from GNU binutils and a full rebuild may help." + echo "*** 'nm' from GNU binutils and a full rebuild may help." fi - if test "$build_old_libs" = no; then + if test no = "$build_old_libs"; then build_libtool_libs=module build_old_libs=yes else @@ -6990,11 +8531,11 @@ func_mode_link () fi fi # link shared/static library? - if test "$linkmode" = lib; then + if test lib = "$linkmode"; then if test -n "$dependency_libs" && - { test "$hardcode_into_libs" != yes || - test "$build_old_libs" = yes || - test "$link_static" = yes; }; then + { test yes != "$hardcode_into_libs" || + test yes = "$build_old_libs" || + test yes = "$link_static"; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do @@ -7008,12 +8549,12 @@ func_mode_link () *) func_append temp_deplibs " $libdir";; esac done - dependency_libs="$temp_deplibs" + dependency_libs=$temp_deplibs fi func_append newlib_search_path " $absdir" # Link against this library - test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" + test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do @@ -7023,7 +8564,7 @@ func_mode_link () func_resolve_sysroot "$func_stripname_result";; *) func_resolve_sysroot "$deplib" ;; esac - if $opt_preserve_dup_deps ; then + if $opt_preserve_dup_deps; then case "$tmp_libs " in *" $func_resolve_sysroot_result "*) func_append specialdeplibs " $func_resolve_sysroot_result" ;; @@ -7032,12 +8573,12 @@ func_mode_link () func_append tmp_libs " $func_resolve_sysroot_result" done - if test "$link_all_deplibs" != no; then + if test no != "$link_all_deplibs"; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in - -L*) path="$deplib" ;; + -L*) path=$deplib ;; *.la) func_resolve_sysroot "$deplib" deplib=$func_resolve_sysroot_result @@ -7045,12 +8586,12 @@ func_mode_link () dir=$func_dirname_result # We need an absolute path. case $dir in - [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; + [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then - func_warning "cannot determine absolute directory name of \`$dir'" - absdir="$dir" + func_warning "cannot determine absolute directory name of '$dir'" + absdir=$dir fi ;; esac @@ -7058,35 +8599,35 @@ func_mode_link () case $host in *-*-darwin*) depdepl= - eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` - if test -n "$deplibrary_names" ; then - for tmp in $deplibrary_names ; do + eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` + if test -n "$deplibrary_names"; then + for tmp in $deplibrary_names; do depdepl=$tmp done - if test -f "$absdir/$objdir/$depdepl" ; then - depdepl="$absdir/$objdir/$depdepl" - darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` + if test -f "$absdir/$objdir/$depdepl"; then + depdepl=$absdir/$objdir/$depdepl + darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then - darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` + darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi - func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" - func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" + func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" + func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" path= fi fi ;; *) - path="-L$absdir/$objdir" + path=-L$absdir/$objdir ;; esac else - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ - func_fatal_error "\`$deplib' is not a valid libtool archive" + func_fatal_error "'$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ - func_warning "\`$deplib' seems to be moved" + func_warning "'$deplib' seems to be moved" - path="-L$absdir" + path=-L$absdir fi ;; esac @@ -7098,23 +8639,23 @@ func_mode_link () fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs - if test "$pass" = link; then - if test "$linkmode" = "prog"; then + if test link = "$pass"; then + if test prog = "$linkmode"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi - dependency_libs="$newdependency_libs" - if test "$pass" = dlpreopen; then + dependency_libs=$newdependency_libs + if test dlpreopen = "$pass"; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi - if test "$pass" != dlopen; then - if test "$pass" != conv; then + if test dlopen != "$pass"; then + test conv = "$pass" || { # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do @@ -7124,12 +8665,12 @@ func_mode_link () esac done newlib_search_path= - fi + } - if test "$linkmode,$pass" != "prog,link"; then - vars="deplibs" - else + if test prog,link = "$linkmode,$pass"; then vars="compile_deplibs finalize_deplibs" + else + vars=deplibs fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order @@ -7187,62 +8728,93 @@ func_mode_link () eval $var=\"$tmp_libs\" done # for var fi + + # Add Sun CC postdeps if required: + test CXX = "$tagname" && { + case $host_os in + linux*) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C++ 5.9 + func_suncc_cstd_abi + + if test no != "$suncc_use_cstd_abi"; then + func_append postdeps ' -library=Cstd -library=Crun' + fi + ;; + esac + ;; + + solaris*) + func_cc_basename "$CC" + case $func_cc_basename_result in + CC* | sunCC*) + func_suncc_cstd_abi + + if test no != "$suncc_use_cstd_abi"; then + func_append postdeps ' -library=Cstd -library=Crun' + fi + ;; + esac + ;; + esac + } + # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= - for i in $dependency_libs ; do + for i in $dependency_libs; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) - i="" + i= ;; esac - if test -n "$i" ; then + if test -n "$i"; then func_append tmp_libs " $i" fi done dependency_libs=$tmp_libs done # for pass - if test "$linkmode" = prog; then - dlfiles="$newdlfiles" + if test prog = "$linkmode"; then + dlfiles=$newdlfiles fi - if test "$linkmode" = prog || test "$linkmode" = lib; then - dlprefiles="$newdlprefiles" + if test prog = "$linkmode" || test lib = "$linkmode"; then + dlprefiles=$newdlprefiles fi case $linkmode in oldlib) - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - func_warning "\`-dlopen' is ignored for archives" + if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then + func_warning "'-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) - func_warning "\`-l' and \`-L' are ignored for archives" ;; + func_warning "'-l' and '-L' are ignored for archives" ;; esac test -n "$rpath" && \ - func_warning "\`-rpath' is ignored for archives" + func_warning "'-rpath' is ignored for archives" test -n "$xrpath" && \ - func_warning "\`-R' is ignored for archives" + func_warning "'-R' is ignored for archives" test -n "$vinfo" && \ - func_warning "\`-version-info/-version-number' is ignored for archives" + func_warning "'-version-info/-version-number' is ignored for archives" test -n "$release" && \ - func_warning "\`-release' is ignored for archives" + func_warning "'-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ - func_warning "\`-export-symbols' is ignored for archives" + func_warning "'-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no - oldlibs="$output" + oldlibs=$output func_append objs "$old_deplibs" ;; lib) - # Make sure we only generate libraries of the form `libNAME.la'. + # Make sure we only generate libraries of the form 'libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" @@ -7251,10 +8823,10 @@ func_mode_link () eval libname=\"$libname_spec\" ;; *) - test "$module" = no && \ - func_fatal_help "libtool library \`$output' must begin with \`lib'" + test no = "$module" \ + && func_fatal_help "libtool library '$output' must begin with 'lib'" - if test "$need_lib_prefix" != no; then + if test no != "$need_lib_prefix"; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result @@ -7268,8 +8840,8 @@ func_mode_link () esac if test -n "$objs"; then - if test "$deplibs_check_method" != pass_all; then - func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" + if test pass_all != "$deplibs_check_method"; then + func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" else echo $ECHO "*** Warning: Linking the shared library $output against the non-libtool" @@ -7278,21 +8850,21 @@ func_mode_link () fi fi - test "$dlself" != no && \ - func_warning "\`-dlopen self' is ignored for libtool libraries" + test no = "$dlself" \ + || func_warning "'-dlopen self' is ignored for libtool libraries" set dummy $rpath shift - test "$#" -gt 1 && \ - func_warning "ignoring multiple \`-rpath's for a libtool library" + test 1 -lt "$#" \ + && func_warning "ignoring multiple '-rpath's for a libtool library" - install_libdir="$1" + install_libdir=$1 oldlibs= if test -z "$rpath"; then - if test "$build_libtool_libs" = yes; then + if test yes = "$build_libtool_libs"; then # Building a libtool convenience library. - # Some compilers have problems with a `.al' extension so + # Some compilers have problems with a '.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" @@ -7301,20 +8873,20 @@ func_mode_link () fi test -n "$vinfo" && \ - func_warning "\`-version-info/-version-number' is ignored for convenience libraries" + func_warning "'-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ - func_warning "\`-release' is ignored for convenience libraries" + func_warning "'-release' is ignored for convenience libraries" else # Parse the version information argument. - save_ifs="$IFS"; IFS=':' + save_ifs=$IFS; IFS=: set dummy $vinfo 0 0 0 shift - IFS="$save_ifs" + IFS=$save_ifs test -n "$7" && \ - func_fatal_help "too many parameters to \`-version-info'" + func_fatal_help "too many parameters to '-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts @@ -7322,45 +8894,45 @@ func_mode_link () case $vinfo_number in yes) - number_major="$1" - number_minor="$2" - number_revision="$3" + number_major=$1 + number_minor=$2 + number_revision=$3 # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix - # which has an extra 1 added just for fun + # that has an extra 1 added just for fun # case $version_type in # correct linux to gnu/linux during the next big refactor - darwin|linux|osf|windows|none) + darwin|freebsd-elf|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result - age="$number_minor" - revision="$number_revision" + age=$number_minor + revision=$number_revision ;; - freebsd-aout|freebsd-elf|qnx|sunos) - current="$number_major" - revision="$number_minor" - age="0" + freebsd-aout|qnx|sunos) + current=$number_major + revision=$number_minor + age=0 ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result - age="$number_minor" - revision="$number_minor" + age=$number_minor + revision=$number_minor lt_irix_increment=no ;; *) - func_fatal_configuration "$modename: unknown library version type \`$version_type'" + func_fatal_configuration "$modename: unknown library version type '$version_type'" ;; esac ;; no) - current="$1" - revision="$2" - age="$3" + current=$1 + revision=$2 + age=$3 ;; esac @@ -7368,30 +8940,30 @@ func_mode_link () case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) - func_error "CURRENT \`$current' must be a nonnegative integer" - func_fatal_error "\`$vinfo' is not valid version information" + func_error "CURRENT '$current' must be a nonnegative integer" + func_fatal_error "'$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) - func_error "REVISION \`$revision' must be a nonnegative integer" - func_fatal_error "\`$vinfo' is not valid version information" + func_error "REVISION '$revision' must be a nonnegative integer" + func_fatal_error "'$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) - func_error "AGE \`$age' must be a nonnegative integer" - func_fatal_error "\`$vinfo' is not valid version information" + func_error "AGE '$age' must be a nonnegative integer" + func_fatal_error "'$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then - func_error "AGE \`$age' is greater than the current interface number \`$current'" - func_fatal_error "\`$vinfo' is not valid version information" + func_error "AGE '$age' is greater than the current interface number '$current'" + func_fatal_error "'$vinfo' is not valid version information" fi # Calculate the version variables. @@ -7406,26 +8978,36 @@ func_mode_link () # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result - versuffix="$major.$age.$revision" + versuffix=$major.$age.$revision # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result - xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" + xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + # On Darwin other compilers + case $CC in + nagfor*) + verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" + ;; + *) + verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + ;; + esac ;; freebsd-aout) - major=".$current" - versuffix=".$current.$revision"; + major=.$current + versuffix=.$current.$revision ;; freebsd-elf) - major=".$current" - versuffix=".$current" + func_arith $current - $age + major=.$func_arith_result + versuffix=$major.$age.$revision ;; irix | nonstopux) - if test "X$lt_irix_increment" = "Xno"; then + if test no = "$lt_irix_increment"; then func_arith $current - $age else func_arith $current - $age + 1 @@ -7436,69 +9018,74 @@ func_mode_link () nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac - verstring="$verstring_prefix$major.$revision" + verstring=$verstring_prefix$major.$revision # Add in all the interfaces that we are compatible with. loop=$revision - while test "$loop" -ne 0; do + while test 0 -ne "$loop"; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result - verstring="$verstring_prefix$major.$iface:$verstring" + verstring=$verstring_prefix$major.$iface:$verstring done - # Before this point, $major must not contain `.'. + # Before this point, $major must not contain '.'. major=.$major - versuffix="$major.$revision" + versuffix=$major.$revision ;; linux) # correct to gnu/linux during the next big refactor func_arith $current - $age major=.$func_arith_result - versuffix="$major.$age.$revision" + versuffix=$major.$age.$revision ;; osf) func_arith $current - $age major=.$func_arith_result - versuffix=".$current.$age.$revision" - verstring="$current.$age.$revision" + versuffix=.$current.$age.$revision + verstring=$current.$age.$revision # Add in all the interfaces that we are compatible with. loop=$age - while test "$loop" -ne 0; do + while test 0 -ne "$loop"; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result - verstring="$verstring:${iface}.0" + verstring=$verstring:$iface.0 done # Make executables depend on our current version. - func_append verstring ":${current}.0" + func_append verstring ":$current.0" ;; qnx) - major=".$current" - versuffix=".$current" + major=.$current + versuffix=.$current + ;; + + sco) + major=.$current + versuffix=.$current ;; sunos) - major=".$current" - versuffix=".$current.$revision" + major=.$current + versuffix=.$current.$revision ;; windows) # Use '-' rather than '.', since we only want one - # extension on DOS 8.3 filesystems. + # extension on DOS 8.3 file systems. func_arith $current - $age major=$func_arith_result - versuffix="-$major" + versuffix=-$major ;; *) - func_fatal_configuration "unknown library version type \`$version_type'" + func_fatal_configuration "unknown library version type '$version_type'" ;; esac @@ -7512,42 +9099,45 @@ func_mode_link () verstring= ;; *) - verstring="0.0" + verstring=0.0 ;; esac - if test "$need_version" = no; then + if test no = "$need_version"; then versuffix= else - versuffix=".0.0" + versuffix=.0.0 fi fi # Remove version info from name if versioning should be avoided - if test "$avoid_version" = yes && test "$need_version" = no; then + if test yes,no = "$avoid_version,$need_version"; then major= versuffix= - verstring="" + verstring= fi # Check to see if the archive will have undefined symbols. - if test "$allow_undefined" = yes; then - if test "$allow_undefined_flag" = unsupported; then - func_warning "undefined symbols not allowed in $host shared libraries" - build_libtool_libs=no - build_old_libs=yes + if test yes = "$allow_undefined"; then + if test unsupported = "$allow_undefined_flag"; then + if test yes = "$build_old_libs"; then + func_warning "undefined symbols not allowed in $host shared libraries; building static only" + build_libtool_libs=no + else + func_fatal_error "can't build $host shared library unless -no-undefined is specified" + fi fi else # Don't allow undefined symbols. - allow_undefined_flag="$no_undefined_flag" + allow_undefined_flag=$no_undefined_flag fi fi - func_generate_dlsyms "$libname" "$libname" "yes" + func_generate_dlsyms "$libname" "$libname" : func_append libobjs " $symfileobj" - test "X$libobjs" = "X " && libobjs= + test " " = "$libobjs" && libobjs= - if test "$opt_mode" != relink; then + if test relink != "$opt_mode"; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= @@ -7556,8 +9146,8 @@ func_mode_link () case $p in *.$objext | *.gcno) ;; - $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) - if test "X$precious_files_regex" != "X"; then + $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) + if test -n "$precious_files_regex"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue @@ -7573,11 +9163,11 @@ func_mode_link () fi # Now set the variables for building old libraries. - if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then + if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then func_append oldlibs " $output_objdir/$libname.$libext" # Transform .lo files to .o files. - oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` + oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. @@ -7598,13 +9188,13 @@ func_mode_link () *) func_append finalize_rpath " $libdir" ;; esac done - if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then + if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened - old_dlfiles="$dlfiles" + old_dlfiles=$dlfiles dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in @@ -7614,7 +9204,7 @@ func_mode_link () done # Make sure dlprefiles contains only unique files - old_dlprefiles="$dlprefiles" + old_dlprefiles=$dlprefiles dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in @@ -7623,7 +9213,7 @@ func_mode_link () esac done - if test "$build_libtool_libs" = yes; then + if test yes = "$build_libtool_libs"; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) @@ -7647,7 +9237,7 @@ func_mode_link () ;; *) # Add libc to deplibs on all other systems if necessary. - if test "$build_libtool_need_lc" = "yes"; then + if test yes = "$build_libtool_need_lc"; then func_append deplibs " -lc" fi ;; @@ -7663,9 +9253,9 @@ func_mode_link () # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? - release="" - versuffix="" - major="" + release= + versuffix= + major= newdeplibs= droppeddeps=no case $deplibs_check_method in @@ -7694,20 +9284,20 @@ EOF -l*) func_stripname -l '' "$i" name=$func_stripname_result - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + if test yes = "$allow_libtool_libs_with_static_runtimes"; then case " $predeps $postdeps " in *" $i "*) func_append newdeplibs " $i" - i="" + i= ;; esac fi - if test -n "$i" ; then + if test -n "$i"; then libname=`eval "\\$ECHO \"$libname_spec\""` deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` set dummy $deplib_matches; shift deplib_match=$1 - if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then + if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then func_append newdeplibs " $i" else droppeddeps=yes @@ -7737,20 +9327,20 @@ EOF $opt_dry_run || $RM conftest if $LTCC $LTCFLAGS -o conftest conftest.c $i; then ldd_output=`ldd conftest` - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + if test yes = "$allow_libtool_libs_with_static_runtimes"; then case " $predeps $postdeps " in *" $i "*) func_append newdeplibs " $i" - i="" + i= ;; esac fi - if test -n "$i" ; then + if test -n "$i"; then libname=`eval "\\$ECHO \"$libname_spec\""` deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` set dummy $deplib_matches; shift deplib_match=$1 - if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then + if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then func_append newdeplibs " $i" else droppeddeps=yes @@ -7787,24 +9377,24 @@ EOF -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + if test yes = "$allow_libtool_libs_with_static_runtimes"; then case " $predeps $postdeps " in *" $a_deplib "*) func_append newdeplibs " $a_deplib" - a_deplib="" + a_deplib= ;; esac fi - if test -n "$a_deplib" ; then + if test -n "$a_deplib"; then libname=`eval "\\$ECHO \"$libname_spec\""` if test -n "$file_magic_glob"; then libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` else libnameglob=$libname fi - test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` + test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do - if test "$want_nocaseglob" = yes; then + if test yes = "$want_nocaseglob"; then shopt -s nocaseglob potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` $nocaseglob @@ -7822,25 +9412,25 @@ EOF # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? - potlib="$potent_lib" + potlib=$potent_lib while test -h "$potlib" 2>/dev/null; do - potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` + potliblink=`ls -ld $potlib | $SED 's/.* -> //'` case $potliblink in - [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; - *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; + [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; + *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then func_append newdeplibs " $a_deplib" - a_deplib="" + a_deplib= break 2 fi done done fi - if test -n "$a_deplib" ; then + if test -n "$a_deplib"; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." @@ -7848,7 +9438,7 @@ EOF echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then + if test -z "$potlib"; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" @@ -7871,30 +9461,30 @@ EOF -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + if test yes = "$allow_libtool_libs_with_static_runtimes"; then case " $predeps $postdeps " in *" $a_deplib "*) func_append newdeplibs " $a_deplib" - a_deplib="" + a_deplib= ;; esac fi - if test -n "$a_deplib" ; then + if test -n "$a_deplib"; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do - potlib="$potent_lib" # see symlink-check above in file_magic test + potlib=$potent_lib # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then func_append newdeplibs " $a_deplib" - a_deplib="" + a_deplib= break 2 fi done done fi - if test -n "$a_deplib" ; then + if test -n "$a_deplib"; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." @@ -7902,7 +9492,7 @@ EOF echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then + if test -z "$potlib"; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" @@ -7918,18 +9508,18 @@ EOF done # Gone through all deplibs. ;; none | unknown | *) - newdeplibs="" + newdeplibs= tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` - if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then - for i in $predeps $postdeps ; do + if test yes = "$allow_libtool_libs_with_static_runtimes"; then + for i in $predeps $postdeps; do # can't use Xsed below, because $i might contain '/' - tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` + tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` done fi case $tmp_deplibs in *[!\ \ ]*) echo - if test "X$deplibs_check_method" = "Xnone"; then + if test none = "$deplibs_check_method"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." @@ -7953,8 +9543,8 @@ EOF ;; esac - if test "$droppeddeps" = yes; then - if test "$module" = yes; then + if test yes = "$droppeddeps"; then + if test yes = "$module"; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" @@ -7963,12 +9553,12 @@ EOF if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + echo "*** lists from a program, using 'nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." - echo "*** \`nm' from GNU binutils and a full rebuild may help." + echo "*** 'nm' from GNU binutils and a full rebuild may help." fi - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" + if test no = "$build_old_libs"; then + oldlibs=$output_objdir/$libname.$libext build_libtool_libs=module build_old_libs=yes else @@ -7979,14 +9569,14 @@ EOF echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." - if test "$allow_undefined" = no; then + if test no = "$allow_undefined"; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" + if test no = "$build_old_libs"; then + oldlibs=$output_objdir/$libname.$libext build_libtool_libs=module build_old_libs=yes else @@ -8032,7 +9622,7 @@ EOF *) func_append new_libs " $deplib" ;; esac done - deplibs="$new_libs" + deplibs=$new_libs # All the library-specific variables (install_libdir is set above). library_names= @@ -8040,25 +9630,25 @@ EOF dlname= # Test again, we may have decided not to build it any more - if test "$build_libtool_libs" = yes; then - # Remove ${wl} instances when linking with ld. + if test yes = "$build_libtool_libs"; then + # Remove $wl instances when linking with ld. # FIXME: should test the right _cmds variable. case $archive_cmds in *\$LD\ *) wl= ;; esac - if test "$hardcode_into_libs" = yes; then + if test yes = "$hardcode_into_libs"; then # Hardcode the library paths hardcode_libdirs= dep_rpath= - rpath="$finalize_rpath" - test "$opt_mode" != relink && rpath="$compile_rpath$rpath" + rpath=$finalize_rpath + test relink = "$opt_mode" || rpath=$compile_rpath$rpath for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then func_replace_sysroot "$libdir" libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" + hardcode_libdirs=$libdir else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in @@ -8083,7 +9673,7 @@ EOF # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" + libdir=$hardcode_libdirs eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then @@ -8097,8 +9687,8 @@ EOF test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi - shlibpath="$finalize_shlibpath" - test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" + shlibpath=$finalize_shlibpath + test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi @@ -8108,19 +9698,19 @@ EOF eval library_names=\"$library_names_spec\" set dummy $library_names shift - realname="$1" + realname=$1 shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else - soname="$realname" + soname=$realname fi if test -z "$dlname"; then dlname=$soname fi - lib="$output_objdir/$realname" + lib=$output_objdir/$realname linknames= for link do @@ -8134,7 +9724,7 @@ EOF delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" - export_symbols="$output_objdir/$libname.uexp" + export_symbols=$output_objdir/$libname.uexp func_append delfiles " $export_symbols" fi @@ -8143,31 +9733,31 @@ EOF cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile - if test "x`$SED 1q $export_symbols`" != xEXPORTS; then + func_dll_def_p "$export_symbols" || { # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. - orig_export_symbols="$export_symbols" + orig_export_symbols=$export_symbols export_symbols= always_export_symbols=yes - fi + } fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then - if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then - func_verbose "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" + if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then + func_verbose "generating symbol list for '$libname.la'" + export_symbols=$output_objdir/$libname.exp $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds - save_ifs="$IFS"; IFS='~' + save_ifs=$IFS; IFS='~' for cmd1 in $cmds; do - IFS="$save_ifs" + IFS=$save_ifs # Take the normal branch if the nm_file_list_spec branch # doesn't work or if tool conversion is not needed. case $nm_file_list_spec~$to_tool_file_cmd in @@ -8181,7 +9771,7 @@ EOF try_normal_branch=no ;; esac - if test "$try_normal_branch" = yes \ + if test yes = "$try_normal_branch" \ && { test "$len" -lt "$max_cmd_len" \ || test "$max_cmd_len" -le -1; } then @@ -8192,7 +9782,7 @@ EOF output_la=$func_basename_result save_libobjs=$libobjs save_output=$output - output=${output_objdir}/${output_la}.nm + output=$output_objdir/$output_la.nm func_to_tool_file "$output" libobjs=$nm_file_list_spec$func_to_tool_file_result func_append delfiles " $output" @@ -8215,8 +9805,8 @@ EOF break fi done - IFS="$save_ifs" - if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then + IFS=$save_ifs + if test -n "$export_symbols_regex" && test : != "$skipped_export"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi @@ -8224,16 +9814,16 @@ EOF fi if test -n "$export_symbols" && test -n "$include_expsyms"; then - tmp_export_symbols="$export_symbols" - test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" + tmp_export_symbols=$export_symbols + test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi - if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then + if test : != "$skipped_export" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. - func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" + func_verbose "filter symbol list for '$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of - # 's' commands which not all seds can handle. GNU sed should be fine + # 's' commands, which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. @@ -8252,11 +9842,11 @@ EOF ;; esac done - deplibs="$tmp_deplibs" + deplibs=$tmp_deplibs if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && - test "$compiler_needs_object" = yes && + test yes = "$compiler_needs_object" && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. @@ -8267,7 +9857,7 @@ EOF eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else - gentop="$output_objdir/${outputname}x" + gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $convenience @@ -8276,18 +9866,18 @@ EOF fi fi - if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then + if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking - if test "$opt_mode" = relink; then + if test relink = "$opt_mode"; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. - if test "$module" = yes && test -n "$module_cmds" ; then + if test yes = "$module" && test -n "$module_cmds"; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds @@ -8305,7 +9895,7 @@ EOF fi fi - if test "X$skipped_export" != "X:" && + if test : != "$skipped_export" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then @@ -8338,8 +9928,8 @@ EOF last_robj= k=1 - if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then - output=${output_objdir}/${output_la}.lnkscript + if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then + output=$output_objdir/$output_la.lnkscript func_verbose "creating GNU ld script: $output" echo 'INPUT (' > $output for obj in $save_libobjs @@ -8351,14 +9941,14 @@ EOF func_append delfiles " $output" func_to_tool_file "$output" output=$func_to_tool_file_result - elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then - output=${output_objdir}/${output_la}.lnk + elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then + output=$output_objdir/$output_la.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= - if test "$compiler_needs_object" = yes; then + if test yes = "$compiler_needs_object"; then firstobj="$1 " shift fi @@ -8373,7 +9963,7 @@ EOF else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." - output=$output_objdir/$output_la-${k}.$objext + output=$output_objdir/$output_la-$k.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result @@ -8385,13 +9975,13 @@ EOF func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result - if test "X$objlist" = X || + if test -z "$objlist" || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. - if test "$k" -eq 1 ; then + if test 1 -eq "$k"; then # The first file doesn't have a previous command to add. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" @@ -8401,10 +9991,10 @@ EOF reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" fi - last_robj=$output_objdir/$output_la-${k}.$objext + last_robj=$output_objdir/$output_la-$k.$objext func_arith $k + 1 k=$func_arith_result - output=$output_objdir/$output_la-${k}.$objext + output=$output_objdir/$output_la-$k.$objext objlist=" $obj" func_len " $last_robj" func_arith $len0 + $func_len_result @@ -8416,9 +10006,9 @@ EOF # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ reload_objs="$objlist $last_robj" - eval concat_cmds=\"\${concat_cmds}$reload_cmds\" + eval concat_cmds=\"\$concat_cmds$reload_cmds\" if test -n "$last_robj"; then - eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" + eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi func_append delfiles " $output" @@ -8426,9 +10016,9 @@ EOF output= fi - if ${skipped_export-false}; then - func_verbose "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" + ${skipped_export-false} && { + func_verbose "generating symbol list for '$libname.la'" + export_symbols=$output_objdir/$libname.exp $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. @@ -8437,16 +10027,16 @@ EOF if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi - fi + } test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. - save_ifs="$IFS"; IFS='~' + save_ifs=$IFS; IFS='~' for cmd in $concat_cmds; do - IFS="$save_ifs" - $opt_silent || { + IFS=$save_ifs + $opt_quiet || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } @@ -8454,7 +10044,7 @@ EOF lt_exit=$? # Restore the uninstalled library and exit - if test "$opt_mode" = relink; then + if test relink = "$opt_mode"; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) @@ -8463,7 +10053,7 @@ EOF exit $lt_exit } done - IFS="$save_ifs" + IFS=$save_ifs if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' @@ -8471,18 +10061,18 @@ EOF fi fi - if ${skipped_export-false}; then + ${skipped_export-false} && { if test -n "$export_symbols" && test -n "$include_expsyms"; then - tmp_export_symbols="$export_symbols" - test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" + tmp_export_symbols=$export_symbols + test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. - func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" + func_verbose "filter symbol list for '$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of - # 's' commands which not all seds can handle. GNU sed should be fine + # 's' commands, which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. @@ -8491,7 +10081,7 @@ EOF export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi - fi + } libobjs=$output # Restore the value of output. @@ -8505,7 +10095,7 @@ EOF # value of $libobjs for piecewise linking. # Do each of the archive commands. - if test "$module" = yes && test -n "$module_cmds" ; then + if test yes = "$module" && test -n "$module_cmds"; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else @@ -8527,7 +10117,7 @@ EOF # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then - gentop="$output_objdir/${outputname}x" + gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $dlprefiles @@ -8535,11 +10125,12 @@ EOF test "X$libobjs" = "X " && libobjs= fi - save_ifs="$IFS"; IFS='~' + save_ifs=$IFS; IFS='~' for cmd in $cmds; do - IFS="$save_ifs" + IFS=$sp$nl eval cmd=\"$cmd\" - $opt_silent || { + IFS=$save_ifs + $opt_quiet || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } @@ -8547,7 +10138,7 @@ EOF lt_exit=$? # Restore the uninstalled library and exit - if test "$opt_mode" = relink; then + if test relink = "$opt_mode"; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) @@ -8556,10 +10147,10 @@ EOF exit $lt_exit } done - IFS="$save_ifs" + IFS=$save_ifs # Restore the uninstalled library and exit - if test "$opt_mode" = relink; then + if test relink = "$opt_mode"; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then @@ -8579,39 +10170,39 @@ EOF done # If -module or -export-dynamic was specified, set the dlname. - if test "$module" = yes || test "$export_dynamic" = yes; then + if test yes = "$module" || test yes = "$export_dynamic"; then # On all known operating systems, these are identical. - dlname="$soname" + dlname=$soname fi fi ;; obj) - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - func_warning "\`-dlopen' is ignored for objects" + if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then + func_warning "'-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) - func_warning "\`-l' and \`-L' are ignored for objects" ;; + func_warning "'-l' and '-L' are ignored for objects" ;; esac test -n "$rpath" && \ - func_warning "\`-rpath' is ignored for objects" + func_warning "'-rpath' is ignored for objects" test -n "$xrpath" && \ - func_warning "\`-R' is ignored for objects" + func_warning "'-R' is ignored for objects" test -n "$vinfo" && \ - func_warning "\`-version-info' is ignored for objects" + func_warning "'-version-info' is ignored for objects" test -n "$release" && \ - func_warning "\`-release' is ignored for objects" + func_warning "'-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ - func_fatal_error "cannot build library object \`$output' from non-libtool objects" + func_fatal_error "cannot build library object '$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" @@ -8619,7 +10210,7 @@ EOF ;; *) libobj= - obj="$output" + obj=$output ;; esac @@ -8632,17 +10223,19 @@ EOF # the extraction. reload_conv_objs= gentop= - # reload_cmds runs $LD directly, so let us get rid of - # -Wl from whole_archive_flag_spec and hope we can get by with - # turning comma into space.. - wl= - + # if reload_cmds runs $LD directly, get rid of -Wl from + # whole_archive_flag_spec and hope we can get by with turning comma + # into space. + case $reload_cmds in + *\$LD[\ \$]*) wl= ;; + esac if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" - reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` + test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` + reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags else - gentop="$output_objdir/${obj}x" + gentop=$output_objdir/${obj}x func_append generated " $gentop" func_extract_archives $gentop $convenience @@ -8651,12 +10244,12 @@ EOF fi # If we're not building shared, we need to use non_pic_objs - test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" + test yes = "$build_libtool_libs" || libobjs=$non_pic_objects # Create the old-style object. - reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test + reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs - output="$obj" + output=$obj func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. @@ -8668,7 +10261,7 @@ EOF exit $EXIT_SUCCESS fi - if test "$build_libtool_libs" != yes; then + test yes = "$build_libtool_libs" || { if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi @@ -8678,12 +10271,12 @@ EOF # $show "echo timestamp > $libobj" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS - fi + } - if test -n "$pic_flag" || test "$pic_mode" != default; then + if test -n "$pic_flag" || test default != "$pic_mode"; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" - output="$libobj" + output=$libobj func_execute_cmds "$reload_cmds" 'exit $?' fi @@ -8700,16 +10293,14 @@ EOF output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ - func_warning "\`-version-info' is ignored for programs" + func_warning "'-version-info' is ignored for programs" test -n "$release" && \ - func_warning "\`-release' is ignored for programs" + func_warning "'-release' is ignored for programs" - test "$preload" = yes \ - && test "$dlopen_support" = unknown \ - && test "$dlopen_self" = unknown \ - && test "$dlopen_self_static" = unknown && \ - func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." + $preload \ + && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ + && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) @@ -8723,11 +10314,11 @@ EOF *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). - if test "$tagname" = CXX ; then + if test CXX = "$tagname"; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) - func_append compile_command " ${wl}-bind_at_load" - func_append finalize_command " ${wl}-bind_at_load" + func_append compile_command " $wl-bind_at_load" + func_append finalize_command " $wl-bind_at_load" ;; esac fi @@ -8763,7 +10354,7 @@ EOF *) func_append new_libs " $deplib" ;; esac done - compile_deplibs="$new_libs" + compile_deplibs=$new_libs func_append compile_command " $compile_deplibs" @@ -8787,7 +10378,7 @@ EOF if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" + hardcode_libdirs=$libdir else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in @@ -8810,7 +10401,7 @@ EOF fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) - testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` + testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; @@ -8827,10 +10418,10 @@ EOF # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" + libdir=$hardcode_libdirs eval rpath=\" $hardcode_libdir_flag_spec\" fi - compile_rpath="$rpath" + compile_rpath=$rpath rpath= hardcode_libdirs= @@ -8838,7 +10429,7 @@ EOF if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" + hardcode_libdirs=$libdir else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in @@ -8863,45 +10454,43 @@ EOF # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" + libdir=$hardcode_libdirs eval rpath=\" $hardcode_libdir_flag_spec\" fi - finalize_rpath="$rpath" + finalize_rpath=$rpath - if test -n "$libobjs" && test "$build_old_libs" = yes; then + if test -n "$libobjs" && test yes = "$build_old_libs"; then # Transform all the library objects into standard objects. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` fi - func_generate_dlsyms "$outputname" "@PROGRAM@" "no" + func_generate_dlsyms "$outputname" "@PROGRAM@" false # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi - wrappers_required=yes + wrappers_required=: case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. - wrappers_required=no + wrappers_required=false ;; *cygwin* | *mingw* ) - if test "$build_libtool_libs" != yes; then - wrappers_required=no - fi + test yes = "$build_libtool_libs" || wrappers_required=false ;; *) - if test "$need_relink" = no || test "$build_libtool_libs" != yes; then - wrappers_required=no + if test no = "$need_relink" || test yes != "$build_libtool_libs"; then + wrappers_required=false fi ;; esac - if test "$wrappers_required" = no; then + $wrappers_required || { # Replace the output file specification. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` - link_command="$compile_command$compile_rpath" + link_command=$compile_command$compile_rpath # We have no uninstalled library dependencies, so finalize right now. exit_status=0 @@ -8914,12 +10503,12 @@ EOF fi # Delete the generated files. - if test -f "$output_objdir/${outputname}S.${objext}"; then - func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' + if test -f "$output_objdir/${outputname}S.$objext"; then + func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' fi exit $exit_status - fi + } if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" @@ -8949,9 +10538,9 @@ EOF fi fi - if test "$no_install" = yes; then + if test yes = "$no_install"; then # We don't need to create a wrapper script. - link_command="$compile_var$compile_command$compile_rpath" + link_command=$compile_var$compile_command$compile_rpath # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. @@ -8968,27 +10557,28 @@ EOF exit $EXIT_SUCCESS fi - if test "$hardcode_action" = relink; then - # Fast installation is not supported - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" + case $hardcode_action,$fast_install in + relink,*) + # Fast installation is not supported + link_command=$compile_var$compile_command$compile_rpath + relink_command=$finalize_var$finalize_command$finalize_rpath - func_warning "this platform does not like uninstalled shared libraries" - func_warning "\`$output' will be relinked during installation" - else - if test "$fast_install" != no; then - link_command="$finalize_var$compile_command$finalize_rpath" - if test "$fast_install" = yes; then - relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` - else - # fast_install is set to needless - relink_command= - fi - else - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - fi - fi + func_warning "this platform does not like uninstalled shared libraries" + func_warning "'$output' will be relinked during installation" + ;; + *,yes) + link_command=$finalize_var$compile_command$finalize_rpath + relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` + ;; + *,no) + link_command=$compile_var$compile_command$compile_rpath + relink_command=$finalize_var$finalize_command$finalize_rpath + ;; + *,needless) + link_command=$finalize_var$compile_command$finalize_rpath + relink_command= + ;; + esac # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` @@ -9045,8 +10635,8 @@ EOF func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result - cwrappersource="$output_path/$objdir/lt-$output_name.c" - cwrapper="$output_path/$output_name.exe" + cwrappersource=$output_path/$objdir/lt-$output_name.c + cwrapper=$output_path/$output_name.exe $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 @@ -9067,7 +10657,7 @@ EOF trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. - if test "x$build" = "x$host" ; then + if test "x$build" = "x$host"; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result @@ -9090,25 +10680,27 @@ EOF # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do - if test "$build_libtool_libs" = convenience; then - oldobjs="$libobjs_save $symfileobj" - addlibs="$convenience" - build_libtool_libs=no - else - if test "$build_libtool_libs" = module; then - oldobjs="$libobjs_save" + case $build_libtool_libs in + convenience) + oldobjs="$libobjs_save $symfileobj" + addlibs=$convenience build_libtool_libs=no - else + ;; + module) + oldobjs=$libobjs_save + addlibs=$old_convenience + build_libtool_libs=no + ;; + *) oldobjs="$old_deplibs $non_pic_objects" - if test "$preload" = yes && test -f "$symfileobj"; then - func_append oldobjs " $symfileobj" - fi - fi - addlibs="$old_convenience" - fi + $preload && test -f "$symfileobj" \ + && func_append oldobjs " $symfileobj" + addlibs=$old_convenience + ;; + esac if test -n "$addlibs"; then - gentop="$output_objdir/${outputname}x" + gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $addlibs @@ -9116,13 +10708,13 @@ EOF fi # Do each command in the archive commands. - if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then + if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then - gentop="$output_objdir/${outputname}x" + gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $dlprefiles @@ -9143,7 +10735,7 @@ EOF : else echo "copying selected object files to avoid basename conflicts..." - gentop="$output_objdir/${outputname}x" + gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs @@ -9152,7 +10744,7 @@ EOF for obj in $save_oldobjs do func_basename "$obj" - objbase="$func_basename_result" + objbase=$func_basename_result case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) @@ -9221,18 +10813,18 @@ EOF else # the above command should be used before it gets too long oldobjs=$objlist - if test "$obj" = "$last_oldobj" ; then + if test "$obj" = "$last_oldobj"; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" + eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist - if test "X$oldobjs" = "X" ; then + if test -z "$oldobjs"; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" @@ -9249,7 +10841,7 @@ EOF case $output in *.la) old_library= - test "$build_old_libs" = yes && old_library="$libname.$libext" + test yes = "$build_old_libs" && old_library=$libname.$libext func_verbose "creating $output" # Preserve any variables that may affect compiler behavior @@ -9264,31 +10856,31 @@ EOF fi done # Quote the link command for shipping. - relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" + relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` - if test "$hardcode_automatic" = yes ; then + if test yes = "$hardcode_automatic"; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do - if test "$installed" = yes; then + if test yes = "$installed"; then if test -z "$install_libdir"; then break fi - output="$output_objdir/$outputname"i + output=$output_objdir/${outputname}i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) func_basename "$deplib" - name="$func_basename_result" + name=$func_basename_result func_resolve_sysroot "$deplib" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` + eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` test -z "$libdir" && \ - func_fatal_error "\`$deplib' is not a valid libtool archive" + func_fatal_error "'$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" ;; -L*) @@ -9304,23 +10896,23 @@ EOF *) func_append newdependency_libs " $deplib" ;; esac done - dependency_libs="$newdependency_libs" + dependency_libs=$newdependency_libs newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" - name="$func_basename_result" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + name=$func_basename_result + eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ - func_fatal_error "\`$lib' is not a valid libtool archive" + func_fatal_error "'$lib' is not a valid libtool archive" func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; *) func_append newdlfiles " $lib" ;; esac done - dlfiles="$newdlfiles" + dlfiles=$newdlfiles newdlprefiles= for lib in $dlprefiles; do case $lib in @@ -9330,34 +10922,34 @@ EOF # didn't already link the preopened objects directly into # the library: func_basename "$lib" - name="$func_basename_result" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + name=$func_basename_result + eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ - func_fatal_error "\`$lib' is not a valid libtool archive" + func_fatal_error "'$lib' is not a valid libtool archive" func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" ;; esac done - dlprefiles="$newdlprefiles" + dlprefiles=$newdlprefiles else newdlfiles= for lib in $dlfiles; do case $lib in - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; + [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlfiles " $abs" done - dlfiles="$newdlfiles" + dlfiles=$newdlfiles newdlprefiles= for lib in $dlprefiles; do case $lib in - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; + [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlprefiles " $abs" done - dlprefiles="$newdlprefiles" + dlprefiles=$newdlprefiles fi $RM $output # place dlname in correct position for cygwin @@ -9373,10 +10965,9 @@ EOF case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. - if test "x$bindir" != x ; - then + if test -n "$bindir"; then func_relative_path "$install_libdir" "$bindir" - tdlname=$func_relative_path_result$dlname + tdlname=$func_relative_path_result/$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname @@ -9385,7 +10976,7 @@ EOF esac $ECHO > $output "\ # $outputname - a libtool library file -# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION +# Generated by $PROGRAM (GNU $PACKAGE) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. @@ -9399,7 +10990,7 @@ library_names='$library_names' # The name of the static archive. old_library='$old_library' -# Linker flags that can not go in dependency_libs. +# Linker flags that cannot go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. @@ -9425,7 +11016,7 @@ dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" - if test "$installed" = no && test "$need_relink" = yes; then + if test no,yes = "$installed,$need_relink"; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi @@ -9440,27 +11031,29 @@ relink_command=\"$relink_command\"" exit $EXIT_SUCCESS } -{ test "$opt_mode" = link || test "$opt_mode" = relink; } && - func_mode_link ${1+"$@"} +if test link = "$opt_mode" || test relink = "$opt_mode"; then + func_mode_link ${1+"$@"} +fi # func_mode_uninstall arg... func_mode_uninstall () { - $opt_debug - RM="$nonopt" + $debug_cmd + + RM=$nonopt files= - rmforce= + rmforce=false exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. - libtool_install_magic="$magic" + libtool_install_magic=$magic for arg do case $arg in - -f) func_append RM " $arg"; rmforce=yes ;; + -f) func_append RM " $arg"; rmforce=: ;; -*) func_append RM " $arg" ;; *) func_append files " $arg" ;; esac @@ -9473,18 +11066,18 @@ func_mode_uninstall () for file in $files; do func_dirname "$file" "" "." - dir="$func_dirname_result" - if test "X$dir" = X.; then - odir="$objdir" + dir=$func_dirname_result + if test . = "$dir"; then + odir=$objdir else - odir="$dir/$objdir" + odir=$dir/$objdir fi func_basename "$file" - name="$func_basename_result" - test "$opt_mode" = uninstall && odir="$dir" + name=$func_basename_result + test uninstall = "$opt_mode" && odir=$dir # Remember odir for removal later, being careful to avoid duplicates - if test "$opt_mode" = clean; then + if test clean = "$opt_mode"; then case " $rmdirs " in *" $odir "*) ;; *) func_append rmdirs " $odir" ;; @@ -9499,11 +11092,11 @@ func_mode_uninstall () elif test -d "$file"; then exit_status=1 continue - elif test "$rmforce" = yes; then + elif $rmforce; then continue fi - rmfiles="$file" + rmfiles=$file case $name in *.la) @@ -9517,7 +11110,7 @@ func_mode_uninstall () done test -n "$old_library" && func_append rmfiles " $odir/$old_library" - case "$opt_mode" in + case $opt_mode in clean) case " $library_names " in *" $dlname "*) ;; @@ -9528,12 +11121,12 @@ func_mode_uninstall () uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. - func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' + func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. - func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' + func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; @@ -9549,21 +11142,19 @@ func_mode_uninstall () func_source $dir/$name # Add PIC object to the list of files to remove. - if test -n "$pic_object" && - test "$pic_object" != none; then + if test -n "$pic_object" && test none != "$pic_object"; then func_append rmfiles " $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. - if test -n "$non_pic_object" && - test "$non_pic_object" != none; then + if test -n "$non_pic_object" && test none != "$non_pic_object"; then func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) - if test "$opt_mode" = clean ; then + if test clean = "$opt_mode"; then noexename=$name case $file in *.exe) @@ -9590,12 +11181,12 @@ func_mode_uninstall () # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles - func_append rmfiles " $odir/$name $odir/${name}S.${objext}" - if test "$fast_install" = yes && test -n "$relink_command"; then + func_append rmfiles " $odir/$name $odir/${name}S.$objext" + if test yes = "$fast_install" && test -n "$relink_command"; then func_append rmfiles " $odir/lt-$name" fi - if test "X$noexename" != "X$name" ; then - func_append rmfiles " $odir/lt-${noexename}.c" + if test "X$noexename" != "X$name"; then + func_append rmfiles " $odir/lt-$noexename.c" fi fi fi @@ -9604,7 +11195,7 @@ func_mode_uninstall () func_show_eval "$RM $rmfiles" 'exit_status=1' done - # Try to remove the ${objdir}s in the directories where we deleted files + # Try to remove the $objdir's in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" @@ -9614,16 +11205,17 @@ func_mode_uninstall () exit $exit_status } -{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && - func_mode_uninstall ${1+"$@"} +if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then + func_mode_uninstall ${1+"$@"} +fi test -z "$opt_mode" && { - help="$generic_help" + help=$generic_help func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ - func_fatal_help "invalid operation mode \`$opt_mode'" + func_fatal_help "invalid operation mode '$opt_mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" @@ -9634,7 +11226,7 @@ exit $exit_status # The TAGs below are defined such that we never get into a situation -# in which we disable both kinds of libraries. Given conflicting +# where we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support @@ -9657,5 +11249,3 @@ build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # mode:shell-script # sh-indentation:2 # End: -# vi:sw=2 - diff --git a/m4/ax_c___attribute__.m4 b/m4/ax_c___attribute__.m4 new file mode 100644 index 0000000..0e952e7 --- /dev/null +++ b/m4/ax_c___attribute__.m4 @@ -0,0 +1,134 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_c___attribute__.html +# +# Downloaded into the Network UPS Tools (NUT) codebase from +# http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/ax_c___attribute__.m4 +# as of 2020-11-20 and adapted for attribute supports we needed +# =========================================================================== +# +# SYNOPSIS +# +# AX_C___ATTRIBUTE__ +# +# DESCRIPTION +# +# Provides a test for the compiler support of __attribute__ extensions. +# Defines HAVE___ATTRIBUTE__ if it is found. +# Also in particular defines +# HAVE___ATTRIBUTE__UNUSED_ARG +# HAVE___ATTRIBUTE__UNUSED_FUNC +# HAVE___ATTRIBUTE__NORETURN +# if support for respective values and use-cases of interest for NUT +# codebase is found. +# +# LICENSE +# +# Copyright (c) 2008 Stepan Kasal +# Copyright (c) 2008 Christian Haggstrom +# Copyright (c) 2008 Ryan McCabe +# Copyright (c) 2020 Jim Klimov +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 9 + +AC_DEFUN([AX_C___ATTRIBUTE__], [ + AC_LANG_PUSH([C]) + AC_CACHE_CHECK([for __attribute__((unused)) for function arguments], [ax_cv___attribute__unused_arg], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + static void foo( int); + static void + foo(__attribute__ ((unused)) int i) { + return; + } + ]], [func(1);])], + [ax_cv___attribute__unused_arg=yes], + [ax_cv___attribute__unused_arg=no] + ) + ]) + + AC_CACHE_CHECK([for __attribute__((unused)) for functions], [ax_cv___attribute__unused_func], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + static void foo(void) __attribute__ ((unused)); + static void + foo(void) { + return; + } + ]], [])], + [ax_cv___attribute__unused_func=yes], + [ax_cv___attribute__unused_func=no] + ) + ]) + + AC_CACHE_CHECK([for __attribute__((noreturn))], [ax_cv___attribute__noreturn], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + static void foo(void) __attribute__ ((noreturn)); + static void + foo(void) { + exit(1); + } + ]], [foo();])], + [ax_cv___attribute__noreturn=yes], + [ax_cv___attribute__noreturn=no] + ) + ]) + AC_LANG_POP([C]) + + AC_CACHE_CHECK([for at least some __attribute__ support], [ax_cv___attribute__], + [if test "$ax_cv___attribute__unused_arg" = "yes" \ + || test "$ax_cv___attribute__unused_func" = "yes" \ + || test "$ax_cv___attribute__noreturn" = "yes" \ + ; then + dnl # Some values did not error, support for keyword itself exists + ax_cv___attribute__=yes + else + dnl # At least none of the options we are interested in work... + ax_cv___attribute__=no + fi + ]) + + if test "$ax_cv___attribute__unused_arg" = "yes"; then + AC_DEFINE([HAVE___ATTRIBUTE__UNUSED_ARG], 1, [define if your compiler has __attribute__((unused)) for function arguments]) + fi + + if test "$ax_cv___attribute__unused_func" = "yes"; then + AC_DEFINE([HAVE___ATTRIBUTE__UNUSED_FUNC], 1, [define if your compiler has __attribute__((unused)) for functions]) + fi + if test "$ax_cv___attribute__noreturn" = "yes"; then + AC_DEFINE([HAVE___ATTRIBUTE__NORETURN], 1, [define if your compiler has __attribute__((noreturn))]) + fi + + if test "$ax_cv___attribute__" = "yes"; then + AC_DEFINE([HAVE___ATTRIBUTE__], 1, [define if your compiler has __attribute__]) + fi +]) diff --git a/m4/ax_c_pragmas.m4 b/m4/ax_c_pragmas.m4 new file mode 100644 index 0000000..53c1aeb --- /dev/null +++ b/m4/ax_c_pragmas.m4 @@ -0,0 +1,983 @@ +dnl Check for current compiler support of specific pragmas we use, +dnl e.g. diagnostics management to keep warnings quiet sometimes + +AC_DEFUN([AX_C_PRAGMAS], [ +if test -z "${nut_have_ax_c_pragmas_seen}"; then + nut_have_ax_c_pragmas_seen="yes" + + CFLAGS_SAVED="${CFLAGS}" + CXXFLAGS_SAVED="${CXXFLAGS}" + + dnl ### To be sure, bolt the language + AC_LANG_PUSH([C]) + + dnl # This is expected to fail builds with unknown pragma names on GCC or CLANG at least + AS_IF([test "${CLANG}" = "yes"], + [CFLAGS="${CFLAGS_SAVED} -Werror=pragmas -Werror=unknown-pragmas -Werror=unknown-warning-option" + CXXFLAGS="${CXXFLAGS_SAVED} -Werror=pragmas -Werror=unknown-pragmas -Werror=unknown-warning-option"], + [AS_IF([test "${GCC}" = "yes"], +dnl ### Despite the docs, this dies with lack of (apparently) support for +dnl ### -Wunknown-warning(-options) on all GCC versions I tried (v5-v10) +dnl ### [CFLAGS="${CFLAGS_SAVED} -Werror=pragmas -Werror=unknown-warning"], + [CFLAGS="${CFLAGS_SAVED} -Wall -Wextra -Werror" + CXXFLAGS="${CXXFLAGS_SAVED} -Wall -Wextra -Werror"], + [CFLAGS="${CFLAGS_SAVED} -Wall -Wextra -Werror" + CXXFLAGS="${CXXFLAGS_SAVED} -Wall -Wextra -Werror"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic push and pop (outside functions)], + [ax_cv__pragma__gcc__diags_push_pop_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ +#pragma GCC diagnostic push +#pragma GCC diagnostic pop + ]], [])], + [ax_cv__pragma__gcc__diags_push_pop_besidefunc=yes], + [ax_cv__pragma__gcc__diags_push_pop_besidefunc=no] + )] + ) + + AC_CACHE_CHECK([for pragma clang diagnostic push and pop (outside functions)], + [ax_cv__pragma__clang__diags_push_pop_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ +#ifdef __clang__ +#endif +#pragma clang diagnostic push +#pragma clang diagnostic pop + ]], [])], + [ax_cv__pragma__clang__diags_push_pop_besidefunc=yes], + [ax_cv__pragma__clang__diags_push_pop_besidefunc=no] + )] + ) + + dnl # Currently our code uses these pragmas as close to lines that cause + dnl # questions from linters as possible. GCC before 4.5 did not allow + dnl # for diag pragmas inside function bodies, but also did not complain + dnl # about messy code as new compilers do. For completeness, we support + dnl # the possibility of defining larger-scoped pragmas around whole + dnl # function bodies. In practice, we don't currently do that so in + dnl # most cases the shorter names (without _INSIDEFUNC) are used with + dnl # that implied meaning. + + AC_CACHE_CHECK([for pragma GCC diagnostic push and pop (inside functions)], + [ax_cv__pragma__gcc__diags_push_pop_insidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic push +#pragma GCC diagnostic pop +} + ]], [])], + [ax_cv__pragma__gcc__diags_push_pop_insidefunc=yes], + [ax_cv__pragma__gcc__diags_push_pop_insidefunc=no] + )] + ) + + AC_CACHE_CHECK([for pragma clang diagnostic push and pop (inside functions)], + [ax_cv__pragma__clang__diags_push_pop_insidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#ifdef __clang__ +#endif +#pragma clang diagnostic push +#pragma clang diagnostic pop +} + ]], [])], + [ax_cv__pragma__clang__diags_push_pop_insidefunc=yes], + [ax_cv__pragma__clang__diags_push_pop_insidefunc=no] + )] + ) + + AS_IF([test "$ax_cv__pragma__gcc__diags_push_pop_insidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_INSIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic push and pop inside function bodies]) + ]) + + AS_IF([test "$ax_cv__pragma__gcc__diags_push_pop_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic push and pop outside function bodies]) + ]) + + AS_IF([test "$ax_cv__pragma__gcc__diags_push_pop_besidefunc" = "yes" && test "$ax_cv__pragma__gcc__diags_push_pop_insidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP], 1, [define if your compiler has #pragma GCC diagnostic push and pop]) + ]) + + AS_IF([test "$ax_cv__pragma__clang__diags_push_pop_insidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_CLANG_DIAGNOSTIC_PUSH_POP_INSIDEFUNC], 1, [define if your compiler has #pragma clang diagnostic push and pop inside function bodies]) + ]) + + AS_IF([test "$ax_cv__pragma__clang__diags_push_pop_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_CLANG_DIAGNOSTIC_PUSH_POP_BESIDEFUNC], 1, [define if your compiler has #pragma clang diagnostic push and pop outside function bodies]) + ]) + + AS_IF([test "$ax_cv__pragma__clang__diags_push_pop_besidefunc" = "yes" && test "$ax_cv__pragma__clang__diags_push_pop_insidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_CLANG_DIAGNOSTIC_PUSH_POP], 1, [define if your compiler has #pragma clang diagnostic push and pop]) + ]) + + dnl Test for some clang-specific pragma support: primarily useful for older + dnl clang (3.x) releases, so polluting NUT codebase only when unavoidable. + dnl In most cases, GCC pragmas are usable by both; in a few others, direct + dnl use of `#ifdef __clang__` suffices. + AS_IF([test "${CLANG}" = "yes"], [ + AC_CACHE_CHECK([for pragma CLANG diagnostic ignored "-Wunreachable-code-return"], + [ax_cv__pragma__clang__diags_ignored_unreachable_code_return], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma clang diagnostic ignored "-Wunreachable-code-return" +} + ]], [])], + [ax_cv__pragma__clang__diags_ignored_unreachable_code_return=yes], + [ax_cv__pragma__clang__diags_ignored_unreachable_code_return=no] + )] + ) + AS_IF([test "$ax_cv__pragma__clang__diags_ignored_unreachable_code_return" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_CLANG_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN], 1, [define if your compiler has #pragma clang diagnostic ignored "-Wunreachable-code-return"]) + ]) + + AC_CACHE_CHECK([for pragma CLANG diagnostic ignored "-Wunreachable-code-return" (outside functions)], + [ax_cv__pragma__clang__diags_ignored_unreachable_code_return_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma clang diagnostic ignored "-Wunreachable-code-return"]], [])], + [ax_cv__pragma__clang__diags_ignored_unreachable_code_return_besidefunc=yes], + [ax_cv__pragma__clang__diags_ignored_unreachable_code_return_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__clang__diags_ignored_unreachable_code_return_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_CLANG_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN_BESIDEFUNC], 1, [define if your compiler has #pragma clang diagnostic ignored "-Wunreachable-code-return" (outside functions)]) + ]) + ]) dnl Special pragma support testing for clang + + dnl Test common pragmas for GCC (and compatible) compilers + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wunused-function"], + [ax_cv__pragma__gcc__diags_ignored_unused_function], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wunused-function" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_unused_function=yes], + [ax_cv__pragma__gcc__diags_ignored_unused_function=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_unused_function" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNUSED_FUNCTION], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wunused-function"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wformat-nonliteral"], + [ax_cv__pragma__gcc__diags_ignored_format_nonliteral], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_format_nonliteral=yes], + [ax_cv__pragma__gcc__diags_ignored_format_nonliteral=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_format_nonliteral" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wformat-nonliteral"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wformat-nonliteral" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_format_nonliteral_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wformat-nonliteral"]], [])], + [ax_cv__pragma__gcc__diags_ignored_format_nonliteral_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_format_nonliteral_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_format_nonliteral_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wformat-nonliteral" (outside functions)]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wformat-security"], + [ax_cv__pragma__gcc__diags_ignored_format_security], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wformat-security" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_format_security=yes], + [ax_cv__pragma__gcc__diags_ignored_format_security=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_format_security" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wformat-security"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wformat-security" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_format_security_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wformat-security"]], [])], + [ax_cv__pragma__gcc__diags_ignored_format_security_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_format_security_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_format_security_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wformat-security" (outside functions)]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wformat-truncation"], + [ax_cv__pragma__gcc__diags_ignored_format_truncation], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wformat-truncation" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_format_truncation=yes], + [ax_cv__pragma__gcc__diags_ignored_format_truncation=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_format_truncation" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wformat-truncation"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wformat-truncation" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_format_truncation_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wformat-truncation"]], [])], + [ax_cv__pragma__gcc__diags_ignored_format_truncation_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_format_truncation_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_format_truncation_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wformat-truncation" (outside functions)]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wstringop-truncation"], + [ax_cv__pragma__gcc__diags_ignored_stringop_truncation], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wstringop-truncation" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_stringop_truncation=yes], + [ax_cv__pragma__gcc__diags_ignored_stringop_truncation=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_stringop_truncation" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRINGOP_TRUNCATION], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wstringop-truncation"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wstringop-truncation" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_stringop_truncation_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wstringop-truncation"]], [])], + [ax_cv__pragma__gcc__diags_ignored_stringop_truncation_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_stringop_truncation_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_stringop_truncation_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRINGOP_TRUNCATION_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wstringop-truncation" (outside functions)]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wtype-limits"], + [ax_cv__pragma__gcc__diags_ignored_type_limits], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wtype-limits" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_type_limits=yes], + [ax_cv__pragma__gcc__diags_ignored_type_limits=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_type_limits" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wtype-limits"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wtype-limits" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_type_limits_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wtype-limits"]], [])], + [ax_cv__pragma__gcc__diags_ignored_type_limits_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_type_limits_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_type_limits_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wtype-limits" (outside functions)]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Warray-bounds"], + [ax_cv__pragma__gcc__diags_ignored_array_bounds], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Warray-bounds" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_array_bounds=yes], + [ax_cv__pragma__gcc__diags_ignored_array_bounds=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_array_bounds" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ARRAY_BOUNDS], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Warray-bounds"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Warray-bounds" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_array_bounds_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Warray-bounds"]], [])], + [ax_cv__pragma__gcc__diags_ignored_array_bounds_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_array_bounds_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_array_bounds_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ARRAY_BOUNDS_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Warray-bounds" (outside functions)]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wtautological-type-limit-compare"], + [ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wtautological-type-limit-compare" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare=yes], + [ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_TYPE_LIMIT_COMPARE], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wtautological-type-limit-compare"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wtautological-type-limit-compare" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wtautological-type-limit-compare"]], [])], + [ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_tautological_type_limit_compare_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_TYPE_LIMIT_COMPARE_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wtautological-type-limit-compare" (outside functions)]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare"], + [ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare=yes], + [ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare"]], [])], + [ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_tautological_constant_out_of_range_compare_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" (outside functions)]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wtautological-unsigned-zero-compare"], + [ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wtautological-unsigned-zero-compare" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare=yes], + [ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_UNSIGNED_ZERO_COMPARE], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wtautological-unsigned-zero-compare"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wtautological-unsigned-zero-compare" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wtautological-unsigned-zero-compare"]], [])], + [ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_tautological_unsigned_zero_compare_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_UNSIGNED_ZERO_COMPARE_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wtautological-unsigned-zero-compare" (outside functions)]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wtautological-compare"], + [ax_cv__pragma__gcc__diags_ignored_tautological_compare], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wtautological-compare" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_tautological_compare=yes], + [ax_cv__pragma__gcc__diags_ignored_tautological_compare=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_tautological_compare" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_COMPARE], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wtautological-compare"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wtautological-compare" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_tautological_compare_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wtautological-compare"]], [])], + [ax_cv__pragma__gcc__diags_ignored_tautological_compare_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_tautological_compare_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_tautological_compare_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_COMPARE_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wtautological-compare" (outside functions)]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wsign-compare"], + [ax_cv__pragma__gcc__diags_ignored_sign_compare], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wsign-compare" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_sign_compare=yes], + [ax_cv__pragma__gcc__diags_ignored_sign_compare=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_sign_compare" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_COMPARE], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wsign-compare"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wsign-compare" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_sign_compare_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wsign-compare"]], [])], + [ax_cv__pragma__gcc__diags_ignored_sign_compare_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_sign_compare_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_sign_compare_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_COMPARE_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wsign-compare" (outside functions)]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wsign-conversion"], + [ax_cv__pragma__gcc__diags_ignored_sign_conversion], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wsign-conversion" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_sign_conversion=yes], + [ax_cv__pragma__gcc__diags_ignored_sign_conversion=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_sign_conversion" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_CONVERSION], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wsign-conversion"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wsign-conversion" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_sign_conversion_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wsign-conversion"]], [])], + [ax_cv__pragma__gcc__diags_ignored_sign_conversion_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_sign_conversion_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_sign_conversion_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_CONVERSION_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wsign-conversion" (outside functions)]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wunreachable-code-break"], + [ax_cv__pragma__gcc__diags_ignored_unreachable_code_break], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wunreachable-code-break" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_unreachable_code_break=yes], + [ax_cv__pragma__gcc__diags_ignored_unreachable_code_break=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_break" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_BREAK], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wunreachable-code-break"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wunreachable-code-break" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_unreachable_code_break_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wunreachable-code-break"]], [])], + [ax_cv__pragma__gcc__diags_ignored_unreachable_code_break_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_unreachable_code_break_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_break_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_BREAK_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wunreachable-code-break" (outside functions)]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wunreachable-code-return"], + [ax_cv__pragma__gcc__diags_ignored_unreachable_code_return], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wunreachable-code-return" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_unreachable_code_return=yes], + [ax_cv__pragma__gcc__diags_ignored_unreachable_code_return=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_return" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wunreachable-code-return"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wunreachable-code-return" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_unreachable_code_return_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wunreachable-code-return"]], [])], + [ax_cv__pragma__gcc__diags_ignored_unreachable_code_return_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_unreachable_code_return_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_return_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_RETURN_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wunreachable-code-return" (outside functions)]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wunreachable-code"], + [ax_cv__pragma__gcc__diags_ignored_unreachable_code], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wunreachable-code" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_unreachable_code=yes], + [ax_cv__pragma__gcc__diags_ignored_unreachable_code=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wunreachable-code"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wunreachable-code" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_unreachable_code_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wunreachable-code"]], [])], + [ax_cv__pragma__gcc__diags_ignored_unreachable_code_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_unreachable_code_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wunreachable-code" (outside functions)]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wformat-overflow"], + [ax_cv__pragma__gcc__diags_ignored_format_overflow], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wformat-overflow" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_format_overflow=yes], + [ax_cv__pragma__gcc__diags_ignored_format_overflow=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_format_overflow" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_OVERFLOW], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wformat-overflow"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wformat-overflow" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_format_overflow_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wformat-overflow"]], [])], + [ax_cv__pragma__gcc__diags_ignored_format_overflow_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_format_overflow_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_format_overflow_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_OVERFLOW_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wformat-overflow" (outside functions)]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wcovered-switch-default"], + [ax_cv__pragma__gcc__diags_ignored_covered_switch_default], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wcovered-switch-default" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_covered_switch_default=yes], + [ax_cv__pragma__gcc__diags_ignored_covered_switch_default=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_covered_switch_default" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wcovered-switch-default"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wcovered-switch-default" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_covered_switch_default_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wcovered-switch-default"]], [])], + [ax_cv__pragma__gcc__diags_ignored_covered_switch_default_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_covered_switch_default_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_covered_switch_default_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wcovered-switch-default" (outside functions)]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wextra-semi-stmt"], + [ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wextra-semi-stmt" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt=yes], + [ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXTRA_SEMI_STMT], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wextra-semi-stmt"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wextra-semi-stmt" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wextra-semi-stmt"]], [])], + [ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_extra_semi_stmt_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXTRA_SEMI_STMT_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wextra-semi-stmt" (outside functions)]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wcast-align"], + [ax_cv__pragma__gcc__diags_ignored_cast_align], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wcast-align" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_cast_align=yes], + [ax_cv__pragma__gcc__diags_ignored_cast_align=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_cast_align" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wcast-align"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wcast-align" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_cast_align_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wcast-align"]], [])], + [ax_cv__pragma__gcc__diags_ignored_cast_align_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_cast_align_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_cast_align_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wcast-align" (outside functions)]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wstrict-prototypes"], + [ax_cv__pragma__gcc__diags_ignored_strict_prototypes], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wstrict-prototypes" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_strict_prototypes=yes], + [ax_cv__pragma__gcc__diags_ignored_strict_prototypes=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_strict_prototypes" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wstrict-prototypes"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wstrict-prototypes" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_strict_prototypes_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wstrict-prototypes"]], [])], + [ax_cv__pragma__gcc__diags_ignored_strict_prototypes_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_strict_prototypes_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_strict_prototypes_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wstrict-prototypes" (outside functions)]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wassign-enum"], + [ax_cv__pragma__gcc__diags_ignored_assign_enum], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wassign-enum" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_assign_enum=yes], + [ax_cv__pragma__gcc__diags_ignored_assign_enum=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_assign_enum" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ASSIGN_ENUM], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wassign-enum"]) + ]) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-Wassign-enum" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_assign_enum_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wassign-enum"]], [])], + [ax_cv__pragma__gcc__diags_ignored_assign_enum_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_assign_enum_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_assign_enum_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ASSIGN_ENUM_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wassign-enum" (outside functions)]) + ]) + + AC_LANG_POP([C]) + + dnl ### Series of tests for C++ specific pragmas + AC_LANG_PUSH([C++]) + + AC_CACHE_CHECK([for C++ pragma GCC diagnostic ignored "-Wc++98-compat-pedantic"], + [ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wc++98-compat-pedantic" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic=yes], + [ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT_PEDANTIC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wc++98-compat-pedantic"]) + ]) + + AC_CACHE_CHECK([for C++ pragma GCC diagnostic ignored "-Wc++98-compat-pedantic" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wc++98-compat-pedantic"]], [])], + [ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT_PEDANTIC_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wc++98-compat-pedantic" (outside functions)]) + ]) + + AC_CACHE_CHECK([for C++ pragma GCC diagnostic ignored "-Wc++98-compat"], + [ax_cv__pragma__gcc__diags_ignored_cxx98_compat], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wc++98-compat" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_cxx98_compat=yes], + [ax_cv__pragma__gcc__diags_ignored_cxx98_compat=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wc++98-compat"]) + ]) + + AC_CACHE_CHECK([for C++ pragma GCC diagnostic ignored "-Wc++98-compat" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_cxx98_compat_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wc++98-compat"]], [])], + [ax_cv__pragma__gcc__diags_ignored_cxx98_compat_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_cxx98_compat_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wc++98-compat" (outside functions)]) + ]) + + AC_CACHE_CHECK([for C++ pragma GCC diagnostic ignored "-Wglobal-constructors"], + [ax_cv__pragma__gcc__diags_ignored_global_constructors], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wglobal-constructors" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_global_constructors=yes], + [ax_cv__pragma__gcc__diags_ignored_global_constructors=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_global_constructors" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wglobal-constructors"]) + ]) + + AC_CACHE_CHECK([for C++ pragma GCC diagnostic ignored "-Wglobal-constructors" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_global_constructors_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wglobal-constructors"]], [])], + [ax_cv__pragma__gcc__diags_ignored_global_constructors_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_global_constructors_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_global_constructors_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wglobal-constructors" (outside functions)]) + ]) + + AC_CACHE_CHECK([for C++ pragma GCC diagnostic ignored "-Wexit-time-destructors"], + [ax_cv__pragma__gcc__diags_ignored_exit_time_destructors], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-Wexit-time-destructors" +} +]], [])], + [ax_cv__pragma__gcc__diags_ignored_exit_time_destructors=yes], + [ax_cv__pragma__gcc__diags_ignored_exit_time_destructors=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_exit_time_destructors" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wexit-time-destructors"]) + ]) + + AC_CACHE_CHECK([for C++ pragma GCC diagnostic ignored "-Wexit-time-destructors" (outside functions)], + [ax_cv__pragma__gcc__diags_ignored_exit_time_destructors_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-Wexit-time-destructors"]], [])], + [ax_cv__pragma__gcc__diags_ignored_exit_time_destructors_besidefunc=yes], + [ax_cv__pragma__gcc__diags_ignored_exit_time_destructors_besidefunc=no] + )] + ) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_exit_time_destructors_besidefunc" = "yes"],[ + AC_DEFINE([HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS_BESIDEFUNC], 1, [define if your compiler has #pragma GCC diagnostic ignored "-Wexit-time-destructors" (outside functions)]) + ]) + + AC_LANG_POP([C++]) + + dnl # Meta-macros for simpler use-cases where we pick + dnl # equivalent-effect macros for different compiler versions + AS_IF([test "$ax_cv__pragma__gcc__diags_push_pop_insidefunc" = "yes"],[ + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_format_security" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_format_nonliteral" = "yes" ],[ + AC_DEFINE([HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL], 1, [define if your compiler has pragmas for GCC diagnostic ignored "-Wformat-nonliteral" or "-Wformat-security" and for push-pop support]) + ]) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_format_truncation" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_stringop_truncation" = "yes" ],[ + AC_DEFINE([HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION], 1, [define if your compiler has pragmas for GCC diagnostic ignored "-Wformat-truncation" or "-Werror=stringop-truncation" and for push-pop support]) + ]) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_break" = "yes" ],[ + AC_DEFINE([HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE], 1, [define if your compiler has pragmas for GCC diagnostic ignored "-Wunreachable-code(-break)" and for push-pop support]) + ]) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat" = "yes" ],[ + AC_DEFINE([HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT], 1, [define if your compiler has pragmas for GCC diagnostic ignored "-Wc++98-compat(-pedantic)" and for push-pop support]) + ]) + ]) + + AS_IF([test "$ax_cv__pragma__gcc__diags_push_pop_besidefunc" = "yes"],[ + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_format_security" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_format_nonliteral" = "yes" ],[ + AC_DEFINE([HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL_BESIDEFUNC], 1, [define if your compiler has pragmas for GCC diagnostic ignored "-Wformat-nonliteral" or "-Wformat-security" and for push-pop support (outside function bodies)]) + ]) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_format_truncation" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_stringop_truncation" = "yes" ],[ + AC_DEFINE([HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_TRUNCATION_BESIDEFUNC], 1, [define if your compiler has pragmas for GCC diagnostic ignored "-Wformat-truncation" or "-Werror=stringop-truncation" and for push-pop support (outside function bodies)]) + ]) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_unreachable_code_break" = "yes" ],[ + AC_DEFINE([HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE_BESIDEFUNC], 1, [define if your compiler has pragmas for GCC diagnostic ignored "-Wunreachable-code(-break)" and for push-pop support (outside function bodies)]) + ]) + AS_IF([test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat_pedantic" = "yes" || test "$ax_cv__pragma__gcc__diags_ignored_cxx98_compat" = "yes" ],[ + AC_DEFINE([HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_CXX98_COMPAT_BESIDEFUNC], 1, [define if your compiler has pragmas for GCC diagnostic ignored "-Wc++98-compat(-pedantic)" and for push-pop support (outside function bodies)]) + ]) + ]) + + dnl ### Sanity check if the CLI options actually work: + AC_CACHE_CHECK([for pragma BOGUSforTest], + [ax_cv__pragma__bogus], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma BOGUSforTest +} +]], [])], + [ax_cv__pragma__bogus=yes], + [ax_cv__pragma__bogus=no] + )] + ) + + AC_CACHE_CHECK([for pragma BOGUSforTest (outside functions)], + [ax_cv__pragma__bogus_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma BOGUSforTest]], [])], + [ax_cv__pragma__bogus_besidefunc=yes], + [ax_cv__pragma__bogus_besidefunc=no] + )] + ) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-WBOGUSforTest"], + [ax_cv__pragma__bogus_diag], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[void func(void) { +#pragma GCC diagnostic ignored "-WBOGUSforTest" +} +]], [])], + [ax_cv__pragma__bogus_diag=yes], + [ax_cv__pragma__bogus_diag=no] + )] + ) + + AC_CACHE_CHECK([for pragma GCC diagnostic ignored "-WBOGUSforTest" (outside functions)], + [ax_cv__pragma__bogus_diag_besidefunc], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#pragma GCC diagnostic ignored "-WBOGUSforTest"]], [])], + [ax_cv__pragma__bogus_diag_besidefunc=yes], + [ax_cv__pragma__bogus_diag_besidefunc=no] + )] + ) + + AS_IF([test "${ax_cv__pragma__bogus}" != "no"], + [AC_MSG_WARN([A bogus test that was expected to fail did not! ax_cv__pragma__bogus=$ax_cv__pragma__bogus (not 'no')])]) + + AS_IF([test "${ax_cv__pragma__bogus_besidefunc}" != "no"], + [AC_MSG_WARN([A bogus test that was expected to fail did not! ax_cv__pragma__bogus_besidefunc=$ax_cv__pragma__bogus_besidefunc (not 'no')])]) + + AS_IF([test "${ax_cv__pragma__bogus_diag}" != "no"], + [AC_MSG_WARN([A bogus test that was expected to fail did not! ax_cv__pragma__bogus_diag=$ax_cv__pragma__bogus_diag (not 'no')])]) + + AS_IF([test "${ax_cv__pragma__bogus_diag_besidefunc}" != "no"], + [AC_MSG_WARN([A bogus test that was expected to fail did not! ax_cv__pragma__bogus_diag_besidefunc=$ax_cv__pragma__bogus_diag_besidefunc (not 'no')])]) + + CFLAGS="${CFLAGS_SAVED}" + CXXFLAGS="${CXXFLAGS_SAVED}" +fi +]) + +AC_DEFUN([AX_C_PRINTF_STRING_NULL], [ +if test -z "${nut_have_ax_c_printf_string_null_seen}"; then + nut_have_ax_c_printf_string_null_seen="yes" + AC_REQUIRE([AX_RUN_OR_LINK_IFELSE])dnl + + dnl ### To be sure, bolt the language + AC_LANG_PUSH([C]) + + AC_CACHE_CHECK([for practical support to pritnf("%s", NULL)], + [ax_cv__printf_string_null], + [AX_RUN_OR_LINK_IFELSE( + [AC_LANG_PROGRAM([dnl +#include +#include +], [dnl +char buf[128]; +char *s = NULL; +int res = snprintf(buf, sizeof(buf), "%s", s); +buf[sizeof(buf)-1] = '\0'; +if (res < 0) { + printf(stderr, "FAILED to snprintf() a NULL string argument"); + exit 1; +} +if (buf[0] == '\0') + printf(stderr, "RETURNED empty string from snprintf() with a NULL string argument"); + exit 0; +} +if (strcasestr(buf, 'null') == NULL) + printf(stderr, "RETURNED some string from snprintf() with a NULL string argument: '%s'", buf); + exit 0; +} +printf(stderr, "SUCCESS: RETURNED a string that contains something like 'null' from snprintf() with a NULL string argument: '%s'", buf); +exit 0; + ])], + [ax_cv__printf_string_null=yes], + [ax_cv__printf_string_null=no] + )] + ) + + AS_IF([test "$ax_cv__printf_string_null" = "yes"],[ + AC_DEFINE([HAVE_PRINTF_STRING_NULL], 1, [define if your libc can printf("%s", NULL) sanely]) + ]) + + AC_LANG_POP([C]) +fi +]) diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4 new file mode 100644 index 0000000..a72fc05 --- /dev/null +++ b/m4/ax_check_compile_flag.m4 @@ -0,0 +1,61 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) +# +# DESCRIPTION +# +# Check whether the given FLAG works with the current language's compiler +# or gives an error. (Warnings, however, are ignored) +# +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on +# success/failure. +# +# If EXTRA-FLAGS is defined, it is added to the current language's default +# flags (e.g. CFLAGS) when the check is done. The check is thus made with +# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to +# force the compiler to issue an error when a bad flag is given. +# +# INPUT gives an alternative input source to AC_COMPILE_IFELSE. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this +# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. +# +# NOTE: This implementation was extended with check for compiler complaints +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# Copyright (c) 2022 Jim Klimov +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 6 + +AC_DEFUN([AX_CHECK_COMPILE_FLAG], +[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF +AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl +AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ + ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS + _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" + AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], + [dnl Toolkit per se did not return an error code; but did it complain? + dnl Below are a few strings typical for some versions of GCC and CLANG + dnl This relies on AC_COMPILE_IFELSE implementation retaining conftest.err + AS_IF([grep -E '(unrecognized.* option|did you mean|unknown argument:)' < conftest.err >/dev/null 2>/dev/null], + [AS_VAR_SET(CACHEVAR,[no])],dnl Hit a complaint, flag is not supported after all + [AS_VAR_SET(CACHEVAR,[yes])])], + [AS_VAR_SET(CACHEVAR,[no])]) + _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) +AS_VAR_IF(CACHEVAR,yes, + [m4_default([$2], :)], + [m4_default([$3], :)]) +AS_VAR_POPDEF([CACHEVAR])dnl +])dnl AX_CHECK_COMPILE_FLAGS diff --git a/m4/ax_compare_version.m4 b/m4/ax_compare_version.m4 old mode 100755 new mode 100644 diff --git a/m4/ax_run_or_link_ifelse.m4 b/m4/ax_run_or_link_ifelse.m4 new file mode 100644 index 0000000..0e36c7e --- /dev/null +++ b/m4/ax_run_or_link_ifelse.m4 @@ -0,0 +1,21 @@ +dnl By default, AC_RUN_IFELSE() fails if it detects cross-compilation +dnl but it provides the fourth argument to customize the handling. +dnl In our case, we would fall back to trying just to link then - +dnl the result would not be as relevant regarding run-time behavior +dnl of the code, but at least we would know that API and ABI are ok. + +dnl Per original /usr/share/autoconf/autoconf/general.m4 which makes +dnl a similar wrapper: +dnl # AC_TRY_RUN(PROGRAM, +dnl # [ACTION-IF-TRUE], [ACTION-IF-FALSE], +dnl # [ACTION-IF-CROSS-COMPILING = RUNTIME-ERROR]) +dnl # ------------------------------------------------------- +AC_DEFUN([AX_RUN_OR_LINK_IFELSE], +[ + AC_RUN_IFELSE([$1], [$2], [$3], + [ + AC_MSG_WARN([Current build is a cross-build, so not running test binaries, just linking them]) + AC_LINK_IFELSE([$1], [$2], [$3]) + ] + ) +]) diff --git a/m4/libtool.m4 b/m4/libtool.m4 index d7c043f..c4c0294 100644 --- a/m4/libtool.m4 +++ b/m4/libtool.m4 @@ -1,8 +1,6 @@ # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. +# Copyright (C) 1996-2001, 2003-2015 Free Software Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives @@ -10,36 +8,30 @@ # modifications, as long as this notice is preserved. m4_define([_LT_COPYING], [dnl -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 +# Copyright (C) 2014 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# GNU Libtool is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of of the License, or +# (at your option) any later version. # -# This file is part of GNU Libtool. +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program or library that is built +# using GNU Libtool, you may include this file under the same +# distribution terms that you use for the rest of that program. # -# GNU Libtool is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or (at your option) any later version. -# -# As a special exception to the GNU General Public License, -# if you distribute this file as part of a program or library that -# is built using GNU Libtool, you may include this file under the -# same distribution terms that you use for the rest of that program. -# -# GNU Libtool is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of +# GNU Libtool is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with GNU Libtool; see the file COPYING. If not, a copy -# can be downloaded from http://www.gnu.org/licenses/gpl.html, or -# obtained by writing to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# along with this program. If not, see . ]) -# serial 57 LT_INIT +# serial 58 LT_INIT # LT_PREREQ(VERSION) @@ -67,7 +59,7 @@ esac # LT_INIT([OPTIONS]) # ------------------ AC_DEFUN([LT_INIT], -[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT +[AC_PREREQ([2.62])dnl We use AC_PATH_PROGS_FEATURE_CHECK AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl AC_BEFORE([$0], [LT_LANG])dnl AC_BEFORE([$0], [LT_OUTPUT])dnl @@ -91,7 +83,7 @@ dnl Parse OPTIONS _LT_SET_OPTIONS([$0], [$1]) # This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ltmain" +LIBTOOL_DEPS=$ltmain # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' @@ -111,26 +103,43 @@ dnl AC_DEFUN([AC_PROG_LIBTOOL], []) dnl AC_DEFUN([AM_PROG_LIBTOOL], []) +# _LT_PREPARE_CC_BASENAME +# ----------------------- +m4_defun([_LT_PREPARE_CC_BASENAME], [ +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +func_cc_basename () +{ + for cc_temp in @S|@*""; do + case $cc_temp in + compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; + distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; + \-*) ;; + *) break;; + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +} +])# _LT_PREPARE_CC_BASENAME + + # _LT_CC_BASENAME(CC) # ------------------- -# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +# It would be clearer to call AC_REQUIREs from _LT_PREPARE_CC_BASENAME, +# but that macro is also expanded into generated libtool script, which +# arranges for $SED and $ECHO to be set by different means. m4_defun([_LT_CC_BASENAME], -[for cc_temp in $1""; do - case $cc_temp in - compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; - distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +[m4_require([_LT_PREPARE_CC_BASENAME])dnl +AC_REQUIRE([_LT_DECL_SED])dnl +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl +func_cc_basename $1 +cc_basename=$func_cc_basename_result ]) # _LT_FILEUTILS_DEFAULTS # ---------------------- # It is okay to use these file commands and assume they have been set -# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. +# sensibly after 'm4_require([_LT_FILEUTILS_DEFAULTS])'. m4_defun([_LT_FILEUTILS_DEFAULTS], [: ${CP="cp -f"} : ${MV="mv -f"} @@ -177,15 +186,16 @@ m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_WITH_SYSROOT])dnl +m4_require([_LT_CMD_TRUNCATE])dnl _LT_CONFIG_LIBTOOL_INIT([ -# See if we are running on zsh, and set the options which allow our +# See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes INIT. -if test -n "\${ZSH_VERSION+set}" ; then +if test -n "\${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi ]) -if test -n "${ZSH_VERSION+set}" ; then +if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi @@ -198,7 +208,7 @@ aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. - if test "X${COLLECT_NAMES+set}" != Xset; then + if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi @@ -209,14 +219,14 @@ esac ofile=libtool can_build_shared=yes -# All known linkers require a `.a' archive for static linking (except MSVC, +# All known linkers require a '.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a -with_gnu_ld="$lt_cv_prog_gnu_ld" +with_gnu_ld=$lt_cv_prog_gnu_ld -old_CC="$CC" -old_CFLAGS="$CFLAGS" +old_CC=$CC +old_CFLAGS=$CFLAGS # Set sane defaults for various variables test -z "$CC" && CC=cc @@ -269,14 +279,14 @@ no_glob_subst='s/\*/\\\*/g' # _LT_PROG_LTMAIN # --------------- -# Note that this code is called both from `configure', and `config.status' +# Note that this code is called both from 'configure', and 'config.status' # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, -# `config.status' has no value for ac_aux_dir unless we are using Automake, +# 'config.status' has no value for ac_aux_dir unless we are using Automake, # so we pass a copy along to make sure it has a sensible value anyway. m4_defun([_LT_PROG_LTMAIN], [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) -ltmain="$ac_aux_dir/ltmain.sh" +ltmain=$ac_aux_dir/ltmain.sh ])# _LT_PROG_LTMAIN @@ -286,7 +296,7 @@ ltmain="$ac_aux_dir/ltmain.sh" # So that we can recreate a full libtool script including additional # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS -# in macros and then make a single call at the end using the `libtool' +# in macros and then make a single call at the end using the 'libtool' # label. @@ -421,8 +431,8 @@ m4_define([_lt_decl_all_varnames], # _LT_CONFIG_STATUS_DECLARE([VARNAME]) # ------------------------------------ -# Quote a variable value, and forward it to `config.status' so that its -# declaration there will have the same value as in `configure'. VARNAME +# Quote a variable value, and forward it to 'config.status' so that its +# declaration there will have the same value as in 'configure'. VARNAME # must have a single quote delimited value for this to work. m4_define([_LT_CONFIG_STATUS_DECLARE], [$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) @@ -446,7 +456,7 @@ m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], # Output comment and list of tags supported by the script m4_defun([_LT_LIBTOOL_TAGS], [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl -available_tags="_LT_TAGS"dnl +available_tags='_LT_TAGS'dnl ]) @@ -474,7 +484,7 @@ m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl # _LT_LIBTOOL_CONFIG_VARS # ----------------------- # Produce commented declarations of non-tagged libtool config variables -# suitable for insertion in the LIBTOOL CONFIG section of the `libtool' +# suitable for insertion in the LIBTOOL CONFIG section of the 'libtool' # script. Tagged libtool config variables (even for the LIBTOOL CONFIG # section) are produced by _LT_LIBTOOL_TAG_VARS. m4_defun([_LT_LIBTOOL_CONFIG_VARS], @@ -500,8 +510,8 @@ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of # variables for single and double quote escaping we saved from calls # to _LT_DECL, we can put quote escaped variables declarations -# into `config.status', and then the shell code to quote escape them in -# for loops in `config.status'. Finally, any additional code accumulated +# into 'config.status', and then the shell code to quote escape them in +# for loops in 'config.status'. Finally, any additional code accumulated # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. m4_defun([_LT_CONFIG_COMMANDS], [AC_PROVIDE_IFELSE([LT_OUTPUT], @@ -547,7 +557,7 @@ for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" @@ -560,7 +570,7 @@ for var in lt_decl_all_varnames([[ \ ]], lt_decl_dquote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" @@ -576,7 +586,7 @@ _LT_OUTPUT_LIBTOOL_INIT # Generate a child script FILE with all initialization necessary to # reuse the environment learned by the parent script, and make the # file executable. If COMMENT is supplied, it is inserted after the -# `#!' sequence but before initialization text begins. After this +# '#!' sequence but before initialization text begins. After this # macro, additional text can be appended to FILE to form the body of # the child script. The macro ends with non-zero status if the # file could not be fully written (such as if the disk is full). @@ -598,7 +608,7 @@ AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 _ASEOF -test $lt_write_fail = 0 && chmod +x $1[]dnl +test 0 = "$lt_write_fail" && chmod +x $1[]dnl m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT # LT_OUTPUT @@ -621,7 +631,7 @@ exec AS_MESSAGE_LOG_FD>>config.log } >&AS_MESSAGE_LOG_FD lt_cl_help="\ -\`$as_me' creates a local libtool stub from the current configuration, +'$as_me' creates a local libtool stub from the current configuration, for use in further configure time tests before the real libtool is generated. @@ -643,7 +653,7 @@ Copyright (C) 2011 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." -while test $[#] != 0 +while test 0 != $[#] do case $[1] in --version | --v* | -V ) @@ -656,10 +666,10 @@ do lt_cl_silent=: ;; -*) AC_MSG_ERROR([unrecognized option: $[1] -Try \`$[0] --help' for more information.]) ;; +Try '$[0] --help' for more information.]) ;; *) AC_MSG_ERROR([unrecognized argument: $[1] -Try \`$[0] --help' for more information.]) ;; +Try '$[0] --help' for more information.]) ;; esac shift done @@ -685,7 +695,7 @@ chmod +x "$CONFIG_LT" # open by configure. Here we exec the FD to /dev/null, effectively closing # config.log, so it can be properly (re)opened and appended to by config.lt. lt_cl_success=: -test "$silent" = yes && +test yes = "$silent" && lt_config_lt_args="$lt_config_lt_args --quiet" exec AS_MESSAGE_LOG_FD>/dev/null $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false @@ -705,32 +715,46 @@ m4_defun([_LT_CONFIG], _LT_CONFIG_SAVE_COMMANDS([ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl m4_if(_LT_TAG, [C], [ - # See if we are running on zsh, and set the options which allow our + # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes. - if test -n "${ZSH_VERSION+set}" ; then + if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi - cfgfile="${ofile}T" + cfgfile=${ofile}T trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL - -# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# Generated automatically by $as_me ($PACKAGE) $VERSION # NOTE: Changes made to this file will be lost: look at ltmain.sh. -# + +# Provide generalized library-building support services. +# Written by Gordon Matzigkeit, 1996 + _LT_COPYING _LT_LIBTOOL_TAGS +# Configured defaults for sys_lib_dlsearch_path munging. +: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} + # ### BEGIN LIBTOOL CONFIG _LT_LIBTOOL_CONFIG_VARS _LT_LIBTOOL_TAG_VARS # ### END LIBTOOL CONFIG +_LT_EOF + + cat <<'_LT_EOF' >> "$cfgfile" + +# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE + +_LT_PREPARE_MUNGE_PATH_LIST +_LT_PREPARE_CC_BASENAME + +# ### END FUNCTIONS SHARED WITH CONFIGURE + _LT_EOF case $host_os in @@ -739,7 +763,7 @@ _LT_EOF # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. -if test "X${COLLECT_NAMES+set}" != Xset; then +if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi @@ -756,8 +780,6 @@ _LT_EOF sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) - _LT_PROG_REPLACE_SHELLFNS - mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" @@ -775,7 +797,6 @@ _LT_EOF [m4_if([$1], [], [ PACKAGE='$PACKAGE' VERSION='$VERSION' - TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile'], []) ])dnl /_LT_CONFIG_SAVE_COMMANDS @@ -974,7 +995,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], [lt_cv_apple_cc_single_mod=no - if test -z "${LT_MULTI_MODULE}"; then + if test -z "$LT_MULTI_MODULE"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the @@ -992,7 +1013,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ cat conftest.err >&AS_MESSAGE_LOG_FD # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. - elif test -f libconftest.dylib && test $_lt_result -eq 0; then + elif test -f libconftest.dylib && test 0 = "$_lt_result"; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD @@ -1010,7 +1031,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [lt_cv_ld_exported_symbols_list=yes], [lt_cv_ld_exported_symbols_list=no]) - LDFLAGS="$save_LDFLAGS" + LDFLAGS=$save_LDFLAGS ]) AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], @@ -1020,8 +1041,8 @@ int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD - echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD - $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD + echo "$AR cr libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD + $AR cr libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF @@ -1032,7 +1053,7 @@ _LT_EOF _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD - elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then + elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD @@ -1042,32 +1063,32 @@ _LT_EOF ]) case $host_os in rhapsody* | darwin1.[[012]]) - _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; + _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; darwin1.*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - 10.[[012]]*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - 10.*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + 10.0,*86*-darwin8*|10.0,*-darwin[[912]]*) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + 10.[[012]][[,.]]*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; + 10.*|11.*) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; esac ;; esac - if test "$lt_cv_apple_cc_single_mod" = "yes"; then + if test yes = "$lt_cv_apple_cc_single_mod"; then _lt_dar_single_mod='$single_module' fi - if test "$lt_cv_ld_exported_symbols_list" = "yes"; then - _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' + if test yes = "$lt_cv_ld_exported_symbols_list"; then + _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' else - _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' + _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' fi - if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then + if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= @@ -1087,29 +1108,29 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES], _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - if test "$lt_cv_ld_force_load" = "yes"; then - _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + if test yes = "$lt_cv_ld_force_load"; then + _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" + _LT_TAGVAR(allow_undefined_flag, $1)=$_lt_dar_allow_undefined case $cc_basename in - ifort*) _lt_dar_can_shared=yes ;; + ifort*|nagfor*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac - if test "$_lt_dar_can_shared" = "yes"; then + if test yes = "$_lt_dar_can_shared"; then output_verbose_link_cmd=func_echo_all - _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" - _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" - _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" + _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" + _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" m4_if([$1], [CXX], -[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then - _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" +[ if test yes != "$lt_cv_apple_cc_single_mod"; then + _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" fi ],[]) else @@ -1129,7 +1150,7 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES], # Allow to override them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl -if test "${lt_cv_aix_libpath+set}" = set; then +if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], @@ -1147,7 +1168,7 @@ else _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then - _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=/usr/lib:/lib fi ]) aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) @@ -1167,8 +1188,8 @@ m4_define([_LT_SHELL_INIT], # ----------------------- # Find how we can fake an echo command that does not interpret backslash. # In particular, with Autoconf 2.60 or later we add some code to the start -# of the generated configure script which will find a shell with a builtin -# printf (which we can use as an echo command). +# of the generated configure script that will find a shell with a builtin +# printf (that we can use as an echo command). m4_defun([_LT_PROG_ECHO_BACKSLASH], [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO @@ -1196,10 +1217,10 @@ fi # Invoke $ECHO with all args, space-separated. func_echo_all () { - $ECHO "$*" + $ECHO "$*" } -case "$ECHO" in +case $ECHO in printf*) AC_MSG_RESULT([printf]) ;; print*) AC_MSG_RESULT([print -r]) ;; *) AC_MSG_RESULT([cat]) ;; @@ -1225,16 +1246,17 @@ _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) AC_DEFUN([_LT_WITH_SYSROOT], [AC_MSG_CHECKING([for sysroot]) AC_ARG_WITH([sysroot], -[ --with-sysroot[=DIR] Search for dependent libraries within DIR - (or the compiler's sysroot if not specified).], +[AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@], + [Search for dependent libraries within DIR (or the compiler's sysroot + if not specified).])], [], [with_sysroot=no]) dnl lt_sysroot will always be passed unquoted. We quote it here dnl in case the user passed a directory name. lt_sysroot= -case ${with_sysroot} in #( +case $with_sysroot in #( yes) - if test "$GCC" = yes; then + if test yes = "$GCC"; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( @@ -1244,14 +1266,14 @@ case ${with_sysroot} in #( no|'') ;; #( *) - AC_MSG_RESULT([${with_sysroot}]) + AC_MSG_RESULT([$with_sysroot]) AC_MSG_ERROR([The sysroot must be an absolute path.]) ;; esac AC_MSG_RESULT([${lt_sysroot:-no}]) _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl -[dependent libraries, and in which our libraries should be installed.])]) +[dependent libraries, and where our libraries should be installed.])]) # _LT_ENABLE_LOCK # --------------- @@ -1259,31 +1281,33 @@ m4_defun([_LT_ENABLE_LOCK], [AC_ARG_ENABLE([libtool-lock], [AS_HELP_STRING([--disable-libtool-lock], [avoid locking (might break parallel builds)])]) -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes +test no = "$enable_libtool_lock" || enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) - # Find out which ABI we are using. + # Find out what ABI is being produced by ac_compile, and set mode + # options accordingly. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) - HPUX_IA64_MODE="32" + HPUX_IA64_MODE=32 ;; *ELF-64*) - HPUX_IA64_MODE="64" + HPUX_IA64_MODE=64 ;; esac fi rm -rf conftest* ;; *-*-irix6*) - # Find out which ABI we are using. + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then - if test "$lt_cv_prog_gnu_ld" = yes; then + if test yes = "$lt_cv_prog_gnu_ld"; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" @@ -1312,9 +1336,46 @@ ia64-*-hpux*) rm -rf conftest* ;; +mips64*-*linux*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + emul=elf + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + emul="${emul}32" + ;; + *64-bit*) + emul="${emul}64" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *MSB*) + emul="${emul}btsmip" + ;; + *LSB*) + emul="${emul}ltsmip" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *N32*) + emul="${emul}n32" + ;; + esac + LD="${LD-ld} -m $emul" + fi + rm -rf conftest* + ;; + x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) - # Find out which ABI we are using. + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. Note that the listed cases only cover the + # situations where additional linker options are needed (such as when + # doing 32-bit compilation for a host where ld defaults to 64-bit, or + # vice versa); the common cases where no linker options are needed do + # not appear in the list. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in @@ -1333,10 +1394,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) ;; esac ;; - powerpc64le-*) + powerpc64le-*linux*) LD="${LD-ld} -m elf32lppclinux" ;; - powerpc64-*) + powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) @@ -1355,10 +1416,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; - powerpcle-*) + powerpcle-*linux*) LD="${LD-ld} -m elf64lppc" ;; - powerpc-*) + powerpc-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) @@ -1376,19 +1437,20 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" + SAVE_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, [AC_LANG_PUSH(C) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) AC_LANG_POP]) - if test x"$lt_cv_cc_needs_belf" != x"yes"; then + if test yes != "$lt_cv_cc_needs_belf"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" + CFLAGS=$SAVE_CFLAGS fi ;; *-*solaris*) - # Find out which ABI we are using. + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in @@ -1396,7 +1458,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) case $lt_cv_prog_gnu_ld in yes*) case $host in - i?86-*-solaris*) + i?86-*-solaris*|x86_64-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) @@ -1405,7 +1467,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then - LD="${LD-ld}_sol2" + LD=${LD-ld}_sol2 fi ;; *) @@ -1421,7 +1483,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) ;; esac -need_locks="$enable_libtool_lock" +need_locks=$enable_libtool_lock ])# _LT_ENABLE_LOCK @@ -1430,7 +1492,7 @@ need_locks="$enable_libtool_lock" m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} -: ${AR_FLAGS=cru} +: ${AR_FLAGS=cr} _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) @@ -1440,11 +1502,11 @@ AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], [echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([lt_ar_try]) - if test "$ac_status" -eq 0; then + if test 0 -eq "$ac_status"; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a AC_TRY_EVAL([lt_ar_try]) - if test "$ac_status" -ne 0; then + if test 0 -ne "$ac_status"; then lt_cv_ar_at_file=@ fi fi @@ -1452,7 +1514,7 @@ AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], ]) ]) -if test "x$lt_cv_ar_at_file" = xno; then +if test no = "$lt_cv_ar_at_file"; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file @@ -1483,7 +1545,7 @@ old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in - openbsd*) + bitrig* | openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) @@ -1519,7 +1581,7 @@ AC_CACHE_CHECK([$1], [$2], [$2=no m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$3" + lt_compiler_flag="$3" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins @@ -1546,7 +1608,7 @@ AC_CACHE_CHECK([$1], [$2], $RM conftest* ]) -if test x"[$]$2" = xyes; then +if test yes = "[$]$2"; then m4_if([$5], , :, [$5]) else m4_if([$6], , :, [$6]) @@ -1568,7 +1630,7 @@ AC_DEFUN([_LT_LINKER_OPTION], m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no - save_LDFLAGS="$LDFLAGS" + save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $3" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then @@ -1587,10 +1649,10 @@ AC_CACHE_CHECK([$1], [$2], fi fi $RM -r conftest* - LDFLAGS="$save_LDFLAGS" + LDFLAGS=$save_LDFLAGS ]) -if test x"[$]$2" = xyes; then +if test yes = "[$]$2"; then m4_if([$4], , :, [$4]) else m4_if([$5], , :, [$5]) @@ -1611,7 +1673,7 @@ AC_DEFUN([LT_CMD_MAX_LEN], AC_MSG_CHECKING([the maximum length of command line arguments]) AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl i=0 - teststring="ABCD" + teststring=ABCD case $build_os in msdosdjgpp*) @@ -1651,7 +1713,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl lt_cv_sys_max_cmd_len=8192; ;; - netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) + bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` @@ -1702,22 +1764,22 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len" && \ - test undefined != "$lt_cv_sys_max_cmd_len"; then + test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. - for i in 1 2 3 4 5 6 7 8 ; do + for i in 1 2 3 4 5 6 7 8; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. - while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ + while { test X`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && - test $i != 17 # 1/2 MB should be enough + test 17 != "$i" # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring @@ -1733,7 +1795,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl ;; esac ]) -if test -n $lt_cv_sys_max_cmd_len ; then +if test -n "$lt_cv_sys_max_cmd_len"; then AC_MSG_RESULT($lt_cv_sys_max_cmd_len) else AC_MSG_RESULT(none) @@ -1761,7 +1823,7 @@ m4_defun([_LT_HEADER_DLFCN], # ---------------------------------------------------------------- m4_defun([_LT_TRY_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl -if test "$cross_compiling" = yes; then : +if test yes = "$cross_compiling"; then : [$4] else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 @@ -1808,9 +1870,9 @@ else # endif #endif -/* When -fvisbility=hidden is used, assume the code has been annotated +/* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ -#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) +#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif @@ -1836,7 +1898,7 @@ int main () return status; }] _LT_EOF - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then + if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null lt_status=$? case x$lt_status in @@ -1857,7 +1919,7 @@ rm -fr conftest* # ------------------ AC_DEFUN([LT_SYS_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl -if test "x$enable_dlopen" != xyes; then +if test yes != "$enable_dlopen"; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown @@ -1867,44 +1929,52 @@ else case $host_os in beos*) - lt_cv_dlopen="load_add_on" + lt_cv_dlopen=load_add_on lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) - lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen=LoadLibrary lt_cv_dlopen_libs= ;; cygwin*) - lt_cv_dlopen="dlopen" + lt_cv_dlopen=dlopen lt_cv_dlopen_libs= ;; darwin*) - # if libdl is installed we need to link against it + # if libdl is installed we need to link against it AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ - lt_cv_dlopen="dyld" + [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],[ + lt_cv_dlopen=dyld lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ]) ;; + tpf*) + # Don't try to run any link tests for TPF. We know it's impossible + # because TPF is a cross-compiler, and we know how we open DSOs. + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + lt_cv_dlopen_self=no + ;; + *) AC_CHECK_FUNC([shl_load], - [lt_cv_dlopen="shl_load"], + [lt_cv_dlopen=shl_load], [AC_CHECK_LIB([dld], [shl_load], - [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], + [lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld], [AC_CHECK_FUNC([dlopen], - [lt_cv_dlopen="dlopen"], + [lt_cv_dlopen=dlopen], [AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], + [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl], [AC_CHECK_LIB([svld], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], + [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld], [AC_CHECK_LIB([dld], [dld_link], - [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) + [lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld]) ]) ]) ]) @@ -1913,21 +1983,21 @@ else ;; esac - if test "x$lt_cv_dlopen" != xno; then - enable_dlopen=yes - else + if test no = "$lt_cv_dlopen"; then enable_dlopen=no + else + enable_dlopen=yes fi case $lt_cv_dlopen in dlopen) - save_CPPFLAGS="$CPPFLAGS" - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + save_CPPFLAGS=$CPPFLAGS + test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" - save_LDFLAGS="$LDFLAGS" + save_LDFLAGS=$LDFLAGS wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - save_LIBS="$LIBS" + save_LIBS=$LIBS LIBS="$lt_cv_dlopen_libs $LIBS" AC_CACHE_CHECK([whether a program can dlopen itself], @@ -1937,7 +2007,7 @@ else lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) ]) - if test "x$lt_cv_dlopen_self" = xyes; then + if test yes = "$lt_cv_dlopen_self"; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" AC_CACHE_CHECK([whether a statically linked program can dlopen itself], lt_cv_dlopen_self_static, [dnl @@ -1947,9 +2017,9 @@ else ]) fi - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - LIBS="$save_LIBS" + CPPFLAGS=$save_CPPFLAGS + LDFLAGS=$save_LDFLAGS + LIBS=$save_LIBS ;; esac @@ -2041,8 +2111,8 @@ m4_defun([_LT_COMPILER_FILE_LOCKS], m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_COMPILER_C_O([$1]) -hard_links="nottested" -if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then +hard_links=nottested +if test no = "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" && test no != "$need_locks"; then # do not overwrite the value of need_locks provided by the user AC_MSG_CHECKING([if we can lock with hard links]) hard_links=yes @@ -2052,8 +2122,8 @@ if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no AC_MSG_RESULT([$hard_links]) - if test "$hard_links" = no; then - AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) + if test no = "$hard_links"; then + AC_MSG_WARN(['$CC' does not support '-c -o', so 'make -j' may be unsafe]) need_locks=warn fi else @@ -2080,8 +2150,8 @@ objdir=$lt_cv_objdir _LT_DECL([], [objdir], [0], [The name of the directory that contains temporary libtool files])dnl m4_pattern_allow([LT_OBJDIR])dnl -AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", - [Define to the sub-directory in which libtool stores uninstalled libraries.]) +AC_DEFINE_UNQUOTED([LT_OBJDIR], "$lt_cv_objdir/", + [Define to the sub-directory where libtool stores uninstalled libraries.]) ])# _LT_CHECK_OBJDIR @@ -2093,15 +2163,15 @@ m4_defun([_LT_LINKER_HARDCODE_LIBPATH], _LT_TAGVAR(hardcode_action, $1)= if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || test -n "$_LT_TAGVAR(runpath_var, $1)" || - test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then + test yes = "$_LT_TAGVAR(hardcode_automatic, $1)"; then # We can hardcode non-existent directories. - if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && + if test no != "$_LT_TAGVAR(hardcode_direct, $1)" && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one - ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && - test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then + ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" && + test no != "$_LT_TAGVAR(hardcode_minus_L, $1)"; then # Linking always hardcodes the temporary library directory. _LT_TAGVAR(hardcode_action, $1)=relink else @@ -2115,12 +2185,12 @@ else fi AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) -if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || - test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then +if test relink = "$_LT_TAGVAR(hardcode_action, $1)" || + test yes = "$_LT_TAGVAR(inherit_rpath, $1)"; then # Fast installation is not supported enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then +elif test yes = "$shlibpath_overrides_runpath" || + test no = "$enable_shared"; then # Fast installation is not necessary enable_fast_install=needless fi @@ -2144,7 +2214,7 @@ else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) - if test -n "$STRIP" ; then + if test -n "$STRIP"; then striplib="$STRIP -x" old_striplib="$STRIP -S" AC_MSG_RESULT([yes]) @@ -2162,6 +2232,47 @@ _LT_DECL([], [striplib], [1]) ])# _LT_CMD_STRIPLIB +# _LT_PREPARE_MUNGE_PATH_LIST +# --------------------------- +# Make sure func_munge_path_list() is defined correctly. +m4_defun([_LT_PREPARE_MUNGE_PATH_LIST], +[[# func_munge_path_list VARIABLE PATH +# ----------------------------------- +# VARIABLE is name of variable containing _space_ separated list of +# directories to be munged by the contents of PATH, which is string +# having a format: +# "DIR[:DIR]:" +# string "DIR[ DIR]" will be prepended to VARIABLE +# ":DIR[:DIR]" +# string "DIR[ DIR]" will be appended to VARIABLE +# "DIRP[:DIRP]::[DIRA:]DIRA" +# string "DIRP[ DIRP]" will be prepended to VARIABLE and string +# "DIRA[ DIRA]" will be appended to VARIABLE +# "DIR[:DIR]" +# VARIABLE will be replaced by "DIR[ DIR]" +func_munge_path_list () +{ + case x@S|@2 in + x) + ;; + *:) + eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'` \@S|@@S|@1\" + ;; + x:*) + eval @S|@1=\"\@S|@@S|@1 `$ECHO @S|@2 | $SED 's/:/ /g'`\" + ;; + *::*) + eval @S|@1=\"\@S|@@S|@1\ `$ECHO @S|@2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" + eval @S|@1=\"`$ECHO @S|@2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \@S|@@S|@1\" + ;; + *) + eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'`\" + ;; + esac +} +]])# _LT_PREPARE_PATH_LIST + + # _LT_SYS_DYNAMIC_LINKER([TAG]) # ----------------------------- # PORTME Fill in your ld.so characteristics @@ -2172,17 +2283,18 @@ m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_OBJDUMP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl +m4_require([_LT_PREPARE_MUNGE_PATH_LIST])dnl AC_MSG_CHECKING([dynamic linker characteristics]) m4_if([$1], [], [ -if test "$GCC" = yes; then +if test yes = "$GCC"; then case $host_os in - darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; - *) lt_awk_arg="/^libraries:/" ;; + darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; + *) lt_awk_arg='/^libraries:/' ;; esac case $host_os in - mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;; - *) lt_sed_strip_eq="s,=/,/,g" ;; + mingw* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;; + *) lt_sed_strip_eq='s|=/|/|g' ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in @@ -2198,28 +2310,35 @@ if test "$GCC" = yes; then ;; esac # Ok, now we have the path, separated by spaces, we can step through it - # and add multilib dir if necessary. + # and add multilib dir if necessary... lt_tmp_lt_search_path_spec= - lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + # ...but if some path component already ends with the multilib dir we assume + # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). + case "$lt_multi_os_dir; $lt_search_path_spec " in + "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) + lt_multi_os_dir= + ;; + esac for lt_sys_path in $lt_search_path_spec; do - if test -d "$lt_sys_path/$lt_multi_os_dir"; then - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" - else + if test -d "$lt_sys_path$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" + elif test -n "$lt_multi_os_dir"; then test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' -BEGIN {RS=" "; FS="/|\n";} { - lt_foo=""; - lt_count=0; +BEGIN {RS = " "; FS = "/|\n";} { + lt_foo = ""; + lt_count = 0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { - lt_foo="/" $lt_i lt_foo; + lt_foo = "/" $lt_i lt_foo; } else { lt_count--; } @@ -2233,7 +2352,7 @@ BEGIN {RS=" "; FS="/|\n";} { # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ - $SED 's,/\([[A-Za-z]]:\),\1,g'` ;; + $SED 's|/\([[A-Za-z]]:\)|\1|g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else @@ -2242,7 +2361,7 @@ fi]) library_names_spec= libname_spec='lib$name' soname_spec= -shrext_cmds=".so" +shrext_cmds=.so postinstall_cmds= postuninstall_cmds= finish_cmds= @@ -2259,14 +2378,17 @@ hardcode_into_libs=no # flags to be left without arguments need_version=unknown +AC_ARG_VAR([LT_SYS_LIBRARY_PATH], +[User-defined run-time library search path.]) + case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + library_names_spec='$libname$release$shared_ext$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' + soname_spec='$libname$release$shared_ext$major' ;; aix[[4-9]]*) @@ -2274,41 +2396,91 @@ aix[[4-9]]*) need_lib_prefix=no need_version=no hardcode_into_libs=yes - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in + # the line '#! .'. This would cause the generated library to + # depend on '.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[[01]] | aix4.[[01]].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' - echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then + echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # Using Import Files as archive members, it is possible to support + # filename-based versioning of shared library archives on AIX. While + # this would work for both with and without runtime linking, it will + # prevent static linking of such archives. So we do filename-based + # shared library versioning with .so extension only, which is used + # when both runtime linking and shared linking is enabled. + # Unfortunately, runtime linking may impact performance, so we do + # not want this to be the default eventually. Also, we use the + # versioned .so libs for executables only if there is the -brtl + # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. + # To allow for filename-based versioning support, we need to create + # libNAME.so.V as an archive file, containing: + # *) an Import File, referring to the versioned filename of the + # archive as well as the shared archive member, telling the + # bitwidth (32 or 64) of that shared object, and providing the + # list of exported symbols of that shared object, eventually + # decorated with the 'weak' keyword + # *) the shared object with the F_LOADONLY flag set, to really avoid + # it being seen by the linker. + # At run time we better use the real file rather than another symlink, + # but for link time we create the symlink libNAME.so -> libNAME.so.V + + case $with_aix_soname,$aix_use_runtimelinking in + # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then + aix,yes) # traditional libtool + dynamic_linker='AIX unversionable lib.so' # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + aix,no) # traditional AIX only + dynamic_linker='AIX lib.a[(]lib.so.V[)]' # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + ;; + svr4,*) # full svr4 only + dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)]" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,yes) # both, prefer svr4 + dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)], lib.a[(]lib.so.V[)]" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # unpreferred sharedlib libNAME.a needs extra handling + postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' + postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,no) # both, prefer aix + dynamic_linker="AIX lib.a[(]lib.so.V[)], lib.so.V[(]$shared_archive_member_spec.o[)]" + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling + postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' + postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' + ;; + esac shlibpath_var=LIBPATH fi ;; @@ -2318,18 +2490,18 @@ amigaos*) powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) - library_names_spec='${libname}${shared_ext}' + library_names_spec='$libname$shared_ext' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; @@ -2337,8 +2509,8 @@ beos*) bsdi[[45]]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" @@ -2350,7 +2522,7 @@ bsdi[[45]]*) cygwin* | mingw* | pw32* | cegcc*) version_type=windows - shrext_cmds=".dll" + shrext_cmds=.dll need_version=no need_lib_prefix=no @@ -2359,8 +2531,8 @@ cygwin* | mingw* | pw32* | cegcc*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ @@ -2376,17 +2548,17 @@ cygwin* | mingw* | pw32* | cegcc*) case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' ;; esac dynamic_linker='Win32 ld.exe' @@ -2395,8 +2567,8 @@ m4_if([$1], [],[ *,cl*) # Native MSVC libname_spec='$name' - soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - library_names_spec='${libname}.dll.lib' + soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' + library_names_spec='$libname.dll.lib' case $build_os in mingw*) @@ -2423,7 +2595,7 @@ m4_if([$1], [],[ sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) - sys_lib_search_path_spec="$LIB" + sys_lib_search_path_spec=$LIB if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` @@ -2436,8 +2608,8 @@ m4_if([$1], [],[ esac # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' @@ -2450,7 +2622,7 @@ m4_if([$1], [],[ *) # Assume MSVC wrapper - library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' + library_names_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac @@ -2463,8 +2635,8 @@ darwin* | rhapsody*) version_type=darwin need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' + library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' + soname_spec='$libname$release$major$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' @@ -2477,8 +2649,8 @@ dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; @@ -2496,12 +2668,13 @@ freebsd* | dragonfly*) version_type=freebsd-$objformat case $version_type in freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' need_version=no need_lib_prefix=no ;; freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' need_version=yes ;; esac @@ -2531,10 +2704,10 @@ haiku*) need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LIBRARY_PATH - shlibpath_overrides_runpath=yes + shlibpath_overrides_runpath=no sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; @@ -2552,14 +2725,15 @@ hpux9* | hpux10* | hpux11*) dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + if test 32 = "$HPUX_IA64_MODE"; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + sys_lib_dlsearch_path_spec=/usr/lib/hpux32 else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + sys_lib_dlsearch_path_spec=/usr/lib/hpux64 fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' @@ -2567,8 +2741,8 @@ hpux9* | hpux10* | hpux11*) dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; @@ -2577,8 +2751,8 @@ hpux9* | hpux10* | hpux11*) dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... @@ -2591,8 +2765,8 @@ interix[[3-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no @@ -2603,7 +2777,7 @@ irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) - if test "$lt_cv_prog_gnu_ld" = yes; then + if test yes = "$lt_cv_prog_gnu_ld"; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix @@ -2611,8 +2785,8 @@ irix5* | irix6* | nonstopux*) esac need_lib_prefix=no need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= @@ -2631,8 +2805,8 @@ irix5* | irix6* | nonstopux*) esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" + sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" hardcode_into_libs=yes ;; @@ -2641,13 +2815,33 @@ linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; +linux*android*) + version_type=none # Android doesn't support versioned libraries. + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext' + soname_spec='$libname$release$shared_ext' + finish_cmds= + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + dynamic_linker='Android linker' + # Don't embed -rpath directories since the linker doesn't support them. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + ;; + # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no @@ -2672,7 +2866,12 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) # before this can be enabled. hardcode_into_libs=yes - # Append ld.so.conf contents to the search path + # Ideally, we could use ldconfig to report *all* directores which are + # searched for libraries, however this is still not possible. Aside from not + # being certain /sbin/ldconfig is available, command + # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, + # even though it is searched at run-time. Try to do the best guess by + # appending ld.so.conf contents (and includes) to the search path. if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" @@ -2704,12 +2903,12 @@ netbsd*) need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH @@ -2719,7 +2918,7 @@ netbsd*) newsos6) version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; @@ -2728,58 +2927,68 @@ newsos6) version_type=qnx need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; -openbsd*) +openbsd* | bitrig*) version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" + sys_lib_dlsearch_path_spec=/usr/lib need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + need_version=no + else + need_version=yes + fi + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[[89]] | openbsd2.[[89]].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi + shlibpath_overrides_runpath=yes ;; os2*) libname_spec='$name' - shrext_cmds=".dll" + version_type=windows + shrext_cmds=.dll + need_version=no need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' + # OS/2 can only load a DLL with a base name of 8 characters or less. + soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; + v=$($ECHO $release$versuffix | tr -d .-); + n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); + $ECHO $n$v`$shared_ext' + library_names_spec='${libname}_dll.$libext' dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH + shlibpath_var=BEGINLIBPATH + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; rdos*) @@ -2790,8 +2999,8 @@ solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes @@ -2801,11 +3010,11 @@ solaris*) sunos4*) version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then + if test yes = "$with_gnu_ld"; then need_lib_prefix=no fi need_version=yes @@ -2813,8 +3022,8 @@ sunos4*) sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) @@ -2835,24 +3044,24 @@ sysv4 | sysv4.3*) ;; sysv4*MP*) - if test -d /usr/nec ;then + if test -d /usr/nec; then version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' + library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' + soname_spec='$libname$shared_ext.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf + version_type=sco need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then + if test yes = "$with_gnu_ld"; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' @@ -2870,7 +3079,7 @@ tpf*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes @@ -2878,8 +3087,8 @@ tpf*) uts4*) version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; @@ -2888,20 +3097,30 @@ uts4*) ;; esac AC_MSG_RESULT([$dynamic_linker]) -test "$dynamic_linker" = no && can_build_shared=no +test no = "$dynamic_linker" && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then +if test yes = "$GCC"; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi -if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then - sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then + sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec fi -if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then - sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" + +if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then + sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec fi +# remember unaugmented sys_lib_dlsearch_path content for libtool script decls... +configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec + +# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code +func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" + +# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool +configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH + _LT_DECL([], [variables_saved_for_relink], [1], [Variables whose values should be saved in libtool wrapper scripts and restored at link time]) @@ -2934,39 +3153,41 @@ _LT_DECL([], [hardcode_into_libs], [0], [Whether we should hardcode library paths into libraries]) _LT_DECL([], [sys_lib_search_path_spec], [2], [Compile-time system search path for libraries]) -_LT_DECL([], [sys_lib_dlsearch_path_spec], [2], - [Run-time system search path for libraries]) +_LT_DECL([sys_lib_dlsearch_path_spec], [configure_time_dlsearch_path], [2], + [Detected run-time system search path for libraries]) +_LT_DECL([], [configure_time_lt_sys_library_path], [2], + [Explicit LT_SYS_LIBRARY_PATH set during ./configure time]) ])# _LT_SYS_DYNAMIC_LINKER # _LT_PATH_TOOL_PREFIX(TOOL) # -------------------------- -# find a file program which can recognize shared library +# find a file program that can recognize shared library AC_DEFUN([_LT_PATH_TOOL_PREFIX], [m4_require([_LT_DECL_EGREP])dnl AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, [case $MAGIC_CMD in [[\\/*] | ?:[\\/]*]) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + lt_save_MAGIC_CMD=$MAGIC_CMD + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="m4_if([$2], , $PATH, [$2])" for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$1; then - lt_cv_path_MAGIC_CMD="$ac_dir/$1" + if test -f "$ac_dir/$1"; then + lt_cv_path_MAGIC_CMD=$ac_dir/"$1" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : @@ -2989,11 +3210,11 @@ _LT_EOF break fi done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" + IFS=$lt_save_ifs + MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac]) -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then AC_MSG_RESULT($MAGIC_CMD) else @@ -3011,7 +3232,7 @@ dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) # _LT_PATH_MAGIC # -------------- -# find a file program which can recognize a shared library +# find a file program that can recognize a shared library m4_defun([_LT_PATH_MAGIC], [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) if test -z "$lt_cv_path_MAGIC_CMD"; then @@ -3038,16 +3259,16 @@ m4_require([_LT_PROG_ECHO_BACKSLASH])dnl AC_ARG_WITH([gnu-ld], [AS_HELP_STRING([--with-gnu-ld], [assume the C compiler uses GNU ld @<:@default=no@:>@])], - [test "$withval" = no || with_gnu_ld=yes], + [test no = "$withval" || with_gnu_ld=yes], [with_gnu_ld=no])dnl ac_prog=ld -if test "$GCC" = yes; then +if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw + # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; @@ -3061,7 +3282,7 @@ if test "$GCC" = yes; then while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done - test -z "$LD" && LD="$ac_prog" + test -z "$LD" && LD=$ac_prog ;; "") # If it fails, then pretend we aren't using GCC. @@ -3072,37 +3293,37 @@ if test "$GCC" = yes; then with_gnu_ld=unknown ;; esac -elif test "$with_gnu_ld" = yes; then +elif test yes = "$with_gnu_ld"; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" + lt_cv_path_LD=$ac_dir/$ac_prog # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 conftest.i +cat conftest.i conftest.i >conftest2.i +: ${lt_DD:=$DD} +AC_PATH_PROGS_FEATURE_CHECK([lt_DD], [dd], +[if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: +fi]) +rm -f conftest.i conftest2.i conftest.out]) +])# _LT_PATH_DD + + +# _LT_CMD_TRUNCATE +# ---------------- +# find command to truncate a binary pipe +m4_defun([_LT_CMD_TRUNCATE], +[m4_require([_LT_PATH_DD]) +AC_CACHE_CHECK([how to truncate binary pipes], [lt_cv_truncate_bin], +[printf 0123456789abcdef0123456789abcdef >conftest.i +cat conftest.i conftest.i >conftest2.i +lt_cv_truncate_bin= +if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" +fi +rm -f conftest.i conftest2.i conftest.out +test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"]) +_LT_DECL([lt_truncate_bin], [lt_cv_truncate_bin], [1], + [Command to truncate a binary pipe]) +])# _LT_CMD_TRUNCATE + + # _LT_CHECK_MAGIC_METHOD # ---------------------- # how to check for library dependencies @@ -3188,13 +3446,13 @@ lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. -# `unknown' -- same as none, but documents that we really don't know. +# 'unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path -# which responds to the $file_magic_cmd with a given extended regex. -# If you have `file' or equivalent on your system and you're not sure -# whether `pass_all' will *always* work, you probably want this one. +# that responds to the $file_magic_cmd with a given extended regex. +# If you have 'file' or equivalent on your system and you're not sure +# whether 'pass_all' will *always* work, you probably want this one. case $host_os in aix[[4-9]]*) @@ -3221,8 +3479,7 @@ mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. - # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. - if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then + if ( file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else @@ -3318,8 +3575,8 @@ newos6*) lt_cv_deplibs_check_method=pass_all ;; -openbsd*) - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then +openbsd* | bitrig*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' @@ -3372,6 +3629,9 @@ sysv4 | sysv4.3*) tpf*) lt_cv_deplibs_check_method=pass_all ;; +os2*) + lt_cv_deplibs_check_method=pass_all + ;; esac ]) @@ -3412,33 +3672,38 @@ AC_DEFUN([LT_PATH_NM], AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. - lt_cv_path_NM="$NM" + lt_cv_path_NM=$NM else - lt_nm_to_check="${ac_tool_prefix}nm" + lt_nm_to_check=${ac_tool_prefix}nm if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. - tmp_nm="$ac_dir/$lt_tmp_nm" - if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + tmp_nm=$ac_dir/$lt_tmp_nm + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # Adding the 'sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file - case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in - */dev/null* | *'Invalid file or object type'*) + # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty + case $build_os in + mingw*) lt_bad_file=conftest.nm/nofile ;; + *) lt_bad_file=/dev/null ;; + esac + case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in + *$lt_bad_file* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" - break + break 2 ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" - break + break 2 ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but @@ -3449,21 +3714,21 @@ else esac fi done - IFS="$lt_save_ifs" + IFS=$lt_save_ifs done : ${lt_cv_path_NM=no} fi]) -if test "$lt_cv_path_NM" != "no"; then - NM="$lt_cv_path_NM" +if test no != "$lt_cv_path_NM"; then + NM=$lt_cv_path_NM else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) - case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in + case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in *COFF*) - DUMPBIN="$DUMPBIN -symbols" + DUMPBIN="$DUMPBIN -symbols -headers" ;; *) DUMPBIN=: @@ -3471,8 +3736,8 @@ else esac fi AC_SUBST([DUMPBIN]) - if test "$DUMPBIN" != ":"; then - NM="$DUMPBIN" + if test : != "$DUMPBIN"; then + NM=$DUMPBIN fi fi test -z "$NM" && NM=nm @@ -3518,8 +3783,8 @@ lt_cv_sharedlib_from_linklib_cmd, case $host_os in cygwin* | mingw* | pw32* | cegcc*) - # two different shell functions defined in ltmain.sh - # decide which to use based on capabilities of $DLLTOOL + # two different shell functions defined in ltmain.sh; + # decide which one to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib @@ -3531,7 +3796,7 @@ cygwin* | mingw* | pw32* | cegcc*) ;; *) # fallback: assume linklib IS sharedlib - lt_cv_sharedlib_from_linklib_cmd="$ECHO" + lt_cv_sharedlib_from_linklib_cmd=$ECHO ;; esac ]) @@ -3558,13 +3823,28 @@ AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool lt_cv_path_mainfest_tool=yes fi rm -f conftest*]) -if test "x$lt_cv_path_mainfest_tool" != xyes; then +if test yes != "$lt_cv_path_mainfest_tool"; then MANIFEST_TOOL=: fi _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl ])# _LT_PATH_MANIFEST_TOOL +# _LT_DLL_DEF_P([FILE]) +# --------------------- +# True iff FILE is a Windows DLL '.def' file. +# Keep in sync with func_dll_def_p in the libtool script +AC_DEFUN([_LT_DLL_DEF_P], +[dnl + test DEF = "`$SED -n dnl + -e '\''s/^[[ ]]*//'\'' dnl Strip leading whitespace + -e '\''/^\(;.*\)*$/d'\'' dnl Delete empty lines and comments + -e '\''s/^\(EXPORTS\|LIBRARY\)\([[ ]].*\)*$/DEF/p'\'' dnl + -e q dnl Only consider the first "real" line + $1`" dnl +])# _LT_DLL_DEF_P + + # LT_LIB_M # -------- # check for math library @@ -3576,11 +3856,11 @@ case $host in # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) - AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM=-lmw) AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") ;; *) - AC_CHECK_LIB(m, cos, LIBM="-lm") + AC_CHECK_LIB(m, cos, LIBM=-lm) ;; esac AC_SUBST([LIBM]) @@ -3599,7 +3879,7 @@ m4_defun([_LT_COMPILER_NO_RTTI], _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= -if test "$GCC" = yes; then +if test yes = "$GCC"; then case $cc_basename in nvcc*) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; @@ -3651,7 +3931,7 @@ cygwin* | mingw* | pw32* | cegcc*) symcode='[[ABCDGISTW]]' ;; hpux*) - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then symcode='[[ABCDEGRST]]' fi ;; @@ -3684,14 +3964,44 @@ case `$NM -V 2>&1` in symcode='[[ABCDGIRSTW]]' ;; esac +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Gets list of data symbols to import. + lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" + # Adjust the below global symbol transforms to fixup imported variables. + lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" + lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" + lt_c_name_lib_hook="\ + -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ + -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" +else + # Disable hooks by default. + lt_cv_sys_global_symbol_to_import= + lt_cdecl_hook= + lt_c_name_hook= + lt_c_name_lib_hook= +fi + # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. -lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" +lt_cv_sys_global_symbol_to_cdecl="sed -n"\ +$lt_cdecl_hook\ +" -e 's/^T .* \(.*\)$/extern int \1();/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ +$lt_c_name_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" + +# Transform an extracted symbol line into symbol name with lib prefix and +# symbol address. +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ +$lt_c_name_lib_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" # Handle CRLF in mingw tool chain opt_cr= @@ -3709,21 +4019,24 @@ for ac_symprfx in "" "_"; do # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then - # Fake it for dumpbin and say T for any non-static function - # and D for any global variable. + # Fake it for dumpbin and say T for any non-static function, + # D for any global variable and I for any imported variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ +" /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ +" /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ +" /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ -" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ -" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ -" s[1]~/^[@?]/{print s[1], s[1]; next};"\ -" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ +" {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ +" {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ +" s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx]" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" @@ -3750,7 +4063,8 @@ _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm - if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then + $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&AS_MESSAGE_LOG_FD + if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&AS_MESSAGE_LOG_FD && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" @@ -3763,11 +4077,11 @@ _LT_EOF if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ -#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) -/* DATA imports from DLLs on WIN32 con't be const, because runtime +#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE +/* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT@&t@_DLSYM_CONST -#elif defined(__osf__) +#elif defined __osf__ /* This system does not cope well with relocations in const data. */ # define LT@&t@_DLSYM_CONST #else @@ -3793,7 +4107,7 @@ lt__PROGRAM__LTX_preloaded_symbols[[]] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF - $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext + $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; @@ -3813,9 +4127,9 @@ _LT_EOF mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS - LIBS="conftstm.$ac_objext" + LIBS=conftstm.$ac_objext CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then + if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS @@ -3836,7 +4150,7 @@ _LT_EOF rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. - if test "$pipe_works" = yes; then + if test yes = "$pipe_works"; then break else lt_cv_sys_global_symbol_pipe= @@ -3863,12 +4177,16 @@ _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], [Take the output of nm and produce a listing of raw symbols and C names]) _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], [Transform the output of nm in a proper C declaration]) +_LT_DECL([global_symbol_to_import], [lt_cv_sys_global_symbol_to_import], [1], + [Transform the output of nm into a list of symbols to manually relocate]) _LT_DECL([global_symbol_to_c_name_address], [lt_cv_sys_global_symbol_to_c_name_address], [1], [Transform the output of nm in a C name address pair]) _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) +_LT_DECL([nm_interface], [lt_cv_nm_interface], [1], + [The name lister interface]) _LT_DECL([], [nm_file_list_spec], [1], [Specify filename containing input files for $NM]) ]) # _LT_CMD_GLOBAL_SYMBOLS @@ -3884,17 +4202,18 @@ _LT_TAGVAR(lt_prog_compiler_static, $1)= m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. - if test "$GXX" = yes; then + if test yes = "$GXX"; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; amigaos*) @@ -3905,8 +4224,8 @@ m4_if([$1], [CXX], [ ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. + # adding the '-m68020' flag to GCC prevents building anything better, + # like '-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac @@ -3922,6 +4241,11 @@ m4_if([$1], [CXX], [ # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + case $host_os in + os2*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' + ;; + esac ;; darwin* | rhapsody*) # PIC is the default on this platform @@ -3971,7 +4295,7 @@ m4_if([$1], [CXX], [ case $host_os in aix[[4-9]]*) # All AIX code is PIC. - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else @@ -4012,14 +4336,14 @@ m4_if([$1], [CXX], [ case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - if test "$host_cpu" != ia64; then + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' + if test ia64 != "$host_cpu"; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' fi ;; aCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default @@ -4056,7 +4380,7 @@ m4_if([$1], [CXX], [ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; ecpc* ) - # old Intel C++ for x86_64 which still supported -KPIC. + # old Intel C++ for x86_64, which still supported -KPIC. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' @@ -4201,17 +4525,18 @@ m4_if([$1], [CXX], [ fi ], [ - if test "$GCC" = yes; then + if test yes = "$GCC"; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; amigaos*) @@ -4222,8 +4547,8 @@ m4_if([$1], [CXX], [ ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. + # adding the '-m68020' flag to GCC prevents building anything better, + # like '-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac @@ -4240,6 +4565,11 @@ m4_if([$1], [CXX], [ # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + case $host_os in + os2*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' + ;; + esac ;; darwin* | rhapsody*) @@ -4310,7 +4640,7 @@ m4_if([$1], [CXX], [ case $host_os in aix*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else @@ -4318,11 +4648,30 @@ m4_if([$1], [CXX], [ fi ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + case $cc_basename in + nagfor*) + # NAG Fortran compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + case $host_os in + os2*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' + ;; + esac ;; hpux9* | hpux10* | hpux11*) @@ -4338,7 +4687,7 @@ m4_if([$1], [CXX], [ ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) @@ -4349,12 +4698,18 @@ m4_if([$1], [CXX], [ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in - # old Intel for x86_64 which still supported -KPIC. + # old Intel for x86_64, which still supported -KPIC. ecc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; + # flang / f18. f95 an alias for gfortran or flang on Debian + flang* | f18* | f95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) @@ -4374,6 +4729,12 @@ m4_if([$1], [CXX], [ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) @@ -4471,7 +4832,7 @@ m4_if([$1], [CXX], [ ;; sysv4*MP*) - if test -d /usr/nec ;then + if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi @@ -4500,7 +4861,7 @@ m4_if([$1], [CXX], [ fi ]) case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: + # For platforms that do not support PIC, -DPIC is meaningless: *djgpp*) _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; @@ -4566,17 +4927,21 @@ m4_if([$1], [CXX], [ case $host_os in aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - # Also, AIX nm treats weak defined symbols like other global defined - # symbols, whereas GNU nm marks them as "W". + # -C means demangle to GNU nm, but means don't demangle to AIX nm. + # Without the "-l" option, or with the "-B" option, AIX nm treats + # weak defined symbols like other global defined symbols, whereas + # GNU nm marks them as "W". + # While the 'weak' keyword is ignored in the Export File, we need + # it in the Import File for the 'aix-soname' feature, so we have + # to replace the "-B" option with "-P" for AIX nm. if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi ;; pw32*) - _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" + _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds ;; cygwin* | mingw* | cegcc*) case $cc_basename in @@ -4625,9 +4990,9 @@ m4_if([$1], [CXX], [ # included in the symbol list _LT_TAGVAR(include_expsyms, $1)= # exclude_expsyms can be an extended regexp of symbols to exclude - # it will be wrapped by ` (' and `)$', so one must not match beginning or - # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', - # as well as any symbol that contains `d'. + # it will be wrapped by ' (' and ')$', so one must not match beginning or + # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', + # as well as any symbol that contains 'd'. _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if @@ -4643,7 +5008,7 @@ dnl Note also adjust exclude_expsyms for C++ above. # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. - if test "$GCC" != yes; then + if test yes != "$GCC"; then with_gnu_ld=no fi ;; @@ -4651,7 +5016,7 @@ dnl Note also adjust exclude_expsyms for C++ above. # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; - openbsd*) + openbsd* | bitrig*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) @@ -4664,7 +5029,7 @@ dnl Note also adjust exclude_expsyms for C++ above. # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no - if test "$with_gnu_ld" = yes; then + if test yes = "$with_gnu_ld"; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility @@ -4686,24 +5051,24 @@ dnl Note also adjust exclude_expsyms for C++ above. esac fi - if test "$lt_use_gnu_ld_interface" = yes; then + if test yes = "$lt_use_gnu_ld_interface"; then # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' + wlarc='$wl' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no - case `$LD -v 2>&1` in + case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... @@ -4716,7 +5081,7 @@ dnl Note also adjust exclude_expsyms for C++ above. case $host_os in aix[[3-9]]*) # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then + if test ia64 != "$host_cpu"; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 @@ -4735,7 +5100,7 @@ _LT_EOF case $host_cpu in powerpc) # see comment about AmigaOS4 .so support - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) @@ -4751,7 +5116,7 @@ _LT_EOF _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME - _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi @@ -4761,7 +5126,7 @@ _LT_EOF # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes @@ -4769,61 +5134,89 @@ _LT_EOF _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file, use it as + # is; otherwise, prepend EXPORTS... + _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; haiku*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; + os2*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + shrext_cmds=.dll + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no - if test "$host_os" = linux-dietlibc; then + if test linux-dietlibc = "$host_os"; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ - && test "$tmp_diet" = no + && test no = "$tmp_diet" then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; @@ -4834,42 +5227,47 @@ _LT_EOF lf95*) # Lahey Fortran 8.1 _LT_TAGVAR(whole_archive_flag_spec, $1)= tmp_sharedflag='--shared' ;; + nagfor*) # NAGFOR 5.3 + tmp_sharedflag='-Wl,-shared' ;; xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac - _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then + if test yes = "$supports_anon_versioning"; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi case $cc_basename in + tcc*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='-rdynamic' + ;; xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then + if test yes = "$supports_anon_versioning"; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac @@ -4883,8 +5281,8 @@ _LT_EOF _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' fi ;; @@ -4902,8 +5300,8 @@ _LT_EOF _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi @@ -4915,7 +5313,7 @@ _LT_EOF _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 -*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify @@ -4930,9 +5328,9 @@ _LT_EOF # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi @@ -4949,15 +5347,15 @@ _LT_EOF *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac - if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then + if test no = "$_LT_TAGVAR(ld_shlibs, $1)"; then runpath_var= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= @@ -4973,7 +5371,7 @@ _LT_EOF # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. _LT_TAGVAR(hardcode_minus_L, $1)=yes - if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. _LT_TAGVAR(hardcode_direct, $1)=unsupported @@ -4981,34 +5379,57 @@ _LT_EOF ;; aix[[4-9]]*) - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' - no_entry_flag="" + no_entry_flag= else # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - # Also, AIX nm treats weak defined symbols like other global - # defined symbols, whereas GNU nm marks them as "W". + # -C means demangle to GNU nm, but means don't demangle to AIX nm. + # Without the "-l" option, or with the "-B" option, AIX nm treats + # weak defined symbols like other global defined symbols, whereas + # GNU nm marks them as "W". + # While the 'weak' keyword is ignored in the Export File, we need + # it in the Import File for the 'aix-soname' feature, so we have + # to replace the "-B" option with "-P" for AIX nm. if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. + # have runtime linking enabled, and use it for executables. + # For shared libraries, we enable/disable runtime linking + # depending on the kind of the shared library created - + # when "with_aix_soname,aix_use_runtimelinking" is: + # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables + # "aix,yes" lib.so shared, rtl:yes, for executables + # lib.a static archive + # "both,no" lib.so.V(shr.o) shared, rtl:yes + # lib.a(lib.so.V) shared, rtl:no, for executables + # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a(lib.so.V) shared, rtl:no + # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a static archive case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then aix_use_runtimelinking=yes break fi done + if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then + # With aix-soname=svr4, we create the lib.so.V shared archives only, + # so we don't have lib.a shared libs to link our executables. + # We have to force runtime linking in this case. + aix_use_runtimelinking=yes + LDFLAGS="$LDFLAGS -Wl,-brtl" + fi ;; esac @@ -5027,13 +5448,21 @@ _LT_EOF _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' + _LT_TAGVAR(file_list_spec, $1)='$wl-f,' + case $with_aix_soname,$aix_use_runtimelinking in + aix,*) ;; # traditional, no import file + svr4,* | *,yes) # use import file + # The Import File defines what to hardcode. + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=no + ;; + esac - if test "$GCC" = yes; then + if test yes = "$GCC"; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` + collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then @@ -5052,62 +5481,80 @@ _LT_EOF ;; esac shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' + if test yes = "$aix_use_runtimelinking"; then + shared_flag="$shared_flag "'$wl-G' fi - _LT_TAGVAR(link_all_deplibs, $1)=no + # Need to ensure runtime linking is disabled for the traditional + # shared library, or the linker may eventually find shared libraries + # /with/ Import File - we do not want to mix them. + shared_flag_aix='-shared' + shared_flag_svr4='-shared $wl-G' else # not using gcc - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' + if test yes = "$aix_use_runtimelinking"; then + shared_flag='$wl-G' else - shared_flag='${wl}-bM:SRE' + shared_flag='$wl-bM:SRE' fi + shared_flag_aix='$wl-bM:SRE' + shared_flag_svr4='$wl-G' fi fi - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. _LT_TAGVAR(always_export_symbols, $1)=yes - if test "$aix_use_runtimelinking" = yes; then + if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else - if test "$host_cpu" = ia64; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + if test ia64 = "$host_cpu"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - if test "$with_gnu_ld" = yes; then + _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok' + if test yes = "$with_gnu_ld"; then # We only use this code for GNU lds that support --whole-archive. - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - # This is similar to how AIX traditionally builds its shared libraries. - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' + # -brtl affects multiple linker settings, -berok does not and is overridden later + compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`' + if test svr4 != "$with_aix_soname"; then + # This is similar to how AIX traditionally builds its shared libraries. + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' + fi + if test aix != "$with_aix_soname"; then + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' + else + # used by -dlpreopen to get the symbols + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir' + fi + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d' fi fi ;; @@ -5116,7 +5563,7 @@ _LT_EOF case $host_cpu in powerpc) # see comment about AmigaOS4 .so support - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) @@ -5146,16 +5593,17 @@ _LT_EOF # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" + shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. - _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; - else - sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; - fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ - linknames=' + _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then + cp "$export_symbols" "$output_objdir/$soname.def"; + echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; + else + $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes @@ -5164,18 +5612,18 @@ _LT_EOF # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ - lt_tool_outputfile="@TOOL_OUTPUT@"~ - case $lt_outputfile in - *.exe|*.EXE) ;; - *) - lt_outputfile="$lt_outputfile.exe" - lt_tool_outputfile="$lt_tool_outputfile.exe" - ;; - esac~ - if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; - $RM "$lt_outputfile.manifest"; - fi' + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile=$lt_outputfile.exe + lt_tool_outputfile=$lt_tool_outputfile.exe + ;; + esac~ + if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' ;; *) # Assume MSVC wrapper @@ -5184,7 +5632,7 @@ _LT_EOF # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" + shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. @@ -5234,33 +5682,33 @@ _LT_EOF ;; hpux9*) - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + if test yes = "$GCC"; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' ;; hpux10*) - if test "$GCC" = yes && test "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + if test yes,no = "$GCC,$with_gnu_ld"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi - if test "$with_gnu_ld" = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + if test no = "$with_gnu_ld"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes @@ -5268,25 +5716,25 @@ _LT_EOF ;; hpux11*) - if test "$GCC" = yes && test "$with_gnu_ld" = no; then + if test yes,no = "$GCC,$with_gnu_ld"; then case $host_cpu in hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) m4_if($1, [], [ @@ -5294,14 +5742,14 @@ _LT_EOF # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) _LT_LINKER_OPTION([if $CC understands -b], _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], - [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], + [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], - [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) + [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) ;; esac fi - if test "$with_gnu_ld" = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + if test no = "$with_gnu_ld"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in @@ -5312,7 +5760,7 @@ _LT_EOF *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. @@ -5323,16 +5771,16 @@ _LT_EOF ;; irix5* | irix6* | nonstopux*) - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + if test yes = "$GCC"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], [lt_cv_irix_exported_symbol], - [save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" + [save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" AC_LINK_IFELSE( [AC_LANG_SOURCE( [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], @@ -5345,21 +5793,32 @@ _LT_EOF end]])])], [lt_cv_irix_exported_symbol=yes], [lt_cv_irix_exported_symbol=no]) - LDFLAGS="$save_LDFLAGS"]) - if test "$lt_cv_irix_exported_symbol" = yes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' + LDFLAGS=$save_LDFLAGS]) + if test yes = "$lt_cv_irix_exported_symbol"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' fi + _LT_TAGVAR(link_all_deplibs, $1)=no else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes _LT_TAGVAR(link_all_deplibs, $1)=yes ;; + linux*) + case $cc_basename in + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + _LT_TAGVAR(ld_shlibs, $1)=yes + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out @@ -5374,7 +5833,7 @@ _LT_EOF newsos6) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; @@ -5382,27 +5841,19 @@ _LT_EOF *nto* | *qnx*) ;; - openbsd*) + openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' else - case $host_os in - openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - ;; - esac + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' fi else _LT_TAGVAR(ld_shlibs, $1)=no @@ -5413,33 +5864,53 @@ _LT_EOF _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' - _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + shrext_cmds=.dll + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; osf3*) - if test "$GCC" = yes; then - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + if test yes = "$GCC"; then + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + if test yes = "$GCC"; then + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ - $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' + $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' @@ -5450,24 +5921,24 @@ _LT_EOF solaris*) _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' - if test "$GCC" = yes; then - wlarc='${wl}' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + if test yes = "$GCC"; then + wlarc='$wl' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' - _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(archive_cmds, $1)='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' + $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) - wlarc='${wl}' - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' + wlarc='$wl' + _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi @@ -5477,11 +5948,11 @@ _LT_EOF solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. GCC discards it without `$wl', + # but understands '-z linker_flag'. GCC discards it without '$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) - if test "$GCC" = yes; then - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + if test yes = "$GCC"; then + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' else _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' fi @@ -5491,10 +5962,10 @@ _LT_EOF ;; sunos4*) - if test "x$host_vendor" = xsequent; then + if test sequent = "$host_vendor"; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi @@ -5543,43 +6014,43 @@ _LT_EOF ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + if test yes = "$GCC"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not + # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport' runpath_var='LD_RUN_PATH' - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + if test yes = "$GCC"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; @@ -5594,17 +6065,17 @@ _LT_EOF ;; esac - if test x$host_vendor = xsni; then + if test sni = "$host_vendor"; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Blargedynsym' ;; esac fi fi ]) AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) -test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no +test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld @@ -5621,7 +6092,7 @@ x|xyes) # Assume -lc should be added _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - if test "$enable_shared" = yes && test "$GCC" = yes; then + if test yes,yes = "$GCC,$enable_shared"; then case $_LT_TAGVAR(archive_cmds, $1) in *'~'*) # FIXME: we may have to deal with multi-command sequences. @@ -5701,12 +6172,12 @@ _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], - [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes + [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_direct_absolute], [0], - [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes + [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes DIR into the resulting binary and the resulting library dependency is - "absolute", i.e impossible to change by setting ${shlibpath_var} if the + "absolute", i.e impossible to change by setting $shlibpath_var if the library is relocated]) _LT_TAGDECL([], [hardcode_minus_L], [0], [Set to "yes" if using the -LDIR flag during linking hardcodes DIR @@ -5747,10 +6218,10 @@ dnl [Compiler flag to generate thread safe objects]) # ------------------------ # Ensure that the configuration variables for a C compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write -# the compiler configuration to `libtool'. +# the compiler configuration to 'libtool'. m4_defun([_LT_LANG_C_CONFIG], [m4_require([_LT_DECL_EGREP])dnl -lt_save_CC="$CC" +lt_save_CC=$CC AC_LANG_PUSH(C) # Source file extension for C test sources. @@ -5790,18 +6261,18 @@ if test -n "$compiler"; then LT_SYS_DLOPEN_SELF _LT_CMD_STRIPLIB - # Report which library types will actually be built + # Report what library types will actually be built AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) - test "$can_build_shared" = "no" && enable_shared=no + test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) - test "$enable_shared" = yes && enable_static=no + test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' @@ -5809,8 +6280,12 @@ if test -n "$compiler"; then ;; aix[[4-9]]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no + if test ia64 != "$host_cpu"; then + case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in + yes,aix,yes) ;; # shared object as lib.so file only + yes,svr4,*) ;; # shared object as lib.so archive member only + yes,*) enable_static=no ;; # shared object in lib.a archive as well + esac fi ;; esac @@ -5818,13 +6293,13 @@ if test -n "$compiler"; then AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes + test yes = "$enable_shared" || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_CONFIG($1) fi AC_LANG_POP -CC="$lt_save_CC" +CC=$lt_save_CC ])# _LT_LANG_C_CONFIG @@ -5832,14 +6307,14 @@ CC="$lt_save_CC" # -------------------------- # Ensure that the configuration variables for a C++ compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write -# the compiler configuration to `libtool'. +# the compiler configuration to 'libtool'. m4_defun([_LT_LANG_CXX_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl -if test -n "$CXX" && ( test "X$CXX" != "Xno" && - ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || - (test "X$CXX" != "Xg++"))) ; then +if test -n "$CXX" && ( test no != "$CXX" && + ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) || + (test g++ != "$CXX"))); then AC_PROG_CXXCPP else _lt_caught_CXX_error=yes @@ -5881,7 +6356,7 @@ _LT_TAGVAR(objext, $1)=$objext # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_caught_CXX_error" != yes; then +if test yes != "$_lt_caught_CXX_error"; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" @@ -5923,35 +6398,35 @@ if test "$_lt_caught_CXX_error" != yes; then if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately - if test "$GXX" = yes; then + if test yes = "$GXX"; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' else _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= fi - if test "$GXX" = yes; then + if test yes = "$GXX"; then # Set up default GNU C++ configuration LT_PATH_LD # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. - if test "$with_gnu_ld" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + if test yes = "$with_gnu_ld"; then + _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) - wlarc='${wl}' + wlarc='$wl' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi @@ -5970,7 +6445,7 @@ if test "$_lt_caught_CXX_error" != yes; then # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else GXX=no @@ -5987,18 +6462,30 @@ if test "$_lt_caught_CXX_error" != yes; then _LT_TAGVAR(ld_shlibs, $1)=no ;; aix[[4-9]]*) - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' - no_entry_flag="" + no_entry_flag= else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. + # have runtime linking enabled, and use it for executables. + # For shared libraries, we enable/disable runtime linking + # depending on the kind of the shared library created - + # when "with_aix_soname,aix_use_runtimelinking" is: + # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables + # "aix,yes" lib.so shared, rtl:yes, for executables + # lib.a static archive + # "both,no" lib.so.V(shr.o) shared, rtl:yes + # lib.a(lib.so.V) shared, rtl:no, for executables + # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a(lib.so.V) shared, rtl:no + # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a static archive case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do case $ld_flag in @@ -6008,6 +6495,13 @@ if test "$_lt_caught_CXX_error" != yes; then ;; esac done + if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then + # With aix-soname=svr4, we create the lib.so.V shared archives only, + # so we don't have lib.a shared libs to link our executables. + # We have to force runtime linking in this case. + aix_use_runtimelinking=yes + LDFLAGS="$LDFLAGS -Wl,-brtl" + fi ;; esac @@ -6026,13 +6520,21 @@ if test "$_lt_caught_CXX_error" != yes; then _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' + _LT_TAGVAR(file_list_spec, $1)='$wl-f,' + case $with_aix_soname,$aix_use_runtimelinking in + aix,*) ;; # no import file + svr4,* | *,yes) # use import file + # The Import File defines what to hardcode. + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=no + ;; + esac - if test "$GXX" = yes; then + if test yes = "$GXX"; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` + collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then @@ -6050,64 +6552,84 @@ if test "$_lt_caught_CXX_error" != yes; then fi esac shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' + if test yes = "$aix_use_runtimelinking"; then + shared_flag=$shared_flag' $wl-G' fi + # Need to ensure runtime linking is disabled for the traditional + # shared library, or the linker may eventually find shared libraries + # /with/ Import File - we do not want to mix them. + shared_flag_aix='-shared' + shared_flag_svr4='-shared $wl-G' else # not using gcc - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' + if test yes = "$aix_use_runtimelinking"; then + shared_flag='$wl-G' else - shared_flag='${wl}-bM:SRE' + shared_flag='$wl-bM:SRE' fi + shared_flag_aix='$wl-bM:SRE' + shared_flag_svr4='$wl-G' fi fi - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. _LT_TAGVAR(always_export_symbols, $1)=yes - if test "$aix_use_runtimelinking" = yes; then + if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(allow_undefined_flag, $1)='-berok' + # The "-G" linker flag allows undefined symbols. + _LT_TAGVAR(no_undefined_flag, $1)='-bernotok' # Determine the default libpath from the value encoded in an empty # executable. _LT_SYS_MODULE_PATH_AIX([$1]) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else - if test "$host_cpu" = ia64; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + if test ia64 = "$host_cpu"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - if test "$with_gnu_ld" = yes; then + _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok' + if test yes = "$with_gnu_ld"; then # We only use this code for GNU lds that support --whole-archive. - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - # This is similar to how AIX traditionally builds its shared - # libraries. - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' + # -brtl affects multiple linker settings, -berok does not and is overridden later + compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`' + if test svr4 != "$with_aix_soname"; then + # This is similar to how AIX traditionally builds its shared + # libraries. Need -bnortl late, we may have -brtl in LDFLAGS. + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' + fi + if test aix != "$with_aix_soname"; then + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' + else + # used by -dlpreopen to get the symbols + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir' + fi + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d' fi fi ;; @@ -6117,7 +6639,7 @@ if test "$_lt_caught_CXX_error" != yes; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME - _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi @@ -6145,57 +6667,58 @@ if test "$_lt_caught_CXX_error" != yes; then # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" + shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. - _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; - else - $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; - fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ - linknames=' + _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then + cp "$export_symbols" "$output_objdir/$soname.def"; + echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; + else + $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ - lt_tool_outputfile="@TOOL_OUTPUT@"~ - case $lt_outputfile in - *.exe|*.EXE) ;; - *) - lt_outputfile="$lt_outputfile.exe" - lt_tool_outputfile="$lt_tool_outputfile.exe" - ;; - esac~ - func_to_tool_file "$lt_outputfile"~ - if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; - $RM "$lt_outputfile.manifest"; - fi' + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile=$lt_outputfile.exe + lt_tool_outputfile=$lt_tool_outputfile.exe + ;; + esac~ + func_to_tool_file "$lt_outputfile"~ + if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' ;; *) # g++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file, use it as + # is; otherwise, prepend EXPORTS... + _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi @@ -6206,6 +6729,34 @@ if test "$_lt_caught_CXX_error" != yes; then _LT_DARWIN_LINKER_FEATURES($1) ;; + os2*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + shrext_cmds=.dll + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + dgux*) case $cc_basename in ec++*) @@ -6241,14 +6792,14 @@ if test "$_lt_caught_CXX_error" != yes; then ;; haiku*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; hpux9*) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default @@ -6260,7 +6811,7 @@ if test "$_lt_caught_CXX_error" != yes; then _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. @@ -6269,11 +6820,11 @@ if test "$_lt_caught_CXX_error" != yes; then # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) - if test "$GXX" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + if test yes = "$GXX"; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no @@ -6283,15 +6834,15 @@ if test "$_lt_caught_CXX_error" != yes; then ;; hpux10*|hpux11*) - if test $with_gnu_ld = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + if test no = "$with_gnu_ld"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) ;; *) - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' ;; esac fi @@ -6317,13 +6868,13 @@ if test "$_lt_caught_CXX_error" != yes; then aCC*) case $host_cpu in hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists @@ -6334,20 +6885,20 @@ if test "$_lt_caught_CXX_error" != yes; then # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) - if test "$GXX" = yes; then - if test $with_gnu_ld = no; then + if test yes = "$GXX"; then + if test no = "$with_gnu_ld"; then case $host_cpu in hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi @@ -6362,22 +6913,22 @@ if test "$_lt_caught_CXX_error" != yes; then interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is @@ -6386,17 +6937,17 @@ if test "$_lt_caught_CXX_error" != yes; then _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) - if test "$GXX" = yes; then - if test "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + if test yes = "$GXX"; then + if test no = "$with_gnu_ld"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes ;; esac - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes ;; @@ -6409,8 +6960,8 @@ if test "$_lt_caught_CXX_error" != yes; then # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. - _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. @@ -6419,10 +6970,10 @@ if test "$_lt_caught_CXX_error" != yes; then # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. @@ -6436,59 +6987,59 @@ if test "$_lt_caught_CXX_error" != yes; then # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac - _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ - compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ + compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ - $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ - $RANLIB $oldlib' + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ + $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ + $RANLIB $oldlib' _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; esac - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl--rpath $wl$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' ;; cxx*) # Compaq C++ - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib $wl-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' @@ -6502,18 +7053,18 @@ if test "$_lt_caught_CXX_error" != yes; then # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + if test yes = "$supports_anon_versioning"; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi ;; *) @@ -6521,10 +7072,10 @@ if test "$_lt_caught_CXX_error" != yes; then *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' + _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes # Not sure whether something based on @@ -6582,22 +7133,17 @@ if test "$_lt_caught_CXX_error" != yes; then _LT_TAGVAR(ld_shlibs, $1)=yes ;; - openbsd2*) - # C++ shared libraries are fairly broken - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - openbsd*) + openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else @@ -6613,9 +7159,9 @@ if test "$_lt_caught_CXX_error" != yes; then # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. - _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Archives containing C++ object files must be created using @@ -6633,17 +7179,17 @@ if test "$_lt_caught_CXX_error" != yes; then cxx*) case $host in osf3*) - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' ;; *) _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ - echo "-hidden">> $lib.exp~ - $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ - $RM $lib.exp' + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~ + $RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' ;; esac @@ -6658,27 +7204,27 @@ if test "$_lt_caught_CXX_error" != yes; then # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + if test yes,no = "$GXX,$with_gnu_ld"; then + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' case $host in osf3*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' ;; *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' ;; esac - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else # FIXME: insert proper C++ library support @@ -6718,9 +7264,9 @@ if test "$_lt_caught_CXX_error" != yes; then # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no @@ -6728,7 +7274,7 @@ if test "$_lt_caught_CXX_error" != yes; then solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. + # but understands '-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; @@ -6745,42 +7291,42 @@ if test "$_lt_caught_CXX_error" != yes; then ;; gcx*) # Green Hills C++ Compiler - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' + if test yes,no = "$GXX,$with_gnu_ld"; then + _LT_TAGVAR(no_undefined_flag, $1)=' $wl-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else - # g++ 2.7 appears to require `-G' NOT `-shared' on this + # g++ 2.7 appears to require '-G' NOT '-shared' on this # platform. - _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir' case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' ;; esac fi @@ -6789,52 +7335,52 @@ if test "$_lt_caught_CXX_error" != yes; then ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not + # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ - '"$_LT_TAGVAR(old_archive_cmds, $1)" + '"$_LT_TAGVAR(old_archive_cmds, $1)" _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ - '"$_LT_TAGVAR(reload_cmds, $1)" + '"$_LT_TAGVAR(reload_cmds, $1)" ;; *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; @@ -6865,10 +7411,10 @@ if test "$_lt_caught_CXX_error" != yes; then esac AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) - test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no - _LT_TAGVAR(GCC, $1)="$GXX" - _LT_TAGVAR(LD, $1)="$LD" + _LT_TAGVAR(GCC, $1)=$GXX + _LT_TAGVAR(LD, $1)=$LD ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change @@ -6895,7 +7441,7 @@ if test "$_lt_caught_CXX_error" != yes; then lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld -fi # test "$_lt_caught_CXX_error" != yes +fi # test yes != "$_lt_caught_CXX_error" AC_LANG_POP ])# _LT_LANG_CXX_CONFIG @@ -6917,13 +7463,14 @@ AC_REQUIRE([_LT_DECL_SED]) AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) func_stripname_cnf () { - case ${2} in - .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; + case @S|@2 in + .*) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%\\\\@S|@2\$%%"`;; + *) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%@S|@2\$%%"`;; esac } # func_stripname_cnf ])# _LT_FUNC_STRIPNAME_CNF + # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose @@ -7007,13 +7554,13 @@ if AC_TRY_EVAL(ac_compile); then pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do - case ${prev}${p} in + case $prev$p in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. - if test $p = "-L" || - test $p = "-R"; then + if test x-L = "$p" || + test x-R = "$p"; then prev=$p continue fi @@ -7029,16 +7576,16 @@ if AC_TRY_EVAL(ac_compile); then case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac - if test "$pre_test_object_deps_done" = no; then - case ${prev} in + if test no = "$pre_test_object_deps_done"; then + case $prev in -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then - _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" + _LT_TAGVAR(compiler_lib_search_path, $1)=$prev$p else - _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" + _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} $prev$p" fi ;; # The "-l" case would never come before the object being @@ -7046,9 +7593,9 @@ if AC_TRY_EVAL(ac_compile); then esac else if test -z "$_LT_TAGVAR(postdeps, $1)"; then - _LT_TAGVAR(postdeps, $1)="${prev}${p}" + _LT_TAGVAR(postdeps, $1)=$prev$p else - _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" + _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} $prev$p" fi fi prev= @@ -7063,15 +7610,15 @@ if AC_TRY_EVAL(ac_compile); then continue fi - if test "$pre_test_object_deps_done" = no; then + if test no = "$pre_test_object_deps_done"; then if test -z "$_LT_TAGVAR(predep_objects, $1)"; then - _LT_TAGVAR(predep_objects, $1)="$p" + _LT_TAGVAR(predep_objects, $1)=$p else _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" fi else if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then - _LT_TAGVAR(postdep_objects, $1)="$p" + _LT_TAGVAR(postdep_objects, $1)=$p else _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" fi @@ -7102,51 +7649,6 @@ interix[[3-9]]*) _LT_TAGVAR(postdep_objects,$1)= _LT_TAGVAR(postdeps,$1)= ;; - -linux*) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - - # The more standards-conforming stlport4 library is - # incompatible with the Cstd library. Avoid specifying - # it if it's in CXXFLAGS. Ignore libCrun as - # -library=stlport4 depends on it. - case " $CXX $CXXFLAGS " in - *" -library=stlport4 "*) - solaris_use_stlport4=yes - ;; - esac - - if test "$solaris_use_stlport4" != yes; then - _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' - fi - ;; - esac - ;; - -solaris*) - case $cc_basename in - CC* | sunCC*) - # The more standards-conforming stlport4 library is - # incompatible with the Cstd library. Avoid specifying - # it if it's in CXXFLAGS. Ignore libCrun as - # -library=stlport4 depends on it. - case " $CXX $CXXFLAGS " in - *" -library=stlport4 "*) - solaris_use_stlport4=yes - ;; - esac - - # Adding this requires a known-good setup of shared libraries for - # Sun compiler versions before 5.6, else PIC objects from an old - # archive will be linked into the output, leading to subtle bugs. - if test "$solaris_use_stlport4" != yes; then - _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' - fi - ;; - esac - ;; esac ]) @@ -7155,7 +7657,7 @@ case " $_LT_TAGVAR(postdeps, $1) " in esac _LT_TAGVAR(compiler_lib_search_dirs, $1)= if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then - _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` + _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | $SED -e 's! -L! !g' -e 's!^ !!'` fi _LT_TAGDECL([], [compiler_lib_search_dirs], [1], [The directories searched by this compiler when creating a shared library]) @@ -7175,10 +7677,10 @@ _LT_TAGDECL([], [compiler_lib_search_path], [1], # -------------------------- # Ensure that the configuration variables for a Fortran 77 compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. +# to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_F77_CONFIG], [AC_LANG_PUSH(Fortran 77) -if test -z "$F77" || test "X$F77" = "Xno"; then +if test -z "$F77" || test no = "$F77"; then _lt_disable_F77=yes fi @@ -7215,7 +7717,7 @@ _LT_TAGVAR(objext, $1)=$objext # the F77 compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_disable_F77" != yes; then +if test yes != "$_lt_disable_F77"; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t @@ -7237,7 +7739,7 @@ if test "$_lt_disable_F77" != yes; then _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. - lt_save_CC="$CC" + lt_save_CC=$CC lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${F77-"f77"} @@ -7251,21 +7753,25 @@ if test "$_lt_disable_F77" != yes; then AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) - test "$can_build_shared" = "no" && enable_shared=no + test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) - test "$enable_shared" = yes && enable_static=no + test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no + if test ia64 != "$host_cpu"; then + case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in + yes,aix,yes) ;; # shared object as lib.so file only + yes,svr4,*) ;; # shared object as lib.so archive member only + yes,*) enable_static=no ;; # shared object in lib.a archive as well + esac fi ;; esac @@ -7273,11 +7779,11 @@ if test "$_lt_disable_F77" != yes; then AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes + test yes = "$enable_shared" || enable_static=yes AC_MSG_RESULT([$enable_static]) - _LT_TAGVAR(GCC, $1)="$G77" - _LT_TAGVAR(LD, $1)="$LD" + _LT_TAGVAR(GCC, $1)=$G77 + _LT_TAGVAR(LD, $1)=$LD ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change @@ -7294,9 +7800,9 @@ if test "$_lt_disable_F77" != yes; then fi # test -n "$compiler" GCC=$lt_save_GCC - CC="$lt_save_CC" - CFLAGS="$lt_save_CFLAGS" -fi # test "$_lt_disable_F77" != yes + CC=$lt_save_CC + CFLAGS=$lt_save_CFLAGS +fi # test yes != "$_lt_disable_F77" AC_LANG_POP ])# _LT_LANG_F77_CONFIG @@ -7306,11 +7812,11 @@ AC_LANG_POP # ------------------------- # Ensure that the configuration variables for a Fortran compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. +# to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_FC_CONFIG], [AC_LANG_PUSH(Fortran) -if test -z "$FC" || test "X$FC" = "Xno"; then +if test -z "$FC" || test no = "$FC"; then _lt_disable_FC=yes fi @@ -7347,7 +7853,7 @@ _LT_TAGVAR(objext, $1)=$objext # the FC compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_disable_FC" != yes; then +if test yes != "$_lt_disable_FC"; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t @@ -7369,7 +7875,7 @@ if test "$_lt_disable_FC" != yes; then _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. - lt_save_CC="$CC" + lt_save_CC=$CC lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${FC-"f95"} @@ -7385,21 +7891,25 @@ if test "$_lt_disable_FC" != yes; then AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) - test "$can_build_shared" = "no" && enable_shared=no + test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) - test "$enable_shared" = yes && enable_static=no + test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no + if test ia64 != "$host_cpu"; then + case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in + yes,aix,yes) ;; # shared object as lib.so file only + yes,svr4,*) ;; # shared object as lib.so archive member only + yes,*) enable_static=no ;; # shared object in lib.a archive as well + esac fi ;; esac @@ -7407,11 +7917,11 @@ if test "$_lt_disable_FC" != yes; then AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes + test yes = "$enable_shared" || enable_static=yes AC_MSG_RESULT([$enable_static]) - _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" - _LT_TAGVAR(LD, $1)="$LD" + _LT_TAGVAR(GCC, $1)=$ac_cv_fc_compiler_gnu + _LT_TAGVAR(LD, $1)=$LD ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change @@ -7431,7 +7941,7 @@ if test "$_lt_disable_FC" != yes; then GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS -fi # test "$_lt_disable_FC" != yes +fi # test yes != "$_lt_disable_FC" AC_LANG_POP ])# _LT_LANG_FC_CONFIG @@ -7441,7 +7951,7 @@ AC_LANG_POP # -------------------------- # Ensure that the configuration variables for the GNU Java Compiler compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. +# to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_GCJ_CONFIG], [AC_REQUIRE([LT_PROG_GCJ])dnl AC_LANG_SAVE @@ -7475,7 +7985,7 @@ CC=${GCJ-"gcj"} CFLAGS=$GCJFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC -_LT_TAGVAR(LD, $1)="$LD" +_LT_TAGVAR(LD, $1)=$LD _LT_CC_BASENAME([$compiler]) # GCJ did not exist at the time GCC didn't implicitly link libc in. @@ -7512,7 +8022,7 @@ CFLAGS=$lt_save_CFLAGS # -------------------------- # Ensure that the configuration variables for the GNU Go compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. +# to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_GO_CONFIG], [AC_REQUIRE([LT_PROG_GO])dnl AC_LANG_SAVE @@ -7546,7 +8056,7 @@ CC=${GOC-"gccgo"} CFLAGS=$GOFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC -_LT_TAGVAR(LD, $1)="$LD" +_LT_TAGVAR(LD, $1)=$LD _LT_CC_BASENAME([$compiler]) # Go did not exist at the time GCC didn't implicitly link libc in. @@ -7583,7 +8093,7 @@ CFLAGS=$lt_save_CFLAGS # ------------------------- # Ensure that the configuration variables for the Windows resource compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. +# to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_RC_CONFIG], [AC_REQUIRE([LT_PROG_RC])dnl AC_LANG_SAVE @@ -7599,7 +8109,7 @@ _LT_TAGVAR(objext, $1)=$objext lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' # Code to be used in simple link tests -lt_simple_link_test_code="$lt_simple_compile_test_code" +lt_simple_link_test_code=$lt_simple_compile_test_code # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER @@ -7609,7 +8119,7 @@ _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. -lt_save_CC="$CC" +lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= @@ -7638,7 +8148,7 @@ AC_DEFUN([LT_PROG_GCJ], [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj,) - test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" + test set = "${GCJFLAGS+set}" || GCJFLAGS="-g -O2" AC_SUBST(GCJFLAGS)])])[]dnl ]) @@ -7749,7 +8259,7 @@ lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do - test ! -f $lt_ac_sed && continue + test ! -f "$lt_ac_sed" && continue cat /dev/null > conftest.in lt_ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >conftest.in @@ -7766,9 +8276,9 @@ for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break cmp -s conftest.out conftest.nl || break # 10000 chars as input seems more than enough - test $lt_ac_count -gt 10 && break + test 10 -lt "$lt_ac_count" && break lt_ac_count=`expr $lt_ac_count + 1` - if test $lt_ac_count -gt $lt_ac_max; then + if test "$lt_ac_count" -gt "$lt_ac_max"; then lt_ac_max=$lt_ac_count lt_cv_path_SED=$lt_ac_sed fi @@ -7792,27 +8302,7 @@ dnl AC_DEFUN([LT_AC_PROG_SED], []) # Find out whether the shell is Bourne or XSI compatible, # or has some other useful features. m4_defun([_LT_CHECK_SHELL_FEATURES], -[AC_MSG_CHECKING([whether the shell understands some XSI constructs]) -# Try some XSI features -xsi_shell=no -( _lt_dummy="a/b/c" - test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ - = c,a/b,b/c, \ - && eval 'test $(( 1 + 1 )) -eq 2 \ - && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ - && xsi_shell=yes -AC_MSG_RESULT([$xsi_shell]) -_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) - -AC_MSG_CHECKING([whether the shell understands "+="]) -lt_shell_append=no -( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ - >/dev/null 2>&1 \ - && lt_shell_append=yes -AC_MSG_RESULT([$lt_shell_append]) -_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) - -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then +[if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false @@ -7836,102 +8326,9 @@ _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl ])# _LT_CHECK_SHELL_FEATURES -# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) -# ------------------------------------------------------ -# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and -# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. -m4_defun([_LT_PROG_FUNCTION_REPLACE], -[dnl { -sed -e '/^$1 ()$/,/^} # $1 /c\ -$1 ()\ -{\ -m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) -} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: -]) - - -# _LT_PROG_REPLACE_SHELLFNS -# ------------------------- -# Replace existing portable implementations of several shell functions with -# equivalent extended shell implementations where those features are available.. -m4_defun([_LT_PROG_REPLACE_SHELLFNS], -[if test x"$xsi_shell" = xyes; then - _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac]) - - _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl - func_basename_result="${1##*/}"]) - - _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac - func_basename_result="${1##*/}"]) - - _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl - # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are - # positional parameters, so assign one to ordinary parameter first. - func_stripname_result=${3} - func_stripname_result=${func_stripname_result#"${1}"} - func_stripname_result=${func_stripname_result%"${2}"}]) - - _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl - func_split_long_opt_name=${1%%=*} - func_split_long_opt_arg=${1#*=}]) - - _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl - func_split_short_opt_arg=${1#??} - func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) - - _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl - case ${1} in - *.lo) func_lo2o_result=${1%.lo}.${objext} ;; - *) func_lo2o_result=${1} ;; - esac]) - - _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) - - _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) - - _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) -fi - -if test x"$lt_shell_append" = xyes; then - _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) - - _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl - func_quote_for_eval "${2}" -dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ - eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) - - # Save a `func_append' function call where possible by direct use of '+=' - sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") - test 0 -eq $? || _lt_function_replace_fail=: -else - # Save a `func_append' function call even when '+=' is not available - sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") - test 0 -eq $? || _lt_function_replace_fail=: -fi - -if test x"$_lt_function_replace_fail" = x":"; then - AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) -fi -]) - # _LT_PATH_CONVERSION_FUNCTIONS # ----------------------------- -# Determine which file name conversion functions should be used by +# Determine what file name conversion functions should be used by # func_to_host_file (and, implicitly, by func_to_host_path). These are needed # for certain cross-compile configurations and native mingw. m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], diff --git a/m4/ltoptions.m4 b/m4/ltoptions.m4 index 5d9acd8..94b0829 100644 --- a/m4/ltoptions.m4 +++ b/m4/ltoptions.m4 @@ -1,14 +1,14 @@ # Helper functions for option handling. -*- Autoconf -*- # -# Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software +# Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. -# serial 7 ltoptions.m4 +# serial 8 ltoptions.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) @@ -29,7 +29,7 @@ m4_define([_LT_SET_OPTION], [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), _LT_MANGLE_DEFUN([$1], [$2]), - [m4_warning([Unknown $1 option `$2'])])[]dnl + [m4_warning([Unknown $1 option '$2'])])[]dnl ]) @@ -75,13 +75,15 @@ m4_if([$1],[LT_INIT],[ dnl dnl If no reference was made to various pairs of opposing options, then dnl we run the default mode handler for the pair. For example, if neither - dnl `shared' nor `disable-shared' was passed, we enable building of shared + dnl 'shared' nor 'disable-shared' was passed, we enable building of shared dnl archives by default: _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], - [_LT_ENABLE_FAST_INSTALL]) + [_LT_ENABLE_FAST_INSTALL]) + _LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4], + [_LT_WITH_AIX_SONAME([aix])]) ]) ])# _LT_SET_OPTIONS @@ -112,7 +114,7 @@ AU_DEFUN([AC_LIBTOOL_DLOPEN], [_LT_SET_OPTION([LT_INIT], [dlopen]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you -put the `dlopen' option into LT_INIT's first parameter.]) +put the 'dlopen' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: @@ -148,7 +150,7 @@ AU_DEFUN([AC_LIBTOOL_WIN32_DLL], _LT_SET_OPTION([LT_INIT], [win32-dll]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you -put the `win32-dll' option into LT_INIT's first parameter.]) +put the 'win32-dll' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: @@ -157,9 +159,9 @@ dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) # _LT_ENABLE_SHARED([DEFAULT]) # ---------------------------- -# implement the --enable-shared flag, and supports the `shared' and -# `disable-shared' LT_INIT options. -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +# implement the --enable-shared flag, and supports the 'shared' and +# 'disable-shared' LT_INIT options. +# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. m4_define([_LT_ENABLE_SHARED], [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([shared], @@ -172,14 +174,14 @@ AC_ARG_ENABLE([shared], *) enable_shared=no # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_shared=yes fi done - IFS="$lt_save_ifs" + IFS=$lt_save_ifs ;; esac], [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) @@ -211,9 +213,9 @@ dnl AC_DEFUN([AM_DISABLE_SHARED], []) # _LT_ENABLE_STATIC([DEFAULT]) # ---------------------------- -# implement the --enable-static flag, and support the `static' and -# `disable-static' LT_INIT options. -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +# implement the --enable-static flag, and support the 'static' and +# 'disable-static' LT_INIT options. +# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. m4_define([_LT_ENABLE_STATIC], [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([static], @@ -226,14 +228,14 @@ AC_ARG_ENABLE([static], *) enable_static=no # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_static=yes fi done - IFS="$lt_save_ifs" + IFS=$lt_save_ifs ;; esac], [enable_static=]_LT_ENABLE_STATIC_DEFAULT) @@ -265,9 +267,9 @@ dnl AC_DEFUN([AM_DISABLE_STATIC], []) # _LT_ENABLE_FAST_INSTALL([DEFAULT]) # ---------------------------------- -# implement the --enable-fast-install flag, and support the `fast-install' -# and `disable-fast-install' LT_INIT options. -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +# implement the --enable-fast-install flag, and support the 'fast-install' +# and 'disable-fast-install' LT_INIT options. +# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. m4_define([_LT_ENABLE_FAST_INSTALL], [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([fast-install], @@ -280,14 +282,14 @@ AC_ARG_ENABLE([fast-install], *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done - IFS="$lt_save_ifs" + IFS=$lt_save_ifs ;; esac], [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) @@ -304,14 +306,14 @@ AU_DEFUN([AC_ENABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put -the `fast-install' option into LT_INIT's first parameter.]) +the 'fast-install' option into LT_INIT's first parameter.]) ]) AU_DEFUN([AC_DISABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put -the `disable-fast-install' option into LT_INIT's first parameter.]) +the 'disable-fast-install' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: @@ -319,11 +321,64 @@ dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) +# _LT_WITH_AIX_SONAME([DEFAULT]) +# ---------------------------------- +# implement the --with-aix-soname flag, and support the `aix-soname=aix' +# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT +# is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'. +m4_define([_LT_WITH_AIX_SONAME], +[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl +shared_archive_member_spec= +case $host,$enable_shared in +power*-*-aix[[5-9]]*,yes) + AC_MSG_CHECKING([which variant of shared library versioning to provide]) + AC_ARG_WITH([aix-soname], + [AS_HELP_STRING([--with-aix-soname=aix|svr4|both], + [shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])], + [case $withval in + aix|svr4|both) + ;; + *) + AC_MSG_ERROR([Unknown argument to --with-aix-soname]) + ;; + esac + lt_cv_with_aix_soname=$with_aix_soname], + [AC_CACHE_VAL([lt_cv_with_aix_soname], + [lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT) + with_aix_soname=$lt_cv_with_aix_soname]) + AC_MSG_RESULT([$with_aix_soname]) + if test aix != "$with_aix_soname"; then + # For the AIX way of multilib, we name the shared archive member + # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', + # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. + # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, + # the AIX toolchain works better with OBJECT_MODE set (default 32). + if test 64 = "${OBJECT_MODE-32}"; then + shared_archive_member_spec=shr_64 + else + shared_archive_member_spec=shr + fi + fi + ;; +*) + with_aix_soname=aix + ;; +esac + +_LT_DECL([], [shared_archive_member_spec], [0], + [Shared archive member basename, for filename based shared library versioning on AIX])dnl +])# _LT_WITH_AIX_SONAME + +LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])]) +LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])]) +LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])]) + + # _LT_WITH_PIC([MODE]) # -------------------- -# implement the --with-pic flag, and support the `pic-only' and `no-pic' +# implement the --with-pic flag, and support the 'pic-only' and 'no-pic' # LT_INIT options. -# MODE is either `yes' or `no'. If omitted, it defaults to `both'. +# MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], @@ -334,19 +389,17 @@ m4_define([_LT_WITH_PIC], *) pic_mode=default # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for lt_pkg in $withval; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done - IFS="$lt_save_ifs" + IFS=$lt_save_ifs ;; esac], - [pic_mode=default]) - -test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) + [pic_mode=m4_default([$1], [default])]) _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl ])# _LT_WITH_PIC @@ -359,7 +412,7 @@ AU_DEFUN([AC_LIBTOOL_PICMODE], [_LT_SET_OPTION([LT_INIT], [pic-only]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you -put the `pic-only' option into LT_INIT's first parameter.]) +put the 'pic-only' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: diff --git a/m4/ltsugar.m4 b/m4/ltsugar.m4 index 9000a05..48bc934 100644 --- a/m4/ltsugar.m4 +++ b/m4/ltsugar.m4 @@ -1,6 +1,7 @@ # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # -# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. +# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software +# Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives @@ -33,7 +34,7 @@ m4_define([_lt_join], # ------------ # Manipulate m4 lists. # These macros are necessary as long as will still need to support -# Autoconf-2.59 which quotes differently. +# Autoconf-2.59, which quotes differently. m4_define([lt_car], [[$1]]) m4_define([lt_cdr], [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], @@ -44,7 +45,7 @@ m4_define([lt_unquote], $1) # lt_append(MACRO-NAME, STRING, [SEPARATOR]) # ------------------------------------------ -# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. +# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'. # Note that neither SEPARATOR nor STRING are expanded; they are appended # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). # No SEPARATOR is output if MACRO-NAME was previously undefined (different diff --git a/m4/ltversion.m4 b/m4/ltversion.m4 index 07a8602..fa04b52 100644 --- a/m4/ltversion.m4 +++ b/m4/ltversion.m4 @@ -1,6 +1,6 @@ # ltversion.m4 -- version numbers -*- Autoconf -*- # -# Copyright (C) 2004 Free Software Foundation, Inc. +# Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004 # # This file is free software; the Free Software Foundation gives @@ -9,15 +9,15 @@ # @configure_input@ -# serial 3337 ltversion.m4 +# serial 4179 ltversion.m4 # This file is part of GNU Libtool -m4_define([LT_PACKAGE_VERSION], [2.4.2]) -m4_define([LT_PACKAGE_REVISION], [1.3337]) +m4_define([LT_PACKAGE_VERSION], [2.4.6]) +m4_define([LT_PACKAGE_REVISION], [2.4.6]) AC_DEFUN([LTVERSION_VERSION], -[macro_version='2.4.2' -macro_revision='1.3337' +[macro_version='2.4.6' +macro_revision='2.4.6' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) diff --git a/m4/lt~obsolete.m4 b/m4/lt~obsolete.m4 index c573da9..c6b26f8 100644 --- a/m4/lt~obsolete.m4 +++ b/m4/lt~obsolete.m4 @@ -1,6 +1,7 @@ # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # -# Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. +# Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software +# Foundation, Inc. # Written by Scott James Remnant, 2004. # # This file is free software; the Free Software Foundation gives @@ -11,7 +12,7 @@ # These exist entirely to fool aclocal when bootstrapping libtool. # -# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) +# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN), # which have later been changed to m4_define as they aren't part of the # exported API, or moved to Autoconf or Automake where they belong. # @@ -25,7 +26,7 @@ # included after everything else. This provides aclocal with the # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything # because those macros already exist, or will be overwritten later. -# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. +# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. # # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. # Yes, that means every name once taken will need to remain here until diff --git a/m4/nut_arg_with.m4 b/m4/nut_arg_with.m4 index 9d1c36b..686306b 100644 --- a/m4/nut_arg_with.m4 +++ b/m4/nut_arg_with.m4 @@ -1,9 +1,21 @@ dnl simplified declaration of some feature options +dnl Working With External Software (might name a variant or other contextual arg) +dnl https://www.gnu.org/software/autoconf/manual/autoconf-2.66/html_node/External-Software.html#External-Software AC_DEFUN([NUT_ARG_WITH], [ AC_ARG_WITH($1, - AC_HELP_STRING([--with-$1], [$2 ($3)]), + AS_HELP_STRING([--with-$1], [$2 ($3)]), [nut_with_$1="${withval}"], [nut_with_$1="$3"] ) ]) + +dnl Enable a feature (might name a variant), or yes/no +dnl https://www.gnu.org/software/autoconf/manual/autoconf-2.66/html_node/Package-Options.html +AC_DEFUN([NUT_ARG_ENABLE], +[ AC_ARG_ENABLE($1, + AS_HELP_STRING([--enable-$1], [$2 ($3)]), + [nut_enable_$1="${enableval}"], + [nut_enable_$1="$3"] + ) +]) diff --git a/m4/nut_check_asciidoc.m4 b/m4/nut_check_asciidoc.m4 index c629eab..b83381e 100644 --- a/m4/nut_check_asciidoc.m4 +++ b/m4/nut_check_asciidoc.m4 @@ -1,12 +1,24 @@ -dnl Check for LIBUSB compiler flags. On success, set nut_have_libusb="yes" -dnl and set LIBUSB_CFLAGS and LIBUSB_LDFLAGS. On failure, set -dnl nut_have_libusb="no". This macro can be run multiple times, but will -dnl do the checking only once. +dnl Check for tools used in generation of documentation final-format files +dnl such as the basically required MAN, and optional HTML (single or chunked). +dnl On success, set nut_have_asciidoc="yes" (meaning we can do at least some +dnl documentation generation) and lots of automake macros and configure vars. +dnl On failure, set nut_have_asciidoc="no" (meaning we can't generate even a +dnl manpage, which is a requirement for proceeding to the other formats). +dnl This macro can be run multiple times, but will do the checking only once. +dnl Also note that this routine currently only checks the basic presence (and +dnl versions) of the required software; the configure script has additional +dnl functional checks (ability to build doc files) based on --with-doc request +dnl so as to not waste time on doc-types not requested by maintainer, and done +dnl in ways more intimate to NUT (using its tracked docs). -AC_DEFUN([NUT_CHECK_ASCIIDOC], +AC_DEFUN([NUT_CHECK_ASCIIDOC], [ if test -z "${nut_have_asciidoc_seen}"; then nut_have_asciidoc_seen=yes + # Note: this is for both asciidoc and a2x at this time + ASCIIDOC_MIN_VERSION="8.6.3" + # Note: this is checked in the configure script if PDF is of interest at all + DBLATEX_MIN_VERSION="0.2.5" AC_PATH_PROGS([ASCIIDOC], [asciidoc]) if test -n "${ASCIIDOC}"; then @@ -16,6 +28,7 @@ if test -z "${nut_have_asciidoc_seen}"; then ASCIIDOC_VERSION="${ASCIIDOC_VERSION##* }" AC_MSG_RESULT(${ASCIIDOC_VERSION} found) fi + AM_CONDITIONAL([MANUALUPDATE], [test -n "${ASCIIDOC}"]) AC_PATH_PROGS([A2X], [a2x]) if test -n "${A2X}"; then @@ -50,10 +63,74 @@ if test -z "${nut_have_asciidoc_seen}"; then XMLLINT_VERSION="`${XMLLINT} --version 2>/dev/null`" dnl strip 'xmllint version ' from version string XMLLINT_VERSION="${XMLLINT_VERSION##* }" + if test -z "${XMLLINT_VERSION}" ; then + dnl Some releases also report what flags they were compiled with as + dnl part of the version info, so the last-line match finds nothing. + dnl Also some builds return version data to stderr. + XMLLINT_VERSION="`${XMLLINT} --version 2>&1 | grep version`" + XMLLINT_VERSION="${XMLLINT_VERSION##* }" + fi AC_MSG_RESULT(${XMLLINT_VERSION} found) fi AC_PATH_PROGS([SOURCE_HIGHLIGHT], [source-highlight]) + AM_CONDITIONAL([HAVE_SOURCE_HIGHLIGHT], [test -n "$SOURCE_HIGHLIGHT"]) + + dnl check for spell checking deps + AC_PATH_PROGS([ASPELL], [aspell]) + AM_CONDITIONAL([HAVE_ASPELL], [test -n "$ASPELL"]) + + dnl Note that a common "nut_have_asciidoc" variable is in fact a flag + dnl that we have several tools needed for the documentation generation + dnl TODO? Rename the script variable and makefile flags to reflect this? + AC_MSG_CHECKING([if asciidoc version can build manpages (minimum required ${ASCIIDOC_MIN_VERSION})]) + AX_COMPARE_VERSION([${ASCIIDOC_VERSION}], [ge], [${ASCIIDOC_MIN_VERSION}], [ + AC_MSG_RESULT(yes) + nut_have_asciidoc="yes" + ], [ + AC_MSG_RESULT(no) + nut_have_asciidoc="no" + ]) + + AC_MSG_CHECKING([if a2x version can build manpages (minimum required ${ASCIIDOC_MIN_VERSION})]) + AX_COMPARE_VERSION([${A2X_VERSION}], [ge], [${ASCIIDOC_MIN_VERSION}], [ + AC_MSG_RESULT(yes) + ], [ + AC_MSG_RESULT(no) + nut_have_asciidoc="no" + ]) + + dnl TODO: test for docbook-xsl files (maybe build a test man page?) + dnl https://github.com/networkupstools/nut/issues/162 + AC_MSG_CHECKING([if xsltproc is present (mandatory for man page regeneration)]) + if test -n "${XSLTPROC}"; then + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + nut_have_asciidoc="no" + fi + + AC_MSG_CHECKING([if xmllint is present (mandatory for man page regeneration)]) + if test -n "${XMLLINT}"; then + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + nut_have_asciidoc="no" + fi + + dnl Notes: we also keep HAVE_ASCIIDOC for implicit targets, such as manpage + dnl building + AM_CONDITIONAL([HAVE_ASCIIDOC], [test "${nut_have_asciidoc}" = "yes"]) + + AC_MSG_CHECKING([if we have all the tools mandatory for man page regeneration]) + AC_MSG_RESULT([${nut_have_asciidoc}]) + + AC_MSG_CHECKING([if source-highlight is present (preferable for documentation generation)]) + if test -n "${SOURCE_HIGHLIGHT}"; then + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi fi ]) diff --git a/m4/nut_check_cppcheck.m4 b/m4/nut_check_cppcheck.m4 new file mode 100644 index 0000000..5a85758 --- /dev/null +++ b/m4/nut_check_cppcheck.m4 @@ -0,0 +1,34 @@ +dnl Check for "cppcheck" analysis tools + +AC_DEFUN([NUT_CHECK_CPPCHECK], +[ +if test -z "${nut_have_cppcheck_seen}"; then + dnl NOTE: Did not really investigate suitable CPPCHECK_MIN_VERSION + dnl values, just using current available as the baseline; maybe + dnl older releases are also okay (if someone proves so). + dnl The oldest available on the NUT CI build farm was 1.6 that worked. + nut_have_cppcheck_seen=yes + CPPCHECK_MIN_VERSION="1.0" + + AC_PATH_PROGS([CPPCHECK], [cppcheck]) + if test -n "${CPPCHECK}"; then + AC_MSG_CHECKING([for cppcheck version]) + CPPCHECK_VERSION="`${CPPCHECK} --version 2>/dev/null`" + dnl strip 'cppcheck ' from version string + CPPCHECK_VERSION="${CPPCHECK_VERSION##* }" + AC_MSG_RESULT(${CPPCHECK_VERSION} found) + fi + + AC_MSG_CHECKING([if cppcheck version is okay (minimum required ${CPPCHECK_MIN_VERSION})]) + AX_COMPARE_VERSION([${CPPCHECK_VERSION}], [ge], [${CPPCHECK_MIN_VERSION}], [ + AC_MSG_RESULT(yes) + nut_have_cppcheck="yes" + ], [ + AC_MSG_RESULT(no) + nut_have_cppcheck="no" + ]) + + dnl Notes: we also keep HAVE_CPPCHECK for implicit targets + AM_CONDITIONAL([HAVE_CPPCHECK], [test "${nut_have_cppcheck}" = "yes"]) +fi +]) diff --git a/m4/nut_check_headers_windows.m4 b/m4/nut_check_headers_windows.m4 new file mode 100644 index 0000000..6f30c92 --- /dev/null +++ b/m4/nut_check_headers_windows.m4 @@ -0,0 +1,193 @@ +dnl This code was lifted and adapted for NUT from cURL project: +dnl https://github.com/curl/curl/blob/83245d9ff352b742753cff1216781ff041e4e987/acinclude.m4#L172 +dnl https://github.com/curl/curl/blob/83245d9ff352b742753cff1216781ff041e4e987/acinclude.m4#L207 +dnl https://github.com/curl/curl/blob/83245d9ff352b742753cff1216781ff041e4e987/acinclude.m4#L238 +dnl https://github.com/curl/curl/blob/83245d9ff352b742753cff1216781ff041e4e987/acinclude.m4#L275 +dnl https://github.com/curl/curl/blob/83245d9ff352b742753cff1216781ff041e4e987/acinclude.m4#L312 + +dnl NUT_CHECK_HEADER_WINDOWS +dnl ------------------------------------------------- +dnl Check for compilable and valid windows.h header + +AC_DEFUN([NUT_CHECK_HEADER_WINDOWS], [ + AC_CACHE_CHECK([for windows.h], [nut_cv_header_windows_h], [ + AC_LANG_PUSH([C]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ +#undef inline +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include + ]],[[ +#if defined(__CYGWIN__) || defined(__CEGCC__) + HAVE_WINDOWS_H shall not be defined. +#else + int dummy=2*WINVER; +#endif + ]]) + ],[ + nut_cv_header_windows_h="yes" + ],[ + nut_cv_header_windows_h="no" + ]) + AC_LANG_POP([C]) + ]) + case "$nut_cv_header_windows_h" in + yes) + AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1, + [Define to 1 if you have the windows.h header file.]) + ;; + esac +]) + + +dnl NUT_CHECK_NATIVE_WINDOWS +dnl ------------------------------------------------- +dnl Check if building a native Windows target + +AC_DEFUN([NUT_CHECK_NATIVE_WINDOWS], [ + AC_REQUIRE([NUT_CHECK_HEADER_WINDOWS])dnl + AC_CACHE_CHECK([whether build target is a native Windows one], [nut_cv_native_windows], [ + if test "$nut_cv_header_windows_h" = "no"; then + nut_cv_native_windows="no" + else + AC_LANG_PUSH([C]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + ]],[[ +#if defined(__MINGW32__) || defined(__MINGW32CE__) || \ + (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))) + int dummy=1; +#else + Not a native Windows build target. +#endif + ]]) + ],[ + nut_cv_native_windows="yes" + ],[ + nut_cv_native_windows="no" + ]) + AC_LANG_POP([C]) + fi + ]) + AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$nut_cv_native_windows" = xyes) +]) + + +dnl NUT_CHECK_HEADER_WINSOCK +dnl ------------------------------------------------- +dnl Check for compilable and valid winsock.h header + +AC_DEFUN([NUT_CHECK_HEADER_WINSOCK], [ + AC_REQUIRE([NUT_CHECK_HEADER_WINDOWS])dnl + AC_CACHE_CHECK([for winsock.h], [nut_cv_header_winsock_h], [ + AC_LANG_PUSH([C]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ +#undef inline +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#include + ]],[[ +#if defined(__CYGWIN__) || defined(__CEGCC__) + HAVE_WINSOCK_H shall not be defined. +#else + int dummy=WSACleanup(); +#endif + ]]) + ],[ + nut_cv_header_winsock_h="yes" + ],[ + nut_cv_header_winsock_h="no" + ]) + AC_LANG_POP([C]) + ]) + case "$nut_cv_header_winsock_h" in + yes) + AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1, + [Define to 1 if you have the winsock.h header file.]) + ;; + esac +]) + + +dnl NUT_CHECK_HEADER_WINSOCK2 +dnl ------------------------------------------------- +dnl Check for compilable and valid winsock2.h header + +AC_DEFUN([NUT_CHECK_HEADER_WINSOCK2], [ + AC_REQUIRE([NUT_CHECK_HEADER_WINDOWS])dnl + AC_CACHE_CHECK([for winsock2.h], [nut_cv_header_winsock2_h], [ + AC_LANG_PUSH([C]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ +#undef inline +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#include + ]],[[ +#if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__) + HAVE_WINSOCK2_H shall not be defined. +#else + int dummy=2*IPPROTO_ESP; +#endif + ]]) + ],[ + nut_cv_header_winsock2_h="yes" + ],[ + nut_cv_header_winsock2_h="no" + ]) + AC_LANG_POP([C]) + ]) + case "$nut_cv_header_winsock2_h" in + yes) + AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1, + [Define to 1 if you have the winsock2.h header file.]) + ;; + esac +]) + + +dnl NUT_CHECK_HEADER_WS2TCPIP +dnl ------------------------------------------------- +dnl Check for compilable and valid ws2tcpip.h header + +AC_DEFUN([NUT_CHECK_HEADER_WS2TCPIP], [ + AC_REQUIRE([NUT_CHECK_HEADER_WINSOCK2])dnl + AC_CACHE_CHECK([for ws2tcpip.h], [nut_cv_header_ws2tcpip_h], [ + AC_LANG_PUSH([C]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ +#undef inline +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#include +#include + ]],[[ +#if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__) + HAVE_WS2TCPIP_H shall not be defined. +#else + int dummy=2*IP_PKTINFO; +#endif + ]]) + ],[ + nut_cv_header_ws2tcpip_h="yes" + ],[ + nut_cv_header_ws2tcpip_h="no" + ]) + AC_LANG_POP([C]) + ]) + case "$nut_cv_header_ws2tcpip_h" in + yes) + AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1, + [Define to 1 if you have the ws2tcpip.h header file.]) + ;; + esac +]) diff --git a/m4/nut_check_libavahi.m4 b/m4/nut_check_libavahi.m4 index 034d31a..d0c4989 100644 --- a/m4/nut_check_libavahi.m4 +++ b/m4/nut_check_libavahi.m4 @@ -1,4 +1,4 @@ -dnl Check for LIBAVAHI compiler flags. On success, set nut_have_neon="yes" +dnl Check for LIBAVAHI compiler flags. On success, set nut_have_avahi="yes" dnl and set LIBAVAHI_CFLAGS and LIBAVAHI_LIBS. On failure, set dnl nut_have_avahi="no". This macro can be run multiple times, but will dnl do the checking only once. @@ -7,25 +7,29 @@ AC_DEFUN([NUT_CHECK_LIBAVAHI], [ if test -z "${nut_have_avahi_seen}"; then nut_have_avahi_seen=yes + NUT_CHECK_PKGCONFIG dnl save CFLAGS and LIBS CFLAGS_ORIG="${CFLAGS}" LIBS_ORIG="${LIBS}" - dnl See which version of the avahi library (if any) is installed - AC_MSG_CHECKING(for avahi-core version via pkg-config (0.6.30 minimum required)) - AVAHI_CORE_VERSION="`pkg-config --silence-errors --modversion avahi-core 2>/dev/null`" - if test "$?" != "0" -o -z "${AVAHI_CORE_VERSION}"; then - AVAHI_CORE_VERSION="none" - fi - AC_MSG_RESULT(${AVAHI_CORE_VERSION} found) + AS_IF([test x"$have_PKG_CONFIG" = xyes], + [dnl See which version of the avahi library (if any) is installed + AC_MSG_CHECKING(for avahi-core version via pkg-config (0.6.30 minimum required)) + AVAHI_CORE_VERSION="`$PKG_CONFIG --silence-errors --modversion avahi-core 2>/dev/null`" + if test "$?" != "0" -o -z "${AVAHI_CORE_VERSION}"; then + AVAHI_CORE_VERSION="none" + fi + AC_MSG_RESULT(${AVAHI_CORE_VERSION} found) - AC_MSG_CHECKING(for avahi-client version via pkg-config (0.6.30 minimum required)) - AVAHI_CLIENT_VERSION="`pkg-config --silence-errors --modversion avahi-client 2>/dev/null`" - if test "$?" != "0" -o -z "${AVAHI_CLIENT_VERSION}"; then - AVAHI_CLIENT_VERSION="none" - fi - AC_MSG_RESULT(${AVAHI_CLIENT_VERSION} found) + AC_MSG_CHECKING(for avahi-client version via pkg-config (0.6.30 minimum required)) + AVAHI_CLIENT_VERSION="`$PKG_CONFIG --silence-errors --modversion avahi-client 2>/dev/null`" + if test "$?" != "0" -o -z "${AVAHI_CLIENT_VERSION}"; then + AVAHI_CLIENT_VERSION="none" + fi + AC_MSG_RESULT(${AVAHI_CLIENT_VERSION} found) + ], [AC_MSG_NOTICE([can not check avahi settings via pkg-config])] + ) AC_MSG_CHECKING(for avahi cflags) AC_ARG_WITH(avahi-includes, @@ -39,7 +43,12 @@ if test -z "${nut_have_avahi_seen}"; then CFLAGS="${withval}" ;; esac - ], [CFLAGS="`pkg-config --silence-errors --cflags avahi-core avahi-client 2>/dev/null`"]) + ], [ + AS_IF([test x"$have_PKG_CONFIG" = xyes], + [CFLAGS="`$PKG_CONFIG --silence-errors --cflags avahi-core avahi-client 2>/dev/null`" || CFLAGS="-I/usr/local/include -I/usr/include -L/usr/local/lib -L/usr/lib"], + [CFLAGS="-I/usr/local/include -I/usr/include -L/usr/local/lib -L/usr/lib"] + )] + ) AC_MSG_RESULT([${CFLAGS}]) AC_MSG_CHECKING(for avahi ldflags) @@ -54,7 +63,12 @@ if test -z "${nut_have_avahi_seen}"; then LIBS="${withval}" ;; esac - ], [LIBS="`pkg-config --silence-errors --libs avahi-core avahi-client 2>/dev/null`"]) + ], [ + AS_IF([test x"$have_PKG_CONFIG" = xyes], + [LIBS="`$PKG_CONFIG --silence-errors --libs avahi-core avahi-client 2>/dev/null`" || LIBS="-lavahi-core -lavahi-client"], + [LIBS="-lavahi-core -lavahi-client"] + )] + ) AC_MSG_RESULT([${LIBS}]) dnl check if avahi-core is usable diff --git a/m4/nut_check_libfreeipmi.m4 b/m4/nut_check_libfreeipmi.m4 index 5b2eae9..5fad0c6 100644 --- a/m4/nut_check_libfreeipmi.m4 +++ b/m4/nut_check_libfreeipmi.m4 @@ -8,25 +8,36 @@ AC_DEFUN([NUT_CHECK_LIBFREEIPMI], [ if test -z "${nut_have_libfreeipmi_seen}"; then nut_have_libfreeipmi_seen=yes + NUT_CHECK_PKGCONFIG dnl save CFLAGS and LIBS CFLAGS_ORIG="${CFLAGS}" LIBS_ORIG="${LIBS}" - AC_MSG_CHECKING(for FreeIPMI version via pkg-config) - dnl pkg-config support requires Freeipmi 1.0.5, released on Thu Jun 30 2011 - dnl but NUT should only require 0.8.5 (for nut-scanner) and 1.0.1 (for - dnl nut-ipmipsu) (comment from upstream Al Chu) - FREEIPMI_VERSION="`pkg-config --silence-errors --modversion libfreeipmi 2>/dev/null`" - if test "$?" = "0" -a -n "${FREEIPMI_VERSION}"; then - CFLAGS="`pkg-config --silence-errors --cflags libfreeipmi libipmimonitoring 2>/dev/null`" - LIBS="`pkg-config --silence-errors --libs libfreeipmi libipmimonitoring 2>/dev/null`" - else - FREEIPMI_VERSION="none" - CFLAGS="" - LIBS="-lfreeipmi -lipmimonitoring" - fi - AC_MSG_RESULT(${FREEIPMI_VERSION} found) + AS_IF([test x"$have_PKG_CONFIG" = xyes], + [dnl pkg-config support requires Freeipmi 1.0.5, released on Thu Jun 30 2011 + dnl but NUT should only require 0.8.5 (for nut-scanner) and 1.0.1 (for + dnl nut-ipmipsu) (comment from upstream Al Chu) + AC_MSG_CHECKING(for FreeIPMI version via pkg-config) + FREEIPMI_VERSION="`$PKG_CONFIG --silence-errors --modversion libfreeipmi 2>/dev/null`" + if test "$?" != "0" -o -z "${FREEIPMI_VERSION}"; then + FREEIPMI_VERSION="none" + fi + AC_MSG_RESULT(${FREEIPMI_VERSION} found) + ], + [FREEIPMI_VERSION="none" + AC_MSG_NOTICE([can not check FreeIPMI settings via pkg-config]) + ] + ) + + AS_IF([test x"$FREEIPMI_VERSION" != xnone], + [CFLAGS="`$PKG_CONFIG --silence-errors --cflags libfreeipmi libipmimonitoring 2>/dev/null`" + LIBS="`$PKG_CONFIG --silence-errors --libs libfreeipmi libipmimonitoring 2>/dev/null`" + ], + [CFLAGS="" + LIBS="-lfreeipmi -lipmimonitoring" + ] + ) dnl allow overriding FreeIPMI settings if the user knows best AC_MSG_CHECKING(for FreeIPMI cflags) diff --git a/m4/nut_check_libgd.m4 b/m4/nut_check_libgd.m4 index 01cc882..b6f58ef 100644 --- a/m4/nut_check_libgd.m4 +++ b/m4/nut_check_libgd.m4 @@ -1,44 +1,87 @@ dnl Check for LIBGD compiler flags. On success, set nut_have_libgd="yes" dnl and set LIBGD_CFLAGS and LIBGD_LDFLAGS. On failure, set dnl nut_have_libgd="no". This macro can be run multiple times, but will -dnl do the checking only once. +dnl do the checking only once. -AC_DEFUN([NUT_CHECK_LIBGD], +AC_DEFUN([NUT_CHECK_LIBGD], [ if test -z "${nut_have_libgd_seen}"; then nut_have_libgd_seen=yes + NUT_CHECK_PKGCONFIG CFLAGS_ORIG="${CFLAGS}" LDFLAGS_ORIG="${LDFLAGS}" LIBS_ORIG="${LIBS}" - - dnl Initial defaults. These are only used if gdlib-config is - dnl unusable and the user fails to pass better values in --with - dnl arguments CFLAGS="" - LDFLAGS="-L/usr/X11R6/lib" - LIBS="-lgd -lpng -lz -ljpeg -lfreetype -lm -lXpm -lX11" + LDFLAGS="" + LIBS="" - AC_MSG_CHECKING(for gd version via gdlib-config) - GD_VERSION=`gdlib-config --version 2>/dev/null` - if test "$?" != "0" -o -z "${GD_VERSION}"; then - GD_VERSION="none" - fi - AC_MSG_RESULT(${GD_VERSION} found) + AS_IF([test x"$have_PKG_CONFIG" = xyes], + [AC_MSG_CHECKING(for gd version via pkg-config) + GD_VERSION="`$PKG_CONFIG --silence-errors --modversion gdlib 2>/dev/null`" + if test "$?" != "0" -o -z "${GD_VERSION}"; then + GD_VERSION="none" + fi + AC_MSG_RESULT(${GD_VERSION} found) + ], + [GD_VERSION="none" + AC_MSG_NOTICE([can not check libgd settings via pkg-config]) + ] + ) - case "${GD_VERSION}" in - none) - ;; - 2.0.5 | 2.0.6 | 2.0.7) - AC_MSG_WARN([[gd ${GD_VERSION} detected, unable to use gdlib-config script]]) - AC_MSG_WARN([[If gd detection fails, upgrade gd or use --with-gd-includes and --with-gd-libs]]) - ;; - *) - CFLAGS="`gdlib-config --includes 2>/dev/null`" - LDFLAGS="`gdlib-config --ldflags 2>/dev/null`" - LIBS="`gdlib-config --libs 2>/dev/null`" - ;; - esac + AS_IF([test x"$GD_VERSION" != xnone], + [CFLAGS="`$PKG_CONFIG --silence-errors --cflags gdlib 2>/dev/null`" + LIBS="`$PKG_CONFIG --silence-errors --libs gdlib 2>/dev/null`" + ], + [dnl Initial defaults. These are only used if gdlib-config is + dnl unusable and the user fails to pass better values in --with + dnl arguments + CFLAGS="" + LDFLAGS="-L/usr/X11R6/lib" + LIBS="-lgd -lpng -lz -ljpeg -lfreetype -lm -lXpm -lX11" + + dnl By default seek in PATH + AC_PATH_PROGS([GDLIB_CONFIG], [gdlib-config], [none]) + AC_ARG_WITH(gdlib-config, + AS_HELP_STRING([@<:@--with-gdlib-config=/path/to/gdlib-config@:>@], + [path to program that reports GDLIB configuration]), + [ + case "${withval}" in + "") ;; + yes|no) + AC_MSG_ERROR(invalid option --with(out)-gdlib-config - see docs/configure.txt) + ;; + *) + GDLIB_CONFIG="${withval}" + ;; + esac + ]) + + AS_IF([test x"$GDLIB_CONFIG" != xnone], + [AC_MSG_CHECKING(for gd version via ${GDLIB_CONFIG}) + GD_VERSION="`${GDLIB_CONFIG} --version 2>/dev/null`" + if test "$?" != "0" -o -z "${GD_VERSION}"; then + GD_VERSION="none" + fi + AC_MSG_RESULT(${GD_VERSION} found) + ], [GD_VERSION="none"] + ) + + case "${GD_VERSION}" in + none) + ;; + 2.0.5 | 2.0.6 | 2.0.7) + AC_MSG_WARN([[gd ${GD_VERSION} detected, unable to use ${GDLIB_CONFIG} script]]) + AC_MSG_WARN([[If gd detection fails, upgrade gd or use --with-gd-includes and --with-gd-libs]]) + ;; + *) + CFLAGS="`${GDLIB_CONFIG} --includes 2>/dev/null`" + LDFLAGS="`${GDLIB_CONFIG} --ldflags 2>/dev/null`" + LIBS="`${GDLIB_CONFIG} --libs 2>/dev/null`" + ;; + esac + ] + ) dnl Now allow overriding gd settings if the user knows best AC_MSG_CHECKING(for gd include flags) @@ -74,7 +117,21 @@ if test -z "${nut_have_libgd_seen}"; then dnl check if gd is usable AC_CHECK_HEADERS(gd.h gdfontmb.h, [nut_have_libgd=yes], [nut_have_libgd=no], [AC_INCLUDES_DEFAULT]) - AC_SEARCH_LIBS(gdImagePng, gd, [], [nut_have_libgd=no]) + AC_SEARCH_LIBS(gdImagePng, gd, [], [ + dnl If using pkg-config, query additionally for Libs.private + dnl to pull -L/usr/X11R6/lib or whatever current OS wants + AC_MSG_CHECKING([for more gd library flags]) + AS_IF([test -n "${with_gd_libs}" || test x"$have_PKG_CONFIG" != xyes], [nut_have_libgd=no], [ + _LIBS_PRIVATE="`$PKG_CONFIG --silence-errors --libs gdlib --static 2>/dev/null`" + AS_IF([test -z "${_LIBS_PRIVATE}"], [nut_have_libgd=no], [ + AC_MSG_CHECKING([with gdlib.pc Libs.private]) + LDFLAGS="$LDFLAGS $_LIBS_PRIVATE" + unset ac_cv_search_gdImagePng + AC_SEARCH_LIBS(gdImagePng, gd, [], [nut_have_libgd=no]) + ]) + unset _LIBS_PRIVATE + ]) + ]) if test "${nut_have_libgd}" = "yes"; then AC_DEFINE(HAVE_LIBGD, 1, [Define if you have Boutell's libgd installed]) diff --git a/m4/nut_check_libmodbus.m4 b/m4/nut_check_libmodbus.m4 new file mode 100644 index 0000000..ea08dd3 --- /dev/null +++ b/m4/nut_check_libmodbus.m4 @@ -0,0 +1,187 @@ +dnl Check for LIBMODBUS compiler flags. On success, set nut_have_libmodbus="yes" +dnl and set LIBMODBUS_CFLAGS and LIBMODBUS_LIBS. On failure, set +dnl nut_have_libmodbus="no". This macro can be run multiple times, but will +dnl do the checking only once. + +AC_DEFUN([NUT_CHECK_LIBMODBUS], +[ +if test -z "${nut_have_libmodbus_seen}"; then + nut_have_libmodbus_seen=yes + + dnl save CFLAGS and LIBS + CFLAGS_ORIG="${CFLAGS}" + LIBS_ORIG="${LIBS}" + NUT_CHECK_PKGCONFIG + + AS_IF([test x"$have_PKG_CONFIG" = xyes], + [AC_MSG_CHECKING(for libmodbus version via pkg-config) + LIBMODBUS_VERSION="`$PKG_CONFIG --silence-errors --modversion libmodbus 2>/dev/null`" + if test "$?" != "0" -o -z "${LIBMODBUS_VERSION}"; then + LIBMODBUS_VERSION="none" + fi + AC_MSG_RESULT(${LIBMODBUS_VERSION} found) + ], + [LIBMODBUS_VERSION="none" + AC_MSG_NOTICE([can not check libmodbus settings via pkg-config]) + ] + ) + + AS_IF([test x"$LIBMODBUS_VERSION" != xnone], + [CFLAGS="`$PKG_CONFIG --silence-errors --cflags libmodbus 2>/dev/null`" + LIBS="`$PKG_CONFIG --silence-errors --libs libmodbus 2>/dev/null`" + ], + [CFLAGS="-I/usr/include/modbus" + LIBS="-lmodbus" + ] + ) + + AC_MSG_CHECKING(for libmodbus cflags) + AC_ARG_WITH(modbus-includes, + AS_HELP_STRING([@<:@--with-modbus-includes=CFLAGS@:>@], [include flags for the libmodbus library]), + [ + case "${withval}" in + yes|no) + AC_MSG_ERROR(invalid option --with(out)-modbus-includes - see docs/configure.txt) + ;; + *) + CFLAGS="${withval}" + ;; + esac + ], []) + AC_MSG_RESULT([${CFLAGS}]) + + AC_MSG_CHECKING(for libmodbus ldflags) + AC_ARG_WITH(modbus-libs, + AS_HELP_STRING([@<:@--with-modbus-libs=LIBS@:>@], [linker flags for the libmodbus library]), + [ + case "${withval}" in + yes|no) + AC_MSG_ERROR(invalid option --with(out)-modbus-libs - see docs/configure.txt) + ;; + *) + LIBS="${withval}" + ;; + esac + ], []) + AC_MSG_RESULT([${LIBS}]) + + dnl check if libmodbus is usable + AC_CHECK_HEADERS(modbus.h, [nut_have_libmodbus=yes], [nut_have_libmodbus=no], [AC_INCLUDES_DEFAULT]) + AC_CHECK_FUNCS(modbus_new_rtu, [], [nut_have_libmodbus=no]) + AC_CHECK_FUNCS(modbus_new_tcp, [], [nut_have_libmodbus=no]) + AC_CHECK_FUNCS(modbus_set_byte_timeout, [], [nut_have_libmodbus=no]) + AC_CHECK_FUNCS(modbus_set_response_timeout, [], [nut_have_libmodbus=no]) + + dnl modbus_set_byte_timeout() and modbus_set_response_timeout() + dnl in 3.0.x and 3.1.x have different args (since ~2013): the + dnl older version used to accept timeout as a struct timeval + dnl instead of seconds and microseconds. Detect which we use?.. + AS_IF([test x"$nut_have_libmodbus" = xyes], + [dnl Do not rely on versions if we can test actual API + AX_C_PRAGMAS + AC_LANG_PUSH([C]) + AC_CACHE_CHECK([types of arguments for modbus_set_byte_timeout], + [nut_cv_func_modbus_set_byte_timeout_args], + [nut_cv_func_modbus_set_byte_timeout_args="unknown" + AC_COMPILE_IFELSE( + [dnl Try purely the old API (timeval) + AC_LANG_PROGRAM([ +#include +#include +], [modbus_t *ctx; struct timeval to = (struct timeval){0}; +modbus_set_byte_timeout(ctx, &to);]) + ], [nut_cv_func_modbus_set_byte_timeout_args="timeval" + dnl Try the old API in more detail: check + dnl if we can just assign uint32's for new + dnl code into timeval fields (exist+numeric)? + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([ +#include +#include +#include +], [modbus_t *ctx; uint32_t to_sec = 10, to_usec = 50; +struct timeval to = (struct timeval){0}; +/* TODO: Clarify and detect warning names and + * so pragmas for signed/unsigned assignment (e.g. + * for timeval definitions that have "long" fields) + */ +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_COMPARE +# pragma GCC diagnostic ignored "-Wsign-compare" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_CONVERSION +# pragma GCC diagnostic ignored "-Wsign-conversion" +#endif +to.tv_sec = to_sec; +to.tv_usec = to_usec; +modbus_set_byte_timeout(ctx, &to); +]) + ], [nut_cv_func_modbus_set_byte_timeout_args="timeval_numeric_fields"]) + ], + + [dnl Try another API variant: new API with + dnl fields of struct timeval as numbers + dnl (checks they exist, and are compatible + dnl numeric types so compiler can convert) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([ +#include +#include +#include +], [modbus_t *ctx; struct timeval to = (struct timeval){0}; +/* TODO: Clarify and detect warning names and + * so pragmas for signed/unsigned assignment (e.g. + * for timeval definitions that have "long" fields) + */ +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_COMPARE +# pragma GCC diagnostic ignored "-Wsign-compare" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_SIGN_CONVERSION +# pragma GCC diagnostic ignored "-Wsign-conversion" +#endif +uint32_t to_sec = to.tv_sec, to_usec = to.tv_usec; +modbus_set_byte_timeout(ctx, to_sec, to_usec); +]) + ], [nut_cv_func_modbus_set_byte_timeout_args="sec_usec_uint32_cast_timeval_fields"], + [dnl Try another API variant: new API purely (two uint32's) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([ +#include +#include +], [modbus_t *ctx; uint32_t to_sec = 0, to_usec = 0; +modbus_set_byte_timeout(ctx, to_sec, to_usec);]) + ], [nut_cv_func_modbus_set_byte_timeout_args="sec_usec_uint32"]) + ]) + ]) + ]) + + dnl NOTE: We could add similar tests to above for + dnl other time-related methods, but for now keep + dnl it simple -- and assume some same approach + dnl applies to the same generation of the library. + AC_LANG_POP([C]) + AC_MSG_RESULT([Found types to use for modbus_set_byte_timeout: ${nut_cv_func_modbus_set_byte_timeout_args}]) + dnl NOTE: code should check for having a token name defined e.g.: + dnl #ifdef NUT_MODBUS_TIMEOUT_ARG_sec_usec_uint32 + dnl Alas, we can't pass variables as macro name to AC_DEFINE + COMMENT="Define to specify timeout method args approach for libmodbus" + AS_CASE(["${nut_cv_func_modbus_set_byte_timeout_args}"], + [timeval_numeric_fields], [AC_DEFINE([NUT_MODBUS_TIMEOUT_ARG_timeval_numeric_fields], 1, [${COMMENT}])], + [timeval], [AC_DEFINE([NUT_MODBUS_TIMEOUT_ARG_timeval], 1, [${COMMENT}])], + [sec_usec_uint32_cast_timeval_fields], [AC_DEFINE([NUT_MODBUS_TIMEOUT_ARG_sec_usec_uint32_cast_timeval_fields], 1, [${COMMENT}])], + [sec_usec_uint32], [AC_DEFINE([NUT_MODBUS_TIMEOUT_ARG_sec_usec_uint32], 1, [${COMMENT}])], + [dnl default + AC_MSG_WARN([Cannot find proper types to use for modbus_set_byte_timeout]) + nut_have_libmodbus=no] + ) + ]) + + AS_IF([test x"${nut_have_libmodbus}" = x"yes"], + [LIBMODBUS_CFLAGS="${CFLAGS}" + LIBMODBUS_LIBS="${LIBS}"] + ) + + dnl restore original CFLAGS and LIBS + CFLAGS="${CFLAGS_ORIG}" + LIBS="${LIBS_ORIG}" +fi +]) diff --git a/m4/nut_check_libneon.m4 b/m4/nut_check_libneon.m4 index 4fd290b..944f7a3 100644 --- a/m4/nut_check_libneon.m4 +++ b/m4/nut_check_libneon.m4 @@ -7,18 +7,27 @@ AC_DEFUN([NUT_CHECK_LIBNEON], [ if test -z "${nut_have_neon_seen}"; then nut_have_neon_seen=yes + NUT_CHECK_PKGCONFIG dnl save CFLAGS and LIBS CFLAGS_ORIG="${CFLAGS}" LIBS_ORIG="${LIBS}" - dnl See which version of the neon library (if any) is installed - AC_MSG_CHECKING(for libneon version via pkg-config (0.25.0 minimum required)) - NEON_VERSION="`pkg-config --silence-errors --modversion neon 2>/dev/null`" - if test "$?" != "0" -o -z "${NEON_VERSION}"; then - NEON_VERSION="none" - fi - AC_MSG_RESULT(${NEON_VERSION} found) + AS_IF([test x"$have_PKG_CONFIG" = xyes], + [dnl See which version of the neon library (if any) is installed + dnl FIXME : Support detection of cflags/ldflags below by legacy + dnl discovery if pkgconfig is not there + AC_MSG_CHECKING(for libneon version via pkg-config (0.25.0 minimum required)) + NEON_VERSION="`$PKG_CONFIG --silence-errors --modversion neon 2>/dev/null`" + if test "$?" != "0" -o -z "${NEON_VERSION}"; then + NEON_VERSION="none" + fi + AC_MSG_RESULT(${NEON_VERSION} found) + ], + [NEON_VERSION="none" + AC_MSG_NOTICE([can not check libneon settings via pkg-config]) + ] + ) AC_MSG_CHECKING(for libneon cflags) AC_ARG_WITH(neon-includes, @@ -32,7 +41,12 @@ if test -z "${nut_have_neon_seen}"; then CFLAGS="${withval}" ;; esac - ], [CFLAGS="`pkg-config --silence-errors --cflags neon 2>/dev/null`"]) + ], [ + AS_IF([test x"$have_PKG_CONFIG" = xyes], + [CFLAGS="`$PKG_CONFIG --silence-errors --cflags neon 2>/dev/null`" || CFLAGS="-I/usr/include/neon -I/usr/local/include/neon"], + [CFLAGS="-I/usr/include/neon -I/usr/local/include/neon"] + )] + ) AC_MSG_RESULT([${CFLAGS}]) AC_MSG_CHECKING(for libneon ldflags) @@ -47,7 +61,12 @@ if test -z "${nut_have_neon_seen}"; then LIBS="${withval}" ;; esac - ], [LIBS="`pkg-config --silence-errors --libs neon 2>/dev/null`"]) + ], [ + AS_IF([test x"$have_PKG_CONFIG" = xyes], + [LIBS="`$PKG_CONFIG --silence-errors --libs neon 2>/dev/null`" || LIBS="-lneon"], + [LIBS="-lneon"] + )] + ) AC_MSG_RESULT([${LIBS}]) dnl check if neon is usable diff --git a/m4/nut_check_libnetsnmp.m4 b/m4/nut_check_libnetsnmp.m4 index e1c1426..1f89b5a 100644 --- a/m4/nut_check_libnetsnmp.m4 +++ b/m4/nut_check_libnetsnmp.m4 @@ -1,25 +1,83 @@ dnl Check for LIBNETSNMP compiler flags. On success, set dnl nut_have_libnetsnmp="yes" and set LIBNETSNMP_CFLAGS and dnl LIBNETSNMP_LIBS. On failure, set nut_have_libnetsnmp="no". -dnl This macro can be run multiple times, but will do the checking only -dnl once. +dnl This macro can be run multiple times, but will do the +dnl checking only once. AC_DEFUN([NUT_CHECK_LIBNETSNMP], [ if test -z "${nut_have_libnetsnmp_seen}"; then nut_have_libnetsnmp_seen=yes + NUT_CHECK_PKGCONFIG + AC_LANG_PUSH([C]) dnl save CFLAGS and LIBS CFLAGS_ORIG="${CFLAGS}" LIBS_ORIG="${LIBS}" - dnl See which version of the Net-SNMP library (if any) is installed - AC_MSG_CHECKING(for Net-SNMP version via net-snmp-config) - SNMP_VERSION=`net-snmp-config --version 2>/dev/null` - if test "$?" != "0" -o -z "${SNMP_VERSION}"; then - SNMP_VERSION="none" + dnl We prefer to get info from pkg-config (for suitable arch/bitness as + dnl specified in args for that mechanism), unless (legacy) a particular + dnl --with-net-snmp-config=... was requested. If there is no pkg-config + dnl info, we fall back to detecting and running a NET_SNMP_CONFIG as well. + + dnl By default seek in PATH, but which variant (if several are provided)? + AC_CHECK_SIZEOF([void *]) + NET_SNMP_CONFIG="none" + AS_CASE(["${ac_cv_sizeof_void_p}"], + [4],[AC_PATH_PROGS([NET_SNMP_CONFIG], [net-snmp-config-32 net-snmp-config], [none])], + [8],[AC_PATH_PROGS([NET_SNMP_CONFIG], [net-snmp-config-64 net-snmp-config], [none])], + [AC_PATH_PROGS([NET_SNMP_CONFIG], [net-snmp-config], [none])] + ) + + prefer_NET_SNMP_CONFIG=false + AC_ARG_WITH(net-snmp-config, + AS_HELP_STRING([@<:@--with-net-snmp-config=/path/to/net-snmp-config@:>@], + [path to program that reports Net-SNMP configuration]), + [ + case "${withval}" in + ""|yes) prefer_NET_SNMP_CONFIG=true ;; + no) + dnl AC_MSG_ERROR(invalid option --with(out)-net-snmp-config - see docs/configure.txt) + prefer_NET_SNMP_CONFIG=false + ;; + *) + NET_SNMP_CONFIG="${withval}" + prefer_NET_SNMP_CONFIG=true + ;; + esac + ]) + + if test x"$have_PKG_CONFIG" = xyes && ! "${prefer_NET_SNMP_CONFIG}" ; then + AC_MSG_CHECKING(for Net-SNMP version via pkg-config) + dnl TODO? Loop over possible/historic pkg names, like + dnl netsnmp, net-snmp, ucd-snmp, libsnmp, snmp... + SNMP_VERSION="`$PKG_CONFIG --silence-errors --modversion netsnmp 2>/dev/null`" + if test "$?" = "0" -a -n "${SNMP_VERSION}" ; then + AC_MSG_RESULT(${SNMP_VERSION} found) + else + AC_MSG_RESULT(none found) + prefer_NET_SNMP_CONFIG=true + fi + fi + + if test "$NET_SNMP_CONFIG" = none ; then + prefer_NET_SNMP_CONFIG=false + fi + + if "${prefer_NET_SNMP_CONFIG}" ; then + dnl See which version of the Net-SNMP library (if any) is installed + AC_MSG_CHECKING(for Net-SNMP version via ${NET_SNMP_CONFIG}) + SNMP_VERSION="`${NET_SNMP_CONFIG} --version 2>/dev/null`" + if test "$?" != "0" -o -z "${SNMP_VERSION}"; then + SNMP_VERSION="none" + prefer_NET_SNMP_CONFIG=false + fi + AC_MSG_RESULT(${SNMP_VERSION} found) + fi + + if test x"$have_PKG_CONFIG" != xyes && ! "${prefer_NET_SNMP_CONFIG}" ; then + AC_MSG_WARN([did not find either net-snmp-config or pkg-config for net-snmp]) fi - AC_MSG_RESULT(${SNMP_VERSION} found) AC_MSG_CHECKING(for Net-SNMP cflags) AC_ARG_WITH(snmp-includes, @@ -33,7 +91,13 @@ if test -z "${nut_have_libnetsnmp_seen}"; then CFLAGS="${withval}" ;; esac - ], [CFLAGS="`net-snmp-config --base-cflags 2>/dev/null`"]) + ], [AS_IF(["${prefer_NET_SNMP_CONFIG}"], + [CFLAGS="`${NET_SNMP_CONFIG} --base-cflags 2>/dev/null`"], + [AS_IF([test x"$have_PKG_CONFIG" = xyes], + [CFLAGS="`$PKG_CONFIG --silence-errors --cflags netsnmp 2>/dev/null`"] + )] + )] + ) AC_MSG_RESULT([${CFLAGS}]) AC_MSG_CHECKING(for Net-SNMP libs) @@ -48,17 +112,211 @@ if test -z "${nut_have_libnetsnmp_seen}"; then LIBS="${withval}" ;; esac - ], [LIBS="`net-snmp-config --libs 2>/dev/null`"]) + ], [AS_IF(["${prefer_NET_SNMP_CONFIG}"], + [LIBS="`${NET_SNMP_CONFIG} --libs 2>/dev/null`"], + [AS_IF([test x"$have_PKG_CONFIG" = xyes], + [LIBS="`$PKG_CONFIG --silence-errors --libs netsnmp 2>/dev/null`"], + [LIBS="-lnetsnmp"])] + )] + ) AC_MSG_RESULT([${LIBS}]) dnl Check if the Net-SNMP library is usable AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [nut_have_libnetsnmp=yes], [nut_have_libnetsnmp=no], [AC_INCLUDES_DEFAULT]) AC_CHECK_FUNCS(init_snmp, [], [nut_have_libnetsnmp=no]) - if test "${nut_have_libnetsnmp}" = "yes"; then + AS_IF([test "${nut_have_libnetsnmp}" = "yes"], [ LIBNETSNMP_CFLAGS="${CFLAGS}" LIBNETSNMP_LIBS="${LIBS}" - fi + + AC_MSG_CHECKING([for defined usmAESPrivProtocol]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +#include +#include +oid * pProto = usmAESPrivProtocol; +], +[] + )], + [AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol, 1, [Variable or macro by this name is resolvable]) + ], + [AC_MSG_RESULT([no]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol, 0, [Variable or macro by this name is not resolvable]) + ]) + + AC_MSG_CHECKING([for defined usmAES128PrivProtocol]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +#include +#include +oid * pProto = usmAES128PrivProtocol; +], +[] + )], + [AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmAES128PrivProtocol, 1, [Variable or macro by this name is resolvable]) + ], + [AC_MSG_RESULT([no]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmAES128PrivProtocol, 0, [Variable or macro by this name is not resolvable]) + ]) + + AC_MSG_CHECKING([for defined usmDESPrivProtocol]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +#include +#include +oid * pProto = usmDESPrivProtocol; +#ifdef NETSNMP_DISABLE_DES +#error "NETSNMP_DISABLE_DES is defined" +#endif +], +[] + )], + [AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmDESPrivProtocol, 1, [Variable or macro by this name is resolvable]) + ], + [AC_MSG_RESULT([no]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmDESPrivProtocol, 0, [Variable or macro by this name is not resolvable]) + ]) + + AC_MSG_CHECKING([for defined usmHMAC256SHA384AuthProtocol]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +#include +#include +oid * pProto = usmHMAC256SHA384AuthProtocol; +#ifndef HAVE_EVP_SHA384 +#error "HAVE_EVP_SHA384 is NOT defined" +#endif +], +[] + )], + [AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmHMAC256SHA384AuthProtocol, 1, [Variable or macro by this name is resolvable]) + ], + [AC_MSG_RESULT([no]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmHMAC256SHA384AuthProtocol, 0, [Variable or macro by this name is not resolvable]) + ]) + + AC_MSG_CHECKING([for defined usmHMAC384SHA512AuthProtocol]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +#include +#include +oid * pProto = usmHMAC384SHA512AuthProtocol; +#ifndef HAVE_EVP_SHA384 +#error "HAVE_EVP_SHA384 is NOT defined" +#endif +], +[] + )], + [AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmHMAC384SHA512AuthProtocol, 1, [Variable or macro by this name is resolvable]) + ], + [AC_MSG_RESULT([no]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmHMAC384SHA512AuthProtocol, 0, [Variable or macro by this name is not resolvable]) + ]) + + AC_MSG_CHECKING([for defined usmHMAC192SHA256AuthProtocol]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +#include +#include +oid * pProto = usmHMAC192SHA256AuthProtocol; +#ifndef HAVE_EVP_SHA224 +#error "HAVE_EVP_SHA224 is NOT defined" +#endif +], +[] + )], + [AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmHMAC192SHA256AuthProtocol, 1, [Variable or macro by this name is resolvable]) + ], + [AC_MSG_RESULT([no]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmHMAC192SHA256AuthProtocol, 0, [Variable or macro by this name is not resolvable]) + ]) + + AC_MSG_CHECKING([for defined usmAES192PrivProtocol]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +#include +#include +oid * pProto = usmAES192PrivProtocol; +#ifndef NETSNMP_DRAFT_BLUMENTHAL_AES_04 +#error "NETSNMP_DRAFT_BLUMENTHAL_AES_04 is NOT defined" +#endif +], +[] + )], + [AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmAES192PrivProtocol, 1, [Variable or macro by this name is resolvable]) + ], + [AC_MSG_RESULT([no]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmAES192PrivProtocol, 0, [Variable or macro by this name is not resolvable]) + ]) + + AC_MSG_CHECKING([for defined usmAES256PrivProtocol]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +#include +#include +oid * pProto = usmAES256PrivProtocol; +#ifndef NETSNMP_DRAFT_BLUMENTHAL_AES_04 +#error "NETSNMP_DRAFT_BLUMENTHAL_AES_04 is NOT defined" +#endif +], +[] + )], + [AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmAES256PrivProtocol, 1, [Variable or macro by this name is resolvable]) + ], + [AC_MSG_RESULT([no]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmAES256PrivProtocol, 0, [Variable or macro by this name is not resolvable]) + ]) + + AC_MSG_CHECKING([for defined usmHMACMD5AuthProtocol]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +#include +#include +oid * pProto = usmHMACMD5AuthProtocol; +#ifdef NETSNMP_DISABLE_MD5 +#error "NETSNMP_DISABLE_MD5 is defined" +#endif +], +[] + )], + [AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmHMACMD5AuthProtocol, 1, [Variable or macro by this name is resolvable]) + ], + [AC_MSG_RESULT([no]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmHMACMD5AuthProtocol, 0, [Variable or macro by this name is not resolvable]) + ]) + + AC_MSG_CHECKING([for defined usmHMACSHA1AuthProtocol]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +#include +#include +oid * pProto = usmHMACSHA1AuthProtocol; +], +[] + )], + [AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmHMACSHA1AuthProtocol, 1, [Variable or macro by this name is resolvable]) + ], + [AC_MSG_RESULT([no]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_usmHMACSHA1AuthProtocol, 0, [Variable or macro by this name is not resolvable]) + ]) + + AC_MSG_CHECKING([for defined NETSNMP_DRAFT_BLUMENTHAL_AES_04]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +#include +#include +int num = NETSNMP_DRAFT_BLUMENTHAL_AES_04 + 1; /* if defined, NETSNMP_DRAFT_BLUMENTHAL_AES_04 is 1 */ +], +[] + )], + [AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_DRAFT_BLUMENTHAL_AES_04, 1, [Variable or macro by this name is resolvable]) + ], + [AC_MSG_RESULT([no]) + AC_DEFINE_UNQUOTED(NUT_HAVE_LIBNETSNMP_DRAFT_BLUMENTHAL_AES_04, 0, [Variable or macro by this name is not resolvable]) + ]) + + ]) + AC_LANG_POP([C]) dnl restore original CFLAGS and LIBS CFLAGS="${CFLAGS_ORIG}" diff --git a/m4/nut_check_libnss.m4 b/m4/nut_check_libnss.m4 index 7c23531..54833d7 100644 --- a/m4/nut_check_libnss.m4 +++ b/m4/nut_check_libnss.m4 @@ -3,26 +3,50 @@ dnl nut_have_libnss="yes" and nut_ssl_lib="Mozilla NSS", and define WITH_SSL, dnl WITH_NSS, LIBSSL_CFLAGS and LIBSSL_LIBS. On failure, set nut_have_libnss="no". dnl This macro can be run multiple times, but will do the checking only once. -AC_DEFUN([NUT_CHECK_LIBNSS], +AC_DEFUN([NUT_CHECK_LIBNSS], [ if test -z "${nut_have_libnss_seen}"; then nut_have_libnss_seen=yes + NUT_CHECK_PKGCONFIG dnl save CFLAGS and LIBS CFLAGS_ORIG="${CFLAGS}" LIBS_ORIG="${LIBS}" + REQUIRES_ORIG="${REQUIRES}" - AC_MSG_CHECKING(for Mozilla NSS version via pkg-config) - NSS_VERSION="`pkg-config --silence-errors --modversion nss 2>/dev/null`" - if test "$?" = "0" -a -n "${NSS_VERSION}"; then - CFLAGS="`pkg-config --silence-errors --cflags nss 2>/dev/null`" - LIBS="`pkg-config --silence-errors --libs nss 2>/dev/null`" - else - NSS_VERSION="none" - CFLAGS="" - LIBS="-lnss3 -lnssutil3 -lsmime3 -lssl3 -lplds4 -lplc4 -lnspr4" + SAVED_GCC="$GCC" + SAVED_CC="$CC" + if ( test "${GCC}" = "yes" ) + then + case "$CFLAGS$LDFLAGS" in + *-m32*) CC="$CC -m32" ;; + *-m64*) CC="$CC -m64" ;; + esac fi - AC_MSG_RESULT(${NSS_VERSION} found) + + AS_IF([test x"$have_PKG_CONFIG" = xyes], + [AC_MSG_CHECKING(for Mozilla NSS version via pkg-config) + NSS_VERSION="`$PKG_CONFIG --silence-errors --modversion nss 2>/dev/null`" + if test "$?" != "0" -o -z "${NSS_VERSION}"; then + NSS_VERSION="none" + fi + AC_MSG_RESULT(${NSS_VERSION} found) + ], + [NSS_VERSION="none" + AC_MSG_NOTICE([can not check libnss settings via pkg-config]) + ] + ) + + AS_IF([test x"$NSS_VERSION" != xnone], + [CFLAGS="`$PKG_CONFIG --silence-errors --cflags nss 2>/dev/null`" + LIBS="`$PKG_CONFIG --silence-errors --libs nss 2>/dev/null`" + REQUIRES="nss" + ], + [CFLAGS="" + LIBS="-lnss3 -lnssutil3 -lsmime3 -lssl3 -lplds4 -lplc4 -lnspr4" + REQUIRES="nss" + ] + ) dnl allow overriding NSS settings if the user knows best AC_MSG_CHECKING(for Mozilla NSS cflags) @@ -56,10 +80,14 @@ if test -z "${nut_have_libnss_seen}"; then AC_MSG_RESULT([${LIBS}]) dnl check if NSS is usable: we need both the runtime and headers + dnl NOTE that caller may have to specify PKG_CONFIG_PATH including + dnl their bitness variant if it is not prioritized in their default + dnl setting built in by OS distribution; the .../pkgconfig/nss.pc + dnl tends to specify the libdir which is CPU Arch dependent. AC_CHECK_FUNCS(NSS_Init, [nut_have_libnss=yes], [nut_have_libnss=no]) dnl libc6 also provides an nss.h file, so also check for ssl.h AC_CHECK_HEADERS([nss.h ssl.h], [], [nut_have_libnss=no], [AC_INCLUDES_DEFAULT]) - + if test "${nut_have_libnss}" = "yes"; then nut_with_ssl="yes" nut_ssl_lib="(Mozilla NSS)" @@ -67,10 +95,14 @@ if test -z "${nut_have_libnss_seen}"; then AC_DEFINE(WITH_NSS, 1, [Define to enable SSL support using Mozilla NSS]) LIBSSL_CFLAGS="${CFLAGS}" LIBSSL_LIBS="${LIBS}" + LIBSSL_REQUIRES="${REQUIRES}" fi dnl restore original CFLAGS and LIBS CFLAGS="${CFLAGS_ORIG}" LIBS="${LIBS_ORIG}" + REQUIRES="${REQUIRES_ORIG}" + GCC="$SAVED_GCC" + CC="$SAVED_CC" fi ]) diff --git a/m4/nut_check_libopenssl.m4 b/m4/nut_check_libopenssl.m4 index 1b87507..d493615 100644 --- a/m4/nut_check_libopenssl.m4 +++ b/m4/nut_check_libopenssl.m4 @@ -8,22 +8,36 @@ AC_DEFUN([NUT_CHECK_LIBOPENSSL], [ if test -z "${nut_have_libopenssl_seen}"; then nut_have_libopenssl_seen=yes + NUT_CHECK_PKGCONFIG dnl save CFLAGS and LIBS CFLAGS_ORIG="${CFLAGS}" LIBS_ORIG="${LIBS}" + REQUIRES_ORIG="${REQUIRES}" - AC_MSG_CHECKING(for OpenSSL version via pkg-config) - OPENSSL_VERSION="`pkg-config --silence-errors --modversion openssl 2>/dev/null`" - if test "$?" = "0" -a -n "${OPENSSL_VERSION}"; then - CFLAGS="`pkg-config --silence-errors --cflags openssl 2>/dev/null`" - LIBS="`pkg-config --silence-errors --libs openssl 2>/dev/null`" - else - OPENSSL_VERSION="none" - CFLAGS="" - LIBS="-lssl -lcrypto" - fi - AC_MSG_RESULT(${OPENSSL_VERSION} found) + AS_IF([test x"$have_PKG_CONFIG" = xyes], + [AC_MSG_CHECKING(for OpenSSL version via pkg-config) + OPENSSL_VERSION="`$PKG_CONFIG --silence-errors --modversion openssl 2>/dev/null`" + if test "$?" != "0" -o -z "${OPENSSL_VERSION}"; then + OPENSSL_VERSION="none" + fi + AC_MSG_RESULT(${OPENSSL_VERSION} found) + ], + [OPENSSL_VERSION="none" + AC_MSG_NOTICE([can not check OpenSSL settings via pkg-config]) + ] + ) + + AS_IF([test x"$OPENSSL_VERSION" != xnone], + [CFLAGS="`$PKG_CONFIG --silence-errors --cflags openssl 2>/dev/null`" + LIBS="`$PKG_CONFIG --silence-errors --libs openssl 2>/dev/null`" + REQUIRES="openssl" + ], + [CFLAGS="" + LIBS="-lssl -lcrypto" + REQUIRES="openssl" + ] + ) dnl allow overriding OpenSSL settings if the user knows best AC_MSG_CHECKING(for OpenSSL cflags) @@ -58,7 +72,7 @@ if test -z "${nut_have_libopenssl_seen}"; then dnl check if openssl is usable AC_CHECK_HEADERS(openssl/ssl.h, [nut_have_openssl=yes], [nut_have_openssl=no], [AC_INCLUDES_DEFAULT]) - AC_CHECK_FUNCS(SSL_library_init, [], [nut_have_openssl=no]) + AC_CHECK_FUNCS(SSL_CTX_new, [], [nut_have_openssl=no]) if test "${nut_have_openssl}" = "yes"; then nut_with_ssl="yes" @@ -67,10 +81,12 @@ if test -z "${nut_have_libopenssl_seen}"; then AC_DEFINE(WITH_OPENSSL, 1, [Define to enable SSL support using OpenSSL]) LIBSSL_CFLAGS="${CFLAGS}" LIBSSL_LIBS="${LIBS}" + LIBSSL_REQUIRES="${REQUIRES}" fi dnl restore original CFLAGS and LIBS CFLAGS="${CFLAGS_ORIG}" LIBS="${LIBS_ORIG}" + REQUIRES="${REQUIRES_ORIG}" fi ]) diff --git a/m4/nut_check_libpowerman.m4 b/m4/nut_check_libpowerman.m4 index a29afed..b731cfe 100644 --- a/m4/nut_check_libpowerman.m4 +++ b/m4/nut_check_libpowerman.m4 @@ -7,24 +7,53 @@ AC_DEFUN([NUT_CHECK_LIBPOWERMAN], [ if test -z "${nut_have_libpowerman_seen}"; then nut_have_libpowerman_seen=yes + NUT_CHECK_PKGCONFIG dnl save CFLAGS and LIBS CFLAGS_ORIG="${CFLAGS}" LIBS_ORIG="${LIBS}" - AC_MSG_CHECKING(for libpowerman cflags) + AS_IF([test x"$have_PKG_CONFIG" = xyes], + [AC_MSG_CHECKING([for LLNC libpowerman version via pkg-config]) + POWERMAN_VERSION="`$PKG_CONFIG --silence-errors --modversion libpowerman 2>/dev/null`" + dnl Unlike other pkg-config enabled projects we use, + dnl libpowerman (at least on Debian) delivers an empty + dnl "Version:" tag in /usr/lib/pkgconfig/libpowerman.pc + dnl (and it is the only file in that dir, others going + dnl to /usr/lib/x86_64-linux-gnu/pkgconfig/ or similar + dnl for other architectures). Empty is not an error here! + if test "$?" != "0" ; then # -o -z "${POWERMAN_VERSION}"; then + POWERMAN_VERSION="none" + fi + AC_MSG_RESULT(['${POWERMAN_VERSION}' found]) + ], + [POWERMAN_VERSION="none" + AC_MSG_NOTICE([can not check LLNC libpowerman settings via pkg-config]) + ] + ) + + AS_IF([test x"$POWERMAN_VERSION" != xnone], + [CFLAGS="`$PKG_CONFIG --silence-errors --cflags libpowerman 2>/dev/null`" + LIBS="`$PKG_CONFIG --silence-errors --libs libpowerman 2>/dev/null`" + ], + [CFLAGS="" + LIBS="" + ] + ) + + AC_MSG_CHECKING([for libpowerman cflags]) AC_ARG_WITH(powerman-includes, AS_HELP_STRING([@<:@--with-powerman-includes=CFLAGS@:>@], [include flags for the libpowerman library]), [ case "${withval}" in yes|no) - AC_MSG_ERROR(invalid option --with(out)-powerman-includes - see docs/configure.txt) + AC_MSG_ERROR([invalid option --with(out)-powerman-includes - see docs/configure.txt]) ;; *) CFLAGS="${withval}" ;; esac - ], [CFLAGS="`pkg-config --silence-errors --cflags libpowerman 2>/dev/null`"]) + ], []) AC_MSG_RESULT([${CFLAGS}]) AC_MSG_CHECKING(for libpowerman libs) @@ -39,12 +68,23 @@ if test -z "${nut_have_libpowerman_seen}"; then LIBS="${withval}" ;; esac - ], [LIBS="`pkg-config --silence-errors --libs libpowerman 2>/dev/null`"]) + ], []) AC_MSG_RESULT([${LIBS}]) dnl check if libpowerman is usable AC_CHECK_HEADERS(libpowerman.h, [nut_have_libpowerman=yes], [nut_have_libpowerman=no], [AC_INCLUDES_DEFAULT]) - AC_CHECK_FUNCS(pm_connect, [], [nut_have_libpowerman=no]) + AC_CHECK_FUNCS(pm_connect, [], [ + dnl Some systems may just have libpowerman in their + dnl standard paths, but not the pkg-config data + AS_IF([test "${nut_have_libpowerman}" = "yes" && test "$POWERMAN_VERSION" = "none" && test -z "$LIBS"], + [AC_MSG_CHECKING([if libpowerman is just present in path]) + LIBS="-L/usr/lib -L/usr/local/lib -lpowerman" + unset ac_cv_func_pm_connect || true + AC_CHECK_FUNCS(pm_connect, [], [nut_have_libpowerman=no]) + AC_MSG_RESULT([${nut_have_libpowerman}]) + ], [nut_have_libpowerman=no] + )] + ) if test "${nut_have_libpowerman}" = "yes"; then LIBPOWERMAN_CFLAGS="${CFLAGS}" diff --git a/m4/nut_check_libusb.m4 b/m4/nut_check_libusb.m4 index b2bb0ab..89f7a02 100644 --- a/m4/nut_check_libusb.m4 +++ b/m4/nut_check_libusb.m4 @@ -1,48 +1,173 @@ -dnl Check for LIBUSB compiler flags. On success, set nut_have_libusb="yes" -dnl and set LIBUSB_CFLAGS and LIBUSB_LIBS. On failure, set +dnl Check for LIBUSB 1.0 or 0.1 (and, if found, fill 'nut_usb_lib' with its +dnl approximate version) and its compiler flags. On success, set +dnl nut_have_libusb="yes" and set LIBUSB_CFLAGS and LIBUSB_LIBS. On failure, set dnl nut_have_libusb="no". This macro can be run multiple times, but will dnl do the checking only once. +dnl By default, if both libusb 1.0 and libusb 0.1 are available and appear to be +dnl usable, libusb 1.0 takes precedence. +dnl An optional argument with value 'libusb-1.0' or 'libusb-0.1' can be used to +dnl restrict checks to a specific version. AC_DEFUN([NUT_CHECK_LIBUSB], [ if test -z "${nut_have_libusb_seen}"; then nut_have_libusb_seen=yes + NUT_CHECK_PKGCONFIG dnl save CFLAGS and LIBS CFLAGS_ORIG="${CFLAGS}" LIBS_ORIG="${LIBS}" + CFLAGS="" + LIBS="" - AC_MSG_CHECKING(for libusb version via pkg-config) - LIBUSB_VERSION="`pkg-config --silence-errors --modversion libusb 2>/dev/null`" - if test "$?" = "0" -a -n "${LIBUSB_VERSION}"; then - CFLAGS="`pkg-config --silence-errors --cflags libusb 2>/dev/null`" - LIBS="`pkg-config --silence-errors --libs libusb 2>/dev/null`" - else - AC_MSG_CHECKING(via libusb-config) - LIBUSB_VERSION="`libusb-config --version 2>/dev/null`" - if test "$?" = "0" -a -n "${LIBUSB_VERSION}"; then - CFLAGS="`libusb-config --cflags 2>/dev/null`" - LIBS="`libusb-config --libs 2>/dev/null`" - else + dnl Magic-format string to hold chosen libusb version and its config-source + nut_usb_lib="" + + dnl TOTHINK: What if there are more than 0.1 and 1.0 to juggle? + dnl TODO? Add libusb-compat (1.0 code with 0.1's API) to the mix? + AS_IF([test x"$have_PKG_CONFIG" = xyes], + [AC_MSG_CHECKING([for libusb-1.0 version via pkg-config]) + LIBUSB_1_0_VERSION="`$PKG_CONFIG --silence-errors --modversion libusb-1.0 2>/dev/null`" \ + && test -n "${LIBUSB_1_0_VERSION}" \ + || LIBUSB_1_0_VERSION="none" + AC_MSG_RESULT([${LIBUSB_1_0_VERSION} found]) + + AC_MSG_CHECKING([for libusb(-0.1) version via pkg-config]) + LIBUSB_0_1_VERSION="`$PKG_CONFIG --silence-errors --modversion libusb 2>/dev/null`" \ + && test -n "${LIBUSB_0_1_VERSION}" \ + || LIBUSB_0_1_VERSION="none" + AC_MSG_RESULT([${LIBUSB_0_1_VERSION} found]) + ], + [LIBUSB_0_1_VERSION="none" + LIBUSB_1_0_VERSION="none" + AC_MSG_NOTICE([can not check libusb settings via pkg-config]) + ] + ) + + dnl Note: it seems the script was only shipped for libusb-0.1 + dnl So we don't separate into LIBUSB_0_1_CONFIG and LIBUSB_1_0_CONFIG + AC_PATH_PROGS([LIBUSB_CONFIG], [libusb-config], [none]) + + AC_ARG_WITH(libusb-config, + AS_HELP_STRING([@<:@--with-libusb-config=/path/to/libusb-config@:>@], + [path to program that reports LibUSB configuration]), dnl ...for LibUSB-0.1 + [ + AS_CASE(["${withval}"], + [""], [], dnl empty arg + [yes|no], [ + dnl MAYBE bump preference of script over pkg-config? + AC_MSG_ERROR([invalid option --with(out)-libusb-config - see docs/configure.txt]) + ], + [dnl default + LIBUSB_CONFIG="${withval}" + ] + ) + ] + ) + + AS_IF([test x"${LIBUSB_CONFIG}" != xnone], + [AC_MSG_CHECKING([via ${LIBUSB_CONFIG}]) + LIBUSB_CONFIG_VERSION="`$LIBUSB_CONFIG --version 2>/dev/null`" \ + && test -n "${LIBUSB_CONFIG_VERSION}" \ + || LIBUSB_CONFIG_VERSION="none" + AC_MSG_RESULT([${LIBUSB_CONFIG_VERSION} found]) + ], [LIBUSB_CONFIG_VERSION="none"] + ) + + dnl By default, prefer newest available, and if anything is known + dnl to pkg-config, prefer that. Otherwise, fall back to script data: + AS_IF([test x"${LIBUSB_1_0_VERSION}" != xnone], + [LIBUSB_VERSION="${LIBUSB_1_0_VERSION}" + nut_usb_lib="(libusb-1.0)" + ], + [AS_IF([test x"${LIBUSB_0_1_VERSION}" != xnone], + [LIBUSB_VERSION="${LIBUSB_0_1_VERSION}" + nut_usb_lib="(libusb-0.1)" + ], + [LIBUSB_VERSION="${LIBUSB_CONFIG_VERSION}" + AS_IF([test x"${LIBUSB_CONFIG_VERSION}" != xnone], + [dnl TODO: This assumes 0.1; check for 1.0+ somehow? + nut_usb_lib="(libusb-0.1-config)"], + [nut_usb_lib=""] + )] + )] + ) + + dnl Pick up the default or caller-provided choice here from + dnl NUT_ARG_WITH(usb, ...) in the main configure.ac script + AC_MSG_CHECKING([for libusb preferred version]) + AS_CASE(["${nut_with_usb}"], + [auto], [], dnl Use preference picked above + [yes], [], dnl Use preference from above, fail in the end if none found + [no], [], dnl Try to find, report in the end if that is discarded; TODO: not waste time? + [libusb-1.0|1.0], [ + dnl NOTE: Assuming there is no libusb-config-1.0 or similar script, never saw one + AS_IF([test x"${LIBUSB_1_0_VERSION}" = xnone], + [AC_MSG_ERROR([option --with-usb=${withval} was required, but this library version was not detected]) + ]) + LIBUSB_VERSION="${LIBUSB_1_0_VERSION}" + nut_usb_lib="(libusb-1.0)" + ], + [libusb-0.1|0.1], [ + AS_IF([test x"${LIBUSB_0_1_VERSION}" = xnone \ + && test x"${LIBUSB_CONFIG_VERSION}" = xnone], + [AC_MSG_ERROR([option --with-usb=${withval} was required, but this library version was not detected]) + ]) + AS_IF([test x"${LIBUSB_0_1_VERSION}" != xnone], + [LIBUSB_VERSION="${LIBUSB_0_1_VERSION}" + nut_usb_lib="(libusb-0.1)" + ], + [LIBUSB_VERSION="${LIBUSB_CONFIG_VERSION}" + nut_usb_lib="(libusb-0.1-config)" + ]) + ], + [dnl default + AC_MSG_ERROR([invalid option value --with-usb=${withval} - see docs/configure.txt]) + ] + ) + AC_MSG_RESULT([${LIBUSB_VERSION} ${nut_usb_lib}]) + + AS_IF([test x"${LIBUSB_1_0_VERSION}" != xnone && test x"${nut_usb_lib}" != x"(libusb-1.0)" ], + [AC_MSG_NOTICE([libusb-1.0 support was detected, but another was chosen ${nut_usb_lib}])] + ) + + dnl FIXME? Detect and report all CFLAGS/LIBS that we can, + dnl and *then* pick one set of values to use? + AS_CASE([${nut_usb_lib}], + ["(libusb-1.0)"], [ + CFLAGS="`$PKG_CONFIG --silence-errors --cflags libusb-1.0 2>/dev/null`" + LIBS="`$PKG_CONFIG --silence-errors --libs libusb-1.0 2>/dev/null`" + ], + ["(libusb-0.1)"], [ + CFLAGS="`$PKG_CONFIG --silence-errors --cflags libusb 2>/dev/null`" + LIBS="`$PKG_CONFIG --silence-errors --libs libusb 2>/dev/null`" + ], + ["(libusb-0.1-config)"], [ + CFLAGS="`$LIBUSB_CONFIG --cflags 2>/dev/null`" + LIBS="`$LIBUSB_CONFIG --libs 2>/dev/null`" + ], + [dnl default, for other versions or "none" + AC_MSG_WARN([Defaulting libusb configuration]) LIBUSB_VERSION="none" CFLAGS="" LIBS="-lusb" - fi - fi - AC_MSG_RESULT(${LIBUSB_VERSION} found) + ] + ) + dnl check optional user-provided values for cflags/ldflags + dnl and publish what we end up using AC_MSG_CHECKING(for libusb cflags) AC_ARG_WITH(usb-includes, AS_HELP_STRING([@<:@--with-usb-includes=CFLAGS@:>@], [include flags for the libusb library]), [ - case "${withval}" in - yes|no) - AC_MSG_ERROR(invalid option --with(out)-usb-includes - see docs/configure.txt) - ;; - *) - CFLAGS="${withval}" - ;; - esac + AS_CASE(["${withval}"], + [yes|no], [ + AC_MSG_ERROR(invalid option --with(out)-usb-includes - see docs/configure.txt) + ], + [dnl default + CFLAGS="${withval}" + ] + ) ], []) AC_MSG_RESULT([${CFLAGS}]) @@ -50,28 +175,159 @@ if test -z "${nut_have_libusb_seen}"; then AC_ARG_WITH(usb-libs, AS_HELP_STRING([@<:@--with-usb-libs=LIBS@:>@], [linker flags for the libusb library]), [ - case "${withval}" in - yes|no) - AC_MSG_ERROR(invalid option --with(out)-usb-libs - see docs/configure.txt) - ;; - *) - LIBS="${withval}" - ;; - esac + AS_CASE(["${withval}"], + [yes|no], [ + AC_MSG_ERROR(invalid option --with(out)-usb-libs - see docs/configure.txt) + ], + [dnl default + LIBS="${withval}" + ] + ) ], []) AC_MSG_RESULT([${LIBS}]) - dnl check if libusb is usable - AC_CHECK_HEADERS(usb.h, [nut_have_libusb=yes], [nut_have_libusb=no], [AC_INCLUDES_DEFAULT]) - AC_CHECK_FUNCS(usb_init, [], [nut_have_libusb=no]) + dnl TODO: Consult chosen nut_usb_lib value and/or nut_with_usb argument + dnl (with "auto" we may use a 0.1 if present and working while a 1.0 is + dnl present but useless) + dnl Check if libusb is usable + AC_LANG_PUSH([C]) + if test -n "${LIBUSB_VERSION}"; then + dnl Test specifically for libusb-1.0 via pkg-config, else fall back below + test -n "$PKG_CONFIG" \ + && test x"${nut_usb_lib}" = x"(libusb-1.0)" \ + && $PKG_CONFIG --silence-errors --atleast-version=1.0 libusb-1.0 2>/dev/null + if test "$?" = "0"; then + dnl libusb 1.0: libusb_set_auto_detach_kernel_driver + AC_CHECK_HEADERS(libusb.h, [nut_have_libusb=yes], [nut_have_libusb=no], [AC_INCLUDES_DEFAULT]) + AC_CHECK_FUNCS(libusb_init, [], [nut_have_libusb=no]) + AC_CHECK_FUNCS(libusb_strerror, [], [nut_have_libusb=no; nut_have_libusb_strerror=no]) + if test "${nut_have_libusb_strerror}" = "no"; then + AC_MSG_WARN([libusb_strerror() not found; install libusbx to use libusb 1.0 API. See https://github.com/networkupstools/nut/issues/509]) + fi + if test "${nut_have_libusb}" = "yes"; then + dnl This function is fairly old, but check for it anyway: + AC_CHECK_FUNCS(libusb_kernel_driver_active) + dnl Check for libusb "force driver unbind" availability + AC_CHECK_FUNCS(libusb_set_auto_detach_kernel_driver) + dnl libusb 1.0: libusb_detach_kernel_driver + dnl FreeBSD 10.1-10.3 have this, but not libusb_set_auto_detach_kernel_driver + AC_CHECK_FUNCS(libusb_detach_kernel_driver) + AC_CHECK_FUNCS(libusb_detach_kernel_driver_np) - if test "${nut_have_libusb}" = "yes"; then - dnl Check for libusb "force driver unbind" availability - AC_CHECK_FUNCS(usb_detach_kernel_driver_np) + dnl From libusb-0.1 - check these to have valid config.h definitions + dnl Note: confusingly, FreeBSD does find both as defined + dnl (despite being spread across usb.h and libusb.h), + dnl so our source code has to care :\ + AC_CHECK_FUNCS(usb_detach_kernel_driver_np) + fi + else + dnl libusb 0.1, or missing pkg-config : + AC_CHECK_HEADERS(usb.h, [nut_have_libusb=yes], [nut_have_libusb=no], [AC_INCLUDES_DEFAULT]) + AC_CHECK_FUNCS(usb_init, [], [ + dnl Some systems may just have libusb in their standard + dnl paths, but not the pkg-config or libusb-config data + AS_IF([test "${nut_have_libusb}" = "yes" && test "$LIBUSB_VERSION" = "none" && test -z "$LIBS"], + [AC_MSG_CHECKING([if libusb is just present in path]) + LIBS="-L/usr/lib -L/usr/local/lib -lusb" + unset ac_cv_func_usb_init || true + AC_CHECK_FUNCS(usb_init, [], [nut_have_libusb=no]) + AC_MSG_RESULT([${nut_have_libusb}]) + ], [nut_have_libusb=no] + )] + ) + dnl Check for libusb "force driver unbind" availability + if test "${nut_have_libusb}" = "yes"; then + AC_CHECK_FUNCS(usb_detach_kernel_driver_np) + + dnl From libusb-1.0 - check these to have valid config.h definitions + AC_CHECK_FUNCS(libusb_kernel_driver_active) + AC_CHECK_FUNCS(libusb_set_auto_detach_kernel_driver) + AC_CHECK_FUNCS(libusb_detach_kernel_driver) + AC_CHECK_FUNCS(libusb_detach_kernel_driver_np) + fi + fi + else + nut_have_libusb=no + fi + + AS_IF([test "${nut_have_libusb}" = "yes"], [ + dnl ---------------------------------------------------------------------- + dnl additional USB-related checks + + dnl Solaris 10/11 USB handling (need librt and libusb runtime path) + dnl Should we check for `uname -o == illumos` to avoid legacy here? + dnl Or better yet, perform some active capability tests for need of + dnl workarounds or not? e.g. OpenIndiana should include a capable + dnl version of libusb-1.0.23+ tailored with NUT tests in mind... + dnl HPUX, since v11, needs an explicit activation of pthreads + dnl TODO: There are reports about FreeBSD error-code + dnl handling in libusb-0.1 port returning "-1" always, + dnl instead of differing codes like on other systems. + dnl Should we check for that below?.. + dnl https://github.com/networkupstools/nut/issues/490 + AS_CASE(["${target_os}"], + [solaris2.1*], [ + AC_MSG_CHECKING([for Solaris 10 / 11 specific configuration for usb drivers]) + AC_SEARCH_LIBS(nanosleep, rt) + LIBS="-R/usr/sfw/lib ${LIBS}" + dnl FIXME: Sun's libusb doesn't support timeout (so blocks notification) + dnl and need to call libusb close upon reconnection + dnl TODO: Somehow test for susceptible versions? + AC_DEFINE(SUN_LIBUSB, 1, [Define to 1 for Sun version of the libusb.]) + SUN_LIBUSB=1 + AC_MSG_RESULT([${LIBS}]) + ], + [hpux11*], [ + CFLAGS="${CFLAGS} -lpthread" + ] + ) + ]) + AC_LANG_POP([C]) + + AS_IF([test "${nut_have_libusb}" = "yes"], [ LIBUSB_CFLAGS="${CFLAGS}" LIBUSB_LIBS="${LIBS}" + ], [ + AS_CASE(["${nut_with_usb}"], + [no|auto], [], + [yes|1.0|0.1|libusb-1.0|libusb-0.1], + [dnl Explicitly choosing a library implies 'yes' (i.e. fail if not found), not 'auto'. + AC_MSG_ERROR([USB drivers requested, but libusb not found.]) + ] + ) + ]) + + if test "${nut_with_usb}" = "no"; then + if test -n "${nut_usb_lib}" && test "${nut_usb_lib}" != none ; then + AC_MSG_NOTICE([libusb was detected ${nut_usb_lib}, but a build without USB drivers was requested]) + fi + nut_usb_lib="" + else + nut_with_usb="${nut_have_libusb}" fi + dnl AC_MSG_NOTICE([DEBUG: nut_have_libusb='${nut_have_libusb}']) + dnl AC_MSG_NOTICE([DEBUG: nut_with_usb='${nut_with_usb}']) + dnl AC_MSG_NOTICE([DEBUG: nut_usb_lib='${nut_usb_lib}']) + + dnl Note: AC_DEFINE specifies a verbatim "value" so we pre-calculate it! + dnl Source code should be careful to use "#if" and not "#ifdef" when + dnl checking these values during the build. And both must be defined + dnl with some value. + AS_IF([test "${nut_with_usb}" = "yes" && test "${nut_usb_lib}" = "(libusb-1.0)"], + [AC_DEFINE([WITH_LIBUSB_1_0], [1], + [Define to 1 for version 1.0 of the libusb (via pkg-config).])], + [AC_DEFINE([WITH_LIBUSB_1_0], [0], + [Define to 1 for version 1.0 of the libusb (via pkg-config).])] + ) + + AS_IF([test "${nut_with_usb}" = "yes" && test "${nut_usb_lib}" = "(libusb-0.1)" -o "${nut_usb_lib}" = "(libusb-0.1-config)"], + [AC_DEFINE([WITH_LIBUSB_0_1], [1], + [Define to 1 for version 0.1 of the libusb (via pkg-config or libusb-config).])], + [AC_DEFINE([WITH_LIBUSB_0_1], [0], + [Define to 1 for version 0.1 of the libusb (via pkg-config or libusb-config).])] + ) + dnl restore original CFLAGS and LIBS CFLAGS="${CFLAGS_ORIG}" LIBS="${LIBS_ORIG}" diff --git a/m4/nut_check_libwrap.m4 b/m4/nut_check_libwrap.m4 index 7f1ff9d..c61f01e 100644 --- a/m4/nut_check_libwrap.m4 +++ b/m4/nut_check_libwrap.m4 @@ -18,6 +18,7 @@ if test -z "${nut_have_libwrap_seen}"; then dnl The line below does not work on Solaris 10. dnl AC_SEARCH_LIBS(request_init, wrap, [], [nut_have_libwrap=no]) AC_MSG_CHECKING(for library containing request_init) + AC_LANG_PUSH([C]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include int allow_severity = 0, deny_severity = 0; @@ -35,6 +36,7 @@ int allow_severity = 0, deny_severity = 0; nut_have_libwrap=no ]) ]) + AC_LANG_POP([C]) if test "${nut_have_libwrap}" = "yes"; then AC_DEFINE(HAVE_WRAP, 1, [Define to enable libwrap support]) diff --git a/m4/nut_check_pkgconfig.m4 b/m4/nut_check_pkgconfig.m4 new file mode 100644 index 0000000..263be4b --- /dev/null +++ b/m4/nut_check_pkgconfig.m4 @@ -0,0 +1,91 @@ +dnl Check for LIBPOWERMAN compiler flags. On success, set nut_have_libpowerman="yes" +dnl and set LIBPOWERMAN_CFLAGS and LIBPOWERMAN_LIBS. On failure, set +dnl nut_have_libpowerman="no". This macro can be run multiple times, but will +dnl do the checking only once. + +AC_DEFUN([NUT_CHECK_PKGCONFIG], +[ +AS_IF([test -z "${nut_have_pkg_config_seen}"], [ + nut_have_pkg_config_seen=yes + + dnl Note that PKG_CONFIG may be a filename, path, + dnl or either with args - so no quoting here + AC_MSG_CHECKING([whether usable PKG_CONFIG was already detected by autoconf]) + AS_IF([test -n "${PKG_CONFIG-}" && test x"${PKG_CONFIG-}" != x"false" && $PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null], + [AC_MSG_RESULT([yes: ${PKG_CONFIG}]) + have_PKG_CONFIG=yes + ], + [AC_MSG_RESULT([no]) + PKG_CONFIG=false + have_PKG_CONFIG=no + ] + ) + + AS_IF([test x"${PKG_CONFIG-}" = x"false"], + [dnl Some systems have older autotools without direct macro support for PKG_CONF* + have_PKG_CONFIG=yes + AC_PATH_PROG(dummy_PKG_CONFIG, pkg-config) + + AC_ARG_WITH(pkg-config, + AS_HELP_STRING([@<:@--with-pkg-config=/path/to/gdlib-config@:>@], + [path to program that reports development package configuration]), + [ + case "${withval}" in + "") ;; + yes|no) + AC_MSG_ERROR(invalid option --with(out)-pkg-config - see docs/configure.txt) + ;; + *) + dummy_PKG_CONFIG="${withval}" + ;; + esac + ]) + + AC_MSG_CHECKING([whether usable PKG_CONFIG is present in PATH or was set by caller]) + AS_IF([test x"$dummy_PKG_CONFIG" = xno || test -z "$dummy_PKG_CONFIG"], + [AC_MSG_RESULT([no]) + PKG_CONFIG=false + have_PKG_CONFIG=no + ], + [AS_IF([$dummy_PKG_CONFIG --help 2>&1 | grep -E '(--cflags|--libs)' >/dev/null], + [AC_MSG_RESULT([yes: ${dummy_PKG_CONFIG}]) + have_PKG_CONFIG=yes + PKG_CONFIG="$dummy_PKG_CONFIG" + ], + [AC_MSG_RESULT([no]) + PKG_CONFIG=false + have_PKG_CONFIG=no + ] + )] + )] + ) + + have_PKG_CONFIG_MACROS=no + AS_IF([test x"$have_PKG_CONFIG" = xyes], + [AC_MSG_NOTICE([checking for autoconf macro support of pkg-config (${PKG_CONFIG})]) + dummy_RES=0 + ifdef([PKG_PROG_PKG_CONFIG], [], [dummy_RES=1]) + ifdef([PKG_CHECK_MODULES], [], [dummy_RES=2]) + AS_IF([test "${dummy_RES}" = 0], + [AC_MSG_NOTICE([checking for autoconf macro support of pkg-config module checker]) + dnl The m4 macro below may be not defined if pkg-config package is not + dnl installed. Use of ifdef (here and below for e.g. CPPUNIT check) + dnl allows to avoid shell syntax errors in generated configure script + dnl by defining a dummy macro in-place. + ifdef([PKG_CHECK_MODULES], [], [AC_DEFUN([PKG_CHECK_MODULES], [false])]) + PKG_CHECK_MODULES([dummy_PKG_CONFIG], [pkg-config], [have_PKG_CONFIG_MACROS=yes]) + ] + )] + ) + + AS_IF([test x"$have_PKG_CONFIG" = xno], + [AC_MSG_WARN([pkg-config program is needed to look for further dependencies (will be skipped)]) + PKG_CONFIG="false" + ], + [AS_IF([test x"$have_PKG_CONFIG_MACROS" = xno], + [AC_MSG_WARN([pkg-config macros are needed to look for further dependencies, but in some cases pkg-config program can be used directly])] + )] + ) + + ]) dnl if nut_have_pkg_config_seen +]) diff --git a/m4/nut_check_python.m4 b/m4/nut_check_python.m4 new file mode 100644 index 0000000..6357286 --- /dev/null +++ b/m4/nut_check_python.m4 @@ -0,0 +1,128 @@ +dnl Check for python binary program names per language version +dnl to embed into scripts and Make rules + +AC_DEFUN([NUT_CHECK_PYTHON], +[ + AS_IF([test -z "${nut_with_python}"], [ + NUT_ARG_WITH([python], [Use a particular program name of the python interpeter], [auto]) + + PYTHON="" + AS_CASE([${nut_with_python}], + [auto|yes|""], [AC_CHECK_PROGS([PYTHON], [python python3 python2], [_python_runtime])], + [no], [PYTHON="no"], + [PYTHON="${nut_with_python}"] + ) + + dnl Default to calling a basename from PATH, only use a specific full pathname + dnl if provided by the caller: + AS_CASE([${PYTHON}], + [_python_runtime], [ + PYTHON="/usr/bin/env python" + AC_MSG_WARN([A python program name was not detected during configuration, will default to '$PYTHON' (scripts will fail if that is not in PATH at run time)])], + [no], [], + [/*" "*" "*], [ + AC_MSG_WARN([A python program name is not a single token (was specified with more than one argument?), so shebangs can be not reliable]) + ], + [/*], [], + [*" "*" "*], [ + AC_MSG_WARN([A python program name is not a single token (was specified with more than one argument?), so shebangs can be not reliable]) + PYTHON="/usr/bin/env ${PYTHON}" + ], + [*" "*], [ + AC_MSG_WARN([A python program name is not a single token (was specified with an argument?), so /usr/bin/env shebangs can be not reliable]) + PYTHON="/usr/bin/env ${PYTHON}" + ], + [*], [PYTHON="/usr/bin/env ${PYTHON}"] + ) + + AC_MSG_CHECKING([python interpeter to call]) + AC_MSG_RESULT([${PYTHON}]) + AC_SUBST([PYTHON], [${PYTHON}]) + AM_CONDITIONAL([HAVE_PYTHON], [test "${PYTHON}" != "no"]) + AS_IF([test -n "${PYTHON}"], [export PYTHON]) + ]) +]) + +AC_DEFUN([NUT_CHECK_PYTHON2], +[ + AS_IF([test -z "${nut_with_python2}"], [ + NUT_ARG_WITH([python2], [Use a particular program name of the python2 interpeter for code that needs that version and is not compatible with python3], [auto]) + + PYTHON2="" + AS_CASE([${nut_with_python2}], + [auto|yes|""], [AC_CHECK_PROGS([PYTHON2], [python2 python2.7 python-2.7 python], [_python2_runtime])], + [no], [PYTHON2="no"], + [PYTHON2="${nut_with_python2}"] + ) + + dnl Default to calling a basename from PATH, only use a specific full pathname + dnl if provided by the caller: + AS_CASE([${PYTHON2}], + [_python2_runtime], [ + PYTHON2="/usr/bin/env python2" + AC_MSG_WARN([A python2 program name was not detected during configuration, will default to '$PYTHON2' (scripts will fail if that is not in PATH at run time)])], + [no], [], + [/*" "*" "*], [ + AC_MSG_WARN([A python2 program name is not a single token (was specified with more than one argument?), so shebangs can be not reliable]) + ], + [/*], [], + [*" "*" "*], [ + AC_MSG_WARN([A python2 program name is not a single token (was specified with more than one argument?), so shebangs can be not reliable]) + PYTHON2="/usr/bin/env ${PYTHON2}" + ], + [*" "*], [ + AC_MSG_WARN([A python2 program name is not a single token (was specified with an argument?), so /usr/bin/env shebangs can be not reliable]) + PYTHON2="/usr/bin/env ${PYTHON2}" + ], + [*], [PYTHON2="/usr/bin/env ${PYTHON2}"] + ) + + AC_MSG_CHECKING([python2 interpeter to call]) + AC_MSG_RESULT([${PYTHON2}]) + AC_SUBST([PYTHON2], [${PYTHON2}]) + AM_CONDITIONAL([HAVE_PYTHON2], [test "${PYTHON2}" != "no"]) + AS_IF([test -n "${PYTHON2}"], [export PYTHON2]) + ]) +]) + +AC_DEFUN([NUT_CHECK_PYTHON3], +[ + AS_IF([test -z "${nut_with_python3}"], [ + NUT_ARG_WITH([python3], [Use a particular program name of the python3 interpeter for code that needs that version and is not compatible with python2], [auto]) + + PYTHON3="" + AS_CASE([${nut_with_python3}], + [auto|yes|""], [AC_CHECK_PROGS([PYTHON3], [python3 python3.9 python-3.9 python3.7 python-3.7 python3.5 python-3.5 python], [_python3_runtime])], + [no], [PYTHON3="no"], + [PYTHON3="${nut_with_python3}"] + ) + + dnl Default to calling a basename from PATH, only use a specific full pathname + dnl if provided by the caller: + AS_CASE([${PYTHON3}], + [_python3_runtime], [ + PYTHON3="/usr/bin/env python3" + AC_MSG_WARN([A python3 program name was not detected during configuration, will default to '$PYTHON3' (scripts will fail if that is not in PATH at run time)])], + [no], [], + [/*" "*" "*], [ + AC_MSG_WARN([A python3 program name is not a single token (was specified with more than one argument?), so shebangs can be not reliable]) + ], + [/*], [], + [*" "*" "*], [ + AC_MSG_WARN([A python3 program name is not a single token (was specified with more than one argument?), so shebangs can be not reliable]) + PYTHON3="/usr/bin/env ${PYTHON3}" + ], + [*" "*], [ + AC_MSG_WARN([A python3 program name is not a single token (was specified with an argument?), so /usr/bin/env shebangs can be not reliable]) + PYTHON3="/usr/bin/env ${PYTHON3}" + ], + [*], [PYTHON3="/usr/bin/env ${PYTHON3}"] + ) + + AC_MSG_CHECKING([python3 interpeter to call]) + AC_MSG_RESULT([${PYTHON3}]) + AC_SUBST([PYTHON3], [${PYTHON3}]) + AM_CONDITIONAL([HAVE_PYTHON3], [test "${PYTHON3}" != "no"]) + AS_IF([test -n "${PYTHON3}"], [export PYTHON3]) + ]) +]) diff --git a/m4/nut_compiler_family.m4 b/m4/nut_compiler_family.m4 new file mode 100644 index 0000000..8cdc972 --- /dev/null +++ b/m4/nut_compiler_family.m4 @@ -0,0 +1,241 @@ +dnl detect if current compiler is clang or gcc (or...) + +AC_DEFUN([NUT_COMPILER_FAMILY], +[ + AC_CACHE_CHECK([if CC compiler family is GCC], + [nut_cv_GCC], + [AS_IF([test -n "$CC"], + [AS_IF([$CC --version 2>&1 | grep 'Free Software Foundation' > /dev/null], + [nut_cv_GCC=yes],[nut_cv_GCC=no])], + [AC_MSG_ERROR([CC is not set])] + )]) + + AC_CACHE_CHECK([if CXX compiler family is GCC], + [nut_cv_GXX], + [AS_IF([test -n "$CXX"], + [AS_IF([$CXX --version 2>&1 | grep 'Free Software Foundation' > /dev/null], + [nut_cv_GXX=yes],[nut_cv_GXX=no])], + [AC_MSG_ERROR([CXX is not set])] + )]) + + AC_CACHE_CHECK([if CPP preprocessor family is GCC], + [nut_cv_GPP], + [AS_IF([test -n "$CPP"], + [AS_IF([$CPP --version 2>&1 | grep 'Free Software Foundation' > /dev/null], + [nut_cv_GPP=yes],[nut_cv_GPP=no])], + [AC_MSG_ERROR([CPP is not set])] + )]) + + AS_IF([test "x$GCC" = "x" && test "$nut_cv_GCC" = yes], [GCC=yes]) + AS_IF([test "x$GXX" = "x" && test "$nut_cv_GXX" = yes], [GXX=yes]) + AS_IF([test "x$GPP" = "x" && test "$nut_cv_GPP" = yes], [GPP=yes]) + + AC_CACHE_CHECK([if CC compiler family is clang], + [nut_cv_CLANGCC], + [AS_IF([test -n "$CC"], + [AS_IF([$CC --version 2>&1 | grep -E '(clang version|Apple LLVM version .*clang-)' > /dev/null], + [nut_cv_CLANGCC=yes],[nut_cv_CLANGCC=no])], + [AC_MSG_ERROR([CC is not set])] + )]) + + AC_CACHE_CHECK([if CXX compiler family is clang], + [nut_cv_CLANGXX], + [AS_IF([test -n "$CXX"], + [AS_IF([$CXX --version 2>&1 | grep -E '(clang version|Apple LLVM version .*clang-)' > /dev/null], + [nut_cv_CLANGXX=yes],[nut_cv_CLANGXX=no])], + [AC_MSG_ERROR([CXX is not set])] + )]) + + AC_CACHE_CHECK([if CPP preprocessor family is clang], + [nut_cv_CLANGPP], + [AS_IF([test -n "$CPP"], + [AS_IF([$CPP --version 2>&1 | grep -E '(clang version|Apple LLVM version .*clang-)' > /dev/null], + [nut_cv_CLANGPP=yes],[nut_cv_CLANGPP=no])], + [AC_MSG_ERROR([CPP is not set])] + )]) + + AS_IF([test "x$CLANGCC" = "x" && test "$nut_cv_CLANGCC" = yes], [CLANGCC=yes]) + AS_IF([test "x$CLANGXX" = "x" && test "$nut_cv_CLANGXX" = yes], [CLANGXX=yes]) + AS_IF([test "x$CLANGPP" = "x" && test "$nut_cv_CLANGPP" = yes], [CLANGPP=yes]) +]) + +AC_DEFUN([NUT_CHECK_COMPILE_FLAG], +[ +dnl Note: with this line uncommented, builds report +dnl sed: 0: conftest.c: No such file or directory +dnl so seemingly try to parse the method without args: + dnl### AC_REQUIRE([AX_RUN_OR_LINK_IFELSE]) + +dnl Note: per https://stackoverflow.com/questions/52557417/how-to-check-support-compile-flag-in-autoconf-for-clang +dnl the -Werror below is needed to detect "warnings" about unsupported options + COMPILERFLAG="$1" + +dnl We also try to run an actual build since tools called from that might +dnl complain if they are forwarded unknown flags accepted by the front-end. + SAVED_CFLAGS="$CFLAGS" + SAVED_CXXFLAGS="$CXXFLAGS" + + AC_LANG_PUSH([C]) + AX_CHECK_COMPILE_FLAG([${COMPILERFLAG}], + [CFLAGS="$CFLAGS ${COMPILERFLAG}" + AX_RUN_OR_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [], [CFLAGS="$SAVED_CFLAGS"]) + ], [], [-Werror]) + AC_LANG_POP([C]) + + AC_LANG_PUSH([C++]) + AX_CHECK_COMPILE_FLAG([${COMPILERFLAG}], + [CXXFLAGS="$CXXFLAGS ${COMPILERFLAG}" + AX_RUN_OR_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [], [CXXFLAGS="$SAVED_CXXFLAGS"]) + ], [], [-Werror]) + AC_LANG_POP([C++]) +]) + +AC_DEFUN([NUT_COMPILER_FAMILY_FLAGS], +[ + AC_MSG_NOTICE([Detecting support for additional compiler flags]) + +dnl -Qunused-arguments: +dnl Do not die due to `clang: error: argument unused during compilation: '-I .'` +dnl -Wno-unknown-warning-option: Do not die (on older clang releases) due to +dnl error: unknown warning option '-Wno-double-promotion'; did you mean +dnl '-Wno-documentation'? [-Werror,-Wunknown-warning-option] +dnl -fcolor-diagnostics: help find where bugs are in the wall of text (clang) +dnl -fdiagnostics-color=ARG: help find where bugs are in the wall of text (gcc) + + dnl First check for this to avoid failing on unused include paths etc: + NUT_CHECK_COMPILE_FLAG([-Qunused-arguments]) + + m4_foreach_w([TESTCOMPILERFLAG], [ + -Wno-reserved-identifier + ], [ + NUT_CHECK_COMPILE_FLAG([TESTCOMPILERFLAG]) + ]) + + dnl Note: each m4_foreach_w arg must be named uniquely + dnl Note: Seems -fcolor-diagnostics is clang-only and sometimes + dnl gcc blindly accepts it in test and fails to use later. + AS_IF([test x"${nut_enable_Wcolor}" = xyes], [ + m4_foreach_w([TESTCOMPILERFLAG_COLOR], [ + -fdiagnostics-color=always + ], [ + NUT_CHECK_COMPILE_FLAG([TESTCOMPILERFLAG_COLOR]) + ]) + ], [AC_MSG_NOTICE([NOT checking for options to request colorized compiler output (pass --enable-Wcolor for that)])]) + + dnl Last check for this to avoid accepting anything regardless of support. + dnl NOTE that some toolkit versions accept this option blindly and without + dnl really supporting it (but not erroring out on it, either): + dnl cc1: note: unrecognized command-line option '-Wno-unknown-warning-option' + dnl may have been intended to silence earlier diagnostics + NUT_CHECK_COMPILE_FLAG([-Wno-unknown-warning-option]) + +dnl # Older "brute-forced" settings: +dnl AS_IF([test "x$CLANGCC" = xyes], [CFLAGS="$CFLAGS -Wno-unknown-warning-option"]) +dnl AS_IF([test "x$CLANGXX" = xyes], [CXXFLAGS="$CXXFLAGS -Wno-unknown-warning-option"]) + +dnl # Despite the internet lore, practical GCC versions seen so far +dnl # (4.x-10.x) do not know of this CLI option, with varied results +dnl # from "cc1: note: unrecognized command-line option '-Wno-unknown-warning' +dnl # may have been intended to silence earlier diagnostics" +dnl # to "cc1: error: unrecognized command line option '-Wno-unknown-warning' +dnl # [-Werror]"... so we do not pass it by default: +dnl AS_IF([test "x$GCC" = xyes], [CFLAGS="$CFLAGS -Wno-unknown-warning"]) +dnl AS_IF([test "x$GXX" = xyes], [CXXFLAGS="$CXXFLAGS -Wno-unknown-warning"]) + +dnl # There should be no need to include standard system paths (and possibly +dnl # confuse the compiler assumptions - along with its provided headers)... +dnl # ideally; in practice however cppunit, net-snmp and some system include +dnl # files do cause grief to picky compiler settings (more so from third +dnl # party packages shipped via /usr/local/... namespace): + AS_IF([test "x$CLANGCC" = xyes -o "x$GCC" = xyes], [ +dnl # CFLAGS="-isystem /usr/include $CFLAGS" + AS_IF([test -d /usr/local/include], + [CFLAGS="-isystem /usr/local/include $CFLAGS"]) + AS_IF([test -d /usr/pkg/include], + [CFLAGS="-isystem /usr/pkg/include $CFLAGS"]) + ]) + AS_IF([test "x$CLANGXX" = xyes -o "x$GXX" = xyes], [ +dnl # CXXFLAGS="-isystem /usr/include $CXXFLAGS" + AS_IF([test -d /usr/local/include], + [CXXFLAGS="-isystem /usr/local/include $CXXFLAGS"]) + AS_IF([test -d /usr/pkg/include], + [CXXFLAGS="-isystem /usr/pkg/include $CXXFLAGS"]) + ]) + +dnl # Default to avoid noisy warnings on older compilers +dnl # (gcc-4.x, clang-3.x) due to their preference of +dnl # ANSI C (C89/C90) out of the box. While NUT codebase +dnl # currently can build in that mode, reliability of +dnl # results is uncertain - third-party and/or system +dnl # headers and libs seemingly no longer care for C90 +dnl # on modern systems, and we have no recent data from +dnl # truly legacy systems which have no choice. +dnl # Some distributions and platforms also have problems +dnl # building in "strict C" mode, so for the GNU-compatible +dnl # compilers we default to the GNU C/C++ dialects. + AS_IF([test "x$GCC" = xyes -o "x$CLANGCC" = xyes], + [AS_CASE(["${CFLAGS}"], [-std=*], [], + [AC_LANG_PUSH([C]) + AX_CHECK_COMPILE_FLAG([-std=gnu99], + [AC_MSG_NOTICE([Defaulting C standard support to GNU C99 on a GCC or CLANG compatible compiler]) + CFLAGS="$CFLAGS -std=gnu99" + ], [], [-Werror]) + AC_LANG_POP([C]) + ]) + ]) + +dnl # Note: this might upset some very old compilers +dnl # but then by default we wouldn't build C++ parts + AS_IF([test "x$GCC" = xyes -o "x$CLANGCC" = xyes], + [AS_CASE(["${CXXFLAGS}"], [-std=*], [], + [AC_LANG_PUSH([C++]) + AX_CHECK_COMPILE_FLAG([-std=gnu++11], + [AC_MSG_NOTICE([Defaulting C++ standard support to GNU C++11 on a GCC or CLANG compatible compiler]) + CXXFLAGS="$CXXFLAGS -std=gnu++11" + ], [], [-Werror]) + AC_LANG_POP([C++]) + ]) + ]) + +]) + +AC_DEFUN([NUT_COMPILER_FAMILY_FLAGS_DEFAULT_STANDARD], +[ +dnl # Default to avoid noisy warnings on older compilers +dnl # (gcc-4.x, clang-3.x) due to their preference of +dnl # ANSI C (C89/C90) out of the box. While NUT codebase +dnl # currently can build in that mode, reliability of +dnl # results is uncertain - third-party and/or system +dnl # headers and libs seemingly no longer care for C90 +dnl # on modern systems, and we have no recent data from +dnl # truly legacy systems which have no choice. +dnl # Some distributions and platforms also have problems +dnl # building in "strict C" mode, so for the GNU-compatible +dnl # compilers we default to the GNU C/C++ dialects. + AS_IF([test "x$GCC" = xyes -o "x$CLANGCC" = xyes], + [AS_CASE(["${CFLAGS}"], [*-std=*], [], + [AC_LANG_PUSH([C]) + AX_CHECK_COMPILE_FLAG([-std=gnu99], + [AC_MSG_NOTICE([Defaulting C standard support to GNU C99 on a GCC or CLANG compatible compiler]) + CFLAGS="$CFLAGS -std=gnu99" + ], [], [-Werror]) + AC_LANG_POP([C]) + ]) + ]) + +dnl # Note: this might upset some very old compilers +dnl # but then by default we wouldn't build C++ parts + AS_IF([test "x$GCC" = xyes -o "x$CLANGCC" = xyes], + [AS_CASE(["${CXXFLAGS}"], [*-std=*], [], + [AC_LANG_PUSH([C++]) + AX_CHECK_COMPILE_FLAG([-std=gnu++11], + [AC_MSG_NOTICE([Defaulting C++ standard support to GNU C++11 on a GCC or CLANG compatible compiler]) + CXXFLAGS="$CXXFLAGS -std=gnu++11" + ], [], [-Werror]) + AC_LANG_POP([C++]) + ]) + ]) + +]) diff --git a/m4/nut_func_getnameinfo_argtypes.m4 b/m4/nut_func_getnameinfo_argtypes.m4 new file mode 100644 index 0000000..8f32c42 --- /dev/null +++ b/m4/nut_func_getnameinfo_argtypes.m4 @@ -0,0 +1,96 @@ +dnl This code was lifted and adapted for NUT from cURL project: +dnl https://github.com/curl/curl/blob/e3657644d695373e9cf9ab9b4f1571afda7fd041/acinclude.m4#L228 + +dnl NUT_FUNC_GETNAMEINFO_ARGTYPES +dnl ------------------------------------------------- +dnl Check the type to be passed to five of the arguments +dnl of getnameinfo function, and define those types in +dnl macros GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2, +dnl GETNAMEINFO_TYPE_ARG46 (4 and 6) and GETNAMEINFO_TYPE_ARG7. +dnl As seen from the loop, these vary a lot between OSes... +dnl Order of attempts in the loop below was updated to first +dnl try and quickly match current X/Open definition at +dnl https://pubs.opengroup.org/onlinepubs/9699919799/functions/getnameinfo.html +dnl for modern conforming OSes. + +AC_DEFUN([NUT_FUNC_GETNAMEINFO_ARGTYPES], [ + AC_REQUIRE([NUT_CHECK_HEADER_WS2TCPIP])dnl + AC_REQUIRE([NUT_TYPE_SOCKLEN_T])dnl + AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h) + AC_LANG_PUSH([C]) + AC_CACHE_CHECK([types of arguments for getnameinfo], + [nut_cv_func_getnameinfo_args], [ + nut_cv_func_getnameinfo_args="unknown" + for gni_arg1 in 'const struct sockaddr *' 'struct sockaddr *' 'void *'; do + for gni_arg2 in 'socklen_t' 'size_t' 'int'; do + for gni_arg46 in 'socklen_t' 'size_t' 'int' 'unsigned int'; do + for gni_arg7 in 'int' 'unsigned int'; do + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ +#undef inline +#ifdef HAVE_WINDOWS_H +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501) +# undef _WIN32_WINNT +# define _WIN32_WINNT 0x0501 +# endif +# include +# ifdef HAVE_WINSOCK2_H +# include +# ifdef HAVE_WS2TCPIP_H +# include +# endif +# endif +# define GNICALLCONV WSAAPI +#else +# ifdef HAVE_SYS_TYPES_H +# include +# endif +# ifdef HAVE_SYS_SOCKET_H +# include +# endif +# ifdef HAVE_NETDB_H +# include +# endif +# define GNICALLCONV +#endif + extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2, + char *, $gni_arg46, + char *, $gni_arg46, + $gni_arg7); + ],[ + $gni_arg2 salen=0; + $gni_arg46 hostlen=0; + $gni_arg46 servlen=0; + $gni_arg7 flags=0; + int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags); + ]) + ],[ + nut_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7" + break 4 + ]) + done + done + done + done + ]) + AC_LANG_POP([C]) + if test "$nut_cv_func_getnameinfo_args" = "unknown"; then + AC_MSG_WARN([Cannot find proper types to use for getnameinfo args]) + else + gni_prev_IFS=$IFS; IFS=',' + set dummy `echo "$nut_cv_func_getnameinfo_args" | sed 's/\*/\*/g'` + IFS=$gni_prev_IFS + shift + AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $[1], + [Define to the type of arg 1 for getnameinfo.]) + AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2], + [Define to the type of arg 2 for getnameinfo.]) + AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3], + [Define to the type of args 4 and 6 for getnameinfo.]) + AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4], + [Define to the type of arg 7 for getnameinfo.]) + fi +]) diff --git a/m4/nut_report_feature.m4 b/m4/nut_report_feature.m4 index f6f35b7..72667ba 100644 --- a/m4/nut_report_feature.m4 +++ b/m4/nut_report_feature.m4 @@ -30,4 +30,13 @@ AC_DEFUN([NUT_REPORT_FEATURE], AC_DEFUN([NUT_PRINT_FEATURE_REPORT], [ cat conf_nut_report_feature + + echo "------------------" + echo "Compiler settings:" + printf 'CC \t:%s\n' "$CC" + printf 'CFLAGS \t:%s\n' "$CFLAGS" + printf 'CXX \t:%s\n' "$CXX" + printf 'CXXFLAGS\t:%s\n' "$CXXFLAGS" + printf 'CPP \t:%s\n' "$CPP" + printf 'CPPFLAGS\t:%s\n' "$CPPFLAGS" ]) diff --git a/m4/nut_stash_warnings.m4 b/m4/nut_stash_warnings.m4 new file mode 100644 index 0000000..069d6b0 --- /dev/null +++ b/m4/nut_stash_warnings.m4 @@ -0,0 +1,77 @@ +dnl Callers like CI or developers can enable various warning flags +dnl including those that would be fatal to the configure script +dnl itself passing (autotools probing code is rather sloppy by +dnl strict standards). These routines try to stash away the warning +dnl flags from CFLAGS and CXXFLAGS passed by user, to re-apply in +dnl the end of configure script run. + +AC_DEFUN([NUT_STASH_WARNINGS], +[ + dnl WARNING: This code assumes that there are no whitespaces + dnl inside C*FLAGS values (e.g. no spacey include paths) + CFLAGS_STASHED_WARNINGS="" + CPPFLAGS_STASHED_WARNINGS="" + CXXFLAGS_STASHED_WARNINGS="" + + AS_IF([test -z "$CFLAGS"],[],[ + TMP="" + for V in ${CFLAGS} ; do + case "$V" in + -W*|-*pedantic*) CFLAGS_STASHED_WARNINGS="${CFLAGS_STASHED_WARNINGS} ${V}" ;; + *) TMP="${TMP} ${V}" ;; + esac + done + CFLAGS="$TMP" + ]) + AS_IF([test -n "${CFLAGS_STASHED_WARNINGS}"], + [AC_MSG_NOTICE([Stashed CFLAGS warnings to not confuse autotools probes: ${CFLAGS_STASHED_WARNINGS}])]) + + AS_IF([test -z "$CPPFLAGS"],[],[ + TMP="" + for V in ${CPPFLAGS} ; do + case "$V" in + -W*|-*pedantic*) CPPFLAGS_STASHED_WARNINGS="${CPPFLAGS_STASHED_WARNINGS} ${V}" ;; + *) TMP="${TMP} ${V}" ;; + esac + done + CPPFLAGS="$TMP" + ]) + AS_IF([test -n "${CPPFLAGS_STASHED_WARNINGS}"], + [AC_MSG_NOTICE([Stashed CPPFLAGS warnings to not confuse autotools probes: ${CPPFLAGS_STASHED_WARNINGS}])]) + + + AS_IF([test -z "$CXXFLAGS"],[],[ + TMP="" + for V in ${CXXFLAGS} ; do + case "$V" in + -W*|-*pedantic*) CXXFLAGS_STASHED_WARNINGS="${CXXFLAGS_STASHED_WARNINGS} ${V}" ;; + *) TMP="${TMP} ${V}" ;; + esac + done + CXXFLAGS="$TMP" + ]) + AS_IF([test -n "${CXXFLAGS_STASHED_WARNINGS}"], + [AC_MSG_NOTICE([Stashed CXXFLAGS warnings to not confuse autotools probes: ${CXXFLAGS_STASHED_WARNINGS}])]) + +]) + +AC_DEFUN([NUT_POP_WARNINGS], +[ + AS_IF([test -n "${CFLAGS_STASHED_WARNINGS}"],[ + AC_MSG_NOTICE([Applying back the stashed CFLAGS warnings]) + CFLAGS="${CFLAGS} ${CFLAGS_STASHED_WARNINGS}" + AC_MSG_NOTICE([Ended up with: '${CFLAGS}']) + ]) + + AS_IF([test -n "${CPPFLAGS_STASHED_WARNINGS}"],[ + AC_MSG_NOTICE([Applying back the stashed CPPFLAGS warnings]) + CPPFLAGS="${CPPFLAGS} ${CPPFLAGS_STASHED_WARNINGS}" + AC_MSG_NOTICE([Ended up with: '${CPPFLAGS}']) + ]) + + AS_IF([test -n "${CXXFLAGS_STASHED_WARNINGS}"],[ + AC_MSG_NOTICE([Applying back the stashed CXXFLAGS warnings]) + CXXFLAGS="${CXXFLAGS} ${CXXFLAGS_STASHED_WARNINGS}" + AC_MSG_NOTICE([Ended up with: '${CXXFLAGS}']) + ]) +]) diff --git a/m4/nut_type_socklen_t.m4 b/m4/nut_type_socklen_t.m4 index 0cbf4b3..205a5f9 100644 --- a/m4/nut_type_socklen_t.m4 +++ b/m4/nut_type_socklen_t.m4 @@ -7,29 +7,65 @@ dnl This code gets around. This instance came from rsync 2.5.6. AC_DEFUN([NUT_TYPE_SOCKLEN_T], [ + AC_REQUIRE([NUT_CHECK_HEADER_WS2TCPIP])dnl + HEADERS_SOCKLEN_T=' +#undef inline +#ifdef HAVE_WINDOWS_H +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501) +# undef _WIN32_WINNT +# define _WIN32_WINNT 0x0501 +# endif +# include +# ifdef HAVE_WINSOCK2_H +# include +# ifdef HAVE_WS2TCPIP_H +# include +# endif +# endif +# define GNICALLCONV WSAAPI +# define GNICALLLINK WINSOCK_API_LINKAGE +#else +# ifdef HAVE_SYS_TYPES_H +# include +# endif +# ifdef HAVE_SYS_SOCKET_H +# include +# endif +# ifdef HAVE_NETDB_H +# include +# endif +# define GNICALLCONV +# define GNICALLLINK +#endif +' AC_CHECK_TYPE([socklen_t], ,[ AC_MSG_CHECKING([for socklen_t equivalent]) AC_CACHE_VAL([nut_cv_socklen_t_equiv], [ # Systems have either "struct sockaddr *" or # "void *" as the second argument to getpeername + AC_LANG_PUSH([C]) nut_cv_socklen_t_equiv= - for arg2 in "struct sockaddr" void; do - for t in int size_t unsigned long "unsigned long"; do - AC_TRY_COMPILE([ -#include -#include - - int getpeername (int, $arg2 *, $t *); - ],[ - $t len; + for arg1 in "int" "SOCKET"; do + for arg2 in "struct sockaddr" void; do + for arg3 in int size_t unsigned long "unsigned long"; do + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([${HEADERS_SOCKLEN_T} + GNICALLLINK int GNICALLCONV getpeername ($arg1, $arg2 *, $arg3 *); + ],[ + $arg3 len; getpeername(0,0,&len); - ],[ - nut_cv_socklen_t_equiv="$t" + ])], + [ + nut_cv_socklen_t_equiv="$arg3" break ]) done + done done + AC_LANG_POP([C]) if test "x$nut_cv_socklen_t_equiv" = x; then AC_MSG_ERROR([Cannot find a type to use in place of socklen_t]) @@ -38,6 +74,5 @@ AC_DEFUN([NUT_TYPE_SOCKLEN_T], AC_MSG_RESULT($nut_cv_socklen_t_equiv) AC_DEFINE_UNQUOTED(socklen_t, $nut_cv_socklen_t_equiv, [type to use in place of socklen_t if not defined])], - [#include -#include ]) + [${HEADERS_SOCKLEN_T}]) ]) diff --git a/missing b/missing index db98974..8d0eaad 100755 --- a/missing +++ b/missing @@ -1,9 +1,9 @@ #! /bin/sh # Common wrapper for a few potentially missing GNU programs. -scriptversion=2013-10-28.13; # UTC +scriptversion=2018-03-07.03; # UTC -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2020 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify @@ -17,7 +17,7 @@ scriptversion=2013-10-28.13; # UTC # GNU General Public License for more details. # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -101,9 +101,9 @@ else exit $st fi -perl_URL=http://www.perl.org/ -flex_URL=http://flex.sourceforge.net/ -gnu_software_URL=http://www.gnu.org/software +perl_URL=https://www.perl.org/ +flex_URL=https://github.com/westes/flex +gnu_software_URL=https://www.gnu.org/software program_details () { @@ -207,9 +207,9 @@ give_advice "$1" | sed -e '1s/^/WARNING: /' \ exit $st # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: diff --git a/scripts/Aix/nut.init.in b/scripts/Aix/nut.init.in new file mode 100755 index 0000000..018777e --- /dev/null +++ b/scripts/Aix/nut.init.in @@ -0,0 +1,171 @@ +#! /bin/sh +# +# ups: Starts the Network UPS Tools +# +# chkconfig: - 26 74 +# description: Network UPS Tools is a collection of programs which provide a common \ +# interface for monitoring and administering UPS hardware. +# processname: upsd +# config: /usr/local/ups/etc +# config: /etc/rc.ups +# +### BEGIN INIT INFO +# Provides: ups +# Required-Start: $syslog $network $named +# Required-Stop: $local_fs +# Default-Stop: 0 1 6 +# Short-Description: Starts the Network UPS tools +# Description: Network UPS Tools is a collection of programs which provide a common \ +# interface for monitoring and administering UPS hardware. +### END INIT INFO + +success() { + echo OK +} + +failure() { + echo FAILED +} + +# Resolve what processes should run +SERVER="no" +CLIENT="no" + +NUT_DIR="@prefix@" +NUT_SBIN_DIR="${NUT_DIR}/sbin" +NUT_LIB_DIR="${NUT_DIR}/lib" +NUT_RUN_DIR="@PIDPATH@/nut" +CONFIG="@CONFPATH@/nut.conf" +NUTUSER="@RUN_AS_USER@" +NUTGROUP="@RUN_AS_GROUP@" +NUT_VAR_LOCK="/var/locks/ups" + +if [ -f "$CONFIG" ] ; then + . "$CONFIG" + + case "$MODE" in + standalone|netserver) + SERVER="yes" + ;; + esac + + rpm -q nut-client >/dev/null 2>&1 && CLIENT="yes" +fi + +do_start() { + RETVAL=0 + + if [ ! -d "$NUT_RUN_DIR" ]; then + mkdir -p "$NUT_RUN_DIR" && \ + chown "root:$NUTGROUP" "$NUT_RUN_DIR" && \ + chmod 770 "$NUT_RUN_DIR" + RETVAL=$? + fi + + if [ "$SERVER" = "yes" ]; then + echo "Starting UPS driver controller: \c" + LD_LIBRARY_PATH="${NUT_LIB_DIR}:$LD_LIBRARY_PATH" "${NUT_SBIN_DIR}"/upsdrvctl start >/dev/null 2>&1 && success || { RETVAL=$?; failure; } + + echo "Starting upsd: \c" + LD_LIBRARY_PATH="${NUT_LIB_DIR}:$LD_LIBRARY_PATH" "${NUT_SBIN_DIR}"/upsd $UPSD_OPTIONS >/dev/null 2>&1 && success || { RETVAL=$?; failure; } + fi + + if [ "$CLIENT" = "yes" ]; then + echo "Starting UPS monitor: \c" + LD_LIBRARY_PATH="${NUT_LIB_DIR}:$LD_LIBRARY_PATH" "${NUT_SBIN_DIR}"/upsmon >/dev/null 2>&1 && success || { RETVAL=$?; failure; } + fi + + [ "$RETVAL" = 0 ] && touch "${NUT_VAR_LOCK}" + return $RETVAL +} + +do_stop() { + RETVAL=0 + if test -e "${NUT_RUN_DIR}"/upsmon.pid; then + echo "Stopping UPS monitor: \c" + PID="`cat "${NUT_RUN_DIR}"/upsmon.pid`" + kill -15 $PID && success || { RETVAL=$?; failure; } + rm "${NUT_RUN_DIR}"/upsmon.pid + fi + + if [ "$SERVER" = "yes" ]; then + if test -e "${NUT_RUN_DIR}"/upsd.pid; then + echo "Stopping upsd: \c" + PID="`cat "${NUT_RUN_DIR}"/upsd.pid`" + kill -15 $PID && success || { RETVAL=$?; failure; } + rm "${NUT_RUN_DIR}"/upsd.pid + fi + + echo "Shutting down UPS driver controller: \c" + "${NUT_SBIN_DIR}"/upsdrvctl stop > /dev/null 2>&1 && success || { RETVAL=$?; failure; } + fi + [ "$RETVAL" = 0 ] && rm -f "${NUT_VAR_LOCK}" + return $RETVAL +} + +do_restart() { + do_stop + waitmore=5 + while [ -n "$(ls "${NUT_RUN_DIR}"/)" -a $waitmore -ge 1 ] + do + sleep 1 + waitmore="$(expr $waitmore - 1)" + done + do_start +} + +do_reload() { + # FIXME: upsd and upsmon always return 0 + # => can't tell if reload was successful + RETVAL=0 + if [ "$SERVER" = "yes" ]; then + echo "Reloading upsd" + LD_LIBRARY_PATH="${NUT_LIB_DIR}:$LD_LIBRARY_PATH" "${NUT_SBIN_DIR}"/upsd -c reload && success || { RETVAL=$?; failure; } + fi + + echo "Reloading upsmon" + LD_LIBRARY_PATH="${NUT_LIB_DIR}:$LD_LIBRARY_PATH" "${NUT_SBIN_DIR}"/upsmon -c reload && success || { RETVAL=$?; failure; } + return $RETVAL +} + +# See how we are called. +case "$1" in + start) + do_start ;; + + stop) + do_stop ;; + + restart) + do_restart ;; + + try-restart) + [ -f "${NUT_VAR_LOCK}" ] && do_restart || true + ;; + + reload) + do_reload ;; + + force-reload) + do_restart ;; + + status) + if [ "$SERVER" = "yes" ]; then + if test -f "${NUT_VAR_LOCK}"; then + echo "upsd is running with PID" `cat "${NUT_RUN_DIR}"/upsd.pid` + fi + fi + + if test -e "${NUT_RUN_DIR}"/upsmon.pid; then + echo "upsmon is running with PID" `cat "${NUT_RUN_DIR}"/upsmon.pid` + elif rpm -q nut-client >/dev/null 2>&1; then + echo "upsmon isn't running" + fi + ;; + + *) + echo "Usage: $0 {start|stop|restart|try-restart|reload|force-reload|status}" + RETVAL=3 +esac + +exit $RETVAL diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 8e84e24..ef6a1dd 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -25,4 +25,6 @@ EXTRA_DIST = README \ Windows/halt.c \ Windows/Makefile -SUBDIRS = augeas devd hotplug python systemd udev Solaris +SUBDIRS = augeas devd hotplug python systemd udev ufw Solaris upsdrvsvcctl + +MAINTAINERCLEANFILES = Makefile.in .dirstamp diff --git a/scripts/Makefile.in b/scripts/Makefile.in index 65ff56c..def2e6a 100644 --- a/scripts/Makefile.in +++ b/scripts/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.16.3 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,18 +89,24 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = scripts -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am README ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nut_arg_with.m4 \ $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ $(top_srcdir)/m4/nut_check_libavahi.m4 \ $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ $(top_srcdir)/m4/nut_check_libgd.m4 \ $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ $(top_srcdir)/m4/nut_check_libneon.m4 \ $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ $(top_srcdir)/m4/nut_check_libnss.m4 \ @@ -99,11 +115,17 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ $(top_srcdir)/m4/nut_check_libusb.m4 \ $(top_srcdir)/m4/nut_check_libwrap.m4 \ $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ $(top_srcdir)/m4/nut_type_socklen_t.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = @@ -142,7 +164,7 @@ am__recursive_targets = \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - distdir + distdir distdir-am am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is @@ -163,6 +185,7 @@ am__define_uniq_tagged_files = \ ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) +am__DIST_COMMON = $(srcdir)/Makefile.in README DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ @@ -196,6 +219,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -206,6 +230,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -219,6 +244,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -231,6 +257,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -248,6 +275,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -258,21 +287,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -292,6 +329,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -305,6 +345,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -322,6 +363,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -335,6 +377,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -360,12 +405,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -402,7 +449,8 @@ EXTRA_DIST = README \ Windows/halt.c \ Windows/Makefile -SUBDIRS = augeas devd hotplug python systemd udev Solaris +SUBDIRS = augeas devd hotplug python systemd udev ufw Solaris upsdrvsvcctl +MAINTAINERCLEANFILES = Makefile.in .dirstamp all: all-recursive .SUFFIXES: @@ -418,14 +466,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu scripts/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu scripts/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -542,7 +589,10 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -632,6 +682,7 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am @@ -713,6 +764,8 @@ uninstall-am: mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags tags-am uninstall uninstall-am +.PRECIOUS: Makefile + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/scripts/Solaris/Makefile.am b/scripts/Solaris/Makefile.am index 15075b0..1544c79 100644 --- a/scripts/Solaris/Makefile.am +++ b/scripts/Solaris/Makefile.am @@ -1,17 +1,88 @@ -EXTRA_DIST = makelocal.sh +EXTRA_DIST = makelocal.sh precheck.py.in preproto.pl.in README +PROTOTYPE_DIR = $(DESTDIR)@prefix@ +SOLARIS_CHECK_TARGETS = +PYTHON = @PYTHON@ -package: makelocal.sh pkginfo - $ cd @prefix@; $ find . -print | pkgproto > prototype1 - $ cp makelocal.sh precheck.py pkginfo nut preinstall postinstall preremove postremove preproto.pl @prefix@ - $ cd @prefix@; perl preproto.pl - $ cd @prefix@; python precheck.py - $ cd @prefix@; rm -f prototype1 - $ cd @prefix@; ./makelocal.sh - $ cp @prefix@/*.gz $(srcdir) - if test `uname -p` = "i386"; then \ - mv NUT_solaris_package.local.gz NUT_solaris_i386_package@PACKAGE_VERSION@.local.gz; \ - else \ - if test `uname -p` = "sparc"; then \ - mv NUT_solaris_package.local.gz NUT_solaris_sparc_package@PACKAGE_VERSION@.local.gz; \ - fi; \ - fi; +SOLARIS_SMF_MANIFESTS = \ + nut.xml \ + nut-server.xml \ + nut-monitor.xml \ + nut-driver.xml \ + nut-driver-enumerator.xml + +SOLARIS_SMF_METHODSCRIPTS = \ + svc-nut-server \ + svc-nut-monitor + +if WITH_SOLARIS_SMF +# OS equivalent of /lib/svc/method and /var/svc/manifest/application +# but we can just use then from this location +solarissmfmethoddir = @datadir@/solaris-smf/method +solarissmfmanifestdir = @datadir@/solaris-smf/manifest +solarissmfmethod_SCRIPTS = $(SOLARIS_SMF_METHODSCRIPTS) +solarissmfmanifest_DATA = $(SOLARIS_SMF_MANIFESTS) + +libexec_SCRIPTS = ../upsdrvsvcctl/nut-driver-enumerator.sh + +sbin_SCRIPTS = ../upsdrvsvcctl/upsdrvsvcctl + +SOLARIS_CHECK_TARGETS += check-local-solaris-smf +endif + +solarisinitscriptdir = @datadir@/solaris-init +solarisinitscript_SCRIPTS = nut + +SOLARIS_PACKAGE_TARGETS = + +if WITH_SOLARIS_PKG_IPS +SOLARIS_PACKAGE_TARGETS += package-solaris-ips +endif + +if WITH_SOLARIS_PKG_SVR4 +SOLARIS_PACKAGE_TARGETS += package-solaris-svr4 +endif + +package: $(SOLARIS_PACKAGE_TARGETS) + +# TODO: Reduce build dependencies (implicit!) on python and perl +# by shelling the scripts used below +# NOTE: This assumes the rest of the product has already been built +# and installed under PROTOTYPE_DIR, but declares no explicit +# dependency on that +SOLARIS_PACKAGE_SVR4_HELPERSCRIPTS = makelocal.sh precheck.py preproto.pl +SOLARIS_PACKAGE_SVR4_INSTALLSCRIPTS = preinstall postinstall preremove postremove +SOLARIS_PACKAGE_SVR4_INSTALLDATA = pkginfo +package-solaris-svr4: $(SOLARIS_PACKAGE_SVR4_HELPERSCRIPTS) $(SOLARIS_PACKAGE_SVR4_INSTALLSCRIPTS) $(SOLARIS_PACKAGE_SVR4_INSTALLDATA) + if test -n "@auglensdir@" && test -d "$(DESTDIR)@auglensdir@" ; then \ + mkdir -p "$(DESTDIR)@datadir@/augeas-lenses" && \ + cd "$(DESTDIR)@auglensdir@" && \ + ( cp -prf ./ "$(DESTDIR)@datadir@/augeas-lenses/" || cp -rf ./ "$(DESTDIR)@datadir@/augeas-lenses/" ) ; fi + cd $(PROTOTYPE_DIR) && find . -print | pkgproto > prototype1 + cp $(SOLARIS_PACKAGE_SVR4_HELPERSCRIPTS) $(SOLARIS_PACKAGE_SVR4_INSTALLSCRIPTS) $(SOLARIS_PACKAGE_SVR4_INSTALLDATA) $(PROTOTYPE_DIR) + cd $(PROTOTYPE_DIR) && chmod +x $(SOLARIS_PACKAGE_SVR4_HELPERSCRIPTS) $(SOLARIS_PACKAGE_SVR4_INSTALLSCRIPTS) + cd $(PROTOTYPE_DIR) && perl preproto.pl +if HAVE_PYTHON + cd $(PROTOTYPE_DIR) && $(PYTHON) precheck.py +endif + cd $(PROTOTYPE_DIR) && rm -f prototype1 + cd $(PROTOTYPE_DIR) && ./makelocal.sh + cp $(PROTOTYPE_DIR)/*.gz $(builddir) + UNAME_P="`uname -p`" && case "$${UNAME_P}" in \ + i386|sparc) \ + mv -f NUT_solaris_package.local.gz "$(abs_top_builddir)/NUT_solaris_$${UNAME_P}_package@PACKAGE_VERSION@.local.gz" ;; \ + esac + +# TODO: Define support for IPS packaging (provide p5m files and make rules) +package-solaris-ips: + @echo "SKIPPED : Target $@ is not implemented yet" + +check-local: $(SOLARIS_CHECK_TARGETS) + +check-local-solaris-smf: $(SOLARIS_SMF_MANIFESTS) + @[ -x /usr/sbin/svccfg ] || { echo "WARNING : Target $@ skipped due to absent /usr/sbin/svccfg" >&2; return 0; } ; \ + RES=0 ; for F in $^ ; do \ + echo " SVCCFG-VALIDATE $$F"; \ + /usr/sbin/svccfg validate "$$F" || RES=$$? ; \ + done; exit $$RES + +MAINTAINERCLEANFILES = Makefile.in .dirstamp diff --git a/scripts/Solaris/Makefile.in b/scripts/Solaris/Makefile.in index 9a1f124..b618339 100644 --- a/scripts/Solaris/Makefile.in +++ b/scripts/Solaris/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.16.3 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -13,8 +13,20 @@ # PARTICULAR PURPOSE. @SET_MAKE@ + + VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -78,21 +90,28 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ +@WITH_SOLARIS_SMF_TRUE@am__append_1 = check-local-solaris-smf +@WITH_SOLARIS_PKG_IPS_TRUE@am__append_2 = package-solaris-ips +@WITH_SOLARIS_PKG_SVR4_TRUE@am__append_3 = package-solaris-svr4 subdir = scripts/Solaris -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(srcdir)/pkginfo.in $(srcdir)/postinstall.in \ - $(srcdir)/preremove.in $(srcdir)/nut.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nut_arg_with.m4 \ $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ $(top_srcdir)/m4/nut_check_libavahi.m4 \ $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ $(top_srcdir)/m4/nut_check_libgd.m4 \ $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ $(top_srcdir)/m4/nut_check_libneon.m4 \ $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ $(top_srcdir)/m4/nut_check_libnss.m4 \ @@ -101,15 +120,57 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ $(top_srcdir)/m4/nut_check_libusb.m4 \ $(top_srcdir)/m4/nut_check_libwrap.m4 \ $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ $(top_srcdir)/m4/nut_type_socklen_t.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/config.h -CONFIG_CLEAN_FILES = pkginfo postinstall preremove nut +CONFIG_CLEAN_FILES = nut-driver-enumerator.xml nut-driver.xml \ + nut-monitor.xml nut-server.xml nut.xml pkginfo svc-nut-server \ + svc-nut-monitor precheck.py preinstall postinstall preremove \ + postremove preproto.pl nut CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(sbindir)" \ + "$(DESTDIR)$(solarisinitscriptdir)" \ + "$(DESTDIR)$(solarissmfmethoddir)" \ + "$(DESTDIR)$(solarissmfmanifestdir)" +SCRIPTS = $(libexec_SCRIPTS) $(sbin_SCRIPTS) \ + $(solarisinitscript_SCRIPTS) $(solarissmfmethod_SCRIPTS) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -129,7 +190,18 @@ am__can_run_installinfo = \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac +DATA = $(solarissmfmanifest_DATA) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in \ + $(srcdir)/nut-driver-enumerator.xml.in \ + $(srcdir)/nut-driver.xml.in $(srcdir)/nut-monitor.xml.in \ + $(srcdir)/nut-server.xml.in $(srcdir)/nut.in \ + $(srcdir)/nut.xml.in $(srcdir)/pkginfo.in \ + $(srcdir)/postinstall.in $(srcdir)/postremove.in \ + $(srcdir)/precheck.py.in $(srcdir)/preinstall.in \ + $(srcdir)/preproto.pl.in $(srcdir)/preremove.in \ + $(srcdir)/svc-nut-monitor.in $(srcdir)/svc-nut-server.in \ + README DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) A2X = @A2X@ ACLOCAL = @ACLOCAL@ @@ -138,6 +210,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -148,6 +221,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -161,6 +235,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -173,6 +248,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -190,6 +266,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -200,21 +278,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -234,6 +320,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -247,6 +336,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -264,6 +354,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -277,6 +368,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -302,12 +396,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -317,7 +413,42 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ udevdir = @udevdir@ -EXTRA_DIST = makelocal.sh +EXTRA_DIST = makelocal.sh precheck.py.in preproto.pl.in README +PROTOTYPE_DIR = $(DESTDIR)@prefix@ +SOLARIS_CHECK_TARGETS = $(am__append_1) +SOLARIS_SMF_MANIFESTS = \ + nut.xml \ + nut-server.xml \ + nut-monitor.xml \ + nut-driver.xml \ + nut-driver-enumerator.xml + +SOLARIS_SMF_METHODSCRIPTS = \ + svc-nut-server \ + svc-nut-monitor + + +# OS equivalent of /lib/svc/method and /var/svc/manifest/application +# but we can just use then from this location +@WITH_SOLARIS_SMF_TRUE@solarissmfmethoddir = @datadir@/solaris-smf/method +@WITH_SOLARIS_SMF_TRUE@solarissmfmanifestdir = @datadir@/solaris-smf/manifest +@WITH_SOLARIS_SMF_TRUE@solarissmfmethod_SCRIPTS = $(SOLARIS_SMF_METHODSCRIPTS) +@WITH_SOLARIS_SMF_TRUE@solarissmfmanifest_DATA = $(SOLARIS_SMF_MANIFESTS) +@WITH_SOLARIS_SMF_TRUE@libexec_SCRIPTS = ../upsdrvsvcctl/nut-driver-enumerator.sh +@WITH_SOLARIS_SMF_TRUE@sbin_SCRIPTS = ../upsdrvsvcctl/upsdrvsvcctl +solarisinitscriptdir = @datadir@/solaris-init +solarisinitscript_SCRIPTS = nut +SOLARIS_PACKAGE_TARGETS = $(am__append_2) $(am__append_3) + +# TODO: Reduce build dependencies (implicit!) on python and perl +# by shelling the scripts used below +# NOTE: This assumes the rest of the product has already been built +# and installed under PROTOTYPE_DIR, but declares no explicit +# dependency on that +SOLARIS_PACKAGE_SVR4_HELPERSCRIPTS = makelocal.sh precheck.py preproto.pl +SOLARIS_PACKAGE_SVR4_INSTALLSCRIPTS = preinstall postinstall preremove postremove +SOLARIS_PACKAGE_SVR4_INSTALLDATA = pkginfo +MAINTAINERCLEANFILES = Makefile.in .dirstamp all: all-am .SUFFIXES: @@ -333,14 +464,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu scripts/Solaris/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu scripts/Solaris/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -351,20 +481,203 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): +nut-driver-enumerator.xml: $(top_builddir)/config.status $(srcdir)/nut-driver-enumerator.xml.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +nut-driver.xml: $(top_builddir)/config.status $(srcdir)/nut-driver.xml.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +nut-monitor.xml: $(top_builddir)/config.status $(srcdir)/nut-monitor.xml.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +nut-server.xml: $(top_builddir)/config.status $(srcdir)/nut-server.xml.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +nut.xml: $(top_builddir)/config.status $(srcdir)/nut.xml.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ pkginfo: $(top_builddir)/config.status $(srcdir)/pkginfo.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +svc-nut-server: $(top_builddir)/config.status $(srcdir)/svc-nut-server.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +svc-nut-monitor: $(top_builddir)/config.status $(srcdir)/svc-nut-monitor.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +precheck.py: $(top_builddir)/config.status $(srcdir)/precheck.py.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +preinstall: $(top_builddir)/config.status $(srcdir)/preinstall.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ postinstall: $(top_builddir)/config.status $(srcdir)/postinstall.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ preremove: $(top_builddir)/config.status $(srcdir)/preremove.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +postremove: $(top_builddir)/config.status $(srcdir)/postremove.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +preproto.pl: $(top_builddir)/config.status $(srcdir)/preproto.pl.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ nut: $(top_builddir)/config.status $(srcdir)/nut.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +install-libexecSCRIPTS: $(libexec_SCRIPTS) + @$(NORMAL_INSTALL) + @list='$(libexec_SCRIPTS)'; test -n "$(libexecdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(libexecdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libexecdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n' \ + -e 'h;s|.*|.|' \ + -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) { files[d] = files[d] " " $$1; \ + if (++n[d] == $(am__install_max)) { \ + print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ + else { print "f", d "/" $$4, $$1 } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(libexecdir)$$dir'"; \ + $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(libexecdir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-libexecSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(libexec_SCRIPTS)'; test -n "$(libexecdir)" || exit 0; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 's,.*/,,;$(transform)'`; \ + dir='$(DESTDIR)$(libexecdir)'; $(am__uninstall_files_from_dir) +install-sbinSCRIPTS: $(sbin_SCRIPTS) + @$(NORMAL_INSTALL) + @list='$(sbin_SCRIPTS)'; test -n "$(sbindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(sbindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(sbindir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n' \ + -e 'h;s|.*|.|' \ + -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) { files[d] = files[d] " " $$1; \ + if (++n[d] == $(am__install_max)) { \ + print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ + else { print "f", d "/" $$4, $$1 } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(sbindir)$$dir'"; \ + $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(sbindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-sbinSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(sbin_SCRIPTS)'; test -n "$(sbindir)" || exit 0; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 's,.*/,,;$(transform)'`; \ + dir='$(DESTDIR)$(sbindir)'; $(am__uninstall_files_from_dir) +install-solarisinitscriptSCRIPTS: $(solarisinitscript_SCRIPTS) + @$(NORMAL_INSTALL) + @list='$(solarisinitscript_SCRIPTS)'; test -n "$(solarisinitscriptdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(solarisinitscriptdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(solarisinitscriptdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n' \ + -e 'h;s|.*|.|' \ + -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) { files[d] = files[d] " " $$1; \ + if (++n[d] == $(am__install_max)) { \ + print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ + else { print "f", d "/" $$4, $$1 } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(solarisinitscriptdir)$$dir'"; \ + $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(solarisinitscriptdir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-solarisinitscriptSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(solarisinitscript_SCRIPTS)'; test -n "$(solarisinitscriptdir)" || exit 0; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 's,.*/,,;$(transform)'`; \ + dir='$(DESTDIR)$(solarisinitscriptdir)'; $(am__uninstall_files_from_dir) +install-solarissmfmethodSCRIPTS: $(solarissmfmethod_SCRIPTS) + @$(NORMAL_INSTALL) + @list='$(solarissmfmethod_SCRIPTS)'; test -n "$(solarissmfmethoddir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(solarissmfmethoddir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(solarissmfmethoddir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n' \ + -e 'h;s|.*|.|' \ + -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) { files[d] = files[d] " " $$1; \ + if (++n[d] == $(am__install_max)) { \ + print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ + else { print "f", d "/" $$4, $$1 } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(solarissmfmethoddir)$$dir'"; \ + $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(solarissmfmethoddir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-solarissmfmethodSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(solarissmfmethod_SCRIPTS)'; test -n "$(solarissmfmethoddir)" || exit 0; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 's,.*/,,;$(transform)'`; \ + dir='$(DESTDIR)$(solarissmfmethoddir)'; $(am__uninstall_files_from_dir) mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs +install-solarissmfmanifestDATA: $(solarissmfmanifest_DATA) + @$(NORMAL_INSTALL) + @list='$(solarissmfmanifest_DATA)'; test -n "$(solarissmfmanifestdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(solarissmfmanifestdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(solarissmfmanifestdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(solarissmfmanifestdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(solarissmfmanifestdir)" || exit $$?; \ + done + +uninstall-solarissmfmanifestDATA: + @$(NORMAL_UNINSTALL) + @list='$(solarissmfmanifest_DATA)'; test -n "$(solarissmfmanifestdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(solarissmfmanifestdir)'; $(am__uninstall_files_from_dir) tags TAGS: ctags CTAGS: @@ -372,7 +685,10 @@ ctags CTAGS: cscope cscopelist: -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -403,9 +719,13 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-local check: check-am -all-am: Makefile +all-am: Makefile $(SCRIPTS) $(DATA) installdirs: + for dir in "$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(solarisinitscriptdir)" "$(DESTDIR)$(solarissmfmethoddir)" "$(DESTDIR)$(solarissmfmanifestdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done install: install-am install-exec: install-exec-am install-data: install-data-am @@ -436,6 +756,7 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am @@ -456,13 +777,14 @@ info: info-am info-am: -install-data-am: +install-data-am: install-solarisinitscriptSCRIPTS \ + install-solarissmfmanifestDATA install-solarissmfmethodSCRIPTS install-dvi: install-dvi-am install-dvi-am: -install-exec-am: +install-exec-am: install-libexecSCRIPTS install-sbinSCRIPTS install-html: install-html-am @@ -500,38 +822,65 @@ ps: ps-am ps-am: -uninstall-am: +uninstall-am: uninstall-libexecSCRIPTS uninstall-sbinSCRIPTS \ + uninstall-solarisinitscriptSCRIPTS \ + uninstall-solarissmfmanifestDATA \ + uninstall-solarissmfmethodSCRIPTS -.MAKE: install-am install-strip +.MAKE: check-am install-am install-strip -.PHONY: all all-am check check-am clean clean-generic clean-libtool \ - cscopelist-am ctags-am distclean distclean-generic \ - distclean-libtool distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ +.PHONY: all all-am check check-am check-local clean clean-generic \ + clean-libtool cscopelist-am ctags-am distclean \ + distclean-generic distclean-libtool distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-libexecSCRIPTS install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-sbinSCRIPTS \ + install-solarisinitscriptSCRIPTS \ + install-solarissmfmanifestDATA install-solarissmfmethodSCRIPTS \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags-am uninstall uninstall-am + tags-am uninstall uninstall-am uninstall-libexecSCRIPTS \ + uninstall-sbinSCRIPTS uninstall-solarisinitscriptSCRIPTS \ + uninstall-solarissmfmanifestDATA \ + uninstall-solarissmfmethodSCRIPTS + +.PRECIOUS: Makefile -package: makelocal.sh pkginfo - $ cd @prefix@; $ find . -print | pkgproto > prototype1 - $ cp makelocal.sh precheck.py pkginfo nut preinstall postinstall preremove postremove preproto.pl @prefix@ - $ cd @prefix@; perl preproto.pl - $ cd @prefix@; python precheck.py - $ cd @prefix@; rm -f prototype1 - $ cd @prefix@; ./makelocal.sh - $ cp @prefix@/*.gz $(srcdir) - if test `uname -p` = "i386"; then \ - mv NUT_solaris_package.local.gz NUT_solaris_i386_package@PACKAGE_VERSION@.local.gz; \ - else \ - if test `uname -p` = "sparc"; then \ - mv NUT_solaris_package.local.gz NUT_solaris_sparc_package@PACKAGE_VERSION@.local.gz; \ - fi; \ - fi; +package: $(SOLARIS_PACKAGE_TARGETS) +package-solaris-svr4: $(SOLARIS_PACKAGE_SVR4_HELPERSCRIPTS) $(SOLARIS_PACKAGE_SVR4_INSTALLSCRIPTS) $(SOLARIS_PACKAGE_SVR4_INSTALLDATA) + if test -n "@auglensdir@" && test -d "$(DESTDIR)@auglensdir@" ; then \ + mkdir -p "$(DESTDIR)@datadir@/augeas-lenses" && \ + cd "$(DESTDIR)@auglensdir@" && \ + ( cp -prf ./ "$(DESTDIR)@datadir@/augeas-lenses/" || cp -rf ./ "$(DESTDIR)@datadir@/augeas-lenses/" ) ; fi + cd $(PROTOTYPE_DIR) && find . -print | pkgproto > prototype1 + cp $(SOLARIS_PACKAGE_SVR4_HELPERSCRIPTS) $(SOLARIS_PACKAGE_SVR4_INSTALLSCRIPTS) $(SOLARIS_PACKAGE_SVR4_INSTALLDATA) $(PROTOTYPE_DIR) + cd $(PROTOTYPE_DIR) && chmod +x $(SOLARIS_PACKAGE_SVR4_HELPERSCRIPTS) $(SOLARIS_PACKAGE_SVR4_INSTALLSCRIPTS) + cd $(PROTOTYPE_DIR) && perl preproto.pl +@HAVE_PYTHON_TRUE@ cd $(PROTOTYPE_DIR) && $(PYTHON) precheck.py + cd $(PROTOTYPE_DIR) && rm -f prototype1 + cd $(PROTOTYPE_DIR) && ./makelocal.sh + cp $(PROTOTYPE_DIR)/*.gz $(builddir) + UNAME_P="`uname -p`" && case "$${UNAME_P}" in \ + i386|sparc) \ + mv -f NUT_solaris_package.local.gz "$(abs_top_builddir)/NUT_solaris_$${UNAME_P}_package@PACKAGE_VERSION@.local.gz" ;; \ + esac + +# TODO: Define support for IPS packaging (provide p5m files and make rules) +package-solaris-ips: + @echo "SKIPPED : Target $@ is not implemented yet" + +check-local: $(SOLARIS_CHECK_TARGETS) + +check-local-solaris-smf: $(SOLARIS_SMF_MANIFESTS) + @[ -x /usr/sbin/svccfg ] || { echo "WARNING : Target $@ skipped due to absent /usr/sbin/svccfg" >&2; return 0; } ; \ + RES=0 ; for F in $^ ; do \ + echo " SVCCFG-VALIDATE $$F"; \ + /usr/sbin/svccfg validate "$$F" || RES=$$? ; \ + done; exit $$RES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/scripts/Solaris/README b/scripts/Solaris/README new file mode 100644 index 0000000..adb305e --- /dev/null +++ b/scripts/Solaris/README @@ -0,0 +1,38 @@ +This directory contains init-scripts and SMF manifests and methods +for integration of NUT services with Solaris and descendant OSes. + +This also includes the nut-driver-enumerator.sh (service and implementation +method) and upsdrvsvcctl (tool) to manage NUT drivers as service instances, +which are stored in ../upsdrvsvcctl/ subdirectory (portable codebase shared +with Linux systemd). + +The default implementation (runs once) can be enabled with: + + svcadm enable nut-driver-enumerator:default + +Note that at the moment there is no out-of-the-box integration for triggering +a restart/refresh of the nut-driver-enumerator SMF service at the very instant +when the `ups.conf` file is modified, like there is with systemd path unit type. +Due to this, the systems administrator is expected to either invoke +`svcadm refresh nut-driver-enumerator` after changing the NUT configuration +or wait until the daemonized mode, if enabled, picks up the change (should do +so within a minute by default). However, a DTrace script or a tool like +https://github.com/emcrisostomo/fswatch wrapped into a service might be used +for equivalent effect. + +Alternatively, but somewhat more expensively, the same `nut-driver-enumerator.sh` +script can be executed in a loop as the payload of the SMF service to keep +inspecting the configuration and apply changes to the running system. It is +not a common use-case to keep changing device setups, so this solution is not +enforced by default ;) although a service variant is provided... + +Note that only one of these can be enabled at the same time: + + svcadm disable nut-driver-enumerator:default + svcadm enable nut-driver-enumerator:daemon + +Init-script solution contributed by numerous authors +SMF solution contributed by Jim Klimov + +For special notes about USB-connected device monitoring with NUT under Solaris +and related operating systems, see docs/solaris-usb.txt diff --git a/scripts/Solaris/makelocal.sh b/scripts/Solaris/makelocal.sh index 639e780..f017c43 100755 --- a/scripts/Solaris/makelocal.sh +++ b/scripts/Solaris/makelocal.sh @@ -1,5 +1,11 @@ #!/bin/sh -pkgmk -o -d `pwd` -pkgtrans `pwd` `pwd`/NUT_solaris_package.local -gzip `pwd`/NUT_solaris_package.local +# Creates the package file from current-directory contents +# Called by Makefile starting from installed prototype directory + +echo "Making Solaris SVR4 package metadata..." && \ +pkgmk -o -d "`pwd`" && \ +echo "Making Solaris SVR4 package archive file..." && \ +( yes "" | pkgtrans "`pwd`" "`pwd`/NUT_solaris_package.local" ) && \ +echo "Compressing Solaris SVR4 package archive file..." && \ +gzip "`pwd`/NUT_solaris_package.local" diff --git a/scripts/Solaris/nut-driver-enumerator.xml.in b/scripts/Solaris/nut-driver-enumerator.xml.in new file mode 100644 index 0000000..55723c0 --- /dev/null +++ b/scripts/Solaris/nut-driver-enumerator.xml.in @@ -0,0 +1,178 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/Solaris/nut-driver.xml.in b/scripts/Solaris/nut-driver.xml.in new file mode 100644 index 0000000..c52afac --- /dev/null +++ b/scripts/Solaris/nut-driver.xml.in @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/Solaris/nut-monitor.xml.in b/scripts/Solaris/nut-monitor.xml.in new file mode 100644 index 0000000..c3118d3 --- /dev/null +++ b/scripts/Solaris/nut-monitor.xml.in @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/Solaris/nut-server.xml.in b/scripts/Solaris/nut-server.xml.in new file mode 100644 index 0000000..6b3b4d0 --- /dev/null +++ b/scripts/Solaris/nut-server.xml.in @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/Solaris/nut.in b/scripts/Solaris/nut.in old mode 100644 new mode 100755 index ab7ec94..1c39603 --- a/scripts/Solaris/nut.in +++ b/scripts/Solaris/nut.in @@ -3,29 +3,31 @@ #init.d script to start nut services NUT_DIR="@prefix@" -CONFIG=$NUT_DIR/etc/nut.conf +NUT_SBIN_DIR="${NUT_DIR}/sbin" +NUT_LIB_DIR="${NUT_DIR}/lib" +CONFIG="@CONFPATH@/nut.conf" -if [ -f $CONFIG ] ; then - . $CONFIG +if [ -f "$CONFIG" ] ; then + . "$CONFIG" fi ups_stop () { pkill -n upsmon pkill -n upsd - ${NUT_DIR}/sbin/upsdrvctl stop > /dev/null 2>&1 + LD_LIBRARY_PATH="${NUT_LIB_DIR}:$LD_LIBRARY_PATH" "${NUT_SBIN_DIR}/upsdrvctl" stop > /dev/null 2>&1 } ups_start () { if [ "$MODE" = "none" ];then - echo No mode set + echo "No NUT mode set, not starting anything" >&2 exit 1 fi - if [ ! "$MODE" = "netclient" ];then - $NUT_DIR/sbin/upsdrvctl start #> /dev/null 2>&1 - $NUT_DIR/sbin/upsd #> /dev/null 2>&1 + if [ "$MODE" != "netclient" ] ; then + LD_LIBRARY_PATH="${NUT_LIB_DIR}:$LD_LIBRARY_PATH" "${NUT_SBIN_DIR}/upsdrvctl" start #> /dev/null 2>&1 + LD_LIBRARY_PATH="${NUT_LIB_DIR}:$LD_LIBRARY_PATH" "${NUT_SBIN_DIR}/upsd" #> /dev/null 2>&1 fi - $NUT_DIR/sbin/upsmon #> /dev/null 2>&1 + LD_LIBRARY_PATH="${NUT_LIB_DIR}:$LD_LIBRARY_PATH" "${NUT_SBIN_DIR}/upsmon" #> /dev/null 2>&1 } case $1 in @@ -46,10 +48,11 @@ case $1 in ups_start ;; 'poweroff') - $NUT_DIR/sbin/upsmon -K >/dev/null 2>&1 + LD_LIBRARY_PATH="${NUT_LIB_DIR}:$LD_LIBRARY_PATH" "${NUT_SBIN_DIR}/upsmon" -K >/dev/null 2>&1 if [ $? = 0 ]; then - echo "Shutting down the UPS ..." - #$NUT_DIR/sbin/upsdrvctl shutdown + echo "Shutting down the UPS(es) ..." + echo "WARNING: UPS shutdown is currently disabled, please uncomment it in the init-script if desired" >&2 + #${NUT_SBIN_DIR}/upsdrvctl shutdown fi ;; *) @@ -57,7 +60,7 @@ case $1 in echo "Usage: '$0' {start | stop | restart }" echo "" exit 64 - ;; + ;; esac exit $? diff --git a/scripts/Solaris/nut.xml.in b/scripts/Solaris/nut.xml.in new file mode 100644 index 0000000..b06b2b1 --- /dev/null +++ b/scripts/Solaris/nut.xml.in @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/Solaris/pkginfo.in b/scripts/Solaris/pkginfo.in index d99bdbe..39667f0 100644 --- a/scripts/Solaris/pkginfo.in +++ b/scripts/Solaris/pkginfo.in @@ -1,6 +1,6 @@ PKG="NUT" NAME="Network UPS Tools" -ARCH="@OS_NAME@" +ARCH="@target_cpu@" VERSION="@PACKAGE_VERSION@" CATEGORY="application" VENDOR="http://www.networkupstools.org" diff --git a/scripts/Solaris/postinstall.in b/scripts/Solaris/postinstall.in old mode 100644 new mode 100755 index 136e077..a6068b4 --- a/scripts/Solaris/postinstall.in +++ b/scripts/Solaris/postinstall.in @@ -1,65 +1,126 @@ #!/bin/sh -#Postinstall script +# Postinstall script for Network UPS Tools package NUT_DIR="@prefix@" +prefix="@prefix@" # expanded as part of some autoconf macros below + +# TODO/FIXME : Should "/var/run" be a configure variable? +# Note that "/var/run" is transient tmpfs, so upgrade has to be done during same uptime. +ACTIVE_ENUMERATOR_FMRI_FILE="/var/run/nut-driver-enumerator-fmri.prev" # make sure the nut user exists and has correct memberships -res=`getent group nut` +res="`getent group @RUN_AS_GROUP@`" || res="" if [ -z "$res" ]; then - groupadd nut + /usr/sbin/groupadd "@RUN_AS_GROUP@" fi -res=`getent passwd nut` +res="`getent passwd @RUN_AS_USER@`" || res="" if [ -z "$res" ]; then - useradd -g nut -G root -d ${NUT_DIR}/bin nut + /usr/sbin/useradd -c "Network UPS Tools" -g "@RUN_AS_GROUP@" -G root -d "@STATEPATH@" -s /bin/false @RUN_AS_USER@ fi -res=`groups nut | grep -w nut` +res="`groups "@RUN_AS_GROUP@" | grep -w "@RUN_AS_USER@"`" || res="" if [ -z "$res" ]; then - usermod -g nut -G root nut + /usr/sbin/usermod -g "@RUN_AS_GROUP@" -G root "@RUN_AS_USER@" fi # make sure that conffiles are secured and have the correct ownerships -if [ -d @CONFPATH@ ] ; then - chown root:nut @CONFPATH@ +if [ -d "@CONFPATH@" ] ; then + chown "root:@RUN_AS_GROUP@" "@CONFPATH@" fi -for file in nut.conf ups.conf upsd.conf upsmon.conf upsd.users upssched.conf; do - if [ -f @CONFPATH@/$file ] ; then - chown root:nut @CONFPATH@/$file - chmod 640 @CONFPATH@/$file +for file in nut.conf ups.conf upsd.conf upsmon.conf upsd.users upssched.conf nut-driver-enumerator.conf; do + if [ -f "@CONFPATH@/$file" ] ; then + chown "root:@RUN_AS_GROUP@" "@CONFPATH@/$file" + chmod 640 "@CONFPATH@/$file" fi done # make sure that /var/run/nut exists and has the correct ownerships -if [ ! -d @PIDPATH@/nut ] ; then - mkdir -p @PIDPATH@/nut +if [ ! -d "@PIDPATH@/nut" ] ; then + mkdir -p "@PIDPATH@/nut" fi -if [ -d @PIDPATH@/nut ] ; then - chown root:nut @PIDPATH@/nut - chmod 770 @PIDPATH@/nut +if [ -d "@PIDPATH@/nut" ] ; then + chown "root:@RUN_AS_GROUP@" "@PIDPATH@/nut" + chmod 770 "@PIDPATH@/nut" fi # make sure that /var/state/ups exists and has the correct ownerships -if [ ! -d @STATEPATH@ ] ; then - mkdir -p @STATEPATH@ +if [ ! -d "@STATEPATH@" ] ; then + mkdir -p "@STATEPATH@" fi -if [ -d @STATEPATH@ ] ; then - chown root:nut @STATEPATH@ - chmod 770 @STATEPATH@ +if [ -d "@STATEPATH@" ] ; then + chown "root:@RUN_AS_GROUP@" "@STATEPATH@" + chmod 770 "@STATEPATH@" fi -# Put init script in /etc/init.d +if [ -n "@auglensdir@" ] && [ -d "@auglensdir@" ] && [ -d "@datarootdir@/augeas-lenses" ] ; then + ( cd "@datarootdir@/augeas-lenses" && cp -prf ./ "@auglensdir@"/ ) +fi -cp $NUT_DIR/nut /etc/init.d -chmod 744 /etc/init.d/nut +if test -x /usr/sbin/svcadm && test -x /usr/sbin/svccfg && test -x /usr/bin/svcs ; then + echo "Register SMF services..." + for S in nut-driver-enumerator nut-driver nut-server nut-monitor nut ; do + echo "Importing NUT service manifest: $S..." + /usr/sbin/svccfg import "@datarootdir@/solaris-smf/manifest/$S.xml" + done + # Enable services if the system already has a configuration (e.g. upgrade) + if test -s "@CONFPATH@/ups.conf" ; then + echo "Stopping NUT drivers, if any (in case of upgrade)..." + @SBINDIR@/upsdrvsvcctl stop + @SBINDIR@/upsdrvctl -DDDDD stop + sleep 5 + echo "(Re-)register NUT drivers (if any)..." + REPORT_RESTART_42=no AUTO_START=no "@NUT_LIBEXECDIR@/nut-driver-enumerator.sh" --reconfigure + sleep 2 + echo "Enable NUT drivers (if any)..." + # Note: we now provide two services, a daemon that keeps checking + # the config for changes and a default one that should be refreshed + # manually to reconfigure nut-driver instances - and is "cheaper". + # This may still fail if the daemon instance is somehow enabled (admin) + PREV_ACTIVE_ENUMERATOR="" + if test -s "${ACTIVE_ENUMERATOR_FMRI_FILE}" ; then + PREV_ACTIVE_ENUMERATOR="`head -1 "${ACTIVE_ENUMERATOR_FMRI_FILE}"`" + fi + [ x"nut-driver-enumerator:default" = x"${PREV_ACTIVE_ENUMERATOR}" ] && PREV_ACTIVE_ENUMERATOR="" + for ACTIVE_ENUMERATOR in ${PREV_ACTIVE_ENUMERATOR} nut-driver-enumerator:default ; do + /usr/sbin/svcadm enable -s ${ACTIVE_ENUMERATOR} || \ + { /usr/sbin/svcadm clear ${ACTIVE_ENUMERATOR} 2>/dev/null ; \ + /usr/sbin/svcadm enable -s ${ACTIVE_ENUMERATOR} ; } && break || true + done + @SBINDIR@/upsdrvsvcctl start + else + echo "NOT ENABLING nut-driver-enumerator at this time : missing or empty @CONFPATH@/ups.conf" >&2 + fi + if test -s "@CONFPATH@/ups.conf" && test -e "@CONFPATH@/upsd.conf" && test -e "@CONFPATH@/upsd.users" ; then + # Note on the mix of "-s" and "-e" in tests above: + # it is a valid use-case for an admin to have just touched an + # empty upsd.conf and so use default settings for the daemon + echo "Enable NUT upsd data server..." + /usr/sbin/svcadm enable -s nut-server + else + echo "NOT ENABLING nut-server at this time : missing at least one of : @CONFPATH@/ups.conf @CONFPATH@/upsd.conf @CONFPATH@/upsd.users" >&2 + fi + if test -s "@CONFPATH@/upsmon.conf" ; then + echo "Enable NUT upsmon client..." + /usr/sbin/svcadm enable -s nut-monitor + else + echo "NOT ENABLING nut-monitor at this time : missing or empty @CONFPATH@/upsmon.conf" >&2 + fi + echo "Enable NUT umbrella service..." + /usr/sbin/svcadm enable -s nut +else + echo "Put init script in /etc/init.d..." + cp -pf "@NUT_DATADIR@/solaris-init/nut" /etc/init.d + chown root:bin /etc/init.d/nut + chmod 744 /etc/init.d/nut -ln -s /etc/init.d/nut /etc/rc3.d/S100nut > /dev/null 2>&1 -ln -s /etc/init.d/nut /etc/rc3.d/K100nut > /dev/null 2>&1 + ln -s ../init.d/nut /etc/rc3.d/S90nut > /dev/null 2>&1 + ln -s ../init.d/nut /etc/rc3.d/K10nut > /dev/null 2>&1 -# Start nut services - -#echo "Starting nut services" -#$NUT_DIR/sbin/upsdrvctl start #> /dev/null 2>&1 -#$NUT_DIR/sbin/upsd #> /dev/null 2>&1 -#$NUT_DIR/sbin/upsmon #> /dev/null 2>&1 + # Start nut services + #echo "Starting nut services" + #$NUT_DIR/sbin/upsdrvctl start #> /dev/null 2>&1 + #$NUT_DIR/sbin/upsd #> /dev/null 2>&1 + #$NUT_DIR/sbin/upsmon #> /dev/null 2>&1 +fi diff --git a/scripts/Solaris/postremove.in b/scripts/Solaris/postremove.in new file mode 100755 index 0000000..dce3f44 --- /dev/null +++ b/scripts/Solaris/postremove.in @@ -0,0 +1,19 @@ +#!/bin/sh + +# Postremove script for Network UPS Tools package + +# Remove init script from /etc/init.d - created by scripts not packaging + +rm -f /etc/init.d/nut +rm -f /etc/rc3.d/S90nut +rm -f /etc/rc3.d/K10nut + +# Remove nut group and user + +/usr/sbin/userdel "@RUN_AS_USER@" + +/usr/sbin/groupdel "@RUN_AS_GROUP@" + +# Remove /var/run/nut + +rm -rf "@PIDPATH@/nut" diff --git a/scripts/Solaris/precheck.py.in b/scripts/Solaris/precheck.py.in new file mode 100755 index 0000000..5a6457c --- /dev/null +++ b/scripts/Solaris/precheck.py.in @@ -0,0 +1,48 @@ +#!@PYTHON@ + +import sys + +if sys.version_info >= ( 2, 6 ): + import subprocess + p = subprocess.Popen(["uname", "-s"], stdout=subprocess.PIPE) + platform = p.communicate()[0] + if p.returncode != 0: + raise Exception("FAILED to get platform from 'uname -s'!") + + p = subprocess.Popen(["uname", "-p"], stdout=subprocess.PIPE) + architecture = p.communicate()[0] + if p.returncode != 0: + raise Exception("FAILED to get architecture from 'uname -p'!") +else: + import commands + platform = commands.getoutput('uname -s') + architecture = commands.getoutput('uname -p') + +# checkinstall script creation +fp=open("checkinstall","w") +# Note: same arch is relevant for different bitnesses that +# can be discerned via `isainfo` further (if ever needed) +fp.write("#!/bin/sh\n") +fp.write("\nexpected_platform=SunOS\n") +if platform == "SunOS" and architecture == "i386": + fp.write("expected_architecture=i386\n") +elif platform == "SunOS" and architecture == "sparc": + fp.write("expected_architecture=sparc\n") + +fp.write("platform=\"`uname -s`\"\n") +fp.write("architecture=\"`uname -p`\"\n\n") + +fp.write("if [ \"${platform}\" -eq \"${expected_platform}\" ]; then\n") +fp.write("\tif [ \"${architecture}\" -eq \"${expected_architecture}\" ]; then\n") +fp.write("\t\techo \"Checkinstall complete\"\n") +fp.write("\telse\n") +fp.write("\t\techo \"This is not Solaris $architecture machine: platform='${platform}' expected_platform='${expected_platform}'\"\n") +fp.write("\t\texit 1\n") +fp.write("\tfi\n") +fp.write("else\n") +fp.write("\techo \"This is not Solaris machine: architecture='${architecture}' expected_architecture='${expected_architecture}'\"\n") +fp.write("\texit 1\n") +fp.write("fi\n") +fp.write("exit 0\n") + +fp.close() diff --git a/scripts/Solaris/preinstall.in b/scripts/Solaris/preinstall.in new file mode 100755 index 0000000..42da1ce --- /dev/null +++ b/scripts/Solaris/preinstall.in @@ -0,0 +1,23 @@ +#!/bin/sh + +# Preinstall script for Network UPS Tools package +NUT_DIR="@prefix@" + +# Create group nut + +grep -w "@RUN_AS_GROUP@" /etc/group +if [ "$?" != 0 ]; then + /usr/sbin/groupadd "@RUN_AS_GROUP@" +fi + +# Create user for installing "Network UPS Tools" + +grep -w "@RUN_AS_USER@" /etc/passwd +if [ "$?" != 0 ]; then + /usr/sbin/useradd -c "Network UPS Tools" -g "@RUN_AS_GROUP@" -G root -d "@STATEPATH@" -s /bin/false "@RUN_AS_USER@" +fi + +res="`groups "@RUN_AS_GROUP@" | grep -w "@RUN_AS_USER@"`" || res="" +if [ -z "$res" ]; then + /usr/sbin/usermod -g "@RUN_AS_GROUP@" -G root "@RUN_AS_USER@" +fi diff --git a/scripts/Solaris/preproto.pl.in b/scripts/Solaris/preproto.pl.in new file mode 100755 index 0000000..ac52c16 --- /dev/null +++ b/scripts/Solaris/preproto.pl.in @@ -0,0 +1,39 @@ +#!/usr/bin/env perl + +$temp = "prototype1"; +$prototype="prototype"; +$pkginfo = "pkginfo"; +$checkinstall = "checkinstall"; +$preinstall = "preinstall"; +$postinstall = "postinstall"; +$preremove = "preremove"; +$postremove = "postremove"; +$nutuser = "@RUN_AS_USER@"; +$nutgroup = "@RUN_AS_GROUP@"; + +open (PREPROTO,"< $temp") || die "Unable to read prototype information ($!)\n"; +open (PROTO,"> $prototype") || die "Unable to write file prototype ($!)\n"; +print PROTO "i pkginfo=./$pkginfo\n"; +print PROTO "i checkinstall=./$checkinstall\n"; +print PROTO "i preinstall=./$preinstall\n"; +print PROTO "i postinstall=./$postinstall\n"; +print PROTO "i preremove=./$preremove\n"; +print PROTO "i postremove=./$postremove\n"; +while () { + # Read the prototype information from /tmp/prototype$$ + chomp; + $thisline = $_; + if ($thisline =~ " prototype1 ") { + # We don't need that line + } elsif ($thisline =~ "^[fd] ") { + # Change the ownership for files and directories + ($dir, $none, $file, $mode, $user, $group) = split / /,$thisline; + print PROTO "$dir $none $file=$file $mode $nutuser $nutgroup\n"; + } else { + # Symlinks and other stuff should be printed as well ofcourse + print PROTO "$thisline\n"; + } +} +#print PROTO "f $none nut $mode root $nutgroup\n"; +close PROTO; +close PREPROTO; diff --git a/scripts/Solaris/preremove.in b/scripts/Solaris/preremove.in old mode 100644 new mode 100755 index dc4a1a1..abce051 --- a/scripts/Solaris/preremove.in +++ b/scripts/Solaris/preremove.in @@ -1,8 +1,71 @@ -#!bin/sh +#!/bin/sh + +# Preremove script for Network UPS Tools package # Stop all nut services NUT_DIR="@prefix@" +prefix="@prefix@" # expanded as part of some autoconf macros below -#$NUT_DIR/sbin/upsdrvctl stop +# TODO/FIXME : Should "/var/run" be a configure variable? +# Note that "/var/run" is transient tmpfs, so upgrade has to be done during same uptime. +ACTIVE_ENUMERATOR_FMRI_FILE="/var/run/nut-driver-enumerator-fmri.prev" +if test -x /usr/sbin/svcadm && test -x /usr/sbin/svccfg && test -x /usr/bin/svcs ; then + # Unconfigure SMF services + # First detect the first active (online, maintenance, etc.) + # instance of nut-driver-enumerator so we can pass it to the + # next lifetime in case of re-install of NUT and keep the + # user's previously declared preference. + ACTIVE_ENUMERATOR="`/usr/bin/svcs -H -o state,fmri '*/nut-driver-enumerator:*' | while read S F ; do [ "$S" != "disabled" ] && [ "$S" != "offline" ] && echo "$F" && break ; done`" + if [ -n "$ACTIVE_ENUMERATOR" ]; then + rm -f "${ACTIVE_ENUMERATOR_FMRI_FILE}" + touch "${ACTIVE_ENUMERATOR_FMRI_FILE}" + chmod 600 "${ACTIVE_ENUMERATOR_FMRI_FILE}" + chown 0:0 "${ACTIVE_ENUMERATOR_FMRI_FILE}" + echo "${ACTIVE_ENUMERATOR}" > "${ACTIVE_ENUMERATOR_FMRI_FILE}" + fi + # First tell the automagic to stop, so it does not interfere; diligently clean it out below + /usr/sbin/svcadm disable nut-driver-enumerator:default || true + /usr/sbin/svcadm disable nut-driver-enumerator:daemon || true + for S in nut nut-monitor nut-server ; do + echo "Stopping NUT service: $S..." + /usr/sbin/svcadm clear "$S" 2>/dev/null + /usr/sbin/svcadm disable -s "$S" + echo "Removing NUT service: $S..." + /usr/sbin/svccfg delete "$S" || \ + /usr/sbin/svccfg -s "$S" delete || \ + /usr/sbin/svccfg -s "$S" delete default + done + echo "Stopping NUT drivers, if any..." + @SBINDIR@/upsdrvsvcctl stop + @SBINDIR@/upsdrvctl -DDDDD stop + sleep 5 + for S in `/usr/bin/svcs -H -o fmri '*/nut-driver:*'` `/usr/bin/svcs -H -o fmri '*/nut-driver-enumerator:*'` ; do + echo "Stopping NUT service: $S..." + /usr/sbin/svcadm clear "$S" 2>/dev/null + /usr/sbin/svcadm disable -s "$S" + done + sleep 5 + for S in `/usr/bin/svcs -H -o fmri '*/nut-driver:*' | grep -wv default` `/usr/bin/svcs -H -o fmri '*/nut-driver-enumerator:*' | grep -wv default` ; do + echo "Removing NUT service: $S..." + # Note: S here is a full FMRI URL + SB="`echo "$S" | sed 's,:[^:]*$,,'`" + SI="`echo "$S" | sed 's,^.*:\([^:]*\)$,\1,'`" + /usr/sbin/svcadm disable -s "$S" + /usr/sbin/svccfg -s "$SB" delete -f "$SI" || \ + /usr/sbin/svccfg delete "$S" + done + for S in nut-driver-enumerator nut-driver ; do + echo "Removing NUT service: $S..." && \ + /usr/sbin/svccfg delete "$S" || \ + /usr/sbin/svccfg -s "$S" delete || \ + /usr/sbin/svccfg -s "$S" delete default + done +else + [ -x /etc/init.d/nut ] && /etc/init.d/nut stop +fi + +if [ -n "@auglensdir@" ] && [ -d "@auglensdir@" ] && [ -d "@datarootdir@/augeas-lenses" ] ; then + ( cd "@datarootdir@/augeas-lenses" && find . -type f -exec rm -f "@auglensdir@"/'{}' \; ) +fi diff --git a/scripts/Solaris/svc-nut-monitor.in b/scripts/Solaris/svc-nut-monitor.in new file mode 100755 index 0000000..a7dd0dc --- /dev/null +++ b/scripts/Solaris/svc-nut-monitor.in @@ -0,0 +1,56 @@ +#!/sbin/sh + +# Trivial (better is yet to come) SMF method script to start nut services +# Adapted for OpenIndiana userland from init.d script template in NUT sources +# Adaptation copyright (C) 2016-2017 Jim Klimov + +if [ -z "$SMF_FMRI" ]; then + echo "$0 must be called in SMF context!" >&2 + exit 1 +fi + +# smf(5) +. /lib/svc/share/smf_include.sh || exit + +prefix="@prefix@" +NUT_DIR="@prefix@" +NUT_SBIN_DIR="${NUT_DIR}/sbin" +NUT_LIB_DIR="${NUT_DIR}/lib" +NUT_RUN_DIR="@PIDPATH@/nut" +CONFIG="@CONFPATH@/nut.conf" +NUTUSER="@RUN_AS_USER@" +NUTGROUP="@RUN_AS_GROUP@" + +if [ -f "$CONFIG" ] ; then + . "$CONFIG" +fi + +ups_start () { + if [ "$MODE" = "none" ];then + echo "No NUT mode set, not starting anything" >&2 + exit $SMF_EXIT_ERR_CONFIG + fi + + # Default rights inspired by NUT scripts/Solaris/postinstall.in + mkdir -p "$NUT_RUN_DIR" && \ + chown "root:$NUTGROUP" "$NUT_RUN_DIR" && \ + chmod 770 "$NUT_RUN_DIR" \ + || exit $SMF_EXIT_ERR_FATAL + + LD_LIBRARY_PATH="${NUT_LIB_DIR}:$LD_LIBRARY_PATH" "${NUT_SBIN_DIR}"/upsmon #> /dev/null 2>&1 +} + +case "$1" in +'start') + ups_start + ;; + +*) + echo "" + echo "Usage: '$0' {start}" + echo "" + exit $SMF_EXIT_ERR_CONFIG + ;; +esac + +exit $? diff --git a/scripts/Solaris/svc-nut-server.in b/scripts/Solaris/svc-nut-server.in new file mode 100755 index 0000000..5fee9c1 --- /dev/null +++ b/scripts/Solaris/svc-nut-server.in @@ -0,0 +1,64 @@ +#!/sbin/sh + +# Trivial (better is yet to come) SMF method script to start nut services +# Adapted for OpenIndiana userland from init.d script template in NUT sources +# Adaptation copyright (C) 2016 Jim Klimov + +if [ -z "$SMF_FMRI" ]; then + echo "$0 must be called in SMF context!" >&2 + exit 1 +fi + +# smf(5) +. /lib/svc/share/smf_include.sh || exit + +prefix="@prefix@" +NUT_DIR="@prefix@" +NUT_SBIN_DIR="$NUT_DIR/sbin" +NUT_LIB_DIR="${NUT_DIR}/lib" +NUT_RUN_DIR="@PIDPATH@/nut" +CONFIG="@CONFPATH@/nut.conf" +NUTUSER="@RUN_AS_USER@" +NUTGROUP="@RUN_AS_GROUP@" + +if [ -f "$CONFIG" ] ; then + . "$CONFIG" +fi + +ups_start () { + # Default rights inspired by NUT scripts/Solaris/postinstall.in + mkdir -p "$NUT_RUN_DIR" && \ + chown "root:$NUTGROUP" "$NUT_RUN_DIR" && \ + chmod 770 "$NUT_RUN_DIR" \ + || exit $SMF_EXIT_ERR_FATAL + + if [ "$MODE" = "none" ];then + echo "No NUT mode set, not starting anything" >&2 + exit 1 + fi + + if [ "$MODE" != "netclient" ] ; then + # In this distribution, UPS drivers are wrapped by service instances + #LD_LIBRARY_PATH="${NUT_LIB_DIR}:$LD_LIBRARY_PATH" "${NUT_SBIN_DIR}/upsdrvctl" start #> /dev/null 2>&1 + LD_LIBRARY_PATH="${NUT_LIB_DIR}:$LD_LIBRARY_PATH" "${NUT_SBIN_DIR}/upsd" #> /dev/null 2>&1 + fi +} + +case "$1" in +'start') + ups_start + ;; + +'refresh'|'reload') + LD_LIBRARY_PATH="${NUT_LIB_DIR}:$LD_LIBRARY_PATH" "${NUT_SBIN_DIR}/upsd" -c reload + ;; + +*) + echo "" + echo "Usage: '$0' {start}" + echo "" + exit $SMF_EXIT_ERR_CONFIG + ;; +esac + +exit $? diff --git a/scripts/augeas/Makefile.am b/scripts/augeas/Makefile.am index 5ef4c1e..b9b8c8e 100644 --- a/scripts/augeas/Makefile.am +++ b/scripts/augeas/Makefile.am @@ -1,16 +1,49 @@ -EXTRA_DIST = gen-nutupsconf-aug.py nutupsconf.aug.tpl \ +EXTRA_DIST = gen-nutupsconf-aug.py.in nutupsconf.aug.tpl \ README tests/test_nut.aug +PYTHON = @PYTHON@ + # only call the script to generate Augeas ups.conf lens upon "make dist", -# and if Python is present +# and if Python is present; the distributed gen-nutupsconf-aug.py.in template +# is assumed to only differ from a generated gen-nutupsconf-aug.py by the +# @PYTHON@ shebang. dist-hook: - @if python -c "import re,glob,codecs"; then \ - echo "Regenerating Augeas ups.conf lens."; \ - $(distdir)/gen-nutupsconf-aug.py $(distdir)/; \ + @if [ -n "$(PYTHON)" ] && $(PYTHON) -c "import re,glob,codecs"; then \ + echo "Regenerating Augeas ups.conf lens with '$(PYTHON)'."; \ + $(PYTHON) $(distdir)/gen-nutupsconf-aug.py.in $(distdir)/; \ else \ echo "----------------------------------------------------------------------"; \ echo "Warning: Python is not available."; \ - echo "Skipping Augeas ups.conf lens regeneration."; \ + echo "Skipping regeneration of Augeas lens for ups.conf parsing." ; \ echo "----------------------------------------------------------------------"; \ fi + +# This needs augparse from augeas-tools +if HAVE_AUGPARSE +check-local: + @echo "augparse proceeding to lenses verification job..."; \ + echo "DISABLED for now due to https://github.com/networkupstools/nut/issues/657" +endif +# FIXME +# augparse -I $(srcdir)/ $(srcdir)/tests/test_nut.aug + +if WITH_AUGLENS +# Now "make install" should cover delivery of Augeas lenses... +# The "auglensdir" value should be set up by configure +# The *.aug files are generated by rule above or by autogen.sh and/or configure + auglens_DATA = \ + nuthostsconf.aug nutupsconf.aug nutupsdusers.aug nutupsschedconf.aug \ + nutnutconf.aug nutupsdconf.aug nutupsmonconf.aug nutupssetconf.aug +endif + +MAINTAINERCLEANFILES = Makefile.in .dirstamp +CLEANFILES = *-spellchecked + +# Can be re-generated by configure script and/or make: +DISTCLEANFILES = gen-nutupsconf-aug.py + +# Generated by autogen.sh and needed to run the configure script: +MAINTAINERCLEANFILES += nutupsconf.aug.in + +DISTCLEANFILES += *.aug diff --git a/scripts/augeas/Makefile.in b/scripts/augeas/Makefile.in index d8fa703..d427b5c 100644 --- a/scripts/augeas/Makefile.in +++ b/scripts/augeas/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.16.3 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -13,8 +13,19 @@ # PARTICULAR PURPOSE. @SET_MAKE@ + VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -79,23 +90,24 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = scripts/augeas -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(srcdir)/nutnutconf.aug.in $(srcdir)/nutupsconf.aug.in \ - $(srcdir)/nutupsdconf.aug.in $(srcdir)/nutupsdusers.aug.in \ - $(srcdir)/nutupsmonconf.aug.in \ - $(srcdir)/nutupsschedconf.aug.in $(srcdir)/nuthostsconf.aug.in \ - $(srcdir)/nutupssetconf.aug.in README ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nut_arg_with.m4 \ $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ $(top_srcdir)/m4/nut_check_libavahi.m4 \ $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ $(top_srcdir)/m4/nut_check_libgd.m4 \ $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ $(top_srcdir)/m4/nut_check_libneon.m4 \ $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ $(top_srcdir)/m4/nut_check_libnss.m4 \ @@ -104,16 +116,22 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ $(top_srcdir)/m4/nut_check_libusb.m4 \ $(top_srcdir)/m4/nut_check_libwrap.m4 \ $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ $(top_srcdir)/m4/nut_type_socklen_t.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/config.h -CONFIG_CLEAN_FILES = nutnutconf.aug nutupsconf.aug nutupsdconf.aug \ - nutupsdusers.aug nutupsmonconf.aug nutupsschedconf.aug \ - nuthostsconf.aug nutupssetconf.aug +CONFIG_CLEAN_FILES = nutnutconf.aug nutupsdconf.aug nutupsdusers.aug \ + nutupsmonconf.aug nutupsschedconf.aug nuthostsconf.aug \ + nutupssetconf.aug gen-nutupsconf-aug.py nutupsconf.aug CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) @@ -134,7 +152,43 @@ am__can_run_installinfo = \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(auglensdir)" +DATA = $(auglens_DATA) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in \ + $(srcdir)/gen-nutupsconf-aug.py.in \ + $(srcdir)/nuthostsconf.aug.in $(srcdir)/nutnutconf.aug.in \ + $(srcdir)/nutupsconf.aug.in $(srcdir)/nutupsdconf.aug.in \ + $(srcdir)/nutupsdusers.aug.in $(srcdir)/nutupsmonconf.aug.in \ + $(srcdir)/nutupsschedconf.aug.in \ + $(srcdir)/nutupssetconf.aug.in README DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) A2X = @A2X@ ACLOCAL = @ACLOCAL@ @@ -143,6 +197,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -153,6 +208,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -166,6 +222,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -178,6 +235,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -195,6 +253,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -205,21 +265,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -239,6 +307,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -252,6 +323,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -269,6 +341,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -282,6 +355,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -307,12 +383,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -322,9 +400,26 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ udevdir = @udevdir@ -EXTRA_DIST = gen-nutupsconf-aug.py nutupsconf.aug.tpl \ +EXTRA_DIST = gen-nutupsconf-aug.py.in nutupsconf.aug.tpl \ README tests/test_nut.aug +# FIXME +# augparse -I $(srcdir)/ $(srcdir)/tests/test_nut.aug + +# Now "make install" should cover delivery of Augeas lenses... +# The "auglensdir" value should be set up by configure +# The *.aug files are generated by rule above or by autogen.sh and/or configure +@WITH_AUGLENS_TRUE@auglens_DATA = \ +@WITH_AUGLENS_TRUE@ nuthostsconf.aug nutupsconf.aug nutupsdusers.aug nutupsschedconf.aug \ +@WITH_AUGLENS_TRUE@ nutnutconf.aug nutupsdconf.aug nutupsmonconf.aug nutupssetconf.aug + + +# Generated by autogen.sh and needed to run the configure script: +MAINTAINERCLEANFILES = Makefile.in .dirstamp nutupsconf.aug.in +CLEANFILES = *-spellchecked + +# Can be re-generated by configure script and/or make: +DISTCLEANFILES = gen-nutupsconf-aug.py *.aug all: all-am .SUFFIXES: @@ -340,14 +435,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu scripts/augeas/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu scripts/augeas/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -360,8 +454,6 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__aclocal_m4_deps): nutnutconf.aug: $(top_builddir)/config.status $(srcdir)/nutnutconf.aug.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ -nutupsconf.aug: $(top_builddir)/config.status $(srcdir)/nutupsconf.aug.in - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ nutupsdconf.aug: $(top_builddir)/config.status $(srcdir)/nutupsdconf.aug.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ nutupsdusers.aug: $(top_builddir)/config.status $(srcdir)/nutupsdusers.aug.in @@ -374,12 +466,37 @@ nuthostsconf.aug: $(top_builddir)/config.status $(srcdir)/nuthostsconf.aug.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ nutupssetconf.aug: $(top_builddir)/config.status $(srcdir)/nutupssetconf.aug.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +gen-nutupsconf-aug.py: $(top_builddir)/config.status $(srcdir)/gen-nutupsconf-aug.py.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +nutupsconf.aug: $(top_builddir)/config.status $(srcdir)/nutupsconf.aug.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs +install-auglensDATA: $(auglens_DATA) + @$(NORMAL_INSTALL) + @list='$(auglens_DATA)'; test -n "$(auglensdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(auglensdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(auglensdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(auglensdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(auglensdir)" || exit $$?; \ + done + +uninstall-auglensDATA: + @$(NORMAL_UNINSTALL) + @list='$(auglens_DATA)'; test -n "$(auglensdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(auglensdir)'; $(am__uninstall_files_from_dir) tags TAGS: ctags CTAGS: @@ -387,7 +504,10 @@ ctags CTAGS: cscope cscopelist: -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -420,10 +540,15 @@ distdir: $(DISTFILES) $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-hook +@HAVE_AUGPARSE_FALSE@check-local: check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-local check: check-am -all-am: Makefile +all-am: Makefile $(DATA) installdirs: + for dir in "$(DESTDIR)$(auglensdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done install: install-am install-exec: install-exec-am install-data: install-data-am @@ -446,14 +571,17 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am @@ -474,7 +602,7 @@ info: info-am info-am: -install-data-am: +install-data-am: install-auglensDATA install-dvi: install-dvi-am @@ -518,36 +646,46 @@ ps: ps-am ps-am: -uninstall-am: +uninstall-am: uninstall-auglensDATA -.MAKE: install-am install-strip +.MAKE: check-am install-am install-strip -.PHONY: all all-am check check-am clean clean-generic clean-libtool \ - cscopelist-am ctags-am dist-hook distclean distclean-generic \ - distclean-libtool distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags-am uninstall uninstall-am +.PHONY: all all-am check check-am check-local clean clean-generic \ + clean-libtool cscopelist-am ctags-am dist-hook distclean \ + distclean-generic distclean-libtool distdir dvi dvi-am html \ + html-am info info-am install install-am install-auglensDATA \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ + uninstall-am uninstall-auglensDATA + +.PRECIOUS: Makefile # only call the script to generate Augeas ups.conf lens upon "make dist", -# and if Python is present +# and if Python is present; the distributed gen-nutupsconf-aug.py.in template +# is assumed to only differ from a generated gen-nutupsconf-aug.py by the +# @PYTHON@ shebang. dist-hook: - @if python -c "import re,glob,codecs"; then \ - echo "Regenerating Augeas ups.conf lens."; \ - $(distdir)/gen-nutupsconf-aug.py $(distdir)/; \ + @if [ -n "$(PYTHON)" ] && $(PYTHON) -c "import re,glob,codecs"; then \ + echo "Regenerating Augeas ups.conf lens with '$(PYTHON)'."; \ + $(PYTHON) $(distdir)/gen-nutupsconf-aug.py.in $(distdir)/; \ else \ echo "----------------------------------------------------------------------"; \ echo "Warning: Python is not available."; \ - echo "Skipping Augeas ups.conf lens regeneration."; \ + echo "Skipping regeneration of Augeas lens for ups.conf parsing." ; \ echo "----------------------------------------------------------------------"; \ fi +# This needs augparse from augeas-tools +@HAVE_AUGPARSE_TRUE@check-local: +@HAVE_AUGPARSE_TRUE@ @echo "augparse proceeding to lenses verification job..."; \ +@HAVE_AUGPARSE_TRUE@ echo "DISABLED for now due to https://github.com/networkupstools/nut/issues/657" + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/scripts/augeas/README b/scripts/augeas/README index a4ac27c..bfa03d3 100644 --- a/scripts/augeas/README +++ b/scripts/augeas/README @@ -57,7 +57,7 @@ These are the *.aug files in the present directory. You can either install the files to the right location on your system, generally in '/usr/share/augeas/lenses/', or use these from NUT -source directory ('nut/scripts/augeas'). The latter is to be prefered for +source directory ('nut/scripts/augeas'). The latter is to be preferred for the time being. @@ -240,7 +240,7 @@ a.set(("/files/etc/nut/upsd.users/%s/instcmds" % user), "ALL") monuser = "monuser" monpasswd = "******" a.set(("/files/etc/nut/upsd.users/%s/password" % monuser), monpasswd) -a.set(("/files/etc/nut/upsd.users/%s/upsmon" % monuser), "master") +a.set(("/files/etc/nut/upsd.users/%s/upsmon" % monuser), "primary") # Generate upsmon.conf a.set("/files/etc/nut/upsmon.conf/MONITOR/system/upsname", device_name) @@ -250,7 +250,7 @@ a.set("/files/etc/nut/upsmon.conf/MONITOR/system/upsname", device_name) a.set("/files/etc/nut/upsmon.conf/MONITOR/powervalue", "1") a.set("/files/etc/nut/upsmon.conf/MONITOR/username", monuser) a.set("/files/etc/nut/upsmon.conf/MONITOR/password", monpasswd) -a.set("/files/etc/nut/upsmon.conf/MONITOR/type", "master") +a.set("/files/etc/nut/upsmon.conf/MONITOR/type", "primary") # FIXME: glitch on the generated content a.set("/files/etc/nut/upsmon.conf/SHUTDOWNCMD", "/sbin/shutdown -h +0") diff --git a/scripts/augeas/gen-nutupsconf-aug.py b/scripts/augeas/gen-nutupsconf-aug.py.in similarity index 96% rename from scripts/augeas/gen-nutupsconf-aug.py rename to scripts/augeas/gen-nutupsconf-aug.py.in index 55db17a..04b6fa1 100755 --- a/scripts/augeas/gen-nutupsconf-aug.py +++ b/scripts/augeas/gen-nutupsconf-aug.py.in @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!@PYTHON@ # Copyright (C) 2010 - Arnaud Quette # # This program is free software; you can redistribute it and/or modify @@ -18,6 +18,8 @@ # This program extracts all drivers specific variables, declared # using 'addvar()' and output a complete ups.conf lens for Augeas +from __future__ import print_function + import sys import re import glob @@ -57,11 +59,11 @@ def grep(string,list): if __name__ == '__main__': rawCount = 0 - global finalCount + #global finalCount variableNames = [] specificVars = "" - global inLensContent - global finalLensContent + #global inLensContent + #global finalLensContent Exceptionlist = ['../../drivers/main.c', '../../drivers/skel.c'] outputFilename = 'nutupsconf.aug.in' templateFilename = 'nutupsconf.aug.tpl' @@ -69,7 +71,7 @@ if __name__ == '__main__': if (len(sys.argv) == 2): dirPrefix = sys.argv[1] - print dirPrefix + print(dirPrefix) # 1/ Extract all specific drivers parameters, in a sorted list with unique entries # 1.1/ List all drivers implementation files diff --git a/scripts/augeas/nutupsconf.aug.in b/scripts/augeas/nutupsconf.aug.in index 441b0a0..3c921f2 100644 --- a/scripts/augeas/nutupsconf.aug.in +++ b/scripts/augeas/nutupsconf.aug.in @@ -47,14 +47,42 @@ let ups_fields = "driver" | "ignorelb" | "maxstartdelay" | "synchronous" + | "BYPASS" + | "CHRG_addr" + | "CHRG_noro" + | "CHRG_regtype" | "CP" | "CS" + | "Could not addvar(%s)" + | "DISCHRG_addr" + | "DISCHRG_noro" + | "DISCHRG_regtype" + | "FSD_addr" + | "FSD_noro" + | "FSD_pulse_duration" + | "FSD_regtype" + | "HB_addr" + | "HB_noro" + | "HB_regtype" | "ID" | "LB" + | "LB_addr" + | "LB_noro" + | "LB_regtype" | "LowBatt" + | "OB_addr" + | "OB_noro" + | "OB_regtype" | "OL" + | "OL_addr" + | "OL_noro" + | "OL_regtype" | "OffDelay" | "OnDelay" + | "RB" + | "RB_addr" + | "RB_noro" + | "RB_regtype" | "SD" | "advanced_eco_mode" | "advorder" @@ -83,12 +111,23 @@ let ups_fields = "driver" | "community" | "constant_phase_angle" | "converter_mode" + | "cshdelay" | "daysoff" | "daysweek" + | "dev_slave_id" + | "device" + | "device_mfr" + | "device_model" + | "do_convert_deci" | "dumbterm" | "eco_mode" | "explore" | "fake_lowbatt" + | "fault_1" + | "fault_2" + | "fault_3" + | "fault_4" + | "fault_5" | "flash" | "frequency" | "fruid" @@ -96,8 +135,10 @@ let ups_fields = "driver" | "hb" | "houroff" | "houron" + | "i2c_address" | "idleload" | "ignoresab" + | "input_fault_voltage" | "input_timeout" | "interruptonly" | "interruptsize" @@ -115,6 +156,7 @@ let ups_fields = "driver" | "max_bypass_freq" | "max_bypass_volt" | "max_load" + | "max_polls_without_data" | "maxreport" | "methodOfFlowControl" | "mfr" @@ -123,21 +165,31 @@ let ups_fields = "driver" | "min_bypass_volt" | "mincharge" | "minruntime" + | "mod_byte_to_s" + | "mod_byte_to_us" + | "mod_resp_to_s" + | "mod_resp_to_us" | "model" | "modelname" + | "nobt" | "nohang" | "nombattvolt" + | "nominal_cell_voltage" | "norating" + | "noscanlangid" | "notification" | "notransferoids" | "novendor" | "nowarn_noimp" | "numOfBytesFromUPS" + | "number_of_battery_cells" | "offdelay" | "oldmac" | "ondelay" + | "onlinedischarge" | "output_pace" | "output_phase_angle" + | "output_voltages" | "password" | "pins_shutdown_mode" | "pollfreq" @@ -151,20 +203,31 @@ let ups_fields = "driver" | "productid" | "protocol" | "rebootdelay" + | "recharge_time" | "reset_to_default" + | "rio_slave_id" + | "runtime_full" + | "runtime_half" | "runtimecal" | "sdtime" | "sdtype" | "secLevel" | "secName" + | "semistaticfreq" + | "ser_baud_rate" + | "ser_data_bit" + | "ser_parity" + | "ser_stop_bit" | "serial" | "serialnumber" + | "series" | "shutdownArguments" | "shutdown_delay" | "shutdown_duration" | "shutdown_timer" | "silent" | "site_fault_detection" + | "slave_address" | "snmp_retries" | "snmp_timeout" | "snmp_version" @@ -173,6 +236,7 @@ let ups_fields = "driver" | "stayoff" | "subdriver" | "subscribe" + | "symmetrathreephase" | "testing" | "testtime" | "timeout" diff --git a/scripts/augeas/nutupsdconf.aug.in b/scripts/augeas/nutupsdconf.aug.in index d3aef1d..35bf896 100644 --- a/scripts/augeas/nutupsdconf.aug.in +++ b/scripts/augeas/nutupsdconf.aug.in @@ -39,6 +39,8 @@ let comment = Util.comment let path = word let upsd_maxage = [ opt_spc . key "MAXAGE" . sep_spc . store num . eol ] +let upsd_trackingdelay = [ opt_spc . key "TRACKINGDELAY" . sep_spc . store num . eol ] +let upsd_allow_no_device = [ opt_spc . key "ALLOW_NO_DEVICE" . sep_spc . store num . eol ] let upsd_statepath = [ opt_spc . key "STATEPATH" . sep_spc . store path . eol ] let upsd_listen = [ opt_spc . key "LISTEN" . sep_spc . [ label "interface" . store ip ] @@ -49,13 +51,15 @@ let upsd_certfile = [ opt_spc . key "CERTFILE" . sep_spc . store path . eol ] (************************************************************************ * MAXAGE seconds + * TRACKINGDELAY seconds + * ALLOW_NO_DEVICE Boolean * STATEPATH path * LISTEN interface port * Multiple LISTEN addresses may be specified. The default is to bind to 0.0.0.0 if no LISTEN addresses are specified. * LISTEN 127.0.0.1 LISTEN 192.168.50.1 LISTEN ::1 LISTEN 2001:0db8:1234:08d3:1319:8a2e:0370:7344 * *************************************************************************) -let upsd_other = upsd_maxage | upsd_statepath | upsd_listen_list | upsd_maxconn | upsd_certfile +let upsd_other = upsd_maxage | upsd_trackingdelay | upsd_allow_no_device | upsd_statepath | upsd_listen_list | upsd_maxconn | upsd_certfile let upsd_lns = (upsd_other|comment|empty)* diff --git a/scripts/augeas/nutupsdusers.aug.in b/scripts/augeas/nutupsdusers.aug.in index 242e64e..a138b61 100644 --- a/scripts/augeas/nutupsdusers.aug.in +++ b/scripts/augeas/nutupsdusers.aug.in @@ -67,7 +67,7 @@ let upsd_users_instcmds = [ del_spc let upsd_users_upsmon = [ del_spc . key "upsmon" . sep_spc - . store /master|slave/ . eol ] + . store /master|primary|slave|secondary/ . eol ] let upsd_users_title = IniFile.indented_title IniFile.record_re diff --git a/scripts/augeas/tests/test_nut.aug b/scripts/augeas/tests/test_nut.aug index 4153ed7..084fd84 100644 --- a/scripts/augeas/tests/test_nut.aug +++ b/scripts/augeas/tests/test_nut.aug @@ -27,6 +27,8 @@ test NutUpsConf.ups_lns get ups_conf = let upsd_conf = " MAXAGE 30 +TRACKINGDELAY 600 +ALLOW_NO_DEVICE 1 LISTEN 0.0.0.0 3493 MAXCONN 1024 " @@ -34,6 +36,8 @@ MAXCONN 1024 test NutUpsdConf.upsd_lns get upsd_conf = { } { "MAXAGE" = "30" } + { "TRACKINGDELAY" = "600" } + { "ALLOW_NO_DEVICE" = "1" } { "LISTEN" { "interface" = "0.0.0.0" } { "port" = "3493" } } @@ -50,13 +54,13 @@ let upsd_users = " instcmds = test.panel.start instcmds = test.panel.stop - [monmaster] + [upswired] password = blah - upsmon master + upsmon primary - [monslave] + [observer] password = abcd - upsmon slave + upsmon secondary " test NutUpsdUsers.upsd_users_lns get upsd_users = @@ -73,16 +77,16 @@ test NutUpsdUsers.upsd_users_lns get upsd_users = { "instcmds" = "test.panel.start" } { "instcmds" = "test.panel.stop" } { } } - { "monmaster" + { "upswired" { "password" = "blah" } - { "upsmon" = "master" } + { "upsmon" = "primary" } { } } - { "monslave" + { "observer" { "password" = "abcd" } - { "upsmon" = "slave" } } + { "upsmon" = "secondary" } } let upsmon_conf = " -MONITOR testups@localhost 1 monmaster blah master +MONITOR testups@localhost 1 upswired blah primary MINSUPPLIES 1 SHUTDOWNCMD /sbin/shutdown -h +0 @@ -103,9 +107,9 @@ test NutUpsmonConf.upsmon_lns get upsmon_conf = { "upsname" = "testups" } { "hostname" = "localhost" } } { "powervalue" = "1" } - { "username" = "monmaster" } + { "username" = "upswired" } { "password" = "blah" } - { "type" = "master" } } + { "type" = "primary" } } { } { "MINSUPPLIES" = "1" } { "SHUTDOWNCMD" = "/sbin/shutdown -h +0" } diff --git a/scripts/devd/Makefile.am b/scripts/devd/Makefile.am index e5a9bbc..c1c8097 100644 --- a/scripts/devd/Makefile.am +++ b/scripts/devd/Makefile.am @@ -9,6 +9,18 @@ endif EXTRA_DIST = README +MAINTAINERCLEANFILES = Makefile.in .dirstamp + +# Generated by configure script: DISTCLEANFILES = nut-usb.conf + # we should never remove this one, apart from a distclean-check #MAINTAINERCLEANFILES = nut-usbups.rules.in + +# Generated by autogen.sh and needed to run the configure script +# (technically, generated by tools/nut-usbinfo.pl script among +# GENERATED_USB_OS_FILES): +MAINTAINERCLEANFILES += nut-usbups.rules.in +MAINTAINERCLEANFILES += nut-usbups.rules.in.AUTOGEN_WITHOUT +MAINTAINERCLEANFILES += nut-usb.conf.in +MAINTAINERCLEANFILES += nut-usb.conf.in.AUTOGEN_WITHOUT diff --git a/scripts/devd/Makefile.in b/scripts/devd/Makefile.in index 094af7d..ae87b77 100644 --- a/scripts/devd/Makefile.in +++ b/scripts/devd/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.16.3 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -15,7 +15,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -81,19 +91,24 @@ host_triplet = @host@ target_triplet = @target@ @WITH_DEVD_TRUE@@WITH_USB_TRUE@am__append_1 = nut-usb.conf subdir = scripts/devd -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(srcdir)/nut-usb.conf.in README ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nut_arg_with.m4 \ $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ $(top_srcdir)/m4/nut_check_libavahi.m4 \ $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ $(top_srcdir)/m4/nut_check_libgd.m4 \ $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ $(top_srcdir)/m4/nut_check_libneon.m4 \ $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ $(top_srcdir)/m4/nut_check_libnss.m4 \ @@ -102,11 +117,17 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ $(top_srcdir)/m4/nut_check_libusb.m4 \ $(top_srcdir)/m4/nut_check_libwrap.m4 \ $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ $(top_srcdir)/m4/nut_type_socklen_t.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = nut-usb.conf @@ -160,6 +181,8 @@ am__uninstall_files_from_dir = { \ am__installdirs = "$(DESTDIR)$(devdconfdir)" DATA = $(devdconf_DATA) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/nut-usb.conf.in \ + README DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) A2X = @A2X@ ACLOCAL = @ACLOCAL@ @@ -168,6 +191,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -178,6 +202,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -191,6 +216,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -203,6 +229,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -220,6 +247,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -230,21 +259,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -264,6 +301,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -277,6 +317,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -294,6 +335,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -307,6 +349,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -332,12 +377,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -350,6 +397,18 @@ udevdir = @udevdir@ @WITH_DEVD_TRUE@devdconfdir = $(devddir) @WITH_DEVD_TRUE@devdconf_DATA = $(am__append_1) EXTRA_DIST = README + +# we should never remove this one, apart from a distclean-check +#MAINTAINERCLEANFILES = nut-usbups.rules.in + +# Generated by autogen.sh and needed to run the configure script +# (technically, generated by tools/nut-usbinfo.pl script among +# GENERATED_USB_OS_FILES): +MAINTAINERCLEANFILES = Makefile.in .dirstamp nut-usbups.rules.in \ + nut-usbups.rules.in.AUTOGEN_WITHOUT nut-usb.conf.in \ + nut-usb.conf.in.AUTOGEN_WITHOUT + +# Generated by configure script: DISTCLEANFILES = nut-usb.conf all: all-am @@ -366,14 +425,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu scripts/devd/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu scripts/devd/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -420,7 +478,10 @@ ctags CTAGS: cscope cscopelist: -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -488,6 +549,7 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am @@ -569,8 +631,8 @@ uninstall-am: uninstall-devdconfDATA mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ uninstall-am uninstall-devdconfDATA -# we should never remove this one, apart from a distclean-check -#MAINTAINERCLEANFILES = nut-usbups.rules.in +.PRECIOUS: Makefile + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/scripts/devd/nut-usb.conf.in b/scripts/devd/nut-usb.conf.in index b491415..c3c1e6c 100644 --- a/scripts/devd/nut-usb.conf.in +++ b/scripts/devd/nut-usb.conf.in @@ -1,7 +1,7 @@ # This file is generated and installed by the Network UPS Tools package. # Homepage: http://www.networkupstools.org/ -# ATCL FOR UPS - nutdrv_atcl_usb +# SNR-UPS-LID-XXXX UPSes - nutdrv_qx notify 100 { match "system" "USB"; match "subsystem" "DEVICE"; @@ -178,7 +178,9 @@ notify 100 { match "product" "0xffff"; action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; }; -# TS Shara UPSes - nutdrv_qx + +# ST Microelectronics +# TS Shara UPSes; vendor ID 0x0483 is from ST Microelectronics - with product IDs delegated to different OEMs - nutdrv_qx notify 100 { match "system" "USB"; match "subsystem" "DEVICE"; @@ -187,6 +189,26 @@ notify 100 { match "product" "0x0035"; action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; }; +# USB IDs device table - usbhid-ups +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x0483"; + match "product" "0xa113"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; + +# IBM +# 6000 VA LCD 4U Rack UPS; 5396-1Kx - usbhid-ups +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x04b3"; + match "product" "0x0001"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; # Riello (Cypress Semiconductor Corp.) # various models - riello_usb @@ -359,7 +381,7 @@ notify 100 { match "product" "0x0004"; action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; }; -# Agiler UPS - blazer_usb +# Agiler UPS - nutdrv_qx notify 100 { match "system" "USB"; match "subsystem" "DEVICE"; @@ -368,7 +390,27 @@ notify 100 { match "product" "0x0000"; action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; }; -# Belkin F6C1200-UNV - blazer_usb + +# Delta UPS +# Delta UPS Amplon R Series, Single Phase UPS, 1/2/3 kVA - usbhid-ups +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x05dd"; + match "product" "0x041b"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; +# Delta/Minuteman Enterprise Plus E1500RM2U - usbhid-ups +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x05dd"; + match "product" "0xa011"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; +# Belkin F6C1200-UNV/Voltronic Power UPSes - nutdrv_qx notify 100 { match "system" "USB"; match "subsystem" "DEVICE"; @@ -379,7 +421,7 @@ notify 100 { }; # Phoenixtec Power Co., Ltd -# various models - bcmxcp_usb +# Online Yunto YQ450 - nutdrv_qx notify 100 { match "system" "USB"; match "subsystem" "DEVICE"; @@ -388,7 +430,7 @@ notify 100 { match "product" "0x0002"; action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; }; -# Mustek Powermust - blazer_usb +# Mustek Powermust - nutdrv_qx notify 100 { match "system" "USB"; match "subsystem" "DEVICE"; @@ -397,7 +439,7 @@ notify 100 { match "product" "0x0003"; action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; }; -# Phoenixtec Innova 3/1 T - blazer_usb +# Phoenixtec Innova 3/1 T - nutdrv_qx notify 100 { match "system" "USB"; match "subsystem" "DEVICE"; @@ -406,7 +448,7 @@ notify 100 { match "product" "0x0004"; action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; }; -# Phoenixtec Innova RT - blazer_usb +# Phoenixtec Innova RT - nutdrv_qx notify 100 { match "system" "USB"; match "subsystem" "DEVICE"; @@ -415,7 +457,7 @@ notify 100 { match "product" "0x0005"; action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; }; -# Phoenixtec Innova T - blazer_usb +# Phoenixtec Innova T - nutdrv_qx notify 100 { match "system" "USB"; match "subsystem" "DEVICE"; @@ -424,7 +466,7 @@ notify 100 { match "product" "0x0201"; action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; }; -# Online Zinto A - blazer_usb +# Online Zinto A - nutdrv_qx notify 100 { match "system" "USB"; match "subsystem" "DEVICE"; @@ -433,7 +475,7 @@ notify 100 { match "product" "0x0601"; action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; }; -# various models - usbhid-ups +# PROTECT B / NAS - usbhid-ups notify 100 { match "system" "USB"; match "subsystem" "DEVICE"; @@ -547,6 +589,15 @@ notify 100 { match "product" "0x1010"; action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; }; +# e.g. TrippLite SU3000LCD2UHV - usbhid-ups +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x09ae"; + match "product" "0x1330"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; # e.g. TrippLite OMNI1000LCD - usbhid-ups notify 100 { match "system" "USB"; @@ -709,6 +760,15 @@ notify 100 { match "product" "0x3016"; action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; }; +# e.g. TrippLite AVR750U (newer unit) - usbhid-ups +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x09ae"; + match "product" "0x3024"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; # e.g. TrippLite SmartOnline SU1500RTXL2UA (older unit?) - usbhid-ups notify 100 { match "system" "USB"; @@ -846,7 +906,7 @@ notify 100 { match "product" "0x00a6"; action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; }; -# Unitek Alpha 1200Sx - blazer_usb +# Unitek Alpha 1200Sx - nutdrv_qx notify 100 { match "system" "USB"; match "subsystem" "DEVICE"; @@ -884,7 +944,7 @@ notify 100 { match "product" "0x0008"; action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; }; -# GE EP series - blazer_usb +# GE EP series - nutdrv_qx notify 100 { match "system" "USB"; match "subsystem" "DEVICE"; @@ -894,6 +954,93 @@ notify 100 { action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; }; +# Legrand +# Legrand Keor SP - usbhid-ups +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x1cb0"; + match "product" "0x0032"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; +# Legrand Daker DK / DK Plus - nutdrv_qx +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x1cb0"; + match "product" "0x0035"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; +# Legrand Keor PDU - usbhid-ups +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x1cb0"; + match "product" "0x0038"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; + +# Arduino +# Arduino Leonardo, Leonardo ETH and Pro Micro - usbhid-ups +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x2341"; + match "product" "0x0036"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; +# Arduino Leonardo, Leonardo ETH and Pro Micro - usbhid-ups +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x2341"; + match "product" "0x8036"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; + +# Arduino +# Arduino Leonardo, Leonardo ETH and Pro Micro - usbhid-ups +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x2A03"; + match "product" "0x0036"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; +# Arduino Leonardo, Leonardo ETH and Pro Micro - usbhid-ups +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x2A03"; + match "product" "0x0040"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; +# Arduino Leonardo, Leonardo ETH and Pro Micro - usbhid-ups +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x2A03"; + match "product" "0x8036"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; +# Arduino Leonardo, Leonardo ETH and Pro Micro - usbhid-ups +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x2A03"; + match "product" "0x8040"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; + # AEG # PROTECT B / NAS - usbhid-ups notify 100 { @@ -904,7 +1051,76 @@ notify 100 { match "product" "0xffff"; action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; }; -# Ablerex 625L USB - blazer_usb + +# Ever +# USB IDs device table - usbhid-ups +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x2e51"; + match "product" "0x0000"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; +# USB IDs device table - usbhid-ups +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x2e51"; + match "product" "0xffff"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; + +# Salicru +# SLC TWIN PRO2<=3KVA per https://github.com/networkupstools/nut/issues/450 - usbhid-ups +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x2e66"; + match "product" "0x0201"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; +# SLC TWIN PRO2<=3KVA per https://github.com/networkupstools/nut/issues/450 - usbhid-ups +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x2e66"; + match "product" "0x0202"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; +# SLC TWIN PRO2<=3KVA per https://github.com/networkupstools/nut/issues/450 - usbhid-ups +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x2e66"; + match "product" "0x0203"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; +# https://www.salicru.com/sps-home.html - usbhid-ups +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x2e66"; + match "product" "0x0300"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; + +# Powervar +# Powervar - usbhid-ups +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x4234"; + match "product" "0x0002"; + action "chgrp @RUN_AS_GROUP@ /dev/$cdev; chmod g+rw /dev/$cdev"; +}; +# Ablerex 625L USB (Note: earlier best-fit was "krauler_subdriver" before PR #1135) - nutdrv_qx notify 100 { match "system" "USB"; match "subsystem" "DEVICE"; diff --git a/scripts/hotplug/Makefile.am b/scripts/hotplug/Makefile.am index c36cd7d..06a6fe3 100644 --- a/scripts/hotplug/Makefile.am +++ b/scripts/hotplug/Makefile.am @@ -6,6 +6,16 @@ if WITH_HOTPLUG endif EXTRA_DIST = README + +MAINTAINERCLEANFILES = Makefile.in .dirstamp + +# Generated by configure script: DISTCLEANFILES = libhidups + # we should never remove this one, apart from a distclean-check #MAINTAINERCLEANFILES = libhid.usermap + +# Generated by autogen.sh and needed to run the configure script +# (technically, generated by tools/nut-usbinfo.pl script among +# GENERATED_USB_OS_FILES): +MAINTAINERCLEANFILES += libhid.usermap diff --git a/scripts/hotplug/Makefile.in b/scripts/hotplug/Makefile.in index 390e97e..3a11e14 100644 --- a/scripts/hotplug/Makefile.in +++ b/scripts/hotplug/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.16.3 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -16,7 +16,17 @@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -81,19 +91,24 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = scripts/hotplug -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(srcdir)/libhidups.in $(am__dist_hotplugusb_DATA_DIST) README ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nut_arg_with.m4 \ $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ $(top_srcdir)/m4/nut_check_libavahi.m4 \ $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ $(top_srcdir)/m4/nut_check_libgd.m4 \ $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ $(top_srcdir)/m4/nut_check_libneon.m4 \ $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ $(top_srcdir)/m4/nut_check_libnss.m4 \ @@ -102,11 +117,18 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ $(top_srcdir)/m4/nut_check_libusb.m4 \ $(top_srcdir)/m4/nut_check_libwrap.m4 \ $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ $(top_srcdir)/m4/nut_type_socklen_t.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__dist_hotplugusb_DATA_DIST) \ + $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = libhidups @@ -163,6 +185,7 @@ am__can_run_installinfo = \ am__dist_hotplugusb_DATA_DIST = libhid.usermap DATA = $(dist_hotplugusb_DATA) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/libhidups.in README DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) A2X = @A2X@ ACLOCAL = @ACLOCAL@ @@ -171,6 +194,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -181,6 +205,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -194,6 +219,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -206,6 +232,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -223,6 +250,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -233,21 +262,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -267,6 +304,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -280,6 +320,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -297,6 +338,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -310,6 +352,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -335,12 +380,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -354,6 +401,16 @@ udevdir = @udevdir@ @WITH_HOTPLUG_TRUE@dist_hotplugusb_DATA = libhid.usermap @WITH_HOTPLUG_TRUE@hotplugusb_SCRIPTS = libhidups EXTRA_DIST = README + +# we should never remove this one, apart from a distclean-check +#MAINTAINERCLEANFILES = libhid.usermap + +# Generated by autogen.sh and needed to run the configure script +# (technically, generated by tools/nut-usbinfo.pl script among +# GENERATED_USB_OS_FILES): +MAINTAINERCLEANFILES = Makefile.in .dirstamp libhid.usermap + +# Generated by configure script: DISTCLEANFILES = libhidups all: all-am @@ -370,14 +427,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu scripts/hotplug/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu scripts/hotplug/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -459,7 +515,10 @@ ctags CTAGS: cscope cscopelist: -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -527,6 +586,7 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am @@ -610,8 +670,8 @@ uninstall-am: uninstall-dist_hotplugusbDATA \ ps ps-am tags-am uninstall uninstall-am \ uninstall-dist_hotplugusbDATA uninstall-hotplugusbSCRIPTS -# we should never remove this one, apart from a distclean-check -#MAINTAINERCLEANFILES = libhid.usermap +.PRECIOUS: Makefile + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/scripts/hotplug/libhid.usermap b/scripts/hotplug/libhid.usermap index 7cee0ae..5a747e3 100644 --- a/scripts/hotplug/libhid.usermap +++ b/scripts/hotplug/libhid.usermap @@ -4,7 +4,7 @@ # libhidups 0x0003 0xVVVV 0xPPPP 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # # usb module match_flags idVendor idProduct bcdDevice_lo bcdDevice_hi bDeviceClass bDeviceSubClass bDeviceProtocol bInterfaceClass bInterfaceSubClass bInterfaceProtocol driver_info -# ATCL FOR UPS +# SNR-UPS-LID-XXXX UPSes libhidups 0x0003 0x0001 0x0000 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett Packard @@ -48,8 +48,16 @@ libhidups 0x0003 0x0463 0xffff 0x0000 0x0000 0x00 # Dell # various models libhidups 0x0003 0x047c 0xffff 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 -# TS Shara UPSes + +# ST Microelectronics +# TS Shara UPSes; vendor ID 0x0483 is from ST Microelectronics - with product IDs delegated to different OEMs libhidups 0x0003 0x0483 0x0035 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +# USB IDs device table +libhidups 0x0003 0x0483 0xa113 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 + +# IBM +# 6000 VA LCD 4U Rack UPS; 5396-1Kx +libhidups 0x0003 0x04b3 0x0001 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Riello (Cypress Semiconductor Corp.) # various models @@ -98,11 +106,17 @@ libhidups 0x0003 0x0592 0x0002 0x0000 0x0000 0x00 libhidups 0x0003 0x0592 0x0004 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Agiler UPS libhidups 0x0003 0x05b8 0x0000 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 -# Belkin F6C1200-UNV + +# Delta UPS +# Delta UPS Amplon R Series, Single Phase UPS, 1/2/3 kVA +libhidups 0x0003 0x05dd 0x041b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +# Delta/Minuteman Enterprise Plus E1500RM2U +libhidups 0x0003 0x05dd 0xa011 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +# Belkin F6C1200-UNV/Voltronic Power UPSes libhidups 0x0003 0x0665 0x5161 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Phoenixtec Power Co., Ltd -# various models +# Online Yunto YQ450 libhidups 0x0003 0x06da 0x0002 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Mustek Powermust libhidups 0x0003 0x06da 0x0003 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 @@ -114,7 +128,7 @@ libhidups 0x0003 0x06da 0x0005 0x0000 0x0000 0x00 libhidups 0x0003 0x06da 0x0201 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Online Zinto A libhidups 0x0003 0x06da 0x0601 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 -# various models +# PROTECT B / NAS libhidups 0x0003 0x06da 0xffff 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # iDowell @@ -144,6 +158,8 @@ libhidups 0x0003 0x09ae 0x1008 0x0000 0x0000 0x00 libhidups 0x0003 0x09ae 0x1009 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # e.g. TrippLite ECO550UPS libhidups 0x0003 0x09ae 0x1010 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +# e.g. TrippLite SU3000LCD2UHV +libhidups 0x0003 0x09ae 0x1330 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # e.g. TrippLite OMNI1000LCD libhidups 0x0003 0x09ae 0x2005 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # e.g. TrippLite OMNI900LCD @@ -180,6 +196,8 @@ libhidups 0x0003 0x09ae 0x3014 0x0000 0x0000 0x00 libhidups 0x0003 0x09ae 0x3015 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # e.g. TrippLite Smart1500LCD (newer unit) libhidups 0x0003 0x09ae 0x3016 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +# e.g. TrippLite AVR750U (newer unit) +libhidups 0x0003 0x09ae 0x3024 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # e.g. TrippLite SmartOnline SU1500RTXL2UA (older unit?) libhidups 0x0003 0x09ae 0x4001 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # e.g. TrippLite SmartOnline SU6000RT4U? @@ -225,8 +243,52 @@ libhidups 0x0003 0x10af 0x0008 0x0000 0x0000 0x00 # GE EP series libhidups 0x0003 0x14f0 0x00c9 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +# Legrand +# Legrand Keor SP +libhidups 0x0003 0x1cb0 0x0032 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +# Legrand Daker DK / DK Plus +libhidups 0x0003 0x1cb0 0x0035 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +# Legrand Keor PDU +libhidups 0x0003 0x1cb0 0x0038 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 + +# Arduino +# Arduino Leonardo, Leonardo ETH and Pro Micro +libhidups 0x0003 0x2341 0x0036 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +# Arduino Leonardo, Leonardo ETH and Pro Micro +libhidups 0x0003 0x2341 0x8036 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 + +# Arduino +# Arduino Leonardo, Leonardo ETH and Pro Micro +libhidups 0x0003 0x2A03 0x0036 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +# Arduino Leonardo, Leonardo ETH and Pro Micro +libhidups 0x0003 0x2A03 0x0040 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +# Arduino Leonardo, Leonardo ETH and Pro Micro +libhidups 0x0003 0x2A03 0x8036 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +# Arduino Leonardo, Leonardo ETH and Pro Micro +libhidups 0x0003 0x2A03 0x8040 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 + # AEG # PROTECT B / NAS libhidups 0x0003 0x2b2d 0xffff 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 -# Ablerex 625L USB + +# Ever +# USB IDs device table +libhidups 0x0003 0x2e51 0x0000 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +# USB IDs device table +libhidups 0x0003 0x2e51 0xffff 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 + +# Salicru +# SLC TWIN PRO2<=3KVA per https://github.com/networkupstools/nut/issues/450 +libhidups 0x0003 0x2e66 0x0201 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +# SLC TWIN PRO2<=3KVA per https://github.com/networkupstools/nut/issues/450 +libhidups 0x0003 0x2e66 0x0202 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +# SLC TWIN PRO2<=3KVA per https://github.com/networkupstools/nut/issues/450 +libhidups 0x0003 0x2e66 0x0203 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +# https://www.salicru.com/sps-home.html +libhidups 0x0003 0x2e66 0x0300 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 + +# Powervar +# Powervar +libhidups 0x0003 0x4234 0x0002 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 +# Ablerex 625L USB (Note: earlier best-fit was "krauler_subdriver" before PR #1135) libhidups 0x0003 0xffff 0x0000 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 diff --git a/scripts/perl/Nut.pm b/scripts/perl/Nut.pm index 8263c0d..f4f81f2 100644 --- a/scripts/perl/Nut.pm +++ b/scripts/perl/Nut.pm @@ -164,7 +164,7 @@ sub _initialize { # Author: Kit Peters my $self = shift; my %arg = @_; - my $host = $arg{HOST} || 'localhost'; # Host running master upsd + my $host = $arg{HOST} || 'localhost'; # Host running upsd and probably drivers my $port = $arg{PORT} || '3493'; # 3493 is IANA assigned port for NUT my $proto = $arg{PROTO} || 'tcp'; # use tcp unless user tells us to my $user = $arg{USERNAME} || undef; # username passed to upsd @@ -591,6 +591,8 @@ sub Master { # check for MASTER level access # Author: Kit Peters # ### changelog: uses the new _send command # +# TODO: API change pending to replace MASTER with PRIMARY +# (and backwards-compatible alias handling) my $self = shift; my $req = "MASTER $self->{name}"; # build request @@ -841,6 +843,9 @@ It is automatically done if connection closed. Use this to find out whether or not we have MASTER privileges for this UPS. Returns 1 if we have MASTER privileges, returns 0 otherwise. +TODO: API change pending to replace MASTER with PRIMARY +(and backwards-compatible alias handling) + =item ListVar($variable, ...) This is an implementation of "LIST VAR" command. diff --git a/scripts/python/Makefile.am b/scripts/python/Makefile.am index 0326725..313ace8 100644 --- a/scripts/python/Makefile.am +++ b/scripts/python/Makefile.am @@ -1,11 +1,24 @@ # Network UPS Tools: data/html +EXTRA_DIST_PY2GTK2 = \ + app/ui/gui-1.3.glade \ + app/NUT-Monitor-py2gtk2.in \ + app/nut-monitor-py2gtk2.desktop + +EXTRA_DIST_PY3QT5 = \ + app/ui/aboutdialog1.ui \ + app/ui/dialog1.ui \ + app/ui/dialog2.ui \ + app/ui/window1.ui \ + app/NUT-Monitor-py3qt5.in \ + app/nut-monitor-py3qt5.desktop + EXTRA_DIST = README \ - app/gui-1.3.glade \ - app/NUT-Monitor \ app/nut-monitor.appdata.xml \ - app/nut-monitor.desktop \ - app/nut-monitor.png \ + app/icons/48x48/nut-monitor.png \ + app/icons/64x64/nut-monitor.png \ + app/icons/256x256/nut-monitor.png \ + app/icons/scalable/nut-monitor.svg \ app/README \ app/pixmaps/var-rw.png \ app/pixmaps/on_line.png \ @@ -14,6 +27,14 @@ EXTRA_DIST = README \ app/pixmaps/var-ro.png \ app/locale/fr/LC_MESSAGES/NUT-Monitor.mo \ app/locale/it/LC_MESSAGES/NUT-Monitor.mo \ - module/PyNUT.py \ - module/test_nutclient.py + module/PyNUT.py.in \ + module/test_nutclient.py.in +# TODO: Make py2/py3-only builds, delivered preferred symlinks, etc. optional: +EXTRA_DIST += $(EXTRA_DIST_PY2GTK2) +EXTRA_DIST += $(EXTRA_DIST_PY3QT5) + +MAINTAINERCLEANFILES = Makefile.in .dirstamp + +clean-local: + rm -rf *.pyc __pycache__ */*.pyc */__pycache__ */*/*.pyc */*/__pycache__ diff --git a/scripts/python/Makefile.in b/scripts/python/Makefile.in index baf6384..b261063 100644 --- a/scripts/python/Makefile.in +++ b/scripts/python/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.16.3 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -16,7 +16,17 @@ # Network UPS Tools: data/html VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -81,18 +91,24 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = scripts/python -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am README ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nut_arg_with.m4 \ $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ $(top_srcdir)/m4/nut_check_libavahi.m4 \ $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ $(top_srcdir)/m4/nut_check_libgd.m4 \ $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ $(top_srcdir)/m4/nut_check_libneon.m4 \ $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ $(top_srcdir)/m4/nut_check_libnss.m4 \ @@ -101,11 +117,17 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ $(top_srcdir)/m4/nut_check_libusb.m4 \ $(top_srcdir)/m4/nut_check_libwrap.m4 \ $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ $(top_srcdir)/m4/nut_type_socklen_t.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = @@ -130,6 +152,7 @@ am__can_run_installinfo = \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in README DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) A2X = @A2X@ ACLOCAL = @ACLOCAL@ @@ -138,6 +161,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -148,6 +172,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -161,6 +186,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -173,6 +199,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -190,6 +217,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -200,21 +229,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -234,6 +271,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -247,6 +287,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -264,6 +305,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -277,6 +319,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -302,12 +347,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -317,23 +364,34 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ udevdir = @udevdir@ -EXTRA_DIST = README \ - app/gui-1.3.glade \ - app/NUT-Monitor \ - app/nut-monitor.appdata.xml \ - app/nut-monitor.desktop \ - app/nut-monitor.png \ - app/README \ - app/pixmaps/var-rw.png \ - app/pixmaps/on_line.png \ - app/pixmaps/warning.png \ - app/pixmaps/on_battery.png \ - app/pixmaps/var-ro.png \ - app/locale/fr/LC_MESSAGES/NUT-Monitor.mo \ - app/locale/it/LC_MESSAGES/NUT-Monitor.mo \ - module/PyNUT.py \ - module/test_nutclient.py +EXTRA_DIST_PY2GTK2 = \ + app/ui/gui-1.3.glade \ + app/NUT-Monitor-py2gtk2.in \ + app/nut-monitor-py2gtk2.desktop +EXTRA_DIST_PY3QT5 = \ + app/ui/aboutdialog1.ui \ + app/ui/dialog1.ui \ + app/ui/dialog2.ui \ + app/ui/window1.ui \ + app/NUT-Monitor-py3qt5.in \ + app/nut-monitor-py3qt5.desktop + + +# TODO: Make py2/py3-only builds, delivered preferred symlinks, etc. optional: +EXTRA_DIST = README app/nut-monitor.appdata.xml \ + app/icons/48x48/nut-monitor.png \ + app/icons/64x64/nut-monitor.png \ + app/icons/256x256/nut-monitor.png \ + app/icons/scalable/nut-monitor.svg app/README \ + app/pixmaps/var-rw.png app/pixmaps/on_line.png \ + app/pixmaps/warning.png app/pixmaps/on_battery.png \ + app/pixmaps/var-ro.png \ + app/locale/fr/LC_MESSAGES/NUT-Monitor.mo \ + app/locale/it/LC_MESSAGES/NUT-Monitor.mo module/PyNUT.py.in \ + module/test_nutclient.py.in $(EXTRA_DIST_PY2GTK2) \ + $(EXTRA_DIST_PY3QT5) +MAINTAINERCLEANFILES = Makefile.in .dirstamp all: all-am .SUFFIXES: @@ -349,14 +407,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu scripts/python/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu scripts/python/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -380,7 +437,10 @@ ctags CTAGS: cscope cscopelist: -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -444,9 +504,10 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am -clean-am: clean-generic clean-libtool mostlyclean-am +clean-am: clean-generic clean-libtool clean-local mostlyclean-am distclean: distclean-am -rm -f Makefile @@ -513,7 +574,7 @@ uninstall-am: .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic clean-libtool \ - cscopelist-am ctags-am distclean distclean-generic \ + clean-local cscopelist-am ctags-am distclean distclean-generic \ distclean-libtool distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ @@ -524,6 +585,11 @@ uninstall-am: mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags-am uninstall uninstall-am +.PRECIOUS: Makefile + + +clean-local: + rm -rf *.pyc __pycache__ */*.pyc */__pycache__ */*/*.pyc */*/__pycache__ # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/scripts/python/README b/scripts/python/README index 15932d9..9a96e71 100644 --- a/scripts/python/README +++ b/scripts/python/README @@ -7,6 +7,7 @@ David Goncalves, and released under GPL v3. * "module": this directory contains PyNUT.py, which is a Python abstraction class to access NUT server(s). You can use it in Python programs to access NUT's upsd data server in a simple way, without having to know the NUT protocol. +The same module should work for Python 2 and Python 3. To import it on Python programs you have to use the following (case sensitive) : 'import PyNUT' @@ -17,16 +18,24 @@ data from an upsd data server. To install the PyNUT module on Debian/Ubuntu, copy it to: /usr/share/python-support/python-pynut/ +For quick tests, just make sure its directory is exported in `PYTHONPATH` +environment variable. + This directory also contains test_nutclient.py, which is a PyNUT test program. For this to be fully functional, you will need to adapt the login, password and -upsname to fit your configuration. +upsname to fit your configuration. A NUT data server should be running for the +test program to verify connection and protocol support. * "app": this directory contains the NUT-Monitor application, that uses the PyNUT class, along with its resources. To install it, you will either need to keep the files together, or to install: -- NUT-Monitor to /usr/bin, /usr/X11R6/bin/ or something like that, -- gui.glade to /usr/share/nut-monitor/, +- Depending on the Python version(s) your system has, put NUT-Monitor-py2gtk2 + or NUT-Monitor-py3qt5 to /usr/bin/, /usr/X11R6/bin/ or something like that + (optionally making a simple NUT-Monitor symlink to the preferred version), +- ui/*.glade (for NUT-Monitor-py2gtk2) or ui/*.ui (for NUT-Monitor-py3qt5) + to /usr/share/nut-monitor/, - nut-monitor.png to something like /usr/share/pixmaps/ -- and nut-monitor.desktop to /usr/share/applications +- finally, nut-monitor-py2gtk2.desktop and/or nut-monitor-py3qt5.desktop + (optionally symlinked as nut-monitor.desktop) to /usr/share/applications/ diff --git a/scripts/python/app/NUT-Monitor b/scripts/python/app/NUT-Monitor-py2gtk2.in similarity index 99% rename from scripts/python/app/NUT-Monitor rename to scripts/python/app/NUT-Monitor-py2gtk2.in index 08dfaa4..d845e87 100755 --- a/scripts/python/app/NUT-Monitor +++ b/scripts/python/app/NUT-Monitor-py2gtk2.in @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!@PYTHON2@ # -*- coding: utf-8 -*- # 2009-12-27 David Goncalves - Version 1.2 @@ -76,7 +76,7 @@ class interface : ( cmd_opts, args ) = opt_parser.parse_args() - self.__glade_file = os.path.join( os.path.dirname( sys.argv[0] ), "gui-1.3.glade" ) + self.__glade_file = os.path.join( os.path.dirname( sys.argv[0] ), "ui/gui-1.3.glade" ) self.__widgets["interface"] = gtk.glade.XML( self.__glade_file, "window1", APP ) self.__widgets["main_window"] = self.__widgets["interface"].get_widget("window1") @@ -486,7 +486,7 @@ class interface : self.gui_status_message( error_msg ) except : - # Failed to get informations from the treeview... skip action + # Failed to get information from the treeview... skip action pass #------------------------------------------------------------------- @@ -813,7 +813,7 @@ class gui_updater( threading.Thread ) : self.__parent_class.gui_status_notification( _("Device is running on batteries"), "on_battery.png" ) was_online = False - # Check for additionnal informations + # Check for additionnal information for k,v in status_mapper.iteritems() : if vars.get("ups.status").find(k) != -1 : if ( text_right != "" ) : diff --git a/scripts/python/app/NUT-Monitor-py3qt5.in b/scripts/python/app/NUT-Monitor-py3qt5.in new file mode 100755 index 0000000..cf1c3b6 --- /dev/null +++ b/scripts/python/app/NUT-Monitor-py3qt5.in @@ -0,0 +1,944 @@ +#!@PYTHON3@ +# -*- coding: utf-8 -*- + +# 2009-12-27 David Goncalves - Version 1.2 +# Total rewrite of NUT-Monitor to optimize GUI interaction. +# Added favorites support (saved to user's home) +# Added status icon on the notification area +# +# 2010-02-26 David Goncalves +# Added UPS vars display and the possibility to change values +# when user double-clicks on a RW var. +# +# 2010-05-01 David Goncalves +# Added support for PyNotify (if available) +# +# 2010-05-05 David Goncalves +# Added support for command line options +# -> --start-hidden +# -> --favorite +# +# NUT-Monitor now tries to detect if there is a NUT server +# on localhost and if there is 1 UPS, connects to it. +# +# 2010-10-06 David Goncalves - Version 1.3 +# Added localisation support +# +# 2015-02-14 Michal Fincham - Version 1.3.1 +# Corrected unsafe permissions on ~/.nut-monitor (Debian #777706) +# +# 2022-02-20 Luke Dashjr - Version 2.0 +# Port to Python 3 with PyQt5. + + +import PyQt5.uic +from PyQt5.QtCore import * +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * +import sys +import base64 +import os, os.path +import stat +import platform +import time +import threading +import optparse +import configparser +import locale +import gettext +import PyNUT + + +class interface : + + DESIRED_FAVORITES_DIRECTORY_MODE = 0o700 + + __widgets = {} + __callbacks = {} + __favorites = {} + __favorites_file = None + __favorites_path = "" + __fav_menu_items = list() + __window_visible = True + __ui_file = None + __connected = False + __ups_handler = None + __ups_commands = None + __ups_vars = None + __ups_rw_vars = None + __gui_thread = None + __current_ups = None + + def __init__( self, argv ) : + + # Before anything, parse command line options if any present... + opt_parser = optparse.OptionParser() + opt_parser.add_option( "-H", "--start-hidden", action="store_true", default=False, dest="hidden", help="Start iconified in tray" ) + opt_parser.add_option( "-F", "--favorite", dest="favorite", help="Load the specified favorite and connect to UPS" ) + + ( cmd_opts, args ) = opt_parser.parse_args() + + + self.__app = QApplication( argv ) + + self.__ui_file = self.__find_res_file( 'ui', "window1.ui" ) + + self.__widgets["interface"] = PyQt5.uic.loadUi( self.__ui_file ) + self.__widgets["main_window"] = self.__widgets["interface"] + self.__widgets["status_bar"] = self.__widgets["interface"].statusbar2 + self.__widgets["ups_host_entry"] = self.__widgets["interface"].entry1 + self.__widgets["ups_port_entry"] = self.__widgets["interface"].spinbutton1 + self.__widgets["ups_refresh_button"] = self.__widgets["interface"].button1 + self.__widgets["ups_authentication_check"] = self.__widgets["interface"].checkbutton1 + self.__widgets["ups_authentication_frame"] = self.__widgets["interface"].hbox1 + self.__widgets["ups_authentication_login"] = self.__widgets["interface"].entry2 + self.__widgets["ups_authentication_password"] = self.__widgets["interface"].entry3 + self.__widgets["ups_list_combo"] = self.__widgets["interface"].combobox1 + self.__widgets["ups_commands_combo"] = self.__widgets["interface"].ups_commands_combo + self.__widgets["ups_commands_button"] = self.__widgets["interface"].button8 + self.__widgets["ups_connect"] = self.__widgets["interface"].button2 + self.__widgets["ups_disconnect"] = self.__widgets["interface"].button7 + self.__widgets["ups_params_box"] = self.__widgets["interface"].vbox6 + self.__widgets["ups_infos"] = self.__widgets["interface"].notebook1 + self.__widgets["ups_vars_tree"] = self.__widgets["interface"].treeview1 + self.__widgets["ups_vars_refresh"] = self.__widgets["interface"].button9 + self.__widgets["ups_status_image"] = self.__widgets["interface"].image1 + self.__widgets["ups_status_left"] = self.__widgets["interface"].label10 + self.__widgets["ups_status_right"] = self.__widgets["interface"].label11 + self.__widgets["ups_status_time"] = self.__widgets["interface"].label15 + self.__widgets["menu_favorites_root"] = self.__widgets["interface"].menu2 + self.__widgets["menu_favorites"] = self.__widgets["interface"].menu2 + self.__widgets["menu_favorites_add"] = self.__widgets["interface"].menuitem4 + self.__widgets["menu_favorites_del"] = self.__widgets["interface"].menuitem5 + self.__widgets["progress_battery_charge"] = self.__widgets["interface"].progressbar1 + self.__widgets["progress_battery_load"] = self.__widgets["interface"].progressbar2 + + # Create the tray icon and connect it to the show/hide method... + self.__widgets["status_icon"] = QSystemTrayIcon( QIcon( self.__find_res_file( "pixmaps", "on_line.png" ) ) ) + self.__widgets["status_icon"].setVisible( True ) + self.__widgets["status_icon"].activated.connect( self.tray_activated ) + + self.__widgets["ups_status_image"].setPixmap( QPixmap( self.__find_res_file( "pixmaps", "on_line.png" ) ) ) + + # Connect interface callbacks actions + self.__widgets["main_window"].destroyed.connect( self.quit ) + self.__widgets["interface"].imagemenuitem1.triggered.connect( self.gui_about_dialog ) + self.__widgets["interface"].imagemenuitem5.triggered.connect( self.quit ) + self.__widgets["ups_host_entry"].textChanged.connect( self.__check_gui_fields ) + self.__widgets["ups_authentication_login"].textChanged.connect( self.__check_gui_fields ) + self.__widgets["ups_authentication_password"].textChanged.connect( self.__check_gui_fields ) + self.__widgets["ups_authentication_check"].stateChanged.connect( self.__check_gui_fields ) + self.__widgets["ups_port_entry"].valueChanged.connect( self.__check_gui_fields ) + self.__widgets["ups_refresh_button"].clicked.connect( self.__update_ups_list ) + self.__widgets["ups_connect"].clicked.connect( self.connect_to_ups ) + self.__widgets["ups_disconnect"].clicked.connect( self.disconnect_from_ups ) + self.__widgets["ups_vars_refresh"].clicked.connect( self.__gui_update_ups_vars_view ) + self.__widgets["menu_favorites_add"].triggered.connect( self.__gui_add_favorite ) + self.__widgets["menu_favorites_del"].triggered.connect( self.__gui_delete_favorite ) + self.__widgets["ups_vars_tree"].doubleClicked.connect( self.__gui_ups_vars_selected ) + + # Remove the dummy combobox entry on UPS List and Commands + self.__widgets["ups_list_combo"].removeItem( 0 ) + + # Set UPS vars treeview properties ----------------------------- + store = QStandardItemModel( 0, 3, self.__widgets["ups_vars_tree"] ) + self.__widgets["ups_vars_tree"].setModel( store ) + self.__widgets["ups_vars_tree"].setHeaderHidden( False ) + self.__widgets["ups_vars_tree"].setRootIsDecorated( False ) + + # Column 0 + store.setHeaderData( 0, Qt.Horizontal, '' ) + + # Column 1 + store.setHeaderData( 1, Qt.Horizontal, _('Var name') ) + + # Column 2 + store.setHeaderData( 2, Qt.Horizontal, _('Value') ) + self.__widgets["ups_vars_tree"].header().setStretchLastSection( True ) + + self.__widgets["ups_vars_tree"].sortByColumn( 1, Qt.AscendingOrder ) + self.__widgets["ups_vars_tree_store"] = store + + self.__widgets["ups_vars_tree"].setMinimumSize( 0, 50 ) + #--------------------------------------------------------------- + + # UPS Commands combo box creation ------------------------------ + ups_commands_height = self.__widgets["ups_commands_combo"].size().height() * 2 + self.__widgets["ups_commands_combo"].setMinimumSize(0, ups_commands_height) + self.__widgets["ups_commands_combo"].setCurrentIndex( 0 ) + + self.__widgets["ups_commands_button"].setMinimumSize(0, ups_commands_height) + self.__widgets["ups_commands_button"].clicked.connect( self.__gui_send_ups_command ) + + self.__widgets["ups_commands_combo_store"] = self.__widgets["ups_commands_combo"] + #--------------------------------------------------------------- + + self.gui_init_unconnected() + + if ( cmd_opts.hidden != True ) : + self.__widgets["main_window"].show() + + # Define favorites path and load favorites + if ( platform.system() == "Linux" ) : + self.__favorites_path = os.path.join( os.environ.get("HOME"), ".nut-monitor" ) + elif ( platform.system() == "Windows" ) : + self.__favorites_path = os.path.join( os.environ.get("USERPROFILE"), "Application Data", "NUT-Monitor" ) + + self.__favorites_file = os.path.join( self.__favorites_path, "favorites.ini" ) + self.__parse_favorites() + + self.gui_status_message( _("Welcome to NUT Monitor") ) + + if ( cmd_opts.favorite != None ) : + if ( cmd_opts.favorite in self.__favorites ) : + self.__gui_load_favorite( fav_name=cmd_opts.favorite ) + self.connect_to_ups() + else : + # Try to scan localhost for available ups and connect to it if there is only one + self.__widgets["ups_host_entry"].setText( "localhost" ) + self.__update_ups_list() + if self.__widgets["ups_list_combo"].count() == 1: + self.connect_to_ups() + + def exec( self ) : + self.__app.exec() + + def __find_res_file( self, ftype, filename ) : + filename = os.path.join( ftype, filename ) + # TODO: Skip checking application directory if installed + path = os.path.join( os.path.dirname( sys.argv[0] ), filename ) + if os.path.exists(path): + return path + path = QStandardPaths.locate(QStandardPaths.AppDataLocation, filename) + if os.path.exists(path): + return path + raise RuntimeError("Cannot find %s resource %s" % (ftype, filename)) + + def __find_icon_file( self ) : + filename = 'nut-monitor.png' + # TODO: Skip checking application directory if installed + path = os.path.join( os.path.dirname( sys.argv[0] ), "icons", "256x256", filename ) + if os.path.exists(path): + return path + path = QStandardPaths.locate(QStandardPaths.AppDataLocation, os.path.join( "icons", "hicolor", "256x256", "apps", filename ) ) + if os.path.exists(path): + return path + raise RuntimeError("Cannot find %s resource %s" % ('icon', filename)) + + # Check if correct fields are filled to enable connection to the UPS + def __check_gui_fields( self, widget=None ) : + # If UPS list contains something, clear it + if self.__widgets["ups_list_combo"].currentIndex() != -1 : + self.__widgets["ups_list_combo"].clear() + self.__widgets["ups_connect"].setEnabled( False ) + self.__widgets["menu_favorites_add"].setEnabled( False ) + + # Host/Port selection + if len( self.__widgets["ups_host_entry"].text() ) > 0 : + sensitive = True + + # If authentication is selected, check that we have a login and password + if self.__widgets["ups_authentication_check"].isChecked() : + if len( self.__widgets["ups_authentication_login"].text() ) == 0 : + sensitive = False + + if len( self.__widgets["ups_authentication_password"].text() ) == 0 : + sensitive = False + + self.__widgets["ups_refresh_button"].setEnabled( sensitive ) + if not sensitive : + self.__widgets["ups_connect"].setEnabled( False ) + self.__widgets["menu_favorites_add"].setEnabled( False ) + else : + self.__widgets["ups_refresh_button"].setEnabled( False ) + self.__widgets["ups_connect"].setEnabled( False ) + self.__widgets["menu_favorites_add"].setEnabled( False ) + + # Use authentication fields... + if self.__widgets["ups_authentication_check"].isChecked() : + self.__widgets["ups_authentication_frame"].setEnabled( True ) + else : + self.__widgets["ups_authentication_frame"].setEnabled( False ) + + self.gui_status_message() + + #------------------------------------------------------------------- + # This method is used to show/hide the main window when user clicks on the tray icon + def tray_activated( self, widget=None, data=None ) : + if self.__window_visible : + self.__widgets["main_window"].hide() + else : + self.__widgets["main_window"].show() + + self.__window_visible = not self.__window_visible + + #------------------------------------------------------------------- + # Change the status icon and tray icon + def change_status_icon( self, icon="on_line", blink=False ) : + self.__widgets["status_icon"].setIcon( QIcon( self.__find_res_file( "pixmaps", "%s.png" % icon ) ) ) + self.__widgets["ups_status_image"].setPixmap( QPixmap( self.__find_res_file( "pixmaps", "%s.png" % icon ) ) ) + # TODO self.__widgets["status_icon"].set_blinking( blink ) + + #------------------------------------------------------------------- + # This method connects to the NUT server and retrieve availables UPSes + # using connection parameters (host, port, login, pass...) + def __update_ups_list( self, widget=None ) : + + host = self.__widgets["ups_host_entry"].text() + port = int( self.__widgets["ups_port_entry"].value() ) + login = None + password = None + + if self.__widgets["ups_authentication_check"].isChecked() : + login = self.__widgets["ups_authentication_login"].text() + password = self.__widgets["ups_authentication_password"].text() + + try : + nut_handler = PyNUT.PyNUTClient( host=host, port=port, login=login, password=password ) + upses = nut_handler.GetUPSList() + + ups_list = list(key.decode('ascii') for key in upses.keys()) + ups_list.sort() + + # If UPS list contains something, clear it + self.__widgets["ups_list_combo"].clear() + + for current in ups_list : + self.__widgets["ups_list_combo"].addItem( current ) + + self.__widgets["ups_list_combo"].setCurrentIndex( 0 ) + + self.__widgets["ups_connect"].setEnabled( True ) + self.__widgets["menu_favorites_add"].setEnabled( True ) + + self.gui_status_message( _("Found {0} devices on {1}").format( len( ups_list ), host ) ) + + except : + error_msg = _("Error connecting to '{0}' ({1})").format( host, sys.exc_info()[1] ) + self.gui_status_message( error_msg ) + + #------------------------------------------------------------------- + # Quit program + def quit( self, widget=None ) : + # If we are connected to an UPS, disconnect first... + if self.__connected : + self.gui_status_message( _("Disconnecting from device") ) + self.disconnect_from_ups() + + self.__app.quit() + + #------------------------------------------------------------------- + # Method called when user wants to add a new favorite entry. It + # displays a dialog to enable user to select the name of the favorite + def __gui_add_favorite( self, widget=None ) : + dialog_ui_file = self.__find_res_file( 'ui', "dialog1.ui" ) + dialog = PyQt5.uic.loadUi( dialog_ui_file ) + + # Define interface callbacks actions + def check_entry(val): + if self.__gui_add_favorite_check_gui_fields(val): + dialog.buttonBox.button(QDialogButtonBox.Ok).setEnabled( True ) + else: + dialog.buttonBox.button(QDialogButtonBox.Ok).setEnabled( False ) + dialog.entry4.textChanged.connect( check_entry ) + + self.__widgets["main_window"].setEnabled( False ) + rc = dialog.exec() + if rc == QDialog.Accepted : + fav_data = {} + fav_data["host"] = self.__widgets["ups_host_entry"].text() + fav_data["port"] = "%d" % self.__widgets["ups_port_entry"].value() + fav_data["ups"] = self.__widgets["ups_list_combo"].currentText() + fav_data["auth"] = self.__widgets["ups_authentication_check"].isChecked() + if fav_data["auth"] : + fav_data["login"] = self.__widgets["ups_authentication_login"].text() + fav_data["password"] = base64.b64encode( self.__widgets["ups_authentication_password"].text().encode('ascii') ).decode('ascii') + + fav_name = dialog.entry4.text() + self.__favorites[ fav_name ] = fav_data + self.__gui_refresh_favorites_menu() + + # Save all favorites + self.__save_favorites() + + self.__widgets["main_window"].setEnabled( True ) + + #------------------------------------------------------------------- + # Method called when user wants to delete an entry from favorites + def __gui_delete_favorite( self, widget=None ) : + dialog_ui_file = self.__find_res_file( 'ui', "dialog2.ui" ) + dialog = PyQt5.uic.loadUi( dialog_ui_file ) + + # Remove the dummy combobox entry on list + dialog.combobox2.removeItem( 0 ) + + favs = list(self.__favorites.keys()) + favs.sort() + for current in favs : + dialog.combobox2.addItem( current ) + + dialog.combobox2.setCurrentIndex( 0 ) + + self.__widgets["main_window"].setEnabled( False ) + rc = dialog.exec() + fav_name = dialog.combobox2.currentText() + self.__widgets["main_window"].setEnabled( True ) + + if ( rc == QDialog.Accepted ) : + # Remove entry, show confirmation dialog + resp = QMessageBox.question( None, self.__widgets["main_window"].windowTitle(), _("Are you sure that you want to remove this favorite ?"), QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes ) + + if ( resp == QMessageBox.Yes ) : + del self.__favorites[ fav_name ] + self.__gui_refresh_favorites_menu() + self.__save_favorites() + self.gui_status_message( _("Removed favorite '%s'") % fav_name ) + + #------------------------------------------------------------------- + # Method called when user selects a favorite from the favorites menu + def __gui_load_favorite( self, fav_name="" ) : + + if ( fav_name in self.__favorites ) : + # If auth is activated, process it before other fields to avoir weird + # reactions with the 'check_gui_fields' function. + if ( self.__favorites[fav_name].get("auth", False ) ) : + self.__widgets["ups_authentication_check"].setChecked( True ) + self.__widgets["ups_authentication_login"].setText( self.__favorites[fav_name].get("login","") ) + self.__widgets["ups_authentication_password"].setText( self.__favorites[fav_name].get("password","") ) + + self.__widgets["ups_host_entry"].setText( self.__favorites[fav_name].get("host","") ) + self.__widgets["ups_port_entry"].setValue( int( self.__favorites[fav_name].get( "port", 3493 ) ) ) + + # Clear UPS list and add current UPS name + self.__widgets["ups_list_combo"].clear() + + self.__widgets["ups_list_combo"].addItem( self.__favorites[fav_name].get("ups","") ) + self.__widgets["ups_list_combo"].setCurrentIndex( 0 ) + + # Activate the connect button + self.__widgets["ups_connect"].setEnabled( True ) + + self.gui_status_message( _("Loaded '%s'") % fav_name ) + + #------------------------------------------------------------------- + # Send the selected command to the UPS + def __gui_send_ups_command( self, widget=None ) : + offset = self.__widgets["ups_commands_combo"].currentIndex() + cmd = self.__ups_commands[ offset ].decode('ascii') + + self.__widgets["main_window"].setEnabled( False ) + resp = QMessageBox.question( None, self.__widgets["main_window"].windowTitle(), _("Are you sure that you want to send '%s' to the device ?") % cmd, QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes ) + self.__widgets["main_window"].setEnabled( True ) + + if ( resp == QMessageBox.Yes ) : + try : + self.__ups_handler.RunUPSCommand( self.__current_ups, cmd ) + self.gui_status_message( _("Sent '{0}' command to {1}").format( cmd, self.__current_ups ) ) + + except : + self.gui_status_message( _("Failed to send '{0}' ({1})").format( cmd, sys.exc_info()[1] ) ) + + #------------------------------------------------------------------- + # Method called when user clicks on the UPS vars treeview. If the user + # performs a double click on a RW var, the GUI shows the update var dialog. + def __gui_ups_vars_selected( self, index ) : + if True : + model = self.__widgets["ups_vars_tree_store"] + try : + ups_var = model.data( index.siblingAtColumn(1) ).encode('ascii') + if ( ups_var in self.__ups_rw_vars ) : + # The selected var is RW, then we can show the update dialog + + cur_val = self.__ups_rw_vars.get(ups_var).decode('ascii') + + self.__widgets["main_window"].setEnabled( False ) + new_val, rc = QInputDialog.getText( None, self.__widgets["main_window"].windowTitle(), _("Enter a new value for the variable.

{0} = {1} (current value)").format( ups_var, cur_val), QLineEdit.Normal, cur_val ) + self.__widgets["main_window"].setEnabled( True ) + + if ( rc ) : + try : + self.__ups_handler.SetRWVar( ups=self.__current_ups, var=ups_var.decode('ascii'), value=new_val ) + self.gui_status_message( _("Updated variable on %s") % self.__current_ups ) + + # Change the value on the local dict to update the GUI + new_val = new_val.encode('ascii') + self.__ups_vars[ups_var] = new_val + self.__ups_rw_vars[ups_var] = new_val + self.__gui_update_ups_vars_view() + + except : + error_msg = _("Error updating variable on '{0}' ({1})").format( self.__current_ups, sys.exc_info()[1] ) + self.gui_status_message( error_msg ) + + else : + # User cancelled modification... + error_msg = _("No variable modified on %s - User cancelled") % self.__current_ups + self.gui_status_message( error_msg ) + + except : + # Failed to get information from the treeview... skip action + pass + + #------------------------------------------------------------------- + # Refresh the content of the favorites menu according to the defined favorites + def __gui_refresh_favorites_menu( self ) : + for current in self.__fav_menu_items : + self.__widgets["menu_favorites"].removeAction(current) + + self.__fav_menu_items = list() + + items = list(self.__favorites.keys()) + items.sort() + + for current in items : + menu_item = QAction( current ) + self.__fav_menu_items.append( menu_item ) + self.__widgets["menu_favorites"].addAction( menu_item ) + + menu_item.triggered.connect( lambda: self.__gui_load_favorite( current ) ) + + if len( items ) > 0 : + self.__widgets["menu_favorites_del"].setEnabled( True ) + else : + self.__widgets["menu_favorites_del"].setEnabled( False ) + + #------------------------------------------------------------------- + # In 'add favorites' dialog, this method compares the content of the + # text widget representing the name of the new favorite with existing + # ones. If they match, the 'add' button will be set to non sensitive + # to avoid creating entries with the same name. + def __gui_add_favorite_check_gui_fields( self, fav_name ) : + if ( len( fav_name ) > 0 ) and ( fav_name not in list(self.__favorites.keys()) ) : + return True + else : + return False + + #------------------------------------------------------------------- + # Load and parse favorites + def __parse_favorites( self ) : + + if ( not os.path.exists( self.__favorites_file ) ) : + # There is no favorites files, do nothing + return + + try : + if ( not stat.S_IMODE( os.stat( self.__favorites_path ).st_mode ) == self.DESIRED_FAVORITES_DIRECTORY_MODE ) : # unsafe pre-1.2 directory found + os.chmod( self.__favorites_path, self.DESIRED_FAVORITES_DIRECTORY_MODE ) + + conf = configparser.ConfigParser() + conf.read( self.__favorites_file ) + for current in conf.sections() : + # Check if mandatory fields are present + if ( conf.has_option( current, "host" ) and conf.has_option( current, "ups" ) ) : + # Valid entry found, add it to the list + fav_data = {} + fav_data["host"] = conf.get( current, "host" ) + fav_data["ups"] = conf.get( current, "ups" ) + + if ( conf.has_option( current, "port" ) ) : + fav_data["port"] = conf.get( current, "port" ) + else : + fav_data["port"] = "3493" + + # If auth is defined the section must have login and pass defined + if ( conf.has_option( current, "auth" ) ) : + if( conf.has_option( current, "login" ) and conf.has_option( current, "password" ) ) : + # Add the entry + fav_data["auth"] = conf.getboolean( current, "auth" ) + fav_data["login"] = conf.get( current, "login" ) + + try : + fav_data["password"] = base64.decodebytes( conf.get( current, "password" ).encode('ascii') ).decode('ascii') + + except : + # If the password is not in base64, let the field empty + print(( _("Error parsing favorites, password for '%s' is not in base64\nSkipping password for this entry") % current )) + fav_data["password"] = "" + else : + fav_data["auth"] = False + + self.__favorites[current] = fav_data + self.__gui_refresh_favorites_menu() + + except : + self.gui_status_message( _("Error while parsing favorites file (%s)") % sys.exc_info()[1] ) + + #------------------------------------------------------------------- + # Save favorites to the defined favorites file using ini format + def __save_favorites( self ) : + + # If path does not exists, try to create it + if ( not os.path.exists( self.__favorites_file ) ) : + try : + os.makedirs( self.__favorites_path, mode=self.DESIRED_FAVORITES_DIRECTORY_MODE, exist_ok=True ) + except : + self.gui_status_message( _("Error while creating configuration folder (%s)") % sys.exc_info()[1] ) + + save_conf = configparser.ConfigParser() + for current in list(self.__favorites.keys()) : + save_conf.add_section( current ) + for k, v in self.__favorites[ current ].items() : + if isinstance( v, bool ) : + v = str( v ) + save_conf.set( current, k, v ) + + try : + fh = open( self.__favorites_file, "w" ) + save_conf.write( fh ) + fh.close() + self.gui_status_message( _("Saved favorites...") ) + + except : + self.gui_status_message( _("Error while saving favorites (%s)") % sys.exc_info()[1] ) + + #------------------------------------------------------------------- + # Display the about dialog + def gui_about_dialog( self, widget=None ) : + self.__widgets["main_window"].adjustSize() + dialog_ui_file = self.__find_res_file( 'ui', "aboutdialog1.ui" ) + + dialog = PyQt5.uic.loadUi( dialog_ui_file ) + dialog.icon.setPixmap( QPixmap( self.__find_icon_file() ) ) + + credits_button = QPushButton( dialog ) + credits_button.setText( _("C&redits") ) + credits_button.setIcon( dialog.style().standardIcon( QStyle.SP_MessageBoxInformation ) ) + credits_button.clicked.connect( self.gui_about_credits ) + + licence_button = QPushButton( dialog ) + licence_button.setText( _("&Licence") ) + licence_button.clicked.connect( self.gui_about_licence ) + + dialog.buttonBox.addButton( credits_button, QDialogButtonBox.HelpRole ) + dialog.buttonBox.addButton( licence_button, QDialogButtonBox.HelpRole ) + + self.__widgets["main_window"].setEnabled( False ) + dialog.exec() + self.__widgets["main_window"].setEnabled( True ) + + def gui_about_credits( self ) : + QMessageBox.about( None, _("Credits"), _(""" +Written by: +David Goncalves + +Translated by: +David Goncalves - Français +Daniele Pezzini - Italiano + """).strip() ) + + def gui_about_licence( self ) : + QMessageBox.about( None, _("Licence"), _(""" +Copyright (C) 2010 David Goncalves + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + """).strip() ) + + #------------------------------------------------------------------- + # Display a message on the status bar. The message is also set as + # tooltip to enable users to see long messages. + def gui_status_message( self, msg="" ) : + text = msg + + message_id = self.__widgets["status_bar"].showMessage( text.replace("\n", "") ) + self.__widgets["status_bar"].setToolTip( text ) + + #------------------------------------------------------------------- + # Display a notification using QSystemTrayIcon with an optional icon + def gui_status_notification( self, message="", icon_file="" ) : + if ( icon_file != "" ) : + icon = QIcon( os.path.abspath( self.__find_res_file( "pixmaps", icon_file ) ) ) + else : + icon = None + + self.__widgets["status_icon"].showMessage( "NUT Monitor", message, icon ) + + #------------------------------------------------------------------- + # Connect to the selected UPS using parameters (host,port,login,pass) + def connect_to_ups( self, widget=None ) : + + host = self.__widgets["ups_host_entry"].text() + port = int( self.__widgets["ups_port_entry"].value() ) + login = None + password = None + + if self.__widgets["ups_authentication_check"].isChecked() : + login = self.__widgets["ups_authentication_login"].text() + password = self.__widgets["ups_authentication_password"].text() + + try : + self.__ups_handler = PyNUT.PyNUTClient( host=host, port=port, login=login, password=password ) + + except : + self.gui_status_message( _("Error connecting to '{0}' ({1})").format( host, sys.exc_info()[1] ) ) + self.gui_status_notification( _("Error connecting to '{0}'\n{1}").format( host, sys.exc_info()[1] ), "warning.png" ) + return + + # Check if selected UPS exists on server... + srv_upses = self.__ups_handler.GetUPSList() + self.__current_ups = self.__widgets["ups_list_combo"].currentText() + + if self.__current_ups.encode('ascii') not in srv_upses : + self.gui_status_message( _("Device '%s' not found on server") % self.__current_ups ) + self.gui_status_notification( _("Device '%s' not found on server") % self.__current_ups, "warning.png" ) + return + + self.__connected = True + self.__widgets["ups_connect"].hide() + self.__widgets["ups_disconnect"].show() + self.__widgets["ups_infos"].show() + self.__widgets["ups_params_box"].setEnabled( False ) + self.__widgets["menu_favorites_root"].setEnabled( False ) + self.__widgets["ups_params_box"].hide() + + commands = self.__ups_handler.GetUPSCommands( self.__current_ups ) + self.__ups_commands = list(commands.keys()) + self.__ups_commands.sort() + + # Refresh UPS commands combo box + self.__widgets["ups_commands_combo_store"].clear() + for desc in self.__ups_commands : + # TODO: Style as "%s
%s" + self.__widgets["ups_commands_combo_store"].addItem( "%s\n%s" % ( desc.decode('ascii'), commands[desc].decode('ascii') ) ) + + self.__widgets["ups_commands_combo"].setCurrentIndex( 0 ) + + # Update UPS vars manually before the thread + self.__ups_vars = self.__ups_handler.GetUPSVars( self.__current_ups ) + self.__ups_rw_vars = self.__ups_handler.GetRWVars( self.__current_ups ) + self.__gui_update_ups_vars_view() + + # Try to resize the main window... + # FIXME: For some reason, calling this immediately doesn't work right + QTimer.singleShot(10, self.__widgets["main_window"].adjustSize) + + # Start the GUI updater thread + self.__gui_thread = gui_updater( self ) + self.__gui_thread.start() + + self.gui_status_message( _("Connected to '{0}' on {1}").format( self.__current_ups, host ) ) + + + #------------------------------------------------------------------- + # Refresh UPS vars in the treeview + def __gui_update_ups_vars_view( self, widget=None ) : + if self.__ups_handler : + vars = self.__ups_vars + rwvars = self.__ups_rw_vars + + self.__widgets["ups_vars_tree_store"].removeRows(0, self.__widgets["ups_vars_tree_store"].rowCount()) + + for k,v in vars.items() : + if ( k in rwvars ) : + icon_file = self.__find_res_file( "pixmaps", "var-rw.png" ) + else : + icon_file = self.__find_res_file( "pixmaps", "var-ro.png" ) + + icon = QIcon( icon_file ) + item_icon = QStandardItem(icon, '') + item_icon.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemNeverHasChildren) + item_var_name = QStandardItem( k.decode('ascii') ) + item_var_name.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemNeverHasChildren) + item_var_val = QStandardItem( v.decode('ascii') ) + item_var_val.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemNeverHasChildren) + self.__widgets["ups_vars_tree_store"].appendRow( (item_icon, item_var_name, item_var_val) ) + self.__widgets["ups_vars_tree"].resizeColumnToContents( 0 ) + self.__widgets["ups_vars_tree"].resizeColumnToContents( 1 ) + + + def gui_init_unconnected( self ) : + self.__connected = False + self.__widgets["ups_connect"].show() + self.__widgets["ups_disconnect"].hide() + self.__widgets["ups_infos"].hide() + self.__widgets["ups_params_box"].setEnabled( True ) + self.__widgets["menu_favorites_root"].setEnabled( True ) + self.__widgets["status_icon"].setToolTip( _("Not connected") ) + self.__widgets["ups_params_box"].show() + + # Try to resize the main window... + self.__widgets["main_window"].adjustSize() + + #------------------------------------------------------------------- + # Disconnect from the UPS + def disconnect_from_ups( self, widget=None ) : + self.gui_init_unconnected() + + # Stop the GUI updater thread + self.__gui_thread.stop_thread() + + del self.__ups_handler + self.gui_status_message( _("Disconnected from '%s'") % self.__current_ups ) + self.change_status_icon( "on_line", blink=False ) + self.__current_ups = None + +#----------------------------------------------------------------------- +# GUI Updater class +# This class updates the main gui with data from connected UPS +class gui_updater : + + __parent_class = None + __stop_thread = False + + def __init__( self, parent_class ) : + threading.Thread.__init__( self ) + self.__parent_class = parent_class + + def start( self ) : + self.__timer = QTimer() + self.__timer.timeout.connect(self.__update) + self.__timer.start(1000) + + def __update( self ) : + + ups = self.__parent_class._interface__current_ups + was_online = True + + # Define a dict containing different UPS status + status_mapper = { b"LB" : "%s" % _("Low batteries"), + b"RB" : "%s" % _("Replace batteries !"), + b"BYPASS" : "Bypass %s" % _("(no battery protection)"), + b"CAL" : _("Performing runtime calibration"), + b"OFF" : "%s (%s)" % ( _("Offline"), _("not providing power to the load") ), + b"OVER" : "%s (%s)" % ( _("Overloaded !"), _("there is too much load for device") ), + b"TRIM" : _("Triming (UPS is triming incoming voltage)"), + b"BOOST" : _("Boost (UPS is boosting incoming voltage)") + } + + if not self.__stop_thread : + try : + vars = self.__parent_class._interface__ups_handler.GetUPSVars( ups ) + self.__parent_class._interface__ups_vars = vars + + # Text displayed on the status frame + text_left = "" + text_right = "" + status_text = "" + + text_left += "%s
" % _("Device status :") + + if ( vars.get(b"ups.status").find(b"OL") != -1 ) : + text_right += "%s" % _("Online") + if not was_online : + self.__parent_class.change_status_icon( "on_line", blink=False ) + was_online = True + + if ( vars.get(b"ups.status").find(b"OB") != -1 ) : + text_right += "%s" % _("On batteries") + if was_online : + self.__parent_class.change_status_icon( "on_battery", blink=True ) + self.__parent_class.gui_status_notification( _("Device is running on batteries"), "on_battery.png" ) + was_online = False + + # Check for additionnal information + for k,v in status_mapper.items() : + if vars.get(b"ups.status").find(k) != -1 : + if ( text_right != "" ) : + text_right += " - %s" % v + else : + text_right += "%s" % v + + # CHRG and DISCHRG cannot be trated with the previous loop ;) + if ( vars.get(b"ups.status").find(b"DISCHRG") != -1 ) : + text_right += " - %s" % _("discharging") + elif ( vars.get(b"ups.status").find(b"CHRG") != -1 ) : + text_right += " - %s" % _("charging") + + status_text += text_right + text_right += "
" + + if ( b"ups.mfr" in vars ) : + text_left += "%s

" % _("Model :") + text_right += "%s
%s
" % ( + vars.get(b"ups.mfr",b"").decode('ascii'), + vars.get(b"ups.model",b"").decode('ascii'), + ) + + if ( b"ups.temperature" in vars ) : + text_left += "%s
" % _("Temperature :") + text_right += "%s
" % int( float( vars.get( b"ups.temperature", 0 ) ) ) + + if ( b"battery.voltage" in vars ) : + text_left += "%s
" % _("Battery voltage :") + text_right += "%sv
" % (vars.get( b"battery.voltage", 0 ).decode('ascii'),) + + self.__parent_class._interface__widgets["ups_status_left"].setText( text_left[:-4] ) + self.__parent_class._interface__widgets["ups_status_right"].setText( text_right[:-4] ) + + # UPS load and battery charge progress bars + self.__parent_class._interface__widgets["progress_battery_charge"].setRange( 0, 100 ) + if ( b"battery.charge" in vars ) : + charge = vars.get( b"battery.charge", "0" ) + self.__parent_class._interface__widgets["progress_battery_charge"].setValue( int( float( charge ) ) ) + self.__parent_class._interface__widgets["progress_battery_charge"].resetFormat() + status_text += "
%s %s%%" % ( _("Battery charge :"), int( float( charge ) ) ) + else : + self.__parent_class._interface__widgets["progress_battery_charge"].setValue( 0 ) + self.__parent_class._interface__widgets["progress_battery_charge"].setFormat( _("Not available") ) + # FIXME: Some themes don't draw text, so swap it with a QLabel? + + self.__parent_class._interface__widgets["progress_battery_load"].setRange( 0, 100 ) + if ( b"ups.load" in vars ) : + load = vars.get( b"ups.load", "0" ) + self.__parent_class._interface__widgets["progress_battery_load"].setValue( int( float( load ) ) ) + self.__parent_class._interface__widgets["progress_battery_load"].resetFormat() + status_text += "
%s %s%%" % ( _("UPS load :"), int( float( load ) ) ) + else : + self.__parent_class._interface__widgets["progress_battery_load"].setValue( 0 ) + self.__parent_class._interface__widgets["progress_battery_load"].setFormat( _("Not available") ) + # FIXME: Some themes don't draw text, so swap it with a QLabel? + + if ( b"battery.runtime" in vars ) : + autonomy = int( float( vars.get( b"battery.runtime", 0 ) ) ) + + if ( autonomy >= 3600 ) : + info = time.strftime( _("%H hours %M minutes %S seconds"), time.gmtime( autonomy ) ) + elif ( autonomy > 300 ) : + info = time.strftime( _("%M minutes %S seconds"), time.gmtime( autonomy ) ) + else : + info = time.strftime( _("%M minutes %S seconds"), time.gmtime( autonomy ) ) + else : + info = _("Not available") + + self.__parent_class._interface__widgets["ups_status_time"].setText( info ) + + # Display UPS status as tooltip for tray icon + self.__parent_class._interface__widgets["status_icon"].setToolTip( status_text ) + + except : + self.__parent_class.gui_status_message( _("Error from '{0}' ({1})").format( ups, sys.exc_info()[1] ) ) + self.__parent_class.gui_status_notification( _("Error from '{0}'\n{1}").format( ups, sys.exc_info()[1] ), "warning.png" ) + + def stop_thread( self ) : + self.__timer.stop() + + +#----------------------------------------------------------------------- +# The main program starts here :-) +if __name__ == "__main__" : + + # Init the localisation + APP = "NUT-Monitor" + DIR = "locale" + + gettext.bindtextdomain( APP, DIR ) + gettext.textdomain( APP ) + _ = gettext.gettext + + for module in ( gettext, ) : + module.bindtextdomain( APP, DIR ) + module.textdomain( APP ) + + gui = interface(sys.argv) + gui.exec() + diff --git a/scripts/python/app/README b/scripts/python/app/README index 2285f2c..163c4ae 100644 --- a/scripts/python/app/README +++ b/scripts/python/app/README @@ -1,7 +1,55 @@ -NUT-Monitor is a graphical application to access and manager UPSes connected to +NUT-Monitor +=========== + +NUT-Monitor is a graphical application to access and manage UPSes connected to a NUT (Network UPS Tools) server. -This application (written in Python + GTK) uses the python-pynut class -(available at http://www.lestat.st) +Dependencies +------------ -David Goncalves +This application (variants written in Python 2 + GTK2, and in Python 3 + Qt5) +uses the python-pynut class (available at http://www.lestat.st), delivered +as PyNUT in the NUT source tree. + +Refer to your OS packaging and/or install custom modules with `pip` (or `pip3`) +to get required dependencies (GTK + GObject or QT5). + +Path to PyNUT module +-------------------- + +For quick tests (e.g. during development), you can run the clients like this: +```` +:; PYTHONPATH=../module/ python2 ./NUT-Monitor-py2gtk2.in +```` +or: +```` +:; PYTHONPATH=../module/ python3 ./NUT-Monitor-py3qt5.in +```` + +Localization +------------ + +For localized UI, also `export LANG=fr_FR.UTF-8` or `export LANG=ru_RU.UTF-8` +(see and feel welcome to improve the choice of languages in `locale` directory). + +NOTE: Currently localization only works for Python 2 client, PRs are welcome. + +Desktop menu integration +------------------------ + +This component ships both implementation-specific `nut-monitor-py2gtk2.desktop` +and `nut-monitor-py3qt5.desktop` files which allows a user to have icons for +both variants separately, as well as the legacy-named `nut-monitor.desktop` +for running the wrapper script `NUT-Monitor` which picks an implementation best +suited for current run-time circumstances. + +Kudos +----- + +NUT-Monitor and PyNUT (for Python 2 syntax) were originally authored +by David Goncalves + +NUT-Monitor was converted to Python 3 + QT5 by Luke Dashjr + +PyNUT was extended, and two variants of NUT-Monitor converged and wrapped +for Python 2+3 dual support by Jim Klimov diff --git a/scripts/python/app/icons/256x256/nut-monitor.png b/scripts/python/app/icons/256x256/nut-monitor.png new file mode 100644 index 0000000000000000000000000000000000000000..15f472a5bd72e5e5e9ba1ecc9cba4ffd35557ee9 GIT binary patch literal 16860 zcmdUX1y`F-^yZrooI-FY7NodCaS0A>(W1p2iWevjf#RiT1t``6h2k#7U5ZoOf|cU# z1UA3_?tXr92RbtCnu$UM6 z|MkQDuKnN=7ef0;=2Bd-;KrAMxj6x(2{aHOr4Zf#jX$+flNTrs=bs=FXx9S{!&W(o z&1}PEBf5QpH|#4z%FCZ1ml<)|1u%(c4T7l|qM7c*h-C`8)o~P`*hzpmy2|#7QRp-Docx_MG;E4%tYstabAjdq`Tl7Lc8~+kcVg9e zSU!LYVua+WGAek=zSH{GfWGgqbqKE0mQ1L!CoTk( z2$2J`fN-F=Em^NYsx<(CoZxUYpAwi+IdL1R69?;o>JWJO0gPBw^d?;$`!oD|`+u?x zsb@gVc%8+78AcbE&YF@3?h2}#El~sY1dEm<3|M?3^^h?B@9EKf^m>=#6+cxlv^@Y+ z)4Ts$9QqXC09LhZg0I26fyhIP&7nT>RW&ewI7_WEkh81y+Jir<9m;||h~M8Y6Ao4A z_sWTpML>g04;1qJrMH>Yh{l>w5?D*d*Oo+4j8q|MmH(6wC=QGVvAlU*7b=DouEmfB)&UnV+`ezP>Uf~weg!dX zvWUSYc>tbq%(#{g`YH81X#+HJd zUb$J&>Wt9v2`H{4a^LtDPu;Z;1)p3PtN0-hOkn^miK0cw6_;-$NLG&EftOhdKgWYC zXp|46txJX&neb~qe2V;x<1dy{*0FY)o>PXcl?MiEk9F*% zIKo7Nx+DTu>pu&f6+U!b%j(hNyc6T`kH3jYK@ucaHaxbndz%)rA2q(~T9wN%Jb@!6 zvlTp>qBK2_Z7^h-<7GnnZ--&&FuN_Xzn@2~f;VaBPua#DhQEzFhbi4OW=J^|#6pg+ zprRkOzx;f4f`eEDJ!-|Hki``q!H5QtNSyMW{Tj>DthSWxXNc)u67j>-z^rI&GpZ57CcjOj;_>%Fdmbr%Ag|fd|CpAvBazRd%9!+nL;0Nx0b!X% z#RG+M%dRSxXd;2DRp*`+%jCU^&HRJv{NIP&nGly%QRd|<6^5HX)Ac`4#>0YPfY{Z< zR>j!Ab=kJ1u2CW6AC`J1YvRY5lMcg~N&&}ApEXRB?N=e`nS|-3B2+$h2gyc>+b~ja zFG8#eg23R`69-}9k{p6-a!Eq|=-|pthgRPBb&ke9coQOQC|Q0%e?G>9ZbO-U zW}1>uq=l*bzvAw;5tp^&9S}>+3sT1#0gW&#e!wZcaO5t_!WyuLg(Fm-OlT9ew1^7K zhG66_H&M|y<0ie`O;CBG9d{9|49K3IkB&UZZ0(z09Tn8Kigl!oNQD6ofm@yq2VTdX zf4WvMD~wjszs-q9TuhMuswyc)CL; zX_R|cdGFXNcC8FLJ_8}{O_>sUB~?{)m{k0 zJJbyPjjo?f(py>HG1S$J%)+%@ZskpVHj2xjRbn`8^l=yfT1dX%P4?08xm zf!~?{OD-hWk`lFa_^s_0&%Y@IEA2)hB<(_0_{FXHeXhCjwR2qK!_B+w);GIH24_cB zKQRAW5~pv8+El|I@Or-3+C)EoZ)o^nIaH2<{{1W>P~Q;O7@<`0kC351mn`uXpacG3 zr(oD-Iszm!#67WBtOQ5?01>fqFRFZ3|v2 z58ikw`Y(N6!yj%(qG9G5bz0WX_? z-s^X)>$$fkM&ZVb!ux*%&>mW;*Wacbtz1{dxt;HzkxRw1ZO2c&>f1~oo5DzTt=vz| zQRA}aw+vag1N-I;Z04N;9WU_OzdTTDc!u%;zS&J5ROq;~?@tXEuPnJsT`Vm9yz!hg z5zUXHdEl<^x?KPa_N~tJl6R{4H`V@SYUN)_uIyKd+Y_eDIkDbb!T&k-NA_lf7GiVw z=WMV#B;rF1Nu^{$3oAj(V(53=UP;bx4w2%e*et0dJl!8~Jgn*WM{@shXLMMcs#JPz z;{V$Z?34bZ36Hwl@9C>}d%#xl zW=)D>W}5B&eh&}a1arU`F{|$_GH!&ebW-eXH(l*AEo`QLUrk$pOA{vw)U-35@+WHz zVD@u^@RSFa*ucaX{9#lr_~QO5o*C`m$rXnuqtor7^`l{x6zw&%S~6jsfa0Tg4XG&o zEpU2fw&LZ*^V#5C^UuoAiSdKcp!J!VmHVTDy5M88AO<2qI}PCTm!szpsjcbJ@*seX z0rlHZ)*I`?+om7bxY4`t8wynuOb3YVk0Ig3Sz@4iBmFE%$=7Eo8h$;>wE6B**G2Dp z;xU%tA04689N8D(7wRrHCPjWAWrDnENa}-bOgG`gGGX#^HVC3v`Z9Wf5?asqbBhs= zEvFMg?=i&3^L@@A>%+8!Yx8{wGo35t2p_dGs-^tlCPtP}Jd~Og!54z1NqjW3bkq2$ zz~iDtHm3Hay)M=Qb|X<lQ4-|Wv$0A4Ls--AcGB^8=}pJ#*&FAeDsv_3y<&OqG7;pFVtf7;rl?D`~Z+ z4<3pG{xd;UnFA?Cp1R50TZ^4ushoN^VUWO2T*i)!fw=?G-?#}>n8ahxKbPJ{yX|oH zkESD!Srz>s3HlXy(XkLEp0!5g-Ks+$b$qww?>+nl^pmM7!v+7W24arL9BbG7)hE9e z$6!|QHMJv1ysleZ<1#Kk3k&_q2rq?7oPUW?Z2inc*ZMy1Qu?Tu#JAb%{+ZEAX1?ca z(>ar(j(=hWDgsyuCCJ|IEt1a|N%@~!ZG{8NkuQjRmI<0RY3DQ$yPfRNM z48rKLt)!#r|L()-sKs_S=`)@N`sp~aXy3oMP%6W2c=FHazGy&h6SpJ6Nc(b!a2K_zPCpVk}Zlp^_KA7@+X-f>*U7bJ8;g>gjXi1p(*d`7V?A+a}&+@gD`GpG#L0wDFcT8Ta^%cTV5)I zO(mdux~Kr5Q_lyOQK;>iQ~{;e%Kmxn8YJM?O~lwQi`f|Be}%*~coJ%#>N2X$rps=N zJNa1+{to=dF9dE+eb|?J-Cu;$IW{>#UBqRxFO4gGX>H_Z085=Qj_#nbukgKK_}+%n z)d7Ah3M{$EZd;Ng4*Oo`H*F%=5q%HT8&ZzUrcn+#+yE{fORcLh0f`)`Jqish% z1z34dfl-LJkc>IEiI{{3md0-M3a-^@+xj`~&W@FF-G5CF@g4?{c2r5sS=3$|x;#7I zB=BAB@)CT%xyku$^@9q(&qMfm_+9r>29 zK$KcZW-!)swrsHdizj3p+FQTHQ$N057EIbfcp~ziL7x5S4im%Ck-k%;jZ3nV0A&C_ zRRA0q-TLlX>+51quuUK4FVllZu+zte!e5>|!idEI^Ai^~q}!GT$yAkRNu6KJrXQr# zcyrg}cSiLUj2k@||8u^R>i+jMuLaEx!H?7)zQVLKj;y+*bcV#*U!qbg)!$^ZK?Q0k zHNI7!(GT&M_udVzM}OTB#m3=)y;SGsdG(RhZ1dm+FPu;Ochq)+1`dVb-L)1&(o;?g zX{}Tq+l&0|*3dmRwUbIEewl*K=JpVDG~q=oSbQHjT~@tod(T)loCZmyce5U}f5O_4 zQ}Fw-EM+GXVM)F>y<+s^FVIq{_~}8-ccBWgJkhIM(5^3xlRk_o#fjVATK+Fv2;(A= zCDJt6X=EQd3WORJ!|Yn6n};v107Utpu4*Q&ySUYQ#FfJ*fPSp+^}abs>X z{&2hB$>c?m$SF^X8`QPCT}JKaJx7RNwI}vQhaW+_2~p8FG2v&*gb4e+BYSI=+}?2| zwbsa>EOps&=Znbtz;^yzV)(thPNHzQh8z=SYLT_-smK@~E>cH&Q32eY7mJ^&TQHDE zUp6_D6QMJFG`WSi6U9$`drr;aGL%Wz(g`TPzRy0!qO#YQwAsf~lSi3=woWaMs}3|# zEy?3UFZ|N*g!lmDbBhv8lA9pnI1FdGmLP+RP-h)p4)DBwBV6#eDUXqJwXm~0t_F;U z_q8G%Y|}fiHx3c?C|o+&^8v(8DC0J^dgD~Aq@acESpuMBFag*i=5^N}qG)!;mrOZU z;bcfo>ULO114J!t>ZhmP^B?6(e%LoNv2f&zuoqVRl57e(I>#+v*RW#`f`YZ5y(nQ} zT>p(c#`0|jpVmELiq~dyHPHQP<6hD^c`L*j#ep2H? zC&Ql_$vivVoor+2j`IPM{4j?ouqG*fWjTgg+8wk7t8s)cYvMy*wmEd?NaHhYe&hew zopViC+oVZ=9Q;*%_ok*y@TeEh*9-i5MB#f+1Ps#W;1J9?{G}Wh2W;_ZwDKPWhs$Dn z0XF~capYHw_ZpmE441LG)m<1LRr0*qrJ>=*V*Ys{%3`0?O8fznlA>dY2-{XMp}nf2 z+b~$c-!&=AIJDLrIQeJXxVMweLiG{G|C4?~n^C=JF^EcT%v*4Hx}#PracnJdho4yw zoPrza&j)8E8DoqImKc*V|F-hzqb999J-Mo&BPf%0!=<7Z%eSVe1>=b>3y%C777W7V zn^_i^(s=;Ho>~q_+<}>(k_oNpv`!u2833ul)Jp`?B9Jh88qsTwj$kmpn+4CR8l4Wg z804`j0;Cqy9aAsr!}KnpZOyvJLE}pXOznbSR_K)>gJ8gBLo`(EBPQz)^LfUp-5#~~ zzzc^Qp1_MUdQyuUgQ&E$M(l4h-gIZl`JCPT7X#85{7+~HF)FG;{nOnpC}6NrP|mwT z53tlL&^O%mO6YUAA{4i)!z`ST<*^Hh2{#!x@83+Ts@G>?2!J2~h57rb5ZGGkcU-AK zBj;#>|2(1wje`vX={Yfij32cP7(e4qWjFK|^t|Ix3X*c;arsWE>V{L!E!%jCCv_Y` z_)ziPPg_NXB+1y8iEcC{?K@YMyIkXOZ|B#(0P}kYw)A#pufZga#h;D`@vxBryVqusQrudVGPd-fbyhV8Wg#17FWVyW@h2Z^^{$D}@7frHSve&ba&DNM z(gmtDT0j&$7{`wvk8}FgK$s>p`O?Gl!aqWi1PS~Ja=+a$l5t?dR1)8Wd)4664{tX@ zK;CG~_9hFB;Cwnu34%$0DxTN~NG(9FsHJPY8FGRW_jXLh+vkDL?cdpi)1IiJeY($t z)E~d(5O`QOe1SBeEbT|W&*)GI)i3nFLQU;wBhRw4L zlLT?9IqVl;_&>!PJQG84wi|q^C+B&mbUNt&o8|YD)OAwgiSR^%&{ZwJ$2x_584;>* zN1_3D{A~xy((C6G*QEp4peGOzkhsD)#L2cZWj+i3?u{symo6_K7}Nyz$f(Q#8={;b z9z5xdQHXHIcX5~m_O!6RIVW*qy`GM?>${D*;Ov|sMTDP8aNBuQ?XX1#wuQOpv9&VZ zpG9+pV0n?DzK^x`HctqKHB-_=KE8fVgb?k>RR_3`fy78IcypfFl^R%wja-PU{1&F# zugj#4o6E?k{>O%egEaBQxqY;kFDbgig8KpYS*^Q7=umMEu-hxJehHH%Xu!_FP%H+F zL04eG@25%tKHTe-ak~sG3W(GyCt}{<4Ixlu>-hfi`X2_9lGWUd`~+sw{V-68{oMt= z2YN&4mtkUyTJpY~mzu$qRx04vb^OcSKeYDsg$%VE>{GLKAR!XnO~P)9j2Y9EN!BuaFl38>ZVI;Uocr46Ik;>GoPoBU86eXG?Y<$rYCVFj^5)cGR zVZuQW*_6-PsC}eKp!>uhr=Qq{^ZZU-P zA%zJuC-^~AU7zGN-QN$gK?tm!23TP|=sXE~`C?X#gM{Yy==s<9Fxu)9`!R}%TNeoMEDIIoI@v?MJf3&i-AH)!rV_1SO=|XH^knwl=b(TjU z5DA3+slIXJHIp81vnnaw)>j5Wb)jQ~Zn-e&0O3RjPhRd<)yVoYPn?^Y)#OFu&=P30 zEN&QJ;~tSC5y|2tz3@&MIQKqL(*&>4Dd|s7o5|bke=7~9=pVCZXqb#fpz@t!tt8JKTYtEzr&5_nFW2H5Cl4=o0z)P9-Eqx&8xLYIaeGejUc z%QCuP4^G5Y`W~IN7)k5OtnSK4x2!1ft5oP-Prtb=BW3xM9p}{5B@qrdXB8iVwZ*o` zm0vRr3pS4N?+25u@(5MjXt85oATQAqL;Sd>po!7yml07qZ%zlQ_UeASm9z#w7+iSe z5QCmBVv#%%fW2hn`TjM53LY)pZ$s%=h4Jh%k+q&Nc>&tR6K$h%sn##$TeSsln6WlB zVD#B0#xti8<@l%e2*M5lvA5%duHduRc`me9AMCEY{6VZr0AFK`J+5cufD1!nT=-?m z1^36LsJ>!bdrA;fhgP!URBF(RBucY>8UAh%ZjXeC_bcMC$W_@l{tZg}7rKF?^OiA! zgg5CxAyzti0}xz#r+UGdEWJcY_Ve7<_WAowThXOU(?*u^W5PWV>n1`HqyiLyx0~(O zG}#)2iX$d?^PVKJDKU5EBfhKM40XMvv1avo38ACR^Mn(Wsxfjcs%iy`-!?^%|9rym zpkzcvW=4|3?89hUIiKbNYXb_s3gM9wj1>zn-n{%oCDp1Pk)J!593W%&;IA3+Y(~q{ zV|QdqvPOAR<~2`^r%RSh!3h=KrrLuBNDctV1`a(BgGB!{e65T%OnFuI%bQ^!^B(W` z4d!;K;HRRWW5eAu#zrHzL+@?)&Lqgw{kBeM%tjb;<2l@a0ME{OUdH#z>MAw;|-&g-pRu~RK zE@ned^ib^bP5Rg6C#7b|#+vM{q`#ju94_uOM{p7&`qFiVMG_*)@Q7ajo~->gSaob$ zB?`rglY=5&pSrp*sQ9nQOxFBlDpicBh-hJDX;ION#hPZ+VXWNp2W_5KR6j(>EWN>1 z;Uc*9pYowWGT{J-yB{7)4<4U`AG@_fJFSm}@ZCt4>#WMo>)Btl(k$9<7e}vN>@L{R zRZi#g)^TVq)Q)^9IT7QtF`>6emXbqI$^k#*$+rujAg6~;0_nca&-N8_e066T*p1%a zOvq@}x;D?{{NHc-jjcbN=1v2C# zS2^&Se)>2w>ZPcNxS`CKwOZf3HtTPmqq$>+vznPc7M}(K^e$g=vE)}B9zu27qhJ6m zE+ja3B6v?P+qXgV$61YMPl0PonUsdb&}YZ!%|F-NM-Wuv%PqWjEixJ`MGOR0x44D! zPyi4YFl>Chx$`}ujt0Ehof$yz_3EJYZQGCKOO1d_tnw3`o$ek_^@!vGb-h$1UWb?^ zmFNW0Yt^51<5)M)TQ7>JpBU1PKQn)$syj8kWQXHc`@|{WFVC!tO(pNw0Au^>Rma^^ zTH30{E#sYOar={n#R+fn!RgA9V7%SQ8lQQxzZ`Lr4+wDBwGBr5|IGyeK58kQdF&To z)PFvB836I^0;+B}_FsB)*E3jr&w$5_iCgxU7BBWq+Le3}aJhAy|AXs|_y7Yip?7ZB zMZX4mJL-01G&>$)+BnLdj9?aCJnQ#q_E11P^}OX$f@hnWHa4#;v7p2tpd&^cM8cWf z4v(kXvIGBBFVg_!i$lWfE6yxVT5q$J*lzHXD zJX)2s4dyX0fI4tGWC9h~{bn~Xrj2tHk@0no0!Pf{wd&!8vG_*^gDK+T*9=R&(GfyI zW0(EzKg&3KeHL_SMIRo&5U&U(L7OD}Pp_X3_Yp75=u7M#&Aim3veYkDY&Wz^fa^); znlpnp3r-e2+4onS-T+F1DHyJU^i4yG zRM$#HZ^cmB0_&PanQkobpg|#wOi!+i_}j&{z7tKWDN`%IEaIaJZKI3&<9_v+iGwWO zf!~MN+!xHY8{%Jp;5JR9nI&K2S-7!^MPfJp({(p1qRM7Zu;4@e;_|%4@=cNTG}J## ze7XsZCvdB6tcav zgsrsRP%U7;_x0SRH94Ck&HrW8HH6cCelK*`Jb61_!d)0Ka~VSW)7jz{NsBcQR^7)U zTE0*>DDlgq*}E%wp)J8{LShlpogNve>zwjF;^EaBg8*7$>CLXXW4dCktu`}8>g8pL z52CJFN}@(#hljGescEzT(Cl$^xUT#_U6bpwSFn}TFAgAB;xm^yYSus$lJ#0~6u&9* z-E%+Dm;9_qU&eN4Wek|owOA1-UDu6{v=g%*LaLBxonw`>eY+i{gy0n6l#?wUY$QsYfh4im|nw# z&Mn8ietB~{Duxck_l8DWULwg{4@xX-@3E#S%f5|MZHl%YcEF-^l_bSoTh_!MIA`kK z=x2{&RL*O8gmCVgH?u~)%KAaR40qw1Olp074;Od^g9pnp3<8vnD!C1hTs-Z z>;>N$P(vXw?4)z+uK;nM#-;GZjs2M8MTJxd>HEy3H6pj08{kb9h~4Pk`D=i|uY*P* z7S#ir9FJv$vF1?#L?h&L{-yT3%S%^*P=2vn@?fd%7wlDPg!LMwXOW&)_oeTBH+QUO zcSp8AB7*K>+g`#W(OQw?5UI^)3$5pW`<9 zt)V4*2HGX8$ILA%$9qoHeru6voRx?qje)EAyq=#8k_?YDz9>0Yp=+)VqDS*Ul#?VI zBW~ixNLqzP*Q7l>9^DXNyPJ)2d(a2o;mskU4*~WQ%$zjZ`C4Y zsw6yGZ;gZJTC_J)8dQs z#!&!VC&57MWvHGiJl_m_hXY3DSnzY-lX4A)vc%uJV@Cgl*ThCY8jtgLP&Dnjzl*zAjuM%U><8N@=B7ACx()&D!FQxFbpDG2*f z5+8meW`M1kI!#23T1oOf6w*E|gw;qI+3C3DOvv93{x}qH`2j<*?^`rAh3+4)))8q~ z?IKws)f67E7(;D>mwRy4FP<6|{H5g$5E8hSN<*X(10ayH-r;?58p-P@?ByResO)mw zaYapG(5uiiVbV&_T47YQH?azK^ficS`DKg}cu^qa1VyF#(>Vac9Y-Qf6dr+3b@=FN zaz{VnxiC|lA`SLCJz9e43Q5C0GoMHGx4Tq7T$H@z5)*U663NS(q&N}{svj{KKim_ z4%9IECLqCrIB+N&=Egu84PVALieirIrd8es-wZI_3`pJNDtW0C|0DeD!Ee&T?o!ww z&0HFus85iPfz)FeP1y6fboo|MJRFFC0k%W&z@KnnsxTR(H$)fvU8!VETf;v9LxIy+ zwGh`rylt+UhSI_rCt4cqDp+iMRXKw9WEM-gOW57(w7mekolRdwV4}!@%etvHe59g8Yz&Nr*WwT z3}60{#)QjCRU|lxVEzx#;i@2gHE&}qc4k}Clk$psYsZWa(~UYm~s9l8` zkv2MkNcAquI;V~@77Ew3o(~qE_~OY7AH6j@BN~hk9HwfS;bN!nJBR3+W{M&@gE8Fz z-HA~o=<2^gzOV-MyX`CuwLL8^;|6b9H$wQH+;YDnM}%_Cmn`A|XM{ zA+GQf{e1dX^dNLmnOu5KKCv_);+qM*Y{r&9)-ow~z!M|cDS_6dA7Xc3%wIqeg6JJQ zR$R~<9m(3(jqFka?_2;Fgp@qBMl+vLo)6-jnBjQ1Nn`s(s_#u>5aa)1e%x?Y^gCpKrSNa=CF3-)}$ zMMY9;rWa|Myv=Nel*E*yzkZE;N;^J~$#_}Hb-O_OmNsOfqGPF`*O;pMp~T7#ViAaw zQ~CgzUM}NJnXWuzPpNk}GNI6$I~8~)aNJ^Aw{|dRM}3{FO7`3Jwpm^8@3IcfWeMvU z)-yCH`@}^#U!neE&^Q1NOss>h#5G1Pnm?`394$`9dy6WbzNv5LTE@;bw1NY`Kw2 zAxO{_0ibjTvYhW3j^UG>P2-%dyhTo5##@I}T9RYJ3SJuco5XNT&-EQQoIJrdy%4+8 zUnHktkXwq+C{F7nE$qA!VZ=su?cu;}NyhAV3g!s;E?bhd1V_tuUs;Y^zFJ_w-1aPHhy(3*2**bZwg9aKAi07y8@Hrnxuwfz{ECVclUq^({#0KS+p?H+W?m+msJM zuNn^C3ib*W5>N{EzjGn-X^%=H zM%-v4@cuO1UrPal{a=XZ`<$z|c3LoeoW4m4x;%SlO80|Vt%^3te!^*c`W3- zkSGCQh`rOr$>JT&cewhbs^oL!Oycl;1vklUUHG$rN~xvJAXYyDVN7 zUe@EI|LdBvEIs#sv~UDKADmKFTzy|OQv0LF)nyb`UNeo~d~lx3}vGJH8a zCRqeU^5cNDdeJV&6|~*CxbCcIqX?7MGy4G?Z!~{bw{(@EnB~2zt42@!&?gQmWb;L7 zSu_S+!#`58%^&`Q$^)`!cofMaNcM~4N~10>?t3y(2i^jY>pii1e3xsmY}@KzKHKqI zB_-nf_8z6K;J#8Xv^{1bzU}Lyc9UVNVAGEwLG@qR^GrDet@56x`ot#$r!b_DA$V}qx}V_O>( z)A)~^KkHww1#9<*Gfx78^0-Y)8)-LcYG!+DM{1HQ-b(@h+f>T&Cxh8HBF{3VLTK8P?OCu87 z>t7~a$h6+>6#o+6xqVy39o$kuOF3bW!-$|n<8D#|G8hFa=5EuwxU}FYRt$X>kXTy^ z?~rWvc|XwB)w9|ce@3C(?{znF>x#DA;1K|+2v0@X-5L>?Ji-!>a#OKHUck9TY84iTV*_QRLQ*EKUp7GJkSv{8D{XK3N(Dn9+!yvRM>qBcUx zE<5L;s7ppTk8jPgDJ!=fJ;RD^1iI1J@6SK>pt3S+@W{jt6SG+c!z^aDMW)hxiV1wU zSA21!nmX8m(htPeTM4A;G0=PjSaZY4ukjz6WV|Xe`-2iB(!DR zkNYC6u(+#B!H!^Y9yn8GoY; z3M53lG)PUgp6MdwFUjdVg=;PgE^f#`!_cgR7E9hCgu54+wLgEdbqW-Adjz!n8W|=v z9B9>X(<{3h|BFNK8qVJz^`Gjylk&wS|A`P>Dz?da-Q-3$ooL?RkpNx|;6_iO#iB0q zcmQtuwS^DzbKgV4Mt`{g9~7mGgEkKShroJ|=epM*6^_fCW>cnfW0Xq)Tx?pY*wBL| zNyVeQK(qzXkPB@ebC<_-Csa_}DP5*G{@|27d{Uhp-0Ezlda%UE?u!-~nwD@U?989s zy|%;kl@9>Jlg~uA}@{>8T(DA%AY89pokibk(aj+dI*(Ih|Xk4-lWt1ScjjZN;C@NK*Y`r z`0;(FW>wDAz-VohZkMPLfe467qeM93i0XYG5waY;d{q`RDri%IaR3ej;yMg{+K`=F zn^HyYTmLleSG!UIK|Z96xc}t-CX=@J4&8IKhW#GCVmP^)3(tYyA)3(HACG-BY9)tn zqWm5}m-LK~hJ-+TzFnM#6&(8Z7I{WuDy&N|JplyN@ZO#66f%!3<&gRbiWp~c!w?6P znXl8ap3-70rrfT{^>pz9w1dB6CWTv^mNm{7{K4^{bgfI(aB8x5Q34PPt!~lhgqxs6 z@=AQ%X6pp19eM%TNv6{CsQZLleq4n5Ros=GDGu?|gY^MSsfy?%QZpDOhB1`>6{9Z| zBR2al)}N^1{FjlLSI%>3xX2Eh@#h}L3}sUDR7l3yEG zDF1Gq9UurkF^B=M+uvbBwLt5j*~?F+7cN3(9hH3^qzH+%nOGo+fF6z@>cyy7579ps zSU^N|(}-z+Ef)P|TIz8bzD;1@Fv1a(#5o}?wO5Y|C5REV!6lv;eM$gpar zzw&#Y2-6Jb{)$HgM6>asa}jILbx?BU#zoAXJXeRA^8o{n7#}~3S9ZMP1TH9D2K6fE z8)PZ4+goo>e9W;D8?gQFueTU&wQH!?4b4~DJMY$r&2-wA6bqI*qOwr@S*G=SS0pGW_>WQ78z<@@ibqyXs)g^JU~Q5MO$2!15ec#TTR~r_4Pi% z#^uvX_N|t3O>~?Wk`%sL?@VW^JT*=A7R@&?-MjCmhEv#Nai3p>LmT|ovGfgQDt`R} z(<@n6Sj2@2z+%PbO9>@13B|S&r+>>2Z;7?vpMT$T>52Gd6=e2hhH|%r@|#40!h)vi z-{OxgJaf+Ms=P*Rh>e;_z3Y%T%ODpzO{rjN*`s@g?)mx0R9p*!;BO22Yfk15oZ%_p zXOn07qYopL_o5q7Ok3|_y;n9Ed=@GPFlZ@3g`Sse@iTRrS0R`2bJ9wJ3;uU;AC!2xfXX%it7mft?HM)F;35Yk?ErA_v2&iVV& zLC%yjXL;y1co_DhK5c;FFJ(nzV+^_vt3L~tqdXHb`UVH_)@Fr#(Vm_n)G?OJpbUwY z#p4@P@Xzi2h5CnkgVwvL6(v6jH}bU2)P3}MEh?WEXGN$9;rz_ZrSgoRjlBf-k(s@B z7yhQr_o$iiLn3}!f}|hd)6>)F^#&NwL!?66=OB{)uSU{A#5g+FFaU=@k>m_mBqI6+ z2(MwG58YMzosf-WxBU;c(Ot8&UWZUnPzWUyJ%0&Z__ zvr%`4cOegKXrG5mlarwD;2MD~j(952BH6YQOy3@jFy6W)%c7Z`oi)7w*C%r#TQ@(P za80m zMxFir3w|5!KXdz9B@7B098dB-!jcmO`L?`!Zkl<^`KEvR*N@P0$(D&@<0gkI=f>z4 zM`#qh)37J>^gKPmzVFc z+b$#cP>*9Z&(w=$$$3YuOLV%=g{qS63^BW@a}|g;d0j zB45Qq?xlE58ltQ1N7l~LCTFD@V>Akcl7Oq-KaY6x!&P4fkrt>%+~?t<550wpy#iz1rHeXx(Y4yv; z8Wj4={SsyCb?2#=)HoYstC6gTZz3kZZhWa$iqg$4$PT`dPLMtRx8f*Fb675!wz)|z z_2zqZ4!fIB(;RrL~7?inuQr+Qcf2__?E_(!NbJe^3D zho_UqLscoAST|a@dJrb0ph0IY(P_Epg@x5C&NR|dtr^a)lkJ@8x%u$w)^7Pl%-JL^ zJpG4iGFk38&WxK$-zP2u_szj3D#9r55W%^_^N`E0E57$3Z652rE*mUQyGuE5yDfDp z#YCnVe2*{zF{>(rpvNDS@5UMY4*F(9MS?}v7G-msEnQs+3p6r2V@TONjyo|kB)lIx zITafknJO{6A{`*@uEufYLSeHDL&0;$v|)bIn7^x2b23X7XZC!A!LU5VbQaYVGUNJs zkJDcD#RfmRnR4^X-V0vku8oM9)`uHe-{S?oRsvbI;{G7EHTRN!B3dF4aFBtl+p>tl z&*#sb+^&&1Tf}}?ySceB|M2}^lA5Nwqa!X24UM6(Y2P*emdC}OQ3-dsg@*^Rr>EyH zJt&Y3K#3<+`)Hw9>b$_OiifGG}|WKOLo Sy(retVj)-iD+ zsNw94yt_V~U0m!&lg8h_dTZ~6;*CfF+qsu4j$tiJ(#|e!)&WlV0RaKCb4wi^9dd6! zq{u&OT-m*ldH74?_Rz-HayD^^WIN8Yx$L)9Tjl}fyOht2ZctnJf@K<$mO@@~s zG=%cNC^?4znqFAyT3+UT`}VE-*uLf1q4k3WgJb&gfB{ET*EoZli_62V+rxre$T1RW zf$(=S-@<&c&e*WpS@}fP{SE>YW`XyTS5!`lP^^x9z|m#v<;i+NhUDeeUrNe*6XtjZ z*`4=J!jDtGe(gIMB+>t@U(s9@mY=Ug{>)3l!AIg>&4NR%q(kkiG(*5g8^}{k{y{~E zMMV%rb$0uY2y3otVfUNQm{R>rPscszR|_wiXQ$j3Ghx&Ok$igx2Y2^A=E3K`XV859 zp(-N#L6dXhv!ouRV)&{<^td|?2Mbmg zNI4hslfI~#K{e&#E6Q8r28$(Xk*?P3uCg{auJlcR_^pxQvLK8Mp za5^k!mY!g@uZhL;nYZ3u{oN*&6`n~8DVloS$`_kE>4Vx~V1jC==M5Bhb^Oamp;{>0 z9(up>nfTof@@%kpeOccL+~xgQa7<7Cc#TF1o$Kk&qEBbraYWK;m$qN+XXm-U7ICV{ z$HOZ<_qv|mMT92d4Sl9%-zITq6AshkA8I$f{M4<>hv()Ctu3b$yDI^x&3EtK5f65k zks#C}kQzO!-E_JHB0`A@a5KgIK)C znsQ+BslyYiz!;Ulft{_^(CA1OM@`j6wu!UP(CyMy2QM_bmZ&bUjROL1XO@F+mx`BM z>!UJMCtm6F6gEG4tX@=+3-sM7R!KJRfA8E;Dja^Lz=YH88|Qhut7t*uv$6$huTC(=)=jx%zc2G< zL>Nuuc4$Xnu0z_%LlGQMh=sqd(Yd2cA;)c<-V|tEO?G>wAzn)F^9nZ+7i2OTk#Gm{ zK_7TmiITA7KR^02gB$85sio;}-lQhLOC}Zvo!y-b2bX<;x>G_S$YqQ9@ND$&toIFK z5BwqK42?kxLE%2TyUiHc?2tuk2*{Toc~2)+6l1P((sX>8!9t1TE$(JSg3#$e>j{qc pk**7lG1Sqt|Br7ZuvmS-mYW>+r0KIEMqk$es3~bEmdRU${V(CxLjV8( literal 0 HcmV?d00001 diff --git a/scripts/python/app/nut-monitor.png b/scripts/python/app/icons/48x48/nut-monitor.png similarity index 100% rename from scripts/python/app/nut-monitor.png rename to scripts/python/app/icons/48x48/nut-monitor.png diff --git a/scripts/python/app/icons/64x64/nut-monitor.png b/scripts/python/app/icons/64x64/nut-monitor.png new file mode 100644 index 0000000000000000000000000000000000000000..9d922847911d3fe932758a20dddcb683aeabe035 GIT binary patch literal 2653 zcmV-j3ZnIiP)9oy~5c{t993_&AIc!|IU@mLUq zf>^KsA-3#TjKpFz|G>a1n~^foNPt9UGZ`KVNDve$5ja2)!Lj1RfbDeLkK278_4@tJ znMGCITes~A?!I=~(%i3fx~gu~y}xt5=kYuB`!&ok!wfUbFvAQp%rL_Y{~uxAtAT#{ zAGABdSMmJMVe~N-xyvY?8u|*CfnR%$?|KWQ|%O(gcVs{w!`waWrr2Sp7)_JO&^F96*;k8=I8~^l8vfHWSEhXSr&+w?PeA@FH zpHZV96q_^wnr$CHT;h>W{g|L}H<%8pLtK1;xOai!&g(=w7udS;64CD4U_4L(W7PAS z*9<&|@qg*H=KlNalb1JdrOs0m@SCRzqXysb{noctvbEO211zncroFI6^T=_6`Z7D0 zpC*a6xc49a4N*lUMzVEma*@IIoAkCW5OpsR4R%RmIQi(;Y0aM^jW$UJ>kM`;)8Bdx z8(&isc7E-L?SDS|rK>L-Isq>{!$V=v{CQAYIezcy&$4**F=~wt5QA)k41k2e=CfF9 znLqX&Z1M&+eia+NN;tK#x{JX(lh2S{&YcvEm@Uv0)d-^@XaM4& zfKkDCZR+h0Q|~-c46Dpbgt#7JcM!XaN*A$RR4pbDBy(T{6ZjZ0sMhepd4k$e`ny-A zRUNnm1Yla2#z&$47{>KccLgN|*~PE}(n3uWOan}<7}5h25Ijvmhd>{d0frvV^no6} zA7T6@@a9o%Vr@Xw?-FlqVUu^SCpU}f3BZBtV(_5$AjbOy1`8;t1BM_&&T=|sB~*2K)wv}ED4-|_xOadi zXbQ#$Y8cZ2eSgW{9u~xB};;iPz76yytMvpyy zrxBoeE{~2Aik0_VAyPb(i{kQUMg~@ltx7RYc~23vY#OG-ErVZ8JZ`TisU?u?%zofP)&hR6bN8*QOS#55ed2X98k!}%caq!VMSCa zqu(AyfR;o~j{|pt8_}Z=s(OfeBLl|y=_tLe1ra(iGmO(h3nEmbui z8Px-;Kf-|{;LZ5+Z(WHW=b_#S8eX4H{VL;Bkg-9yV%jUcE)#}R$@x4LxGo*45~nq; zy}iaey?g0(zX3dbI0PiNl_k1{lYsT!DK)GyH4N@8Kr^R3JGO&l%5_JL10gq zk0nZ*tatC>;`#|Ly>mAYpIIdgeRi|8sf?eB0OuSAQ>3VpX^q{egEMVJmhsF0!wvym zjCMg%)Ggpif@;0|6+~)S@ky=6FljQ3S`5=BJHvT)`g3gd7ufE#$kL1~%dpO(s)z_8 z)7OD12#|?tO%c9|A_~?v5vk#15hp?#Kg?iw7AFqp9M)RWG$Bb6k~kqL&y$2SO-a*? zEKA9GVMJ8xnrDz&H}0xFehO&RC>bs~GDXo$p3 zG(>rmBxKnk65vudvVS}S6lXG?+ZD-|!I*4t%4=0EmdPe1H(VyjDZ{=@fkTae)TMb1 zD7`-_;DS(TVWm`l)YeQGUnOBIdkrthsE{HmSUdfK@l-`{{0cB`W*B+8NP&Wcd}_RL zm7fg%%JssPY?0EMYPUX5t0Ud{X^{A>CJ!Aq#DL}>f zl%6kAKmbvYagiLiwd3hO|7dJn>2=*x2dWVCPKW?T?<8dxH<{mM8te)0%KJke+PcU1 zz3&A#fau}Q0;zMQ|3?v^qw~pE+cKob1#|Kpze>){LOARi;PO78Y=TDZP^DPOL7a*Q1f45uz}TauVtK=&6OGHQTEr}&s`*qrC8mC% z*6QD)@RfINl<#*Mre9I07zuj~zO#*oDF{#L4fD^7-KMo{GXoyCKfdEnqe^bK|mOWwA*bK7nfMQ=O}Ay zCwbuh2RVN42|VB9{OjlC<(FSJ8=ITY{p=^t|BHwu~Vuji6DdGXR;{`&8K_}w2~0pdcEJ?Hx}YQG4X ztOvE?yng!h0}mWKe*B}IPUi#lM&o^;3jn_FGdDM9+pRX8xsC~fkVd`kd7d%DK_qb! zYnEo(AM_XwBQK6)ub54ov+l|;8lLO*2ItPdcK(Hpjg8I1$h{J?56@3SKnbrxLRb({ zE6zh8Tv%9`J8|;FsZOVJqE-u5!XR7-!(dSr&kMY!!T2hYifF2k+AP~jvuqszMy?L;|y7{(-&pH)%WTrBs`%DwX$W|(1y8D^N_HsOB(P<>YP_}e=_00000 LNkvXXu0mjfECL1A literal 0 HcmV?d00001 diff --git a/scripts/python/app/icons/scalable/nut-monitor.svg b/scripts/python/app/icons/scalable/nut-monitor.svg new file mode 100644 index 0000000..c046562 --- /dev/null +++ b/scripts/python/app/icons/scalable/nut-monitor.svg @@ -0,0 +1,490 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + Lapo Calamandrei + + + Battery + + + battery + recharge + power + acpi + apm + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/python/app/nut-monitor-py2gtk2.desktop b/scripts/python/app/nut-monitor-py2gtk2.desktop new file mode 100644 index 0000000..130cd06 --- /dev/null +++ b/scripts/python/app/nut-monitor-py2gtk2.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Name=NUT Monitor +Name[fr]=Moniteur NUT +Comment=Network UPS Tools GUI client (Py2Gtk2) +Comment[fr]=Client graphique pour NUT (Network UPS Tools, Py2Gtk2) +Comment[it]=Client grafico per NUT (Network UPS Tools, Py2Gtk2) +Categories=System;Monitor;HardwareSettings;Settings;GTK +Exec=NUT-Monitor-py2gtk2 +Icon=nut-monitor +Terminal=false +Type=Application diff --git a/scripts/python/app/nut-monitor-py3qt5.desktop b/scripts/python/app/nut-monitor-py3qt5.desktop new file mode 100644 index 0000000..66fcd86 --- /dev/null +++ b/scripts/python/app/nut-monitor-py3qt5.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Name=NUT Monitor +Name[fr]=Moniteur NUT +Comment=Network UPS Tools GUI client (Py3Qt5) +Comment[fr]=Client graphique pour NUT (Network UPS Tools, Py3Qt5) +Comment[it]=Client grafico per NUT (Network UPS Tools, Py3Qt5) +Categories=System;Monitor;HardwareSettings;Settings;Qt +Exec=NUT-Monitor-py3qt5 +Icon=nut-monitor +Terminal=false +Type=Application diff --git a/scripts/python/app/nut-monitor.appdata.xml b/scripts/python/app/nut-monitor.appdata.xml index ba1d0b9..da0f163 100644 --- a/scripts/python/app/nut-monitor.appdata.xml +++ b/scripts/python/app/nut-monitor.appdata.xml @@ -1,7 +1,7 @@ - - nut-monitor.desktop + + nut-monitor.desktop CC0-1.0 GPL-3.0+ NUT Monitor @@ -32,11 +32,17 @@

- http://www.lestat.st/_media/informatique/projets/nut-monitor/nut-monitor-1.png - http://www.lestat.st/_media/informatique/projets/nut-monitor/nut-monitor-2.png - http://www.lestat.st/_media/informatique/projets/nut-monitor/nut-monitor-3.png + + https://www.lestat.st/_media/informatique/projets/nut-monitor/nut-monitor-1.png + + + https://www.lestat.st/_media/informatique/projets/nut-monitor/nut-monitor-2.png + + + https://www.lestat.st/_media/informatique/projets/nut-monitor/nut-monitor-3.png + - http://www.lestat.st/en/informatique/projets/nut-monitor - david@lestat.st + https://www.lestat.st/en/informatique/projets/nut-monitor + david@lestat.st -
+ diff --git a/scripts/python/app/nut-monitor.desktop b/scripts/python/app/nut-monitor.desktop deleted file mode 100644 index 4e698d2..0000000 --- a/scripts/python/app/nut-monitor.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Name=NUT Monitor -Name[fr]=Moniteur NUT -Comment=Network UPS Tools GUI client -Comment[fr]=Client graphique pour NUT (Network UPS Tools) -Comment[it]=Client grafico per NUT (Network UPS Tools) -Categories=Application;Network; -Encoding=UTF-8 -Exec=NUT-Monitor -Icon=nut-monitor.png -Terminal=false -Type=Application diff --git a/scripts/python/app/ui/aboutdialog1.ui b/scripts/python/app/ui/aboutdialog1.ui new file mode 100644 index 0000000..c6a6214 --- /dev/null +++ b/scripts/python/app/ui/aboutdialog1.ui @@ -0,0 +1,108 @@ + + + aboutdialog1 + + + About NUT-Monitor + + + true + + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + <h1>NUT-Monitor 1.3.1</h1> +<p>GUI to manage devices connected a NUT server.</p> +<p>For more information about NUT (Network UPS Tools) please visit the author's website.</p> +<p style="margin-bottom: 1.5em">http://www.networkupstools.org</p> +<p style=" font-size:8pt;">Copyright (c) 2010 David Goncalves</p> +<p><a href="http://www.lestat.st/informatique/projets/nut-monitor-en">http://www.lestat.st</a></p> + + + Qt::RichText + + + Qt::AlignCenter + + + true + + + true + + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + aboutdialog1 + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + aboutdialog1 + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/scripts/python/app/ui/dialog1.ui b/scripts/python/app/ui/dialog1.ui new file mode 100644 index 0000000..6cf652b --- /dev/null +++ b/scripts/python/app/ui/dialog1.ui @@ -0,0 +1,89 @@ + + + dialog1 + + + + 0 + 0 + 297 + 133 + + + + Dialog + + + true + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + Enter a name for this favorite<br><br><font color="#808080">You cannot re-use a name from another entry</font> + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + dialog1 + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + dialog1 + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/scripts/python/app/ui/dialog2.ui b/scripts/python/app/ui/dialog2.ui new file mode 100644 index 0000000..d31542e --- /dev/null +++ b/scripts/python/app/ui/dialog2.ui @@ -0,0 +1,98 @@ + + + dialog2 + + + + 0 + 0 + 229 + 116 + + + + Dialog + + + true + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + Please select the favorite that you want to delete from list... + + + true + + + + + + + + None + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + dialog2 + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + dialog2 + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/scripts/python/app/gui-1.3.glade b/scripts/python/app/ui/gui-1.3.glade similarity index 100% rename from scripts/python/app/gui-1.3.glade rename to scripts/python/app/ui/gui-1.3.glade diff --git a/scripts/python/app/ui/window1.ui b/scripts/python/app/ui/window1.ui new file mode 100644 index 0000000..1950464 --- /dev/null +++ b/scripts/python/app/ui/window1.ui @@ -0,0 +1,473 @@ + + + window1 + + + + 0 + 0 + 560 + 465 + + + + NUT Monitor + + + + ../../../../../.designer/backup../../../../../.designer/backup + + + + + + + NUT Server + + + Qt::AlignCenter + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + 65535 + + + 3493 + + + + + + + + + + Device : + + + + + + + + None + + + + + + + + Host / Port : + + + + + + + false + + + &Refresh + + + + + + + + + + + + Use authentication + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Login / Password : + + + + + + + + + + QLineEdit::Password + + + + + + + + + + QFrame::HLine + + + QFrame::Sunken + + + + + + + + + + + + false + + + C&onnect + + + + + + + + + + &Disconnect + + + + + + + + + + + + + + + 0 + + + + Device status + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + 0 + 0 + + + + label + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + label + + + + + + + + + + + + + + Remaining time : + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Battery charge : + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 24 + + + + + + + Device commands : + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 24 + + + + + + + Current load : + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + N/A + + + Qt::AlignCenter + + + + + + + + + + + + + 0 + 0 + + + + QComboBox::AdjustToContents + + + + + + + &Execute + + + + + + + + + + + + + + + Device vars + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + &Refresh + + + + + + + + + + + + + + + + + + + 0 + 0 + 560 + 24 + + + + + &File + + + + + + + + F&avorites + + + + + + + + + + + + + + + &About + + + + + + + + &Quit + + + Ctrl+Q + + + + + false + + + + + + &Add + + + + + false + + + + + + &Delete + + + + + + diff --git a/scripts/python/module/PyNUT.py b/scripts/python/module/PyNUT.py.in similarity index 53% rename from scripts/python/module/PyNUT.py rename to scripts/python/module/PyNUT.py.in index 9a9399c..226c0ae 100644 --- a/scripts/python/module/PyNUT.py +++ b/scripts/python/module/PyNUT.py.in @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!@PYTHON@ # -*- coding: utf-8 -*- # Copyright (C) 2008 David Goncalves @@ -38,6 +38,11 @@ # 2014-06-03 george2 - Version 1.3.0 # Added custom exception class, fixed minor bug, added Python 3 support. # +# 2021-09-27 Jim Klimov - Version 1.4.0 +# Revise strings used to be byte sequences as required by telnetlib +# in Python 3.9, by spelling out b"STR" or str.encode('ascii'); +# the change was also tested to work with Python 2.7, 3.4, 3.5 and +# 3.7 (to the extent of accompanying test_nutclient.py at least). import telnetlib @@ -56,8 +61,8 @@ class PyNUTClient : __timeout = None __srv_handler = None - __version = "1.3.0" - __release = "2014-06-03" + __version = "1.4.0" + __release = "2021-09-27" def __init__( self, host="127.0.0.1", port=3493, login=None, password=None, debug=False, timeout=5 ) : @@ -89,7 +94,7 @@ timeout : Timeout used to wait for network response def __del__( self ) : """ Class destructor method """ try : - self.__srv_handler.write( "LOGOUT\n" ) + self.__srv_handler.write( b"LOGOUT\n" ) except : pass @@ -105,16 +110,16 @@ if something goes wrong. self.__srv_handler = telnetlib.Telnet( self.__host, self.__port ) if self.__login != None : - self.__srv_handler.write( "USERNAME %s\n" % self.__login ) - result = self.__srv_handler.read_until( "\n", self.__timeout ) - if result[:2] != "OK" : - raise PyNUTError( result.replace( "\n", "" ) ) + self.__srv_handler.write( ("USERNAME %s\n" % self.__login).encode('ascii') ) + result = self.__srv_handler.read_until( b"\n", self.__timeout ) + if result[:2] != b"OK" : + raise PyNUTError( result.replace( b"\n", b"" ) ) if self.__password != None : - self.__srv_handler.write( "PASSWORD %s\n" % self.__password ) - result = self.__srv_handler.read_until( "\n", self.__timeout ) - if result[:2] != "OK" : - raise PyNUTError( result.replace( "\n", "" ) ) + self.__srv_handler.write( ("PASSWORD %s\n" % self.__password).encode('ascii') ) + result = self.__srv_handler.read_until( b"\n", self.__timeout ) + if result[:2] != b"OK" : + raise PyNUTError( result.replace( b"\n", b"" ) ) def GetUPSList( self ) : """ Returns the list of available UPS from the NUT server @@ -124,18 +129,18 @@ The result is a dictionary containing 'key->val' pairs of 'UPSName' and 'UPS Des if self.__debug : print( "[DEBUG] GetUPSList from server" ) - self.__srv_handler.write( "LIST UPS\n" ) - result = self.__srv_handler.read_until( "\n" ) - if result != "BEGIN LIST UPS\n" : - raise PyNUTError( result.replace( "\n", "" ) ) + self.__srv_handler.write( b"LIST UPS\n" ) + result = self.__srv_handler.read_until( b"\n" ) + if result != b"BEGIN LIST UPS\n" : + raise PyNUTError( result.replace( b"\n", b"" ) ) - result = self.__srv_handler.read_until( "END LIST UPS\n" ) + result = self.__srv_handler.read_until( b"END LIST UPS\n" ) ups_list = {} - for line in result.split( "\n" ) : - if line[:3] == "UPS" : - ups, desc = line[4:-1].split( '"' ) - ups_list[ ups.replace( " ", "" ) ] = desc + for line in result.split( b"\n" ) : + if line[:3] == b"UPS" : + ups, desc = line[4:-1].split( b'"' ) + ups_list[ ups.replace( b" ", b"" ) ] = desc return( ups_list ) @@ -148,19 +153,19 @@ available vars. if self.__debug : print( "[DEBUG] GetUPSVars called..." ) - self.__srv_handler.write( "LIST VAR %s\n" % ups ) - result = self.__srv_handler.read_until( "\n" ) - if result != "BEGIN LIST VAR %s\n" % ups : - raise PyNUTError( result.replace( "\n", "" ) ) + self.__srv_handler.write( ("LIST VAR %s\n" % ups).encode('ascii') ) + result = self.__srv_handler.read_until( b"\n" ) + if result != ("BEGIN LIST VAR %s\n" % ups).encode('ascii') : + raise PyNUTError( result.replace( b"\n", b"" ) ) ups_vars = {} - result = self.__srv_handler.read_until( "END LIST VAR %s\n" % ups ) - offset = len( "VAR %s " % ups ) - end_offset = 0 - ( len( "END LIST VAR %s\n" % ups ) + 1 ) + result = self.__srv_handler.read_until( ("END LIST VAR %s\n" % ups).encode('ascii') ) + offset = len( ("VAR %s " % ups ).encode('ascii') ) + end_offset = 0 - ( len( ("END LIST VAR %s\n" % ups).encode('ascii') ) + 1 ) - for current in result[:end_offset].split( "\n" ) : - var = current[ offset: ].split( '"' )[0].replace( " ", "" ) - data = current[ offset: ].split( '"' )[1] + for current in result[:end_offset].split( b"\n" ) : + var = current[ offset: ].split( b'"' )[0].replace( b" ", b"" ) + data = current[ offset: ].split( b'"' )[1] ups_vars[ var ] = data return( ups_vars ) @@ -174,28 +179,28 @@ of the command as value if self.__debug : print( "[DEBUG] GetUPSCommands called..." ) - self.__srv_handler.write( "LIST CMD %s\n" % ups ) - result = self.__srv_handler.read_until( "\n" ) - if result != "BEGIN LIST CMD %s\n" % ups : - raise PyNUTError( result.replace( "\n", "" ) ) + self.__srv_handler.write( ("LIST CMD %s\n" % ups).encode('ascii') ) + result = self.__srv_handler.read_until( b"\n" ) + if result != ("BEGIN LIST CMD %s\n" % ups).encode('ascii') : + raise PyNUTError( result.replace( b"\n", b"" ) ) ups_cmds = {} - result = self.__srv_handler.read_until( "END LIST CMD %s\n" % ups ) - offset = len( "CMD %s " % ups ) - end_offset = 0 - ( len( "END LIST CMD %s\n" % ups ) + 1 ) + result = self.__srv_handler.read_until( ("END LIST CMD %s\n" % ups).encode('ascii') ) + offset = len( ("CMD %s " % ups).encode('ascii') ) + end_offset = 0 - ( len( ("END LIST CMD %s\n" % ups).encode('ascii') ) + 1 ) - for current in result[:end_offset].split( "\n" ) : - var = current[ offset: ].split( '"' )[0].replace( " ", "" ) + for current in result[:end_offset].split( b"\n" ) : + var = current[ offset: ].split( b'"' )[0].replace( b" ", b"" ) # For each var we try to get the available description try : - self.__srv_handler.write( "GET CMDDESC %s %s\n" % ( ups, var ) ) - temp = self.__srv_handler.read_until( "\n" ) - if temp[:7] != "CMDDESC" : + self.__srv_handler.write( ("GET CMDDESC %s %s\n" % ( ups, var )).encode('ascii') ) + temp = self.__srv_handler.read_until( b"\n" ) + if temp[:7] != b"CMDDESC" : raise PyNUTError else : - off = len( "CMDDESC %s %s " % ( ups, var ) ) - desc = temp[off:-1].split('"')[1] + off = len( ("CMDDESC %s %s " % ( ups, var )).encode('ascii') ) + desc = temp[off:-1].split(b'"')[1] except : desc = var @@ -211,20 +216,20 @@ The result is presented as a dictionary containing 'key->val' pairs if self.__debug : print( "[DEBUG] GetUPSVars from '%s'..." % ups ) - self.__srv_handler.write( "LIST RW %s\n" % ups ) - result = self.__srv_handler.read_until( "\n" ) - if ( result != "BEGIN LIST RW %s\n" % ups ) : - raise PyNUTError( result.replace( "\n", "" ) ) + self.__srv_handler.write( ("LIST RW %s\n" % ups).encode('ascii') ) + result = self.__srv_handler.read_until( b"\n" ) + if ( result != ("BEGIN LIST RW %s\n" % ups).encode('ascii') ) : + raise PyNUTError( result.replace( b"\n", b"" ) ) - result = self.__srv_handler.read_until( "END LIST RW %s\n" % ups ) - offset = len( "VAR %s" % ups ) - end_offset = 0 - ( len( "END LIST RW %s\n" % ups ) + 1 ) + result = self.__srv_handler.read_until( ("END LIST RW %s\n" % ups).encode('ascii') ) + offset = len( ("VAR %s" % ups).encode('ascii') ) + end_offset = 0 - ( len( ("END LIST RW %s\n" % ups).encode('ascii') ) + 1 ) rw_vars = {} try : - for current in result[:end_offset].split( "\n" ) : - var = current[ offset: ].split( '"' )[0].replace( " ", "" ) - data = current[ offset: ].split( '"' )[1] + for current in result[:end_offset].split( b"\n" ) : + var = current[ offset: ].split( b'"' )[0].replace( b" ", b"" ) + data = current[ offset: ].split( b'"' )[1] rw_vars[ var ] = data except : @@ -239,9 +244,9 @@ The variable must be a writable value (cf GetRWVars) and you must have the prope rights to set it (maybe login/password). """ - self.__srv_handler.write( "SET VAR %s %s %s\n" % ( ups, var, value ) ) - result = self.__srv_handler.read_until( "\n" ) - if ( result == "OK\n" ) : + self.__srv_handler.write( ("SET VAR %s %s %s\n" % ( ups, var, value )).encode('ascii') ) + result = self.__srv_handler.read_until( b"\n" ) + if ( result == b"OK\n" ) : return( "OK" ) else : raise PyNUTError( result ) @@ -255,35 +260,43 @@ Returns OK on success or raises an error if self.__debug : print( "[DEBUG] RunUPSCommand called..." ) - self.__srv_handler.write( "INSTCMD %s %s\n" % ( ups, command ) ) - result = self.__srv_handler.read_until( "\n" ) - if ( result == "OK\n" ) : + self.__srv_handler.write( ("INSTCMD %s %s\n" % ( ups, command )).encode('ascii') ) + result = self.__srv_handler.read_until( b"\n" ) + if ( result == b"OK\n" ) : return( "OK" ) else : - raise PyNUTError( result.replace( "\n", "" ) ) + raise PyNUTError( result.replace( b"\n", b"" ) ) def FSD( self, ups="") : """ Send FSD command Returns OK on success or raises an error + +NOTE: API changed since NUT 2.8.0 to replace MASTER with PRIMARY +(and backwards-compatible alias handling) """ if self.__debug : - print( "[DEBUG] MASTER called..." ) + print( "[DEBUG] PRIMARY called..." ) - self.__srv_handler.write( "MASTER %s\n" % ups ) - result = self.__srv_handler.read_until( "\n" ) - if ( result != "OK MASTER-GRANTED\n" ) : - raise PyNUTError( ( "Master level function are not available", "" ) ) + self.__srv_handler.write( ("PRIMARY %s\n" % ups).encode('ascii') ) + result = self.__srv_handler.read_until( b"\n" ) + if ( result != b"OK PRIMARY-GRANTED\n" ) : + if self.__debug : + print( "[DEBUG] Retrying: MASTER called..." ) + self.__srv_handler.write( ("MASTER %s\n" % ups).encode('ascii') ) + result = self.__srv_handler.read_until( b"\n" ) + if ( result != b"OK MASTER-GRANTED\n" ) : + raise PyNUTError( ( "Primary level functions are not available", "" ) ) if self.__debug : print( "[DEBUG] FSD called..." ) - self.__srv_handler.write( "FSD %s\n" % ups ) - result = self.__srv_handler.read_until( "\n" ) - if ( result == "OK FSD-SET\n" ) : + self.__srv_handler.write( ("FSD %s\n" % ups).encode('ascii') ) + result = self.__srv_handler.read_until( b"\n" ) + if ( result == b"OK FSD-SET\n" ) : return( "OK" ) else : - raise PyNUTError( result.replace( "\n", "" ) ) + raise PyNUTError( result.replace( b"\n", b"" ) ) def help(self) : """ Send HELP command @@ -292,8 +305,8 @@ Returns OK on success or raises an error if self.__debug : print( "[DEBUG] HELP called..." ) - self.__srv_handler.write( "HELP\n") - return self.__srv_handler.read_until( "\n" ) + self.__srv_handler.write( b"HELP\n" ) + return self.__srv_handler.read_until( b"\n" ) def ver(self) : """ Send VER command @@ -302,8 +315,8 @@ Returns OK on success or raises an error if self.__debug : print( "[DEBUG] VER called..." ) - self.__srv_handler.write( "VER\n") - return self.__srv_handler.read_until( "\n" ) + self.__srv_handler.write( b"VER\n" ) + return self.__srv_handler.read_until( b"\n" ) def ListClients( self, ups = None ) : """ Returns the list of connected clients from the NUT server @@ -317,20 +330,20 @@ The result is a dictionary containing 'key->val' pairs of 'UPSName' and a list o raise PyNUTError( "%s is not a valid UPS" % ups ) if ups: - self.__srv_handler.write( "LIST CLIENTS %s\n" % ups) + self.__srv_handler.write( ("LIST CLIENTS %s\n" % ups).encode('ascii') ) else: - self.__srv_handler.write( "LIST CLIENTS\n" ) - result = self.__srv_handler.read_until( "\n" ) - if result != "BEGIN LIST CLIENTS\n" : - raise PyNUTError( result.replace( "\n", "" ) ) + self.__srv_handler.write( b"LIST CLIENTS\n" ) + result = self.__srv_handler.read_until( b"\n" ) + if result != b"BEGIN LIST CLIENTS\n" : + raise PyNUTError( result.replace( b"\n", b"" ) ) - result = self.__srv_handler.read_until( "END LIST CLIENTS\n" ) + result = self.__srv_handler.read_until( b"END LIST CLIENTS\n" ) ups_list = {} - for line in result.split( "\n" ): - if line[:6] == "CLIENT" : - host, ups = line[7:].split(' ') - ups.replace(' ', '') + for line in result.split( b"\n" ): + if line[:6] == b"CLIENT" : + host, ups = line[7:].split(b' ') + ups.replace(b' ', b'') if not ups in ups_list: ups_list[ups] = [] ups_list[ups].append(host) diff --git a/scripts/python/module/test_nutclient.py b/scripts/python/module/test_nutclient.py.in similarity index 68% rename from scripts/python/module/test_nutclient.py rename to scripts/python/module/test_nutclient.py.in index 39993e0..22e6adb 100755 --- a/scripts/python/module/test_nutclient.py +++ b/scripts/python/module/test_nutclient.py.in @@ -1,22 +1,31 @@ -#!/usr/bin/env python +#!@PYTHON@ # -*- coding: utf-8 -*- # This source code is provided for testing/debuging purpose ;) import PyNUT import sys +import os if __name__ == "__main__" : + NUT_PORT = int(os.getenv('NUT_PORT', '3493')) + NUT_USER = os.getenv('NUT_USER', None) + NUT_PASS = os.getenv('NUT_PASS', None) print( "PyNUTClient test..." ) - nut = PyNUT.PyNUTClient( debug=True ) - #nut = PyNUT.PyNUTClient( login="upsadmin", password="upsadmin", debug=True ) + #nut = PyNUT.PyNUTClient( debug=True, port=NUT_PORT ) + nut = PyNUT.PyNUTClient( login=NUT_USER, password=NUT_PASS, debug=True, port=NUT_PORT ) + #nut = PyNUT.PyNUTClient( login="upsadmin", password="upsadmin", debug=True, port=NUT_PORT ) print( 80*"-" + "\nTesting 'GetUPSList' :") result = nut.GetUPSList( ) print( "\033[01;33m%s\033[0m\n" % result ) - print( 80*"-" + "\nTesting 'GetUPSVars' :") + # [dummy] + # driver = dummy-ups + # desc = "Test device" + # port = /src/nut/data/evolution500.seq + print( 80*"-" + "\nTesting 'GetUPSVars' for 'dummy' (should be registered in upsd.conf) :") result = nut.GetUPSVars( "dummy" ) print( "\033[01;33m%s\033[0m\n" % result ) diff --git a/scripts/subdriver/gen-snmp-subdriver.sh b/scripts/subdriver/gen-snmp-subdriver.sh index 0ff16d6..f7ccf44 100755 --- a/scripts/subdriver/gen-snmp-subdriver.sh +++ b/scripts/subdriver/gen-snmp-subdriver.sh @@ -3,13 +3,14 @@ # an auxiliary script to produce a "stub" snmp-ups subdriver from # SNMP data from a real agent or from dump files # -# Version: 0.6 +# Version: 0.13 # # See also: docs/snmp-subdrivers.txt # # Copyright (C) # 2011 - 2012 Arnaud Quette -# 2015 Arnaud Quette +# 2015 - 2022 Eaton (author: Arnaud Quette ) +# 2011 Jim Klimov # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -26,37 +27,53 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # TODO: +# - Prepend sysDescription (.1.3.6.1.2.1.1.1.0) to have some more visibility # - extend to SNMP v3 (auth.) usage() { - echo "Usage: $0 [options] [file]" - echo "Options:" - echo " -h, --help -- show this message and quit" - echo " -n name -- subdriver name (use natural capitalization)" - echo " -M DIRLIST -- colon separated list of directories to also search for MIBs" - echo " -k -- keep temporary files (for debugging)" - echo "" - echo "mode 1: get SNMP data from a real agent" - echo " -H host_address -- SNMP host IP address or name" - echo " -c community -- SNMP v1 community name (default: public)" - echo " -s XXXX -- override SNMP OID entry point (sysOID). Ex: '.1.3.6.1.4.1.534.10'" - echo "" - echo "mode 2: get data from files (snmpwalk dumps of 'sysOID' subtree)" - echo " -s XXXX -- SNMP OID entry point (sysOID). Ex: '.1.3.6.1.4.1.534.6.6.7'" - echo " file1 file2 -- read from files instead of an host (using Net SNMP)" - echo " file1: numeric SNMP walk (snmpwalk -On ... )" - echo " file2: string SNMP walk (snmpwalk -Os ... )" - echo "" - echo "Notes:" - echo " For both modes, prefer to copy the specific MIB file(s) for your device in the $0 script directory" - echo " In such case, for mode 2, also add \"-M.\" to allow the name resolution of OIDs" - echo "" - echo "Example:" - echo "mode 1: $0 -H 192.168.0.1 -n mibname -c mycommunity" - echo "mode 2: (using sysOID .1.3.6.1.4.1.534.6.6.7)" - echo " snmpwalk -On -v1 -c mycommunity 192.168.0.1 .1.3.6.1.4.1.534.6.6.7 2>/dev/null 1> numeric-walk-file" - echo " snmpwalk -Os -v1 -m ALL -M+. -c mycommunity 192.168.0.1 .1.3.6.1.4.1.534.6.6.7 2>/dev/null 1> string-walk-file" - echo " $0 -s .1.3.6.1.4.1.534.6.6.7 numeric-walk-file string-walk-file" + echo "Usage: $0 [options] [file]" + echo "Options:" + echo " -h, --help -- show this message and quit" + echo " -n name -- subdriver name (use natural capitalization)" + echo " -M DIRLIST -- colon separated list of directories to also search for MIBs" + echo " -k -- keep temporary files (for debugging)" + echo "" + echo "mode 1: get SNMP data from a real agent" + echo " -H host_address -- SNMP host IP address or name" + echo " -c community -- SNMP v1 community name (default: public)" + echo " -s XXXX -- override SNMP OID entry point (sysOID). Ex: '.1.3.6.1.4.1.534.10'" + echo "" + echo "mode 2: get data from files (snmpwalk dumps of 'sysOID' subtree)" + echo " -s XXXX -- SNMP OID entry point (sysOID). Ex: '.1.3.6.1.4.1.534.6.6.7'" + echo " file1 file2 -- read from files instead of an host (using Net SNMP)" + echo " file1: numeric SNMP walk (snmpwalk -On ... )" + echo " file2: string SNMP walk (snmpwalk -Os ... )" + echo "" + echo "mode 3: get data from 1 file (numeric snmpwalk dump of the whole SNMP tree)" + echo " The sysOID is extracted from the dump, and only the pointed subtree is used" + echo " A MIB file MUST be provided, and is used to produce the string SNMP walk" + echo " file1 -- read from file instead of an host (using Net SNMP)" + echo " file1: numeric SNMP walk (snmpwalk -On ... )" + echo "" + + echo "Notes:" + echo " For both modes, prefer to copy the specific MIB file(s) for your device in the $0 script directory" + echo " So that it is automatically taken into account for the string name resolution of OIDs" + echo " Otherwise, use \"-M.\" option" + echo "" + echo "Example:" + echo "mode 1: $0 -H 192.168.0.1 -n mibname -c mycommunity" + echo "mode 2: (using sysOID .1.3.6.1.4.1.534.6.6.7)" + echo " snmpwalk -On -v1 -c mycommunity 192.168.0.1 .1.3.6.1.4.1.534.6.6.7 2>/dev/null 1> numeric-walk-file" + echo " snmpwalk -Os -v1 -m ALL -M+. -c mycommunity 192.168.0.1 .1.3.6.1.4.1.534.6.6.7 2>/dev/null 1> string-walk-file" + echo " $0 -s .1.3.6.1.4.1.534.6.6.7 numeric-walk-file string-walk-file" + echo "mode 3:" + echo " snmpwalk -On -v1 -c mycommunity 192.168.0.1 .1 2>/dev/null 1> numeric-walk-file" + echo " $0 numeric-walk-file" + echo "" + echo " You may alos need to install additional packages:" + echo " - 'snmp' package (on Debian) for the base commands (snmpget, snmpwalk, snmptranslate)" + echo " - 'snmp-mibs-downloader' package (on Debian) to get all standard MIBs" } # variables @@ -65,298 +82,388 @@ KEEP="" HOSTNAME="" MIBS_DIRLIST="+." COMMUNITY="public" +DEVICE_SYSOID="" SYSOID="" MODE=0 # constants NAME=gen-snmp-subdriver TMPDIR="${TEMPDIR:-/tmp}" -DEBUG=`mktemp "$TMPDIR/$NAME-DEBUG.XXXXXX"` -DFL_NUMWALKFILE=`mktemp "$TMPDIR/$NAME-NUMWALK.XXXXXX"` -DFL_STRWALKFILE=`mktemp "$TMPDIR/$NAME-STRWALK.XXXXXX"` -TMP_NUMWALKFILE=`mktemp "$TMPDIR/$NAME-TMP-NUMWALK.XXXXXX"` -TMP_STRWALKFILE=`mktemp "$TMPDIR/$NAME-TMP-STRWALK.XXXXXX"` +SYSOID_NUMBER=".1.3.6.1.2.1.1.2.0" +DEBUG="`mktemp "$TMPDIR/$NAME-DEBUG.XXXXXX"`" +DFL_NUMWALKFILE="`mktemp "$TMPDIR/$NAME-NUMWALK.XXXXXX"`" +DFL_STRWALKFILE="`mktemp "$TMPDIR/$NAME-STRWALK.XXXXXX"`" +TMP_NUMWALKFILE="`mktemp "$TMPDIR/$NAME-TMP-NUMWALK.XXXXXX"`" +TMP_STRWALKFILE="`mktemp "$TMPDIR/$NAME-TMP-STRWALK.XXXXXX"`" get_snmp_data() { - # 1) get the sysOID (points the mfr specif MIB), apart if there's an override - if [ -z "$SYSOID" ] - then - SYSOID=`snmpget -On -v1 -c $COMMUNITY -Ov $HOSTNAME .1.3.6.1.2.1.1.2.0 | cut -d' ' -f2` + # 1) get the sysOID (points the mfr specif MIB), apart if there's an override + if [ -z "$SYSOID" ] + then + SYSOID="`snmpget -On -v1 -c "$COMMUNITY" -Ov "$HOSTNAME" "$SYSOID_NUMBER" | cut -d' ' -f2`" echo "sysOID retrieved: ${SYSOID}" else echo "Using the provided sysOID override ($SYSOID)" fi + DEVICE_SYSOID="$SYSOID" - # 2) get the content of the mfr specif MIB - echo "Retrieving SNMP information. This may take some time" - snmpwalk -On -v1 -c $COMMUNITY $HOSTNAME $SYSOID 2>/dev/null 1> $DFL_NUMWALKFILE - snmpwalk -Os -v1 -m ALL -M $MIBS_DIRLIST -c $COMMUNITY $HOSTNAME $SYSOID 2>/dev/null 1> $DFL_STRWALKFILE + OID_COUNT=0 + while (test "$OID_COUNT" -eq 0) + do + # 2) get the content of the mfr specif MIB + echo "Retrieving SNMP information. This may take some time" + snmpwalk -On -v1 -c "$COMMUNITY" "$HOSTNAME" "$SYSOID" 2>/dev/null 1> "$DFL_NUMWALKFILE" + snmpwalk -Os -v1 -m ALL -M"$MIBS_DIRLIST" -c "$COMMUNITY" "$HOSTNAME" "$SYSOID" 2>/dev/null 1> "$DFL_STRWALKFILE" + + # 3) test return value of the walk, and possibly ramp-up the path to get something. + # The sysOID mechanism only works if we're pointed somehow in the right direction + # i.e. doesn't work if sysOID is .1.3.6.1.4.1.705.1 and data is at .1.3.6.1.4.1.534... + # Ex: sysOID = ".1.X.Y.Z" + # try with ".1.X.Y.Z", if fails try with .1.X.Y", if fails try with .1.X"... + OID_COUNT="`cat $NUMWALKFILE | wc -l`" + if [ $OID_COUNT -eq 0 ]; then + # ramp-up the provided sysOID by removing the last .x part + SYSOID=${SYSOID%.*} + echo "Warning: sysOID provided no data! Trying with a level up using $SYSOID" + fi + done + return $OID_COUNT } -# process command line options -while [ $# -gt 0 ]; do - if [ $# -gt 1 -a "$1" = "-n" ]; then - DRIVER="$2" - shift 2 - elif [ $# -gt 1 -a "$1" = "-M" ]; then - MIBS_DIRLIST="$MIBS_DIRLIST:$2" - shift 2 - elif [ "$1" = "-k" ]; then - KEEP=yes - shift - elif [ $# -gt 1 -a "$1" = "-H" ]; then - HOSTNAME="$2" - shift 2 - elif [ $# -gt 1 -a "$1" = "-c" ]; then - COMMUNITY="$2" - shift 2 - elif [ $# -gt 1 -a "$1" = "-s" ]; then - SYSOID="$2" - shift 2 - elif echo "$1" | grep -qv '^-'; then - if [ $# -gt 1 ]; then - NUMWALKFILE="$1" - shift - STRWALKFILE="$1" - shift - else - usage - exit 1 - fi - elif [ "$1" = "--help" -o "$1" = "-h" ]; then - usage - exit 0 - else - echo "Illegal option $1. Try --help for more info." >&2 - exit 1 - fi -done +generate_C() { + # create file names, lowercase + LDRIVER="`echo "$DRIVER" | tr A-Z a-z`" + UDRIVER="`echo "$DRIVER" | tr a-z A-Z`" + # keep dashes in name for files + CFILE="$LDRIVER-mib.c" + HFILE="$LDRIVER-mib.h" + # but replace with underscores for the structures and defines + LDRIVER="`echo "$LDRIVER" | tr - _`" + UDRIVER="`echo "$UDRIVER" | tr - _`" -# check that the needed parameters are provided, depending on the mode -if [ -z "$NUMWALKFILE" ]; then - # mode 1: directly get SNMP data from a real agent - MODE=1 - NUMWALKFILE=$DFL_NUMWALKFILE - STRWALKFILE=$DFL_STRWALKFILE - - # check if Net SNMP is available - if [ -z "`which snmpget`" -o -z "`which snmpwalk`" ]; then - echo "Net SNMP not found! snmpget and snmpwalk commands are required." >&2 - exit 1 - fi - # hostname is also mandatory - while [ -z "$HOSTNAME" ]; do - echo " - Please enter the SNMP host IP address or name." - read -p "SNMP host IP name or address: " HOSTNAME < /dev/tty - if echo $HOSTNAME | egrep -q '[^a-zA-Z0-9]'; then - echo "Please use only letters and digits" - HOSTNAME="" - fi - done - # get data from the agent - get_snmp_data -else - # mode 2: get data from files - MODE=2 - - # get sysOID value from command line, if needed - while [ -z "$SYSOID" ]; do - echo " -Please enter the value of sysOID, as displayed by snmp-ups. For example '.1.3.6.1.4.1.2254.2.4'. -You can get it using: snmpget -v1 -c XXX .1.3.6.1.2.1.1.2.0" - read -p "Value of sysOID: " SYSOID < /dev/tty - if echo $SYSOID | egrep -q '[^0-9.]'; then - echo "Please use only the numeric form, with dots and digits" - SYSOID="" - fi - done - # check for actual files existence - if [ ! -f "$NUMWALKFILE" -o ! -f "$STRWALKFILE" ]; then - echo "SNMP walk dump files are missing on disk. Try --help for more info." >&2 - exit 1 - fi -fi - -# delete temporary files: this is called just before exiting. -cleanup () { - rm -f "$DEBUG $DFL_NUMWALKFILE $TMP_NUMWALKFILE $DFL_STRWALKFILE $TMP_STRWALKFILE" -} -if [ -n "$KEEP" ]; then - trap cleanup EXIT -fi - -# prompt use for name of driver -while [ -z "$DRIVER" ]; do - echo " -Please enter a name for this driver. Use only letters and numbers. Use -natural (upper- and lowercase) capitalization, e.g., 'Belkin', 'APC'." - read -p "Name of subdriver: " DRIVER < /dev/tty - if echo $DRIVER | egrep -q '[^a-zA-Z0-9]'; then - echo "Please use only letters and digits" - DRIVER="" - fi -done - -# remove blank and "End of MIB" lines -egrep -e "^[[:space:]]?$" -e "End of MIB" -v ${NUMWALKFILE} > ${TMP_NUMWALKFILE} -egrep -e "^[[:space:]]?$" -e "End of MIB" -v ${STRWALKFILE} > ${TMP_STRWALKFILE} -NUMWALKFILE=${TMP_NUMWALKFILE} -STRWALKFILE=${TMP_STRWALKFILE} - -# FIXME: sanity checks (! -z contents -a same `wc -l`) -NUM_OID_COUNT="`cat $NUMWALKFILE | wc -l`" -STR_OID_COUNT="`cat $STRWALKFILE | wc -l`" - -echo "COUNT = $NUM_OID_COUNT / $NUM_OID_COUNT" - -# create file names -LDRIVER=`echo $DRIVER | tr A-Z a-z` -UDRIVER=`echo $DRIVER | tr a-z A-Z` -CFILE="$LDRIVER-mib.c" -HFILE="$LDRIVER-mib.h" - -# generate header file -echo "Creating $HFILE" -cat > "$HFILE" < - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef ${UDRIVER}_MIB_H -#define ${UDRIVER}_MIB_H - -#include "main.h" -#include "snmp-ups.h" - -extern mib2nut_info_t ${LDRIVER}; - -#endif /* ${UDRIVER}_MIB_H */ -EOF - -# generate source file -# create header -echo "Creating $CFILE" -cat > "$CFILE" < - * - * Note: this subdriver was initially generated as a "stub" by the - * gen-snmp-subdriver script. It must be customized! - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "${HFILE}" - -#define ${UDRIVER}_MIB_VERSION "0.1" - -#define ${UDRIVER}_SYSOID "${SYSOID}" - -/* To create a value lookup structure (as needed on the 2nd line of the example - * below), use the following kind of declaration, outside of the present snmp_info_t[]: - * static info_lkp_t onbatt_info[] = { - * { 1, "OB" }, - * { 2, "OL" }, - * { 0, NULL } - * }; - */ - -/* ${UDRIVER} Snmp2NUT lookup table */ -static snmp_info_t ${LDRIVER}_mib[] = { - - /* Data format: - * { info_type, info_flags, info_len, OID, dfl, flags, oid2info, setvar }, + # generate header file + # NOTE: with <<-EOF leading TABs are all stripped + echo "Creating $HFILE" + cat > "$HFILE" <<-EOF + /* ${HFILE} - subdriver to monitor ${DRIVER} SNMP devices with NUT * - * info_type: NUT INFO_ or CMD_ element name - * info_flags: flags to set in addinfo - * info_len: length of strings if STR - * cmd value if CMD, multiplier otherwise - * OID: SNMP OID or NULL - * dfl: default value - * flags: snmp-ups internal flags (FIXME: ...) - * oid2info: lookup table between OID and NUT values - * setvar: variable to set for SU_FLAG_SETINT + * Copyright (C) + * 2011 - 2016 Arnaud Quette * - * Example: - * { "input.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.2.1", "", SU_INPUT_1, NULL }, - * { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.7.3.0", "", SU_FLAG_OK | SU_STATUS_BATT, onbatt_info }, + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * To create a value lookup structure (as needed on the 2nd line), use the - * following kind of declaration, outside of the present snmp_info_t[]: + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + #ifndef ${UDRIVER}_MIB_H + #define ${UDRIVER}_MIB_H + + #include "main.h" + #include "snmp-ups.h" + + extern mib2nut_info_t ${LDRIVER}; + + #endif /* ${UDRIVER}_MIB_H */ + EOF + + # generate source file + # create heading boilerblate + # NOTE: with <<-EOF leading TABs are all stripped + echo "Creating $CFILE" + cat > "$CFILE" <<-EOF + /* ${CFILE} - subdriver to monitor ${DRIVER} SNMP devices with NUT + * + * Copyright (C) + * 2011 - 2016 Arnaud Quette + * + * Note: this subdriver was initially generated as a "stub" by the + * gen-snmp-subdriver script. It must be customized! + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + #include "${HFILE}" + + #define ${UDRIVER}_MIB_VERSION "0.1" + + #define ${UDRIVER}_SYSOID "${DEVICE_SYSOID}" + + /* To create a value lookup structure (as needed on the 2nd line of the example + * below), use the following kind of declaration, outside of the present snmp_info_t[]: * static info_lkp_t onbatt_info[] = { * { 1, "OB" }, * { 2, "OL" }, * { 0, NULL } * }; */ + + /* ${UDRIVER} Snmp2NUT lookup table */ + static snmp_info_t ${LDRIVER}_mib[] = { + + /* Data format: + * { info_type, info_flags, info_len, OID, dfl, flags, oid2info }, + * + * info_type: NUT INFO_ or CMD_ element name + * info_flags: flags to set in addinfo + * info_len: length of strings if ST_FLAG_STRING, multiplier otherwise + * OID: SNMP OID or NULL + * dfl: default value + * flags: snmp-ups internal flags (FIXME: ...) + * oid2info: lookup table between OID and NUT values + * + * Example: + * { "input.voltage", 0, 0.1, ".1.3.6.1.4.1.705.1.6.2.1.2.1", "", SU_INPUT_1, NULL }, + * { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.7.3.0", "", SU_FLAG_OK | SU_STATUS_BATT, onbatt_info }, + * + * To create a value lookup structure (as needed on the 2nd line), use the + * following kind of declaration, outside of the present snmp_info_t[]: + * static info_lkp_t onbatt_info[] = { + * { 1, "OB" }, + * { 2, "OL" }, + * { 0, NULL } + * }; + */ + + /* standard MIB items; if the vendor MIB contains better OIDs for + * this (e.g. with daisy-chain support), consider adding those here + */ + EOF + + # Same file, indented text (TABs not stripped): + cat >> "$CFILE" < /dev/null + if [ $? -eq 0 ]; then + ST_FLAG_TYPE="ST_FLAG_STRING" + SU_INFOSIZE="SU_INFOSIZE" + else + ST_FLAG_TYPE="0" + SU_INFOSIZE="1" + fi + # get the matching numeric OID + NUM_OID="`sed -n "${LINENB}p" "${NUMWALKFILE}" | cut -d' ' -f1`" + printf "\t/* ${FULL_STR_OID} */\n\t{ \"unmapped.${STR_OID}\", ${ST_FLAG_TYPE}, ${SU_INFOSIZE}, \"${NUM_OID}\", NULL, SU_FLAG_OK, NULL },\n" + done < "${STRWALKFILE}" >> "${CFILE}" -# extract OID string paths, one by one -LINENB="0" -while IFS= read -r line; do - LINENB="`expr $LINENB + 1`" - FULL_STR_OID="$line" - STR_OID="`echo $line | cut -d'.' -f1`" - echo $line | grep STRING > /dev/null - if [ $? -eq 0 ]; then - ST_FLAG_TYPE="ST_FLAG_STRING" - SU_INFOSIZE="SU_INFOSIZE" - else - ST_FLAG_TYPE="0" - SU_INFOSIZE="1" - fi - # get the matching numeric OID - NUM_OID="`sed -n ${LINENB}p ${NUMWALKFILE} | cut -d' ' -f1`" - printf "\t/* ${FULL_STR_OID} */\n\t{ \"unmapped.${STR_OID}\", ${ST_FLAG_TYPE}, ${SU_INFOSIZE}, \"${NUM_OID}\", NULL, SU_FLAG_OK, NULL, NULL },\n" -done < ${STRWALKFILE} >> ${CFILE} - -# append footer -cat >> "$CFILE" <> "$CFILE" <&2 + exit 1 + fi +done + +# check that the needed parameters are provided, depending on the mode +if [ -z "$NUMWALKFILE" ]; then + # mode 1: directly get SNMP data from a real agent + echo "Mode 1 selected" + MODE=1 + NUMWALKFILE="$DFL_NUMWALKFILE" + STRWALKFILE="$DFL_STRWALKFILE" + + # check if Net SNMP is available + if [ -z "`command -v snmpget`" -o -z "`command -v snmpwalk`" ] && \ + [ -z "`which snmpget`" -o -z "`which snmpwalk`" ]; then + echo "Net SNMP not found! snmpget and snmpwalk commands are required." >&2 + exit 1 + fi + # hostname is also mandatory + while [ -z "$HOSTNAME" ]; do + printf "\n\tPlease enter the SNMP host IP address or name.\n" + read -p "SNMP host IP name or address: " HOSTNAME < /dev/tty + if echo "$HOSTNAME" | egrep -q '[^a-zA-Z0-9.-]'; then + echo "Please use only letters, digits, dash and period character" + HOSTNAME="" + fi + done + # get data from the agent + get_snmp_data +else + # no string walk provided, so mode 3 + if [ -z "$STRWALKFILE" ]; then + # mode 3: get data from 1 file, + # Filter according to sysOID on the specific subtree + # Generate the numeric SNMP walk using this output + # then use snmptranslate to get the string OIDs and generated the string SNMP walk + echo "Mode 3 selected" + MODE=3 + RAWWALKFILE="$NUMWALKFILE" + NUMWALKFILE="$DFL_NUMWALKFILE" + STRWALKFILE="$DFL_STRWALKFILE" + + # check for actual file existence + if [ ! -f "$RAWWALKFILE" ]; then + echo "SNMP walk dump file is missing on disk. Try --help for more info." >&2 + exit 1 + fi + # Extract the sysOID + # Format is "1.3.6.1.2.1.1.2.0 = OID: 1.3.6.1.4.1.4555.1.1.1" + DEVICE_SYSOID="`grep 1.3.6.1.2.1.1.2.0 "$RAWWALKFILE" | cut -d' ' -f4`" + if [ -n "$DEVICE_SYSOID" ]; then + echo "Found sysOID $DEVICE_SYSOID" + else + echo "SNMP sysOID is missing in file. Try --help for more info." >&2 + exit 1 + fi + + # Switch to the entry point, and extract the subtree + # Extract the numeric walk + echo -n "Extracting numeric SNMP walk..." + grep "$DEVICE_SYSOID" "$RAWWALKFILE" | egrep -v "1.3.6.1.2.1.1.2.0" 2>/dev/null 1> "$NUMWALKFILE" + echo " done" + + # Create the string walk from a translation of the numeric one + echo -n "Converting string SNMP walk..." + while IFS=' = ' read NUM_OID OID_VALUE + do + STR_OID="`snmptranslate -Os -m ALL -M+. "$NUM_OID" 2>/dev/null`" + # Uncomment the below line to get debug logs + #echo "Got: $STR_OID = $OID_VALUE" + printf "." + echo "$STR_OID = $OID_VALUE" >> "$STRWALKFILE" + done < "$NUMWALKFILE" + echo " done" + else + # mode 2: get data from files + echo "Mode 2 selected" + MODE=2 + + # get sysOID value from command line, if needed + while [ -z "$SYSOID" ]; do + echo " +Please enter the value of sysOID, as displayed by snmp-ups. For example '.1.3.6.1.4.1.2254.2.4'. +You can get it using: snmpget -v1 -c XXX $SYSOID_NUMBER" + read -p "Value of sysOID: " SYSOID < /dev/tty + if echo "$SYSOID" | egrep -q '[^0-9.]'; then + echo "Please use only the numeric form, with dots and digits" + SYSOID="" + fi + done + # check for actual files existence + if [ ! -f "$NUMWALKFILE" -o ! -f "$STRWALKFILE" ]; then + echo "SNMP walk dump files are missing on disk. Try --help for more info." >&2 + exit 1 + fi + fi +fi + +# delete temporary files: this is called just before exiting. +cleanup () { + rm -f "$DEBUG $DFL_NUMWALKFILE $TMP_NUMWALKFILE $DFL_STRWALKFILE $TMP_STRWALKFILE" +} +if [ -n "$KEEP" ]; then + trap cleanup EXIT +fi + +# prompt use for name of driver +while [ -z "$DRIVER" ]; do + echo " +Please enter a name for this driver. Use only letters and numbers. Use +natural (upper- and lowercase) capitalization, e.g., 'Belkin', 'APC'." + read -p "Name of subdriver: " DRIVER < /dev/tty + if echo "$DRIVER" | egrep -q '[^a-zA-Z0-9]'; then + echo "Please use only letters and digits" + DRIVER="" + fi +done + +# remove blank and "End of MIB" lines +egrep -e "^[[:space:]]?$" -e "End of MIB" -v "${NUMWALKFILE}" > "${TMP_NUMWALKFILE}" +egrep -e "^[[:space:]]?$" -e "End of MIB" -v "${STRWALKFILE}" > "${TMP_STRWALKFILE}" +NUMWALKFILE="${TMP_NUMWALKFILE}" +STRWALKFILE="${TMP_STRWALKFILE}" + +# FIXME: sanity checks (! -z contents -a same `wc -l`) +NUM_OID_COUNT="`cat "$NUMWALKFILE" | wc -l`" +STR_OID_COUNT="`cat "$STRWALKFILE" | wc -l`" + +echo "SNMP OIDs extracted = $NUM_OID_COUNT / $NUM_OID_COUNT" + +generate_C + # Display the remaining tasks cat < "$CFILE" < * 2013 Charles Lepple * + * TODO: Add year and name for new subdriver author (contributor) + * Mention in docs/acknowledgements.txt if this is a vendor contribution + * * Note: this subdriver was initially generated as a "stub" by the * gen-usbhid-subdriver script. It must be customized. * @@ -203,7 +206,7 @@ static usb_device_id_t ${LDRIVER}_usb_device_table[] = { { USB_DEVICE(${UDRIVER}_VENDORID, 0x${PRODUCTID}), NULL }, /* Terminating entry */ - { -1, -1, NULL } + { 0, 0, NULL } }; @@ -218,7 +221,7 @@ EOF cat "$SUBST" | sed 's/\(.*\) \(.*\)/\t{ "\2",\t0x\1 },/' >> "$CFILE" cat >> "$CFILE" <> "$CFILE" <> "$CFILE" </dev/null 2>&1;; \ esac -DATA = $(systemdsystemunit_DATA) +DATA = $(systemdsystemunit_DATA) $(systemdtmpfiles_DATA) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in \ + $(srcdir)/nut-common.tmpfiles.in \ + $(srcdir)/nut-driver-enumerator.path.in \ + $(srcdir)/nut-driver-enumerator.service.in \ + $(srcdir)/nut-driver@.service.in \ + $(srcdir)/nut-monitor.service.in \ + $(srcdir)/nut-server.service.in $(srcdir)/nutshutdown.in \ + README DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) A2X = @A2X@ ACLOCAL = @ACLOCAL@ @@ -177,6 +211,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -187,6 +222,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -200,6 +236,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -212,6 +249,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -229,6 +267,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -239,21 +279,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -273,6 +321,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -286,6 +337,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -303,6 +355,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -316,6 +369,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -341,12 +397,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -356,13 +414,27 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ udevdir = @udevdir@ -EXTRA_DIST = README $(am__append_1) +EXTRA_DIST = README $(am__append_1) $(am__append_2) @HAVE_SYSTEMD_TRUE@systemdsystemunit_DATA = \ -@HAVE_SYSTEMD_TRUE@ nut-driver.service \ +@HAVE_SYSTEMD_TRUE@ nut-driver-enumerator.service \ +@HAVE_SYSTEMD_TRUE@ nut-driver-enumerator.path \ +@HAVE_SYSTEMD_TRUE@ nut-driver@.service \ @HAVE_SYSTEMD_TRUE@ nut-monitor.service \ -@HAVE_SYSTEMD_TRUE@ nut-server.service +@HAVE_SYSTEMD_TRUE@ nut-server.service \ +@HAVE_SYSTEMD_TRUE@ nut-driver.target \ +@HAVE_SYSTEMD_TRUE@ nut.target -@HAVE_SYSTEMD_TRUE@systemdsystemshutdown_SCRIPTS = nutshutdown +@HAVE_SYSTEMD_TRUE@systemdtmpfiles_DATA = \ +@HAVE_SYSTEMD_TRUE@ nut-common.tmpfiles + +@HAVE_SYSTEMD_TRUE@systemdshutdown_SCRIPTS = nutshutdown +@HAVE_SYSTEMD_TRUE@libexec_SCRIPTS = ../upsdrvsvcctl/nut-driver-enumerator.sh +@HAVE_SYSTEMD_TRUE@sbin_SCRIPTS = ../upsdrvsvcctl/upsdrvsvcctl + +# NOTE: Do not EXTRA_DIST nut-common.tmpfiles.in - it is generated per build + +# Generated by autogen.sh and needed to run the configure script: +MAINTAINERCLEANFILES = Makefile.in .dirstamp nut-common.tmpfiles.in all: all-am .SUFFIXES: @@ -378,14 +450,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu scripts/systemd/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu scripts/systemd/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -396,20 +467,26 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): -nut-driver.service: $(top_builddir)/config.status $(srcdir)/nut-driver.service.in +nut-common.tmpfiles: $(top_builddir)/config.status $(srcdir)/nut-common.tmpfiles.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +nut-driver@.service: $(top_builddir)/config.status $(srcdir)/nut-driver@.service.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ nut-monitor.service: $(top_builddir)/config.status $(srcdir)/nut-monitor.service.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ nut-server.service: $(top_builddir)/config.status $(srcdir)/nut-server.service.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +nut-driver-enumerator.service: $(top_builddir)/config.status $(srcdir)/nut-driver-enumerator.service.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +nut-driver-enumerator.path: $(top_builddir)/config.status $(srcdir)/nut-driver-enumerator.path.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ nutshutdown: $(top_builddir)/config.status $(srcdir)/nutshutdown.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ -install-systemdsystemshutdownSCRIPTS: $(systemdsystemshutdown_SCRIPTS) +install-libexecSCRIPTS: $(libexec_SCRIPTS) @$(NORMAL_INSTALL) - @list='$(systemdsystemshutdown_SCRIPTS)'; test -n "$(systemdsystemshutdowndir)" || list=; \ + @list='$(libexec_SCRIPTS)'; test -n "$(libexecdir)" || list=; \ if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(systemdsystemshutdowndir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(systemdsystemshutdowndir)" || exit 1; \ + echo " $(MKDIR_P) '$(DESTDIR)$(libexecdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libexecdir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ @@ -428,17 +505,87 @@ install-systemdsystemshutdownSCRIPTS: $(systemdsystemshutdown_SCRIPTS) while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ - echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(systemdsystemshutdowndir)$$dir'"; \ - $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(systemdsystemshutdowndir)$$dir" || exit $$?; \ + echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(libexecdir)$$dir'"; \ + $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(libexecdir)$$dir" || exit $$?; \ } \ ; done -uninstall-systemdsystemshutdownSCRIPTS: +uninstall-libexecSCRIPTS: @$(NORMAL_UNINSTALL) - @list='$(systemdsystemshutdown_SCRIPTS)'; test -n "$(systemdsystemshutdowndir)" || exit 0; \ + @list='$(libexec_SCRIPTS)'; test -n "$(libexecdir)" || exit 0; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 's,.*/,,;$(transform)'`; \ - dir='$(DESTDIR)$(systemdsystemshutdowndir)'; $(am__uninstall_files_from_dir) + dir='$(DESTDIR)$(libexecdir)'; $(am__uninstall_files_from_dir) +install-sbinSCRIPTS: $(sbin_SCRIPTS) + @$(NORMAL_INSTALL) + @list='$(sbin_SCRIPTS)'; test -n "$(sbindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(sbindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(sbindir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n' \ + -e 'h;s|.*|.|' \ + -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) { files[d] = files[d] " " $$1; \ + if (++n[d] == $(am__install_max)) { \ + print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ + else { print "f", d "/" $$4, $$1 } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(sbindir)$$dir'"; \ + $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(sbindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-sbinSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(sbin_SCRIPTS)'; test -n "$(sbindir)" || exit 0; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 's,.*/,,;$(transform)'`; \ + dir='$(DESTDIR)$(sbindir)'; $(am__uninstall_files_from_dir) +install-systemdshutdownSCRIPTS: $(systemdshutdown_SCRIPTS) + @$(NORMAL_INSTALL) + @list='$(systemdshutdown_SCRIPTS)'; test -n "$(systemdshutdowndir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(systemdshutdowndir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(systemdshutdowndir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n' \ + -e 'h;s|.*|.|' \ + -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) { files[d] = files[d] " " $$1; \ + if (++n[d] == $(am__install_max)) { \ + print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ + else { print "f", d "/" $$4, $$1 } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(systemdshutdowndir)$$dir'"; \ + $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(systemdshutdowndir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-systemdshutdownSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(systemdshutdown_SCRIPTS)'; test -n "$(systemdshutdowndir)" || exit 0; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 's,.*/,,;$(transform)'`; \ + dir='$(DESTDIR)$(systemdshutdowndir)'; $(am__uninstall_files_from_dir) mostlyclean-libtool: -rm -f *.lo @@ -466,6 +613,27 @@ uninstall-systemdsystemunitDATA: @list='$(systemdsystemunit_DATA)'; test -n "$(systemdsystemunitdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(systemdsystemunitdir)'; $(am__uninstall_files_from_dir) +install-systemdtmpfilesDATA: $(systemdtmpfiles_DATA) + @$(NORMAL_INSTALL) + @list='$(systemdtmpfiles_DATA)'; test -n "$(systemdtmpfilesdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(systemdtmpfilesdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(systemdtmpfilesdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(systemdtmpfilesdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(systemdtmpfilesdir)" || exit $$?; \ + done + +uninstall-systemdtmpfilesDATA: + @$(NORMAL_UNINSTALL) + @list='$(systemdtmpfiles_DATA)'; test -n "$(systemdtmpfilesdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(systemdtmpfilesdir)'; $(am__uninstall_files_from_dir) tags TAGS: ctags CTAGS: @@ -473,7 +641,10 @@ ctags CTAGS: cscope cscopelist: -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -507,7 +678,7 @@ check-am: all-am check: check-am all-am: Makefile $(SCRIPTS) $(DATA) installdirs: - for dir in "$(DESTDIR)$(systemdsystemshutdowndir)" "$(DESTDIR)$(systemdsystemunitdir)"; do \ + for dir in "$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(systemdshutdowndir)" "$(DESTDIR)$(systemdsystemunitdir)" "$(DESTDIR)$(systemdtmpfilesdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am @@ -540,6 +711,7 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am @@ -560,14 +732,14 @@ info: info-am info-am: -install-data-am: install-systemdsystemshutdownSCRIPTS \ - install-systemdsystemunitDATA +install-data-am: install-systemdshutdownSCRIPTS \ + install-systemdsystemunitDATA install-systemdtmpfilesDATA install-dvi: install-dvi-am install-dvi-am: -install-exec-am: +install-exec-am: install-libexecSCRIPTS install-sbinSCRIPTS install-html: install-html-am @@ -605,8 +777,9 @@ ps: ps-am ps-am: -uninstall-am: uninstall-systemdsystemshutdownSCRIPTS \ - uninstall-systemdsystemunitDATA +uninstall-am: uninstall-libexecSCRIPTS uninstall-sbinSCRIPTS \ + uninstall-systemdshutdownSCRIPTS \ + uninstall-systemdsystemunitDATA uninstall-systemdtmpfilesDATA .MAKE: install-am install-strip @@ -615,15 +788,19 @@ uninstall-am: uninstall-systemdsystemshutdownSCRIPTS \ distclean-libtool distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip install-systemdsystemshutdownSCRIPTS \ - install-systemdsystemunitDATA installcheck installcheck-am \ + install-html-am install-info install-info-am \ + install-libexecSCRIPTS install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-sbinSCRIPTS install-strip \ + install-systemdshutdownSCRIPTS install-systemdsystemunitDATA \ + install-systemdtmpfilesDATA installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags-am uninstall uninstall-am \ - uninstall-systemdsystemshutdownSCRIPTS \ - uninstall-systemdsystemunitDATA + uninstall-libexecSCRIPTS uninstall-sbinSCRIPTS \ + uninstall-systemdshutdownSCRIPTS \ + uninstall-systemdsystemunitDATA uninstall-systemdtmpfilesDATA + +.PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/scripts/systemd/README b/scripts/systemd/README index c8930ab..b006358 100644 --- a/scripts/systemd/README +++ b/scripts/systemd/README @@ -4,5 +4,10 @@ Service Manager. These files are automatically installed, upon detection (at configure time) of a systemd enabled system. -Contributed by Michal Hlavinka +This also uses the nut-driver-enumerator.sh (service and implementation +method) and upsdrvsvcctl (tool) to manage NUT drivers as service instances +located in ../upsdrvsvcctl/ source subdirectory. + +Contributed by Michal Hlavinka +Updated 2016-2018 by Michal Hrusecky and Jim Klimov diff --git a/scripts/systemd/nut-common.tmpfiles.in b/scripts/systemd/nut-common.tmpfiles.in new file mode 100644 index 0000000..e69e784 --- /dev/null +++ b/scripts/systemd/nut-common.tmpfiles.in @@ -0,0 +1,5 @@ +# State file (e.g. upsd to driver) and pidfile location for NUT: +d @STATEPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - +X @STATEPATH@/nut +d @PIDPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - - +X @PIDPATH@/nut diff --git a/scripts/systemd/nut-driver-enumerator.path.in b/scripts/systemd/nut-driver-enumerator.path.in new file mode 100644 index 0000000..11f3406 --- /dev/null +++ b/scripts/systemd/nut-driver-enumerator.path.in @@ -0,0 +1,7 @@ +# Trigger restart of nut-driver-enumerator.service whenever ups.conf is edited + +[Path] +PathModified=@CONFPATH@/ups.conf + +[Install] +WantedBy=nut.target diff --git a/scripts/systemd/nut-driver-enumerator.service.in b/scripts/systemd/nut-driver-enumerator.service.in new file mode 100644 index 0000000..51e6d15 --- /dev/null +++ b/scripts/systemd/nut-driver-enumerator.service.in @@ -0,0 +1,30 @@ +[Unit] +# This unit starts early in system lifecycle to set up nut-driver instances. +# End-user may also restart this unit after editing ups.conf to automatically +# un-register or add new instances as appropriate. +Description=Network UPS Tools - enumeration of configure-file devices into systemd unit instances +After=local-fs.target +Before=nut-driver.target +PartOf=nut.target + +[Service] +### Script needs privileges to restart units +#User=@RUN_AS_USER@ +#Group=@RUN_AS_GROUP@ +User=root +SyslogIdentifier=%N +# it is expected that the process has to exit before systemd starts follow-up +# units; it should not be a problem for those +Type=oneshot +# Currently systemd does not support restarting of oneshot services, and does +# not seem to guarantee that other services would only start after the script +# completes, for a non-oneshot case. The script itself handles restarting of +# nut-server which is the primary concerned dependency at the moment, so we +# don't want it to fail the unit (when it can't restart). +Environment=REPORT_RESTART_42=no +EnvironmentFile=-@CONFPATH@/nut.conf +ExecStart=@NUT_LIBEXECDIR@/nut-driver-enumerator.sh +ExecReload=@NUT_LIBEXECDIR@/nut-driver-enumerator.sh + +[Install] +WantedBy=nut.target diff --git a/scripts/systemd/nut-driver.service.in b/scripts/systemd/nut-driver.service.in deleted file mode 100644 index f81ac69..0000000 --- a/scripts/systemd/nut-driver.service.in +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=Network UPS Tools - power device driver controller -After=local-fs.target network.target -StopWhenUnneeded=yes - -[Service] -ExecStart=@SBINDIR@/upsdrvctl start -ExecStop=@SBINDIR@/upsdrvctl stop -Type=forking - diff --git a/scripts/systemd/nut-driver.target b/scripts/systemd/nut-driver.target new file mode 100644 index 0000000..d994ab9 --- /dev/null +++ b/scripts/systemd/nut-driver.target @@ -0,0 +1,8 @@ +[Unit] +Description=Network UPS Tools - target for power device drivers on this system +After=local-fs.target +# network.target +PartOf=nut.target + +[Install] +WantedBy=nut.target diff --git a/scripts/systemd/nut-driver@.service.in b/scripts/systemd/nut-driver@.service.in new file mode 100644 index 0000000..3f1d028 --- /dev/null +++ b/scripts/systemd/nut-driver@.service.in @@ -0,0 +1,67 @@ +[Unit] +Description=Network UPS Tools - device driver for %I +After=local-fs.target + +# Note: If the "Before" line below is uncommented, the target unit +# would only become initialized after the driver units are all in +# a final state (active, failed, ...) and would allow nut-server +# (upsd) to start up and represent those devices on the network. +# With this constraint commented away, the nut-server should start +# earlier, but may initially report some devices as Not connected +# (they should appear when drivers complete their initialization - +# e.g. snmp walks of large MIBs can take a while): +#Before=nut-driver.target + +# Propagate stopping of the target: +PartOf=nut-driver.target + +# Note: The choice of "network.target" allows to schedule this unit +# roughly when the network stack of this OS is ready (e.g. that the +# subsequent `upsd` will have a `0.0.0.0` or a `localhost` to bind +# to); however this target does not ensure availability of a real +# connection or final IP addresses. Drivers that require network as +# a media for interaction with UPSes (snmp-ups, netxml-ups, ipmi etc.) +# may want to extend this unit with `Requires=network-online.target` +# instead. Also note that *generally* this should not be a problem, +# since the drivers have a few retries with timeouts during startup, +# and typically by the time the box gets an IP address, the driver +# is still retrying to start and will succeed. +# Extending the unit does not require *this* file to be edited, you +# can instead drop in an additional piece of configuration, e.g. add +# a `/etc/systemd/system/nut-driver@.service.d/network.conf` with: +# [Unit] +# Requires=network-online.target +# After=network-online.target +# If your `upsd` requires specific IP addresses to be available before +# starting, a `/etc/systemd/system/nut-driver.target.d/network.conf` +# can be used in a similar manner. +# Finally note that "nut-driver-enumerator.service" should take care of this. + +[Service] +EnvironmentFile=-@CONFPATH@/nut.conf +SyslogIdentifier=%N +ExecStart=/bin/sh -c 'NUTDEV="`@NUT_LIBEXECDIR@/nut-driver-enumerator.sh --get-device-for-service %i`" && [ -n "$NUTDEV" ] || { echo "FATAL: Could not find a NUT device section for service unit %i" >&2 ; exit 1 ; } ; @SBINDIR@/upsdrvctl start "$NUTDEV"' +ExecStop=/bin/sh -c 'NUTDEV="`@NUT_LIBEXECDIR@/nut-driver-enumerator.sh --get-device-for-service %i`" && [ -n "$NUTDEV" ] || { echo "FATAL: Could not find a NUT device section for service unit %i" >&2 ; exit 1 ; } ; @SBINDIR@/upsdrvctl stop "$NUTDEV"' +# Restart really always, do not stop trying: +StartLimitInterval=0 +Restart=always +# Protract the "hold-off" interval, so if the device connection is +# lost, the driver does not reapidly restart and fail too many times, +# and then systemd would keep the unit failed without further retries. +# Notably, this helps start "dummy-ups" drivers retranslating local +# devices (so getting a chicken-and-egg problem for driver-upsd-driver +# orderly series of initializations). More details in NUT issue #779. +RestartSec=15s +Type=forking +# Note: If you customize the "maxstartdelay" in ups.conf or in your +# NUT compilation defaults, so it exceeds the default systemd unit +# startup timeout (typically 90 sec), then make sure to set a slightly +# longer systemd timeout for the nut-driver unit instances. You can +# do this by populating a drop-in configuration, so it is not later +# overwritten by updates to your NUT package -- create a dir+file: +# /etc/systemd/system/nut-driver@.service.d/timeout.conf with lines: +# [Service] +# TimeoutStartSec=190s + +[Install] +WantedBy=nut-driver.target diff --git a/scripts/systemd/nut-monitor.service.in b/scripts/systemd/nut-monitor.service.in index 8429bf2..4ee216e 100644 --- a/scripts/systemd/nut-monitor.service.in +++ b/scripts/systemd/nut-monitor.service.in @@ -1,11 +1,26 @@ [Unit] Description=Network UPS Tools - power device monitor and shutdown controller After=local-fs.target network.target nut-server.service +# Note: We do not specify Requires nut-server.service because +# the `upsd` daemon(s) may be running on a different machine +# (connected to the UPSes) than the `upsmon` shutdown protector. +# The "Wants" directive would try to start the nut-server but +# would not abort if that attempt fails for whatever reason. +Wants=nut-server.service +# Extending the unit does not require *this* file to be edited, you +# can instead drop in an additional piece of configuration, e.g. add +# a `/etc/systemd/system/nut-monitor.service.d/network.conf` with: +# [Unit] +# Requires=network-online.target +# After=network-online.target +PartOf=nut.target [Service] -ExecStart=@SBINDIR@/upsmon +EnvironmentFile=-@CONFPATH@/nut.conf +SyslogIdentifier=%N +ExecStart=@SBINDIR@/upsmon -F +ExecReload=@SBINDIR@/upsmon -c reload PIDFile=@PIDPATH@/upsmon.pid -Type=forking [Install] -WantedBy=multi-user.target +WantedBy=nut.target diff --git a/scripts/systemd/nut-server.service.in b/scripts/systemd/nut-server.service.in index fe20145..713f5c4 100644 --- a/scripts/systemd/nut-server.service.in +++ b/scripts/systemd/nut-server.service.in @@ -1,15 +1,29 @@ [Unit] Description=Network UPS Tools - power devices information server -After=local-fs.target network.target nut-driver.service +After=local-fs.target network.target nut-driver.target # We don't Require drivers to be successfully started! This would be # a change of behavior compared to init SysV, and could prevent from # accessing successfully started, at least to audit a system. -Wants=nut-driver.service +Wants=nut-driver.target +# The `upsd` is a networked service (even if bound to a `localhost`) +# so it requires that the OS has some notion of networking already. +# Extending the unit does not require *this* file to be edited, you +# can instead drop in an additional piece of configuration, e.g. add +# a `/etc/systemd/system/nut-server.service.d/network.conf` with: +# [Unit] +# Requires=network-online.target +# After=network-online.target +Requires=network.target Before=nut-monitor.service +PartOf=nut.target [Service] -ExecStart=@SBINDIR@/upsd -Type=forking +EnvironmentFile=-@CONFPATH@/nut.conf +SyslogIdentifier=%N +# Note: foreground mode by default skips writing a PID file (and +# needs Type=simple); can use "-FF" here to create one anyway: +ExecStart=@SBINDIR@/upsd -F +ExecReload=@SBINDIR@/upsd -c reload -P $MAINPID [Install] -WantedBy=multi-user.target +WantedBy=nut.target diff --git a/scripts/systemd/nut.target b/scripts/systemd/nut.target new file mode 100644 index 0000000..f744d29 --- /dev/null +++ b/scripts/systemd/nut.target @@ -0,0 +1,8 @@ +[Unit] +Description=Network UPS Tools - target for power device drivers, data server and monitoring client (if enabled) on this system +After=local-fs.target nut-driver.target nut-server.service nut-monitor.service +Wants=local-fs.target nut-driver.target nut-server.service nut-monitor.service +# network.target + +[Install] +WantedBy=multi-user.target diff --git a/scripts/systemd/nutshutdown.in b/scripts/systemd/nutshutdown.in old mode 100644 new mode 100755 index 1b97fa2..ace2485 --- a/scripts/systemd/nutshutdown.in +++ b/scripts/systemd/nutshutdown.in @@ -1,2 +1,23 @@ #!/bin/sh -@SBINDIR@/upsmon -K >/dev/null 2>&1 && @SBINDIR@/upsdrvctl shutdown + +# This script requires both nut-server (drivers) +# and nut-client (upsmon) to be present locally +# and on mounted filesystems +[ -x "@SBINDIR@/upsmon" ] && [ -x "@SBINDIR@/upsdrvctl" ] || exit + +if @SBINDIR@/upsmon -K >/dev/null 2>&1; then + # The argument may be anything compatible with sleep + # (not necessarily a non-negative integer) + wait_delay="`/bin/sed -ne 's#^ *POWEROFF_WAIT= *\(.*\)$#\1#p' @CONFPATH@/nut.conf`" || wait_delay="" + + @SBINDIR@/upsdrvctl shutdown + + if [ -n "$wait_delay" ] ; then + /bin/sleep $wait_delay + # We need to pass --force twice here to bypass systemd and execute the + # reboot directly ourself. + /bin/systemctl reboot --force --force + fi +fi + +exit 0 diff --git a/scripts/udev/Makefile.am b/scripts/udev/Makefile.am index 1973ccf..5d299a7 100644 --- a/scripts/udev/Makefile.am +++ b/scripts/udev/Makefile.am @@ -18,7 +18,17 @@ EXTRA_DIST = README 52-nut-ipmipsu.rules: nut-ipmipsu.rules cp nut-ipmipsu.rules $@ +MAINTAINERCLEANFILES = Makefile.in .dirstamp + +# Generated by configure script: DISTCLEANFILES = nut-usbups.rules nut-ipmipsu.rules + CLEANFILES = 62-nut-usbups.rules 52-nut-ipmipsu.rules + # we should never remove this one, apart from a distclean-check #MAINTAINERCLEANFILES = nut-usbups.rules.in + +# Generated by autogen.sh and needed to run the configure script +# (technically, generated by tools/nut-usbinfo.pl script among +# GENERATED_USB_OS_FILES): +MAINTAINERCLEANFILES += nut-usbups.rules.in nut-usbups.rules.in.AUTOGEN_WITHOUT diff --git a/scripts/udev/Makefile.in b/scripts/udev/Makefile.in index 7b7485f..70061d2 100644 --- a/scripts/udev/Makefile.in +++ b/scripts/udev/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.16.3 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -15,7 +15,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -82,20 +92,24 @@ target_triplet = @target@ @WITH_UDEV_TRUE@@WITH_USB_TRUE@am__append_1 = 62-nut-usbups.rules @WITH_IPMI_TRUE@@WITH_UDEV_TRUE@am__append_2 = 52-nut-ipmipsu.rules subdir = scripts/udev -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(srcdir)/nut-ipmipsu.rules.in $(srcdir)/nut-usbups.rules.in \ - README ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nut_arg_with.m4 \ $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ $(top_srcdir)/m4/nut_check_libavahi.m4 \ $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ $(top_srcdir)/m4/nut_check_libgd.m4 \ $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ $(top_srcdir)/m4/nut_check_libneon.m4 \ $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ $(top_srcdir)/m4/nut_check_libnss.m4 \ @@ -104,11 +118,17 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ $(top_srcdir)/m4/nut_check_libusb.m4 \ $(top_srcdir)/m4/nut_check_libwrap.m4 \ $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ $(top_srcdir)/m4/nut_type_socklen_t.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = nut-ipmipsu.rules nut-usbups.rules @@ -162,6 +182,8 @@ am__uninstall_files_from_dir = { \ am__installdirs = "$(DESTDIR)$(udevrulesdir)" DATA = $(udevrules_DATA) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/nut-ipmipsu.rules.in \ + $(srcdir)/nut-usbups.rules.in README DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) A2X = @A2X@ ACLOCAL = @ACLOCAL@ @@ -170,6 +192,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -180,6 +203,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -193,6 +217,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -205,6 +230,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -222,6 +248,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -232,21 +260,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -266,6 +302,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -279,6 +318,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -296,6 +336,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -309,6 +350,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -334,12 +378,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -352,6 +398,17 @@ udevdir = @udevdir@ @WITH_UDEV_TRUE@udevrulesdir = $(udevdir)/rules.d @WITH_UDEV_TRUE@udevrules_DATA = $(am__append_1) $(am__append_2) EXTRA_DIST = README + +# we should never remove this one, apart from a distclean-check +#MAINTAINERCLEANFILES = nut-usbups.rules.in + +# Generated by autogen.sh and needed to run the configure script +# (technically, generated by tools/nut-usbinfo.pl script among +# GENERATED_USB_OS_FILES): +MAINTAINERCLEANFILES = Makefile.in .dirstamp nut-usbups.rules.in \ + nut-usbups.rules.in.AUTOGEN_WITHOUT + +# Generated by configure script: DISTCLEANFILES = nut-usbups.rules nut-ipmipsu.rules CLEANFILES = 62-nut-usbups.rules 52-nut-ipmipsu.rules all: all-am @@ -369,14 +426,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu scripts/udev/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu scripts/udev/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -425,7 +481,10 @@ ctags CTAGS: cscope cscopelist: -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -494,6 +553,7 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am @@ -575,14 +635,14 @@ uninstall-am: uninstall-udevrulesDATA mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ uninstall-am uninstall-udevrulesDATA +.PRECIOUS: Makefile + 62-nut-usbups.rules: nut-usbups.rules cp nut-usbups.rules $@ 52-nut-ipmipsu.rules: nut-ipmipsu.rules cp nut-ipmipsu.rules $@ -# we should never remove this one, apart from a distclean-check -#MAINTAINERCLEANFILES = nut-usbups.rules.in # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/scripts/udev/nut-usbups.rules.in b/scripts/udev/nut-usbups.rules.in index 966674f..e073853 100644 --- a/scripts/udev/nut-usbups.rules.in +++ b/scripts/udev/nut-usbups.rules.in @@ -1,12 +1,12 @@ # This file is generated and installed by the Network UPS Tools package. -ACTION!="add|change", GOTO="nut-usbups_rules_end" +ACTION=="remove", GOTO="nut-usbups_rules_end" SUBSYSTEM=="usb_device", GOTO="nut-usbups_rules_real" SUBSYSTEM=="usb", GOTO="nut-usbups_rules_real" -SUBSYSTEM!="usb", GOTO="nut-usbups_rules_end" +GOTO="nut-usbups_rules_end" LABEL="nut-usbups_rules_real" -# ATCL FOR UPS - nutdrv_atcl_usb +# SNR-UPS-LID-XXXX UPSes - nutdrv_qx ATTR{idVendor}=="0001", ATTR{idProduct}=="0000", MODE="664", GROUP="@RUN_AS_GROUP@" # Hewlett Packard @@ -50,8 +50,16 @@ ATTR{idVendor}=="0463", ATTR{idProduct}=="ffff", MODE="664", GROUP="@RUN_AS_GROU # Dell # various models - usbhid-ups ATTR{idVendor}=="047c", ATTR{idProduct}=="ffff", MODE="664", GROUP="@RUN_AS_GROUP@" -# TS Shara UPSes - nutdrv_qx + +# ST Microelectronics +# TS Shara UPSes; vendor ID 0x0483 is from ST Microelectronics - with product IDs delegated to different OEMs - nutdrv_qx ATTR{idVendor}=="0483", ATTR{idProduct}=="0035", MODE="664", GROUP="@RUN_AS_GROUP@" +# USB IDs device table - usbhid-ups +ATTR{idVendor}=="0483", ATTR{idProduct}=="a113", MODE="664", GROUP="@RUN_AS_GROUP@" + +# IBM +# 6000 VA LCD 4U Rack UPS; 5396-1Kx - usbhid-ups +ATTR{idVendor}=="04b3", ATTR{idProduct}=="0001", MODE="664", GROUP="@RUN_AS_GROUP@" # Riello (Cypress Semiconductor Corp.) # various models - riello_usb @@ -98,25 +106,31 @@ ATTR{idVendor}=="051d", ATTR{idProduct}=="0003", MODE="664", GROUP="@RUN_AS_GROU ATTR{idVendor}=="0592", ATTR{idProduct}=="0002", MODE="664", GROUP="@RUN_AS_GROUP@" # PW 9140 - usbhid-ups ATTR{idVendor}=="0592", ATTR{idProduct}=="0004", MODE="664", GROUP="@RUN_AS_GROUP@" -# Agiler UPS - blazer_usb +# Agiler UPS - nutdrv_qx ATTR{idVendor}=="05b8", ATTR{idProduct}=="0000", MODE="664", GROUP="@RUN_AS_GROUP@" -# Belkin F6C1200-UNV - blazer_usb + +# Delta UPS +# Delta UPS Amplon R Series, Single Phase UPS, 1/2/3 kVA - usbhid-ups +ATTR{idVendor}=="05dd", ATTR{idProduct}=="041b", MODE="664", GROUP="@RUN_AS_GROUP@" +# Delta/Minuteman Enterprise Plus E1500RM2U - usbhid-ups +ATTR{idVendor}=="05dd", ATTR{idProduct}=="a011", MODE="664", GROUP="@RUN_AS_GROUP@" +# Belkin F6C1200-UNV/Voltronic Power UPSes - nutdrv_qx ATTR{idVendor}=="0665", ATTR{idProduct}=="5161", MODE="664", GROUP="@RUN_AS_GROUP@" # Phoenixtec Power Co., Ltd -# various models - bcmxcp_usb +# Online Yunto YQ450 - nutdrv_qx ATTR{idVendor}=="06da", ATTR{idProduct}=="0002", MODE="664", GROUP="@RUN_AS_GROUP@" -# Mustek Powermust - blazer_usb +# Mustek Powermust - nutdrv_qx ATTR{idVendor}=="06da", ATTR{idProduct}=="0003", MODE="664", GROUP="@RUN_AS_GROUP@" -# Phoenixtec Innova 3/1 T - blazer_usb +# Phoenixtec Innova 3/1 T - nutdrv_qx ATTR{idVendor}=="06da", ATTR{idProduct}=="0004", MODE="664", GROUP="@RUN_AS_GROUP@" -# Phoenixtec Innova RT - blazer_usb +# Phoenixtec Innova RT - nutdrv_qx ATTR{idVendor}=="06da", ATTR{idProduct}=="0005", MODE="664", GROUP="@RUN_AS_GROUP@" -# Phoenixtec Innova T - blazer_usb +# Phoenixtec Innova T - nutdrv_qx ATTR{idVendor}=="06da", ATTR{idProduct}=="0201", MODE="664", GROUP="@RUN_AS_GROUP@" -# Online Zinto A - blazer_usb +# Online Zinto A - nutdrv_qx ATTR{idVendor}=="06da", ATTR{idProduct}=="0601", MODE="664", GROUP="@RUN_AS_GROUP@" -# various models - usbhid-ups +# PROTECT B / NAS - usbhid-ups ATTR{idVendor}=="06da", ATTR{idProduct}=="ffff", MODE="664", GROUP="@RUN_AS_GROUP@" # iDowell @@ -146,6 +160,8 @@ ATTR{idVendor}=="09ae", ATTR{idProduct}=="1008", MODE="664", GROUP="@RUN_AS_GROU ATTR{idVendor}=="09ae", ATTR{idProduct}=="1009", MODE="664", GROUP="@RUN_AS_GROUP@" # e.g. TrippLite ECO550UPS - usbhid-ups ATTR{idVendor}=="09ae", ATTR{idProduct}=="1010", MODE="664", GROUP="@RUN_AS_GROUP@" +# e.g. TrippLite SU3000LCD2UHV - usbhid-ups +ATTR{idVendor}=="09ae", ATTR{idProduct}=="1330", MODE="664", GROUP="@RUN_AS_GROUP@" # e.g. TrippLite OMNI1000LCD - usbhid-ups ATTR{idVendor}=="09ae", ATTR{idProduct}=="2005", MODE="664", GROUP="@RUN_AS_GROUP@" # e.g. TrippLite OMNI900LCD - usbhid-ups @@ -182,6 +198,8 @@ ATTR{idVendor}=="09ae", ATTR{idProduct}=="3014", MODE="664", GROUP="@RUN_AS_GROU ATTR{idVendor}=="09ae", ATTR{idProduct}=="3015", MODE="664", GROUP="@RUN_AS_GROUP@" # e.g. TrippLite Smart1500LCD (newer unit) - usbhid-ups ATTR{idVendor}=="09ae", ATTR{idProduct}=="3016", MODE="664", GROUP="@RUN_AS_GROUP@" +# e.g. TrippLite AVR750U (newer unit) - usbhid-ups +ATTR{idVendor}=="09ae", ATTR{idProduct}=="3024", MODE="664", GROUP="@RUN_AS_GROUP@" # e.g. TrippLite SmartOnline SU1500RTXL2UA (older unit?) - usbhid-ups ATTR{idVendor}=="09ae", ATTR{idProduct}=="4001", MODE="664", GROUP="@RUN_AS_GROUP@" # e.g. TrippLite SmartOnline SU6000RT4U? - usbhid-ups @@ -214,7 +232,7 @@ ATTR{idVendor}=="0d9f", ATTR{idProduct}=="00a4", MODE="664", GROUP="@RUN_AS_GROU ATTR{idVendor}=="0d9f", ATTR{idProduct}=="00a5", MODE="664", GROUP="@RUN_AS_GROUP@" # PowerCOM BNT - Black Knight Pro - usbhid-ups ATTR{idVendor}=="0d9f", ATTR{idProduct}=="00a6", MODE="664", GROUP="@RUN_AS_GROUP@" -# Unitek Alpha 1200Sx - blazer_usb +# Unitek Alpha 1200Sx - nutdrv_qx ATTR{idVendor}=="0f03", ATTR{idProduct}=="0001", MODE="664", GROUP="@RUN_AS_GROUP@" # Liebert @@ -224,13 +242,57 @@ ATTR{idVendor}=="10af", ATTR{idProduct}=="0001", MODE="664", GROUP="@RUN_AS_GROU ATTR{idVendor}=="10af", ATTR{idProduct}=="0004", MODE="664", GROUP="@RUN_AS_GROUP@" # Liebert GXT3 - usbhid-ups ATTR{idVendor}=="10af", ATTR{idProduct}=="0008", MODE="664", GROUP="@RUN_AS_GROUP@" -# GE EP series - blazer_usb +# GE EP series - nutdrv_qx ATTR{idVendor}=="14f0", ATTR{idProduct}=="00c9", MODE="664", GROUP="@RUN_AS_GROUP@" +# Legrand +# Legrand Keor SP - usbhid-ups +ATTR{idVendor}=="1cb0", ATTR{idProduct}=="0032", MODE="664", GROUP="@RUN_AS_GROUP@" +# Legrand Daker DK / DK Plus - nutdrv_qx +ATTR{idVendor}=="1cb0", ATTR{idProduct}=="0035", MODE="664", GROUP="@RUN_AS_GROUP@" +# Legrand Keor PDU - usbhid-ups +ATTR{idVendor}=="1cb0", ATTR{idProduct}=="0038", MODE="664", GROUP="@RUN_AS_GROUP@" + +# Arduino +# Arduino Leonardo, Leonardo ETH and Pro Micro - usbhid-ups +ATTR{idVendor}=="2341", ATTR{idProduct}=="0036", MODE="664", GROUP="@RUN_AS_GROUP@" +# Arduino Leonardo, Leonardo ETH and Pro Micro - usbhid-ups +ATTR{idVendor}=="2341", ATTR{idProduct}=="8036", MODE="664", GROUP="@RUN_AS_GROUP@" + +# Arduino +# Arduino Leonardo, Leonardo ETH and Pro Micro - usbhid-ups +ATTR{idVendor}=="2A03", ATTR{idProduct}=="0036", MODE="664", GROUP="@RUN_AS_GROUP@" +# Arduino Leonardo, Leonardo ETH and Pro Micro - usbhid-ups +ATTR{idVendor}=="2A03", ATTR{idProduct}=="0040", MODE="664", GROUP="@RUN_AS_GROUP@" +# Arduino Leonardo, Leonardo ETH and Pro Micro - usbhid-ups +ATTR{idVendor}=="2A03", ATTR{idProduct}=="8036", MODE="664", GROUP="@RUN_AS_GROUP@" +# Arduino Leonardo, Leonardo ETH and Pro Micro - usbhid-ups +ATTR{idVendor}=="2A03", ATTR{idProduct}=="8040", MODE="664", GROUP="@RUN_AS_GROUP@" + # AEG # PROTECT B / NAS - usbhid-ups ATTR{idVendor}=="2b2d", ATTR{idProduct}=="ffff", MODE="664", GROUP="@RUN_AS_GROUP@" -# Ablerex 625L USB - blazer_usb + +# Ever +# USB IDs device table - usbhid-ups +ATTR{idVendor}=="2e51", ATTR{idProduct}=="0000", MODE="664", GROUP="@RUN_AS_GROUP@" +# USB IDs device table - usbhid-ups +ATTR{idVendor}=="2e51", ATTR{idProduct}=="ffff", MODE="664", GROUP="@RUN_AS_GROUP@" + +# Salicru +# SLC TWIN PRO2<=3KVA per https://github.com/networkupstools/nut/issues/450 - usbhid-ups +ATTR{idVendor}=="2e66", ATTR{idProduct}=="0201", MODE="664", GROUP="@RUN_AS_GROUP@" +# SLC TWIN PRO2<=3KVA per https://github.com/networkupstools/nut/issues/450 - usbhid-ups +ATTR{idVendor}=="2e66", ATTR{idProduct}=="0202", MODE="664", GROUP="@RUN_AS_GROUP@" +# SLC TWIN PRO2<=3KVA per https://github.com/networkupstools/nut/issues/450 - usbhid-ups +ATTR{idVendor}=="2e66", ATTR{idProduct}=="0203", MODE="664", GROUP="@RUN_AS_GROUP@" +# https://www.salicru.com/sps-home.html - usbhid-ups +ATTR{idVendor}=="2e66", ATTR{idProduct}=="0300", MODE="664", GROUP="@RUN_AS_GROUP@" + +# Powervar +# Powervar - usbhid-ups +ATTR{idVendor}=="4234", ATTR{idProduct}=="0002", MODE="664", GROUP="@RUN_AS_GROUP@" +# Ablerex 625L USB (Note: earlier best-fit was "krauler_subdriver" before PR #1135) - nutdrv_qx ATTR{idVendor}=="ffff", ATTR{idProduct}=="0000", MODE="664", GROUP="@RUN_AS_GROUP@" LABEL="nut-usbups_rules_end" diff --git a/scripts/ufw/Makefile.am b/scripts/ufw/Makefile.am new file mode 100644 index 0000000..dc72ff3 --- /dev/null +++ b/scripts/ufw/Makefile.am @@ -0,0 +1,2 @@ +MAINTAINERCLEANFILES = Makefile.in .dirstamp +CLEANFILES = *-spellchecked diff --git a/scripts/ufw/Makefile.in b/scripts/ufw/Makefile.in new file mode 100644 index 0000000..039dbc9 --- /dev/null +++ b/scripts/ufw/Makefile.in @@ -0,0 +1,569 @@ +# Makefile.in generated by automake 1.16.3 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2020 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = scripts/ufw +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/nut_arg_with.m4 \ + $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ + $(top_srcdir)/m4/nut_check_libavahi.m4 \ + $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ + $(top_srcdir)/m4/nut_check_libgd.m4 \ + $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ + $(top_srcdir)/m4/nut_check_libneon.m4 \ + $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ + $(top_srcdir)/m4/nut_check_libnss.m4 \ + $(top_srcdir)/m4/nut_check_libopenssl.m4 \ + $(top_srcdir)/m4/nut_check_libpowerman.m4 \ + $(top_srcdir)/m4/nut_check_libusb.m4 \ + $(top_srcdir)/m4/nut_check_libwrap.m4 \ + $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ + $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ + $(top_srcdir)/m4/nut_type_socklen_t.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/config.h +CONFIG_CLEAN_FILES = nut.ufw.profile +CONFIG_CLEAN_VPATH_FILES = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +SOURCES = +DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/nut.ufw.profile.in \ + README +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +A2X = @A2X@ +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +ASCIIDOC = @ASCIIDOC@ +ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BINDIR = @BINDIR@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CONFPATH = @CONFPATH@ +CPP = @CPP@ +CPPCHECK = @CPPCHECK@ +CPPFLAGS = @CPPFLAGS@ +CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ +CPPUNIT_LIBS = @CPPUNIT_LIBS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DBLATEX = @DBLATEX@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ +DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ +DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ +DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ +DRVPATH = @DRVPATH@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBAVAHI_CFLAGS = @LIBAVAHI_CFLAGS@ +LIBAVAHI_LIBS = @LIBAVAHI_LIBS@ +LIBDIR = @LIBDIR@ +LIBGD_CFLAGS = @LIBGD_CFLAGS@ +LIBGD_LDFLAGS = @LIBGD_LDFLAGS@ +LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ +LIBIPMI_LIBS = @LIBIPMI_LIBS@ +LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ +LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ +LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ +LIBNEON_LIBS = @LIBNEON_LIBS@ +LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ +LIBNETSNMP_LIBS = @LIBNETSNMP_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBPOWERMAN_CFLAGS = @LIBPOWERMAN_CFLAGS@ +LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ +LIBS = @LIBS@ +LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ +LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ +LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ +LIBUSB_LIBS = @LIBUSB_LIBS@ +LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ +LIBWRAP_LIBS = @LIBWRAP_LIBS@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LN_S_R = @LN_S_R@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ +NUT_NETVERSION = @NUT_NETVERSION@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OS_NAME = @OS_NAME@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PIDPATH = @PIDPATH@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ +RANLIB = @RANLIB@ +RUN_AS_GROUP = @RUN_AS_GROUP@ +RUN_AS_USER = @RUN_AS_USER@ +SBINDIR = @SBINDIR@ +SED = @SED@ +SERLIBS = @SERLIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOURCE_HIGHLIGHT = @SOURCE_HIGHLIGHT@ +STATEPATH = @STATEPATH@ +STRIP = @STRIP@ +SUN_LIBUSB = @SUN_LIBUSB@ +TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ +VERSION = @VERSION@ +WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ +XMLLINT = @XMLLINT@ +XSLTPROC = @XSLTPROC@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +auglensdir = @auglensdir@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +cgiexecdir = @cgiexecdir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +devddir = @devddir@ +docdir = @docdir@ +driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +hotplugdir = @hotplugdir@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +now = @now@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgconfigdir = @pkgconfigdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +systemdshutdowndir = @systemdshutdowndir@ +systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +udevdir = @udevdir@ +MAINTAINERCLEANFILES = Makefile.in .dirstamp +CLEANFILES = *-spellchecked +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu scripts/ufw/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu scripts/ufw/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +nut.ufw.profile: $(top_builddir)/config.status $(srcdir)/nut.ufw.profile.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags TAGS: + +ctags CTAGS: + +cscope cscopelist: + + +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + cscopelist-am ctags-am distclean distclean-generic \ + distclean-libtool distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags-am uninstall uninstall-am + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/scripts/upower/95-upower-hid.rules b/scripts/upower/95-upower-hid.rules index 4c5f2ca..c6e2d06 100644 --- a/scripts/upower/95-upower-hid.rules +++ b/scripts/upower/95-upower-hid.rules @@ -1,145 +1,2 @@ -############################################################################################################## -# Uninterruptible Power Supplies with USB HID interfaces -# -# This file was automatically generated by NUT: -# https://github.com/networkupstools/nut/ -# -# To keep up to date, monitor upstream NUT -# https://github.com/networkupstools/nut/commits/master/scripts/upower/95-upower-hid.rules -# or checkout the NUT repository and call 'tools/nut-usbinfo.pl' - -# newer hiddev are part of the usbmisc class -SUBSYSTEM=="usbmisc", GOTO="up_hid_chkdev" -# only support USB, else ignore -SUBSYSTEM!="usb", GOTO="up_hid_end" - -# if usbraw device, ignore -LABEL="up_hid_chkdev" -KERNEL!="hiddev*", GOTO="up_hid_end" - -# if an interface, ignore -ENV{DEVTYPE}=="usb_interface", GOTO="up_hid_end" - -ATTRS{idVendor}=="03f0", ENV{UPOWER_VENDOR}="Hewlett Packard" -ATTRS{idVendor}=="0463", ENV{UPOWER_VENDOR}="Eaton" -ATTRS{idVendor}=="047c", ENV{UPOWER_VENDOR}="Dell" -ATTRS{idVendor}=="04d8", ENV{UPOWER_VENDOR}="Minibox" -ATTRS{idVendor}=="050d", ENV{UPOWER_VENDOR}="Belkin" -ATTRS{idVendor}=="051d", ENV{UPOWER_VENDOR}="APC" -ATTRS{idVendor}=="0592", ENV{UPOWER_VENDOR}="Powerware" -ATTRS{idVendor}=="06da", ENV{UPOWER_VENDOR}="Phoenixtec Power Co., Ltd" -ATTRS{idVendor}=="075d", ENV{UPOWER_VENDOR}="iDowell" -ATTRS{idVendor}=="0764", ENV{UPOWER_VENDOR}="Cyber Power Systems" -ATTRS{idVendor}=="09ae", ENV{UPOWER_VENDOR}="TrippLite" -ATTRS{idVendor}=="0d9f", ENV{UPOWER_VENDOR}="PowerCOM" -ATTRS{idVendor}=="10af", ENV{UPOWER_VENDOR}="Liebert" -ATTRS{idVendor}=="2b2d", ENV{UPOWER_VENDOR}="AEG" - -# Hewlett Packard -ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0001", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1f06", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1f08", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1f09", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1f0a", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1fe0", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1fe1", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1fe2", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1fe3", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1fe5", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1fe6", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1fe7", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1fe8", ENV{UPOWER_BATTERY_TYPE}="ups" - -# Eaton -ATTRS{idVendor}=="0463", ATTRS{idProduct}=="0001", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="0463", ATTRS{idProduct}=="ffff", ENV{UPOWER_BATTERY_TYPE}="ups" - -# Dell -ATTRS{idVendor}=="047c", ATTRS{idProduct}=="ffff", ENV{UPOWER_BATTERY_TYPE}="ups" - -# Minibox -ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="d004", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="d005", ENV{UPOWER_BATTERY_TYPE}="ups" - -# Belkin -ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0375", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0551", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0750", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0751", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0900", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0910", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0912", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0980", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="050d", ATTRS{idProduct}=="0f51", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="050d", ATTRS{idProduct}=="1100", ENV{UPOWER_BATTERY_TYPE}="ups" - -# APC -ATTRS{idVendor}=="051d", ATTRS{idProduct}=="0000", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="051d", ATTRS{idProduct}=="0002", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="051d", ATTRS{idProduct}=="0003", ENV{UPOWER_BATTERY_TYPE}="ups" - -# Powerware -ATTRS{idVendor}=="0592", ATTRS{idProduct}=="0004", ENV{UPOWER_BATTERY_TYPE}="ups" - -# Phoenixtec Power Co., Ltd -ATTRS{idVendor}=="06da", ATTRS{idProduct}=="ffff", ENV{UPOWER_BATTERY_TYPE}="ups" - -# iDowell -ATTRS{idVendor}=="075d", ATTRS{idProduct}=="0300", ENV{UPOWER_BATTERY_TYPE}="ups" - -# Cyber Power Systems -ATTRS{idVendor}=="0764", ATTRS{idProduct}=="0005", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="0764", ATTRS{idProduct}=="0501", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="0764", ATTRS{idProduct}=="0601", ENV{UPOWER_BATTERY_TYPE}="ups" - -# TrippLite -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="1003", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="1007", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="1008", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="1009", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="1010", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="2005", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="2007", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="2008", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="2009", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="2010", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="2011", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="2012", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="2013", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="2014", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="3008", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="3009", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="3010", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="3011", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="3012", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="3013", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="3014", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="3015", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="3016", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="4001", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="4002", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="4003", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="4004", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="4005", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="4006", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="4007", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="09ae", ATTRS{idProduct}=="4008", ENV{UPOWER_BATTERY_TYPE}="ups" - -# PowerCOM -ATTRS{idVendor}=="0d9f", ATTRS{idProduct}=="0001", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="0d9f", ATTRS{idProduct}=="0004", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="0d9f", ATTRS{idProduct}=="00a2", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="0d9f", ATTRS{idProduct}=="00a3", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="0d9f", ATTRS{idProduct}=="00a4", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="0d9f", ATTRS{idProduct}=="00a5", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="0d9f", ATTRS{idProduct}=="00a6", ENV{UPOWER_BATTERY_TYPE}="ups" - -# Liebert -ATTRS{idVendor}=="10af", ATTRS{idProduct}=="0001", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="10af", ATTRS{idProduct}=="0004", ENV{UPOWER_BATTERY_TYPE}="ups" -ATTRS{idVendor}=="10af", ATTRS{idProduct}=="0008", ENV{UPOWER_BATTERY_TYPE}="ups" - -# AEG -ATTRS{idVendor}=="2b2d", ATTRS{idProduct}=="ffff", ENV{UPOWER_BATTERY_TYPE}="ups" - -LABEL="up_hid_end" +# Copy some attributes from the USB device to the hiddev device +SUBSYSTEM=="usbmisc", SUBSYSTEMS=="usb", KERNEL=="hiddev*", IMPORT{parent}="UPOWER_*", IMPORT{parent}="ID_VENDOR", IMPORT{parent}="ID_PRODUCT" diff --git a/scripts/upsdrvsvcctl/Makefile.am b/scripts/upsdrvsvcctl/Makefile.am new file mode 100644 index 0000000..77313ca --- /dev/null +++ b/scripts/upsdrvsvcctl/Makefile.am @@ -0,0 +1,13 @@ +EXTRA_DIST = README + +if HAVE_SYSTEMD +EXTRA_DIST += nut-driver-enumerator.sh upsdrvsvcctl +else +if WITH_SOLARIS_SMF +EXTRA_DIST += nut-driver-enumerator.sh upsdrvsvcctl +endif +endif + +EXTRA_DIST += nut-driver-enumerator.sh.in upsdrvsvcctl.in + +MAINTAINERCLEANFILES = Makefile.in .dirstamp diff --git a/scripts/upsdrvsvcctl/Makefile.in b/scripts/upsdrvsvcctl/Makefile.in new file mode 100644 index 0000000..860002a --- /dev/null +++ b/scripts/upsdrvsvcctl/Makefile.in @@ -0,0 +1,574 @@ +# Makefile.in generated by automake 1.16.3 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2020 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +@HAVE_SYSTEMD_TRUE@am__append_1 = nut-driver-enumerator.sh upsdrvsvcctl +@HAVE_SYSTEMD_FALSE@@WITH_SOLARIS_SMF_TRUE@am__append_2 = nut-driver-enumerator.sh upsdrvsvcctl +subdir = scripts/upsdrvsvcctl +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/nut_arg_with.m4 \ + $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ + $(top_srcdir)/m4/nut_check_libavahi.m4 \ + $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ + $(top_srcdir)/m4/nut_check_libgd.m4 \ + $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ + $(top_srcdir)/m4/nut_check_libneon.m4 \ + $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ + $(top_srcdir)/m4/nut_check_libnss.m4 \ + $(top_srcdir)/m4/nut_check_libopenssl.m4 \ + $(top_srcdir)/m4/nut_check_libpowerman.m4 \ + $(top_srcdir)/m4/nut_check_libusb.m4 \ + $(top_srcdir)/m4/nut_check_libwrap.m4 \ + $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ + $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ + $(top_srcdir)/m4/nut_type_socklen_t.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/config.h +CONFIG_CLEAN_FILES = nut-driver-enumerator.sh upsdrvsvcctl +CONFIG_CLEAN_VPATH_FILES = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +SOURCES = +DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in \ + $(srcdir)/nut-driver-enumerator.sh.in \ + $(srcdir)/upsdrvsvcctl.in README +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +A2X = @A2X@ +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +ASCIIDOC = @ASCIIDOC@ +ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BINDIR = @BINDIR@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CONFPATH = @CONFPATH@ +CPP = @CPP@ +CPPCHECK = @CPPCHECK@ +CPPFLAGS = @CPPFLAGS@ +CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ +CPPUNIT_LIBS = @CPPUNIT_LIBS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DBLATEX = @DBLATEX@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ +DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ +DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ +DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ +DRVPATH = @DRVPATH@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBAVAHI_CFLAGS = @LIBAVAHI_CFLAGS@ +LIBAVAHI_LIBS = @LIBAVAHI_LIBS@ +LIBDIR = @LIBDIR@ +LIBGD_CFLAGS = @LIBGD_CFLAGS@ +LIBGD_LDFLAGS = @LIBGD_LDFLAGS@ +LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ +LIBIPMI_LIBS = @LIBIPMI_LIBS@ +LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ +LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ +LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ +LIBNEON_LIBS = @LIBNEON_LIBS@ +LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ +LIBNETSNMP_LIBS = @LIBNETSNMP_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBPOWERMAN_CFLAGS = @LIBPOWERMAN_CFLAGS@ +LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ +LIBS = @LIBS@ +LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ +LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ +LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ +LIBUSB_LIBS = @LIBUSB_LIBS@ +LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ +LIBWRAP_LIBS = @LIBWRAP_LIBS@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LN_S_R = @LN_S_R@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ +NUT_NETVERSION = @NUT_NETVERSION@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OS_NAME = @OS_NAME@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PIDPATH = @PIDPATH@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ +RANLIB = @RANLIB@ +RUN_AS_GROUP = @RUN_AS_GROUP@ +RUN_AS_USER = @RUN_AS_USER@ +SBINDIR = @SBINDIR@ +SED = @SED@ +SERLIBS = @SERLIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOURCE_HIGHLIGHT = @SOURCE_HIGHLIGHT@ +STATEPATH = @STATEPATH@ +STRIP = @STRIP@ +SUN_LIBUSB = @SUN_LIBUSB@ +TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ +VERSION = @VERSION@ +WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ +XMLLINT = @XMLLINT@ +XSLTPROC = @XSLTPROC@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +auglensdir = @auglensdir@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +cgiexecdir = @cgiexecdir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +devddir = @devddir@ +docdir = @docdir@ +driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +hotplugdir = @hotplugdir@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +now = @now@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgconfigdir = @pkgconfigdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +systemdshutdowndir = @systemdshutdowndir@ +systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +udevdir = @udevdir@ +EXTRA_DIST = README $(am__append_1) $(am__append_2) \ + nut-driver-enumerator.sh.in upsdrvsvcctl.in +MAINTAINERCLEANFILES = Makefile.in .dirstamp +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu scripts/upsdrvsvcctl/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu scripts/upsdrvsvcctl/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +nut-driver-enumerator.sh: $(top_builddir)/config.status $(srcdir)/nut-driver-enumerator.sh.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +upsdrvsvcctl: $(top_builddir)/config.status $(srcdir)/upsdrvsvcctl.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags TAGS: + +ctags CTAGS: + +cscope cscopelist: + + +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + cscopelist-am ctags-am distclean distclean-generic \ + distclean-libtool distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags-am uninstall uninstall-am + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/scripts/upsdrvsvcctl/README b/scripts/upsdrvsvcctl/README new file mode 100644 index 0000000..b2a9db6 --- /dev/null +++ b/scripts/upsdrvsvcctl/README @@ -0,0 +1,11 @@ +This directory contains the shared NUT support files for Linux systemd (the +System and Service Manager) and Solaris SMF (Service Management Framework). +It includes the nut-driver-enumerator.sh (service and implementation method) +and upsdrvsvcctl (tool) to manage NUT drivers as service instances. + +These files are automatically installed into SBINDIR/upsdrvsvcctl and +LIBEXECDIR/nut-driver-enumerator.sh, upon detection (at configure time) +of a systemd or SMF enabled system, with Makefiles of the ../systemd/ and +../Solaris/ source directories respectively. + +Contributed 2016-2018 by Jim Klimov diff --git a/scripts/upsdrvsvcctl/nut-driver-enumerator.sh b/scripts/upsdrvsvcctl/nut-driver-enumerator.sh new file mode 100755 index 0000000..cce714c --- /dev/null +++ b/scripts/upsdrvsvcctl/nut-driver-enumerator.sh @@ -0,0 +1,1391 @@ +#!/bin/sh +# +# NOTE: This script is intentionally written with portable shell constructs +# with the aim and hope to work in different interpreters, so it is a +# bit dumber and less efficient than could be achieved with the more +# featured shells in the spectrum. +# NOTE ALSO: The configuration parser in this script is not meant to be a +# reference or 100% compliant with what the binary code uses; its aim +# is to just pick out some strings relevant for tracking config changes. +# +# Copyright (C) 2016-2020 Eaton +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +#! \file nut-driver-enumerator.sh(.in) +# \author Jim Klimov +# \brief Enumerate NUT devices for service-unit instance configuration +# \details This script allows to enumerate UPSes in order to produce the +# individual service unit instances for each defined configuration. +# It assumes the user has adequate permissions to inspect and create +# services (e.g. is a root or has proper RBAC profiles to do so). +# It helps service frameworks such as Linux systemd and Solaris SMF. +# When executed, this script looks for all configured ups.conf +# sections and registered service instances, and makes these two +# lists match up. It has also a mode to do this in a loop, to keep +# checking for differences and applying them, on systems where it's +# problematic to trigger it in response to FS event notifications. +# Returns exit codes: +# 0 Sections and services already match up +# 42 Sections and services differed, but now match up - +# now the caller should likely restart some services. +# Note that the drivers' service instances were started or +# stopped as required (by AUTO_START=yes) - but maybe the +# upsd or upsmon services should restart. If you pass envvar +# REPORT_RESTART_42=no then this codepath would return 0. +# In default mode, such non-null reconfiguration should cause +# the nut-driver-enumerator service to restart and this would +# propagate to other NUT services that depend on it. +# 13 Sections and services differed, and still do not match up +# 1 Bad inputs, e.g. unrecognized service management framework +# 2 Absent or unreadable ups.conf file +# + +# NOTE: Currently found caveats that might be solved later but require +# considerable effort: +# * Solaris SMF constrains the syntax of valid strings for instance names +# (e.g. not starting with a digit, no period chars) which blocks creation +# of some UPS driver instances. This might be worked around by hashing +# the device name e.g. to base64 (and un-hashing instance name when calling +# upsdrvctl), but is not quite user-friendly. Also can store device name +# in a service attribute while mangling the instance name to a valid subset. +# Comparisons (if devices are already wrapped) becomes more complicated in +# the script in either case, as well as in the service startup method. +# ** The `+` `/` `=` characters from base64 are also invalid for SMF instance +# name, but the first two can be sed'ed to `-` `_` and back, for example. +# Some prefix word is also needed (avoid starting with a digit). +# The trailing padding `=` can be dropped, and added until we get a +# non-empty decode. Conversions can be done by +# `echo "$string" | openssl base64 -e|-d` +# * Dummy-UPS services that "proxy" another locally defined section are +# essentially a circular dependency for upsd. While the system might +# start-up lacking a driver, there should be some timer to re-enable +# failed not-disabled drivers (would be useful in any case though). + +# Directory where NUT configs are located, e.g. /etc/nut or /etc/ups +# Set at package configuration, compiled into daemons and drivers +prefix="/usr/local" +[ -n "${NUT_CONFPATH-}" ] || NUT_CONFPATH="${prefix}/etc" +# Technically this should be a distribution-dependent value configured +# during package build. But everyone has it the same from systemd defaults: +[ -n "${SYSTEMD_CONFPATH-}" ] || SYSTEMD_CONFPATH="/etc/systemd/system" + +if [ -n "$ZSH_VERSION" ]; then + ### Problem: loops like `for UPS in $UPSLIST` do not separate + ### the UPSLIST into many tokens but use it as one string. + echo "FATAL: zsh is not supported in this script" >&2 + exit 1 +# setopt noglob +# setopt +F +# IFS="`printf ' \t\r\n'`" ; export IFS +fi + +if set | egrep '^(shell|version|t?csh)' | egrep 't?csh' >/dev/null ; then + echo "FATAL: csh or tcsh is not supported in this script" >&2 + exit 1 +fi + +# Third-party services to depend on (can be overridden by config file) +### Note that for systemd+udev integration, it may be better to set up +### triggers in udev, see e.g. +### http://stackoverflow.com/questions/18463755/linux-start-daemon-on-connected-usb-serial-dongle +### Also can tune whether a driver "Wants" another service (would consider +### ordering if that one is enabled, but live if it is disabled), or if it +### "Requires" that (would cause that to start). +DEPSVC_USB_SYSTEMD="systemd-udev.service systemd-udev-settle.service" +DEPREQ_USB_SYSTEMD="Wants" +DEPSVC_NET_FULL_SYSTEMD="network-online.target systemd-resolved.service ifplugd.service" +DEPREQ_NET_FULL_SYSTEMD="Wants" +DEPSVC_NET_LOCAL_SYSTEMD="network.target" +DEPREQ_NET_LOCAL_SYSTEMD="Wants" +SVCNAME_SYSTEMD="nut-driver" + +# Some or all of these FMRIs may be related to dynamically changing hardware +# require_all) ;; # All cited services are running (online or degraded) +# require_any) ;; # At least one of the cited services is running +# optional_all) ;; # (All) cited services are running or would not run +# # without administrative action (disabled, maintenance, +# # not present, or are waiting for dependencies which do +# # not start without administrative action). +DEPSVC_USB_SMF="svc:/system/hotplug:default svc:/system/dbus:default svc:/system/hal:default svc:/milestone/devices:default" +DEPREQ_USB_SMF="optional_all" +# By default there are several physical network FMRIs shipped and at most +# only one is enabled on a particular system (e.g. :default or :nwam) +DEPSVC_NET_FULL_SMF="svc:/network/physical svc:/milestone/name-services" +DEPREQ_NET_FULL_SMF="optional_all" +DEPSVC_NET_LOCAL_SMF="svc:/network/loopback:default" +DEPREQ_NET_LOCAL_SMF="optional_all" +SVCNAME_SMF="svc:/system/power/nut-driver" + +[ -z "${NUT_DRIVER_ENUMERATOR_CONF-}" ] && \ + NUT_DRIVER_ENUMERATOR_CONF="${NUT_CONFPATH}/nut-driver-enumerator.conf" + +[ -s "${NUT_DRIVER_ENUMERATOR_CONF}" ] && \ + echo "Sourcing config file: ${NUT_DRIVER_ENUMERATOR_CONF}" && \ + . "${NUT_DRIVER_ENUMERATOR_CONF}" + +[ -z "${UPSCONF-}" ] && \ + UPSCONF="${NUT_CONFPATH}/ups.conf" + +# Start a freshly-registered unit? +[ -z "${AUTO_START-}" ] && AUTO_START=yes + +# We avoid regex '\t' which gets misinterpreted by some tools +TABCHAR="`printf '\t'`" || TABCHAR=' ' + +if [ -z "${SERVICE_FRAMEWORK-}" ] ; then + [ -x /usr/sbin/svcadm ] && [ -x /usr/sbin/svccfg ] && [ -x /usr/bin/svcs ] && [ -x /usr/bin/svcprop ] && \ + SERVICE_FRAMEWORK="smf" + [ -z "${SERVICE_FRAMEWORK-}" ] && \ + [ -x /bin/systemctl ] && \ + SERVICE_FRAMEWORK="systemd" +fi + +# Optionally use Coreutils timeout to limit the +# (potentially hanging) calls to systemd tools... +# Should not hurt with SMF too, if it ever misbehaves. +if [ -z "${TIMEOUT_CMD+x}" ]; then + # Envvar not set at all (set but empty is okay, caller wants that then) + TIMEOUT_CMD="" + TIMEOUT_ARGS="" + if which timeout 2>/dev/null >/dev/null ; then + # Systemd default timeout for unit start/stop + TIMEOUT_CMD="timeout" + TIMEOUT_ARGS="90s" + fi +fi + +# Cache needed bits of ups.conf to speed up later parsing. Note that these +# data are needed for most operations, and populated by upslist_readFile() +UPSCONF_DATA="" +# Subset of normalized data above that only has sections, drivers and ports +UPSCONF_DATA_SDP="" + +# List of configured UPSes in the config-file +UPSLIST_FILE="" +# List of configured service instances for UPS drivers +UPSLIST_SVCS="" + +# Framework-specific implementations are generally hooked here: +hook_registerInstance="" +hook_unregisterInstance="" +hook_refreshSupervizor="" +hook_listInstances="" +hook_listInstances_raw="" +hook_validInstanceName="" +hook_validFullUnitName="" +hook_validInstanceSuffixName="" +hook_getSavedMD5="" +hook_setSavedMD5="" +hook_restart_upsd="" +hook_restart_drv="" + +case "${SERVICE_FRAMEWORK-}" in + smf) + hook_registerInstance="smf_registerInstance" + hook_unregisterInstance="smf_unregisterInstance" + hook_refreshSupervizor="smf_refreshSupervizor" + hook_listInstances="smf_listInstances" + hook_listInstances_raw="smf_listInstances_raw" + hook_validInstanceName="smf_validInstanceName" + hook_validFullUnitName="smf_validFullUnitName" + hook_validInstanceSuffixName="smf_validInstanceSuffixName" + hook_getSavedMD5="smf_getSavedMD5" + hook_setSavedMD5="smf_setSavedMD5" + hook_restart_upsd="smf_restart_upsd" + hook_restart_drv="smf_restart_drv" + ;; + systemd) + hook_registerInstance="systemd_registerInstance" + hook_unregisterInstance="systemd_unregisterInstance" + hook_refreshSupervizor="systemd_refreshSupervizor" + hook_listInstances="systemd_listInstances" + hook_listInstances_raw="systemd_listInstances_raw" + hook_validInstanceName="systemd_validInstanceName" + hook_validFullUnitName="systemd_validFullUnitName" + hook_validInstanceSuffixName="systemd_validInstanceSuffixName" + hook_getSavedMD5="systemd_getSavedMD5" + hook_setSavedMD5="systemd_setSavedMD5" + hook_restart_upsd="systemd_restart_upsd" + hook_restart_drv="systemd_restart_drv" + ;; + selftest) + hook_registerInstance="selftest_NOOP" + hook_unregisterInstance="selftest_NOOP" + hook_refreshSupervizor="selftest_NOOP" + hook_listInstances="selftest_NOOP" + hook_listInstances_raw="selftest_NOOP" + hook_validInstanceName="selftest_NOOP" + hook_validFullUnitName="selftest_NOOP" + hook_validInstanceSuffixName="selftest_NOOP" + hook_getSavedMD5="selftest_NOOP" + hook_setSavedMD5="selftest_NOOP" + hook_restart_upsd="selftest_NOOP" + hook_restart_drv="selftest_NOOP" + ;; + "") + echo "Error detecting the service-management framework on this OS" >&2 + exit 1 + ;; + *) + echo "Error: User provided an unknown service-management framework '$SERVICE_FRAMEWORK'" >&2 + exit 1 + ;; +esac + +selftest_NOOP() { + echo "NO-OP: Self-testing context does not do systems configuration" >&2 + return 0 +} + +common_isFiled() { + [ -n "$UPSLIST_FILE" ] && \ + for UPSF in $UPSLIST_FILE ; do + [ "$1" = "$UPSF" ] && return 0 + [ "`$hook_validInstanceName "$UPSF"`" = "$1" ] && return 0 + done + return 1 +} + +common_isRegistered() { + [ -n "$UPSLIST_SVCS" ] && \ + for UPSS in $UPSLIST_SVCS ; do + [ "$1" = "$UPSS" ] && return 0 + [ "`$hook_validInstanceName "$1"`" = "$UPSS" ] && return 0 + done + return 1 +} + +upslist_equals() { + # Compare pre-sorted list of DEVICES ($1) and SVCINSTs ($2) including + # the possible mangling for service names. Return 0 if lists describe + # exactly same set of devices and their services. + # Note: This logic only checks the names, not the contents of device + # sections, so re-definitions of an existing device configuration + # would not trigger a service restart by itself. Such deeper check + # belongs in a different routine, see upssvcconf_checksum_unchanged(). + + # Trivial case 0: one string is empty, another is not + # Note: `echo '' | wc -l` == "1" not "0"! + [ -n "$1" -a -z "$2" ] && return 1 + [ -z "$1" -a -n "$2" ] && return 1 + + # Trivial case 1: equal strings + [ "$1" = "$2" ] && return 0 + # Trivial case 2: different amount of entries + [ "`echo "$1" | wc -l`" = "`echo "$2" | wc -l`" ] || return $? + + _TMP_DEV_SVC="" + for _DEV in $1 ; do + DEVINST="`$hook_validInstanceName "$_DEV"`" + for _SVC in $2 ; do + [ "$_DEV" = "$_SVC" ] \ + || [ "$DEVINST" = "$_SVC" ] \ + && { [ -z "$_TMP_DEV_SVC" ] \ + && _TMP_DEV_SVC="$_DEV = $_SVC" \ + || _TMP_DEV_SVC="$_TMP_DEV_SVC +$_DEV = $_SVC" ; } + done + done + + # Input was not empty; did anything in output fit? + [ -z "$_TMP_DEV_SVC" ] && return 1 + + # Exit code : is the built mapping as long as the source list(s)? + [ "`echo "$1" | wc -l`" = "`echo "$_TMP_DEV_SVC" | wc -l`" ] +} + +upssvcconf_checksum_unchanged() { + # $1 = dev, $2 = svc + # compare checksums of the configuration section from the file and the + # stashed configuration in a service instance (if any). + # FIXME : optimize by caching, we likely have quite a few requests + [ "`upsconf_getSection_MD5 "$1"`" = "`$hook_getSavedMD5 "$2"`" ] +} + +upslist_checksums_unchanged() { + # For each device and its corresponding unit, compare checksums of the + # configuration section from the file and the stashed configuration in + # a service instance. Prints a list of mismatching service names that + # should get reconfigured. + [ -z "$1" -o -z "$2" ] && return 1 + + _TMP_SVC="" + for _DEV in $1 ; do + DEVINST="`$hook_validInstanceName "$_DEV"`" + for _SVC in $2 ; do + if [ "$_DEV" = "$_SVC" ] \ + || [ "$DEVINST" = "$_SVC" ] \ + ; then + upssvcconf_checksum_unchanged "$_DEV" "$_SVC" || \ + { [ -z "$_TMP_SVC" ] \ + && _TMP_SVC="$_SVC" \ + || _TMP_SVC="$_TMP_SVC +$_SVC" ; } + fi + done + done + [ -z "$_TMP_SVC" ] && return 0 + echo "$_TMP_SVC" + return 1 +} + +upsconf_getSection_content() { + # "$1" = name of ups.conf section to display in whole, from whatever + # comes on stdin (file or a pre-made normalized variable) + # empty "$1" means the global config (before any sections) + # + # NOTE (TODO?): This routine finds the one NUT device section, prints it + # and returns when the section is over. It currently does not cover (in + # a way allowing to do it efficiently) selection of several sections, + # or storing each section content in some array or dynamic variables + # (as would be better fit for portable shells) to later address them + # quickly without re-parsing the file or big envvar many times. + # + + CURR_SECTION="" + SECTION_CONTENT="" + RES=1 + [ -n "$1" ] || RES=0 + while read LINE ; do + case "$LINE" in + \["$1"\]) + if [ "$RES" = 0 ]; then + # We have already displayed a section, here is a new one, + # and this routine only displays one (TODO: toggle?) + break + fi + SECTION_CONTENT="$LINE" + CURR_SECTION="$1" + RES=0 + continue + ;; + \[*\ *\]|\[*"$TABCHAR"*\]) + # Note that section-name brackets should contain a single token + # Fall through to add the line to contents of existing section + ;; + \[*\]) + [ "$CURR_SECTION" = "$1" ] && break + # Use a value that can not be a section name here: + CURR_SECTION="[]" + continue + ;; + "") continue ;; + *) ;; # Fall through to add the line to contents of existing section + esac + if [ "$CURR_SECTION" = "$1" ]; then + if [ -n "$SECTION_CONTENT" ]; then + SECTION_CONTENT="$SECTION_CONTENT +$LINE" + else + SECTION_CONTENT="$LINE" + fi + fi + done + + if [ -n "$SECTION_CONTENT" ]; then + echo "$SECTION_CONTENT" + fi + + [ "$RES" = 0 ] || echo "ERROR: Section [$1] was not found in the '$UPSCONF' file" >&2 + return $RES +} + +upsconf_getSection() { + # Use the whole output of normalization parser + upslist_normalizeFile_once || return # Propagate errors upwards + upsconf_getSection_content "$@" << EOF +${UPSCONF_DATA} +EOF +} + +upsconf_getSection_MD5() { + calc_md5 "`upsconf_getSection "$@"`" +} + +upsconf_getSection_SDP() { + # Use the section-driver-port subset + upslist_normalizeFile_once || return # Propagate errors upwards + upsconf_getSection_content "$@" << EOF +${UPSCONF_DATA_SDP} +EOF +} + +upsconf_getValue() { + # "$1" = name of ups.conf section, may be empty for global config + # "$2..$N" = name of config key; we will echo its value +### [ -n "$1" ] || return $? + [ -n "$2" ] || return $? + [ -n "$GETSECTION" ] || GETSECTION="upsconf_getSection" + CURR_SECTION="" # Gets set by a GETSECTION implementation + RES=0 + + # Note: Primary aim of this egrep is to pick either assignments or flags + # As a by-product it can be used to test if a particular value is set ;) + SECTION_CONTENT="`$GETSECTION "$1"`" || return + shift + KEYS="$*" + + while [ "$#" -gt 0 ] ; do + RES_L=0 + VALUE="" + + LINE="`echo "$SECTION_CONTENT" | egrep '(^'"$1"'=|^'"$1"'$)'`" \ + && VALUE="$(echo "$LINE" | sed -e "s,^$1=,," -e 's,^\"\(.*\)\"$,\1,' -e "s,^'\(.*\)'$,\1,")" \ + || RES_L=$? + + [ "$RES_L" = 0 ] || { RES="$RES_L" ; echo "ERROR: Section [$CURR_SECTION] or key '$1' in it was not found in the '$UPSCONF' file" >&2 ; } + + echo "$VALUE" + shift + done + + [ "$RES" = 0 ] || echo "ERROR: Section [$CURR_SECTION] or key(s) '$KEYS' in it was not found in the '$UPSCONF' file" >&2 + return $RES +} + +upsconf_getDriver() { + # "$1" = name of ups.conf section; return (echo) the driver name used there + # In the context this function is used, UPSCONF exists and section is there + GETSECTION="upsconf_getSection_SDP" upsconf_getValue "$1" "driver" + return $? +} + +upsconf_getPort() { + # "$1" = name of ups.conf section; return (echo) the "port" name used there + # In the context this function is used, UPSCONF exists and section is there + GETSECTION="upsconf_getSection_SDP" upsconf_getValue "$1" "port" + return $? +} + +upsconf_getDriverMedia() { + # "$1" = name of ups.conf section; return (echo) name and type of driver as + # needed for dependency evaluation (what services we must depend on for this + # unit), newline-separated (drvnametype). Empty type for unclassified + # results, assuming no known special dependencies (note that depending on + # particular system's physics, both serial and network media may need USB). + CURR_DRV="`upsconf_getDriver "$1"`" || return $? + case "$CURR_DRV" in + *netxml*|*snmp*|*ipmi*|*powerman*|*-mib*|*avahi*|*apcupsd*) + printf '%s\n%s\n' "$CURR_DRV" "network" ; return ;; + *usb*) + printf '%s\n%s\n' "$CURR_DRV" "usb" ; return ;; + nutdrv_qx) # May be direct serial or USB + CURR_PORT="`upsconf_getPort "$1"`" || CURR_PORT="" + case "$CURR_PORT" in + auto|/dev/*usb*|/dev/*hid*) + printf '%s\n%s\n' "$CURR_DRV" "usb" ; return ;; + /dev/*) + # See drivers/nutdrv_qx.c :: upsdrv_initups() for a list + if [ -n "`upsconf_getValue "$1" 'subdriver' 'vendorid' 'productid' 'vendor' 'product' 'serial' 'bus' 'langid_fix'`" ] \ + ; then + printf '%s\n%s\n' "$CURR_DRV" "usb" ; return + else + printf '%s\n%s\n' "$CURR_DRV" "serial" ; return + fi + ;; + *) + printf '%s\n%s\n' "$CURR_DRV" "" ; return ;; + esac + ;; + *dummy*|*clone*) # May be networked (proxy to remote NUT) + CURR_PORT="`upsconf_getPort "$1"`" || CURR_PORT="" + case "$CURR_PORT" in + *@localhost|*@|*@127.0.0.1|*@::1) + printf '%s\n%s\n' "$CURR_DRV" "network-localhost" ; return ;; + *@*) + printf '%s\n%s\n' "$CURR_DRV" "network" ; return ;; + *) + printf '%s\n%s\n' "$CURR_DRV" "" ; return ;; + esac + ;; + *) printf '%s\n%s\n' "$CURR_DRV" "" ; return ;; + esac +} + +upsconf_getMedia() { + _DRVMED="`upsconf_getDriverMedia "$1"`" || return + echo "$_DRVMED" | tail -n +2 + return 0 +} + +upsconf_debug() { + _DRV="`upsconf_getDriver "$1"`" + _PRT="`upsconf_getPort "$1"`" + _MED="`upsconf_getMedia "$1"`" + _MD5="`upsconf_getSection_MD5 "$1"`" + NAME_MD5="`calc_md5 "$1"`" + echo "INST: ${NAME_MD5}~[$1]: DRV='$_DRV' PORT='$_PRT' MEDIA='$_MED' SECTIONMD5='$_MD5'" +} + +calc_md5() { + # Tries several ways to produce an MD5 of the "$1" argument + _MD5="`echo "$1" | md5sum 2>/dev/null | awk '{print $1}'`" && [ -n "$_MD5" ] || \ + { _MD5="`echo "$1" | openssl dgst -md5 2>/dev/null | awk '{print $NF}'`" && [ -n "$_MD5" ]; } || \ + return 1 + + echo "$_MD5" +} + +calc_md5_file() { + # Tries several ways to produce an MD5 of the file named by "$1" argument + [ -s "$1" ] || return 2 + + _MD5="`md5sum 2>/dev/null < "$1" | awk '{print $1}'`" && [ -n "$_MD5" ] || \ + { _MD5="`openssl dgst -md5 2>/dev/null < "$1" | awk '{print $NF}'`" && [ -n "$_MD5" ]; } || \ + return 1 + + echo "$_MD5" +} + +smf_validFullUnitName() { + case "$1" in + *:*) echo "$1" ;; + *) echo "$SVCNAME_SMF:$1" ;; + esac +} +smf_validInstanceName() { + echo "MD5_`calc_md5 "$1"`" +} +smf_validInstanceSuffixName() { + case "$1" in + *:*) echo "$1" | sed 's,^.*:\([^:]*\)$,\1,' ;; + *) echo "$1" ;; + esac +} +smf_registerInstance() { + DEVICE="$1" + SVCINST="$1" + /usr/sbin/svccfg -s nut-driver add "$DEVICE" || \ + { SVCINST="`smf_validInstanceName "$1"`" && \ + /usr/sbin/svccfg -s nut-driver add "$SVCINST" || return ; } + echo "Added instance: 'nut-driver:$SVCINST' for NUT configuration section '$DEVICE'" >&2 + + DEPSVC="" + DEPREQ="" + _MED="`upsconf_getMedia "$DEVICE"`" + case "$_MED" in + usb) + DEPSVC="$DEPSVC_USB_SMF" + DEPREQ="$DEPREQ_USB_SMF" ;; + network-localhost) + DEPSVC="$DEPSVC_NET_LOCAL_SMF" + DEPREQ="$DEPREQ_NET_LOCAL_SMF" ;; + network) + DEPSVC="$DEPSVC_NET_FULL_SMF" + DEPREQ="$DEPREQ_NET_FULL_SMF" ;; + serial) ;; + '') ;; + *) echo "WARNING: Unexpected NUT media type ignored: '$_MED'" >&2 ;; + esac + + TARGET_FMRI="nut-driver:$SVCINST" + if [ -n "$DEPSVC" ]; then + [ -n "$DEPREQ" ] || DEPREQ="optional_all" + echo "Adding '$DEPREQ' dependency for '$SVCINST' on '$DEPSVC'..." + + DEPPG="nut-driver-enumerator-generated" + RESTARTON="refresh" + /usr/sbin/svccfg -s "$TARGET_FMRI" addpg "$DEPPG" dependency && \ + /usr/sbin/svccfg -s "$TARGET_FMRI" setprop "$DEPPG"/grouping = astring: "$DEPREQ" && \ + /usr/sbin/svccfg -s "$TARGET_FMRI" setprop "$DEPPG"/restart_on = astring: "$RESTARTON" && \ + /usr/sbin/svccfg -s "$TARGET_FMRI" setprop "$DEPPG"/type = astring: service && \ + /usr/sbin/svccfg -s "$TARGET_FMRI" setprop "$DEPPG"/entities = fmri: "($DEPSVC)" && \ + echo "OK" || echo "FAILED to define the dependency" >&2 + fi + + smf_setSavedMD5 "$SVCINST" "`upsconf_getSection_MD5 "$DEVICE"`" + + /usr/sbin/svcadm refresh "${TARGET_FMRI}" || return + if [ "$AUTO_START" = yes ] ; then + /usr/sbin/svcadm clear "${TARGET_FMRI}" 2>/dev/null || true + /usr/sbin/svcadm enable "${TARGET_FMRI}" || return + echo "Started instance: 'nut-driver:$SVCINST' for NUT configuration section '$DEVICE'" >&2 + fi +} +smf_unregisterInstance() { + echo "Removing instance: 'nut-driver:$1' ..." >&2 + /usr/sbin/svcadm disable -ts 'nut-driver:'"$1" || false + /usr/sbin/svccfg -s nut-driver delete "$1" +} +smf_refreshSupervizor() { + : +} +smf_listInstances_raw() { + # Newer versions have pattern matching; older SMF might not have this luxury + /usr/bin/svcs -a -H -o fmri | egrep '/nut-driver:' +} +smf_listInstances() { + smf_listInstances_raw | sed 's/^.*://' | sort -n +} +smf_getSavedMD5() { + # Query service instance $1 + PG="nut-driver-enumerator-generated-checksum" + PROP="SECTION_CHECKSUM" + + if [ -n "$1" ]; then + TARGET_FMRI="nut-driver:$1" + else + # Global section + TARGET_FMRI="nut-driver" + PROP="SECTION_CHECKSUM_GLOBAL" + fi + + # Note: lookups for GLOBAL cause each service instance to show up + /usr/bin/svcprop -p "$PG/$PROP" "$TARGET_FMRI" | head -1 | awk '{print $NF}' +} +smf_setSavedMD5() { + # Save checksum value $2 into service instance $1 + PG="nut-driver-enumerator-generated-checksum" + PROP="SECTION_CHECKSUM" + + if [ -n "$1" ]; then + TARGET_FMRI="nut-driver:$1" + else + # Global section + TARGET_FMRI="nut-driver" + PROP="SECTION_CHECKSUM_GLOBAL" + fi + + /usr/sbin/svccfg -s "$TARGET_FMRI" delprop "$PG" || true + /usr/sbin/svccfg -s "$TARGET_FMRI" addpg "$PG" application && \ + /usr/sbin/svccfg -s "$TARGET_FMRI" setprop "$PG/$PROP" = astring: "$2" + [ $? = 0 ] && echo "OK" || { echo "FAILED to stash the checksum">&2 ; return 1 ; } + /usr/sbin/svcadm refresh "${TARGET_FMRI}" || return +} +smf_restart_upsd() { + echo "Restarting NUT data server to make sure it knows new configuration..." + /usr/sbin/svcadm enable "nut-server" 2>/dev/null + /usr/sbin/svcadm clear "nut-server" 2>/dev/null + /usr/sbin/svcadm refresh "nut-server" || \ + /usr/sbin/svcadm restart "nut-server" +} +smf_restart_drv() { + echo "Restarting NUT driver instance '$1' to make sure it knows new configuration..." + /usr/sbin/svcadm enable "nut-driver:$1" 2>/dev/null + /usr/sbin/svcadm clear "nut-driver:$1" 2>/dev/null + /usr/sbin/svcadm refresh "nut-driver:$1" || \ + /usr/sbin/svcadm restart "nut-driver:$1" +} + +systemd_validFullUnitName() { + case "$1" in + *@*.*) echo "$1" ;; + *@*) echo "$1.service" ;; + *) echo "$SVCNAME_SYSTEMD@$1.service" ;; + esac +} +systemd_validInstanceName() { + echo "MD5_`calc_md5 "$1"`" +} +systemd_validInstanceSuffixName() { + echo "$1" | sed -e 's,^.*@,,' -e 's,\.service$,,' +} +systemd_registerInstance() { + # Instance is registered by device section name; ultimate name in systemd may differ + DEVICE="$1" + SVCINST="$1" + /bin/systemctl enable 'nut-driver@'"$DEVICE".service || \ + { SVCINST="`systemd_validInstanceName "$1"`" && \ + /bin/systemctl enable 'nut-driver@'"$SVCINST".service || return ; } + echo "Enabled instance: 'nut-driver@$SVCINST' for NUT configuration section '$DEVICE'" >&2 + + DEPSVC="" + DEPREQ="" + _MED="`upsconf_getMedia "$DEVICE"`" + case "$_MED" in + usb) + DEPSVC="$DEPSVC_USB_SYSTEMD" + DEPREQ="$DEPREQ_USB_SYSTEMD" ;; + network-localhost) + DEPSVC="$DEPSVC_NET_LOCAL_SYSTEMD" + DEPREQ="$DEPREQ_NET_LOCAL_SYSTEMD" ;; + network) + DEPSVC="$DEPSVC_NET_FULL_SYSTEMD" + DEPREQ="$DEPREQ_NET_FULL_SYSTEMD" ;; + serial) ;; + '') ;; + *) echo "WARNING: Unexpected NUT media type ignored: '$_MED'" >&2 ;; + esac + if [ -n "$DEPSVC" ]; then + [ -n "$DEPREQ" ] || DEPREQ="#Wants" + echo "Adding '$DEPREQ'+After dependency for '$SVCINST' on '$DEPSVC'..." + mkdir -p "${SYSTEMD_CONFPATH}/nut-driver@$SVCINST.service.d" && \ + cat > "${SYSTEMD_CONFPATH}/nut-driver@$SVCINST.service.d/nut-driver-enumerator-generated.conf" <&2 + fi + + systemd_setSavedMD5 "$SVCINST" "`upsconf_getSection_MD5 "$DEVICE"`" + + if [ "$AUTO_START" = yes ] ; then + systemd_refreshSupervizor || echo "WARNING: Somehow managed to fail systemd_refreshSupervizor()" >&2 + $TIMEOUT_CMD $TIMEOUT_ARGS /bin/systemctl start --no-block 'nut-driver@'"$SVCINST".service || return + echo "Started instance: 'nut-driver@$SVCINST' for NUT configuration section '$DEVICE'" >&2 + fi +} +systemd_unregisterInstance() { + echo "Removing instance: 'nut-driver@$1' ..." >&2 + $TIMEOUT_CMD $TIMEOUT_ARGS /bin/systemctl stop 'nut-driver@'"$1".service || \ + $TIMEOUT_CMD $TIMEOUT_ARGS /bin/systemctl stop 'nut-driver@'"$1".service || \ + $TIMEOUT_CMD $TIMEOUT_ARGS /bin/systemctl stop 'nut-driver@'"$1".service || false + + /bin/systemctl disable 'nut-driver@'"$1".service + rm -rf "${SYSTEMD_CONFPATH}/nut-driver@$1.service.d" + /bin/systemctl reset-failed 'nut-driver@'"$1".service +} +systemd_refreshSupervizor() { + /bin/systemctl daemon-reload +} +systemd_listInstances_raw() { + /bin/systemctl show 'nut-driver@*' -p Id | egrep '=nut-driver' | sed 's,^Id=,,' +} +systemd_listInstances() { + systemd_listInstances_raw | sed -e 's/^.*@//' -e 's/\.service$//' | sort -n +} +systemd_getSavedMD5() { + # Query service instance $1 or global section + PROP="SECTION_CHECKSUM" + [ -n "$1" ] || PROP="SECTION_CHECKSUM_GLOBAL" + [ -s "${SYSTEMD_CONFPATH}/nut-driver@$1.service.d/nut-driver-enumerator-generated-checksum.conf" ] \ + && grep "Environment='$PROP=" "${SYSTEMD_CONFPATH}/nut-driver@$1.service.d/nut-driver-enumerator-generated-checksum.conf" | sed -e "s,^Environment='$PROP=,," -e "s,'\$,," \ + || { echo "Did not find '${SYSTEMD_CONFPATH}/nut-driver@$1.service.d/nut-driver-enumerator-generated-checksum.conf' with a $PROP" ; return 1; } +} +systemd_setSavedMD5() { + # Save checksum value $2 into service instance $1 + PROP="SECTION_CHECKSUM" + [ -n "$1" ] || PROP="SECTION_CHECKSUM_GLOBAL" + mkdir -p "${SYSTEMD_CONFPATH}/nut-driver@$1.service.d" && \ + cat > "${SYSTEMD_CONFPATH}/nut-driver@$1.service.d/nut-driver-enumerator-generated-checksum.conf" << EOF +[Service] +Environment='$PROP=$2' +EOF + [ $? = 0 ] && echo "OK" || { echo "FAILED to stash the checksum">&2 ; return 1 ; } +} +systemd_restart_upsd() { + # Do not restart/reload if not already running + case "`/bin/systemctl is-active "nut-server"`" in + active|unknown) ;; # unknown meant "starting" in our testing... + failed) echo "Note: nut-server unit was 'failed' - not disabled by user, so (re)starting it (probably had no config initially)" >&2 ;; + *) return 0 ;; + esac + + echo "Restarting NUT data server to make sure it knows new configuration..." + # Note: reload is a better way to go about this, so the + # data service is not interrupted by re-initialization + # of the daemon. But systemd/systemctl sometimes stalls... + + $TIMEOUT_CMD $TIMEOUT_ARGS /bin/systemctl reload-or-restart "nut-server" || \ + $TIMEOUT_CMD $TIMEOUT_ARGS /bin/systemctl restart "nut-server" +} + +systemd_restart_drv() { + # Do not restart/reload if not already running + case "`/bin/systemctl is-active "nut-driver@$1"`" in + active|unknown) ;; + *) return 0 ;; + esac + + echo "Restarting NUT driver instance '$1' to make sure it knows new configuration..." + + # Full restart, e.g. in case we changed the user= in configs + $TIMEOUT_CMD $TIMEOUT_ARGS /bin/systemctl restart "nut-driver@$1" +} + +upslist_normalizeFile_filter() { + # See upslist_normalizeFile() detailed comments below; this routine + # is a pipe worker to prepare the text into a simpler expected form. + + # Pick the lines which contain a bracket or assignment character, + # or a single token (certain keywords come as just NUT "flags"), + # trim leading and trailing whitespace, comment-only lines, and in + # assignment lines trim the spaces around equality character and + # quoting characters around assignment of values without whitespaces. + # Any whitespace characters around a section name (single token that + # starts the line and is enclosed in brackets) and a trailing comment + # are dropped. Note that brackets with spaces inside, and brackets + # that do not start the non-whitespace payload of the line, are not + # sections. + egrep -v '(^$|^#)' | \ + sed -e 's,^['"$TABCHAR"'\ ]*,,' \ + -e 's,^\#.*$,,' \ + -e 's,['"$TABCHAR"'\ ]*$,,' \ + -e 's,^\([^=\ '"$TABCHAR"']*\)['"$TABCHAR"'\ ]*=['"$TABCHAR"'\ ]*,\1=,g' \ + -e 's,=\"\([^\ '"$TABCHAR"']*\)\"$,=\1,' \ + -e 's,^\(\[[^]'"$TABCHAR"'\ ]*\]\)['"$TABCHAR"'\ ]*\(#.*\)*$,\1,' \ + | egrep -v '^$' \ + | egrep '([\[\=]|^[^ '"$TABCHAR"']*$|^[^ '"$TABCHAR"']*[ '"$TABCHAR"']*\#.*$)' +} + +upslist_normalizeFile() { + # Read the ups.conf file and find all defined sections (names of + # configuration blocks for drivers that connect to a certain device + # using specified protocol and media); normalize section contents + # as detailed below, to simplify subsequent parsing and comparison. + + # File contents + UPSCONF_DATA="" + UPSCONF_DATA_SDP="" + if [ -n "$UPSCONF" ] && [ -f "$UPSCONF" ] && [ -r "$UPSCONF" ]; then + [ ! -s "$UPSCONF" ] \ + && echo "WARNING: The '$UPSCONF' file exists but is empty" >&2 \ + && return 0 + # Ok to continue - we may end up removing all instances + else + echo "FATAL: The '$UPSCONF' file does not exist or is not readable" >&2 + return 2 + fi + + # Store a normalized version of NUT configuration file contents. + # Also use a SDP subset with just section, driver and port info + # for faster parsing when determining driver-required media etc. + UPSCONF_DATA="$(upslist_normalizeFile_filter < "$UPSCONF")" \ + && [ -n "$UPSCONF_DATA" ] \ + && UPSCONF_DATA_SDP="`egrep '^(\[.*\]|driver=|port=)' << EOF +$UPSCONF_DATA +EOF`" \ + || { echo "Error reading the '$UPSCONF' file or it does not declare any device configurations: nothing left after normalization" >&2 + UPSCONF_DATA="" + UPSCONF_DATA_SDP="" + } +} + +upslist_normalizeFile_once() { + # Wrapper that ensures that the parsing is only done once + # (will re-parse if there were no devices listed on the + # first time, though) + [ -z "$UPSCONF_DATA" ] && [ -z "$UPSCONF_DATA_SDP" ] || return 0 + upslist_normalizeFile +} + +upslist_readFile() { + # Use the routine above (unconditionally) to get or update the + # listing of device sections known at this moment. + + # List of devices from the config file + UPSLIST_FILE="" + if [ "$DO_NORMALIZE_ONCE" = yes ]; then + upslist_normalizeFile_once || return # Propagate errors upwards + else + upslist_normalizeFile || return # Propagate errors upwards + fi + + if [ -n "$UPSCONF_DATA" ] ; then + # Note that section-name brackets should contain a single token + UPSLIST_FILE="$(echo "$UPSCONF_DATA_SDP" | egrep '^\[[^'"$TABCHAR"'\ ]*\]$' | sed 's,^\[\(.*\)\]$,\1,' | sort -n)" \ + || UPSLIST_FILE="" + if [ -z "$UPSLIST_FILE" ] ; then + echo "Error reading the '$UPSCONF' file or it does not declare any device configurations: no section declarations in parsed normalized contents" >&2 + fi + fi + # Ok to continue with empty results - we may end up removing all instances +} + +upslist_readFile_once() { + # Wrapper that ensures that the parsing is only done once + # (will re-parse if there were no devices listed on the + # first time, though) + [ -z "$UPSLIST_FILE" ] || return 0 + DO_NORMALIZE_ONCE=yes upslist_readFile +} + +upslist_readSvcs() { + UPSLIST_SVCS="`$hook_listInstances`" || UPSLIST_SVCS="" + if [ -z "$UPSLIST_SVCS" ] && [ "$1" != "-" ] ; then + EXPLAIN="" + [ -z "$1" ] || EXPLAIN=" - $1" + echo "Error reading the list of ${SERVICE_FRAMEWORK-} service instances for UPS drivers, or none are defined${EXPLAIN}" >&2 + # Ok to continue - we may end up defining new instances + fi +} + +upslist_debug() { + for UPSF in "" $UPSLIST_FILE ; do + upsconf_debug "$UPSF" + done +} + +upslist_addSvcs() { + # Note: This routine registers service instances for device config sections + # that are not wrapped currently. Support for redefined previously existing + # sections - is attained by removing the old service instance elsewhere and + # recreating it here, since any data could change including the dependency + # list, etc. + for UPSF in $UPSLIST_FILE ; do + if ! common_isRegistered "$UPSF" ; then + echo "Adding new ${SERVICE_FRAMEWORK} service instance for power device [${UPSF}]..." >&2 + $hook_registerInstance "$UPSF" + fi + done +} + +upslist_delSvcs() { + for UPSS in $UPSLIST_SVCS ; do + if ! common_isFiled "$UPSS" ; then + echo "Dropping old ${SERVICE_FRAMEWORK} service instance for power device [${UPSS}] which is no longer in config file..." >&2 + $hook_unregisterInstance "$UPSS" + fi + done +} + +upslist_restartSvcs() { + for UPSS in $UPSLIST_SVCS ; do + if common_isFiled "$UPSS" ; then + $hook_restart_drv "$UPSS" + fi + done +} + +nut_driver_enumerator_main() { + ################# MAIN PROGRAM by default + + # Note: do not use the read..._once() here, to ensure that the + # looped daemon sees the whole picture, which can be new every time + upslist_readFile || return $? + #upslist_debug + upslist_readSvcs "before manipulations" + + # Test if global config has changed since last run + RESTART_ALL=no + upssvcconf_checksum_unchanged "" || { echo "`date -u` : Detected changes in global section of '$UPSCONF', will restart all drivers"; RESTART_ALL=yes; } + + # Quickly exit if there's nothing to do; note the lists are pre-sorted + # Otherwise a non-zero exit will be done below + # Note: We implement testing in detail whether section definitions were + # changed since last run, as a first step before checking that name + # lists are still equivalent, because we need to always have the result + # of the "has it changed?" check as a hit-list of something to remove, + # while the check for no new device section definitions is just boolean. + # We can only exit quickly if both there are no changed sections and no + # new or removed sections since last run. + NEW_CHECKSUM="`upslist_checksums_unchanged "$UPSLIST_FILE" "$UPSLIST_SVCS"`" \ + && [ -z "$NEW_CHECKSUM" ] \ + && upslist_equals "$UPSLIST_FILE" "$UPSLIST_SVCS" \ + && if [ -z "$DAEMON_SLEEP" -o "${VERBOSE_LOOP}" = yes ] ; then \ + echo "`date -u` : OK: No changes to reconcile between ${SERVICE_FRAMEWORK} service instances and device configurations in '$UPSCONF'" ; \ + fi \ + && [ "$RESTART_ALL" = no ] && return 0 + + if [ -n "$NEW_CHECKSUM" ]; then + for UPSS in $NEW_CHECKSUM ; do + echo "Dropping old ${SERVICE_FRAMEWORK} service instance ${UPSS} whose section in config file has changed..." >&2 + $hook_unregisterInstance "$UPSS" + done + upslist_readSvcs "after updating for new config section checksums" + fi + + if [ -n "$UPSLIST_SVCS" ]; then + # Drop services that are not in config file (any more?) + upslist_delSvcs + + if [ "$RESTART_ALL" = yes ] && [ "$AUTO_START" = yes ] ; then + # Here restart only existing services; new ones will (try to) + # start soon after creation and upsd is handled below + upslist_restartSvcs + fi + fi + + if [ "$RESTART_ALL" = yes ] ; then + # Save new checksum of global config + $hook_setSavedMD5 "" "`upsconf_getSection_MD5 ""`" + fi + + if [ -n "$UPSLIST_FILE" ]; then + # Add services for sections that are in config file but not yet wrapped + upslist_addSvcs + $hook_refreshSupervizor + upslist_readSvcs "after checking for new config sections to define service instances" + fi + + upslist_readSvcs + if [ -n "$UPSLIST_SVCS" ] ; then + echo "=== The currently defined service instances are:" + echo "$UPSLIST_SVCS" + fi + + if [ -n "$UPSLIST_FILE" ] ; then + echo "=== The currently defined configurations in '$UPSCONF' are:" + echo "$UPSLIST_FILE" + fi + + # We had some changes to the config file; upsd must be made aware + if [ "$AUTO_START" = yes ] ; then + $hook_restart_upsd + fi + + # Return 42 if there was a change applied succesfully + # (but e.g. some services should restart - upsd, maybe upsmon) + UPSLIST_EQ_RES=0 + upslist_equals "$UPSLIST_FILE" "$UPSLIST_SVCS" || UPSLIST_EQ_RES=$? + + # File processing and service startups take a while; + # make sure upsconf did not change while we worked... + # NOTE: Check this at the last moment to minimize + # the chance of still not noticing the change made + # at just the wrong moment. + UPSCONF_CHECKSUM_END="`calc_md5_file "$UPSCONF"`" || true + if [ "$UPSCONF_CHECKSUM_END" != "$UPSCONF_CHECKSUM_START" ] ; then + # NOTE: even if daemonized, the sleep between iterations + # can be configured into an uncomfortably long lag, so + # we should re-sync the system config in any case. + echo "`date -u` : '$UPSCONF' changed while $0 $* was processing its older contents; re-running the script to pick up the late-coming changes" + # Make sure the cycle does not repeat itself due to diffs + # from an ages-old state of the file from when we started. + UPSCONF_CHECKSUM_START="$UPSCONF_CHECKSUM_END" + ( nut_driver_enumerator_main ) ; return $? + # The "main" routine at the end of recursions will + # do REPORT_RESTART_42 logic or the error exit-code + fi + + if [ "$UPSLIST_EQ_RES" = 0 ] ; then + echo "`date -u` : OK: No more changes to reconcile between ${SERVICE_FRAMEWORK} service instances and device configurations in '$UPSCONF'" + [ "${REPORT_RESTART_42-}" = no ] && return 0 || return 42 + fi + return 13 +} + +daemonize() ( + # Support (SIG)HUP == signal code 1 to quickly reconfigure, + # e.g. to request it while the sleep is happening or while + # "main" is processing an earlier change of the file. + RECONFIGURE_ASAP=false + trap 'RECONFIGURE_ASAP=true' 1 + + # Note: this loop would die on errors with config file or + # inability to ensure that it matches the list of services. + # If caller did not `export REPORT_RESTART_42=no` then the + # loop would exit with code 42, and probably trigger restart + # of the service which wraps this daemon do topple others that + # depend on it. + # Note: do not quickly skip the "main" based on full-file + # checksum refresh, to ensure that whatever is configured + # gets applied (e.g. if user disabled some services or they + # died, or some config was not applied due to coding error). + while nut_driver_enumerator_main ; do + if $RECONFIGURE_ASAP ; then + echo "`date -u` : Trapped a SIGHUP during last run of nut_driver_enumerator_main, repeating reconfiguration quickly" >&2 + else + sleep $DAEMON_SLEEP & + trap "kill $! ; echo 'Sleep interrupted, processing configs now!'>&2" 1 + wait $! + fi + RECONFIGURE_ASAP=false + trap 'RECONFIGURE_ASAP=true' 1 + done + exit $? +) + +# Save the checksum of ups.conf as early as possible, +# to test in the end that it is still the same file. +UPSCONF_CHECKSUM_START="`calc_md5_file "$UPSCONF"`" || true + +# By default, update wrapping of devices into services +if [ $# = 0 ]; then + nut_driver_enumerator_main ; exit $? +fi + +if [ $# = 1 ] ; then + [ -n "$DAEMON_SLEEP" ] || DAEMON_SLEEP=60 + # Note: Not all shells have 'case ... ;&' support + case "$1" in + --daemon=*) DAEMON_SLEEP="`echo "$1" | sed 's,^--daemon=,,'`" ;; + esac + case "$1" in + --daemon|--daemon=*) + daemonize & + exit $? + ;; + esac +fi +unset DAEMON_SLEEP + +usage() { + cat << EOF +$0 (no args) + Update wrapping of devices into services +$0 --daemon(=freq) + Update wrapping of devices into services in an infinite loop + Default freq is 60 sec +$0 --reconfigure + Stop and un-register all service instances and recreate them + (e.g. if new dependency template was defined in a new + version of this script and/or NUT package) +$0 --get-service-framework + Print the detected service + management framework in this OS +$0 --list-devices + Print list of devices in NUT config +$0 --list-services + Print list of service instances which wrap registered + NUT devices (full name of service unit) +$0 --list-instances + Print list of service instances which wrap registered + NUT devices (just instance suffix) +$0 --get-service-for-device DEV + Print the full name of service unit which wraps a NUT + device named "DEV" +$0 --get-device-for-service SVC + Print the NUT device name for full or instance-suffix name of + a service unit which wraps it +$0 --list-services-for-devices + Print a TAB-separated list of service units and corresponding + NUT device names which each such unit wraps +$0 --show-configs|--show-all-configs + Show the complete normalized list of device configuration blocks +$0 --show-config DEV +$0 --show-device-config DEV + Show configuration block of the specified NUT device +$0 --show-device-config-value DEV KEY [KEY...] + Show single configuration key value of the specified NUT device + For flags, shows the flag name if present in the section + If several keys or flags are requested, their values are reported + one per line in the same order (including empty lines for missing + values); any missing value yields a non-zero exit code. +EOF +} + +while [ $# -gt 0 ]; do + case "$1" in + --help|-h|-help) usage; exit 0 ;; + --get-service-framework) echo "${SERVICE_FRAMEWORK}" ; exit 0 ;; + --reconfigure) + upslist_readFile_once || exit $? + upslist_readSvcs "before manipulations" + + if [ -n "$UPSLIST_SVCS" ]; then + for UPSS in $UPSLIST_SVCS ; do + echo "Dropping old ${SERVICE_FRAMEWORK} service instance for power device [${UPSS}] to reconfigure the service unit..." >&2 + $hook_unregisterInstance "$UPSS" + done + upslist_readSvcs "after dropping" + fi + + if [ -n "$UPSLIST_FILE" ]; then + upslist_addSvcs + upslist_readSvcs "after checking for new config sections to define service instances" + fi + + # Save new checksum of global config + $hook_setSavedMD5 "" "`upsconf_getSection_MD5 ""`" + + # Service units were manipulated, including saving of checksums; + # refresh the service management daemon if needed + $hook_refreshSupervizor + + if [ -n "$UPSLIST_SVCS" ] ; then + echo "=== The currently defined service instances are:" + echo "$UPSLIST_SVCS" + fi + + if [ -n "$UPSLIST_FILE" ] ; then + echo "=== The currently defined configurations in '$UPSCONF' are:" + echo "$UPSLIST_FILE" + fi + + # We had some changes to the config file; upsd must be made aware + if [ "$AUTO_START" = yes ] ; then + $hook_restart_upsd + fi + + # Return 42 if there was a change applied succesfully + # (but e.g. some services should restart - upsd, maybe upsmon) + UPSLIST_EQ_RES=0 + upslist_equals "$UPSLIST_FILE" "$UPSLIST_SVCS" || UPSLIST_EQ_RES=$? + + # File processing and service startups take a while; + # make sure upsconf did not change while we worked... + # NOTE: Check this at the last moment to minimize + # the chance of still not noticing the change made + # at just the wrong moment. + UPSCONF_CHECKSUM_END="`calc_md5_file "$UPSCONF"`" || true + if [ "$UPSCONF_CHECKSUM_END" != "$UPSCONF_CHECKSUM_START" ] ; then + echo "`date -u` : '$UPSCONF' changed while $0 $* was processing its older contents; re-running the script to pick up the late-coming changes" + $0 ; exit $? + # The "main" routine will do REPORT_RESTART_42 logic too + fi + + if [ "$UPSLIST_EQ_RES" = 0 ] ; then + echo "`date -u` : OK: No more changes to reconcile between ${SERVICE_FRAMEWORK} service instances and device configurations in '$UPSCONF'" + [ "${REPORT_RESTART_42-}" = no ] && exit 0 || exit 42 + fi + + exit 13 + ;; + --list-devices) + upslist_readFile_once && \ + if [ -n "$UPSLIST_FILE" ] ; then + echo "=== The currently defined configurations in '$UPSCONF' are:" >&2 + echo "$UPSLIST_FILE" + exit 0 + fi + echo "No devices detected in '$UPSCONF'" >&2 + exit 1 + ;; + --list-services) + UPSLIST_SVCS_RAW="`$hook_listInstances_raw`" && \ + if [ -n "$UPSLIST_SVCS_RAW" ] ; then + echo "=== The currently defined service units are:" >&2 + echo "$UPSLIST_SVCS_RAW" + exit 0 + fi + echo "No service units detected" >&2 + exit 1 + ;; + --list-instances) + upslist_readSvcs "by user request" && \ + if [ -n "$UPSLIST_SVCS" ] ; then + echo "=== The currently defined service instances are:" >&2 + echo "$UPSLIST_SVCS" + exit 0 + fi + echo "No service instances detected" >&2 + exit 1 + ;; + --get-service-for-device) [ -z "$2" ] && echo "Device name argument required" >&2 && exit 1 + DEV="$2" + upslist_readSvcs "by user request" && [ -n "$UPSLIST_SVCS" ] \ + || { echo "No service instances detected" >&2 ; exit 1; } + UPSLIST_SVCS_RAW="`$hook_listInstances_raw`" && [ -n "$UPSLIST_SVCS_RAW" ] \ + || { echo "No service units detected" >&2 ; exit 1; } + vINST="`$hook_validInstanceName "$DEV"`" + vUNITD="`$hook_validFullUnitName "$DEV"`" + vUNITI="`$hook_validFullUnitName "$vINST"`" + # First pass over simple verbatim names + for INST in $UPSLIST_SVCS ; do + if [ "$INST" = "$DEV" ] ; then + for UNIT in $UPSLIST_SVCS_RAW ; do + if [ "$UNIT" = "$vUNITD" ] ; then + echo "$UNIT" + exit 0 + fi + done + fi + done + for INST in $UPSLIST_SVCS ; do + if [ "$INST" = "$vINST" ] ; then + for UNIT in $UPSLIST_SVCS_RAW ; do + if [ "$UNIT" = "$vUNITI" ] ; then + echo "$UNIT" + exit 0 + fi + done + fi + done + echo "No service instances detected that match device '$2'" >&2 + exit 1 + ;; + --get-device-for-service) [ -z "$2" ] && echo "Service (instance) name argument required" >&2 && exit 1 + # Instance name can be a hash or "native" NUT section name + SVC="`$hook_validInstanceSuffixName "$2"`" + case "$SVC" in + MD5_*) ;; # fall through to the bulk of code + *) upslist_readFile_once || exit $? + echo "$UPSLIST_FILE" | egrep "^$SVC\$" + exit $? + ;; + esac + FINAL_RES=0 + OUT="`"$0" --list-services-for-devices`" && [ -n "$OUT" ] || FINAL_RES=$? + if [ "$FINAL_RES" = 0 ]; then + echo "$OUT" | grep "$SVC" | ( \ + while read _SVC _DEV ; do + _SVC="`$hook_validInstanceSuffixName "${_SVC}"`" || exit + [ "${_SVC}" = "${SVC}" ] && echo "$_DEV" && exit 0 + done ; exit 1 ) && exit 0 + fi + echo "No service instance '$2' was detected that matches a NUT device" >&2 + exit 1 + ;; + --list-services-for-devices) + FINAL_RES=0 + upslist_readFile_once && [ -n "$UPSLIST_FILE" ] \ + || { echo "No devices detected in '$UPSCONF'" >&2 ; exit 1 ; } + upslist_readSvcs "by user request" && [ -n "$UPSLIST_SVCS" ] \ + || { echo "No service instances detected" >&2 ; exit 1; } + UPSLIST_SVCS_RAW="`$hook_listInstances_raw`" && [ -n "$UPSLIST_SVCS_RAW" ] \ + || { echo "No service units detected" >&2 ; exit 1; } + for DEV in $UPSLIST_FILE ; do + vINST="`$hook_validInstanceName "$DEV"`" + vUNITD="`$hook_validFullUnitName "$DEV"`" + vUNITI="`$hook_validFullUnitName "$vINST"`" + # First pass over simple verbatim names + for INST in $UPSLIST_SVCS ; do + if [ "$INST" = "$DEV" ] ; then + for UNIT in $UPSLIST_SVCS_RAW ; do + if [ "$UNIT" = "$vUNITD" ] ; then + printf '%s\t%s\n' "$UNIT" "$DEV" + continue 3 + fi + done + fi + done + for INST in $UPSLIST_SVCS ; do + if [ "$INST" = "$vINST" ] ; then + for UNIT in $UPSLIST_SVCS_RAW ; do + if [ "$UNIT" = "$vUNITI" ] ; then + printf '%s\t%s\n' "$UNIT" "$DEV" + continue 3 + fi + done + fi + done + echo "WARNING: no service instances detected that match device '$DEV'" >&2 + FINAL_RES=1 + done + exit $FINAL_RES + ;; + --show-configs|--show-device-configs|--show-all-configs|--show-all-device-configs) + RES=0 + upslist_readFile_once || RES=$? + [ "$RES" != 0 ] && { echo "ERROR: upslist_readFile_once () failed with code $RES" >&2; exit $RES; } + [ -n "$UPSLIST_FILE" ] \ + || { echo "WARNING: No devices detected in '$UPSCONF'" >&2 ; RES=1 ; } + echo "$UPSCONF_DATA" + exit $RES + ;; + --show-config|--show-device-config) + [ -z "$2" ] && echo "WARNING: Device name argument empty, will show global config" >&2 + DEV="$2" + upsconf_getSection "$DEV" + exit $? + ;; + --show-config-value|--show-device-config-value) + [ -z "$3" ] && echo "At least one configuration key name argument is required" >&2 && exit 1 + [ -z "$2" ] && echo "WARNING: Device name argument empty, will show global config" >&2 + DEV="$2" + shift 2 + upsconf_getValue "$DEV" "$@" + exit $? + ;; + upsconf_debug) # Not public, not in usage() + [ -z "$2" ] && echo "Device name argument required" >&2 && exit 1 + upsconf_debug "$2" + exit $? + ;; + upslist_debug) # Not public, not in usage() + upslist_readFile_once || exit + upslist_debug + exit $? + ;; + *) echo "Unrecognized argument: $1" >&2 ; exit 1 ;; + esac + shift +done diff --git a/scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in b/scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in new file mode 100755 index 0000000..a91ce5e --- /dev/null +++ b/scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in @@ -0,0 +1,1391 @@ +#!/bin/sh +# +# NOTE: This script is intentionally written with portable shell constructs +# with the aim and hope to work in different interpreters, so it is a +# bit dumber and less efficient than could be achieved with the more +# featured shells in the spectrum. +# NOTE ALSO: The configuration parser in this script is not meant to be a +# reference or 100% compliant with what the binary code uses; its aim +# is to just pick out some strings relevant for tracking config changes. +# +# Copyright (C) 2016-2020 Eaton +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +#! \file nut-driver-enumerator.sh(.in) +# \author Jim Klimov +# \brief Enumerate NUT devices for service-unit instance configuration +# \details This script allows to enumerate UPSes in order to produce the +# individual service unit instances for each defined configuration. +# It assumes the user has adequate permissions to inspect and create +# services (e.g. is a root or has proper RBAC profiles to do so). +# It helps service frameworks such as Linux systemd and Solaris SMF. +# When executed, this script looks for all configured ups.conf +# sections and registered service instances, and makes these two +# lists match up. It has also a mode to do this in a loop, to keep +# checking for differences and applying them, on systems where it's +# problematic to trigger it in response to FS event notifications. +# Returns exit codes: +# 0 Sections and services already match up +# 42 Sections and services differed, but now match up - +# now the caller should likely restart some services. +# Note that the drivers' service instances were started or +# stopped as required (by AUTO_START=yes) - but maybe the +# upsd or upsmon services should restart. If you pass envvar +# REPORT_RESTART_42=no then this codepath would return 0. +# In default mode, such non-null reconfiguration should cause +# the nut-driver-enumerator service to restart and this would +# propagate to other NUT services that depend on it. +# 13 Sections and services differed, and still do not match up +# 1 Bad inputs, e.g. unrecognized service management framework +# 2 Absent or unreadable ups.conf file +# + +# NOTE: Currently found caveats that might be solved later but require +# considerable effort: +# * Solaris SMF constrains the syntax of valid strings for instance names +# (e.g. not starting with a digit, no period chars) which blocks creation +# of some UPS driver instances. This might be worked around by hashing +# the device name e.g. to base64 (and un-hashing instance name when calling +# upsdrvctl), but is not quite user-friendly. Also can store device name +# in a service attribute while mangling the instance name to a valid subset. +# Comparisons (if devices are already wrapped) becomes more complicated in +# the script in either case, as well as in the service startup method. +# ** The `+` `/` `=` characters from base64 are also invalid for SMF instance +# name, but the first two can be sed'ed to `-` `_` and back, for example. +# Some prefix word is also needed (avoid starting with a digit). +# The trailing padding `=` can be dropped, and added until we get a +# non-empty decode. Conversions can be done by +# `echo "$string" | openssl base64 -e|-d` +# * Dummy-UPS services that "proxy" another locally defined section are +# essentially a circular dependency for upsd. While the system might +# start-up lacking a driver, there should be some timer to re-enable +# failed not-disabled drivers (would be useful in any case though). + +# Directory where NUT configs are located, e.g. /etc/nut or /etc/ups +# Set at package configuration, compiled into daemons and drivers +prefix="@prefix@" +[ -n "${NUT_CONFPATH-}" ] || NUT_CONFPATH="@sysconfdir@" +# Technically this should be a distribution-dependent value configured +# during package build. But everyone has it the same from systemd defaults: +[ -n "${SYSTEMD_CONFPATH-}" ] || SYSTEMD_CONFPATH="/etc/systemd/system" + +if [ -n "$ZSH_VERSION" ]; then + ### Problem: loops like `for UPS in $UPSLIST` do not separate + ### the UPSLIST into many tokens but use it as one string. + echo "FATAL: zsh is not supported in this script" >&2 + exit 1 +# setopt noglob +# setopt +F +# IFS="`printf ' \t\r\n'`" ; export IFS +fi + +if set | egrep '^(shell|version|t?csh)' | egrep 't?csh' >/dev/null ; then + echo "FATAL: csh or tcsh is not supported in this script" >&2 + exit 1 +fi + +# Third-party services to depend on (can be overridden by config file) +### Note that for systemd+udev integration, it may be better to set up +### triggers in udev, see e.g. +### http://stackoverflow.com/questions/18463755/linux-start-daemon-on-connected-usb-serial-dongle +### Also can tune whether a driver "Wants" another service (would consider +### ordering if that one is enabled, but live if it is disabled), or if it +### "Requires" that (would cause that to start). +DEPSVC_USB_SYSTEMD="systemd-udev.service systemd-udev-settle.service" +DEPREQ_USB_SYSTEMD="Wants" +DEPSVC_NET_FULL_SYSTEMD="network-online.target systemd-resolved.service ifplugd.service" +DEPREQ_NET_FULL_SYSTEMD="Wants" +DEPSVC_NET_LOCAL_SYSTEMD="network.target" +DEPREQ_NET_LOCAL_SYSTEMD="Wants" +SVCNAME_SYSTEMD="nut-driver" + +# Some or all of these FMRIs may be related to dynamically changing hardware +# require_all) ;; # All cited services are running (online or degraded) +# require_any) ;; # At least one of the cited services is running +# optional_all) ;; # (All) cited services are running or would not run +# # without administrative action (disabled, maintenance, +# # not present, or are waiting for dependencies which do +# # not start without administrative action). +DEPSVC_USB_SMF="svc:/system/hotplug:default svc:/system/dbus:default svc:/system/hal:default svc:/milestone/devices:default" +DEPREQ_USB_SMF="optional_all" +# By default there are several physical network FMRIs shipped and at most +# only one is enabled on a particular system (e.g. :default or :nwam) +DEPSVC_NET_FULL_SMF="svc:/network/physical svc:/milestone/name-services" +DEPREQ_NET_FULL_SMF="optional_all" +DEPSVC_NET_LOCAL_SMF="svc:/network/loopback:default" +DEPREQ_NET_LOCAL_SMF="optional_all" +SVCNAME_SMF="svc:/system/power/nut-driver" + +[ -z "${NUT_DRIVER_ENUMERATOR_CONF-}" ] && \ + NUT_DRIVER_ENUMERATOR_CONF="${NUT_CONFPATH}/nut-driver-enumerator.conf" + +[ -s "${NUT_DRIVER_ENUMERATOR_CONF}" ] && \ + echo "Sourcing config file: ${NUT_DRIVER_ENUMERATOR_CONF}" && \ + . "${NUT_DRIVER_ENUMERATOR_CONF}" + +[ -z "${UPSCONF-}" ] && \ + UPSCONF="${NUT_CONFPATH}/ups.conf" + +# Start a freshly-registered unit? +[ -z "${AUTO_START-}" ] && AUTO_START=yes + +# We avoid regex '\t' which gets misinterpreted by some tools +TABCHAR="`printf '\t'`" || TABCHAR=' ' + +if [ -z "${SERVICE_FRAMEWORK-}" ] ; then + [ -x /usr/sbin/svcadm ] && [ -x /usr/sbin/svccfg ] && [ -x /usr/bin/svcs ] && [ -x /usr/bin/svcprop ] && \ + SERVICE_FRAMEWORK="smf" + [ -z "${SERVICE_FRAMEWORK-}" ] && \ + [ -x /bin/systemctl ] && \ + SERVICE_FRAMEWORK="systemd" +fi + +# Optionally use Coreutils timeout to limit the +# (potentially hanging) calls to systemd tools... +# Should not hurt with SMF too, if it ever misbehaves. +if [ -z "${TIMEOUT_CMD+x}" ]; then + # Envvar not set at all (set but empty is okay, caller wants that then) + TIMEOUT_CMD="" + TIMEOUT_ARGS="" + if which timeout 2>/dev/null >/dev/null ; then + # Systemd default timeout for unit start/stop + TIMEOUT_CMD="timeout" + TIMEOUT_ARGS="90s" + fi +fi + +# Cache needed bits of ups.conf to speed up later parsing. Note that these +# data are needed for most operations, and populated by upslist_readFile() +UPSCONF_DATA="" +# Subset of normalized data above that only has sections, drivers and ports +UPSCONF_DATA_SDP="" + +# List of configured UPSes in the config-file +UPSLIST_FILE="" +# List of configured service instances for UPS drivers +UPSLIST_SVCS="" + +# Framework-specific implementations are generally hooked here: +hook_registerInstance="" +hook_unregisterInstance="" +hook_refreshSupervizor="" +hook_listInstances="" +hook_listInstances_raw="" +hook_validInstanceName="" +hook_validFullUnitName="" +hook_validInstanceSuffixName="" +hook_getSavedMD5="" +hook_setSavedMD5="" +hook_restart_upsd="" +hook_restart_drv="" + +case "${SERVICE_FRAMEWORK-}" in + smf) + hook_registerInstance="smf_registerInstance" + hook_unregisterInstance="smf_unregisterInstance" + hook_refreshSupervizor="smf_refreshSupervizor" + hook_listInstances="smf_listInstances" + hook_listInstances_raw="smf_listInstances_raw" + hook_validInstanceName="smf_validInstanceName" + hook_validFullUnitName="smf_validFullUnitName" + hook_validInstanceSuffixName="smf_validInstanceSuffixName" + hook_getSavedMD5="smf_getSavedMD5" + hook_setSavedMD5="smf_setSavedMD5" + hook_restart_upsd="smf_restart_upsd" + hook_restart_drv="smf_restart_drv" + ;; + systemd) + hook_registerInstance="systemd_registerInstance" + hook_unregisterInstance="systemd_unregisterInstance" + hook_refreshSupervizor="systemd_refreshSupervizor" + hook_listInstances="systemd_listInstances" + hook_listInstances_raw="systemd_listInstances_raw" + hook_validInstanceName="systemd_validInstanceName" + hook_validFullUnitName="systemd_validFullUnitName" + hook_validInstanceSuffixName="systemd_validInstanceSuffixName" + hook_getSavedMD5="systemd_getSavedMD5" + hook_setSavedMD5="systemd_setSavedMD5" + hook_restart_upsd="systemd_restart_upsd" + hook_restart_drv="systemd_restart_drv" + ;; + selftest) + hook_registerInstance="selftest_NOOP" + hook_unregisterInstance="selftest_NOOP" + hook_refreshSupervizor="selftest_NOOP" + hook_listInstances="selftest_NOOP" + hook_listInstances_raw="selftest_NOOP" + hook_validInstanceName="selftest_NOOP" + hook_validFullUnitName="selftest_NOOP" + hook_validInstanceSuffixName="selftest_NOOP" + hook_getSavedMD5="selftest_NOOP" + hook_setSavedMD5="selftest_NOOP" + hook_restart_upsd="selftest_NOOP" + hook_restart_drv="selftest_NOOP" + ;; + "") + echo "Error detecting the service-management framework on this OS" >&2 + exit 1 + ;; + *) + echo "Error: User provided an unknown service-management framework '$SERVICE_FRAMEWORK'" >&2 + exit 1 + ;; +esac + +selftest_NOOP() { + echo "NO-OP: Self-testing context does not do systems configuration" >&2 + return 0 +} + +common_isFiled() { + [ -n "$UPSLIST_FILE" ] && \ + for UPSF in $UPSLIST_FILE ; do + [ "$1" = "$UPSF" ] && return 0 + [ "`$hook_validInstanceName "$UPSF"`" = "$1" ] && return 0 + done + return 1 +} + +common_isRegistered() { + [ -n "$UPSLIST_SVCS" ] && \ + for UPSS in $UPSLIST_SVCS ; do + [ "$1" = "$UPSS" ] && return 0 + [ "`$hook_validInstanceName "$1"`" = "$UPSS" ] && return 0 + done + return 1 +} + +upslist_equals() { + # Compare pre-sorted list of DEVICES ($1) and SVCINSTs ($2) including + # the possible mangling for service names. Return 0 if lists describe + # exactly same set of devices and their services. + # Note: This logic only checks the names, not the contents of device + # sections, so re-definitions of an existing device configuration + # would not trigger a service restart by itself. Such deeper check + # belongs in a different routine, see upssvcconf_checksum_unchanged(). + + # Trivial case 0: one string is empty, another is not + # Note: `echo '' | wc -l` == "1" not "0"! + [ -n "$1" -a -z "$2" ] && return 1 + [ -z "$1" -a -n "$2" ] && return 1 + + # Trivial case 1: equal strings + [ "$1" = "$2" ] && return 0 + # Trivial case 2: different amount of entries + [ "`echo "$1" | wc -l`" = "`echo "$2" | wc -l`" ] || return $? + + _TMP_DEV_SVC="" + for _DEV in $1 ; do + DEVINST="`$hook_validInstanceName "$_DEV"`" + for _SVC in $2 ; do + [ "$_DEV" = "$_SVC" ] \ + || [ "$DEVINST" = "$_SVC" ] \ + && { [ -z "$_TMP_DEV_SVC" ] \ + && _TMP_DEV_SVC="$_DEV = $_SVC" \ + || _TMP_DEV_SVC="$_TMP_DEV_SVC +$_DEV = $_SVC" ; } + done + done + + # Input was not empty; did anything in output fit? + [ -z "$_TMP_DEV_SVC" ] && return 1 + + # Exit code : is the built mapping as long as the source list(s)? + [ "`echo "$1" | wc -l`" = "`echo "$_TMP_DEV_SVC" | wc -l`" ] +} + +upssvcconf_checksum_unchanged() { + # $1 = dev, $2 = svc + # compare checksums of the configuration section from the file and the + # stashed configuration in a service instance (if any). + # FIXME : optimize by caching, we likely have quite a few requests + [ "`upsconf_getSection_MD5 "$1"`" = "`$hook_getSavedMD5 "$2"`" ] +} + +upslist_checksums_unchanged() { + # For each device and its corresponding unit, compare checksums of the + # configuration section from the file and the stashed configuration in + # a service instance. Prints a list of mismatching service names that + # should get reconfigured. + [ -z "$1" -o -z "$2" ] && return 1 + + _TMP_SVC="" + for _DEV in $1 ; do + DEVINST="`$hook_validInstanceName "$_DEV"`" + for _SVC in $2 ; do + if [ "$_DEV" = "$_SVC" ] \ + || [ "$DEVINST" = "$_SVC" ] \ + ; then + upssvcconf_checksum_unchanged "$_DEV" "$_SVC" || \ + { [ -z "$_TMP_SVC" ] \ + && _TMP_SVC="$_SVC" \ + || _TMP_SVC="$_TMP_SVC +$_SVC" ; } + fi + done + done + [ -z "$_TMP_SVC" ] && return 0 + echo "$_TMP_SVC" + return 1 +} + +upsconf_getSection_content() { + # "$1" = name of ups.conf section to display in whole, from whatever + # comes on stdin (file or a pre-made normalized variable) + # empty "$1" means the global config (before any sections) + # + # NOTE (TODO?): This routine finds the one NUT device section, prints it + # and returns when the section is over. It currently does not cover (in + # a way allowing to do it efficiently) selection of several sections, + # or storing each section content in some array or dynamic variables + # (as would be better fit for portable shells) to later address them + # quickly without re-parsing the file or big envvar many times. + # + + CURR_SECTION="" + SECTION_CONTENT="" + RES=1 + [ -n "$1" ] || RES=0 + while read LINE ; do + case "$LINE" in + \["$1"\]) + if [ "$RES" = 0 ]; then + # We have already displayed a section, here is a new one, + # and this routine only displays one (TODO: toggle?) + break + fi + SECTION_CONTENT="$LINE" + CURR_SECTION="$1" + RES=0 + continue + ;; + \[*\ *\]|\[*"$TABCHAR"*\]) + # Note that section-name brackets should contain a single token + # Fall through to add the line to contents of existing section + ;; + \[*\]) + [ "$CURR_SECTION" = "$1" ] && break + # Use a value that can not be a section name here: + CURR_SECTION="[]" + continue + ;; + "") continue ;; + *) ;; # Fall through to add the line to contents of existing section + esac + if [ "$CURR_SECTION" = "$1" ]; then + if [ -n "$SECTION_CONTENT" ]; then + SECTION_CONTENT="$SECTION_CONTENT +$LINE" + else + SECTION_CONTENT="$LINE" + fi + fi + done + + if [ -n "$SECTION_CONTENT" ]; then + echo "$SECTION_CONTENT" + fi + + [ "$RES" = 0 ] || echo "ERROR: Section [$1] was not found in the '$UPSCONF' file" >&2 + return $RES +} + +upsconf_getSection() { + # Use the whole output of normalization parser + upslist_normalizeFile_once || return # Propagate errors upwards + upsconf_getSection_content "$@" << EOF +${UPSCONF_DATA} +EOF +} + +upsconf_getSection_MD5() { + calc_md5 "`upsconf_getSection "$@"`" +} + +upsconf_getSection_SDP() { + # Use the section-driver-port subset + upslist_normalizeFile_once || return # Propagate errors upwards + upsconf_getSection_content "$@" << EOF +${UPSCONF_DATA_SDP} +EOF +} + +upsconf_getValue() { + # "$1" = name of ups.conf section, may be empty for global config + # "$2..$N" = name of config key; we will echo its value +### [ -n "$1" ] || return $? + [ -n "$2" ] || return $? + [ -n "$GETSECTION" ] || GETSECTION="upsconf_getSection" + CURR_SECTION="" # Gets set by a GETSECTION implementation + RES=0 + + # Note: Primary aim of this egrep is to pick either assignments or flags + # As a by-product it can be used to test if a particular value is set ;) + SECTION_CONTENT="`$GETSECTION "$1"`" || return + shift + KEYS="$*" + + while [ "$#" -gt 0 ] ; do + RES_L=0 + VALUE="" + + LINE="`echo "$SECTION_CONTENT" | egrep '(^'"$1"'=|^'"$1"'$)'`" \ + && VALUE="$(echo "$LINE" | sed -e "s,^$1=,," -e 's,^\"\(.*\)\"$,\1,' -e "s,^'\(.*\)'$,\1,")" \ + || RES_L=$? + + [ "$RES_L" = 0 ] || { RES="$RES_L" ; echo "ERROR: Section [$CURR_SECTION] or key '$1' in it was not found in the '$UPSCONF' file" >&2 ; } + + echo "$VALUE" + shift + done + + [ "$RES" = 0 ] || echo "ERROR: Section [$CURR_SECTION] or key(s) '$KEYS' in it was not found in the '$UPSCONF' file" >&2 + return $RES +} + +upsconf_getDriver() { + # "$1" = name of ups.conf section; return (echo) the driver name used there + # In the context this function is used, UPSCONF exists and section is there + GETSECTION="upsconf_getSection_SDP" upsconf_getValue "$1" "driver" + return $? +} + +upsconf_getPort() { + # "$1" = name of ups.conf section; return (echo) the "port" name used there + # In the context this function is used, UPSCONF exists and section is there + GETSECTION="upsconf_getSection_SDP" upsconf_getValue "$1" "port" + return $? +} + +upsconf_getDriverMedia() { + # "$1" = name of ups.conf section; return (echo) name and type of driver as + # needed for dependency evaluation (what services we must depend on for this + # unit), newline-separated (drvnametype). Empty type for unclassified + # results, assuming no known special dependencies (note that depending on + # particular system's physics, both serial and network media may need USB). + CURR_DRV="`upsconf_getDriver "$1"`" || return $? + case "$CURR_DRV" in + *netxml*|*snmp*|*ipmi*|*powerman*|*-mib*|*avahi*|*apcupsd*) + printf '%s\n%s\n' "$CURR_DRV" "network" ; return ;; + *usb*) + printf '%s\n%s\n' "$CURR_DRV" "usb" ; return ;; + nutdrv_qx) # May be direct serial or USB + CURR_PORT="`upsconf_getPort "$1"`" || CURR_PORT="" + case "$CURR_PORT" in + auto|/dev/*usb*|/dev/*hid*) + printf '%s\n%s\n' "$CURR_DRV" "usb" ; return ;; + /dev/*) + # See drivers/nutdrv_qx.c :: upsdrv_initups() for a list + if [ -n "`upsconf_getValue "$1" 'subdriver' 'vendorid' 'productid' 'vendor' 'product' 'serial' 'bus' 'langid_fix'`" ] \ + ; then + printf '%s\n%s\n' "$CURR_DRV" "usb" ; return + else + printf '%s\n%s\n' "$CURR_DRV" "serial" ; return + fi + ;; + *) + printf '%s\n%s\n' "$CURR_DRV" "" ; return ;; + esac + ;; + *dummy*|*clone*) # May be networked (proxy to remote NUT) + CURR_PORT="`upsconf_getPort "$1"`" || CURR_PORT="" + case "$CURR_PORT" in + *@localhost|*@|*@127.0.0.1|*@::1) + printf '%s\n%s\n' "$CURR_DRV" "network-localhost" ; return ;; + *@*) + printf '%s\n%s\n' "$CURR_DRV" "network" ; return ;; + *) + printf '%s\n%s\n' "$CURR_DRV" "" ; return ;; + esac + ;; + *) printf '%s\n%s\n' "$CURR_DRV" "" ; return ;; + esac +} + +upsconf_getMedia() { + _DRVMED="`upsconf_getDriverMedia "$1"`" || return + echo "$_DRVMED" | tail -n +2 + return 0 +} + +upsconf_debug() { + _DRV="`upsconf_getDriver "$1"`" + _PRT="`upsconf_getPort "$1"`" + _MED="`upsconf_getMedia "$1"`" + _MD5="`upsconf_getSection_MD5 "$1"`" + NAME_MD5="`calc_md5 "$1"`" + echo "INST: ${NAME_MD5}~[$1]: DRV='$_DRV' PORT='$_PRT' MEDIA='$_MED' SECTIONMD5='$_MD5'" +} + +calc_md5() { + # Tries several ways to produce an MD5 of the "$1" argument + _MD5="`echo "$1" | md5sum 2>/dev/null | awk '{print $1}'`" && [ -n "$_MD5" ] || \ + { _MD5="`echo "$1" | openssl dgst -md5 2>/dev/null | awk '{print $NF}'`" && [ -n "$_MD5" ]; } || \ + return 1 + + echo "$_MD5" +} + +calc_md5_file() { + # Tries several ways to produce an MD5 of the file named by "$1" argument + [ -s "$1" ] || return 2 + + _MD5="`md5sum 2>/dev/null < "$1" | awk '{print $1}'`" && [ -n "$_MD5" ] || \ + { _MD5="`openssl dgst -md5 2>/dev/null < "$1" | awk '{print $NF}'`" && [ -n "$_MD5" ]; } || \ + return 1 + + echo "$_MD5" +} + +smf_validFullUnitName() { + case "$1" in + *:*) echo "$1" ;; + *) echo "$SVCNAME_SMF:$1" ;; + esac +} +smf_validInstanceName() { + echo "MD5_`calc_md5 "$1"`" +} +smf_validInstanceSuffixName() { + case "$1" in + *:*) echo "$1" | sed 's,^.*:\([^:]*\)$,\1,' ;; + *) echo "$1" ;; + esac +} +smf_registerInstance() { + DEVICE="$1" + SVCINST="$1" + /usr/sbin/svccfg -s nut-driver add "$DEVICE" || \ + { SVCINST="`smf_validInstanceName "$1"`" && \ + /usr/sbin/svccfg -s nut-driver add "$SVCINST" || return ; } + echo "Added instance: 'nut-driver:$SVCINST' for NUT configuration section '$DEVICE'" >&2 + + DEPSVC="" + DEPREQ="" + _MED="`upsconf_getMedia "$DEVICE"`" + case "$_MED" in + usb) + DEPSVC="$DEPSVC_USB_SMF" + DEPREQ="$DEPREQ_USB_SMF" ;; + network-localhost) + DEPSVC="$DEPSVC_NET_LOCAL_SMF" + DEPREQ="$DEPREQ_NET_LOCAL_SMF" ;; + network) + DEPSVC="$DEPSVC_NET_FULL_SMF" + DEPREQ="$DEPREQ_NET_FULL_SMF" ;; + serial) ;; + '') ;; + *) echo "WARNING: Unexpected NUT media type ignored: '$_MED'" >&2 ;; + esac + + TARGET_FMRI="nut-driver:$SVCINST" + if [ -n "$DEPSVC" ]; then + [ -n "$DEPREQ" ] || DEPREQ="optional_all" + echo "Adding '$DEPREQ' dependency for '$SVCINST' on '$DEPSVC'..." + + DEPPG="nut-driver-enumerator-generated" + RESTARTON="refresh" + /usr/sbin/svccfg -s "$TARGET_FMRI" addpg "$DEPPG" dependency && \ + /usr/sbin/svccfg -s "$TARGET_FMRI" setprop "$DEPPG"/grouping = astring: "$DEPREQ" && \ + /usr/sbin/svccfg -s "$TARGET_FMRI" setprop "$DEPPG"/restart_on = astring: "$RESTARTON" && \ + /usr/sbin/svccfg -s "$TARGET_FMRI" setprop "$DEPPG"/type = astring: service && \ + /usr/sbin/svccfg -s "$TARGET_FMRI" setprop "$DEPPG"/entities = fmri: "($DEPSVC)" && \ + echo "OK" || echo "FAILED to define the dependency" >&2 + fi + + smf_setSavedMD5 "$SVCINST" "`upsconf_getSection_MD5 "$DEVICE"`" + + /usr/sbin/svcadm refresh "${TARGET_FMRI}" || return + if [ "$AUTO_START" = yes ] ; then + /usr/sbin/svcadm clear "${TARGET_FMRI}" 2>/dev/null || true + /usr/sbin/svcadm enable "${TARGET_FMRI}" || return + echo "Started instance: 'nut-driver:$SVCINST' for NUT configuration section '$DEVICE'" >&2 + fi +} +smf_unregisterInstance() { + echo "Removing instance: 'nut-driver:$1' ..." >&2 + /usr/sbin/svcadm disable -ts 'nut-driver:'"$1" || false + /usr/sbin/svccfg -s nut-driver delete "$1" +} +smf_refreshSupervizor() { + : +} +smf_listInstances_raw() { + # Newer versions have pattern matching; older SMF might not have this luxury + /usr/bin/svcs -a -H -o fmri | egrep '/nut-driver:' +} +smf_listInstances() { + smf_listInstances_raw | sed 's/^.*://' | sort -n +} +smf_getSavedMD5() { + # Query service instance $1 + PG="nut-driver-enumerator-generated-checksum" + PROP="SECTION_CHECKSUM" + + if [ -n "$1" ]; then + TARGET_FMRI="nut-driver:$1" + else + # Global section + TARGET_FMRI="nut-driver" + PROP="SECTION_CHECKSUM_GLOBAL" + fi + + # Note: lookups for GLOBAL cause each service instance to show up + /usr/bin/svcprop -p "$PG/$PROP" "$TARGET_FMRI" | head -1 | awk '{print $NF}' +} +smf_setSavedMD5() { + # Save checksum value $2 into service instance $1 + PG="nut-driver-enumerator-generated-checksum" + PROP="SECTION_CHECKSUM" + + if [ -n "$1" ]; then + TARGET_FMRI="nut-driver:$1" + else + # Global section + TARGET_FMRI="nut-driver" + PROP="SECTION_CHECKSUM_GLOBAL" + fi + + /usr/sbin/svccfg -s "$TARGET_FMRI" delprop "$PG" || true + /usr/sbin/svccfg -s "$TARGET_FMRI" addpg "$PG" application && \ + /usr/sbin/svccfg -s "$TARGET_FMRI" setprop "$PG/$PROP" = astring: "$2" + [ $? = 0 ] && echo "OK" || { echo "FAILED to stash the checksum">&2 ; return 1 ; } + /usr/sbin/svcadm refresh "${TARGET_FMRI}" || return +} +smf_restart_upsd() { + echo "Restarting NUT data server to make sure it knows new configuration..." + /usr/sbin/svcadm enable "nut-server" 2>/dev/null + /usr/sbin/svcadm clear "nut-server" 2>/dev/null + /usr/sbin/svcadm refresh "nut-server" || \ + /usr/sbin/svcadm restart "nut-server" +} +smf_restart_drv() { + echo "Restarting NUT driver instance '$1' to make sure it knows new configuration..." + /usr/sbin/svcadm enable "nut-driver:$1" 2>/dev/null + /usr/sbin/svcadm clear "nut-driver:$1" 2>/dev/null + /usr/sbin/svcadm refresh "nut-driver:$1" || \ + /usr/sbin/svcadm restart "nut-driver:$1" +} + +systemd_validFullUnitName() { + case "$1" in + *@*.*) echo "$1" ;; + *@*) echo "$1.service" ;; + *) echo "$SVCNAME_SYSTEMD@$1.service" ;; + esac +} +systemd_validInstanceName() { + echo "MD5_`calc_md5 "$1"`" +} +systemd_validInstanceSuffixName() { + echo "$1" | sed -e 's,^.*@,,' -e 's,\.service$,,' +} +systemd_registerInstance() { + # Instance is registered by device section name; ultimate name in systemd may differ + DEVICE="$1" + SVCINST="$1" + /bin/systemctl enable 'nut-driver@'"$DEVICE".service || \ + { SVCINST="`systemd_validInstanceName "$1"`" && \ + /bin/systemctl enable 'nut-driver@'"$SVCINST".service || return ; } + echo "Enabled instance: 'nut-driver@$SVCINST' for NUT configuration section '$DEVICE'" >&2 + + DEPSVC="" + DEPREQ="" + _MED="`upsconf_getMedia "$DEVICE"`" + case "$_MED" in + usb) + DEPSVC="$DEPSVC_USB_SYSTEMD" + DEPREQ="$DEPREQ_USB_SYSTEMD" ;; + network-localhost) + DEPSVC="$DEPSVC_NET_LOCAL_SYSTEMD" + DEPREQ="$DEPREQ_NET_LOCAL_SYSTEMD" ;; + network) + DEPSVC="$DEPSVC_NET_FULL_SYSTEMD" + DEPREQ="$DEPREQ_NET_FULL_SYSTEMD" ;; + serial) ;; + '') ;; + *) echo "WARNING: Unexpected NUT media type ignored: '$_MED'" >&2 ;; + esac + if [ -n "$DEPSVC" ]; then + [ -n "$DEPREQ" ] || DEPREQ="#Wants" + echo "Adding '$DEPREQ'+After dependency for '$SVCINST' on '$DEPSVC'..." + mkdir -p "${SYSTEMD_CONFPATH}/nut-driver@$SVCINST.service.d" && \ + cat > "${SYSTEMD_CONFPATH}/nut-driver@$SVCINST.service.d/nut-driver-enumerator-generated.conf" <&2 + fi + + systemd_setSavedMD5 "$SVCINST" "`upsconf_getSection_MD5 "$DEVICE"`" + + if [ "$AUTO_START" = yes ] ; then + systemd_refreshSupervizor || echo "WARNING: Somehow managed to fail systemd_refreshSupervizor()" >&2 + $TIMEOUT_CMD $TIMEOUT_ARGS /bin/systemctl start --no-block 'nut-driver@'"$SVCINST".service || return + echo "Started instance: 'nut-driver@$SVCINST' for NUT configuration section '$DEVICE'" >&2 + fi +} +systemd_unregisterInstance() { + echo "Removing instance: 'nut-driver@$1' ..." >&2 + $TIMEOUT_CMD $TIMEOUT_ARGS /bin/systemctl stop 'nut-driver@'"$1".service || \ + $TIMEOUT_CMD $TIMEOUT_ARGS /bin/systemctl stop 'nut-driver@'"$1".service || \ + $TIMEOUT_CMD $TIMEOUT_ARGS /bin/systemctl stop 'nut-driver@'"$1".service || false + + /bin/systemctl disable 'nut-driver@'"$1".service + rm -rf "${SYSTEMD_CONFPATH}/nut-driver@$1.service.d" + /bin/systemctl reset-failed 'nut-driver@'"$1".service +} +systemd_refreshSupervizor() { + /bin/systemctl daemon-reload +} +systemd_listInstances_raw() { + /bin/systemctl show 'nut-driver@*' -p Id | egrep '=nut-driver' | sed 's,^Id=,,' +} +systemd_listInstances() { + systemd_listInstances_raw | sed -e 's/^.*@//' -e 's/\.service$//' | sort -n +} +systemd_getSavedMD5() { + # Query service instance $1 or global section + PROP="SECTION_CHECKSUM" + [ -n "$1" ] || PROP="SECTION_CHECKSUM_GLOBAL" + [ -s "${SYSTEMD_CONFPATH}/nut-driver@$1.service.d/nut-driver-enumerator-generated-checksum.conf" ] \ + && grep "Environment='$PROP=" "${SYSTEMD_CONFPATH}/nut-driver@$1.service.d/nut-driver-enumerator-generated-checksum.conf" | sed -e "s,^Environment='$PROP=,," -e "s,'\$,," \ + || { echo "Did not find '${SYSTEMD_CONFPATH}/nut-driver@$1.service.d/nut-driver-enumerator-generated-checksum.conf' with a $PROP" ; return 1; } +} +systemd_setSavedMD5() { + # Save checksum value $2 into service instance $1 + PROP="SECTION_CHECKSUM" + [ -n "$1" ] || PROP="SECTION_CHECKSUM_GLOBAL" + mkdir -p "${SYSTEMD_CONFPATH}/nut-driver@$1.service.d" && \ + cat > "${SYSTEMD_CONFPATH}/nut-driver@$1.service.d/nut-driver-enumerator-generated-checksum.conf" << EOF +[Service] +Environment='$PROP=$2' +EOF + [ $? = 0 ] && echo "OK" || { echo "FAILED to stash the checksum">&2 ; return 1 ; } +} +systemd_restart_upsd() { + # Do not restart/reload if not already running + case "`/bin/systemctl is-active "nut-server"`" in + active|unknown) ;; # unknown meant "starting" in our testing... + failed) echo "Note: nut-server unit was 'failed' - not disabled by user, so (re)starting it (probably had no config initially)" >&2 ;; + *) return 0 ;; + esac + + echo "Restarting NUT data server to make sure it knows new configuration..." + # Note: reload is a better way to go about this, so the + # data service is not interrupted by re-initialization + # of the daemon. But systemd/systemctl sometimes stalls... + + $TIMEOUT_CMD $TIMEOUT_ARGS /bin/systemctl reload-or-restart "nut-server" || \ + $TIMEOUT_CMD $TIMEOUT_ARGS /bin/systemctl restart "nut-server" +} + +systemd_restart_drv() { + # Do not restart/reload if not already running + case "`/bin/systemctl is-active "nut-driver@$1"`" in + active|unknown) ;; + *) return 0 ;; + esac + + echo "Restarting NUT driver instance '$1' to make sure it knows new configuration..." + + # Full restart, e.g. in case we changed the user= in configs + $TIMEOUT_CMD $TIMEOUT_ARGS /bin/systemctl restart "nut-driver@$1" +} + +upslist_normalizeFile_filter() { + # See upslist_normalizeFile() detailed comments below; this routine + # is a pipe worker to prepare the text into a simpler expected form. + + # Pick the lines which contain a bracket or assignment character, + # or a single token (certain keywords come as just NUT "flags"), + # trim leading and trailing whitespace, comment-only lines, and in + # assignment lines trim the spaces around equality character and + # quoting characters around assignment of values without whitespaces. + # Any whitespace characters around a section name (single token that + # starts the line and is enclosed in brackets) and a trailing comment + # are dropped. Note that brackets with spaces inside, and brackets + # that do not start the non-whitespace payload of the line, are not + # sections. + egrep -v '(^$|^#)' | \ + sed -e 's,^['"$TABCHAR"'\ ]*,,' \ + -e 's,^\#.*$,,' \ + -e 's,['"$TABCHAR"'\ ]*$,,' \ + -e 's,^\([^=\ '"$TABCHAR"']*\)['"$TABCHAR"'\ ]*=['"$TABCHAR"'\ ]*,\1=,g' \ + -e 's,=\"\([^\ '"$TABCHAR"']*\)\"$,=\1,' \ + -e 's,^\(\[[^]'"$TABCHAR"'\ ]*\]\)['"$TABCHAR"'\ ]*\(#.*\)*$,\1,' \ + | egrep -v '^$' \ + | egrep '([\[\=]|^[^ '"$TABCHAR"']*$|^[^ '"$TABCHAR"']*[ '"$TABCHAR"']*\#.*$)' +} + +upslist_normalizeFile() { + # Read the ups.conf file and find all defined sections (names of + # configuration blocks for drivers that connect to a certain device + # using specified protocol and media); normalize section contents + # as detailed below, to simplify subsequent parsing and comparison. + + # File contents + UPSCONF_DATA="" + UPSCONF_DATA_SDP="" + if [ -n "$UPSCONF" ] && [ -f "$UPSCONF" ] && [ -r "$UPSCONF" ]; then + [ ! -s "$UPSCONF" ] \ + && echo "WARNING: The '$UPSCONF' file exists but is empty" >&2 \ + && return 0 + # Ok to continue - we may end up removing all instances + else + echo "FATAL: The '$UPSCONF' file does not exist or is not readable" >&2 + return 2 + fi + + # Store a normalized version of NUT configuration file contents. + # Also use a SDP subset with just section, driver and port info + # for faster parsing when determining driver-required media etc. + UPSCONF_DATA="$(upslist_normalizeFile_filter < "$UPSCONF")" \ + && [ -n "$UPSCONF_DATA" ] \ + && UPSCONF_DATA_SDP="`egrep '^(\[.*\]|driver=|port=)' << EOF +$UPSCONF_DATA +EOF`" \ + || { echo "Error reading the '$UPSCONF' file or it does not declare any device configurations: nothing left after normalization" >&2 + UPSCONF_DATA="" + UPSCONF_DATA_SDP="" + } +} + +upslist_normalizeFile_once() { + # Wrapper that ensures that the parsing is only done once + # (will re-parse if there were no devices listed on the + # first time, though) + [ -z "$UPSCONF_DATA" ] && [ -z "$UPSCONF_DATA_SDP" ] || return 0 + upslist_normalizeFile +} + +upslist_readFile() { + # Use the routine above (unconditionally) to get or update the + # listing of device sections known at this moment. + + # List of devices from the config file + UPSLIST_FILE="" + if [ "$DO_NORMALIZE_ONCE" = yes ]; then + upslist_normalizeFile_once || return # Propagate errors upwards + else + upslist_normalizeFile || return # Propagate errors upwards + fi + + if [ -n "$UPSCONF_DATA" ] ; then + # Note that section-name brackets should contain a single token + UPSLIST_FILE="$(echo "$UPSCONF_DATA_SDP" | egrep '^\[[^'"$TABCHAR"'\ ]*\]$' | sed 's,^\[\(.*\)\]$,\1,' | sort -n)" \ + || UPSLIST_FILE="" + if [ -z "$UPSLIST_FILE" ] ; then + echo "Error reading the '$UPSCONF' file or it does not declare any device configurations: no section declarations in parsed normalized contents" >&2 + fi + fi + # Ok to continue with empty results - we may end up removing all instances +} + +upslist_readFile_once() { + # Wrapper that ensures that the parsing is only done once + # (will re-parse if there were no devices listed on the + # first time, though) + [ -z "$UPSLIST_FILE" ] || return 0 + DO_NORMALIZE_ONCE=yes upslist_readFile +} + +upslist_readSvcs() { + UPSLIST_SVCS="`$hook_listInstances`" || UPSLIST_SVCS="" + if [ -z "$UPSLIST_SVCS" ] && [ "$1" != "-" ] ; then + EXPLAIN="" + [ -z "$1" ] || EXPLAIN=" - $1" + echo "Error reading the list of ${SERVICE_FRAMEWORK-} service instances for UPS drivers, or none are defined${EXPLAIN}" >&2 + # Ok to continue - we may end up defining new instances + fi +} + +upslist_debug() { + for UPSF in "" $UPSLIST_FILE ; do + upsconf_debug "$UPSF" + done +} + +upslist_addSvcs() { + # Note: This routine registers service instances for device config sections + # that are not wrapped currently. Support for redefined previously existing + # sections - is attained by removing the old service instance elsewhere and + # recreating it here, since any data could change including the dependency + # list, etc. + for UPSF in $UPSLIST_FILE ; do + if ! common_isRegistered "$UPSF" ; then + echo "Adding new ${SERVICE_FRAMEWORK} service instance for power device [${UPSF}]..." >&2 + $hook_registerInstance "$UPSF" + fi + done +} + +upslist_delSvcs() { + for UPSS in $UPSLIST_SVCS ; do + if ! common_isFiled "$UPSS" ; then + echo "Dropping old ${SERVICE_FRAMEWORK} service instance for power device [${UPSS}] which is no longer in config file..." >&2 + $hook_unregisterInstance "$UPSS" + fi + done +} + +upslist_restartSvcs() { + for UPSS in $UPSLIST_SVCS ; do + if common_isFiled "$UPSS" ; then + $hook_restart_drv "$UPSS" + fi + done +} + +nut_driver_enumerator_main() { + ################# MAIN PROGRAM by default + + # Note: do not use the read..._once() here, to ensure that the + # looped daemon sees the whole picture, which can be new every time + upslist_readFile || return $? + #upslist_debug + upslist_readSvcs "before manipulations" + + # Test if global config has changed since last run + RESTART_ALL=no + upssvcconf_checksum_unchanged "" || { echo "`date -u` : Detected changes in global section of '$UPSCONF', will restart all drivers"; RESTART_ALL=yes; } + + # Quickly exit if there's nothing to do; note the lists are pre-sorted + # Otherwise a non-zero exit will be done below + # Note: We implement testing in detail whether section definitions were + # changed since last run, as a first step before checking that name + # lists are still equivalent, because we need to always have the result + # of the "has it changed?" check as a hit-list of something to remove, + # while the check for no new device section definitions is just boolean. + # We can only exit quickly if both there are no changed sections and no + # new or removed sections since last run. + NEW_CHECKSUM="`upslist_checksums_unchanged "$UPSLIST_FILE" "$UPSLIST_SVCS"`" \ + && [ -z "$NEW_CHECKSUM" ] \ + && upslist_equals "$UPSLIST_FILE" "$UPSLIST_SVCS" \ + && if [ -z "$DAEMON_SLEEP" -o "${VERBOSE_LOOP}" = yes ] ; then \ + echo "`date -u` : OK: No changes to reconcile between ${SERVICE_FRAMEWORK} service instances and device configurations in '$UPSCONF'" ; \ + fi \ + && [ "$RESTART_ALL" = no ] && return 0 + + if [ -n "$NEW_CHECKSUM" ]; then + for UPSS in $NEW_CHECKSUM ; do + echo "Dropping old ${SERVICE_FRAMEWORK} service instance ${UPSS} whose section in config file has changed..." >&2 + $hook_unregisterInstance "$UPSS" + done + upslist_readSvcs "after updating for new config section checksums" + fi + + if [ -n "$UPSLIST_SVCS" ]; then + # Drop services that are not in config file (any more?) + upslist_delSvcs + + if [ "$RESTART_ALL" = yes ] && [ "$AUTO_START" = yes ] ; then + # Here restart only existing services; new ones will (try to) + # start soon after creation and upsd is handled below + upslist_restartSvcs + fi + fi + + if [ "$RESTART_ALL" = yes ] ; then + # Save new checksum of global config + $hook_setSavedMD5 "" "`upsconf_getSection_MD5 ""`" + fi + + if [ -n "$UPSLIST_FILE" ]; then + # Add services for sections that are in config file but not yet wrapped + upslist_addSvcs + $hook_refreshSupervizor + upslist_readSvcs "after checking for new config sections to define service instances" + fi + + upslist_readSvcs + if [ -n "$UPSLIST_SVCS" ] ; then + echo "=== The currently defined service instances are:" + echo "$UPSLIST_SVCS" + fi + + if [ -n "$UPSLIST_FILE" ] ; then + echo "=== The currently defined configurations in '$UPSCONF' are:" + echo "$UPSLIST_FILE" + fi + + # We had some changes to the config file; upsd must be made aware + if [ "$AUTO_START" = yes ] ; then + $hook_restart_upsd + fi + + # Return 42 if there was a change applied succesfully + # (but e.g. some services should restart - upsd, maybe upsmon) + UPSLIST_EQ_RES=0 + upslist_equals "$UPSLIST_FILE" "$UPSLIST_SVCS" || UPSLIST_EQ_RES=$? + + # File processing and service startups take a while; + # make sure upsconf did not change while we worked... + # NOTE: Check this at the last moment to minimize + # the chance of still not noticing the change made + # at just the wrong moment. + UPSCONF_CHECKSUM_END="`calc_md5_file "$UPSCONF"`" || true + if [ "$UPSCONF_CHECKSUM_END" != "$UPSCONF_CHECKSUM_START" ] ; then + # NOTE: even if daemonized, the sleep between iterations + # can be configured into an uncomfortably long lag, so + # we should re-sync the system config in any case. + echo "`date -u` : '$UPSCONF' changed while $0 $* was processing its older contents; re-running the script to pick up the late-coming changes" + # Make sure the cycle does not repeat itself due to diffs + # from an ages-old state of the file from when we started. + UPSCONF_CHECKSUM_START="$UPSCONF_CHECKSUM_END" + ( nut_driver_enumerator_main ) ; return $? + # The "main" routine at the end of recursions will + # do REPORT_RESTART_42 logic or the error exit-code + fi + + if [ "$UPSLIST_EQ_RES" = 0 ] ; then + echo "`date -u` : OK: No more changes to reconcile between ${SERVICE_FRAMEWORK} service instances and device configurations in '$UPSCONF'" + [ "${REPORT_RESTART_42-}" = no ] && return 0 || return 42 + fi + return 13 +} + +daemonize() ( + # Support (SIG)HUP == signal code 1 to quickly reconfigure, + # e.g. to request it while the sleep is happening or while + # "main" is processing an earlier change of the file. + RECONFIGURE_ASAP=false + trap 'RECONFIGURE_ASAP=true' 1 + + # Note: this loop would die on errors with config file or + # inability to ensure that it matches the list of services. + # If caller did not `export REPORT_RESTART_42=no` then the + # loop would exit with code 42, and probably trigger restart + # of the service which wraps this daemon do topple others that + # depend on it. + # Note: do not quickly skip the "main" based on full-file + # checksum refresh, to ensure that whatever is configured + # gets applied (e.g. if user disabled some services or they + # died, or some config was not applied due to coding error). + while nut_driver_enumerator_main ; do + if $RECONFIGURE_ASAP ; then + echo "`date -u` : Trapped a SIGHUP during last run of nut_driver_enumerator_main, repeating reconfiguration quickly" >&2 + else + sleep $DAEMON_SLEEP & + trap "kill $! ; echo 'Sleep interrupted, processing configs now!'>&2" 1 + wait $! + fi + RECONFIGURE_ASAP=false + trap 'RECONFIGURE_ASAP=true' 1 + done + exit $? +) + +# Save the checksum of ups.conf as early as possible, +# to test in the end that it is still the same file. +UPSCONF_CHECKSUM_START="`calc_md5_file "$UPSCONF"`" || true + +# By default, update wrapping of devices into services +if [ $# = 0 ]; then + nut_driver_enumerator_main ; exit $? +fi + +if [ $# = 1 ] ; then + [ -n "$DAEMON_SLEEP" ] || DAEMON_SLEEP=60 + # Note: Not all shells have 'case ... ;&' support + case "$1" in + --daemon=*) DAEMON_SLEEP="`echo "$1" | sed 's,^--daemon=,,'`" ;; + esac + case "$1" in + --daemon|--daemon=*) + daemonize & + exit $? + ;; + esac +fi +unset DAEMON_SLEEP + +usage() { + cat << EOF +$0 (no args) + Update wrapping of devices into services +$0 --daemon(=freq) + Update wrapping of devices into services in an infinite loop + Default freq is 60 sec +$0 --reconfigure + Stop and un-register all service instances and recreate them + (e.g. if new dependency template was defined in a new + version of this script and/or NUT package) +$0 --get-service-framework + Print the detected service + management framework in this OS +$0 --list-devices + Print list of devices in NUT config +$0 --list-services + Print list of service instances which wrap registered + NUT devices (full name of service unit) +$0 --list-instances + Print list of service instances which wrap registered + NUT devices (just instance suffix) +$0 --get-service-for-device DEV + Print the full name of service unit which wraps a NUT + device named "DEV" +$0 --get-device-for-service SVC + Print the NUT device name for full or instance-suffix name of + a service unit which wraps it +$0 --list-services-for-devices + Print a TAB-separated list of service units and corresponding + NUT device names which each such unit wraps +$0 --show-configs|--show-all-configs + Show the complete normalized list of device configuration blocks +$0 --show-config DEV +$0 --show-device-config DEV + Show configuration block of the specified NUT device +$0 --show-device-config-value DEV KEY [KEY...] + Show single configuration key value of the specified NUT device + For flags, shows the flag name if present in the section + If several keys or flags are requested, their values are reported + one per line in the same order (including empty lines for missing + values); any missing value yields a non-zero exit code. +EOF +} + +while [ $# -gt 0 ]; do + case "$1" in + --help|-h|-help) usage; exit 0 ;; + --get-service-framework) echo "${SERVICE_FRAMEWORK}" ; exit 0 ;; + --reconfigure) + upslist_readFile_once || exit $? + upslist_readSvcs "before manipulations" + + if [ -n "$UPSLIST_SVCS" ]; then + for UPSS in $UPSLIST_SVCS ; do + echo "Dropping old ${SERVICE_FRAMEWORK} service instance for power device [${UPSS}] to reconfigure the service unit..." >&2 + $hook_unregisterInstance "$UPSS" + done + upslist_readSvcs "after dropping" + fi + + if [ -n "$UPSLIST_FILE" ]; then + upslist_addSvcs + upslist_readSvcs "after checking for new config sections to define service instances" + fi + + # Save new checksum of global config + $hook_setSavedMD5 "" "`upsconf_getSection_MD5 ""`" + + # Service units were manipulated, including saving of checksums; + # refresh the service management daemon if needed + $hook_refreshSupervizor + + if [ -n "$UPSLIST_SVCS" ] ; then + echo "=== The currently defined service instances are:" + echo "$UPSLIST_SVCS" + fi + + if [ -n "$UPSLIST_FILE" ] ; then + echo "=== The currently defined configurations in '$UPSCONF' are:" + echo "$UPSLIST_FILE" + fi + + # We had some changes to the config file; upsd must be made aware + if [ "$AUTO_START" = yes ] ; then + $hook_restart_upsd + fi + + # Return 42 if there was a change applied succesfully + # (but e.g. some services should restart - upsd, maybe upsmon) + UPSLIST_EQ_RES=0 + upslist_equals "$UPSLIST_FILE" "$UPSLIST_SVCS" || UPSLIST_EQ_RES=$? + + # File processing and service startups take a while; + # make sure upsconf did not change while we worked... + # NOTE: Check this at the last moment to minimize + # the chance of still not noticing the change made + # at just the wrong moment. + UPSCONF_CHECKSUM_END="`calc_md5_file "$UPSCONF"`" || true + if [ "$UPSCONF_CHECKSUM_END" != "$UPSCONF_CHECKSUM_START" ] ; then + echo "`date -u` : '$UPSCONF' changed while $0 $* was processing its older contents; re-running the script to pick up the late-coming changes" + $0 ; exit $? + # The "main" routine will do REPORT_RESTART_42 logic too + fi + + if [ "$UPSLIST_EQ_RES" = 0 ] ; then + echo "`date -u` : OK: No more changes to reconcile between ${SERVICE_FRAMEWORK} service instances and device configurations in '$UPSCONF'" + [ "${REPORT_RESTART_42-}" = no ] && exit 0 || exit 42 + fi + + exit 13 + ;; + --list-devices) + upslist_readFile_once && \ + if [ -n "$UPSLIST_FILE" ] ; then + echo "=== The currently defined configurations in '$UPSCONF' are:" >&2 + echo "$UPSLIST_FILE" + exit 0 + fi + echo "No devices detected in '$UPSCONF'" >&2 + exit 1 + ;; + --list-services) + UPSLIST_SVCS_RAW="`$hook_listInstances_raw`" && \ + if [ -n "$UPSLIST_SVCS_RAW" ] ; then + echo "=== The currently defined service units are:" >&2 + echo "$UPSLIST_SVCS_RAW" + exit 0 + fi + echo "No service units detected" >&2 + exit 1 + ;; + --list-instances) + upslist_readSvcs "by user request" && \ + if [ -n "$UPSLIST_SVCS" ] ; then + echo "=== The currently defined service instances are:" >&2 + echo "$UPSLIST_SVCS" + exit 0 + fi + echo "No service instances detected" >&2 + exit 1 + ;; + --get-service-for-device) [ -z "$2" ] && echo "Device name argument required" >&2 && exit 1 + DEV="$2" + upslist_readSvcs "by user request" && [ -n "$UPSLIST_SVCS" ] \ + || { echo "No service instances detected" >&2 ; exit 1; } + UPSLIST_SVCS_RAW="`$hook_listInstances_raw`" && [ -n "$UPSLIST_SVCS_RAW" ] \ + || { echo "No service units detected" >&2 ; exit 1; } + vINST="`$hook_validInstanceName "$DEV"`" + vUNITD="`$hook_validFullUnitName "$DEV"`" + vUNITI="`$hook_validFullUnitName "$vINST"`" + # First pass over simple verbatim names + for INST in $UPSLIST_SVCS ; do + if [ "$INST" = "$DEV" ] ; then + for UNIT in $UPSLIST_SVCS_RAW ; do + if [ "$UNIT" = "$vUNITD" ] ; then + echo "$UNIT" + exit 0 + fi + done + fi + done + for INST in $UPSLIST_SVCS ; do + if [ "$INST" = "$vINST" ] ; then + for UNIT in $UPSLIST_SVCS_RAW ; do + if [ "$UNIT" = "$vUNITI" ] ; then + echo "$UNIT" + exit 0 + fi + done + fi + done + echo "No service instances detected that match device '$2'" >&2 + exit 1 + ;; + --get-device-for-service) [ -z "$2" ] && echo "Service (instance) name argument required" >&2 && exit 1 + # Instance name can be a hash or "native" NUT section name + SVC="`$hook_validInstanceSuffixName "$2"`" + case "$SVC" in + MD5_*) ;; # fall through to the bulk of code + *) upslist_readFile_once || exit $? + echo "$UPSLIST_FILE" | egrep "^$SVC\$" + exit $? + ;; + esac + FINAL_RES=0 + OUT="`"$0" --list-services-for-devices`" && [ -n "$OUT" ] || FINAL_RES=$? + if [ "$FINAL_RES" = 0 ]; then + echo "$OUT" | grep "$SVC" | ( \ + while read _SVC _DEV ; do + _SVC="`$hook_validInstanceSuffixName "${_SVC}"`" || exit + [ "${_SVC}" = "${SVC}" ] && echo "$_DEV" && exit 0 + done ; exit 1 ) && exit 0 + fi + echo "No service instance '$2' was detected that matches a NUT device" >&2 + exit 1 + ;; + --list-services-for-devices) + FINAL_RES=0 + upslist_readFile_once && [ -n "$UPSLIST_FILE" ] \ + || { echo "No devices detected in '$UPSCONF'" >&2 ; exit 1 ; } + upslist_readSvcs "by user request" && [ -n "$UPSLIST_SVCS" ] \ + || { echo "No service instances detected" >&2 ; exit 1; } + UPSLIST_SVCS_RAW="`$hook_listInstances_raw`" && [ -n "$UPSLIST_SVCS_RAW" ] \ + || { echo "No service units detected" >&2 ; exit 1; } + for DEV in $UPSLIST_FILE ; do + vINST="`$hook_validInstanceName "$DEV"`" + vUNITD="`$hook_validFullUnitName "$DEV"`" + vUNITI="`$hook_validFullUnitName "$vINST"`" + # First pass over simple verbatim names + for INST in $UPSLIST_SVCS ; do + if [ "$INST" = "$DEV" ] ; then + for UNIT in $UPSLIST_SVCS_RAW ; do + if [ "$UNIT" = "$vUNITD" ] ; then + printf '%s\t%s\n' "$UNIT" "$DEV" + continue 3 + fi + done + fi + done + for INST in $UPSLIST_SVCS ; do + if [ "$INST" = "$vINST" ] ; then + for UNIT in $UPSLIST_SVCS_RAW ; do + if [ "$UNIT" = "$vUNITI" ] ; then + printf '%s\t%s\n' "$UNIT" "$DEV" + continue 3 + fi + done + fi + done + echo "WARNING: no service instances detected that match device '$DEV'" >&2 + FINAL_RES=1 + done + exit $FINAL_RES + ;; + --show-configs|--show-device-configs|--show-all-configs|--show-all-device-configs) + RES=0 + upslist_readFile_once || RES=$? + [ "$RES" != 0 ] && { echo "ERROR: upslist_readFile_once () failed with code $RES" >&2; exit $RES; } + [ -n "$UPSLIST_FILE" ] \ + || { echo "WARNING: No devices detected in '$UPSCONF'" >&2 ; RES=1 ; } + echo "$UPSCONF_DATA" + exit $RES + ;; + --show-config|--show-device-config) + [ -z "$2" ] && echo "WARNING: Device name argument empty, will show global config" >&2 + DEV="$2" + upsconf_getSection "$DEV" + exit $? + ;; + --show-config-value|--show-device-config-value) + [ -z "$3" ] && echo "At least one configuration key name argument is required" >&2 && exit 1 + [ -z "$2" ] && echo "WARNING: Device name argument empty, will show global config" >&2 + DEV="$2" + shift 2 + upsconf_getValue "$DEV" "$@" + exit $? + ;; + upsconf_debug) # Not public, not in usage() + [ -z "$2" ] && echo "Device name argument required" >&2 && exit 1 + upsconf_debug "$2" + exit $? + ;; + upslist_debug) # Not public, not in usage() + upslist_readFile_once || exit + upslist_debug + exit $? + ;; + *) echo "Unrecognized argument: $1" >&2 ; exit 1 ;; + esac + shift +done diff --git a/scripts/upsdrvsvcctl/upsdrvsvcctl b/scripts/upsdrvsvcctl/upsdrvsvcctl new file mode 100755 index 0000000..001ac42 --- /dev/null +++ b/scripts/upsdrvsvcctl/upsdrvsvcctl @@ -0,0 +1,196 @@ +#!/bin/sh +# +# Copyright (C) 2016-2018 Eaton +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +#! \file upsdrvsvcctl(.in) +# \author Jim Klimov +# \brief Manage NUT devices registered as service-unit instances +# + +if [ -z "${SERVICE_FRAMEWORK-}" ] ; then + [ -x /usr/sbin/svcadm ] && [ -x /usr/sbin/svccfg ] && [ -x /usr/bin/svcs ] && \ + SERVICE_FRAMEWORK="smf" + [ -z "${SERVICE_FRAMEWORK-}" ] && \ + [ -x /bin/systemctl ] && \ + SERVICE_FRAMEWORK="systemd" +fi + +VERB="" +CMD="" +CMDARG="" +ENUMERATOR="" +case "$SERVICE_FRAMEWORK" in + smf) CMD="/usr/sbin/svcadm" + ENUMERATOR="/usr/local/libexec/nut-driver-enumerator.sh" + ;; + systemd) CMD="/bin/systemctl" + ENUMERATOR="/usr/local/libexec/nut-driver-enumerator.sh" + ;; + *) echo "Unrecognized SERVICE_FRAMEWORK: $SERVICE_FRAMEWORK" >&2 ; exit ;; +esac + + +usage() { + # Note: version header differs from UPS_VERSION in binaries that + # might also have the git-version suffixed during build time + cat << EOF +Network UPS Tools - UPS driver controller ${PACKAGE_VERSION} +Starts and stops UPS drivers via system service instances, see +the $ENUMERATOR +script for more details. + +usage: $0 [OPTIONS] (start | stop | shutdown) [] + +Options: + -h display this help + -t testing mode - prints actions without doing them + -D raise debugging level + start start all UPS drivers in ups.conf + start only start driver for UPS + stop stop all UPS drivers in ups.conf + stop only stop driver for UPS + +Note: the "shutdown" options from original upsdrvctl are not currently +directly supported by this service management framework wrapper; instead +they are passed to the native upsdrvctl binary (your current user account +should have sufficient permissions to do that all): + shutdown shutdown all UPS drivers in ups.conf + shutdown only shutdown UPS + +usage: $0 [OPTIONS] resync + resync call $ENUMERATOR + to update the mapping of service instances for + NUT drivers to device sections in 'ups.conf' + +usage: $0 [OPTIONS] reconfigure + reconfigure call $ENUMERATOR + to remove and re-create the mapping of all service + instances for NUT drivers to device sections in + 'ups.conf' e.g. after a NUT package upgrade + +usage: $0 [OPTIONS] list [] + list call $ENUMERATOR + to list the mapping of service instances to device sections + list (optionally return the service instance name for one device) + +usage: $0 [OPTIONS] show-config [] + show-config output config section from ups.conf for device + show-config ...or all devices if no argument was passed +EOF +} + +ACTION="" +SVCINST="" +DRYRUN="" +DEBUG=0 +# Note: DEBUG is UNUSED_PARAM so far +while [ $# -gt 0 ]; do + case "$1" in + resync) eval $DRYRUN $ENUMERATOR ; exit $? ;; + reconf|reconfigure) eval $DRYRUN $ENUMERATOR --reconfigure ; exit $? ;; + list) + if [ -n "$2" ] ; then + eval $ENUMERATOR --get-service-for-device "$2" ; exit $? + else + eval $ENUMERATOR --list-services-for-devices ; exit $? + fi + ;; + show-config) + if [ -n "$2" ] ; then + eval $ENUMERATOR --show-device-config "$2" ; exit $? + else + eval $ENUMERATOR --show-all-configs ; exit $? + fi + ;; + start|stop) + ACTION="$1" + if [ -n "$2" ] ; then + SVCINST="`$ENUMERATOR --get-service-for-device "$2"`" || exit + shift + fi + ;; + shutdown) + echo "NOTE: Action '$1' is not implemented via services currently, will call upsdrvctl" >&2 + echo "Stopping the driver service instance(s) to release exclusive resources, if any..." >&2 + RES=0 + $0 stop $2 + /usr/local/sbin/upsdrvctl shutdown $2 || RES=$? + echo "Starting the driver service instance(s) so they can reconnect when the UPS returns..." >&2 + $0 start $2 + exit $RES + ;; + -t) DRYRUN="echo" ;; + -h) usage; exit 0 ;; + -D) DEBUG="`expr $DEBUG + 1`" ;; + -r|-u) echo "Option '$1 $2' is not implemented via services currently" >&2 ; shift;; + *) echo "Unrecognized argument: $1" >&2 ; exit ;; + esac + shift +done + +if [ -z "$ENUMERATOR" ] || [ ! -s "$ENUMERATOR" ] || [ ! -x "$ENUMERATOR" ] ; then + echo "ENUMERATOR script (nut-driver-enumerator.sh) not found!" >&2 + exit 1 +fi + +if [ -z "$ACTION" ]; then + echo "No action was requested!" >&2 + exit 1 +fi + +if [ -z "$SVCINST" ]; then + SVCINST="`$ENUMERATOR --list-services`" || exit +fi + +# TODO: Support shutdown of one or all UPSes by stopping its service +# and then calling the original upsdrvctl on it? +case "$ACTION" in + start) + VERB="Starting" + case "$SERVICE_FRAMEWORK" in + smf) CMDARG="enable -ts" ;; + systemd) CMDARG="start" ;; + esac + ;; + stop) + VERB="Stopping" + case "$SERVICE_FRAMEWORK" in + smf) CMDARG="disable -ts" ;; + systemd) CMDARG="stop" ;; + esac + ;; + *) echo "Unrecognized ACTION: $ACTION" >&2 ; exit ;; +esac + +for INST in $SVCINST ; do + echo "$VERB $INST ..." >&2 + $DRYRUN $CMD $CMDARG "$INST" & +done +wait + +case "$SERVICE_FRAMEWORK" in + smf) + sleep 1 + echo "Post-process clearing services that failed early..." >&2 + for INST in $SVCINST ; do + echo "Clearing $INST (if it got broken) ..." >&2 + $DRYRUN $CMD clear "$INST" & + done + ;; +esac + +wait diff --git a/scripts/upsdrvsvcctl/upsdrvsvcctl.in b/scripts/upsdrvsvcctl/upsdrvsvcctl.in new file mode 100755 index 0000000..d9e127c --- /dev/null +++ b/scripts/upsdrvsvcctl/upsdrvsvcctl.in @@ -0,0 +1,196 @@ +#!/bin/sh +# +# Copyright (C) 2016-2018 Eaton +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +#! \file upsdrvsvcctl(.in) +# \author Jim Klimov +# \brief Manage NUT devices registered as service-unit instances +# + +if [ -z "${SERVICE_FRAMEWORK-}" ] ; then + [ -x /usr/sbin/svcadm ] && [ -x /usr/sbin/svccfg ] && [ -x /usr/bin/svcs ] && \ + SERVICE_FRAMEWORK="smf" + [ -z "${SERVICE_FRAMEWORK-}" ] && \ + [ -x /bin/systemctl ] && \ + SERVICE_FRAMEWORK="systemd" +fi + +VERB="" +CMD="" +CMDARG="" +ENUMERATOR="" +case "$SERVICE_FRAMEWORK" in + smf) CMD="/usr/sbin/svcadm" + ENUMERATOR="@NUT_LIBEXECDIR@/nut-driver-enumerator.sh" + ;; + systemd) CMD="/bin/systemctl" + ENUMERATOR="@NUT_LIBEXECDIR@/nut-driver-enumerator.sh" + ;; + *) echo "Unrecognized SERVICE_FRAMEWORK: $SERVICE_FRAMEWORK" >&2 ; exit ;; +esac + + +usage() { + # Note: version header differs from UPS_VERSION in binaries that + # might also have the git-version suffixed during build time + cat << EOF +Network UPS Tools - UPS driver controller ${PACKAGE_VERSION} +Starts and stops UPS drivers via system service instances, see +the $ENUMERATOR +script for more details. + +usage: $0 [OPTIONS] (start | stop | shutdown) [] + +Options: + -h display this help + -t testing mode - prints actions without doing them + -D raise debugging level + start start all UPS drivers in ups.conf + start only start driver for UPS + stop stop all UPS drivers in ups.conf + stop only stop driver for UPS + +Note: the "shutdown" options from original upsdrvctl are not currently +directly supported by this service management framework wrapper; instead +they are passed to the native upsdrvctl binary (your current user account +should have sufficient permissions to do that all): + shutdown shutdown all UPS drivers in ups.conf + shutdown only shutdown UPS + +usage: $0 [OPTIONS] resync + resync call $ENUMERATOR + to update the mapping of service instances for + NUT drivers to device sections in 'ups.conf' + +usage: $0 [OPTIONS] reconfigure + reconfigure call $ENUMERATOR + to remove and re-create the mapping of all service + instances for NUT drivers to device sections in + 'ups.conf' e.g. after a NUT package upgrade + +usage: $0 [OPTIONS] list [] + list call $ENUMERATOR + to list the mapping of service instances to device sections + list (optionally return the service instance name for one device) + +usage: $0 [OPTIONS] show-config [] + show-config output config section from ups.conf for device + show-config ...or all devices if no argument was passed +EOF +} + +ACTION="" +SVCINST="" +DRYRUN="" +DEBUG=0 +# Note: DEBUG is UNUSED_PARAM so far +while [ $# -gt 0 ]; do + case "$1" in + resync) eval $DRYRUN $ENUMERATOR ; exit $? ;; + reconf|reconfigure) eval $DRYRUN $ENUMERATOR --reconfigure ; exit $? ;; + list) + if [ -n "$2" ] ; then + eval $ENUMERATOR --get-service-for-device "$2" ; exit $? + else + eval $ENUMERATOR --list-services-for-devices ; exit $? + fi + ;; + show-config) + if [ -n "$2" ] ; then + eval $ENUMERATOR --show-device-config "$2" ; exit $? + else + eval $ENUMERATOR --show-all-configs ; exit $? + fi + ;; + start|stop) + ACTION="$1" + if [ -n "$2" ] ; then + SVCINST="`$ENUMERATOR --get-service-for-device "$2"`" || exit + shift + fi + ;; + shutdown) + echo "NOTE: Action '$1' is not implemented via services currently, will call upsdrvctl" >&2 + echo "Stopping the driver service instance(s) to release exclusive resources, if any..." >&2 + RES=0 + $0 stop $2 + @SBINDIR@/upsdrvctl shutdown $2 || RES=$? + echo "Starting the driver service instance(s) so they can reconnect when the UPS returns..." >&2 + $0 start $2 + exit $RES + ;; + -t) DRYRUN="echo" ;; + -h) usage; exit 0 ;; + -D) DEBUG="`expr $DEBUG + 1`" ;; + -r|-u) echo "Option '$1 $2' is not implemented via services currently" >&2 ; shift;; + *) echo "Unrecognized argument: $1" >&2 ; exit ;; + esac + shift +done + +if [ -z "$ENUMERATOR" ] || [ ! -s "$ENUMERATOR" ] || [ ! -x "$ENUMERATOR" ] ; then + echo "ENUMERATOR script (nut-driver-enumerator.sh) not found!" >&2 + exit 1 +fi + +if [ -z "$ACTION" ]; then + echo "No action was requested!" >&2 + exit 1 +fi + +if [ -z "$SVCINST" ]; then + SVCINST="`$ENUMERATOR --list-services`" || exit +fi + +# TODO: Support shutdown of one or all UPSes by stopping its service +# and then calling the original upsdrvctl on it? +case "$ACTION" in + start) + VERB="Starting" + case "$SERVICE_FRAMEWORK" in + smf) CMDARG="enable -ts" ;; + systemd) CMDARG="start" ;; + esac + ;; + stop) + VERB="Stopping" + case "$SERVICE_FRAMEWORK" in + smf) CMDARG="disable -ts" ;; + systemd) CMDARG="stop" ;; + esac + ;; + *) echo "Unrecognized ACTION: $ACTION" >&2 ; exit ;; +esac + +for INST in $SVCINST ; do + echo "$VERB $INST ..." >&2 + $DRYRUN $CMD $CMDARG "$INST" & +done +wait + +case "$SERVICE_FRAMEWORK" in + smf) + sleep 1 + echo "Post-process clearing services that failed early..." >&2 + for INST in $SVCINST ; do + echo "Clearing $INST (if it got broken) ..." >&2 + $DRYRUN $CMD clear "$INST" & + done + ;; +esac + +wait diff --git a/server/Makefile.am b/server/Makefile.am index 8146568..1ab6393 100644 --- a/server/Makefile.am +++ b/server/Makefile.am @@ -1,5 +1,10 @@ # Network UPS Tools: server +# Make sure out-of-dir dependencies exist (especially when dev-building parts): +$(top_builddir)/common/libcommon.la \ +$(top_builddir)/common/libparseconf.la: dummy + @cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F) + # Avoid per-target CFLAGS, because this will prevent re-use of object # files. In any case, CFLAGS are only -I options, so there is no harm, # but only add them if we really use the target. @@ -10,7 +15,7 @@ endif if WITH_SSL AM_CFLAGS += $(LIBSSL_CFLAGS) endif -LDADD = ../common/libcommon.la ../common/libparseconf.la $(NETLIBS) +LDADD = $(top_builddir)/common/libcommon.la $(top_builddir)/common/libparseconf.la $(NETLIBS) if WITH_WRAP LDADD += $(LIBWRAP_LIBS) endif @@ -28,3 +33,12 @@ upsd_SOURCES = upsd.c user.c conf.c netssl.c sstate.c desc.c \ upstype.h user-data.h user.h sockdebug_SOURCES = sockdebug.c + +dummy: + +MAINTAINERCLEANFILES = Makefile.in .dirstamp + +# NOTE: Do not clean ".deps" in SUBDIRS of the main project, +# the root Makefile.am takes care of that! +#clean-local: +# rm -rf $(builddir)/.deps diff --git a/server/Makefile.in b/server/Makefile.in index e81745a..bfb217c 100644 --- a/server/Makefile.in +++ b/server/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.16.3 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -17,7 +17,17 @@ # Network UPS Tools: server VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -88,19 +98,24 @@ target_triplet = @target@ sbin_PROGRAMS = upsd$(EXEEXT) EXTRA_PROGRAMS = sockdebug$(EXEEXT) subdir = server -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nut_arg_with.m4 \ $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ $(top_srcdir)/m4/nut_check_libavahi.m4 \ $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ $(top_srcdir)/m4/nut_check_libgd.m4 \ $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ $(top_srcdir)/m4/nut_check_libneon.m4 \ $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ $(top_srcdir)/m4/nut_check_libnss.m4 \ @@ -109,11 +124,17 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ $(top_srcdir)/m4/nut_check_libusb.m4 \ $(top_srcdir)/m4/nut_check_libwrap.m4 \ $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ $(top_srcdir)/m4/nut_type_socklen_t.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = @@ -126,8 +147,8 @@ sockdebug_LDADD = $(LDADD) am__DEPENDENCIES_1 = @WITH_WRAP_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) @WITH_SSL_TRUE@am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1) -sockdebug_DEPENDENCIES = ../common/libcommon.la \ - ../common/libparseconf.la $(am__DEPENDENCIES_1) \ +sockdebug_DEPENDENCIES = $(top_builddir)/common/libcommon.la \ + $(top_builddir)/common/libparseconf.la $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_3) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -139,9 +160,9 @@ am_upsd_OBJECTS = upsd.$(OBJEXT) user.$(OBJEXT) conf.$(OBJEXT) \ netuser.$(OBJEXT) netset.$(OBJEXT) netinstcmd.$(OBJEXT) upsd_OBJECTS = $(am_upsd_OBJECTS) upsd_LDADD = $(LDADD) -upsd_DEPENDENCIES = ../common/libcommon.la ../common/libparseconf.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \ - $(am__DEPENDENCIES_3) +upsd_DEPENDENCIES = $(top_builddir)/common/libcommon.la \ + $(top_builddir)/common/libparseconf.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_3) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -156,7 +177,13 @@ am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/conf.Po ./$(DEPDIR)/desc.Po \ + ./$(DEPDIR)/netget.Po ./$(DEPDIR)/netinstcmd.Po \ + ./$(DEPDIR)/netlist.Po ./$(DEPDIR)/netmisc.Po \ + ./$(DEPDIR)/netset.Po ./$(DEPDIR)/netssl.Po \ + ./$(DEPDIR)/netuser.Po ./$(DEPDIR)/sockdebug.Po \ + ./$(DEPDIR)/sstate.Po ./$(DEPDIR)/upsd.Po ./$(DEPDIR)/user.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -202,6 +229,7 @@ am__define_uniq_tagged_files = \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) A2X = @A2X@ ACLOCAL = @ACLOCAL@ @@ -210,6 +238,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -220,6 +249,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -233,6 +263,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -245,6 +276,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -262,6 +294,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -272,21 +306,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -306,6 +348,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -319,6 +364,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -336,6 +382,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -349,6 +396,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -374,12 +424,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -394,7 +446,8 @@ udevdir = @udevdir@ # files. In any case, CFLAGS are only -I options, so there is no harm, # but only add them if we really use the target. AM_CFLAGS = -I$(top_srcdir)/include $(am__append_1) $(am__append_2) -LDADD = ../common/libcommon.la ../common/libparseconf.la $(NETLIBS) \ +LDADD = $(top_builddir)/common/libcommon.la \ + $(top_builddir)/common/libparseconf.la $(NETLIBS) \ $(am__append_3) $(am__append_4) upsd_SOURCES = upsd.c user.c conf.c netssl.c sstate.c desc.c \ netget.c netmisc.c netlist.c netuser.c netset.c netinstcmd.c \ @@ -403,6 +456,7 @@ upsd_SOURCES = upsd.c user.c conf.c netssl.c sstate.c desc.c \ upstype.h user-data.h user.h sockdebug_SOURCES = sockdebug.c +MAINTAINERCLEANFILES = Makefile.in .dirstamp all: all-am .SUFFIXES: @@ -419,14 +473,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu server/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu server/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -501,19 +554,25 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conf.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/desc.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netget.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netinstcmd.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netlist.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netmisc.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netset.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netssl.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netuser.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sockdebug.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sstate.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upsd.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/user.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conf.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/desc.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netget.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netinstcmd.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netlist.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netmisc.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netset.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netssl.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netuser.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sockdebug.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sstate.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upsd.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/user.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @@ -597,7 +656,10 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -664,13 +726,26 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am clean-am: clean-generic clean-libtool clean-sbinPROGRAMS \ mostlyclean-am distclean: distclean-am - -rm -rf ./$(DEPDIR) + -rm -f ./$(DEPDIR)/conf.Po + -rm -f ./$(DEPDIR)/desc.Po + -rm -f ./$(DEPDIR)/netget.Po + -rm -f ./$(DEPDIR)/netinstcmd.Po + -rm -f ./$(DEPDIR)/netlist.Po + -rm -f ./$(DEPDIR)/netmisc.Po + -rm -f ./$(DEPDIR)/netset.Po + -rm -f ./$(DEPDIR)/netssl.Po + -rm -f ./$(DEPDIR)/netuser.Po + -rm -f ./$(DEPDIR)/sockdebug.Po + -rm -f ./$(DEPDIR)/sstate.Po + -rm -f ./$(DEPDIR)/upsd.Po + -rm -f ./$(DEPDIR)/user.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -716,7 +791,19 @@ install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) + -rm -f ./$(DEPDIR)/conf.Po + -rm -f ./$(DEPDIR)/desc.Po + -rm -f ./$(DEPDIR)/netget.Po + -rm -f ./$(DEPDIR)/netinstcmd.Po + -rm -f ./$(DEPDIR)/netlist.Po + -rm -f ./$(DEPDIR)/netmisc.Po + -rm -f ./$(DEPDIR)/netset.Po + -rm -f ./$(DEPDIR)/netssl.Po + -rm -f ./$(DEPDIR)/netuser.Po + -rm -f ./$(DEPDIR)/sockdebug.Po + -rm -f ./$(DEPDIR)/sstate.Po + -rm -f ./$(DEPDIR)/upsd.Po + -rm -f ./$(DEPDIR)/user.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -737,9 +824,9 @@ uninstall-am: uninstall-sbinPROGRAMS .MAKE: install-am install-strip -.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-sbinPROGRAMS cscopelist-am ctags ctags-am \ - distclean distclean-compile distclean-generic \ +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ + clean-generic clean-libtool clean-sbinPROGRAMS cscopelist-am \ + ctags ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ @@ -751,6 +838,20 @@ uninstall-am: uninstall-sbinPROGRAMS mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am uninstall-sbinPROGRAMS +.PRECIOUS: Makefile + + +# Make sure out-of-dir dependencies exist (especially when dev-building parts): +$(top_builddir)/common/libcommon.la \ +$(top_builddir)/common/libparseconf.la: dummy + @cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F) + +dummy: + +# NOTE: Do not clean ".deps" in SUBDIRS of the main project, +# the root Makefile.am takes care of that! +#clean-local: +# rm -rf $(builddir)/.deps # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/server/conf.c b/server/conf.c index aea8220..3dd2696 100644 --- a/server/conf.c +++ b/server/conf.c @@ -23,9 +23,19 @@ #include "sstate.h" #include "user.h" #include "netssl.h" +#include "nut_stdint.h" +#include - ups_t *upstable = NULL; - int num_ups = 0; +static ups_t *upstable = NULL; +int num_ups = 0; + +/* Users can pass a -D[...] option to enable debugging. + * For the service tracing purposes, also the upsd.conf + * can define a debug_min value in the global section, + * to set the minimal debug level (CLI provided value less + * than that would not have effect, can only have more). + */ +int nut_debug_level_global = -1; /* add another UPS for monitoring from ups.conf */ static void ups_create(const char *fn, const char *name, const char *desc) @@ -110,25 +120,91 @@ static void ups_update(const char *fn, const char *name, const char *desc) /* always set this on reload */ temp->retain = 1; -} +} + +/* returns 1 if "arg" was usable as a boolean value, 0 if not + * saves converted meaning of "arg" into referenced "result" + */ +static int parse_boolean(char *arg, int *result) +{ + if ( (!strcasecmp(arg, "true")) || (!strcasecmp(arg, "on")) || (!strcasecmp(arg, "yes")) || (!strcasecmp(arg, "1"))) { + *result = 1; + return 1; + } + if ( (!strcasecmp(arg, "false")) || (!strcasecmp(arg, "off")) || (!strcasecmp(arg, "no")) || (!strcasecmp(arg, "0"))) { + *result = 0; + return 1; + } + return 0; +} /* return 1 if usable, 0 if not */ -static int parse_upsd_conf_args(int numargs, char **arg) +static int parse_upsd_conf_args(size_t numargs, char **arg) { /* everything below here uses up through arg[1] */ if (numargs < 2) return 0; + /* DEBUG_MIN (NUM) */ + /* debug_min (NUM) also acceptable, to be on par with ups.conf */ + if (!strcasecmp(arg[0], "DEBUG_MIN")) { + int lvl = -1; // typeof common/common.c: int nut_debug_level + if ( str_to_int (arg[1], &lvl, 10) && lvl >= 0 ) { + nut_debug_level_global = lvl; + } else { + upslogx(LOG_INFO, "DEBUG_MIN has non numeric or negative value in upsd.conf"); + } + return 1; + } + /* MAXAGE */ if (!strcmp(arg[0], "MAXAGE")) { - maxage = atoi(arg[1]); - return 1; + if (isdigit((size_t)arg[1][0])) { + maxage = atoi(arg[1]); + return 1; + } + else { + upslogx(LOG_ERR, "MAXAGE has non numeric value (%s)!", arg[1]); + return 0; + } + } + + /* TRACKINGDELAY */ + if (!strcmp(arg[0], "TRACKINGDELAY")) { + if (isdigit((size_t)arg[1][0])) { + tracking_delay = atoi(arg[1]); + return 1; + } + else { + upslogx(LOG_ERR, "TRACKINGDELAY has non numeric value (%s)!", arg[1]); + return 0; + } + } + + /* ALLOW_NO_DEVICE */ + if (!strcmp(arg[0], "ALLOW_NO_DEVICE")) { + if (isdigit((size_t)arg[1][0])) { + allow_no_device = (atoi(arg[1]) != 0); /* non-zero arg is true here */ + return 1; + } + if (parse_boolean(arg[1], &allow_no_device)) + return 1; + + upslogx(LOG_ERR, "ALLOW_NO_DEVICE has non numeric and non boolean value (%s)!", arg[1]); + return 0; } /* MAXCONN */ if (!strcmp(arg[0], "MAXCONN")) { - maxconn = atoi(arg[1]); - return 1; + if (isdigit((size_t)arg[1][0])) { + /* FIXME: Check for overflows (and int size of nfds_t vs. long) - see get_max_pid_t() for example */ + maxconn = (nfds_t)atol(arg[1]); + return 1; + } + else { + upslogx(LOG_ERR, "MAXCONN has non numeric value (%s)!", arg[1]); + return 0; + } } /* STATEPATH */ @@ -162,12 +238,29 @@ static int parse_upsd_conf_args(int numargs, char **arg) #ifdef WITH_CLIENT_CERTIFICATE_VALIDATION /* CERTREQUEST (0 | 1 | 2) */ if (!strcmp(arg[0], "CERTREQUEST")) { - certrequest = atoi(arg[1]); - return 1; + if (isdigit((size_t)arg[1][0])) { + certrequest = atoi(arg[1]); + return 1; + } + else { + upslogx(LOG_ERR, "CERTREQUEST has non numeric value (%s)!", arg[1]); + return 0; + } } #endif /* WITH_CLIENT_CERTIFICATE_VALIDATION */ #endif /* WITH_OPENSSL | WITH_NSS */ - + +#if defined(WITH_OPENSSL) || defined(WITH_NSS) + /* DISABLE_WEAK_SSL */ + if (!strcmp(arg[0], "DISABLE_WEAK_SSL")) { + if (parse_boolean(arg[1], &disable_weak_ssl)) + return 1; + + upslogx(LOG_ERR, "DISABLE_WEAK_SSL has non boolean value (%s)!", arg[1]); + return 0; + } +#endif /* WITH_OPENSSL | WITH_NSS */ + /* ACCEPT [...] */ if (!strcmp(arg[0], "ACCEPT")) { upslogx(LOG_WARNING, "ACCEPT in upsd.conf is no longer supported - switch to LISTEN"); @@ -198,7 +291,7 @@ static int parse_upsd_conf_args(int numargs, char **arg) upslogx(LOG_WARNING, "ACL in upsd.conf is no longer supported - switch to LISTEN"); return 1; } - + #ifdef WITH_NSS /* CERTIDENT */ if (!strcmp(arg[0], "CERTIDENT")) { @@ -241,6 +334,13 @@ void load_upsdconf(int reloading) return; } + if (reloading) { + /* if upsd.conf added or changed + * (or commented away) the debug_min + * setting, detect that */ + nut_debug_level_global = -1; + } + while (pconf_file_next(&ctx)) { if (pconf_parse_error(&ctx)) { upslogx(LOG_ERR, "Parse error: %s:%d: %s", @@ -255,11 +355,11 @@ void load_upsdconf(int reloading) unsigned int i; char errmsg[SMALLBUF]; - snprintf(errmsg, sizeof(errmsg), + snprintf(errmsg, sizeof(errmsg), "upsd.conf: invalid directive"); for (i = 0; i < ctx.numargs; i++) - snprintfcat(errmsg, sizeof(errmsg), " %s", + snprintfcat(errmsg, sizeof(errmsg), " %s", ctx.arglist[i]); upslogx(LOG_WARNING, "%s", errmsg); @@ -267,7 +367,16 @@ void load_upsdconf(int reloading) } - pconf_finish(&ctx); + if (reloading) { + if (nut_debug_level_global > -1) { + upslogx(LOG_INFO, + "Applying debug_min=%d from upsd.conf", + nut_debug_level_global); + nut_debug_level = nut_debug_level_global; + } + } + + pconf_finish(&ctx); } /* callback during parsing of ups.conf */ @@ -331,7 +440,7 @@ void upsconf_add(int reloading) /* don't accept an entry that's missing items */ if ((!tmp->driver) || (!tmp->port)) { - upslogx(LOG_WARNING, "Warning: ignoring incomplete configuration for UPS [%s]\n", + upslogx(LOG_WARNING, "Warning: ignoring incomplete configuration for UPS [%s]\n", tmp->upsname); } else { snprintf(statefn, sizeof(statefn), "%s-%s", @@ -404,7 +513,7 @@ static void delete_ups(upstype_t *target) /* shouldn't happen */ upslogx(LOG_ERR, "delete_ups: UPS not found"); -} +} /* see if we can open a file */ static int check_file(const char *fn) diff --git a/server/conf.h b/server/conf.h index e6b207a..432b7f9 100644 --- a/server/conf.h +++ b/server/conf.h @@ -3,6 +3,7 @@ Copyright (C) 2001 Russell Kroll 2008 Arjen de Korte + 2020 Jim Klimov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,6 +20,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef NUT_CONF_H_SEEN +#define NUT_CONF_H_SEEN 1 + #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { @@ -47,6 +51,7 @@ void delete_acls(void); void delete_access(void); extern int num_ups; +extern int nut_debug_level_global; #ifdef __cplusplus /* *INDENT-OFF* */ @@ -54,3 +59,4 @@ extern int num_ups; /* *INDENT-ON* */ #endif +#endif /* NUT_CONF_H_SEEN */ diff --git a/server/desc.c b/server/desc.c index b74df72..e6b08f0 100644 --- a/server/desc.c +++ b/server/desc.c @@ -17,6 +17,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "config.h" /* must be the first header */ + #include #include "common.h" diff --git a/server/desc.h b/server/desc.h index 00b413d..a574831 100644 --- a/server/desc.h +++ b/server/desc.h @@ -1,3 +1,28 @@ +/* desc.h - variable/command description handling for upsd + + Copyright (C) + 2003 Russell Kroll + 2005 Arnaud Quette + 2013 Emilien Kia + 2020 Jim Klimov + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef NUT_DESC_H_SEEN +#define NUT_DESC_H_SEEN 1 #ifdef __cplusplus /* *INDENT-OFF* */ @@ -16,3 +41,4 @@ const char *desc_get_var(const char *name); /* *INDENT-ON* */ #endif +#endif /* NUT_DESC_H_SEEN */ diff --git a/server/netcmds.h b/server/netcmds.h index 20bc464..6a5a632 100644 --- a/server/netcmds.h +++ b/server/netcmds.h @@ -1,6 +1,11 @@ /* netcmds.h - upsd support structure details Copyright (C) 2001 Russell Kroll + 2005 Arnaud Quette + 2007 Peter Selinger + 2010 Arjen de Korte + 2012 Emilien Kia + 2020 Jim Klimov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,6 +22,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef NUT_NETCMDS_H_SEEN +#define NUT_NETCMDS_H_SEEN 1 + #include "nut_ctype.h" #include "netssl.h" @@ -35,13 +43,14 @@ extern "C" { /* *INDENT-ON* */ #endif -struct { +static struct { const char *name; - void (*func)(nut_ctype_t *client, int numargs, const char **arg); + void (*func)(nut_ctype_t *client, size_t numargs, const char **arg); int flags; } netcmds[] = { { "VER", net_ver, 0 }, { "NETVER", net_netver, 0 }, + { "PROTVER", net_netver, 0 }, /* aliased since NUT 2.8.0 */ { "HELP", net_help, 0 }, { "STARTTLS", net_starttls, 0 }, @@ -53,6 +62,10 @@ struct { { "LOGIN", net_login, FLAG_USER }, { "LOGOUT", net_logout, 0 }, + /* NOTE: Protocol in NUT 2.8.0 allows to handle + * master/primary to rename/alias the routine. + */ + { "PRIMARY", net_primary, FLAG_USER }, { "MASTER", net_master, FLAG_USER }, { "FSD", net_fsd, FLAG_USER }, @@ -60,7 +73,7 @@ struct { { "SET", net_set, FLAG_USER }, { "INSTCMD", net_instcmd, FLAG_USER }, - { NULL, (void(*)())(NULL), 0 } + { NULL, (void(*)(struct nut_ctype_s *, size_t, const char **))(NULL), 0 } }; #ifdef __cplusplus @@ -69,3 +82,4 @@ struct { /* *INDENT-ON* */ #endif +#endif /* NUT_NETCMDS_H_SEEN */ diff --git a/server/neterr.h b/server/neterr.h index 0be8b83..3891452 100644 --- a/server/neterr.h +++ b/server/neterr.h @@ -1,3 +1,35 @@ +/* neterr.h - network error definitions for NUT + + Copyright (C) + 2003 Russell Kroll + 2005 Arnaud Quette + 2013 Emilien Kia + 2020 Jim Klimov + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef NUT_NETERR_H_SEEN +#define NUT_NETERR_H_SEEN 1 + +#ifdef __cplusplus +/* *INDENT-OFF* */ +extern "C" { +/* *INDENT-ON* */ +#endif + /* network error definitions for consistency */ #define NUT_ERR_ACCESS_DENIED "ACCESS-DENIED" @@ -33,3 +65,11 @@ #define NUT_ERR_UNKNOWN_INSTCMD "UNKNOWN-INSTCMD" #define NUT_ERR_MISSING_ARGUMENT "MISSING-ARGUMENT" #define NUT_ERR_INVALID_VALUE "INVALID-VALUE" + +#ifdef __cplusplus +/* *INDENT-OFF* */ +} +/* *INDENT-ON* */ +#endif + +#endif /* NUT_NETERR_H_SEEN */ diff --git a/server/netget.c b/server/netget.c index d876891..a5f822a 100644 --- a/server/netget.c +++ b/server/netget.c @@ -109,7 +109,7 @@ static void get_cmddesc(nut_ctype_t *client, const char *upsname, const char *cm if (desc) sendback(client, "CMDDESC %s %s \"%s\"\n", upsname, cmd, desc); else - sendback(client, "CMDDESC %s %s \"Description unavailable\"\n", + sendback(client, "CMDDESC %s %s \"Description unavailable\"\n", upsname, cmd); } @@ -142,38 +142,36 @@ static void get_type(nut_ctype_t *client, const char *upsname, const char *var) snprintfcat(buf, sizeof(buf), " RW"); if (node->enum_list) { - sendback(client, "%s ENUM\n", buf); - return; + snprintfcat(buf, sizeof(buf), " ENUM"); } if (node->range_list) { - sendback(client, "%s RANGE\n", buf); - return; + snprintfcat(buf, sizeof(buf), " RANGE"); } if (node->flags & ST_FLAG_STRING) { - sendback(client, "%s STRING:%d\n", buf, node->aux); + sendback(client, "%s STRING:%ld\n", buf, node->aux); return; } /* Any variable that is not string | range | enum is just a simple * numeric value */ - sendback(client, "TYPE %s %s NUMBER\n", upsname, var); -} + sendback(client, "%s NUMBER\n", buf); +} static void get_var_server(nut_ctype_t *client, const char *upsname, const char *var) { if (!strcasecmp(var, "server.info")) { sendback(client, "VAR %s server.info " "\"Network UPS Tools upsd %s - " - "http://www.networkupstools.org/\"\n", + "http://www.networkupstools.org/\"\n", upsname, UPS_VERSION); return; } if (!strcasecmp(var, "server.version")) { - sendback(client, "VAR %s server.version \"%s\"\n", + sendback(client, "VAR %s server.version \"%s\"\n", upsname, UPS_VERSION); return; } @@ -216,8 +214,27 @@ static void get_var(nut_ctype_t *client, const char *upsname, const char *var) sendback(client, "VAR %s %s \"%s\"\n", upsname, var, val); } -void net_get(nut_ctype_t *client, int numarg, const char **arg) +void net_get(nut_ctype_t *client, size_t numarg, const char **arg) { + if (numarg < 1) { + send_err(client, NUT_ERR_INVALID_ARGUMENT); + return; + } + + /* GET TRACKING [ID] */ + if (!strcasecmp(arg[0], "TRACKING")) { + if (numarg < 2) { + sendback(client, "%s\n", (client->tracking) ? "ON" : "OFF"); + } + else { + if (client->tracking) + sendback(client, "%s\n", tracking_get(arg[1])); + else + send_err(client, NUT_ERR_FEATURE_NOT_CONFIGURED); + } + return; + } + if (numarg < 2) { send_err(client, NUT_ERR_INVALID_ARGUMENT); return; diff --git a/server/netget.h b/server/netget.h index eb98b99..4ccfd7b 100644 --- a/server/netget.h +++ b/server/netget.h @@ -1,10 +1,37 @@ +/* netget.h - GET handlers for upsd + + Copyright (C) + 2003 Russell Kroll + 2005 Arnaud Quette + 2007 Peter Selinger + 2013 Emilien Kia + 2020 Jim Klimov + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef NUT_NETGET_H_SEEN +#define NUT_NETGET_H_SEEN 1 + #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { /* *INDENT-ON* */ #endif -void net_get(nut_ctype_t *client, int numarg, const char **arg); +void net_get(nut_ctype_t *client, size_t numarg, const char **arg); #ifdef __cplusplus /* *INDENT-OFF* */ @@ -12,3 +39,4 @@ void net_get(nut_ctype_t *client, int numarg, const char **arg); /* *INDENT-ON* */ #endif +#endif /* NUT_NETGET_H_SEEN */ diff --git a/server/netinstcmd.c b/server/netinstcmd.c index c21d7ec..00923c4 100644 --- a/server/netinstcmd.c +++ b/server/netinstcmd.c @@ -28,10 +28,10 @@ #include "netinstcmd.h" -static void send_instcmd(nut_ctype_t *client, const char *upsname, - const char *cmdname, const char *value) +static void send_instcmd(nut_ctype_t *client, const char *upsname, + const char *cmdname, const char *value, const char *tracking_id) { - int found; + int found, have_tracking_id = 0; upstype_t *ups; const cmdlist_t *ctmp; char sockcmd[SMALLBUF], esc[SMALLBUF]; @@ -70,20 +70,30 @@ static void send_instcmd(nut_ctype_t *client, const char *upsname, return; } + /* Format the base command */ + snprintf(sockcmd, sizeof(sockcmd), "INSTCMD %s", cmdname); + /* see if the user has also passed a value for this command */ - if (value != NULL) { - upslogx(LOG_INFO, "Instant command: %s@%s did %s with value \"%s\" on %s", - client->username, client->addr, cmdname, value, ups->name); + if (value != NULL) + snprintfcat(sockcmd, sizeof(sockcmd), " %s", pconf_encode(value, esc, sizeof(esc))); - snprintf(sockcmd, sizeof(sockcmd), "INSTCMD %s %s\n", - cmdname, pconf_encode(value, esc, sizeof(esc))); + /* see if the user want execution tracking for this command */ + if (tracking_id && *tracking_id) { + snprintfcat(sockcmd, sizeof(sockcmd), " TRACKING %s", tracking_id); + /* Add an entry in the tracking structure */ + tracking_add(tracking_id); + have_tracking_id = 1; } - else { - upslogx(LOG_INFO, "Instant command: %s@%s did %s on %s", - client->username, client->addr, cmdname, ups->name); - snprintf(sockcmd, sizeof(sockcmd), "INSTCMD %s\n", cmdname); - } + /* add EOL */ + snprintfcat(sockcmd, sizeof(sockcmd), "\n"); + + upslogx(LOG_INFO, "Instant command: %s@%s did %s%s%s on %s (tracking ID: %s)", + client->username, client->addr, cmdname, + (value != NULL)?" with value ":"", + (value != NULL)?value:"", + ups->name, + (have_tracking_id) ? tracking_id : "disabled"); if (!sstate_sendline(ups, sockcmd)) { upslogx(LOG_INFO, "Set command send failed"); @@ -91,18 +101,38 @@ static void send_instcmd(nut_ctype_t *client, const char *upsname, return; } - /* FIXME: need to retrieve the cookie number */ - sendback(client, "OK\n"); + /* return the result, possibly including tracking_id */ + if (have_tracking_id) + sendback(client, "OK TRACKING %s\n", tracking_id); + else + sendback(client, "OK\n"); } -void net_instcmd(nut_ctype_t *client, int numarg, const char **arg) +void net_instcmd(nut_ctype_t *client, size_t numarg, const char **arg) { + const char *devname = NULL; + const char *cmdname = NULL; + const char *cmdparam = NULL; + char tracking_id[UUID4_LEN] = ""; + if (numarg < 2) { send_err(client, NUT_ERR_INVALID_ARGUMENT); return; } - - /* INSTCMD []*/ - send_instcmd(client, arg[0], arg[1], (numarg == 3)?arg[2]:NULL); + + /* INSTCMD [cmdparam] */ + /* Check arguments */ + devname = arg[0]; + cmdname = arg[1]; + if (numarg == 3) + cmdparam = arg[2]; + + if (client->tracking) { + /* Generate a tracking ID, if client requested status tracking */ + nut_uuid_v4(tracking_id); + } + + send_instcmd(client, devname, cmdname, cmdparam, tracking_id); + return; } diff --git a/server/netinstcmd.h b/server/netinstcmd.h index d8ef7e2..2814ecb 100644 --- a/server/netinstcmd.h +++ b/server/netinstcmd.h @@ -1,10 +1,37 @@ +/* netinstcmd.h - network instand command definitions for NUT + + Copyright (C) + 2003 Russell Kroll + 2005 Arnaud Quette + 2007 Peter Selinger + 2013 Emilien Kia + 2020 Jim Klimov + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef NUT_NETINSTCMD_H_SEEN +#define NUT_NETINSTCMD_H_SEEN 1 + #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { /* *INDENT-ON* */ #endif -void net_instcmd(nut_ctype_t *client, int numarg, const char **arg); +void net_instcmd(nut_ctype_t *client, size_t numarg, const char **arg); #ifdef __cplusplus /* *INDENT-OFF* */ @@ -12,3 +39,4 @@ void net_instcmd(nut_ctype_t *client, int numarg, const char **arg); /* *INDENT-ON* */ #endif +#endif /* NUT_NETINSTCMD_H_SEEN */ diff --git a/server/netlist.c b/server/netlist.c index c226dc3..d480eb1 100644 --- a/server/netlist.c +++ b/server/netlist.c @@ -52,7 +52,7 @@ static int tree_dump(st_tree_t *node, nut_ctype_t *client, const char *ups, if (node->flags & ST_FLAG_RW) { ret = sendback(client, "RW %s %s \"%s\"\n", ups, node->var, node->val); - + } else { ret = 1; /* dummy */ } @@ -240,7 +240,7 @@ static void list_ups(nut_ctype_t *client) pconf_encode(utmp->desc, esc, sizeof(esc)); ret = sendback(client, "UPS %s \"%s\"\n", utmp->name, esc); - + } else { ret = sendback(client, "UPS %s \"Description unavailable\"\n", utmp->name); @@ -253,7 +253,7 @@ static void list_ups(nut_ctype_t *client) } sendback(client, "END LIST UPS\n"); -} +} static void list_clients(nut_ctype_t *client, const char *upsname) { @@ -285,7 +285,7 @@ static void list_clients(nut_ctype_t *client, const char *upsname) sendback(client, "END LIST CLIENT %s\n", upsname); } -void net_list(nut_ctype_t *client, int numarg, const char **arg) +void net_list(nut_ctype_t *client, size_t numarg, const char **arg) { if (numarg < 1) { send_err(client, NUT_ERR_INVALID_ARGUMENT); diff --git a/server/netlist.h b/server/netlist.h index 535af2a..072dc94 100644 --- a/server/netlist.h +++ b/server/netlist.h @@ -1,10 +1,37 @@ +/* netlist.h - LIST handlers for upsd + + Copyright (C) + 2003 Russell Kroll + 2005 Arnaud Quette + 2007 Peter Selinger + 2013 Emilien Kia + 2020 Jim Klimov + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef NUT_NETLIST_H_SEEN +#define NUT_NETLIST_H_SEEN 1 + #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { /* *INDENT-ON* */ #endif -void net_list(nut_ctype_t *client, int numarg, const char **arg); +void net_list(nut_ctype_t *client, size_t numarg, const char **arg); #ifdef __cplusplus /* *INDENT-OFF* */ @@ -12,3 +39,4 @@ void net_list(nut_ctype_t *client, int numarg, const char **arg); /* *INDENT-ON* */ #endif +#endif /* NUT_NETLIST_H_SEEN */ diff --git a/server/netmisc.c b/server/netmisc.c index 3863ae5..106d828 100644 --- a/server/netmisc.c +++ b/server/netmisc.c @@ -22,15 +22,16 @@ #include "common.h" #include "upsd.h" -#include "sstate.h" +#include "sstate.h" #include "state.h" #include "user.h" /* for user_checkaction */ #include "neterr.h" #include "netmisc.h" -void net_ver(nut_ctype_t *client, int numarg, const char **arg) +void net_ver(nut_ctype_t *client, size_t numarg, const char **arg) { + NUT_UNUSED_VARIABLE(arg); if (numarg != 0) { send_err(client, NUT_ERR_INVALID_ARGUMENT); return; @@ -40,8 +41,9 @@ void net_ver(nut_ctype_t *client, int numarg, const char **arg) UPS_VERSION); } -void net_netver(nut_ctype_t *client, int numarg, const char **arg) +void net_netver(nut_ctype_t *client, size_t numarg, const char **arg) { + NUT_UNUSED_VARIABLE(arg); if (numarg != 0) { send_err(client, NUT_ERR_INVALID_ARGUMENT); return; @@ -50,8 +52,9 @@ void net_netver(nut_ctype_t *client, int numarg, const char **arg) sendback(client, "%s\n", NUT_NETVERSION); } -void net_help(nut_ctype_t *client, int numarg, const char **arg) +void net_help(nut_ctype_t *client, size_t numarg, const char **arg) { + NUT_UNUSED_VARIABLE(arg); if (numarg != 0) { send_err(client, NUT_ERR_INVALID_ARGUMENT); return; @@ -61,7 +64,7 @@ void net_help(nut_ctype_t *client, int numarg, const char **arg) " USERNAME PASSWORD STARTTLS\n"); } -void net_fsd(nut_ctype_t *client, int numarg, const char **arg) +void net_fsd(nut_ctype_t *client, size_t numarg, const char **arg) { upstype_t *ups; @@ -77,13 +80,13 @@ void net_fsd(nut_ctype_t *client, int numarg, const char **arg) return; } - /* make sure this user is allowed to do FSD */ + /* make sure this user is allowed to do FSD */ if (!user_checkaction(client->username, client->password, "FSD")) { send_err(client, NUT_ERR_ACCESS_DENIED); return; } - upslogx(LOG_INFO, "Client %s@%s set FSD on UPS [%s]", + upslogx(LOG_INFO, "Client %s@%s set FSD on UPS [%s]", client->username, client->addr, ups->name); ups->fsd = 1; diff --git a/server/netmisc.h b/server/netmisc.h index 7e69c38..8513190 100644 --- a/server/netmisc.h +++ b/server/netmisc.h @@ -1,13 +1,40 @@ +/* netmisc.h - miscellaneous network handlers for upsd (VER, HELP, FSD) + + Copyright (C) + 2003 Russell Kroll + 2007 Peter Selinger + 2012 Arnaud Quette + 2013 Emilien Kia + 2020 Jim Klimov + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef NUT_NETMISC_H_SEEN +#define NUT_NETMISC_H_SEEN 1 + #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { /* *INDENT-ON* */ #endif -void net_ver(nut_ctype_t *client, int numarg, const char **arg); -void net_netver(nut_ctype_t *client, int numarg, const char **arg); -void net_help(nut_ctype_t *client, int numarg, const char **arg); -void net_fsd(nut_ctype_t *client, int numarg, const char **arg); +void net_ver(nut_ctype_t *client, size_t numarg, const char **arg); +void net_netver(nut_ctype_t *client, size_t numarg, const char **arg); +void net_help(nut_ctype_t *client, size_t numarg, const char **arg); +void net_fsd(nut_ctype_t *client, size_t numarg, const char **arg); #ifdef __cplusplus /* *INDENT-OFF* */ @@ -15,3 +42,4 @@ void net_fsd(nut_ctype_t *client, int numarg, const char **arg); /* *INDENT-ON* */ #endif +#endif /* NUT_NETMISC_H_SEEN */ diff --git a/server/netset.c b/server/netset.c index b88bb40..1e185b8 100644 --- a/server/netset.c +++ b/server/netset.c @@ -28,13 +28,14 @@ #include "netset.h" static void set_var(nut_ctype_t *client, const char *upsname, const char *var, - const char *newval) + const char *newval, const char *tracking_id) { upstype_t *ups; const char *val; const enum_t *etmp; const range_t *rtmp; char cmd[SMALLBUF], esc[SMALLBUF]; + int have_tracking_id = 0; ups = get_ups_ptr(upsname); @@ -68,7 +69,7 @@ static void set_var(nut_ctype_t *client, const char *upsname, const char *var, /* see if the new value is allowed for this variable */ if (sstate_getflags(ups, var) & ST_FLAG_STRING) { - int aux; + long aux; aux = sstate_getaux(ups, var); @@ -81,6 +82,10 @@ static void set_var(nut_ctype_t *client, const char *upsname, const char *var, return; } + /* FIXME? Should this cast to "long"? + * An int-size string is quite a lot already, + * even on architectures with a moderate INTMAX + */ if (aux < (int) strlen(newval)) { send_err(client, NUT_ERR_TOO_LONG); return; @@ -134,31 +139,92 @@ static void set_var(nut_ctype_t *client, const char *upsname, const char *var, /* must be OK now */ - upslogx(LOG_INFO, "Set variable: %s@%s set %s on %s to %s", - client->username, client->addr, var, ups->name, newval); - - snprintf(cmd, sizeof(cmd), "SET %s \"%s\"\n", + snprintf(cmd, sizeof(cmd), "SET %s \"%s\"", var, pconf_encode(newval, esc, sizeof(esc))); + /* see if the user want execution tracking for this command */ + if (tracking_id && *tracking_id) { + snprintfcat(cmd, sizeof(cmd), " TRACKING %s", tracking_id); + /* Add an entry in the tracking structure */ + tracking_add(tracking_id); + have_tracking_id = 1; + } + + /* add EOL */ + snprintfcat(cmd, sizeof(cmd), "\n"); + + upslogx(LOG_INFO, "Set variable: %s@%s set %s on %s to %s (tracking ID: %s)", + client->username, client->addr, var, ups->name, newval, + (have_tracking_id) ? tracking_id : "disabled"); + if (!sstate_sendline(ups, cmd)) { upslogx(LOG_INFO, "Set command send failed"); send_err(client, NUT_ERR_SET_FAILED); return; } - sendback(client, "OK\n"); + /* return the result, possibly including tracking_id */ + if (have_tracking_id) + sendback(client, "OK TRACKING %s\n", tracking_id); + else + sendback(client, "OK\n"); } -void net_set(nut_ctype_t *client, int numarg, const char **arg) +void net_set(nut_ctype_t *client, size_t numarg, const char **arg) { - if (numarg < 4) { + char tracking_id[UUID4_LEN] = ""; + + /* Base verification, to ensure that we have at least the SET parameter */ + if (numarg < 2) { send_err(client, NUT_ERR_INVALID_ARGUMENT); return; } /* SET VAR UPS VARNAME VALUE */ if (!strcasecmp(arg[0], "VAR")) { - set_var(client, arg[1], arg[2], arg[3]); + if (numarg < 4) { + send_err(client, NUT_ERR_INVALID_ARGUMENT); + return; + } + + if (client->tracking) { + /* Generate a tracking ID, if client requested status tracking */ + nut_uuid_v4(tracking_id); + } + + set_var(client, arg[1], arg[2], arg[3], tracking_id); + + return; + } + + /* SET TRACKING VALUE */ + if (!strcasecmp(arg[0], "TRACKING")) { + if (!strcasecmp(arg[1], "ON")) { + /* general enablement along with for this client */ + client->tracking = tracking_enable(); + } + else if (!strcasecmp(arg[1], "OFF")) { + /* disable status tracking for this client first */ + client->tracking = 0; + /* then only disable the general one if no other clients use it! + * Note: don't call tracking_free() since we want info to + * persist, and tracking_cleanup() takes care of cleaning */ + if (tracking_disable()) { + upsdebugx(2, "%s: TRACKING disabled for one client, more remain.", __func__); + } else { + upsdebugx(2, "%s: TRACKING disabled for last client.", __func__); + } + } + else { + send_err(client, NUT_ERR_INVALID_ARGUMENT); + return; + } + upsdebugx(1, "%s: TRACKING general %s, client %s.", __func__, + tracking_is_enabled() ? "enabled" : "disabled", + client->tracking ? "enabled" : "disabled"); + + sendback(client, "OK\n"); + return; } diff --git a/server/netset.h b/server/netset.h index afcde0f..1306126 100644 --- a/server/netset.h +++ b/server/netset.h @@ -1,10 +1,37 @@ +/* netset.h - SET handler for upsd + + Copyright (C) + 2003 Russell Kroll + 2005 Arnaud Quette + 2007 Peter Selinger + 2013 Emilien Kia + 2020 Jim Klimov + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef NUT_NETSET_H_SEEN +#define NUT_NETSET_H_SEEN 1 + #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { /* *INDENT-ON* */ #endif -void net_set(nut_ctype_t *client, int numarg, const char **arg); +void net_set(nut_ctype_t *client, size_t numarg, const char **arg); #ifdef __cplusplus /* *INDENT-OFF* */ @@ -12,3 +39,4 @@ void net_set(nut_ctype_t *client, int numarg, const char **arg); /* *INDENT-ON* */ #endif +#endif /* NUT_NETSET_H_SEEN */ diff --git a/server/netssl.c b/server/netssl.c index cbf0c7e..6360117 100644 --- a/server/netssl.c +++ b/server/netssl.c @@ -30,21 +30,35 @@ #include "upsd.h" #include "neterr.h" #include "netssl.h" +#include "nut_stdint.h" #ifdef WITH_NSS #include #include #include +#if defined(NSS_VMAJOR) && (NSS_VMAJOR > 3 || (NSS_VMAJOR == 3 && defined(NSS_VMINOR) && NSS_VMINOR >= 39)) + #include + #include +#else #include #include +#endif /* NSS before 3.39 */ #include #include + #include #endif /* WITH_NSS */ char *certfile = NULL; char *certname = NULL; char *certpasswd = NULL; +/* Warning: in this release of NUT, this feature is disabled by default + * in order to retain compatibility with "least surprise" for earlier + * existing deployments. Over time it can become enabled by default. + * See upsd.conf option DISABLE_WEAK_SSL to toggle this in-vivo. + */ +int disable_weak_ssl = 0; + #ifdef WITH_CLIENT_CERTIFICATE_VALIDATION int certrequest = 0; #endif /* WITH_CLIENT_CERTIFICATE_VALIDATION */ @@ -54,20 +68,32 @@ static int ssl_initialized = 0; #ifndef WITH_SSL /* stubs for non-ssl compiles */ -void net_starttls(nut_ctype_t *client, int numarg, const char **arg) +void net_starttls(nut_ctype_t *client, size_t numarg, const char **arg) { + NUT_UNUSED_VARIABLE(client); + NUT_UNUSED_VARIABLE(numarg); + NUT_UNUSED_VARIABLE(arg); + send_err(client, NUT_ERR_FEATURE_NOT_SUPPORTED); return; } -int ssl_write(nut_ctype_t *client, const char *buf, size_t buflen) +ssize_t ssl_write(nut_ctype_t *client, const char *buf, size_t buflen) { + NUT_UNUSED_VARIABLE(client); + NUT_UNUSED_VARIABLE(buf); + NUT_UNUSED_VARIABLE(buflen); + upslogx(LOG_ERR, "ssl_write called but SSL wasn't compiled in"); return -1; } -int ssl_read(nut_ctype_t *client, char *buf, size_t buflen) +ssize_t ssl_read(nut_ctype_t *client, char *buf, size_t buflen) { + NUT_UNUSED_VARIABLE(client); + NUT_UNUSED_VARIABLE(buf); + NUT_UNUSED_VARIABLE(buflen); + upslogx(LOG_ERR, "ssl_read called but SSL wasn't compiled in"); return -1; } @@ -96,7 +122,7 @@ static SSL_CTX *ssl_ctx = NULL; static void ssl_debug(void) { - int e; + unsigned long e; char errmsg[SMALLBUF]; while ((e = ERR_get_error()) != 0) { @@ -105,32 +131,36 @@ static void ssl_debug(void) } } -static int ssl_error(SSL *ssl, int ret) +static int ssl_error(SSL *ssl, ssize_t ret) { int e; - e = SSL_get_error(ssl, ret); + if (ret >= INT_MAX) { + upslogx(LOG_ERR, "ssl_error() ret=%zd would not fit in an int", ret); + return -1; + } + e = SSL_get_error(ssl, (int)ret); switch (e) { case SSL_ERROR_WANT_READ: - upsdebugx(1, "ssl_error() ret=%d SSL_ERROR_WANT_READ", ret); + upsdebugx(1, "ssl_error() ret=%zd SSL_ERROR_WANT_READ", ret); break; case SSL_ERROR_WANT_WRITE: - upsdebugx(1, "ssl_error() ret=%d SSL_ERROR_WANT_WRITE", ret); + upsdebugx(1, "ssl_error() ret=%zd SSL_ERROR_WANT_WRITE", ret); break; case SSL_ERROR_SYSCALL: if (ret == 0 && ERR_peek_error() == 0) { upsdebugx(1, "ssl_error() EOF from client"); } else { - upsdebugx(1, "ssl_error() ret=%d SSL_ERROR_SYSCALL", ret); + upsdebugx(1, "ssl_error() ret=%zd SSL_ERROR_SYSCALL", ret); } break; default: - upsdebugx(1, "ssl_error() ret=%d SSL_ERROR %d", ret, e); + upsdebugx(1, "ssl_error() ret=%zd SSL_ERROR %d", ret, e); ssl_debug(); } @@ -142,9 +172,11 @@ static int ssl_error(SSL *ssl, int ret) static CERTCertificate *cert; static SECKEYPrivateKey *privKey; -static char *nss_password_callback(PK11SlotInfo *slot, PRBool retry, +static char *nss_password_callback(PK11SlotInfo *slot, PRBool retry, void *arg) { + NUT_UNUSED_VARIABLE(arg); + if (retry) { /* Force not inted to retrieve password many times. */ return NULL; @@ -165,12 +197,14 @@ static void nss_error(const char* text) } } -static int ssl_error(PRFileDesc *ssl, int ret) +static int ssl_error(PRFileDesc *ssl, ssize_t ret) { char buffer[256]; PRInt32 length; PRErrorCode e; - + NUT_UNUSED_VARIABLE(ssl); + NUT_UNUSED_VARIABLE(ret); + e = PR_GetError(); length = PR_GetErrorText(buffer); if (length > 0 && length < 256) { @@ -195,13 +229,15 @@ static SECStatus AuthCertificate(CERTCertDBHandle *arg, PRFileDesc *fd, static SECStatus BadCertHandler(nut_ctype_t *arg, PRFileDesc *fd) { + NUT_UNUSED_VARIABLE(fd); + upslogx(LOG_WARNING, "Certificate validation failed for %s", (arg&&arg->addr)?arg->addr:""); #ifdef WITH_CLIENT_CERTIFICATE_VALIDATION /* BadCertHandler is called when the NSS certificate validation is failed. * If the certificate verification (user conf) is mandatory, reject authentication * else accept it. - */ + */ return certrequest==NETSSL_CERTREQ_REQUIRE?SECFailure:SECSuccess; #else /* WITH_CLIENT_CERTIFICATE_VALIDATION */ /* Always accept clients. */ @@ -211,6 +247,8 @@ static SECStatus BadCertHandler(nut_ctype_t *arg, PRFileDesc *fd) static void HandshakeCallback(PRFileDesc *fd, nut_ctype_t *client_data) { + NUT_UNUSED_VARIABLE(fd); + upslogx(LOG_INFO, "SSL handshake done successfully with client %s", client_data->addr); } @@ -218,7 +256,7 @@ static void HandshakeCallback(PRFileDesc *fd, nut_ctype_t *client_data) #endif /* WITH_OPENSSL | WITH_NSS */ -void net_starttls(nut_ctype_t *client, int numarg, const char **arg) +void net_starttls(nut_ctype_t *client, size_t numarg, const char **arg) { #ifdef WITH_OPENSSL int ret; @@ -226,7 +264,10 @@ void net_starttls(nut_ctype_t *client, int numarg, const char **arg) SECStatus status; PRFileDesc *socket; #endif /* WITH_OPENSSL | WITH_NSS */ - + + NUT_UNUSED_VARIABLE(numarg); + NUT_UNUSED_VARIABLE(arg); + if (client->ssl) { send_err(client, NUT_ERR_ALREADY_SSL_MODE); return; @@ -238,22 +279,23 @@ void net_starttls(nut_ctype_t *client, int numarg, const char **arg) send_err(client, NUT_ERR_FEATURE_NOT_CONFIGURED); return; } - -#ifdef WITH_OPENSSL - if (!ssl_ctx) { + +#ifdef WITH_OPENSSL + if (!ssl_ctx) #elif defined(WITH_NSS) /* WITH_OPENSSL */ - if (!NSS_IsInitialized()) { + if (!NSS_IsInitialized()) #endif /* WITH_OPENSSL | WITH_NSS */ + { send_err(client, NUT_ERR_FEATURE_NOT_CONFIGURED); ssl_initialized = 0; return; } - + if (!sendback(client, "OK STARTTLS\n")) { return; } -#ifdef WITH_OPENSSL +#ifdef WITH_OPENSSL client->ssl = SSL_new(ssl_ctx); @@ -268,15 +310,15 @@ void net_starttls(nut_ctype_t *client, int numarg, const char **arg) ssl_debug(); return; } - + ret = SSL_accept(client->ssl); switch (ret) { case 1: client->ssl_connected = 1; - upsdebugx(3, "SSL connected"); + upsdebugx(3, "SSL connected (%s)", SSL_get_version(client->ssl)); break; - + case 0: upslog_with_errno(LOG_ERR, "SSL_accept do not accept handshake."); ssl_error(client->ssl, ret); @@ -286,7 +328,7 @@ void net_starttls(nut_ctype_t *client, int numarg, const char **arg) ssl_error(client->ssl, ret); break; } - + #elif defined(WITH_NSS) /* WITH_OPENSSL */ socket = PR_ImportTCPSocket(client->sock_fd); @@ -302,13 +344,13 @@ void net_starttls(nut_ctype_t *client, int numarg, const char **arg) nss_error("net_starttls / SSL_ImportFD"); return; } - + if (SSL_SetPKCS11PinArg(client->ssl, client) == -1){ upslogx(LOG_ERR, "Can not inialize SSL connection"); nss_error("net_starttls / SSL_SetPKCS11PinArg"); return; } - + /* Note cast to SSLAuthCertificate to prevent warning due to * bad function prototype in NSS. */ @@ -318,21 +360,21 @@ void net_starttls(nut_ctype_t *client, int numarg, const char **arg) nss_error("net_starttls / SSL_AuthCertificateHook"); return; } - + status = SSL_BadCertHook(client->ssl, (SSLBadCertHandler)BadCertHandler, client); if (status != SECSuccess) { upslogx(LOG_ERR, "Can not inialize SSL connection"); nss_error("net_starttls / SSL_BadCertHook"); return; } - + status = SSL_HandshakeCallback(client->ssl, (SSLHandshakeCallback)HandshakeCallback, client); if (status != SECSuccess) { upslogx(LOG_ERR, "Can not inialize SSL connection"); nss_error("net_starttls / SSL_HandshakeCallback"); return; } - + status = SSL_ConfigSecureServer(client->ssl, cert, privKey, NSS_FindCertKEAType(cert)); if (status != SECSuccess) { upslogx(LOG_ERR, "Can not inialize SSL connection"); @@ -370,35 +412,53 @@ void ssl_init(void) { #ifdef WITH_NSS SECStatus status; -#elif defined(WITH_OPENSSL) -#if OPENSSL_VERSION_NUMBER >= 0x10000000L - const SSL_METHOD *ssl_method; -#else - SSL_METHOD *ssl_method; +#if defined(NSS_VMAJOR) && (NSS_VMAJOR > 3 || (NSS_VMAJOR == 3 && defined(NSS_VMINOR) && NSS_VMINOR >= 14)) + SSLVersionRange range; #endif -#endif /* WITH_NSS|WITH_OPENSSL */ +#endif /* WITH_NSS */ if (!certfile) { return; } check_perms(certfile); + if (!disable_weak_ssl) + upslogx(LOG_WARNING, "Warning: DISABLE_WEAK_SSL is not enabled. Please consider enabling to improve network security."); #ifdef WITH_OPENSSL +#if OPENSSL_VERSION_NUMBER < 0x10100000L SSL_load_error_strings(); SSL_library_init(); - if ((ssl_method = TLSv1_server_method()) == NULL) { - ssl_debug(); - fatalx(EXIT_FAILURE, "TLSv1_server_method failed"); - } + ssl_ctx = SSL_CTX_new(SSLv23_server_method()); +#else + ssl_ctx = SSL_CTX_new(TLS_server_method()); +#endif - if ((ssl_ctx = SSL_CTX_new(ssl_method)) == NULL) { + if (!ssl_ctx) { ssl_debug(); fatalx(EXIT_FAILURE, "SSL_CTX_new failed"); } + SSL_CTX_set_options(ssl_ctx, SSL_OP_CIPHER_SERVER_PREFERENCE); +#if OPENSSL_VERSION_NUMBER < 0x10100000L + /* set minimum protocol TLSv1 */ + SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3); + if (disable_weak_ssl) { +#if defined(SSL_OP_NO_TLSv1_2) + SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1); +#elif defined(SSL_OP_NO_TLSv1_1) + SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_TLSv1); +#endif + } +#else + if (SSL_CTX_set_min_proto_version(ssl_ctx, disable_weak_ssl ? TLS1_2_VERSION : TLS1_VERSION) != 1) { + ssl_debug(); + fatalx(EXIT_FAILURE, "SSL_CTX_set_min_proto_version(TLS1_VERSION)"); + } +#endif + if (SSL_CTX_use_certificate_chain_file(ssl_ctx, certfile) != 1) { ssl_debug(); fatalx(EXIT_FAILURE, "SSL_CTX_use_certificate_chain_file(%s) failed", certfile); @@ -422,7 +482,7 @@ void ssl_init(void) SSL_CTX_set_verify(ssl_ctx, SSL_VERIFY_NONE, NULL); ssl_initialized = 1; - + #elif defined(WITH_NSS) /* WITH_OPENSSL */ if (!certname || certname[0]==0 ) { @@ -431,9 +491,9 @@ void ssl_init(void) } PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); - + PK11_SetPasswordFunc(nss_password_callback); - + if (certfile) /* Note: this call can generate memory leaks not resolvable * by any release function. @@ -444,10 +504,10 @@ void ssl_init(void) status = NSS_NoDB_Init(NULL); if (status != SECSuccess) { upslogx(LOG_ERR, "Can not initialize SSL context"); - nss_error("upscli_init / NSS_[NoDB]_Init"); + nss_error("upscli_init / NSS_[NoDB]_Init"); return; } - + status = NSS_SetDomesticPolicy(); if (status != SECSuccess) { upslogx(LOG_ERR, "Can not initialize SSL policy"); @@ -462,18 +522,57 @@ void ssl_init(void) nss_error("upscli_init / SSL_ConfigServerSessionIDCache"); return; } - - status = SSL_OptionSetDefault(SSL_ENABLE_SSL3, PR_TRUE); - if (status != SECSuccess) { - upslogx(LOG_ERR, "Can not enable SSLv3"); - nss_error("upscli_init / SSL_OptionSetDefault(SSL_ENABLE_SSL3)"); - return; - } - status = SSL_OptionSetDefault(SSL_ENABLE_TLS, PR_TRUE); - if (status != SECSuccess) { - upslogx(LOG_ERR, "Can not enable TLSv1"); - nss_error("upscli_init / SSL_OptionSetDefault(SSL_ENABLE_TLS)"); - return; + + if (!disable_weak_ssl) { + status = SSL_OptionSetDefault(SSL_ENABLE_SSL3, PR_TRUE); + if (status != SECSuccess) { + upslogx(LOG_ERR, "Can not enable SSLv3"); + nss_error("upscli_init / SSL_OptionSetDefault(SSL_ENABLE_SSL3)"); + return; + } + status = SSL_OptionSetDefault(SSL_ENABLE_TLS, PR_TRUE); + if (status != SECSuccess) { + upslogx(LOG_ERR, "Can not enable TLSv1"); + nss_error("upscli_init / SSL_OptionSetDefault(SSL_ENABLE_TLS)"); + return; + } + } else { +#if defined(NSS_VMAJOR) && (NSS_VMAJOR > 3 || (NSS_VMAJOR == 3 && defined(NSS_VMINOR) && NSS_VMINOR >= 14)) + status = SSL_VersionRangeGetSupported(ssl_variant_stream, &range); + if (status != SECSuccess) { + upslogx(LOG_ERR, "Can not get versions supported"); + nss_error("upscli_init / SSL_VersionRangeGetSupported"); + return; + } + range.min = SSL_LIBRARY_VERSION_TLS_1_1; +#ifdef SSL_LIBRARY_VERSION_TLS_1_2 + range.min = SSL_LIBRARY_VERSION_TLS_1_2; +#endif + status = SSL_VersionRangeSetDefault(ssl_variant_stream, &range); + if (status != SECSuccess) { + upslogx(LOG_ERR, "Can not set versions supported"); + nss_error("upscli_init / SSL_VersionRangeSetDefault"); + return; + } + /* Disable old/weak ciphers */ + SSL_CipherPrefSetDefault(TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA, PR_FALSE); + SSL_CipherPrefSetDefault(TLS_RSA_WITH_3DES_EDE_CBC_SHA, PR_FALSE); + SSL_CipherPrefSetDefault(TLS_RSA_WITH_RC4_128_SHA, PR_FALSE); + SSL_CipherPrefSetDefault(TLS_RSA_WITH_RC4_128_MD5, PR_FALSE); +#else + status = SSL_OptionSetDefault(SSL_ENABLE_SSL3, PR_FALSE); + if (status != SECSuccess) { + upslogx(LOG_ERR, "Can not disable SSLv3"); + nss_error("upscli_init / SSL_OptionSetDefault(SSL_DISABLE_SSL3)"); + return; + } + status = SSL_OptionSetDefault(SSL_ENABLE_TLS, PR_TRUE); + if (status != SECSuccess) { + upslogx(LOG_ERR, "Can not enable TLSv1"); + nss_error("upscli_init / SSL_OptionSetDefault(SSL_ENABLE_TLS)"); + return; + } +#endif } #ifdef WITH_CLIENT_CERTIFICATE_VALIDATION @@ -483,7 +582,7 @@ void ssl_init(void) return; } - if (certrequest == NETSSL_CERTREQ_REQUEST || + if (certrequest == NETSSL_CERTREQ_REQUEST || certrequest == NETSSL_CERTREQ_REQUIRE ) { status = SSL_OptionSetDefault(SSL_REQUEST_CERTIFICATE, PR_TRUE); if (status != SECSuccess) { @@ -502,39 +601,59 @@ void ssl_init(void) } } #endif /* WITH_CLIENT_CERTIFICATE_VALIDATION */ - + cert = PK11_FindCertFromNickname(certname, NULL); if(cert==NULL) { upslogx(LOG_ERR, "Can not find server certificate"); nss_error("upscli_init / PK11_FindCertFromNickname"); return; } - + privKey = PK11_FindKeyByAnyCert(cert, NULL); if(privKey==NULL){ upslogx(LOG_ERR, "Can not find private key associate to server certificate"); nss_error("upscli_init / PK11_FindKeyByAnyCert"); return; } - + ssl_initialized = 1; #else /* WITH_OPENSSL | WITH_NSS */ upslogx(LOG_ERR, "ssl_init called but SSL wasn't compiled in"); #endif /* WITH_OPENSSL | WITH_NSS */ } -int ssl_read(nut_ctype_t *client, char *buf, size_t buflen) +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC) ) +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC +# pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif +ssize_t ssl_read(nut_ctype_t *client, char *buf, size_t buflen) { - int ret; + ssize_t ret = -1; if (!client->ssl_connected) { return -1; } #ifdef WITH_OPENSSL - ret = SSL_read(client->ssl, buf, buflen); + /* SSL_* routines deal with int type for return and buflen + * We might need to window our I/O if we exceed 2GB (in + * 32-bit builds)... Not likely to exceed in 64-bit builds, + * but smaller systems with 16-bits might be endangered :) + */ + assert(buflen <= INT_MAX); + int iret = SSL_read(client->ssl, buf, (int)buflen); + assert(iret <= SSIZE_MAX); + ret = (ssize_t)iret; #elif defined(WITH_NSS) /* WITH_OPENSSL */ - ret = PR_Read(client->ssl, buf, buflen); + /* PR_* routines deal in PRInt32 type + * We might need to window our I/O if we exceed 2GB :) */ + assert(buflen <= PR_INT32_MAX); + ret = PR_Read(client->ssl, buf, (PRInt32)buflen); #endif /* WITH_OPENSSL | WITH_NSS */ if (ret < 1) { @@ -545,24 +664,38 @@ int ssl_read(nut_ctype_t *client, char *buf, size_t buflen) return ret; } -int ssl_write(nut_ctype_t *client, const char *buf, size_t buflen) +ssize_t ssl_write(nut_ctype_t *client, const char *buf, size_t buflen) { - int ret; + ssize_t ret = -1; if (!client->ssl_connected) { return -1; } #ifdef WITH_OPENSSL - ret = SSL_write(client->ssl, buf, buflen); + /* SSL_* routines deal with int type for return and buflen + * We might need to window our I/O if we exceed 2GB (in + * 32-bit builds)... Not likely to exceed in 64-bit builds, + * but smaller systems with 16-bits might be endangered :) + */ + assert(buflen <= INT_MAX); + int iret = SSL_write(client->ssl, buf, (int)buflen); + assert(iret <= SSIZE_MAX); + ret = (ssize_t)iret; #elif defined(WITH_NSS) /* WITH_OPENSSL */ - ret = PR_Write(client->ssl, buf, buflen); + /* PR_* routines deal in PRInt32 type + * We might need to window our I/O if we exceed 2GB :) */ + assert(buflen <= PR_INT32_MAX); + ret = PR_Write(client->ssl, buf, (PRInt32)buflen); #endif /* WITH_OPENSSL | WITH_NSS */ - upsdebugx(5, "ssl_write ret=%d", ret); + upsdebugx(5, "ssl_write ret=%zd", ret); return ret; } +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP_BESIDEFUNC) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS_BESIDEFUNC) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE_BESIDEFUNC) ) +# pragma GCC diagnostic pop +#endif void ssl_finish(nut_ctype_t *client) { diff --git a/server/netssl.h b/server/netssl.h index 8f68168..1cff564 100644 --- a/server/netssl.h +++ b/server/netssl.h @@ -17,8 +17,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef NETSSL_H_SEEN -#define NETSSL_H_SEEN 1 +#ifndef NUT_NETSSL_H_SEEN +#define NUT_NETSSL_H_SEEN 1 #include "nut_ctype.h" @@ -31,6 +31,7 @@ extern "C" { extern char *certfile; extern char *certname; extern char *certpasswd; +extern int disable_weak_ssl; #ifdef WITH_CLIENT_CERTIFICATE_VALIDATION extern int certrequest; #endif /* WITH_CLIENT_CERTIFICATE_VALIDATION */ @@ -48,10 +49,10 @@ void ssl_init(void); void ssl_finish(nut_ctype_t *client); void ssl_cleanup(void); -int ssl_read(nut_ctype_t *client, char *buf, size_t buflen); -int ssl_write(nut_ctype_t *client, const char *buf, size_t buflen); +ssize_t ssl_read(nut_ctype_t *client, char *buf, size_t buflen); +ssize_t ssl_write(nut_ctype_t *client, const char *buf, size_t buflen); -void net_starttls(nut_ctype_t *client, int numarg, const char **arg); +void net_starttls(nut_ctype_t *client, size_t numarg, const char **arg); #ifdef __cplusplus /* *INDENT-OFF* */ @@ -59,4 +60,4 @@ void net_starttls(nut_ctype_t *client, int numarg, const char **arg); /* *INDENT-ON* */ #endif -#endif /* NETSSL_H_SEEN */ +#endif /* NUT_NETSSL_H_SEEN */ diff --git a/server/netuser.c b/server/netuser.c index 29c8596..6f4c677 100644 --- a/server/netuser.c +++ b/server/netuser.c @@ -1,4 +1,4 @@ -/* netuser.c - LOGIN/LOGOUT/USERNAME/PASSWORD/MASTER handlers for upsd +/* netuser.c - LOGIN/LOGOUT/USERNAME/PASSWORD/MASTER[PRIMARY] handlers for upsd Copyright (C) 2003 Russell Kroll @@ -28,7 +28,7 @@ #include "netuser.h" /* LOGIN */ -void net_login(nut_ctype_t *client, int numarg, const char **arg) +void net_login(nut_ctype_t *client, size_t numarg, const char **arg) { upstype_t *ups; @@ -53,6 +53,8 @@ void net_login(nut_ctype_t *client, int numarg, const char **arg) /* make sure this is a valid user */ if (!user_checkaction(client->username, client->password, "LOGIN")) { + upsdebugx(3, "%s: not a valid user: %s", + __func__, client->username); send_err(client, NUT_ERR_ACCESS_DENIED); return; } @@ -65,8 +67,9 @@ void net_login(nut_ctype_t *client, int numarg, const char **arg) sendback(client, "OK\n"); } -void net_logout(nut_ctype_t *client, int numarg, const char **arg) +void net_logout(nut_ctype_t *client, size_t numarg, const char **arg) { + NUT_UNUSED_VARIABLE(arg); if (numarg != 0) { send_err(client, NUT_ERR_INVALID_ARGUMENT); return; @@ -82,35 +85,64 @@ void net_logout(nut_ctype_t *client, int numarg, const char **arg) client->last_heard = 0; } -/* MASTER */ -void net_master(nut_ctype_t *client, int numarg, const char **arg) +/* NOTE: Protocol updated since NUT 2.8.0 to handle master/primary + * and API bumped, to rename/alias the routine. + */ +static int do_net_primary(nut_ctype_t *client, size_t numarg, const char **arg) { upstype_t *ups; if (numarg != 1) { send_err(client, NUT_ERR_INVALID_ARGUMENT); - return; + return -1; } ups = get_ups_ptr(arg[0]); if (!ups) { send_err(client, NUT_ERR_UNKNOWN_UPS); - return; + return -1; } - /* make sure this user is allowed to do MASTER */ - if (!user_checkaction(client->username, client->password, "MASTER")) { + /* make sure this user is allowed to do PRIMARY or MASTER */ + if (!user_checkaction(client->username, client->password, "PRIMARY") + && !user_checkaction(client->username, client->password, "MASTER") + ) { send_err(client, NUT_ERR_ACCESS_DENIED); - return; + return -1; } /* this is just an access level check */ - sendback(client, "OK MASTER-GRANTED\n"); + /* sendback() will be worded by caller below */ + return 0; +} + +/* MASTER (deprecated) */ +void net_master(nut_ctype_t *client, size_t numarg, const char **arg) { + /* Allow existing binaries linked against this file to still work */ + upsdebugx(1, + "WARNING: Client %s@%s " + "requested MASTER level for device %s - " + "which is deprecated in favor of PRIMARY " + "since NUT 2.8.0", + client->username, client->addr, + (numarg > 0) ? arg[0] : ""); + + if (0 == do_net_primary(client, numarg, arg)) { + sendback(client, "OK MASTER-GRANTED\n"); + } +} + +/* PRIMARY (since NUT 2.8.0) */ +void net_primary(nut_ctype_t *client, size_t numarg, const char **arg) +{ + if (0 == do_net_primary(client, numarg, arg)) { + sendback(client, "OK PRIMARY-GRANTED\n"); + } } /* USERNAME */ -void net_username(nut_ctype_t *client, int numarg, const char **arg) +void net_username(nut_ctype_t *client, size_t numarg, const char **arg) { if (numarg != 1) { send_err(client, NUT_ERR_INVALID_ARGUMENT); @@ -130,7 +162,7 @@ void net_username(nut_ctype_t *client, int numarg, const char **arg) } /* PASSWORD */ -void net_password(nut_ctype_t *client, int numarg, const char **arg) +void net_password(nut_ctype_t *client, size_t numarg, const char **arg) { if (numarg != 1) { send_err(client, NUT_ERR_INVALID_ARGUMENT); diff --git a/server/netuser.h b/server/netuser.h index af227b9..7532b3c 100644 --- a/server/netuser.h +++ b/server/netuser.h @@ -1,14 +1,48 @@ +/* netuser.c - LOGIN/LOGOUT/USERNAME/PASSWORD/MASTER[PRIMARY] handlers for upsd + + Copyright (C) + 2003 Russell Kroll + 2005 Arnaud Quette + 2007 Peter Selinger + 2013 Emilien Kia + 2020-2021 Jim Klimov + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef NUT_NETUSER_H_SEEN +#define NUT_NETUSER_H_SEEN 1 + #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { /* *INDENT-ON* */ #endif -void net_login(nut_ctype_t *client, int numarg, const char **arg); -void net_logout(nut_ctype_t *client, int numarg, const char **arg); -void net_master(nut_ctype_t *client, int numarg, const char **arg); -void net_username(nut_ctype_t *client, int numarg, const char **arg); -void net_password(nut_ctype_t *client, int numarg, const char **arg); +void net_login(nut_ctype_t *client, size_t numarg, const char **arg); +void net_logout(nut_ctype_t *client, size_t numarg, const char **arg); + +/* NOTE: Since NUT 2.8.0 we handle master as alias for primary + * Header keyword kept for building older consumers, but + * the implementation will warn that it is deprecated. + */ +void net_master(nut_ctype_t *client, size_t numarg, const char **arg); +void net_primary(nut_ctype_t *client, size_t numarg, const char **arg); + +void net_username(nut_ctype_t *client, size_t numarg, const char **arg); +void net_password(nut_ctype_t *client, size_t numarg, const char **arg); #ifdef __cplusplus /* *INDENT-OFF* */ @@ -16,3 +50,4 @@ void net_password(nut_ctype_t *client, int numarg, const char **arg); /* *INDENT-ON* */ #endif +#endif /* NUT_NETUSER_H_SEEN */ diff --git a/server/nut_ctype.h b/server/nut_ctype.h index c2302aa..db9f4df 100644 --- a/server/nut_ctype.h +++ b/server/nut_ctype.h @@ -4,6 +4,8 @@ 2002 Russell Kroll 2008 Arjen de Korte 2011 Arnaud Quette + 2013 Emilien Kia + 2020 Jim Klimov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,6 +39,12 @@ #include "parseconf.h" +#ifdef __cplusplus +/* *INDENT-OFF* */ +extern "C" { +/* *INDENT-ON* */ +#endif + /* client structure */ typedef struct nut_ctype_s { char *addr; @@ -45,6 +53,9 @@ typedef struct nut_ctype_s { char *loginups; char *password; char *username; + /* per client status info for commands and settings + * (disabled by default) */ + int tracking; #ifdef WITH_OPENSSL SSL *ssl; @@ -62,4 +73,10 @@ typedef struct nut_ctype_s { struct nut_ctype_s *next; } nut_ctype_t; +#ifdef __cplusplus +/* *INDENT-OFF* */ +} +/* *INDENT-ON* */ +#endif + #endif /* NUT_CTYPE_H_SEEN */ diff --git a/server/sockdebug.c b/server/sockdebug.c index 7829292..f9fe476 100644 --- a/server/sockdebug.c +++ b/server/sockdebug.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -31,11 +31,11 @@ PCONF_CTX_t sock_ctx; -static void sock_arg(int numarg, char **arg) +static void sock_arg(size_t numarg, char **arg) { - int i; + size_t i; - printf("numarg=%d : ", numarg); + printf("numarg=%zu : ", numarg); for (i = 0; i < numarg; i++) printf("[%s] ", arg[i]); @@ -48,6 +48,8 @@ static int socket_connect(const char *sockfn) int ret, fd; struct sockaddr_un sa; + check_unix_socket_filename(sockfn); + memset(&sa, '\0', sizeof(sa)); sa.sun_family = AF_UNIX; snprintf(sa.sun_path, sizeof(sa.sun_path), "%s", sockfn); @@ -98,7 +100,7 @@ static void read_sock(int fd) } if (ret < 0) { - perror("read sockfd"); + perror("read sockfd"); exit(EXIT_FAILURE); } diff --git a/server/sstate.c b/server/sstate.c index 15d2c14..167bc09 100644 --- a/server/sstate.c +++ b/server/sstate.c @@ -25,7 +25,9 @@ #include "timehead.h" #include "sstate.h" +#include "upsd.h" #include "upstype.h" +#include "nut_stdint.h" #include #include @@ -33,9 +35,9 @@ #include #include #include -#include +#include -static int parse_args(upstype_t *ups, int numargs, char **arg) +static int parse_args(upstype_t *ups, size_t numargs, char **arg) { if (numargs < 1) return 0; @@ -104,48 +106,63 @@ static int parse_args(upstype_t *ups, int numargs, char **arg) return 1; } - /* ADDRANGE */ - if (!strcasecmp(arg[0], "ADDRANGE")) { - state_addrange(ups->inforoot, arg[1], atoi(arg[2]), atoi(arg[3])); - return 1; - } - /* DELENUM */ if (!strcasecmp(arg[0], "DELENUM")) { state_delenum(ups->inforoot, arg[1], arg[2]); return 1; } - /* DELRANGE */ - if (!strcasecmp(arg[0], "DELRANGE")) { - state_delrange(ups->inforoot, arg[1], atoi(arg[2]), atoi(arg[3])); - return 1; - } - /* SETAUX */ if (!strcasecmp(arg[0], "SETAUX")) { state_setaux(ups->inforoot, arg[1], arg[2]); return 1; } + /* TRACKING */ + if (!strcasecmp(arg[0], "TRACKING")) { + tracking_set(arg[1], arg[2]); + upsdebugx(1, "TRACKING: ID %s status %s", arg[1], arg[2]); + + /* log actual result of instcmd / setvar */ + if (strncmp(arg[2], "PENDING", 7) != 0) { + upslogx(LOG_INFO, "tracking ID: %s\tresult: %s", arg[1], tracking_get(arg[1])); + } + return 1; + } + + if (numargs < 4) + return 0; + + /* ADDRANGE */ + if (!strcasecmp(arg[0], "ADDRANGE")) { + state_addrange(ups->inforoot, arg[1], atoi(arg[2]), atoi(arg[3])); + return 1; + } + + /* DELRANGE */ + if (!strcasecmp(arg[0], "DELRANGE")) { + state_delrange(ups->inforoot, arg[1], atoi(arg[2]), atoi(arg[3])); + return 1; + } + return 0; } /* nothing fancy - just make the driver say something back to us */ static void sendping(upstype_t *ups) { - int ret; + ssize_t ret; const char *cmd = "PING\n"; + size_t cmdlen = strlen(cmd); if ((!ups) || (ups->sock_fd < 0)) { return; } upsdebugx(3, "Pinging UPS [%s]", ups->name); + ret = write(ups->sock_fd, cmd, cmdlen); - ret = write(ups->sock_fd, cmd, strlen(cmd)); - - if (ret != (int)strlen(cmd)) { + if ((ret < 1) || (ret != (ssize_t)cmdlen)) { upslog_with_errno(LOG_NOTICE, "Send ping to UPS [%s] failed", ups->name); sstate_disconnect(ups); return; @@ -158,10 +175,14 @@ static void sendping(upstype_t *ups) int sstate_connect(upstype_t *ups) { - int ret, fd; + int fd; const char *dumpcmd = "DUMPALL\n"; + size_t dumpcmdlen = strlen(dumpcmd); + ssize_t ret; struct sockaddr_un sa; + check_unix_socket_filename(ups->fn); + memset(&sa, '\0', sizeof(sa)); sa.sun_family = AF_UNIX; snprintf(sa.sun_path, sizeof(sa.sun_path), "%s", ups->fn); @@ -186,7 +207,7 @@ int sstate_connect(upstype_t *ups) return -1; ups->last_connfail = now; - upslog_with_errno(LOG_ERR, "Can't connect to UPS [%s] (%s)", + upslog_with_errno(LOG_ERR, "Can't connect to UPS [%s] (%s)", ups->name, ups->fn); return -1; @@ -209,9 +230,9 @@ int sstate_connect(upstype_t *ups) } /* get a dump started so we have a fresh set of data */ - ret = write(fd, dumpcmd, strlen(dumpcmd)); + ret = write(fd, dumpcmd, dumpcmdlen); - if (ret != (int)strlen(dumpcmd)) { + if ((ret < 1) || (ret != (ssize_t)dumpcmdlen)) { upslog_with_errno(LOG_ERR, "Initial write to UPS [%s] failed", ups->name); close(fd); return -1; @@ -250,7 +271,7 @@ void sstate_disconnect(upstype_t *ups) void sstate_readline(upstype_t *ups) { - int i, ret; + ssize_t i, ret; char buf[SMALLBUF]; if ((!ups) || (ups->sock_fd < 0)) { @@ -280,7 +301,7 @@ void sstate_readline(upstype_t *ups) case 1: /* set the 'last heard' time to now for later staleness checks */ if (parse_args(ups, ups->sock_ctx.numargs, ups->sock_ctx.arglist)) { - time(&ups->last_heard); + time(&ups->last_heard); } continue; @@ -303,12 +324,12 @@ const char *sstate_getinfo(const upstype_t *ups, const char *var) int sstate_getflags(const upstype_t *ups, const char *var) { return state_getflags(ups->inforoot, var); -} +} -int sstate_getaux(const upstype_t *ups, const char *var) +long sstate_getaux(const upstype_t *ups, const char *var) { return state_getaux(ups->inforoot, var); -} +} const enum_t *sstate_getenumlist(const upstype_t *ups, const char *var) { @@ -325,7 +346,7 @@ const cmdlist_t *sstate_getcmdlist(const upstype_t *ups) return ups->cmdlist; } -int sstate_dead(upstype_t *ups, int maxage) +int sstate_dead(upstype_t *ups, int arg_maxage) { time_t now; double elapsed; @@ -347,12 +368,12 @@ int sstate_dead(upstype_t *ups, int maxage) elapsed = difftime(now, ups->last_heard); /* somewhere beyond a third of the maximum time - prod it to make it talk */ - if ((elapsed > (maxage / 3)) && (difftime(now, ups->last_ping) > (maxage / 3))) + if ((elapsed > (arg_maxage / 3)) && (difftime(now, ups->last_ping) > (arg_maxage / 3))) sendping(ups); - if (elapsed > maxage) { + if (elapsed > arg_maxage) { upsdebugx(3, "sstate_dead: didn't hear from driver for UPS [%s] for %g seconds (max %d)", - ups->name, elapsed, maxage); + ups->name, elapsed, arg_maxage); return 1; /* dead */ } @@ -376,16 +397,24 @@ void sstate_cmdfree(upstype_t *ups) int sstate_sendline(upstype_t *ups, const char *buf) { - int ret; + ssize_t ret; + size_t buflen; if ((!ups) ||(ups->sock_fd < 0)) { return 0; /* failed */ } - ret = write(ups->sock_fd, buf, strlen(buf)); + buflen = strlen(buf); + if (buflen >= SSIZE_MAX) { + /* Can't compare buflen to ret... */ + upslog_with_errno(LOG_NOTICE, "Send ping to UPS [%s] failed: buffered message too large", ups->name); + return 0; /* failed */ + } - if (ret == (int)strlen(buf)) { - return 1; + ret = write(ups->sock_fd, buf, buflen); + + if (ret == (ssize_t)buflen) { + return 1; } upslog_with_errno(LOG_NOTICE, "Send to UPS [%s] failed", ups->name); diff --git a/server/sstate.h b/server/sstate.h index fe8485c..7a7fff6 100644 --- a/server/sstate.h +++ b/server/sstate.h @@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef SSTATE_H_SEEN -#define SSTATE_H_SEEN +#ifndef NUT_SSTATE_H_SEEN +#define NUT_SSTATE_H_SEEN 1 #include "state.h" #include "upstype.h" @@ -40,7 +40,7 @@ void sstate_disconnect(upstype_t *ups); void sstate_readline(upstype_t *ups); const char *sstate_getinfo(const upstype_t *ups, const char *var); int sstate_getflags(const upstype_t *ups, const char *var); -int sstate_getaux(const upstype_t *ups, const char *var); +long sstate_getaux(const upstype_t *ups, const char *var); const enum_t *sstate_getenumlist(const upstype_t *ups, const char *var); const range_t *sstate_getrangelist(const upstype_t *ups, const char *var); const cmdlist_t *sstate_getcmdlist(const upstype_t *ups); @@ -59,4 +59,4 @@ const st_tree_t *sstate_getnode(const upstype_t *ups, const char *varname); /* *INDENT-ON* */ #endif -#endif /* SSTATE_H_SEEN */ +#endif /* NUT_SSTATE_H_SEEN */ diff --git a/server/stype.h b/server/stype.h index c143018..54e5ff2 100644 --- a/server/stype.h +++ b/server/stype.h @@ -18,8 +18,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef STYPE_H_SEEN -#define STYPE_H_SEEN 1 +#ifndef NUT_STYPE_H_SEEN +#define NUT_STYPE_H_SEEN 1 #include @@ -50,4 +50,4 @@ typedef struct stype_s { /* *INDENT-ON* */ #endif -#endif /* STYPE_H_SEEN */ +#endif /* NUT_STYPE_H_SEEN */ diff --git a/server/upsd.c b/server/upsd.c index c6efb21..6299150 100644 --- a/server/upsd.c +++ b/server/upsd.c @@ -1,9 +1,10 @@ -/* upsd.c - watches ups state files and answers queries +/* upsd.c - watches ups state files and answers queries Copyright (C) 1999 Russell Kroll 2008 Arjen de Korte 2011 - 2012 Arnaud Quette + 2019 Eaton (author: Arnaud Quette ) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,6 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "config.h" /* must be the first header */ + #include "upsd.h" #include "upstype.h" #include "conf.h" @@ -30,10 +33,17 @@ #include #include #include -#include + +#ifdef HAVE_SYS_SIGNAL_H +#include +#endif +#ifdef HAVE_SIGNAL_H +#include +#endif #include "user.h" #include "nut_ctype.h" +#include "nut_stdint.h" #include "stype.h" #include "netssl.h" #include "sstate.h" @@ -46,29 +56,38 @@ int allow_severity = LOG_INFO; int deny_severity = LOG_WARNING; #endif /* HAVE_WRAP */ - /* externally-visible settings and pointers */ +/* externally-visible settings and pointers */ - upstype_t *firstups = NULL; +upstype_t *firstups = NULL; - /* default 15 seconds before data is marked stale */ - int maxage = 15; +/* default 15 seconds before data is marked stale */ +int maxage = 15; - /* preloaded to {OPEN_MAX} in main, can be overridden via upsd.conf */ - int maxconn = 0; +/* default to 1h before cleaning up status tracking entries */ +int tracking_delay = 3600; - /* preloaded to STATEPATH in main, can be overridden via upsd.conf */ - char *statepath = NULL; +/* + * Preloaded to ALLOW_NO_DEVICE from upsd.conf or environment variable + * (with higher prio for envvar); defaults to disabled for legacy compat. + */ +int allow_no_device = 0; - /* preloaded to DATADIR in main, can be overridden via upsd.conf */ - char *datapath = NULL; +/* preloaded to {OPEN_MAX} in main, can be overridden via upsd.conf */ +nfds_t maxconn = 0; - /* everything else */ - const char *progname; +/* preloaded to STATEPATH in main, can be overridden via upsd.conf */ +char *statepath = NULL; + +/* preloaded to DATADIR in main, can be overridden via upsd.conf */ +char *datapath = NULL; + +/* everything else */ +static const char *progname; nut_ctype_t *firstclient = NULL; /* static nut_ctype_t *lastclient = NULL; */ - /* default is to listen on all local interfaces */ +/* default is to listen on all local interfaces */ static stype_t *firstaddr = NULL; static int opt_af = AF_UNSPEC; @@ -84,6 +103,28 @@ typedef struct { void *data; } handler_t; + +/* Commands and settings status tracking */ + +/* general enable/disable status info for commands and settings + * (disabled by default) + * Note that only client that requested it will have it enabled + * (see nut_ctype.h) */ +static int tracking_enabled = 0; + +/* Commands and settings status tracking structure */ +typedef struct tracking_s { + char *id; + int status; + time_t request_time; /* for cleanup */ + /* doubly linked list */ + struct tracking_s *prev; + struct tracking_s *next; +} tracking_t; + +static tracking_t *tracking_list = NULL; + + /* pollfd */ static struct pollfd *fds = NULL; static handler_t *handler = NULL; @@ -94,6 +135,11 @@ static char pidfn[SMALLBUF]; /* set by signal handlers */ static int reload_flag = 0, exit_flag = 0; +/* Minimalistic support for UUID v4 */ +/* Ref: RFC 4122 https://tools.ietf.org/html/rfc4122#section-4.1.2 */ +#define UUID4_BYTESIZE 16 + + static const char *inet_ntopW (struct sockaddr_storage *s) { static char str[40]; @@ -204,7 +250,7 @@ static void setuptcp(stype_t *server) upsdebug_with_errno(3, "setuptcp: socket"); continue; } - + if (setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof(one)) != 0) { fatal_with_errno(EXIT_FAILURE, "setuptcp: setsockopt"); } @@ -308,12 +354,15 @@ static void client_disconnect(nut_ctype_t *client) return; } -/* send the buffer of length to host */ +/* send the buffer of length to host + * returns effectively a boolean: 0 = failed, 1 = sent ok + */ int sendback(nut_ctype_t *client, const char *fmt, ...) { - int res, len; - char ans[NUT_NET_ANSWER_MAX+1]; - va_list ap; + ssize_t res; + size_t len; + char ans[NUT_NET_ANSWER_MAX+1]; + va_list ap; if (!client) { return 0; @@ -325,18 +374,23 @@ int sendback(nut_ctype_t *client, const char *fmt, ...) len = strlen(ans); + /* System write() and our ssl_write() have a loophole that they write a + * size_t amount of bytes and upon success return that in ssize_t value + */ + assert(len < SSIZE_MAX); + #ifdef WITH_SSL if (client->ssl) { res = ssl_write(client, ans, len); - } else + } else #endif /* WITH_SSL */ { res = write(client->sock_fd, ans, len); } - upsdebugx(2, "write: [destfd=%d] [len=%d] [%s]", client->sock_fd, len, str_rtrim(ans, '\n')); + upsdebugx(2, "write: [destfd=%d] [len=%zu] [%s]", client->sock_fd, len, str_rtrim(ans, '\n')); - if (len != res) { + if (res < 0 || len != (size_t)res) { upslog_with_errno(LOG_NOTICE, "write() failed for %s", client->addr); client->last_heard = 0; return 0; /* failed */ @@ -396,20 +450,25 @@ int ups_available(const upstype_t *ups, nut_ctype_t *client) } /* check flags and access for an incoming command from the network */ -static void check_command(int cmdnum, nut_ctype_t *client, int numarg, +static void check_command(int cmdnum, nut_ctype_t *client, size_t numarg, const char **arg) { + upsdebugx(6, "Entering %s: %s", __func__, numarg > 0 ? arg[0] : "<>"); + if (netcmds[cmdnum].flags & FLAG_USER) { + /* command requires previous authentication */ #ifdef HAVE_WRAP struct request_info req; #endif /* HAVE_WRAP */ if (!client->username) { + upsdebugx(1, "%s: client not logged in yet", __func__); send_err(client, NUT_ERR_USERNAME_REQUIRED); return; } if (!client->password) { + upsdebugx(1, "%s: client not logged in yet", __func__); send_err(client, NUT_ERR_PASSWORD_REQUIRED); return; } @@ -419,15 +478,20 @@ static void check_command(int cmdnum, nut_ctype_t *client, int numarg, fromhost(&req); if (!hosts_access(&req)) { - /* tcp-wrappers says access should be denied */ + upsdebugx(1, + "%s: while authenticating %s found that " + "tcp-wrappers says access should be denied", + __func__, client->username); send_err(client, NUT_ERR_ACCESS_DENIED); return; } #endif /* HAVE_WRAP */ } + upsdebugx(6, "%s: Calling command handler for %s", __func__, numarg > 0 ? arg[0] : "<>"); + /* looks good - call the command */ - netcmds[cmdnum].func(client, numarg - 1, &arg[1]); + netcmds[cmdnum].func(client, (numarg < 2) ? 0 : (numarg - 1), (numarg > 1) ? &arg[1] : NULL); } /* parse requests from the network */ @@ -457,7 +521,7 @@ static void parse_net(nut_ctype_t *client) static void client_connect(stype_t *server) { struct sockaddr_storage csock; -#if defined(__hpux) && !defined(_XOPEN_SOURCE_EXTENDED) +#if defined(__hpux) && !defined(_XOPEN_SOURCE_EXTENDED) int clen; #else socklen_t clen; @@ -480,6 +544,8 @@ static void client_connect(stype_t *server) client->addr = xstrdup(inet_ntopW(&csock)); + client->tracking = 0; + pconf_init(&client->ctx, NULL); if (firstclient) { @@ -504,12 +570,13 @@ static void client_connect(stype_t *server) static void client_readline(nut_ctype_t *client) { char buf[SMALLBUF]; - int i, ret; + int i; + ssize_t ret; #ifdef WITH_SSL if (client->ssl) { ret = ssl_read(client, buf, sizeof(buf)); - } else + } else #endif /* WITH_SSL */ { ret = read(client->sock_fd, buf, sizeof(buf)); @@ -569,7 +636,7 @@ void server_load(void) for (server = firstaddr; server; server = server->next) { setuptcp(server); } - + /* check if we have at least 1 valid LISTEN interface */ if (firstaddr->sock_fd < 0) { fatalx(EXIT_FAILURE, "no listening interface available"); @@ -607,11 +674,14 @@ static void client_free(void) } } -void driver_free(void) +static void driver_free(void) { upstype_t *ups, *unext; for (ups = firstups; ups; ups = unext) { + upsdebugx(1, "%s: forgetting UPS [%s] (FD %d)", + __func__, ups->name, ups->sock_fd); + unext = ups->next; if (ups->sock_fd != -1) { @@ -640,10 +710,11 @@ static void upsd_cleanup(void) user_flush(); desc_free(); - + server_free(); client_free(); driver_free(); + tracking_free(); free(statepath); free(datapath); @@ -655,27 +726,256 @@ static void upsd_cleanup(void) free(handler); } -void poll_reload(void) +static void poll_reload(void) { - int ret; + long ret; ret = sysconf(_SC_OPEN_MAX); - if (ret < maxconn) { + if ((intmax_t)ret < (intmax_t)maxconn) { fatalx(EXIT_FAILURE, - "Your system limits the maximum number of connections to %d\n" - "but you requested %d. The server won't start until this\n" - "problem is resolved.\n", ret, maxconn); + "Your system limits the maximum number of connections to %ld\n" + "but you requested %jd. The server won't start until this\n" + "problem is resolved.\n", ret, (intmax_t)maxconn); } - fds = xrealloc(fds, maxconn * sizeof(*fds)); - handler = xrealloc(handler, maxconn * sizeof(*handler)); + if (1 > maxconn) { + fatalx(EXIT_FAILURE, + "You requested %jd as maximum number of connections.\n" + "The server won't start until this problem is resolved.\n", (intmax_t)maxconn); + } + + /* How many items can we stuff into the array? */ + size_t maxalloc = SIZE_MAX / sizeof(void *); + if ((uintmax_t)maxalloc < (uintmax_t)maxconn) { + fatalx(EXIT_FAILURE, + "You requested %jd as maximum number of connections, but we can only allocate %zu.\n" + "The server won't start until this problem is resolved.\n", (intmax_t)maxconn, maxalloc); + } + + /* The checks above effectively limit that maxconn is in size_t range */ + fds = xrealloc(fds, (size_t)maxconn * sizeof(*fds)); + handler = xrealloc(handler, (size_t)maxconn * sizeof(*handler)); +} + +/* instant command and setvar status tracking */ + +/* allocate a new status tracking entry */ +int tracking_add(const char *id) +{ + tracking_t *item; + + if ((!tracking_enabled) || (!id)) + return 0; + + item = xcalloc(1, sizeof(*item)); + + item->id = xstrdup(id); + item->status = STAT_PENDING; + time(&item->request_time); + + if (tracking_list) { + tracking_list->prev = item; + item->next = tracking_list; + } + + tracking_list = item; + + return 1; +} + +/* set status of a specific tracking entry */ +int tracking_set(const char *id, const char *value) +{ + tracking_t *item, *next_item; + + /* sanity checks */ + if ((!tracking_list) || (!id) || (!value)) + return 0; + + for (item = tracking_list; item; item = next_item) { + + next_item = item->next; + + if (!strcasecmp(item->id, id)) { + item->status = atoi(value); + return 1; + } + } + + return 0; /* id not found! */ +} + +/* free a specific tracking entry */ +int tracking_del(const char *id) +{ + tracking_t *item, *next_item; + + /* sanity check */ + if ((!tracking_list) || (!id)) + return 0; + + upsdebugx(3, "%s: deleting id %s", __func__, id); + + for (item = tracking_list; item; item = next_item) { + + next_item = item->next; + + if (strcasecmp(item->id, id)) + continue; + + if (item->prev) + item->prev->next = item->next; + else + /* deleting first entry */ + tracking_list = item->next; + + if (item->next) + item->next->prev = item->prev; + + free(item->id); + free(item); + + return 1; + + } + + return 0; /* id not found! */ +} + +/* free all status tracking entries */ +void tracking_free(void) +{ + tracking_t *item, *next_item; + + /* sanity check */ + if (!tracking_list) + return; + + upsdebugx(3, "%s", __func__); + + for (item = tracking_list; item; item = next_item) { + next_item = item->next; + tracking_del(item->id); + } +} + +/* cleanup status tracking entries according to their age and tracking_delay */ +void tracking_cleanup(void) +{ + tracking_t *item, *next_item; + time_t now; + + /* sanity check */ + if (!tracking_list) + return; + + time(&now); + + upsdebugx(3, "%s", __func__); + + for (item = tracking_list; item; item = next_item) { + + next_item = item->next; + + if (difftime(now, item->request_time) > tracking_delay) { + tracking_del(item->id); + } + } +} + +/* get status of a specific tracking entry */ +char *tracking_get(const char *id) +{ + tracking_t *item, *next_item; + + /* sanity checks */ + if ((!tracking_list) || (!id)) + return "ERR UNKNOWN"; + + for (item = tracking_list; item; item = next_item) { + + next_item = item->next; + + if (strcasecmp(item->id, id)) + continue; + + switch (item->status) + { + case STAT_PENDING: + return "PENDING"; + case STAT_HANDLED: + return "SUCCESS"; + case STAT_UNKNOWN: + return "ERR UNKNOWN"; + case STAT_INVALID: + return "ERR INVALID-ARGUMENT"; + case STAT_FAILED: + return "ERR FAILED"; + } + } + + return "ERR UNKNOWN"; /* id not found! */ +} + +/* enable general status tracking (tracking_enabled) and return its value (1). */ +int tracking_enable(void) +{ + tracking_enabled = 1; + + return tracking_enabled; +} + +/* disable general status tracking only if no client use it anymore. + * return the new value for tracking_enabled */ +int tracking_disable(void) +{ + nut_ctype_t *client, *cnext; + + for (client = firstclient; client; client = cnext) { + cnext = client->next; + if (client->tracking == 1) + return 1; + } + return 0; +} + +/* return current general status of tracking (tracking_enabled). */ +int tracking_is_enabled(void) +{ + return tracking_enabled; +} + +/* UUID v4 basic implementation + * Note: 'dest' must be at least `UUID4_LEN` long */ +int nut_uuid_v4(char *uuid_str) +{ + size_t i; + uint8_t nut_uuid[UUID4_BYTESIZE]; + + if (!uuid_str) + return 0; + + for (i = 0; i < UUID4_BYTESIZE; i++) + nut_uuid[i] = (uint8_t)rand() + (uint8_t)rand(); + + /* set variant and version */ + nut_uuid[6] = (nut_uuid[6] & 0x0F) | 0x40; + nut_uuid[8] = (nut_uuid[8] & 0x3F) | 0x80; + + return snprintf(uuid_str, UUID4_LEN, + "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X", + nut_uuid[0], nut_uuid[1], nut_uuid[2], nut_uuid[3], + nut_uuid[4], nut_uuid[5], nut_uuid[6], nut_uuid[7], + nut_uuid[8], nut_uuid[9], nut_uuid[10], nut_uuid[11], + nut_uuid[12], nut_uuid[13], nut_uuid[14], nut_uuid[15]); } /* service requests and check on new data */ static void mainloop(void) { - int i, ret, nfds = 0; + int ret; + nfds_t i, nfds = 0; upstype_t *ups; nut_ctype_t *client, *cnext; @@ -690,12 +990,19 @@ static void mainloop(void) reload_flag = 0; } + /* cleanup instcmd/setvar status tracking entries if needed */ + tracking_cleanup(); + /* scan through driver sockets */ for (ups = firstups; ups && (nfds < maxconn); ups = ups->next) { /* see if we need to (re)connect to the socket */ if (ups->sock_fd < 0) { + upsdebugx(1, "%s: UPS [%s] is not currently connected", + __func__, ups->name); ups->sock_fd = sstate_connect(ups); + upsdebugx(1, "%s: UPS [%s] is now connected as FD %d", + __func__, ups->name, ups->sock_fd); continue; } @@ -722,6 +1029,7 @@ static void mainloop(void) if (difftime(now, client->last_heard) > 60) { /* shed clients after 1 minute of inactivity */ + /* FIXME: create an upsd.conf parameter (CLIENT_INACTIVITY_DELAY) */ client_disconnect(client); continue; } @@ -756,7 +1064,7 @@ static void mainloop(void) nfds++; } - upsdebugx(2, "%s: polling %d filedescriptors", __func__, nfds); + upsdebugx(2, "%s: polling %jd filedescriptors", __func__, (intmax_t)nfds); ret = poll(fds, nfds, 2000); @@ -785,9 +1093,36 @@ static void mainloop(void) case SERVER: upsdebugx(2, "%s: server disconnected", __func__); break; + +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) ) +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT +# pragma GCC diagnostic ignored "-Wcovered-switch-default" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +# pragma GCC diagnostic ignored "-Wunreachable-code" +#endif +/* Older CLANG (e.g. clang-3.4) seems to not support the GCC pragmas above */ +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcovered-switch-default" +#pragma clang diagnostic ignored "-Wunreachable-code" +#endif + /* All enum cases defined as of the time of coding + * have been covered above. Handle later definitions, + * memory corruptions and buggy inputs below... + */ default: upsdebugx(2, "%s: disconnected", __func__); break; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) ) +# pragma GCC diagnostic pop +#endif + } continue; @@ -806,9 +1141,35 @@ static void mainloop(void) case SERVER: client_connect((stype_t *)handler[i].data); break; + +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) ) +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT +# pragma GCC diagnostic ignored "-Wcovered-switch-default" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +# pragma GCC diagnostic ignored "-Wunreachable-code" +#endif +/* Older CLANG (e.g. clang-3.4) seems to not support the GCC pragmas above */ +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcovered-switch-default" +#pragma clang diagnostic ignored "-Wunreachable-code" +#endif + /* All enum cases defined as of the time of coding + * have been covered above. Handle later definitions, + * memory corruptions and buggy inputs below... + */ default: upsdebugx(2, "%s: has data available", __func__); break; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_COVERED_SWITCH_DEFAULT) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE) ) +# pragma GCC diagnostic pop +#endif } continue; @@ -816,17 +1177,24 @@ static void mainloop(void) } } -static void help(const char *progname) +static void help(const char *arg_progname) + __attribute__((noreturn)); + +static void help(const char *arg_progname) { printf("Network server for UPS data.\n\n"); - printf("usage: %s [OPTIONS]\n", progname); + printf("usage: %s [OPTIONS]\n", arg_progname); printf("\n"); printf(" -c send via signal to background process\n"); printf(" commands:\n"); printf(" - reload: reread configuration files\n"); printf(" - stop: stop process and exit\n"); - printf(" -D raise debugging level\n"); + printf(" -P send the signal above to specified PID (bypassing PID file)\n"); + printf(" -D raise debugging level (and stay foreground by default)\n"); + printf(" -F stay foregrounded even if no debugging is enabled\n"); + printf(" -FF stay foregrounded and still save the PID file\n"); + printf(" -B stay backgrounded even if debugging is bumped\n"); printf(" -h display this help\n"); printf(" -r chroots to \n"); printf(" -q raise log level threshold\n"); @@ -840,6 +1208,7 @@ static void help(const char *progname) static void set_reload_flag(int sig) { + NUT_UNUSED_VARIABLE(sig); reload_flag = 1; } @@ -857,7 +1226,14 @@ static void setup_signals(void) sa.sa_flags = 0; /* basic signal setup to ignore SIGPIPE */ +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wstrict-prototypes" +#endif sa.sa_handler = SIG_IGN; +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES) +# pragma GCC diagnostic pop +#endif sigaction(SIGPIPE, &sa, NULL); /* handle shutdown signals */ @@ -890,10 +1266,11 @@ void check_perms(const char *fn) int main(int argc, char **argv) { - int i, cmd = 0; + int i, cmd = 0, cmdret = 0, foreground = -1; char *chroot_path = NULL; const char *user = RUN_AS_USER; struct passwd *new_uid = NULL; + pid_t oldpid = -1; progname = xbasename(argv[0]); @@ -906,25 +1283,29 @@ int main(int argc, char **argv) printf("Network UPS Tools %s %s\n", progname, UPS_VERSION); - while ((i = getopt(argc, argv, "+h46p:qr:i:fu:Vc:D")) != -1) { + while ((i = getopt(argc, argv, "+h46p:qr:i:fu:Vc:P:DFB")) != -1) { switch (i) { - case 'h': - help(progname); - break; case 'p': case 'i': fatalx(EXIT_FAILURE, "Specifying a listening addresses with '-i
' and '-p '\n" "is deprecated. Use 'LISTEN
[]' in 'upsd.conf' instead.\n" "See 'man 8 upsd.conf' for more information."); +#ifndef HAVE___ATTRIBUTE__NORETURN + exit(EXIT_FAILURE); /* Should not get here in practice, but compiler is afraid we can fall through */ +#endif + case 'q': nut_log_level++; break; + case 'r': chroot_path = optarg; break; + case 'u': user = optarg; break; + case 'V': /* do nothing - we already printed the banner */ exit(EXIT_SUCCESS); @@ -940,9 +1321,25 @@ int main(int argc, char **argv) help(progname); break; + case 'P': + if ((oldpid = parsepid(optarg)) < 0) + help(progname); + break; + case 'D': nut_debug_level++; break; + case 'F': + if (foreground > 0) { + /* specified twice to save PID file anyway */ + foreground = 2; + } else { + foreground = 1; + } + break; + case 'B': + foreground = 0; + break; case '4': opt_af = AF_INET; @@ -952,24 +1349,56 @@ int main(int argc, char **argv) opt_af = AF_INET6; break; + case 'h': default: help(progname); - break; + } + } + + if (foreground < 0) { + if (nut_debug_level > 0) { + foreground = 1; + } else { + foreground = 0; } } if (cmd) { - sendsignalfn(pidfn, cmd); - exit(EXIT_SUCCESS); + if (oldpid < 0) { + cmdret = sendsignalfn(pidfn, cmd); + } else { + cmdret = sendsignalpid(oldpid, cmd); + } + exit((cmdret == 0)?EXIT_SUCCESS:EXIT_FAILURE); } /* otherwise, we are being asked to start. * so check if a previous instance is running by sending signal '0' * (Ie 'kill 0') */ - if (sendsignalfn(pidfn, 0) == 0) { + if (oldpid < 0) { + cmdret = sendsignalfn(pidfn, 0); + } else { + cmdret = sendsignalpid(oldpid, 0); + } + switch (cmdret) { + case 0: printf("Fatal error: A previous upsd instance is already running!\n"); printf("Either stop the previous instance first, or use the 'reload' command.\n"); exit(EXIT_FAILURE); + + case -3: + case -2: + upslogx(LOG_WARNING, "Could not %s PID file '%s' " + "to see if previous upsd instance is " + "already running!\n", + (cmdret == -3 ? "find" : "parse"), + pidfn); + break; + + case -1: + default: + /* Just failed to send signal, no competitor running */ + break; } argc -= optind; @@ -995,12 +1424,43 @@ int main(int argc, char **argv) chroot_start(chroot_path); } - /* default to system limit (may be overridden in upsd.conf */ - maxconn = sysconf(_SC_OPEN_MAX); + /* default to system limit (may be overridden in upsd.conf) */ + /* FIXME: Check for overflows (and int size of nfds_t vs. long) - see get_max_pid_t() for example */ + maxconn = (nfds_t)sysconf(_SC_OPEN_MAX); /* handle upsd.conf */ load_upsdconf(0); /* 0 = initial */ + /* CLI debug level can not be smaller than debug_min specified + * in upsd.conf. Note that non-zero debug_min does not impact + * foreground running mode. + */ + if (nut_debug_level_global > nut_debug_level) + nut_debug_level = nut_debug_level_global; + upsdebugx(1, "debug level is '%d'", nut_debug_level); + + { /* scope */ + /* As documented above, the ALLOW_NO_DEVICE can be provided via + * envvars and then has higher priority than an upsd.conf setting + */ + const char *envvar = getenv("ALLOW_NO_DEVICE"); + if ( envvar != NULL) { + if ( (!strncasecmp("TRUE", envvar, 4)) || (!strncasecmp("YES", envvar, 3)) || (!strncasecmp("ON", envvar, 2)) || (!strncasecmp("1", envvar, 1)) ) { + /* Admins of this server expressed a desire to serve + * anything on the NUT protocol, even if nothing is + * configured yet - tell the clients so, properly. + */ + allow_no_device = 1; + } else if ( (!strncasecmp("FALSE", envvar, 5)) || (!strncasecmp("NO", envvar, 2)) || (!strncasecmp("OFF", envvar, 3)) || (!strncasecmp("0", envvar, 1)) ) { + /* Admins of this server expressed a desire to serve + * anything on the NUT protocol, even if nothing is + * configured yet - tell the clients so, properly. + */ + allow_no_device = 0; + } + } + } /* scope */ + /* start server */ server_load(); @@ -1019,7 +1479,11 @@ int main(int argc, char **argv) poll_reload(); if (num_ups == 0) { - fatalx(EXIT_FAILURE, "Fatal error: at least one UPS must be defined in ups.conf"); + if (allow_no_device) { + upslogx(LOG_WARNING, "Normally at least one UPS must be defined in ups.conf, currently there are none (please configure the file and reload the service)"); + } else { + fatalx(EXIT_FAILURE, "Fatal error: at least one UPS must be defined in ups.conf"); + } } /* try to bring in the var/cmd descriptions */ @@ -1028,11 +1492,17 @@ int main(int argc, char **argv) /* handle upsd.users */ user_load(); - if (!nut_debug_level) { + if (!foreground) { background(); writepid(pidfn); } else { - memset(pidfn, 0, sizeof(pidfn)); + if (foreground == 2) { + upslogx(LOG_WARNING, "Running as foreground process, but saving a PID file anyway"); + writepid(pidfn); + } else { + upslogx(LOG_WARNING, "Running as foreground process, not saving a PID file"); + memset(pidfn, 0, sizeof(pidfn)); + } } /* initialize SSL (keyfile must be readable by nut user) */ diff --git a/server/upsd.h b/server/upsd.h index 2b3a3a7..1380188 100644 --- a/server/upsd.h +++ b/server/upsd.h @@ -38,6 +38,7 @@ #include "timehead.h" #include +#include /* nfds_t */ #include "parseconf.h" #include "nut_ctype.h" @@ -68,9 +69,30 @@ void server_free(void); void check_perms(const char *fn); -/* declarations from upsd.c */ +/* return values for instcmd / setvar status tracking, + * mapped on drivers/upshandler.h, apart from STAT_PENDING (initial state) */ +enum { + STAT_PENDING = -1, /* not yet completed */ + STAT_HANDLED = 0, /* completed successfully (NUT_SUCCESS or "OK") */ + STAT_UNKNOWN, /* unspecified error (NUT_ERR_UNKNOWN) */ + STAT_INVALID, /* invalid command/setvar (NUT_ERR_INVALID_ARGUMENT) */ + STAT_FAILED /* command/setvar failed (NUT_ERR_INSTCMD_FAILED / NUT_ERR_SET_FAILED) */ +}; -extern int maxage, maxconn; +/* Commands and settings status tracking functions */ +int tracking_add(const char *id); +int tracking_set(const char *id, const char *value); +int tracking_del(const char *id); +void tracking_free(void); +void tracking_cleanup(void); +char *tracking_get(const char *id); +int tracking_enable(void); +int tracking_disable(void); +int tracking_is_enabled(void); + +/* declarations from upsd.c */ +extern int maxage, tracking_delay, allow_no_device; +extern nfds_t maxconn; extern char *statepath, *datapath; extern upstype_t *firstups; extern nut_ctype_t *firstclient; @@ -91,6 +113,10 @@ extern nut_ctype_t *firstclient; #define shutdown_how 2 #endif +/* UUID v4 generation function + * Note: 'dest' must be at least `UUID4_LEN` long */ +int nut_uuid_v4(char *uuid_str); + #ifdef __cplusplus /* *INDENT-OFF* */ } diff --git a/server/upstype.h b/server/upstype.h index bbadd50..bc03187 100644 --- a/server/upstype.h +++ b/server/upstype.h @@ -19,8 +19,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef UPSTYPE_H_SEEN -#define UPSTYPE_H_SEEN 1 +#ifndef NUT_UPSTYPE_H_SEEN +#define NUT_UPSTYPE_H_SEEN 1 #include "parseconf.h" @@ -51,7 +51,7 @@ typedef struct upstype_s { int fsd; /* forced shutdown in effect? */ int retain; - + struct upstype_s *next; } upstype_t; @@ -64,4 +64,4 @@ extern upstype_t *firstups; /* *INDENT-ON* */ #endif -#endif /* UPSTYPE_H_SEEN */ +#endif /* NUT_UPSTYPE_H_SEEN */ diff --git a/server/user-data.h b/server/user-data.h index 5cc1e99..d5da7b4 100644 --- a/server/user-data.h +++ b/server/user-data.h @@ -1,6 +1,11 @@ /* user-data.h - structures for user.c Copyright (C) 2001 Russell Kroll + 2005 Arnaud Quette + 2007 Peter Selinger + 2008 Arjen de Korte + 2013 Emilien Kia + 2020 Jim Klimov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,6 +22,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef NUT_USERDATA_H_SEEN +#define NUT_USERDATA_H_SEEN 1 + #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { @@ -47,3 +55,4 @@ typedef struct { /* *INDENT-ON* */ #endif +#endif /* NUT_USERDATA_H_SEEN */ diff --git a/server/user.c b/server/user.c index 8eff8a0..b0c985b 100644 --- a/server/user.c +++ b/server/user.c @@ -17,6 +17,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "config.h" /* must be the first header */ + #include #include #include @@ -28,9 +30,9 @@ #include "user.h" #include "user-data.h" - ulist_t *users = NULL; +static ulist_t *users = NULL; - static ulist_t *curr_user; +static ulist_t *curr_user; /* create a new user entry */ static void user_add(const char *un) @@ -57,7 +59,7 @@ static void user_add(const char *un) if (last) { last->next = tmp; } else { - users = tmp; + users = tmp; } /* remember who we're working on */ @@ -78,7 +80,7 @@ static void user_password(const char *pw) } if (curr_user->password) { - fprintf(stderr, "Ignoring duplicate password for %s\n", + fprintf(stderr, "Ignoring duplicate password for %s\n", curr_user->username); return; } @@ -317,19 +319,20 @@ int user_checkaction(const char *un, const char *pw, const char *action) return 0; /* fail */ } -/* handle "upsmon master" and "upsmon slave" for nicer configurations */ +/* handle "upsmon primary" and "upsmon secondary" for nicer configurations */ +/* FIXME: Protocol update needed to handle master/primary alias (in action and in protocol) */ static void set_upsmon_type(char *type) { - /* master: login, master, fsd */ - if (!strcasecmp(type, "master")) { + /* primary: login, master, fsd */ + if (!strcasecmp(type, "master") || !strcasecmp(type, "primary")) { user_add_action("login"); - user_add_action("master"); + user_add_action("master"); /* Note: this is linked to "MASTER" API command permission */ user_add_action("fsd"); return; } - /* slave: just login */ - if (!strcasecmp(type, "slave")) { + /* secondary: just login */ + if (!strcasecmp(type, "slave") || !strcasecmp(type, "secondary")) { user_add_action("login"); return; } @@ -370,9 +373,9 @@ static void parse_var(char *var, char *val) } /* parse first var+val pair, then flip through remaining vals */ -static void parse_rest(char *var, char *fval, char **arg, int next, int left) +static void parse_rest(char *var, char *fval, char **arg, size_t next, size_t left) { - int i; + size_t i; /* no globals supported yet, so there's no sense in continuing */ if (!curr_user) { @@ -390,7 +393,7 @@ static void parse_rest(char *var, char *fval, char **arg, int next, int left) } } -static void user_parse_arg(int numargs, char **arg) +static void user_parse_arg(size_t numargs, char **arg) { char *ep; @@ -414,7 +417,7 @@ static void user_parse_arg(int numargs, char **arg) /* 0 1 2 ... */ /* foo=bar ... */ - parse_rest(arg[0], ep+1, arg, 1, numargs - 1); + parse_rest(arg[0], ep+1, arg, 1, (numargs < 2) ? 0 : (numargs - 1)); return; } @@ -447,8 +450,8 @@ static void user_parse_arg(int numargs, char **arg) /* foo = bar ... */ /* parse first var/val, plus subsequent values (if any) */ - - parse_rest(arg[0], arg[2], arg, 3, numargs - 3); + + parse_rest(arg[0], arg[2], arg, 3, (numargs < 4) ? 0 : (numargs - 3)); return; } diff --git a/server/user.h b/server/user.h index 48b7004..613a0c5 100644 --- a/server/user.h +++ b/server/user.h @@ -1,6 +1,11 @@ /* user.c - supporting elements of user handling functions for upsd Copyright (C) 2001 Russell Kroll + 2005 Arnaud Quette + 2007 Peter Selinger + 2008 Arjen de Korte + 2013 Emilien Kia + 2020 Jim Klimov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,6 +22,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef NUT_USER_H_SEEN +#define NUT_USER_H_SEEN 1 + #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { @@ -39,3 +47,4 @@ void check_perms(const char *fn); /* *INDENT-ON* */ #endif +#endif /* NUT_USER_H_SEEN */ diff --git a/test-driver b/test-driver index d306056..9759384 100755 --- a/test-driver +++ b/test-driver @@ -1,9 +1,9 @@ #! /bin/sh # test-driver - basic testsuite driver script. -scriptversion=2013-07-13.22; # UTC +scriptversion=2018-03-07.03; # UTC -# Copyright (C) 2011-2013 Free Software Foundation, Inc. +# Copyright (C) 2011-2020 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ scriptversion=2013-07-13.22; # UTC # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -42,11 +42,13 @@ print_usage () { cat <$log_file 2>&1 estatus=$? + if test $enable_hard_errors = no && test $estatus -eq 99; then - estatus=1 + tweaked_estatus=1 +else + tweaked_estatus=$estatus fi -case $estatus:$expect_failure in +case $tweaked_estatus:$expect_failure in 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;; 0:*) col=$grn res=PASS recheck=no gcopy=no;; 77:*) col=$blu res=SKIP recheck=no gcopy=yes;; @@ -119,6 +124,12 @@ case $estatus:$expect_failure in *:*) col=$red res=FAIL recheck=yes gcopy=yes;; esac +# Report the test outcome and exit status in the logs, so that one can +# know whether the test passed or failed simply by looking at the '.log' +# file, without the need of also peaking into the corresponding '.trs' +# file (automake bug#11814). +echo "$res $test_name (exit status: $estatus)" >>$log_file + # Report outcome to console. echo "${col}${res}${std}: $test_name" @@ -131,9 +142,9 @@ echo ":copy-in-global-log: $gcopy" >> $trs_file # Local Variables: # mode: shell-script # sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: diff --git a/tests/Makefile.am b/tests/Makefile.am index 3960ad8..e9cfd70 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,21 +1,117 @@ # Network UPS Tools: tests -if HAVE_CPPUNIT +SUBDIRS = . NIT -TESTS = cppunittest +all: $(TESTS) + +EXTRA_DIST = nut-driver-enumerator-test.sh nut-driver-enumerator-test--ups.conf + +TESTS = nutlogtest +CLEANFILES = *.trs *.log + +AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/drivers +AM_CXXFLAGS = -I$(top_srcdir)/include check_PROGRAMS = $(TESTS) -cppunittest_CXXFLAGS = $(CPPUNIT_CFLAGS) -cppunittest_LDFLAGS = $(CPPUNIT_LIBS) +# NUT Integration Testing suite +check-NIT check-NIT-devel: + cd "$(builddir)/NIT" && $(MAKE) $@ +nutlogtest_SOURCES = nutlogtest.c +nutlogtest_LDADD = $(top_builddir)/common/libcommon.la + +# Separate the .deps of other dirs from this one +LINKED_SOURCE_FILES = hidparser.c + +# NOTE: Not using "$<" due to a legacy Sun/illumos dmake bug with resolver +# of dynamic vars, see e.g. https://man.omnios.org/man1/make#BUGS +hidparser.c: $(top_srcdir)/drivers/hidparser.c + test -s "$@" || ln -s -f "$(top_srcdir)/drivers/hidparser.c" "$@" + +if WITH_USB +TESTS += getvaluetest + +getvaluetest_SOURCES = getvaluetest.c +nodist_getvaluetest_SOURCES = hidparser.c +# Pull the right include path for chosen libusb version: +getvaluetest_CFLAGS = $(AM_CFLAGS) $(LIBUSB_CFLAGS) +getvaluetest_LDADD = $(top_builddir)/common/libcommon.la +endif + +# Make sure out-of-dir dependencies exist (especially when dev-building parts): +$(top_builddir)/common/libcommon.la: dummy + @cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F) + +### Optional tests which can not be built everywhere # List of src files for CppUnit tests -CPPUNITTESTSRC = example.cpp +CPPUNITTESTSRC = example.cpp nutclienttest.cpp +# The test driver which orchestrates running those tests above +CPPUNITTESTERSRC = cpputest.cpp -cppunittest_SOURCES = $(CPPUNITTESTSRC) cpputest.cpp +CPPCLIENTTESTSRC = cpputest-client.cpp + +TESTS_CXX11 = cppunittest + +if HAVE_CXX11 +if HAVE_CPPUNIT +# Note: per configure script this "SHOULD" also assume +# that we HAVE_CXX11 - but better have it explicit + +TESTS += $(TESTS_CXX11) + +# Note: we only build it, but do not run directly (NIT prepares the sandbox) +check_PROGRAMS += cppnit + +if WITH_VALGRIND +check-local: $(check_PROGRAMS) + RES=0; for P in $^ ; do $(VALGRIND) ./$$P || { RES=$$? ; echo "FAILED: $(VALGRIND) ./$$P" >&2; }; done; exit $$RES +endif + +cppunittest_CXXFLAGS = $(AM_CXXFLAGS) $(CPPUNIT_CFLAGS) $(CPPUNIT_CXXFLAGS) $(CPPUNIT_NUT_CXXFLAGS) $(CXXFLAGS) +cppunittest_LDFLAGS = $(CPPUNIT_LDFLAGS) $(CPPUNIT_LIBS) +cppunittest_LDADD = $(top_builddir)/clients/libnutclient.la $(top_builddir)/clients/libnutclientstub.la +cppunittest_SOURCES = $(CPPUNITTESTSRC) $(CPPUNITTESTERSRC) + +cppnit_CXXFLAGS = $(AM_CXXFLAGS) $(CPPUNIT_CFLAGS) $(CPPUNIT_CXXFLAGS) $(CPPUNIT_NUT_CXXFLAGS) $(CXXFLAGS) +cppnit_LDFLAGS = $(CPPUNIT_LDFLAGS) $(CPPUNIT_LIBS) +cppnit_LDADD = $(top_builddir)/clients/libnutclient.la $(top_builddir)/clients/libnutclientstub.la +cppnit_SOURCES = $(CPPCLIENTTESTSRC) $(CPPUNITTESTERSRC) + +# Make sure out-of-dir C++ dependencies exist (especially when dev-building +# only some parts of NUT): +$(top_builddir)/clients/libnutclient.la \ +$(top_builddir)/clients/libnutclientstub.la: dummy + @cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F) else !HAVE_CPPUNIT +# Just redistribute test source into tarball if not building tests -EXTRA_DIST = example.cpp cpputest.cpp +EXTRA_DIST += $(CPPUNITTESTSRC) $(CPPCLIENTTESTSRC) $(CPPUNITTESTERSRC) + +cppnit: + @echo "SKIP: $@ not implemented without C++11 and CPPUNIT enabled" >&2 ; exit 1 endif !HAVE_CPPUNIT + +else !HAVE_CXX11 +# Just redistribute test source into tarball if not building C++ at all + +EXTRA_DIST += $(CPPUNITTESTSRC) $(CPPCLIENTTESTSRC) $(CPPUNITTESTERSRC) + +cppnit: + @echo "SKIP: $@ not implemented without C++11 and CPPUNIT enabled" >&2 ; exit 1 + +endif !HAVE_CXX11 + +dummy: + +BUILT_SOURCES = $(LINKED_SOURCE_FILES) +CLEANFILES += $(LINKED_SOURCE_FILES) +CLEANFILES += $(TESTS) $(TESTS_CXX11) +MAINTAINERCLEANFILES = Makefile.in .dirstamp + +# NOTE: Do not clean ".deps" in SUBDIRS of the main project, +# the root Makefile.am takes care of that! +#clean-local: +# rm -rf $(builddir)/.deps diff --git a/tests/Makefile.in b/tests/Makefile.in index 5991274..25d882b 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.16.3 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -16,7 +16,17 @@ # Network UPS Tools: tests VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -80,22 +90,41 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ -@HAVE_CPPUNIT_TRUE@TESTS = cppunittest$(EXEEXT) -@HAVE_CPPUNIT_TRUE@check_PROGRAMS = $(am__EXEEXT_1) +TESTS = nutlogtest$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_3) +check_PROGRAMS = $(am__EXEEXT_4) $(am__EXEEXT_5) +@WITH_USB_TRUE@am__append_1 = getvaluetest + +# Note: per configure script this "SHOULD" also assume +# that we HAVE_CXX11 - but better have it explicit +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@am__append_2 = $(TESTS_CXX11) + +# Note: we only build it, but do not run directly (NIT prepares the sandbox) +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@am__append_3 = cppnit + +# Just redistribute test source into tarball if not building tests +@HAVE_CPPUNIT_FALSE@@HAVE_CXX11_TRUE@am__append_4 = $(CPPUNITTESTSRC) $(CPPCLIENTTESTSRC) $(CPPUNITTESTERSRC) + +# Just redistribute test source into tarball if not building C++ at all +@HAVE_CXX11_FALSE@am__append_5 = $(CPPUNITTESTSRC) $(CPPCLIENTTESTSRC) $(CPPUNITTESTERSRC) subdir = tests -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(top_srcdir)/depcomp $(top_srcdir)/test-driver ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nut_arg_with.m4 \ $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ $(top_srcdir)/m4/nut_check_libavahi.m4 \ $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ $(top_srcdir)/m4/nut_check_libgd.m4 \ $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ $(top_srcdir)/m4/nut_check_libneon.m4 \ $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ $(top_srcdir)/m4/nut_check_libnss.m4 \ @@ -104,29 +133,71 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ $(top_srcdir)/m4/nut_check_libusb.m4 \ $(top_srcdir)/m4/nut_check_libwrap.m4 \ $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ $(top_srcdir)/m4/nut_type_socklen_t.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = -@HAVE_CPPUNIT_TRUE@am__EXEEXT_1 = cppunittest$(EXEEXT) -am__cppunittest_SOURCES_DIST = example.cpp cpputest.cpp -@HAVE_CPPUNIT_TRUE@am__objects_1 = cppunittest-example.$(OBJEXT) -@HAVE_CPPUNIT_TRUE@am_cppunittest_OBJECTS = $(am__objects_1) \ -@HAVE_CPPUNIT_TRUE@ cppunittest-cpputest.$(OBJEXT) -cppunittest_OBJECTS = $(am_cppunittest_OBJECTS) -cppunittest_LDADD = $(LDADD) +@WITH_USB_TRUE@am__EXEEXT_1 = getvaluetest$(EXEEXT) +am__EXEEXT_2 = cppunittest$(EXEEXT) +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@am__EXEEXT_3 = $(am__EXEEXT_2) +am__EXEEXT_4 = nutlogtest$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_3) +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@am__EXEEXT_5 = cppnit$(EXEEXT) +am__cppnit_SOURCES_DIST = cpputest-client.cpp cpputest.cpp +am__objects_1 = cppnit-cpputest-client.$(OBJEXT) +am__objects_2 = cppnit-cpputest.$(OBJEXT) +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@am_cppnit_OBJECTS = \ +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@ $(am__objects_1) \ +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@ $(am__objects_2) +cppnit_OBJECTS = $(am_cppnit_OBJECTS) +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppnit_DEPENDENCIES = $(top_builddir)/clients/libnutclient.la \ +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@ $(top_builddir)/clients/libnutclientstub.la AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = +cppnit_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(cppnit_CXXFLAGS) \ + $(CXXFLAGS) $(cppnit_LDFLAGS) $(LDFLAGS) -o $@ +am__cppunittest_SOURCES_DIST = example.cpp nutclienttest.cpp \ + cpputest.cpp +am__objects_3 = cppunittest-example.$(OBJEXT) \ + cppunittest-nutclienttest.$(OBJEXT) +am__objects_4 = cppunittest-cpputest.$(OBJEXT) +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@am_cppunittest_OBJECTS = \ +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@ $(am__objects_3) \ +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@ $(am__objects_4) +cppunittest_OBJECTS = $(am_cppunittest_OBJECTS) +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppunittest_DEPENDENCIES = $(top_builddir)/clients/libnutclient.la \ +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@ $(top_builddir)/clients/libnutclientstub.la cppunittest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(cppunittest_CXXFLAGS) \ $(CXXFLAGS) $(cppunittest_LDFLAGS) $(LDFLAGS) -o $@ +am__getvaluetest_SOURCES_DIST = getvaluetest.c +@WITH_USB_TRUE@am_getvaluetest_OBJECTS = \ +@WITH_USB_TRUE@ getvaluetest-getvaluetest.$(OBJEXT) +@WITH_USB_TRUE@nodist_getvaluetest_OBJECTS = \ +@WITH_USB_TRUE@ getvaluetest-hidparser.$(OBJEXT) +getvaluetest_OBJECTS = $(am_getvaluetest_OBJECTS) \ + $(nodist_getvaluetest_OBJECTS) +@WITH_USB_TRUE@getvaluetest_DEPENDENCIES = \ +@WITH_USB_TRUE@ $(top_builddir)/common/libcommon.la +getvaluetest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(getvaluetest_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +am_nutlogtest_OBJECTS = nutlogtest.$(OBJEXT) +nutlogtest_OBJECTS = $(am_nutlogtest_OBJECTS) +nutlogtest_DEPENDENCIES = $(top_builddir)/common/libcommon.la AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -141,8 +212,34 @@ am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/cppnit-cpputest-client.Po \ + ./$(DEPDIR)/cppnit-cpputest.Po \ + ./$(DEPDIR)/cppunittest-cpputest.Po \ + ./$(DEPDIR)/cppunittest-example.Po \ + ./$(DEPDIR)/cppunittest-nutclienttest.Po \ + ./$(DEPDIR)/getvaluetest-getvaluetest.Po \ + ./$(DEPDIR)/getvaluetest-hidparser.Po \ + ./$(DEPDIR)/nutlogtest.Po am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ @@ -161,13 +258,33 @@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = -SOURCES = $(cppunittest_SOURCES) -DIST_SOURCES = $(am__cppunittest_SOURCES_DIST) +SOURCES = $(cppnit_SOURCES) $(cppunittest_SOURCES) \ + $(getvaluetest_SOURCES) $(nodist_getvaluetest_SOURCES) \ + $(nutlogtest_SOURCES) +DIST_SOURCES = $(am__cppnit_SOURCES_DIST) \ + $(am__cppunittest_SOURCES_DIST) \ + $(am__getvaluetest_SOURCES_DIST) $(nutlogtest_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ + ctags-recursive dvi-recursive html-recursive info-recursive \ + install-data-recursive install-dvi-recursive \ + install-exec-recursive install-html-recursive \ + install-info-recursive install-pdf-recursive \ + install-ps-recursive install-recursive installcheck-recursive \ + installdirs-recursive pdf-recursive ps-recursive \ + tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +am__recursive_targets = \ + $(RECURSIVE_TARGETS) \ + $(RECURSIVE_CLEAN_TARGETS) \ + $(am__extra_recursive_targets) +AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ + check recheck distdir distdir-am am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is @@ -369,8 +486,8 @@ am__set_TESTS_bases = \ bases='$(TEST_LOGS)'; \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` +AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)' RECHECK_LOGS = $(TEST_LOGS) -AM_RECURSIVE_TARGETS = check recheck TEST_SUITE_LOG = test-suite.log TEST_EXTENSIONS = @EXEEXT@ .test LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver @@ -391,7 +508,35 @@ TEST_LOGS = $(am__test_logs2:.test.log=.log) TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ $(TEST_LOG_FLAGS) +DIST_SUBDIRS = $(SUBDIRS) +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \ + $(top_srcdir)/test-driver DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" A2X = @A2X@ ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ @@ -399,6 +544,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -409,6 +555,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -422,6 +569,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -434,6 +582,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -451,6 +600,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -461,21 +612,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -495,6 +654,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -508,6 +670,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -525,6 +688,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -538,6 +702,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -563,12 +730,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -578,17 +747,47 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ udevdir = @udevdir@ -@HAVE_CPPUNIT_TRUE@cppunittest_CXXFLAGS = $(CPPUNIT_CFLAGS) -@HAVE_CPPUNIT_TRUE@cppunittest_LDFLAGS = $(CPPUNIT_LIBS) +SUBDIRS = . NIT +EXTRA_DIST = nut-driver-enumerator-test.sh \ + nut-driver-enumerator-test--ups.conf $(am__append_4) \ + $(am__append_5) +CLEANFILES = *.trs *.log $(LINKED_SOURCE_FILES) $(TESTS) \ + $(TESTS_CXX11) +AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/drivers +AM_CXXFLAGS = -I$(top_srcdir)/include +nutlogtest_SOURCES = nutlogtest.c +nutlogtest_LDADD = $(top_builddir)/common/libcommon.la +# Separate the .deps of other dirs from this one +LINKED_SOURCE_FILES = hidparser.c +@WITH_USB_TRUE@getvaluetest_SOURCES = getvaluetest.c +@WITH_USB_TRUE@nodist_getvaluetest_SOURCES = hidparser.c +# Pull the right include path for chosen libusb version: +@WITH_USB_TRUE@getvaluetest_CFLAGS = $(AM_CFLAGS) $(LIBUSB_CFLAGS) +@WITH_USB_TRUE@getvaluetest_LDADD = $(top_builddir)/common/libcommon.la + +### Optional tests which can not be built everywhere # List of src files for CppUnit tests -@HAVE_CPPUNIT_TRUE@CPPUNITTESTSRC = example.cpp -@HAVE_CPPUNIT_TRUE@cppunittest_SOURCES = $(CPPUNITTESTSRC) cpputest.cpp -@HAVE_CPPUNIT_FALSE@EXTRA_DIST = example.cpp cpputest.cpp -all: all-am +CPPUNITTESTSRC = example.cpp nutclienttest.cpp +# The test driver which orchestrates running those tests above +CPPUNITTESTERSRC = cpputest.cpp +CPPCLIENTTESTSRC = cpputest-client.cpp +TESTS_CXX11 = cppunittest +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppunittest_CXXFLAGS = $(AM_CXXFLAGS) $(CPPUNIT_CFLAGS) $(CPPUNIT_CXXFLAGS) $(CPPUNIT_NUT_CXXFLAGS) $(CXXFLAGS) +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppunittest_LDFLAGS = $(CPPUNIT_LDFLAGS) $(CPPUNIT_LIBS) +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppunittest_LDADD = $(top_builddir)/clients/libnutclient.la $(top_builddir)/clients/libnutclientstub.la +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppunittest_SOURCES = $(CPPUNITTESTSRC) $(CPPUNITTESTERSRC) +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppnit_CXXFLAGS = $(AM_CXXFLAGS) $(CPPUNIT_CFLAGS) $(CPPUNIT_CXXFLAGS) $(CPPUNIT_NUT_CXXFLAGS) $(CXXFLAGS) +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppnit_LDFLAGS = $(CPPUNIT_LDFLAGS) $(CPPUNIT_LIBS) +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppnit_LDADD = $(top_builddir)/clients/libnutclient.la $(top_builddir)/clients/libnutclientstub.la +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppnit_SOURCES = $(CPPCLIENTTESTSRC) $(CPPUNITTESTERSRC) +BUILT_SOURCES = $(LINKED_SOURCE_FILES) +MAINTAINERCLEANFILES = Makefile.in .dirstamp +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: -.SUFFIXES: .cpp .lo .log .o .obj .test .test$(EXEEXT) .trs +.SUFFIXES: .c .cpp .lo .log .o .obj .test .test$(EXEEXT) .trs $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ @@ -601,14 +800,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu tests/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -629,18 +827,94 @@ clean-checkPROGRAMS: echo " rm -f" $$list; \ rm -f $$list +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppnit$(EXEEXT): $(cppnit_OBJECTS) $(cppnit_DEPENDENCIES) $(EXTRA_cppnit_DEPENDENCIES) +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@ @rm -f cppnit$(EXEEXT) +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@ $(AM_V_CXXLD)$(cppnit_LINK) $(cppnit_OBJECTS) $(cppnit_LDADD) $(LIBS) + cppunittest$(EXEEXT): $(cppunittest_OBJECTS) $(cppunittest_DEPENDENCIES) $(EXTRA_cppunittest_DEPENDENCIES) @rm -f cppunittest$(EXEEXT) $(AM_V_CXXLD)$(cppunittest_LINK) $(cppunittest_OBJECTS) $(cppunittest_LDADD) $(LIBS) +getvaluetest$(EXEEXT): $(getvaluetest_OBJECTS) $(getvaluetest_DEPENDENCIES) $(EXTRA_getvaluetest_DEPENDENCIES) + @rm -f getvaluetest$(EXEEXT) + $(AM_V_CCLD)$(getvaluetest_LINK) $(getvaluetest_OBJECTS) $(getvaluetest_LDADD) $(LIBS) + +nutlogtest$(EXEEXT): $(nutlogtest_OBJECTS) $(nutlogtest_DEPENDENCIES) $(EXTRA_nutlogtest_DEPENDENCIES) + @rm -f nutlogtest$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(nutlogtest_OBJECTS) $(nutlogtest_LDADD) $(LIBS) + mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cppunittest-cpputest.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cppunittest-example.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cppnit-cpputest-client.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cppnit-cpputest.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cppunittest-cpputest.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cppunittest-example.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cppunittest-nutclienttest.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getvaluetest-getvaluetest.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getvaluetest-hidparser.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nutlogtest.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +getvaluetest-getvaluetest.o: getvaluetest.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(getvaluetest_CFLAGS) $(CFLAGS) -MT getvaluetest-getvaluetest.o -MD -MP -MF $(DEPDIR)/getvaluetest-getvaluetest.Tpo -c -o getvaluetest-getvaluetest.o `test -f 'getvaluetest.c' || echo '$(srcdir)/'`getvaluetest.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/getvaluetest-getvaluetest.Tpo $(DEPDIR)/getvaluetest-getvaluetest.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='getvaluetest.c' object='getvaluetest-getvaluetest.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(getvaluetest_CFLAGS) $(CFLAGS) -c -o getvaluetest-getvaluetest.o `test -f 'getvaluetest.c' || echo '$(srcdir)/'`getvaluetest.c + +getvaluetest-getvaluetest.obj: getvaluetest.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(getvaluetest_CFLAGS) $(CFLAGS) -MT getvaluetest-getvaluetest.obj -MD -MP -MF $(DEPDIR)/getvaluetest-getvaluetest.Tpo -c -o getvaluetest-getvaluetest.obj `if test -f 'getvaluetest.c'; then $(CYGPATH_W) 'getvaluetest.c'; else $(CYGPATH_W) '$(srcdir)/getvaluetest.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/getvaluetest-getvaluetest.Tpo $(DEPDIR)/getvaluetest-getvaluetest.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='getvaluetest.c' object='getvaluetest-getvaluetest.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(getvaluetest_CFLAGS) $(CFLAGS) -c -o getvaluetest-getvaluetest.obj `if test -f 'getvaluetest.c'; then $(CYGPATH_W) 'getvaluetest.c'; else $(CYGPATH_W) '$(srcdir)/getvaluetest.c'; fi` + +getvaluetest-hidparser.o: hidparser.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(getvaluetest_CFLAGS) $(CFLAGS) -MT getvaluetest-hidparser.o -MD -MP -MF $(DEPDIR)/getvaluetest-hidparser.Tpo -c -o getvaluetest-hidparser.o `test -f 'hidparser.c' || echo '$(srcdir)/'`hidparser.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/getvaluetest-hidparser.Tpo $(DEPDIR)/getvaluetest-hidparser.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hidparser.c' object='getvaluetest-hidparser.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(getvaluetest_CFLAGS) $(CFLAGS) -c -o getvaluetest-hidparser.o `test -f 'hidparser.c' || echo '$(srcdir)/'`hidparser.c + +getvaluetest-hidparser.obj: hidparser.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(getvaluetest_CFLAGS) $(CFLAGS) -MT getvaluetest-hidparser.obj -MD -MP -MF $(DEPDIR)/getvaluetest-hidparser.Tpo -c -o getvaluetest-hidparser.obj `if test -f 'hidparser.c'; then $(CYGPATH_W) 'hidparser.c'; else $(CYGPATH_W) '$(srcdir)/hidparser.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/getvaluetest-hidparser.Tpo $(DEPDIR)/getvaluetest-hidparser.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hidparser.c' object='getvaluetest-hidparser.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(getvaluetest_CFLAGS) $(CFLAGS) -c -o getvaluetest-hidparser.obj `if test -f 'hidparser.c'; then $(CYGPATH_W) 'hidparser.c'; else $(CYGPATH_W) '$(srcdir)/hidparser.c'; fi` .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @@ -666,6 +940,34 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< +cppnit-cpputest-client.o: cpputest-client.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppnit_CXXFLAGS) $(CXXFLAGS) -MT cppnit-cpputest-client.o -MD -MP -MF $(DEPDIR)/cppnit-cpputest-client.Tpo -c -o cppnit-cpputest-client.o `test -f 'cpputest-client.cpp' || echo '$(srcdir)/'`cpputest-client.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cppnit-cpputest-client.Tpo $(DEPDIR)/cppnit-cpputest-client.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='cpputest-client.cpp' object='cppnit-cpputest-client.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppnit_CXXFLAGS) $(CXXFLAGS) -c -o cppnit-cpputest-client.o `test -f 'cpputest-client.cpp' || echo '$(srcdir)/'`cpputest-client.cpp + +cppnit-cpputest-client.obj: cpputest-client.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppnit_CXXFLAGS) $(CXXFLAGS) -MT cppnit-cpputest-client.obj -MD -MP -MF $(DEPDIR)/cppnit-cpputest-client.Tpo -c -o cppnit-cpputest-client.obj `if test -f 'cpputest-client.cpp'; then $(CYGPATH_W) 'cpputest-client.cpp'; else $(CYGPATH_W) '$(srcdir)/cpputest-client.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cppnit-cpputest-client.Tpo $(DEPDIR)/cppnit-cpputest-client.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='cpputest-client.cpp' object='cppnit-cpputest-client.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppnit_CXXFLAGS) $(CXXFLAGS) -c -o cppnit-cpputest-client.obj `if test -f 'cpputest-client.cpp'; then $(CYGPATH_W) 'cpputest-client.cpp'; else $(CYGPATH_W) '$(srcdir)/cpputest-client.cpp'; fi` + +cppnit-cpputest.o: cpputest.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppnit_CXXFLAGS) $(CXXFLAGS) -MT cppnit-cpputest.o -MD -MP -MF $(DEPDIR)/cppnit-cpputest.Tpo -c -o cppnit-cpputest.o `test -f 'cpputest.cpp' || echo '$(srcdir)/'`cpputest.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cppnit-cpputest.Tpo $(DEPDIR)/cppnit-cpputest.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='cpputest.cpp' object='cppnit-cpputest.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppnit_CXXFLAGS) $(CXXFLAGS) -c -o cppnit-cpputest.o `test -f 'cpputest.cpp' || echo '$(srcdir)/'`cpputest.cpp + +cppnit-cpputest.obj: cpputest.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppnit_CXXFLAGS) $(CXXFLAGS) -MT cppnit-cpputest.obj -MD -MP -MF $(DEPDIR)/cppnit-cpputest.Tpo -c -o cppnit-cpputest.obj `if test -f 'cpputest.cpp'; then $(CYGPATH_W) 'cpputest.cpp'; else $(CYGPATH_W) '$(srcdir)/cpputest.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cppnit-cpputest.Tpo $(DEPDIR)/cppnit-cpputest.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='cpputest.cpp' object='cppnit-cpputest.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppnit_CXXFLAGS) $(CXXFLAGS) -c -o cppnit-cpputest.obj `if test -f 'cpputest.cpp'; then $(CYGPATH_W) 'cpputest.cpp'; else $(CYGPATH_W) '$(srcdir)/cpputest.cpp'; fi` + cppunittest-example.o: example.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppunittest_CXXFLAGS) $(CXXFLAGS) -MT cppunittest-example.o -MD -MP -MF $(DEPDIR)/cppunittest-example.Tpo -c -o cppunittest-example.o `test -f 'example.cpp' || echo '$(srcdir)/'`example.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cppunittest-example.Tpo $(DEPDIR)/cppunittest-example.Po @@ -680,6 +982,20 @@ cppunittest-example.obj: example.cpp @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppunittest_CXXFLAGS) $(CXXFLAGS) -c -o cppunittest-example.obj `if test -f 'example.cpp'; then $(CYGPATH_W) 'example.cpp'; else $(CYGPATH_W) '$(srcdir)/example.cpp'; fi` +cppunittest-nutclienttest.o: nutclienttest.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppunittest_CXXFLAGS) $(CXXFLAGS) -MT cppunittest-nutclienttest.o -MD -MP -MF $(DEPDIR)/cppunittest-nutclienttest.Tpo -c -o cppunittest-nutclienttest.o `test -f 'nutclienttest.cpp' || echo '$(srcdir)/'`nutclienttest.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cppunittest-nutclienttest.Tpo $(DEPDIR)/cppunittest-nutclienttest.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='nutclienttest.cpp' object='cppunittest-nutclienttest.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppunittest_CXXFLAGS) $(CXXFLAGS) -c -o cppunittest-nutclienttest.o `test -f 'nutclienttest.cpp' || echo '$(srcdir)/'`nutclienttest.cpp + +cppunittest-nutclienttest.obj: nutclienttest.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppunittest_CXXFLAGS) $(CXXFLAGS) -MT cppunittest-nutclienttest.obj -MD -MP -MF $(DEPDIR)/cppunittest-nutclienttest.Tpo -c -o cppunittest-nutclienttest.obj `if test -f 'nutclienttest.cpp'; then $(CYGPATH_W) 'nutclienttest.cpp'; else $(CYGPATH_W) '$(srcdir)/nutclienttest.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cppunittest-nutclienttest.Tpo $(DEPDIR)/cppunittest-nutclienttest.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='nutclienttest.cpp' object='cppunittest-nutclienttest.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppunittest_CXXFLAGS) $(CXXFLAGS) -c -o cppunittest-nutclienttest.obj `if test -f 'nutclienttest.cpp'; then $(CYGPATH_W) 'nutclienttest.cpp'; else $(CYGPATH_W) '$(srcdir)/nutclienttest.cpp'; fi` + cppunittest-cpputest.o: cpputest.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppunittest_CXXFLAGS) $(CXXFLAGS) -MT cppunittest-cpputest.o -MD -MP -MF $(DEPDIR)/cppunittest-cpputest.Tpo -c -o cppunittest-cpputest.o `test -f 'cpputest.cpp' || echo '$(srcdir)/'`cpputest.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cppunittest-cpputest.Tpo $(DEPDIR)/cppunittest-cpputest.Po @@ -700,14 +1016,61 @@ mostlyclean-libtool: clean-libtool: -rm -rf .libs _libs +# This directory's subdirectories are mostly independent; you can cd +# into them and run 'make' without going through this Makefile. +# To change the values of 'make' variables: instead of editing Makefiles, +# (1) if the variable is set in 'config.status', edit 'config.status' +# (which will cause the Makefiles to be regenerated when you run 'make'); +# (2) otherwise, pass the desired values on the 'make' command line. +$(am__recursive_targets): + @fail=; \ + if $(am__make_keepgoing); then \ + failcom='fail=yes'; \ + else \ + failcom='exit 1'; \ + fi; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am +tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ @@ -720,7 +1083,7 @@ tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $$unique; \ fi; \ fi -ctags: ctags-am +ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) @@ -733,7 +1096,7 @@ GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am +cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ @@ -782,7 +1145,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS) if test -n "$$am__remaking_logs"; then \ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ "recursion detected" >&2; \ - else \ + elif test -n "$$redo_logs"; then \ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ fi; \ if $(am__make_dryrun); then :; else \ @@ -859,7 +1222,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS) test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ fi; \ echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ + echo "$${col}Testsuite summary"$(AM_TESTSUITE_SUMMARY_HEADER)"$${std}"; \ echo "$${col}$$br$${std}"; \ create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ @@ -872,7 +1235,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS) fi; \ $$success || exit 1 -check-TESTS: +check-TESTS: $(check_PROGRAMS) @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @@ -893,6 +1256,20 @@ recheck: all $(check_PROGRAMS) am__force_recheck=am--force-recheck \ TEST_LOGS="$$log_list"; \ exit $$? +nutlogtest.log: nutlogtest$(EXEEXT) + @p='nutlogtest$(EXEEXT)'; \ + b='nutlogtest'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +getvaluetest.log: getvaluetest$(EXEEXT) + @p='getvaluetest$(EXEEXT)'; \ + b='getvaluetest'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) cppunittest.log: cppunittest$(EXEEXT) @p='cppunittest$(EXEEXT)'; \ b='cppunittest'; \ @@ -915,7 +1292,10 @@ cppunittest.log: cppunittest$(EXEEXT) @am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ @am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -945,21 +1325,53 @@ distdir: $(DISTFILES) || exit 1; \ fi; \ done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + $(am__make_dryrun) \ + || test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done +@HAVE_CPPUNIT_FALSE@check-local: +@HAVE_CXX11_FALSE@check-local: +@WITH_VALGRIND_FALSE@check-local: check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) - $(MAKE) $(AM_MAKEFLAGS) check-TESTS -check: check-am + $(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-recursive all-am: Makefile -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am +installdirs: installdirs-recursive +installdirs-am: +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-recursive +install-exec: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am -installcheck: installcheck-am +installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ @@ -976,6 +1388,7 @@ mostlyclean-generic: -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) @@ -984,80 +1397,98 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -clean: clean-am + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-recursive clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ mostlyclean-am -distclean: distclean-am - -rm -rf ./$(DEPDIR) +distclean: distclean-recursive + -rm -f ./$(DEPDIR)/cppnit-cpputest-client.Po + -rm -f ./$(DEPDIR)/cppnit-cpputest.Po + -rm -f ./$(DEPDIR)/cppunittest-cpputest.Po + -rm -f ./$(DEPDIR)/cppunittest-example.Po + -rm -f ./$(DEPDIR)/cppunittest-nutclienttest.Po + -rm -f ./$(DEPDIR)/getvaluetest-getvaluetest.Po + -rm -f ./$(DEPDIR)/getvaluetest-hidparser.Po + -rm -f ./$(DEPDIR)/nutlogtest.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags -dvi: dvi-am +dvi: dvi-recursive dvi-am: -html: html-am +html: html-recursive html-am: -info: info-am +info: info-recursive info-am: install-data-am: -install-dvi: install-dvi-am +install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: -install-html: install-html-am +install-html: install-html-recursive install-html-am: -install-info: install-info-am +install-info: install-info-recursive install-info-am: install-man: -install-pdf: install-pdf-am +install-pdf: install-pdf-recursive install-pdf-am: -install-ps: install-ps-am +install-ps: install-ps-recursive install-ps-am: installcheck-am: -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) +maintainer-clean: maintainer-clean-recursive + -rm -f ./$(DEPDIR)/cppnit-cpputest-client.Po + -rm -f ./$(DEPDIR)/cppnit-cpputest.Po + -rm -f ./$(DEPDIR)/cppunittest-cpputest.Po + -rm -f ./$(DEPDIR)/cppunittest-example.Po + -rm -f ./$(DEPDIR)/cppunittest-nutclienttest.Po + -rm -f ./$(DEPDIR)/getvaluetest-getvaluetest.Po + -rm -f ./$(DEPDIR)/getvaluetest-hidparser.Po + -rm -f ./$(DEPDIR)/nutlogtest.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic -mostlyclean: mostlyclean-am +mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool -pdf: pdf-am +pdf: pdf-recursive pdf-am: -ps: ps-am +ps: ps-recursive ps-am: uninstall-am: -.MAKE: check-am install-am install-strip +.MAKE: $(am__recursive_targets) all check check-am install install-am \ + install-exec install-strip -.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ +.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ + am--depfiles check check-TESTS check-am check-local clean \ clean-checkPROGRAMS clean-generic clean-libtool cscopelist-am \ ctags ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ @@ -1066,11 +1497,50 @@ uninstall-am: install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ + installcheck-am installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ recheck tags tags-am uninstall uninstall-am +.PRECIOUS: Makefile + + +all: $(TESTS) + +# NUT Integration Testing suite +check-NIT check-NIT-devel: + cd "$(builddir)/NIT" && $(MAKE) $@ + +# NOTE: Not using "$<" due to a legacy Sun/illumos dmake bug with resolver +# of dynamic vars, see e.g. https://man.omnios.org/man1/make#BUGS +hidparser.c: $(top_srcdir)/drivers/hidparser.c + test -s "$@" || ln -s -f "$(top_srcdir)/drivers/hidparser.c" "$@" + +# Make sure out-of-dir dependencies exist (especially when dev-building parts): +$(top_builddir)/common/libcommon.la: dummy + @cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F) + +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@@WITH_VALGRIND_TRUE@check-local: $(check_PROGRAMS) +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@@WITH_VALGRIND_TRUE@ RES=0; for P in $^ ; do $(VALGRIND) ./$$P || { RES=$$? ; echo "FAILED: $(VALGRIND) ./$$P" >&2; }; done; exit $$RES + +# Make sure out-of-dir C++ dependencies exist (especially when dev-building +# only some parts of NUT): +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@$(top_builddir)/clients/libnutclient.la \ +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@$(top_builddir)/clients/libnutclientstub.la: dummy +@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@ @cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F) + +@HAVE_CPPUNIT_FALSE@@HAVE_CXX11_TRUE@cppnit: +@HAVE_CPPUNIT_FALSE@@HAVE_CXX11_TRUE@ @echo "SKIP: $@ not implemented without C++11 and CPPUNIT enabled" >&2 ; exit 1 + +@HAVE_CXX11_FALSE@cppnit: +@HAVE_CXX11_FALSE@ @echo "SKIP: $@ not implemented without C++11 and CPPUNIT enabled" >&2 ; exit 1 + +dummy: + +# NOTE: Do not clean ".deps" in SUBDIRS of the main project, +# the root Makefile.am takes care of that! +#clean-local: +# rm -rf $(builddir)/.deps # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/tests/NIT/Makefile.am b/tests/NIT/Makefile.am new file mode 100644 index 0000000..6ce64a9 --- /dev/null +++ b/tests/NIT/Makefile.am @@ -0,0 +1,26 @@ +EXTRA_DIST = nit.sh README + +if WITH_CHECK_NIT +check: check-NIT +else +check: + @echo "NO-OP: $@ in `pwd` is inactive by default. Run 'configure --enable-check-NIT' or 'make check-NIT' explicitly" >&2 +endif + +# Run in builddir, use script from srcdir +# Avoid running "$<" - not all make implementations handle that +check-NIT: $(abs_srcdir)/nit.sh + "$(abs_srcdir)/nit.sh" + +# Make sure pre-requisites for NIT are fresh as we iterate +check-NIT-devel: $(abs_srcdir)/nit.sh + @cd .. && ( $(MAKE) -s cppnit || echo "OPTIONAL C++ test client test will be skipped" ) + @cd "$(top_builddir)/clients" && $(MAKE) -s upsc upsrw upsmon + @cd "$(top_builddir)/server" && $(MAKE) -s upsd + @cd "$(top_builddir)/drivers" && $(MAKE) -s dummy-ups + @$(MAKE) check-NIT + +MAINTAINERCLEANFILES = Makefile.in .dirstamp + +clean-local: + rm -rf tmp diff --git a/tests/NIT/Makefile.in b/tests/NIT/Makefile.in new file mode 100644 index 0000000..1cc9271 --- /dev/null +++ b/tests/NIT/Makefile.in @@ -0,0 +1,585 @@ +# Makefile.in generated by automake 1.16.3 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2020 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = tests/NIT +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/nut_arg_with.m4 \ + $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ + $(top_srcdir)/m4/nut_check_libavahi.m4 \ + $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ + $(top_srcdir)/m4/nut_check_libgd.m4 \ + $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ + $(top_srcdir)/m4/nut_check_libneon.m4 \ + $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ + $(top_srcdir)/m4/nut_check_libnss.m4 \ + $(top_srcdir)/m4/nut_check_libopenssl.m4 \ + $(top_srcdir)/m4/nut_check_libpowerman.m4 \ + $(top_srcdir)/m4/nut_check_libusb.m4 \ + $(top_srcdir)/m4/nut_check_libwrap.m4 \ + $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ + $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ + $(top_srcdir)/m4/nut_type_socklen_t.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +SOURCES = +DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in README +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +A2X = @A2X@ +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +ASCIIDOC = @ASCIIDOC@ +ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BINDIR = @BINDIR@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CONFPATH = @CONFPATH@ +CPP = @CPP@ +CPPCHECK = @CPPCHECK@ +CPPFLAGS = @CPPFLAGS@ +CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ +CPPUNIT_LIBS = @CPPUNIT_LIBS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DBLATEX = @DBLATEX@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ +DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ +DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ +DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ +DRVPATH = @DRVPATH@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBAVAHI_CFLAGS = @LIBAVAHI_CFLAGS@ +LIBAVAHI_LIBS = @LIBAVAHI_LIBS@ +LIBDIR = @LIBDIR@ +LIBGD_CFLAGS = @LIBGD_CFLAGS@ +LIBGD_LDFLAGS = @LIBGD_LDFLAGS@ +LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ +LIBIPMI_LIBS = @LIBIPMI_LIBS@ +LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ +LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ +LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ +LIBNEON_LIBS = @LIBNEON_LIBS@ +LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ +LIBNETSNMP_LIBS = @LIBNETSNMP_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBPOWERMAN_CFLAGS = @LIBPOWERMAN_CFLAGS@ +LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ +LIBS = @LIBS@ +LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ +LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ +LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ +LIBUSB_LIBS = @LIBUSB_LIBS@ +LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ +LIBWRAP_LIBS = @LIBWRAP_LIBS@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LN_S_R = @LN_S_R@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ +NUT_NETVERSION = @NUT_NETVERSION@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OS_NAME = @OS_NAME@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PIDPATH = @PIDPATH@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ +RANLIB = @RANLIB@ +RUN_AS_GROUP = @RUN_AS_GROUP@ +RUN_AS_USER = @RUN_AS_USER@ +SBINDIR = @SBINDIR@ +SED = @SED@ +SERLIBS = @SERLIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOURCE_HIGHLIGHT = @SOURCE_HIGHLIGHT@ +STATEPATH = @STATEPATH@ +STRIP = @STRIP@ +SUN_LIBUSB = @SUN_LIBUSB@ +TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ +VERSION = @VERSION@ +WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ +XMLLINT = @XMLLINT@ +XSLTPROC = @XSLTPROC@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +auglensdir = @auglensdir@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +cgiexecdir = @cgiexecdir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +devddir = @devddir@ +docdir = @docdir@ +driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +hotplugdir = @hotplugdir@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +now = @now@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgconfigdir = @pkgconfigdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +systemdshutdowndir = @systemdshutdowndir@ +systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +udevdir = @udevdir@ +EXTRA_DIST = nit.sh README +MAINTAINERCLEANFILES = Makefile.in .dirstamp +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/NIT/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu tests/NIT/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags TAGS: + +ctags CTAGS: + +cscope cscopelist: + + +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic clean-libtool clean-local mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + clean-local cscopelist-am ctags-am distclean distclean-generic \ + distclean-libtool distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags-am uninstall uninstall-am + +.PRECIOUS: Makefile + + +@WITH_CHECK_NIT_TRUE@check: check-NIT +@WITH_CHECK_NIT_FALSE@check: +@WITH_CHECK_NIT_FALSE@ @echo "NO-OP: $@ in `pwd` is inactive by default. Run 'configure --enable-check-NIT' or 'make check-NIT' explicitly" >&2 + +# Run in builddir, use script from srcdir +# Avoid running "$<" - not all make implementations handle that +check-NIT: $(abs_srcdir)/nit.sh + "$(abs_srcdir)/nit.sh" + +# Make sure pre-requisites for NIT are fresh as we iterate +check-NIT-devel: $(abs_srcdir)/nit.sh + @cd .. && ( $(MAKE) -s cppnit || echo "OPTIONAL C++ test client test will be skipped" ) + @cd "$(top_builddir)/clients" && $(MAKE) -s upsc upsrw upsmon + @cd "$(top_builddir)/server" && $(MAKE) -s upsd + @cd "$(top_builddir)/drivers" && $(MAKE) -s dummy-ups + @$(MAKE) check-NIT + +clean-local: + rm -rf tmp + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/tests/NIT/README b/tests/NIT/README new file mode 100644 index 0000000..30da730 --- /dev/null +++ b/tests/NIT/README @@ -0,0 +1,17 @@ +NUT Integration Testing suite +============================= + +This suite aims to simplify running `upsd`, a `dummy-ups` driver and +a few clients to query them, as part of regular `make check` routine +or separately with existing binaries (should not impact any existing +installation data, processes or communications). + +WARNING: Current working directory when starting the script should be +the location where it may create temporary data (e.g. the BUILDDIR). + +See also +link:https://git.launchpad.net/ubuntu/+source/nut/tree/debian/tests/test-nut.py[The NUT testing script] +available in the +link:https://code.edge.launchpad.net/qa-regression-testing[Ubuntu QA Regression Testing suite] +doing a similar job with NUT installed from packages and configuring +it via files in standard path names. diff --git a/tests/NIT/nit.sh b/tests/NIT/nit.sh new file mode 100755 index 0000000..f404cb9 --- /dev/null +++ b/tests/NIT/nit.sh @@ -0,0 +1,853 @@ +#!/bin/sh + +# NUT Integration Testing suite, assumes the codebase was built and +# arranges running of the binaries to test driver-client-server +# ability to start and their interactions. +# +# Note: currently it is a PoC-quality mess that gets the job done +# but could be refactored for better maintainability and generic +# approach. Part of the goal was to let this script set up the +# sandbox to run tests which could be defined in other files. +# +# WARNING: Current working directory when starting the script should be +# the location where it may create temporary data (e.g. the BUILDDIR). +# Caller can export envvars to impact the script behavior, e.g.: +# DEBUG=true to print debug messages, running processes, etc. +# DEBUG_SLEEP=60 to sleep after tests, with driver+server running +# NUT_DEBUG_MIN=3 to set (minimum) debug level for drivers, upsd... +# NUT_PORT=12345 custom port for upsd to listen and clients to query +# +# Design note: written with dumbed-down POSIX shell syntax, to +# properly work in whatever different OSes have (bash, dash, +# ksh, busybox sh...) +# +# Copyright +# 2022 Jim Klimov +# +# License: GPLv2+ + +TZ=UTC +LANG=C +LC_ALL=C +export TZ LANG LC_ALL + +log_separator() { + echo "" >&2 + echo "================================" >&2 +} + +shouldDebug() { + [ -n "$DEBUG" ] || [ -n "$DEBUG_SLEEP" ] +} + +log_debug() { + if shouldDebug ; then + echo "[DEBUG] $@" >&2 + fi +} + +log_info() { + echo "[INFO] $@" >&2 +} + +log_error() { + echo "[ERROR] $@" >&2 +} + +die() { + echo "[FATAL] $@" >&2 + exit 1 +} + +# Note: current directory is assumed to be writeable for temporary +# data, e.g. the $(builddir) from the Makefile. Static resources +# from the source codebase are where the script resides, e.g. +# the $(srcdir) from the Makefile. If we are not in the source +# tree, tests would use binaries in PATH (e.g. packaged install). +BUILDDIR="`pwd`" +TOP_BUILDDIR="" +case "${BUILDDIR}" in + */tests/NIT) + TOP_BUILDDIR="`cd "${BUILDDIR}"/../.. && pwd`" ;; + *) log_info "Current directory '${BUILDDIR}' is not a .../tests/NIT" ;; +esac +if ! test -w "${BUILDDIR}" ; then + log_error "BUILDDIR='${BUILDDIR}' is not writeable, tests may fail below" +fi + +SRCDIR="`dirname "$0"`" +SRCDIR="`cd "$SRCDIR" && pwd`" +TOP_SRCDIR="" +case "${SRCDIR}" in + */tests/NIT) + TOP_SRCDIR="`cd "${SRCDIR}"/../.. && pwd`" ;; + *) log_info "Script source directory '${SRCDIR}' is not a .../tests/NIT" ;; +esac + +# No fuss about LD_LIBRARY_PATH: for binaries that need it, +# PATH entries below would contain libtool wrapper scripts; +# for other builds we use system default or caller's env. +PATH_ADD="${BUILDDIR}" +if [ x"${SRCDIR}" != x"${BUILDDIR}" ]; then + PATH_ADD="${PATH_ADD}:${SRCDIR}" +fi + +if [ x"${TOP_BUILDDIR}" != x ]; then + PATH_ADD="${PATH_ADD}:${TOP_BUILDDIR}/clients:${TOP_BUILDDIR}/drivers:${TOP_BUILDDIR}/server:${TOP_BUILDDIR}/tools:${TOP_BUILDDIR}/tools/nut-scanner" +fi + +if [ x"${TOP_SRCDIR}" != x ]; then + PATH_ADD="${PATH_ADD}:${TOP_SRCDIR}/clients:${TOP_SRCDIR}/drivers:${TOP_SRCDIR}/server:${TOP_SRCDIR}/tools:${TOP_SRCDIR}/tools/nut-scanner" +fi + +PATH="${PATH_ADD}:${PATH}" +export PATH +unset PATH_ADD + +log_debug "Using PATH='$PATH'" + +for PROG in upsd upsc dummy-ups upsmon ; do + (command -v ${PROG}) || die "Useless setup: ${PROG} not found in PATH: ${PATH}" +done + +PID_UPSD="" +PID_DUMMYUPS="" +PID_DUMMYUPS1="" +PID_DUMMYUPS2="" + +TESTDIR="$BUILDDIR/tmp" +# Technically the limit is sizeof(sockaddr.sun_path) for complete socket +# pathname, which varies 104-108 chars max on systems seen in CI farm; +# we reserve 17 chars for "/dummy-ups-dummy" longest filename. +if [ `echo "$TESTDIR" | wc -c` -gt 80 ]; then + log_info "'$TESTDIR' is too long to store AF_UNIX socket files, will mktemp" + if ! ( [ -n "${TMPDIR-}" ] && [ -d "${TMPDIR-}" ] && [ -w "${TMPDIR-}" ] ) ; then + if [ -d /dev/shm ] && [ -w /dev/shm ]; then TMPDIR=/dev/shm ; else TMPDIR=/tmp ; fi + fi + TESTDIR="`mktemp -d "${TMPDIR}/nit-tmp.$$.XXXXXX"`" || die "Failed to mktemp" +else + rm -rf "${TESTDIR}" || true +fi +log_info "Using '$TESTDIR' for generated configs and state files" + +mkdir -p "${TESTDIR}/etc" "${TESTDIR}/run" && chmod 750 "${TESTDIR}/run" \ +|| die "Failed to create temporary FS structure for the NIT" + +stop_daemons() { + if [ -n "$PID_UPSD$PID_DUMMYUPS$PID_DUMMYUPS1$PID_DUMMYUPS2" ] ; then + log_info "Stopping test daemons" + kill -15 $PID_UPSD $PID_DUMMYUPS $PID_DUMMYUPS1 $PID_DUMMYUPS2 2>/dev/null + fi +} + +trap 'RES=$?; stop_daemons; if [ "${TESTDIR}" != "${BUILDDIR}/tmp" ] ; then rm -rf "${TESTDIR}" ; fi; exit $RES;' 0 1 2 3 15 + +NUT_STATEPATH="${TESTDIR}/run" +NUT_ALTPIDPATH="${TESTDIR}/run" +NUT_CONFPATH="${TESTDIR}/etc" +export NUT_STATEPATH NUT_ALTPIDPATH NUT_CONFPATH + +# TODO: Find a portable way to (check and) grab a random unprivileged port? +[ -n "${NUT_PORT-}" ] && [ "$NUT_PORT" -gt 0 ] && [ "$NUT_PORT" -lt 65536 ] \ +|| { + DELTA1="`date +%S`" || DELTA1=0 + DELTA2="`expr $$ % 99`" || DELTA2=0 + + NUT_PORT="`expr 34931 + $DELTA1 + $DELTA2`" \ + && [ "$NUT_PORT" -gt 0 ] && [ "$NUT_PORT" -lt 65536 ] \ + || NUT_PORT=34931 +} +export NUT_PORT + +### upsd.conf: ################################################## + +generatecfg_upsd_trivial() { + # Populate the configs for the run + cat > "$NUT_CONFPATH/upsd.conf" << EOF +STATEPATH "$NUT_STATEPATH" +LISTEN localhost $NUT_PORT +EOF + [ $? = 0 ] || die "Failed to populate temporary FS structure for the NIT: upsd.conf" + chmod 640 "$NUT_CONFPATH/upsd.conf" + + # Some systems listining on symbolic "localhost" actually + # only bind to IPv6, and Python telnetlib resolves IPv4 + # and fails its connection tests. Others fare well with + # both addresses in one command. + for LH in 127.0.0.1 '::1' ; do + if ( + ( cat /etc/hosts || getent hosts ) | grep "$LH" \ + || ping -c 1 "$LH" + ) 2>/dev/null >/dev/null ; then + echo "LISTEN $LH $NUT_PORT" >> "$NUT_CONFPATH/upsd.conf" + fi + done + + if [ -n "${NUT_DEBUG_MIN-}" ] ; then + echo "DEBUG_MIN ${NUT_DEBUG_MIN}" >> "$NUT_CONFPATH/upsd.conf" || exit + fi +} + +generatecfg_upsd_nodev() { + generatecfg_upsd_trivial + echo "ALLOW_NO_DEVICE true" >> "$NUT_CONFPATH/upsd.conf" \ + || die "Failed to populate temporary FS structure for the NIT: upsd.conf" +} + +### upsd.users: ################################################## + +TESTPASS_ADMIN='mypass' +TESTPASS_TESTER='pass words' +TESTPASS_UPSMON_PRIMARY='P@ssW0rdAdm' +TESTPASS_UPSMON_SECONDARY='P@ssW0rd' + +generatecfg_upsdusers_trivial() { + cat > "$NUT_CONFPATH/upsd.users" << EOF +[admin] + password = $TESTPASS_ADMIN + actions = SET + instcmds = ALL + +[tester] + password = "${TESTPASS_TESTER}" + instcmds = test.battery.start + instcmds = test.battery.stop + +[dummy-admin-m] + password = "${TESTPASS_UPSMON_PRIMARY}" + upsmon master + +[dummy-admin] + password = "${TESTPASS_UPSMON_PRIMARY}" + upsmon primary + +[dummy-user-s] + password = "${TESTPASS_UPSMON_SECONDARY}" + upsmon slave + +[dummy-user] + password = "${TESTPASS_UPSMON_SECONDARY}" + upsmon secondary +EOF + [ $? = 0 ] || die "Failed to populate temporary FS structure for the NIT: upsd.users" + chmod 640 "$NUT_CONFPATH/upsd.users" +} + +### upsmon.conf: ################################################## + +generatecfg_upsmon_trivial() { + # Populate the configs for the run + ( echo 'MINSUPPLIES 0' > "$NUT_CONFPATH/upsmon.conf" || exit + echo 'SHUTDOWNCMD "echo TESTING_DUMMY_SHUTDOWN_NOW"' >> "$NUT_CONFPATH/upsmon.conf" || exit + + if [ -n "${NUT_DEBUG_MIN-}" ] ; then + echo "DEBUG_MIN ${NUT_DEBUG_MIN}" >> "$NUT_CONFPATH/upsmon.conf" || exit + fi + ) || die "Failed to populate temporary FS structure for the NIT: upsmon.conf" + chmod 640 "$NUT_CONFPATH/upsmon.conf" +} + +generatecfg_upsmon_master() { + generatecfg_upsmon_trivial + echo "MONITOR 'dummy@localhost:$NUT_PORT' 0 'dummy-admin-m' '${TESTPASS_UPSMON_PRIMARY}' master" >> "$NUT_CONFPATH/upsmon.conf" \ + || die "Failed to populate temporary FS structure for the NIT: upsmon.conf" +} + +generatecfg_upsmon_primary() { + generatecfg_upsmon_trivial + echo "MONITOR 'dummy@localhost:$NUT_PORT' 0 'dummy-admin' '${TESTPASS_UPSMON_PRIMARY}' primary" >> "$NUT_CONFPATH/upsmon.conf" \ + || die "Failed to populate temporary FS structure for the NIT: upsmon.conf" +} + +generatecfg_upsmon_slave() { + generatecfg_upsmon_trivial + echo "MONITOR 'dummy@localhost:$NUT_PORT' 0 'dummy-user-s' '${TESTPASS_UPSMON_SECONDARY}' slave" >> "$NUT_CONFPATH/upsmon.conf" \ + || die "Failed to populate temporary FS structure for the NIT: upsmon.conf" +} + +generatecfg_upsmon_secondary() { + generatecfg_upsmon_trivial + echo "MONITOR 'dummy@localhost:$NUT_PORT' 0 'dummy-user' '${TESTPASS_UPSMON_SECONDARY}' secondary" >> "$NUT_CONFPATH/upsmon.conf" \ + || die "Failed to populate temporary FS structure for the NIT: upsmon.conf" +} + +### ups.conf: ################################################## + +generatecfg_ups_trivial() { + # Populate the configs for the run + ( echo 'maxretry = 3' > "$NUT_CONFPATH/ups.conf" || exit + if [ x"${TOP_BUILDDIR}" != x ]; then + echo "driverpath = '${TOP_BUILDDIR}/drivers'" >> "$NUT_CONFPATH/ups.conf" || exit + fi + if [ -n "${NUT_DEBUG_MIN-}" ] ; then + echo "debug_min = ${NUT_DEBUG_MIN}" >> "$NUT_CONFPATH/ups.conf" || exit + fi + ) || die "Failed to populate temporary FS structure for the NIT: ups.conf" + chmod 640 "$NUT_CONFPATH/ups.conf" + +} + +generatecfg_ups_dummy() { + generatecfg_ups_trivial + + cat > "$NUT_CONFPATH/dummy.seq" << EOF +ups.status: OB +TIMER 5 +ups.status: OL +TIMER 5 +EOF + [ $? = 0 ] || die "Failed to populate temporary FS structure for the NIT: dummy.seq" + + cat >> "$NUT_CONFPATH/ups.conf" << EOF +[dummy] + driver = dummy-ups + desc = "Crash Dummy" + port = dummy.seq + #mode = dummy-loop +EOF + [ $? = 0 ] || die "Failed to populate temporary FS structure for the NIT: ups.conf" + + if [ x"${TOP_SRCDIR}" != x ]; then + cp "${TOP_SRCDIR}/data/evolution500.seq" "${TOP_SRCDIR}/data/epdu-managed.dev" "$NUT_CONFPATH/" + + cat >> "$NUT_CONFPATH/ups.conf" << EOF +[UPS1] + driver = dummy-ups + desc = "Example event sequence" + port = evolution500.seq + +[UPS2] + driver = dummy-ups + desc = "Example ePDU data dump" + port = epdu-managed.dev + mode = dummy-once +EOF + [ $? = 0 ] || die "Failed to populate temporary FS structure for the NIT: ups.conf" + + # HACK: Avoid empty ups.status that may be present in example docs + # FIXME: Might we actually want that value (un-)set for tests?.. + # TODO: Check if the problem was with dummy-ups looping? [#1385] + for F in "$NUT_CONFPATH/"*.dev "$NUT_CONFPATH/"*.seq ; do + sed -e 's,^ups.status: *$,ups.status: OL BOOST,' -i'.bak' "$F" + grep -E '^ups.status:' "$F" >/dev/null || { echo "ups.status: OL BOOST" >> "$F"; } + done + fi + +} + +##################################################### + +isPidAlive() { + [ -n "$1" ] && [ "$1" -gt 0 ] || return + [ -d "/proc/$1" ] || kill -0 "$1" 2>/dev/null +} + +FAILED=0 +PASSED=0 + +testcase_upsd_no_configs_at_all() { + log_separator + log_info "Test UPSD without configs at all" + upsd -F + if [ "$?" = 0 ]; then + log_error "upsd should fail without configs" + FAILED="`expr $FAILED + 1`" + else + log_info "OK, upsd failed to start in wrong conditions" + PASSED="`expr $PASSED + 1`" + fi +} + +testcase_upsd_no_configs_driver_file() { + log_separator + log_info "Test UPSD without driver config file" + generatecfg_upsd_trivial + upsd -F + if [ "$?" = 0 ]; then + log_error "upsd should fail without driver config file" + FAILED="`expr $FAILED + 1`" + else + log_info "OK, upsd failed to start in wrong conditions" + PASSED="`expr $PASSED + 1`" + fi +} + +testcase_upsd_no_configs_in_driver_file() { + log_separator + log_info "Test UPSD without drivers defined in config file" + generatecfg_upsd_trivial + generatecfg_ups_trivial + upsd -F + if [ "$?" = 0 ]; then + log_error "upsd should fail without drivers defined in config file" + FAILED="`expr $FAILED + 1`" + else + log_info "OK, upsd failed to start in wrong conditions" + PASSED="`expr $PASSED + 1`" + fi +} + +testcase_upsd_allow_no_device() { + log_separator + log_info "Test UPSD allowed to run without driver configs" + generatecfg_upsd_nodev + generatecfg_upsdusers_trivial + generatecfg_ups_trivial + upsd -F & + PID_UPSD="$!" + sleep 2 + if isPidAlive "$PID_UPSD"; then + log_info "OK, upsd is running" + PASSED="`expr $PASSED + 1`" + + log_separator + log_info "Test that UPSD responds to UPSC" + OUT="`upsc -l localhost:$NUT_PORT`" || die "upsd does not respond: $OUT" + if [ -n "$OUT" ] ; then + log_error "got reply for upsc listing when none was expected: $OUT" + FAILED="`expr $FAILED + 1`" + else + log_info "OK, empty response as expected" + PASSED="`expr $PASSED + 1`" + fi + else + log_error "upsd was expected to be running although no devices are defined" + FAILED="`expr $FAILED + 1`" + fi + kill -15 $PID_UPSD + wait $PID_UPSD +} + +testgroup_upsd_invalid_configs() { + testcase_upsd_no_configs_at_all + testcase_upsd_no_configs_driver_file + testcase_upsd_no_configs_in_driver_file +} + +testgroup_upsd_questionable_configs() { + testcase_upsd_allow_no_device +} + +######################################################### +### Tests in a common sandbox with driver(s) + server ### +######################################################### + +SANDBOX_CONFIG_GENERATED=false +sandbox_generate_configs() { + if $SANDBOX_CONFIG_GENERATED ; then return ; fi + + log_info "Generating configs for sandbox" + generatecfg_upsd_nodev + generatecfg_upsdusers_trivial + generatecfg_ups_dummy + SANDBOX_CONFIG_GENERATED=true +} + +sandbox_forget_configs() { + SANDBOX_CONFIG_GENERATED=false + if [ -z "${DEBUG_SLEEP-}" ] ; then + stop_daemons + fi +} + +sandbox_start_upsd() { + if isPidAlive "$PID_UPSD" ; then + return 0 + fi + + sandbox_generate_configs + + log_info "Starting UPSD for sandbox" + upsd -F & + PID_UPSD="$!" + sleep 5 +} + +sandbox_start_drivers() { + if isPidAlive "$PID_DUMMYUPS" \ + && { [ x"${TOP_SRCDIR}" != x ] && isPidAlive "$PID_DUMMYUPS1" && isPidAlive "$PID_DUMMYUPS2" \ + || [ x"${TOP_SRCDIR}" = x ] ; } \ + ; then + # All drivers expected for this environment are already running + return 0 + fi + + sandbox_generate_configs + + log_info "Starting dummy-ups driver(s) for sandbox" + #upsdrvctl -F start dummy & + dummy-ups -a dummy -F & + PID_DUMMYUPS="$!" + + if [ x"${TOP_SRCDIR}" != x ]; then + dummy-ups -a UPS1 -F & + PID_DUMMYUPS1="$!" + + dummy-ups -a UPS2 -F & + PID_DUMMYUPS2="$!" + fi + + sleep 5 + + if shouldDebug ; then + (ps -ef || ps -xawwu) 2>/dev/null | grep -E '(ups|nut|dummy)' || true + fi +} + +testcase_sandbox_start_upsd_alone() { + log_separator + log_info "Test starting UPSD but not a driver before it" + sandbox_start_upsd + + EXPECTED_UPSLIST='dummy' + if [ x"${TOP_SRCDIR}" != x ]; then + EXPECTED_UPSLIST="$EXPECTED_UPSLIST +UPS1 +UPS2" + fi + + log_info "Query listing from UPSD by UPSC (driver not running yet)" + OUT="`upsc -l localhost:$NUT_PORT`" || die "upsd does not respond: $OUT" + if [ x"$OUT" != x"$EXPECTED_UPSLIST" ] ; then + log_error "got this reply for upsc listing when '$EXPECTED_UPSLIST' was expected: $OUT" + FAILED="`expr $FAILED + 1`" + else + PASSED="`expr $PASSED + 1`" + fi + + log_info "Query driver state from UPSD by UPSC (driver not running yet)" + OUT="`upsc dummy@localhost:$NUT_PORT 2>&1`" && { + log_error "upsc was supposed to answer with error exit code: $OUT" + FAILED="`expr $FAILED + 1`" + } + if ! echo "$OUT" | grep 'Error: Driver not connected' ; then + log_error "got reply for upsc query when 'Error: Driver not connected' was expected: '$OUT'" + FAILED="`expr $FAILED + 1`" + else + PASSED="`expr $PASSED + 1`" + fi +} + +testcase_sandbox_start_upsd_after_drivers() { + # Historically this is a fallback from testcase_sandbox_start_drivers_after_upsd + kill -15 $PID_UPSD 2>/dev/null + wait $PID_UPSD + upsd -F & + PID_UPSD="$!" + + sandbox_start_drivers + sandbox_start_upsd + + sleep 5 + upsc dummy@localhost:$NUT_PORT || die "upsd does not respond" +} + +testcase_sandbox_start_drivers_after_upsd() { + #sandbox_start_upsd + testcase_sandbox_start_upsd_alone + sandbox_start_drivers + + log_info "Query driver state from UPSD by UPSC after driver startup" + upsc dummy@localhost:$NUT_PORT || { + # Should not get to this, except on very laggy systems maybe + log_error "Query failed, retrying with UPSD started after drivers" + testcase_sandbox_start_upsd_after_drivers + } + + if [ x"${TOP_SRCDIR}" != x ]; then + log_info "Wait for dummy UPSes with larger data sets to initialize" + for U in UPS1 UPS2 ; do + COUNTDOWN=60 + while ! upsc $U@localhost:$NUT_PORT ups.status ; do + sleep 1 + COUNTDOWN="`expr $COUNTDOWN - 1`" + # Systemic error, e.g. could not create socket file? + [ "$COUNTDOWN" -lt 1 ] && die "Dummy driver did not start or respond in time" + done + done + fi + + log_info "Expected drivers are now responding via UPSD" +} + +testcase_sandbox_upsc_query_model() { + OUT="`upsc dummy@localhost:$NUT_PORT device.model`" || die "upsd does not respond: $OUT" + if [ x"$OUT" != x"Dummy UPS" ] ; then + log_error "got this reply for upsc query when 'Dummy UPS' was expected: $OUT" + FAILED="`expr $FAILED + 1`" + else + PASSED="`expr $PASSED + 1`" + fi +} + +testcase_sandbox_upsc_query_bogus() { + log_info "Query driver state from UPSD by UPSC for bogus info" + OUT="`upsc dummy@localhost:$NUT_PORT ups.bogus.value 2>&1`" && { + log_error "upsc was supposed to answer with error exit code: $OUT" + FAILED="`expr $FAILED + 1`" + } + if ! echo "$OUT" | grep 'Error: Variable not supported by UPS' ; then + log_error "got reply for upsc query when 'Error: Variable not supported by UPS' was expected: $OUT" + FAILED="`expr $FAILED + 1`" + else + PASSED="`expr $PASSED + 1`" + fi +} + +testcase_sandbox_upsc_query_timer() { + log_separator + log_info "Test that dummy-ups TIMER action changes the reported state" + # Driver is set up to flip ups.status every 5 sec, so check every 3 + OUT1="`upsc dummy@localhost:$NUT_PORT ups.status`" || die "upsd does not respond: $OUT1" ; sleep 3 + OUT2="`upsc dummy@localhost:$NUT_PORT ups.status`" || die "upsd does not respond: $OUT2" + OUT3="" + OUT4="" + if [ x"$OUT1" = x"$OUT2" ]; then + sleep 3 + OUT3="`upsc dummy@localhost:$NUT_PORT ups.status`" || die "upsd does not respond: $OUT3" + if [ x"$OUT2" = x"$OUT3" ]; then + sleep 3 + OUT4="`upsc dummy@localhost:$NUT_PORT ups.status`" || die "upsd does not respond: $OUT4" + fi + fi + if echo "$OUT1$OUT2$OUT3$OUT4" | grep "OB" && echo "$OUT1$OUT2$OUT3$OUT4" | grep "OL" ; then + log_info "OK, ups.status flips over time" + PASSED="`expr $PASSED + 1`" + else + log_error "ups.status did not flip over time" + FAILED="`expr $FAILED + 1`" + fi +} + +isTestablePython() { + # We optionally make python module (if interpreter is found): + if [ x"${TOP_BUILDDIR}" = x ] \ + || [ ! -x "${TOP_BUILDDIR}/scripts/python/module/test_nutclient.py" ] \ + ; then + return 1 + fi + return 0 +} + +testcase_sandbox_python_without_credentials() { + isTestablePython || return 0 + log_separator + log_info "Call Python module test suite: PyNUT (NUT Python bindings) without login credentials" + if ( unset NUT_USER || true + unset NUT_PASS || true + "${TOP_BUILDDIR}/scripts/python/module/test_nutclient.py" + ) ; then + log_info "OK, PyNUT did not complain" + PASSED="`expr $PASSED + 1`" + else + log_error "PyNUT complained, check above" + FAILED="`expr $FAILED + 1`" + fi +} + +testcase_sandbox_python_with_credentials() { + isTestablePython || return 0 + + # That script says it expects data/evolution500.seq (as the UPS1 dummy) + # but the dummy data does not currently let issue the commands and + # setvars tested from python script. + log_separator + log_info "Call Python module test suite: PyNUT (NUT Python bindings) with login credentials" + if ( + NUT_USER='admin' + NUT_PASS="${TESTPASS_ADMIN}" + export NUT_USER NUT_PASS + "${TOP_BUILDDIR}/scripts/python/module/test_nutclient.py" + ) ; then + log_info "OK, PyNUT did not complain" + PASSED="`expr $PASSED + 1`" + else + log_error "PyNUT complained, check above" + FAILED="`expr $FAILED + 1`" + fi +} + +testcases_sandbox_python() { + isTestablePython || return 0 + testcase_sandbox_python_without_credentials + testcase_sandbox_python_with_credentials +} + +#################################### + +isTestableCppNIT() { + # We optionally make and here can run C++ client tests: + if [ x"${TOP_BUILDDIR}" = x ] \ + || [ ! -x "${TOP_BUILDDIR}/tests/cppnit" ] \ + ; then + return 1 + fi + return 0 +} + +testcase_sandbox_cppnit_without_creds() { + isTestableCppNIT || return 0 + + log_separator + log_info "Call libnutclient test suite: cppnit without login credentials" + if ( unset NUT_USER || true + unset NUT_PASS || true + "${TOP_BUILDDIR}/tests/cppnit" + ) ; then + log_info "OK, cppnit did not complain" + PASSED="`expr $PASSED + 1`" + else + log_error "cppnit complained, check above" + FAILED="`expr $FAILED + 1`" + fi +} + +testcase_sandbox_cppnit_simple_admin() { + isTestableCppNIT || return 0 + + log_separator + log_info "Call libnutclient test suite: cppnit with login credentials: simple admin" + if ( + NUT_USER='admin' + NUT_PASS="${TESTPASS_ADMIN}" + if [ x"${TOP_SRCDIR}" != x ]; then + # Avoid dummies with TIMER flip-flops + NUT_SETVAR_DEVICE='UPS2' + else + # Risks failure when lauching sub-test at the wrong second + NUT_SETVAR_DEVICE='dummy' + fi + unset NUT_PRIMARY_DEVICE + export NUT_USER NUT_PASS NUT_SETVAR_DEVICE + "${TOP_BUILDDIR}/tests/cppnit" + ) ; then + log_info "OK, cppnit did not complain" + PASSED="`expr $PASSED + 1`" + else + log_error "cppnit complained, check above" + FAILED="`expr $FAILED + 1`" + fi +} + +testcase_sandbox_cppnit_upsmon_primary() { + isTestableCppNIT || return 0 + + log_separator + log_info "Call libnutclient test suite: cppnit with login credentials: upsmon-primary" + if ( + NUT_USER='dummy-admin' + NUT_PASS="${TESTPASS_UPSMON_PRIMARY}" + NUT_PRIMARY_DEVICE='dummy' + unset NUT_SETVAR_DEVICE + export NUT_USER NUT_PASS NUT_PRIMARY_DEVICE + "${TOP_BUILDDIR}/tests/cppnit" + ) ; then + log_info "OK, cppnit did not complain" + PASSED="`expr $PASSED + 1`" + else + log_error "cppnit complained, check above" + FAILED="`expr $FAILED + 1`" + fi +} + +testcase_sandbox_cppnit_upsmon_master() { + isTestableCppNIT || return 0 + + log_separator + log_info "Call libnutclient test suite: cppnit with login credentials: upsmon-master" + if ( + NUT_USER='dummy-admin-m' + NUT_PASS="${TESTPASS_UPSMON_PRIMARY}" + NUT_PRIMARY_DEVICE='dummy' + unset NUT_SETVAR_DEVICE + export NUT_USER NUT_PASS NUT_PRIMARY_DEVICE + "${TOP_BUILDDIR}/tests/cppnit" + ) ; then + log_info "OK, cppnit did not complain" + PASSED="`expr $PASSED + 1`" + else + log_error "cppnit complained, check above" + FAILED="`expr $FAILED + 1`" + fi +} + +testcases_sandbox_cppnit() { + isTestableCppNIT || return 0 + testcase_sandbox_cppnit_without_creds + testcase_sandbox_cppnit_upsmon_primary + testcase_sandbox_cppnit_upsmon_master + testcase_sandbox_cppnit_simple_admin +} + +# TODO: Some upsmon tests? + +testgroup_sandbox() { + testcase_sandbox_start_drivers_after_upsd + testcase_sandbox_upsc_query_model + testcase_sandbox_upsc_query_bogus + testcase_sandbox_upsc_query_timer + testcases_sandbox_python + testcases_sandbox_cppnit + + sandbox_forget_configs +} + +testgroup_sandbox_python() { + # Arrange for quick test iterations + testcase_sandbox_start_drivers_after_upsd + testcases_sandbox_python + sandbox_forget_configs +} + +testgroup_sandbox_cppnit() { + # Arrange for quick test iterations + testcase_sandbox_start_drivers_after_upsd + testcases_sandbox_cppnit + sandbox_forget_configs +} + +testgroup_sandbox_cppnit_simple_admin() { + # Arrange for quick test iterations + testcase_sandbox_start_drivers_after_upsd + testcase_sandbox_cppnit_simple_admin + sandbox_forget_configs +} + +################################################################ + +case "${NIT_CASE}" in + cppnit) testgroup_sandbox_cppnit ;; + python) testgroup_sandbox_python ;; + testcase_*|testgroup_*|testcases_*|testgroups_*) + "${NIT_CASE}" ;; + "") # Default test groups: + testgroup_upsd_invalid_configs + testgroup_upsd_questionable_configs + testgroup_sandbox + ;; + *) die "Unsupported NIT_CASE='$NIT_CASE' was requested" ;; +esac + +log_separator +log_info "OVERALL: PASSED=$PASSED FAILED=$FAILED" + +# Allow to leave the sandbox daemons running for a while, +# to experiment with them interactively: +if [ -n "${DEBUG_SLEEP-}" ] ; then + log_separator + log_info "Sleeping now as asked, so you can play with the driver and server running; hint: export NUT_PORT=$NUT_PORT" + log_separator + if [ "${DEBUG_SLEEP-}" -gt 0 ] ; then + sleep "${DEBUG_SLEEP}" + else + sleep 60 + fi + log_info "Sleep finished" + log_separator +fi + +if [ "$PASSED" = 0 ] || [ "$FAILED" != 0 ] ; then + die "Some test scenarios failed!" +else + log_info "SUCCESS" +fi diff --git a/tests/cpputest-client.cpp b/tests/cpputest-client.cpp new file mode 100644 index 0000000..9a6169a --- /dev/null +++ b/tests/cpputest-client.cpp @@ -0,0 +1,415 @@ +/* cpputest-client - CppUnit libnutclient active test + + Module for NUT `cpputest` runner, to check client-server interactions + as part of NIT (NUT Integration Testing) suite and similar scenarios. + This is an "active" NUT client talking to an `upsd` on $NUT_PORT, + as opposed to nutclienttest.cpp which unit-tests the class API etc. + in isolated-binary fashion. + + Copyright (C) 2022 Jim Klimov + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "common.h" + +/* Current CPPUnit offends the honor of C++98 */ +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS || defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS) +#pragma GCC diagnostic push +# ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS +# pragma GCC diagnostic ignored "-Wglobal-constructors" +# endif +# ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS +# pragma GCC diagnostic ignored "-Wexit-time-destructors" +# endif +#endif + +#include +#include +#include +#include +#include + +namespace nut { + +class NutActiveClientTest : public CppUnit::TestFixture +{ + /* Note: is "friend" of nut::TcpClient class + * to test a few of its protected methods */ + + CPPUNIT_TEST_SUITE( NutActiveClientTest ); + CPPUNIT_TEST( test_query_ver ); + CPPUNIT_TEST( test_list_ups ); + CPPUNIT_TEST( test_auth_user ); + CPPUNIT_TEST( test_auth_primary ); + CPPUNIT_TEST_SUITE_END(); + +private: + /* Fed by caller via envvars: */ + uint16_t NUT_PORT = 0; + std::string NUT_USER = ""; + std::string NUT_PASS = ""; + std::string NUT_PRIMARY_DEVICE = ""; + std::string NUT_SETVAR_DEVICE = ""; + +public: + void setUp() override; + void tearDown() override; + + void test_query_ver(); + void test_list_ups(); + void test_auth_user(); + void test_auth_primary(); +}; + +// Registers the fixture into the 'registry' +CPPUNIT_TEST_SUITE_REGISTRATION( NutActiveClientTest ); + +} // namespace nut {} + +#ifndef _NUTCLIENTTEST_BUILD +# define _NUTCLIENTTEST_BUILD 1 +#endif + +#include "../clients/nutclient.h" +#include "../clients/nutclientmem.h" + +namespace nut { + +extern "C" { +strarr stringset_to_strarr(const std::set& strset); +strarr stringvector_to_strarr(const std::vector& strset); +} // extern "C" + +void NutActiveClientTest::setUp() +{ + /* NUT_PORT etc. are provided by external test suite driver */ + char * s; + + s = std::getenv("NUT_PORT"); + if (s) { + long l = atol(s); + if (l < 1 || l > 65535) { + throw std::runtime_error("NUT_PORT specified by caller is out of range"); + } + NUT_PORT = static_cast(l); + } else { + throw std::runtime_error("NUT_PORT not specified by caller, NIT should call this test"); + } + + s = std::getenv("NUT_USER"); + if (s) { + NUT_USER = s; + } // else stays empty + + s = std::getenv("NUT_PASS"); + if (s) { + NUT_PASS = s; + } // else stays empty + + s = std::getenv("NUT_PRIMARY_DEVICE"); + if (s) { + NUT_PRIMARY_DEVICE = s; + } // else stays empty + + s = std::getenv("NUT_SETVAR_DEVICE"); + if (s) { + NUT_SETVAR_DEVICE = s; + } // else stays empty +} + +void NutActiveClientTest::tearDown() +{ +} + +void NutActiveClientTest::test_query_ver() { + nut::TcpClient c("localhost", NUT_PORT); + std::string s; + + std::cerr << "[D] C++ NUT Client lib test running against Data Server at: " + << c.getHost() << ':' << c.getPort() << std::endl; + + CPPUNIT_ASSERT_MESSAGE( + "TcpClient is not connected after constructor", + c.isConnected()); + + /* Note: generic client code can not use protected methods + * like low-level sendQuery(), list(), get() and some more, + * but this NutActiveClientTest is a friend of TcpClient: + */ + s = c.sendQuery("VER"); + std::cerr << "[D] Got Data Server VER: " << s << std::endl; + + try { + s = c.sendQuery("PROTVER"); + std::cerr << "[D] Got PROTVER: " << s << std::endl; + } + catch(nut::NutException& ex) + { + std::cerr << "[D] Did not get PROTVER: " << ex.what() << std::endl; + } + + try { + s = c.sendQuery("NETVER"); + std::cerr << "[D] Got NETVER (obsolete): " << s << std::endl; + } + catch(nut::NutException& ex) + { + std::cerr << "[D] Did not get NETVER (obsolete): " << ex.what() << std::endl; + } + + try { + c.logout(); + } + catch(nut::NutException& ex) + { + std::cerr << "[D] Could not get LOGOUT: " << ex.what() << std::endl; + } + + try { + c.disconnect(); + } + catch(nut::NutException& ex) + { + /* NUT_UNUSED_VARIABLE(ex); */ + std::cerr << "[D] Could not get disconnect(): " << ex.what() << std::endl; + } +} + +void NutActiveClientTest::test_list_ups() { + nut::TcpClient c("localhost", NUT_PORT); + std::set devs; + bool noException = true; + + try { + devs = c.getDeviceNames(); + std::cerr << "[D] Got device list (" << devs.size() << "): ["; + for (std::set::iterator it = devs.begin(); + it != devs.end(); it++ + ) { + if (it != devs.begin()) { + std::cerr << ", "; + } + std::cerr << '"' << *it << '"'; + } + std::cerr << "]" << std::endl; + } + catch(nut::NutException& ex) + { + std::cerr << "[D] Could not device list: " << ex.what() << std::endl; + noException = false; + } + + c.logout(); + c.disconnect(); + + CPPUNIT_ASSERT_MESSAGE( + "Failed to list UPS with TcpClient: threw NutException", + noException); +} + +void NutActiveClientTest::test_auth_user() { + if (NUT_USER.empty()) { + std::cerr << "[D] SKIPPING test_auth_user()" << std::endl; + return; + } + + nut::TcpClient c("localhost", NUT_PORT); + bool noException = true; + try { + c.authenticate(NUT_USER, NUT_PASS); + std::cerr << "[D] Authenticated without exceptions" << std::endl; + /* Note: no high hopes here, credentials are checked by server + * when running critical commands, not at auth request itself */ + } + catch(nut::NutException& ex) + { + std::cerr << "[D] Could not authenticate as a simple user: " << ex.what() << std::endl; + noException = false; + } + + if (!NUT_SETVAR_DEVICE.empty()) { + try { + TrackingResult tres; + TrackingID tid; + int i; + std::string nutVar = "ups.status"; /* Has a risk of flip-flop with NIT dummy setup */ + std::string s1 = c.getDeviceVariableValue(NUT_SETVAR_DEVICE, nutVar)[0]; + std::string sTest = s1 + "-test"; + + std::cerr << "[D] Got initial device '" << NUT_SETVAR_DEVICE + << "' variable '" << nutVar << "' value: " << s1 << std::endl; + CPPUNIT_ASSERT_MESSAGE( + "Did not expect empty value here", + !s1.empty()); + + tid = c.setDeviceVariable(NUT_SETVAR_DEVICE, nutVar, sTest); + while ( (tres = c.getTrackingResult(tid)) == PENDING) { + usleep(100); + } + if (tres != SUCCESS) { + std::cerr << "[D] Failed to set device variable: " + << "tracking result is " << tres << std::endl; + noException = false; + } + /* Check what we got after set */ + /* Note that above we told the server to tell the driver + * to set a dstate entry; below we ask the server to ask + * the driver and relay the answer to us. The dummy-ups + * driver may also be in a sleeping state between cycles. + * Data propagation may be not instantaneous, so we loop + * for a while to see the expected value (or give up). + */ + std::string s2; + for (i = 0; i < 100 ; i++) { + s2 = c.getDeviceVariableValue(NUT_SETVAR_DEVICE, nutVar)[0]; + if (s2 == sTest) + break; + usleep(100000); + } + std::cerr << "[D] Read back: " << s2 + << " after " << (100 * i) << "msec" + << std::endl; + + /* Fix it back */ + tid = c.setDeviceVariable(NUT_SETVAR_DEVICE, nutVar, s1); + while ( (tres = c.getTrackingResult(tid)) == PENDING) { + usleep(100); + } + if (tres != SUCCESS) { + std::cerr << "[D] Failed to set device variable: " + << "tracking result is " << tres << std::endl; + noException = false; + } + std::string s3; + for (i = 0; i < 100 ; i++) { + s3 = c.getDeviceVariableValue(NUT_SETVAR_DEVICE, nutVar)[0]; + if (s3 == s1) + break; + usleep(100000); + } + std::cerr << "[D] Read back: " << s3 + << " after " << (100 * i) << "msec" + << std::endl; + + if (s3 != s1) { + std::cerr << "[D] Final device variable value '" << s3 + << "' differs from original '" << s1 + << "'" << std::endl; + noException = false; + } + + if (s2 == s1) { + std::cerr << "[D] Tweaked device variable value '" << s2 + << "' does not differ from original '" << s1 + << "'" << std::endl; + noException = false; + } + + if (noException) { + std::cerr << "[D] Tweaked device variable value OK" << std::endl; + } + } + catch(nut::NutException& ex) + { + std::cerr << "[D] Failed to set device variable: " + << ex.what() << std::endl; + noException = false; + } + } else { + std::cerr << "[D] SKIPPING test_auth_user() active test " + << "(got no NUT_SETVAR_DEVICE to poke)" << std::endl; + } + + c.logout(); + c.disconnect(); + + CPPUNIT_ASSERT_MESSAGE( + "Failed to auth as user with TcpClient or tweak device variable", + noException); +} + +void NutActiveClientTest::test_auth_primary() { + if (NUT_USER.empty() || NUT_PRIMARY_DEVICE.empty()) { + std::cerr << "[D] SKIPPING test_auth_primary()" << std::endl; + return; + } + + nut::TcpClient c("localhost", NUT_PORT); + bool noException = true; + try { + c.authenticate(NUT_USER, NUT_PASS); + std::cerr << "[D] Authenticated without exceptions" << std::endl; + } + catch(nut::NutException& ex) + { + std::cerr << "[D] Could not authenticate as an upsmon primary user: " + << ex.what() << std::endl; + noException = false; + } + + try { + Device d = c.getDevice(NUT_PRIMARY_DEVICE); + bool gotPrimary = false; + bool gotMaster = false; + + try { + c.deviceMaster(NUT_PRIMARY_DEVICE); + gotMaster = true; + std::cerr << "[D] Elevated as MASTER without exceptions" << std::endl; + } + catch(nut::NutException& ex) + { + std::cerr << "[D] Could not elevate as MASTER for " + << "NUT_PRIMARY_DEVICE " << NUT_PRIMARY_DEVICE << ": " + << ex.what() << std::endl; + } + + try { + c.devicePrimary(NUT_PRIMARY_DEVICE); + gotPrimary = true; + std::cerr << "[D] Elevated as PRIMARY without exceptions" << std::endl; + } + catch(nut::NutException& ex) + { + std::cerr << "[D] Could not elevate as PRIMARY for " + << "NUT_PRIMARY_DEVICE " << NUT_PRIMARY_DEVICE << ": " + << ex.what() << std::endl; + } + + if (!gotMaster && !gotPrimary) + noException = false; + } + catch(nut::NutException& ex) + { + std::cerr << "[D] NUT_PRIMARY_DEVICE " << NUT_PRIMARY_DEVICE + << " not found on Data Server: " + << ex.what() << std::endl; + noException = false; + } + + c.logout(); + c.disconnect(); + + CPPUNIT_ASSERT_MESSAGE( + "Failed to auth as user with TcpClient: threw NutException", + noException); +} + +} // namespace nut {} + +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS || defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS) +#pragma GCC diagnostic pop +#endif diff --git a/tests/cpputest.cpp b/tests/cpputest.cpp index 448dd5b..d0b0adb 100644 --- a/tests/cpputest.cpp +++ b/tests/cpputest.cpp @@ -2,6 +2,7 @@ Copyright (C) 2012 Emilien Kia + 2020 Jim Klimov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,27 +19,75 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include +#include #include +#include #include #include +#include "common.h" +// Inspired by https://stackoverflow.com/a/66702001 +class MyCustomProgressTestListener : public CppUnit::TextTestProgressListener { + public: + virtual void startTest(CppUnit::Test *test) override; +}; + +// Implement out of class declaration to avoid +// error: 'MyCustomProgressTestListener' has no out-of-line virtual method +// definitions; its vtable will be emitted in every translation unit +// [-Werror,-Wweak-vtables] +void MyCustomProgressTestListener::startTest(CppUnit::Test *test) { + //fprintf(stderr, "starting test %s\n", test->getName().c_str()); + std::cerr << "starting test " << test->getName() << std::endl; +} int main(int argc, char* argv[]) { + bool verbose = false; + if (argc > 1) { + if (strcmp("-v", argv[1]) == 0 || strcmp("--verbose", argv[1]) == 0 ) { + verbose = true; + } + } + /* Get the top level suite from the registry */ + std::cerr << "D: Getting test suite..." << std::endl; CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); /* Adds the test to the list of test to run */ + std::cerr << "D: Preparing test runner..." << std::endl; CppUnit::TextUi::TestRunner runner; runner.addTest( suite ); /* Change the default outputter to a compiler error format outputter */ + std::cerr << "D: Setting test runner outputter..." << std::endl; runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), std::cerr ) ); + + if (verbose) { + /* Add a listener to report test names */ + std::cerr << "D: Setting test runner listener for test names..." << std::endl; + MyCustomProgressTestListener progress; + runner.eventManager().addListener(&progress); + } + /* Run the tests. */ - bool wasSucessful = runner.run(); + bool wasSucessful = false; + try { + std::cerr << "D: Launching the test run..." << std::endl; + wasSucessful = runner.run(); + } + catch ( std::invalid_argument &e ) // Test path not resolved + { + std::cerr << std::endl + << "ERROR: " << e.what() + << std::endl; + wasSucessful = false; + } /* Return error code 1 if the one of test failed. */ + std::cerr << "D: Got to the end of test suite with code " << + "'" << ( wasSucessful ? "true" : "false" ) << "'" << std::endl; return wasSucessful ? 0 : 1; } - diff --git a/tests/example.cpp b/tests/example.cpp index 28ea52e..cb52e93 100644 --- a/tests/example.cpp +++ b/tests/example.cpp @@ -2,6 +2,7 @@ Copyright (C) 2012 Emilien Kia + 2020 Jim Klimov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,6 +18,20 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include "common.h" + +/* Current CPPUnit offends the honor of C++98 */ +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS || defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS) +#pragma GCC diagnostic push +# ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS +# pragma GCC diagnostic ignored "-Wglobal-constructors" +# endif +# ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS +# pragma GCC diagnostic ignored "-Wexit-time-destructors" +# endif +#endif + #include class ExampleTest : public CppUnit::TestFixture @@ -26,8 +41,8 @@ class ExampleTest : public CppUnit::TestFixture CPPUNIT_TEST_SUITE_END(); public: - void setUp(); - void tearDown(); + void setUp() override; + void tearDown() override; void testOne(); }; @@ -53,10 +68,12 @@ void ExampleTest::testOne() float f = 1.0; // Process - int cast = (int)f; + int cast = static_cast(f); // Check CPPUNIT_ASSERT_EQUAL( i, cast ); } - +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS || defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS) +#pragma GCC diagnostic pop +#endif diff --git a/tests/getvaluetest.c b/tests/getvaluetest.c new file mode 100644 index 0000000..769df06 --- /dev/null +++ b/tests/getvaluetest.c @@ -0,0 +1,282 @@ +/* getvaluetest - check that the bitness/endianness dependent conversions + * of representation of numeric types between wire protocols and different + * CPU computations produce expected results. + * + * See also: + * https://github.com/networkupstools/nut/pull/1055 + * https://github.com/networkupstools/nut/pull/1040 + * https://github.com/networkupstools/nut/pull/1024 + * https://github.com/networkupstools/nut/issues/1023 + * + * Copyright (C) + * 2021 Nick Briggs + * 2022 Jim Klimov + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config.h" + +#include +#include +#include +#include +#include +#include "hidtypes.h" +#include "usb-common.h" +#include "common.h" + +void GetValue(const unsigned char *Buf, HIDData_t *pData, long *pValue); + +static void Usage(char *name) { + printf("%s [ ]\n", name); + printf(" - string of hex digit pairs, space separated\n"); + printf(" - offset of the report item value in bits, typically 0..31\n"); + printf(" - size of the report item value in bits: typically 1..32\n"); + printf(" - logical minimum value for report item\n"); + printf(" - logical maximum value for report item\n"); + printf(" - expected value\n"); + printf("\n"); + printf("%s \"0c 64 11 0d\" 8 16 0 65535 3345\n", name); + printf("\nIf no arguments are given a builtin set of tests are run.\n"); +} + +static void PrintBufAndData(uint8_t *buf, size_t bufSize, HIDData_t *pData) { + size_t i; + + printf("buf \""); + for (i = 0; i < bufSize - 1; i++) { + printf("%02x ", buf[i]); + } + printf("%02x\"", buf[bufSize - 1]); + printf(" offset %u size %u logmin %ld (0x%lx) logmax %ld (0x%lx)", + pData->Offset, pData->Size, pData->LogMin, pData->LogMin, pData->LogMax, pData->LogMax); +} + +static int RunBuiltInTests(char *argv[]) { + NUT_UNUSED_VARIABLE(argv); + + int exitStatus = 0; + size_t i; + char *next; + uint8_t reportBuf[64]; + size_t bufSize; + HIDData_t data; + long value; + + static struct { + char *buf; /* item data, starts with report id byte, then remaining report bytes */ + uint8_t Offset; /* item offset in bits, typically 0..31 */ + uint8_t Size; /* item size in bits, typically 1..32 */ + long LogMin, LogMax; /* logical minimum and maximum values */ + long expectedValue; /* the expected result of decoding the value in the buffer */ + } testData[] = { + {.buf = "00 ff ff ff ff", .Offset = 0, .Size = 32, .LogMin = -1, .LogMax = 2147483647, .expectedValue = -1}, + {.buf = "00 ff", .Offset = 0, .Size = 8, .LogMin = -1, .LogMax = 127, .expectedValue = -1}, + {.buf = "00 ff", .Offset = 0, .Size = 8, .LogMin = 0, .LogMax = 127, .expectedValue = 127}, + {.buf = "00 ff", .Offset = 0, .Size = 8, .LogMin = 0, .LogMax = 255, .expectedValue = 255}, + {.buf = "33 00 0a 08 80", .Offset = 0, .Size = 32, .LogMin = 0, .LogMax = 65535, .expectedValue = 2560}, + {.buf = "00 00 08 00 00", .Offset = 0, .Size = 32, .LogMin = 0, .LogMax = 65535, .expectedValue = 2048}, + {.buf = "06 00 00 08", .Offset = 0, .Size = 8, .LogMin = 0, .LogMax = 255, .expectedValue = 0}, + {.buf = "06 00 00 08", .Offset = 8, .Size = 8, .LogMin = 0, .LogMax = 255, .expectedValue = 0}, + {.buf = "06 00 00 08", .Offset = 16, .Size = 8, .LogMin = 0, .LogMax = 255, .expectedValue = 8}, + {.buf = "16 0c 00 00 00", .Offset = 0, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 0}, + {.buf = "16 0c 00 00 00", .Offset = 1, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 0}, + {.buf = "16 0c 00 00 00", .Offset = 2, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 1}, + {.buf = "16 0c 00 00 00", .Offset = 3, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 1}, + {.buf = "16 0c 00 00 00", .Offset = 4, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 0}, + {.buf = "16 0c 00 00 00", .Offset = 5, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 0}, + {.buf = "16 0c 00 00 00", .Offset = 6, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 0}, + {.buf = "16 0c 00 00 00", .Offset = 7, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 0}, + {.buf = "16 0c 00 00 00", .Offset = 8, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 0}, + {.buf = "16 0c 00 00 00", .Offset = 9, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 0}, + {.buf = "16 0c 00 00 00", .Offset = 10, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 0} + }; + + for (i = 0; i < sizeof(testData)/sizeof(testData[0]); i++) { + next = testData[i].buf; + for (bufSize = 0; *next != 0; bufSize++) { + reportBuf[bufSize] = (uint8_t) strtol(next, (char **)&next, 16); + } + memset((void *)&data, 0, sizeof(data)); + data.Offset = testData[i].Offset; + data.Size = testData[i].Size; + data.LogMin = testData[i].LogMin; + data.LogMax = testData[i].LogMax; + + GetValue(reportBuf, &data, &value); + + printf("Test #%zd ", i + 1); + PrintBufAndData(reportBuf, bufSize, &data); + if (value == testData[i].expectedValue) { + printf(" value %ld PASS\n", value); + } else { + printf(" value %ld FAIL expected %ld\n", value, testData[i].expectedValue); + exitStatus = 1; + } + } + + /* Emulate rdlen calculations in libusb{0,1}.c or + * langid calculations in nutdrv_qx.c; in these + * cases we take two bytes (cast from usb_ctrl_char + * type, may be signed depending on used API version) + * from the protocol buffer, and build a platform + * dependent representation of a two-byte word. + */ + usb_ctrl_char bufC[2]; + signed char bufS[2]; + unsigned char bufU[2]; + int rdlen; + + /* Example from issue https://github.com/networkupstools/nut/issues/1261 + * where resulting length 0x01a9 should be "425" but ended up "-87" */ + bufC[0] = (usb_ctrl_char)0xa9; + bufC[1] = (usb_ctrl_char)0x01; + + bufS[0] = (signed char)0xa9; + bufS[1] = (signed char)0x01; + + bufU[0] = (unsigned char)0xa9; + bufU[1] = (unsigned char)0x01; + + /* Check different conversion methods and hope current build CPU, + * C implementation etc. do not mess up bit-shifting vs rotation, + * zeroing high bits, int type width extension et al. If something + * is mismatched below, the production NUT code may need adaptations + * for that platform to count stuff correctly! + */ + printf("\nTesting bit-shifting approaches used in codebase to get 2-byte int lengths from wire bytes:\n"); + printf("(Expected correct value is '425', incorrect '-87' or other)\n"); + +#define REPORT_VERDICT(expected) { if (expected) { printf(" - PASS\n"); } else { printf(" - FAIL\n"); exitStatus = 1; } } + + rdlen = bufC[0] | (bufC[1] << 8); + printf(" * reference: no casting, usb_ctrl_char :\t%d\t(depends on libusb API built against)", rdlen); + REPORT_VERDICT (rdlen == 425 || rdlen == -87) + + rdlen = bufS[0] | (bufS[1] << 8); + printf(" * reference: no casting, signed char :\t%d\t(expected '-87' here)", rdlen); + REPORT_VERDICT (rdlen == -87) + + rdlen = bufU[0] | (bufU[1] << 8); + printf(" * reference: no casting, unsigned char :\t%d\t(expected '425')", rdlen); + REPORT_VERDICT (rdlen == 425) + + + rdlen = (uint8_t)bufC[0] | ((uint8_t)bufC[1] << 8); + printf(" * uint8_t casting, usb_ctrl_char :\t%d", rdlen); + REPORT_VERDICT (rdlen == 425) + + rdlen = (uint8_t)bufS[0] | ((uint8_t)bufS[1] << 8); + printf(" * uint8_t casting, signed char :\t%d", rdlen); + REPORT_VERDICT (rdlen == 425) + + rdlen = (uint8_t)bufU[0] | ((uint8_t)bufU[1] << 8); + printf(" * uint8_t casting, unsigned char :\t%d", rdlen); + REPORT_VERDICT (rdlen == 425) + + + rdlen = ((uint8_t)bufC[0]) | (((uint8_t)bufC[1]) << 8); + printf(" * uint8_t casting with parentheses, usb_ctrl_char :\t%d", rdlen); + REPORT_VERDICT (rdlen == 425) + + rdlen = ((uint8_t)bufS[0]) | (((uint8_t)bufS[1]) << 8); + printf(" * uint8_t casting with parentheses, signed char :\t%d", rdlen); + REPORT_VERDICT (rdlen == 425) + + rdlen = ((uint8_t)bufU[0]) | (((uint8_t)bufU[1]) << 8); + printf(" * uint8_t casting with parentheses, unsigned char :\t%d", rdlen); + REPORT_VERDICT (rdlen == 425) + + + rdlen = ((uint16_t)(bufC[0]) & 0x00FF) | (((uint16_t)(bufC[1]) & 0x00FF) << 8); + printf(" * uint16_t casting with 8-bit mask, usb_ctrl_char :\t%d", rdlen); + REPORT_VERDICT (rdlen == 425) + + rdlen = ((uint16_t)(bufS[0]) & 0x00FF) | (((uint16_t)(bufS[1]) & 0x00FF) << 8); + printf(" * uint16_t casting with 8-bit mask, signed char :\t%d", rdlen); + REPORT_VERDICT (rdlen == 425) + + rdlen = ((uint16_t)(bufU[0]) & 0x00FF) | (((uint16_t)(bufU[1]) & 0x00FF) << 8); + printf(" * uint16_t casting with 8-bit mask, unsigned char :\t%d", rdlen); + REPORT_VERDICT (rdlen == 425) + + + rdlen = 256 * (uint8_t)(bufC[1]) + (uint8_t)(bufC[0]); + printf(" * uint8_t casting with multiplication, usb_ctrl_char :\t%d", rdlen); + REPORT_VERDICT (rdlen == 425) + + rdlen = 256 * (uint8_t)(bufS[1]) + (uint8_t)(bufS[0]); + printf(" * uint8_t casting with multiplication, signed char :\t%d", rdlen); + REPORT_VERDICT (rdlen == 425) + + rdlen = 256 * (uint8_t)(bufU[1]) + (uint8_t)(bufU[0]); + printf(" * uint8_t casting with multiplication, unsigned char :\t%d", rdlen); + REPORT_VERDICT (rdlen == 425) + + + return (exitStatus); +} + +static int RunCommandLineTest(char *argv[]) { + uint8_t reportBuf[64]; + size_t bufSize; + char *start, *end; + HIDData_t data; + long value, expectedValue; + + start = argv[1]; + end = NULL; + for (bufSize = 0; *start != 0; bufSize++) { + reportBuf[bufSize] = (uint8_t) strtol(start, (char **)&end, 16); + if (start == end) break; + start = end; + } + memset((void *)&data, 0, sizeof(data)); + data.Offset = (uint8_t) atoi(argv[2]); + data.Size = (uint8_t) atoi(argv[3]); + data.LogMin = strtol(argv[4], 0, 0); + data.LogMax = strtol(argv[5], 0, 0); + expectedValue = strtol(argv[6], 0, 0); + + GetValue(reportBuf, &data, &value); + + printf("Test #0 "); + PrintBufAndData(reportBuf, bufSize, &data); + if (value == expectedValue) { + printf(" value %ld PASS\n", value); + return (0); + } else { + printf(" value %ld FAIL expected %ld\n", value, expectedValue); + return (1); + } +} + +int main (int argc, char *argv[]) { + int status; + + switch (argc) { + case 1: + status = RunBuiltInTests(argv); + break; + case 7: + status = RunCommandLineTest(argv); + break; + default: + Usage(argv[0]); + status = 2; + } + return(status); +} diff --git a/tests/nut-driver-enumerator-test--ups.conf b/tests/nut-driver-enumerator-test--ups.conf new file mode 100644 index 0000000..c2916e2 --- /dev/null +++ b/tests/nut-driver-enumerator-test--ups.conf @@ -0,0 +1,71 @@ +# This is an ups.conf file for nut-driver-enumerator-test.sh +# It is intentionally written in different samples of markup, +# do not clean it up ;) + +maxstartdelay=180 +globalflag + +[dummy1] +driver = dummy-ups + port = file1.dev + desc = "This is ups-1" +[epdu-2] +# This is an ePDU +driver=netxml-ups +port="http://172.16.1.2" +synchronous=yes +[epdu-2-snmp] +driver=snmp-ups +port=172.16.1.2 +synchronous=no + +[usb_3] + driver = "usbhid-ups" + port = "auto" + +[serial.4] + + driver = serial-ups +driverflag + port = /dev/ttyS1 # some path + + +[dummy-proxy] +driver = "dummy-ups " + port = remoteUPS@RemoteHost.local + +[dummy-proxy-localhost] +driver = 'dummy-ups ' + port = "localUPS@127.0.0.1" + +[valueHasEquals] + driver = dummy=ups + port = file1.dev # key = val, right? + +[valueHasHashtag] + driver = dummy-ups + port = file#1.dev + +[valueHasQuotedHashtag] + driver = dummy-ups + port = "file#1.dev" + +[qx-serial] + driver=nutdrv_qx + port = /dev/ttyb + +[qx-usb1] + driver=nutdrv_qx + port = auto +[qx-usb2] + driver=nutdrv_qx + port = /dev/usb/8 +[sectionWithComment]# Some comment + driver=nutdrv_qx#comment + port = /dev/usb/8 + desc="value with [brackets]" + [brackets with spaces are not sections] # but rather an invalid mess as binary parser may think + [sectionWithCommentWhitespace] # Some comment with a space and tab + driver=nutdrv_qx # comment + port = /dev/usb/8 # comment + commentedDriverFlag # This flag gotta mean something diff --git a/tests/nut-driver-enumerator-test.sh b/tests/nut-driver-enumerator-test.sh new file mode 100755 index 0000000..dd91a58 --- /dev/null +++ b/tests/nut-driver-enumerator-test.sh @@ -0,0 +1,314 @@ +#!/bin/sh + +# Copyright (C) 2018 Eaton +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +#! \file nut-driver-enumerator-test.sh +# \author Jim Klimov +# \brief Self-test for nut-driver-enumerator.sh utility +# \details Automated sanity test for nut-driver-enumerator.sh(.in) +# using different shells (per $SHELL_PROGS) and CLI requests +# for regression and compatibility tests as well as for TDD +# fueled by pre-decided expected outcomes. + +### Use a standard locale setup so sorting in expected results is not confused +LANG=C +LC_ALL=C +TZ=UTC +export LANG LC_ALL TZ + +### Note: These are relative to where the selftest script lives, +### not the NUT top_srcdir etc. They can be exported by a Makefile. +[ -n "${BUILDDIR-}" ] || BUILDDIR="`dirname $0`" +[ -n "${SRCDIR-}" ] || SRCDIR="`dirname $0`" +[ -n "${SHELL_PROGS-}" ] || SHELL_PROGS="/bin/sh" +case "${DEBUG-}" in + [Yy]|[Yy][Ee][Ss]) DEBUG=yes ;; + [Tt][Rr][Aa][Cc][Ee]) DEBUG=trace ;; + *) DEBUG="" ;; +esac + +SYSTEMD_CONFPATH="${BUILDDIR}/selftest-rw/systemd-units" +export SYSTEMD_CONFPATH + +NUT_CONFPATH="${BUILDDIR}/selftest-rw/nut" +export NUT_CONFPATH + +[ -n "${UPSCONF-}" ] || UPSCONF="${SRCDIR}/nut-driver-enumerator-test--ups.conf" +[ ! -s "${UPSCONF-}" ] && echo "FATAL : testing ups.conf not found as '$UPSCONF'" >&2 && exit 1 +export UPSCONF + +if [ ! -n "${NDE-}" ] ; then + for NDE in \ + "${BUILDDIR}/../scripts/upsdrvsvcctl/nut-driver-enumerator.sh" \ + "${SRCDIR}/../scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in" \ + ; do [ -s "$NDE" ] && break ; done +fi +[ ! -s "${NDE-}" ] && echo "FATAL : testing nut-driver-enumerator.sh implementation not found as '$NDE'" >&2 && exit 1 + +# TODO : Add tests that generate configuration files for units +#mkdir -p "${NUT_CONFPATH}" "${SYSTEMD_CONFPATH}" || exit + +FAIL_COUNT=0 +GOOD_COUNT=0 +callNDE() { + case "$DEBUG" in + yes) time $USE_SHELL $NDE "$@" ;; + trace) time $USE_SHELL -x $NDE "$@" ;; + *) $USE_SHELL $NDE "$@" 2>/dev/null ;; + esac +} + +run_testcase() { + # First 3 args are required as defined below; the rest are + # CLI arg(s) to nut-driver-enumerator.sh + CASE_DESCR="$1" + EXPECT_CODE="$2" + EXPECT_TEXT="$3" + shift 3 + + printf "Testing : SHELL='%s'\tCASE='%s'\t" "$USE_SHELL" "$CASE_DESCR" + OUT="`callNDE "$@"`" ; RESCODE=$? + printf "Got : RESCODE='%s'\t" "$RESCODE" + + RES=0 + if [ "$RESCODE" = "$EXPECT_CODE" ]; then + printf "STATUS_CODE='MATCHED'\t" + GOOD_COUNT="`expr $GOOD_COUNT + 1`" + else + printf "STATUS_CODE='MISMATCH' expect_code=%s received_code=%s\t" "$EXPECT_CODE" "$RESCODE" >&2 + FAIL_COUNT="`expr $FAIL_COUNT + 1`" + RES="`expr $RES + 1`" + fi + + if [ "$OUT" = "$EXPECT_TEXT" ]; then + printf "STATUS_TEXT='MATCHED'\n" + GOOD_COUNT="`expr $GOOD_COUNT + 1`" + else + printf "STATUS_TEXT='MISMATCH'\n" + printf '\t--- expected ---\n%s\n\t--- received ---\n%s\n\t--- MISMATCH ABOVE\n\n' "$EXPECT_TEXT" "$OUT" >&2 + # Give a nice output to help track the problem: + ( rm -f "/tmp/.nde.text.expected.$$" "/tmp/.nde.text.actual.$$" \ + && echo "$EXPECT_TEXT" > "/tmp/.nde.text.expected.$$" \ + && echo "$OUT" > "/tmp/.nde.text.actual.$$" \ + && diff -u "/tmp/.nde.text.expected.$$" "/tmp/.nde.text.actual.$$" ) 2>/dev/null || true + rm -f "/tmp/.nde.text.expected.$$" "/tmp/.nde.text.actual.$$" + FAIL_COUNT="`expr $FAIL_COUNT + 1`" + RES="`expr $RES + 2`" + fi + if [ "$RES" != 0 ] || [ -n "$DEBUG" ] ; then echo "" ; fi + return $RES +} + +################################################################## +# Note: expectations in test cases below are tightly connected # +# to both the current code in the script and content of the test # +# configuration file. # +################################################################## + +testcase_bogus_args() { + run_testcase "Reject unknown args" 1 "" \ + --some-bogus-arg +} + +testcase_list_all_devices() { + # We expect a list of unbracketed names from the device sections + # Note: unlike other outputs, this list is alphabetically sorted + run_testcase "List all device names from sections" 0 \ +"dummy-proxy +dummy-proxy-localhost +dummy1 +epdu-2 +epdu-2-snmp +qx-serial +qx-usb1 +qx-usb2 +sectionWithComment +sectionWithCommentWhitespace +serial.4 +usb_3 +valueHasEquals +valueHasHashtag +valueHasQuotedHashtag" \ + --list-devices +} + +testcase_show_all_configs() { + # We expect whitespace trimmed, comment-only lines removed + run_testcase "Show all configs" 0 \ +'maxstartdelay=180 +globalflag +[dummy1] +driver=dummy-ups +port=file1.dev +desc="This is ups-1" +[epdu-2] +driver=netxml-ups +port=http://172.16.1.2 +synchronous=yes +[epdu-2-snmp] +driver=snmp-ups +port=172.16.1.2 +synchronous=no +[usb_3] +driver=usbhid-ups +port=auto +[serial.4] +driver=serial-ups +driverflag +port=/dev/ttyS1 # some path +[dummy-proxy] +driver="dummy-ups " +port=remoteUPS@RemoteHost.local +[dummy-proxy-localhost] +driver='"'dummy-ups '"' +port=localUPS@127.0.0.1 +[valueHasEquals] +driver=dummy=ups +port=file1.dev # key = val, right? +[valueHasHashtag] +driver=dummy-ups +port=file#1.dev +[valueHasQuotedHashtag] +driver=dummy-ups +port=file#1.dev +[qx-serial] +driver=nutdrv_qx +port=/dev/ttyb +[qx-usb1] +driver=nutdrv_qx +port=auto +[qx-usb2] +driver=nutdrv_qx +port=/dev/usb/8 +[sectionWithComment] +driver=nutdrv_qx#comment +port=/dev/usb/8 +desc="value with [brackets]" +[brackets with spaces are not sections] # but rather an invalid mess as binary parser may think +[sectionWithCommentWhitespace] +driver=nutdrv_qx # comment +port=/dev/usb/8 # comment +commentedDriverFlag # This flag gotta mean something' \ + --show-all-configs +} + +testcase_upslist_debug() { + # We expect a list of names, ports and decided MEDIA type (for dependencies) + run_testcase "List decided MEDIA and config checksums for all devices" 0 \ +"INST: 68b329da9893e34099c7d8ad5cb9c940~[]: DRV='' PORT='' MEDIA='' SECTIONMD5='9a1f372a850f1ee3ab1fc08b185783e0' +INST: 010cf0aed6dd49865bb49b70267946f5~[dummy-proxy]: DRV='dummy-ups ' PORT='remoteUPS@RemoteHost.local' MEDIA='network' SECTIONMD5='aff543fc07d7fbf83e81001b181c8b97' +INST: 1ea79c6eea3681ba73cc695f3253e605~[dummy-proxy-localhost]: DRV='dummy-ups ' PORT='localUPS@127.0.0.1' MEDIA='network-localhost' SECTIONMD5='73e6b7e3e3b73558dc15253d8cca51b2' +INST: 76b645e28b0b53122b4428f4ab9eb4b9~[dummy1]: DRV='dummy-ups' PORT='file1.dev' MEDIA='' SECTIONMD5='9e0a326b67e00d455494f8b4258a01f1' +INST: a293d65e62e89d6cc3ac6cb88bc312b8~[epdu-2]: DRV='netxml-ups' PORT='http://172.16.1.2' MEDIA='network' SECTIONMD5='0d9a0147dcf87c7c720e341170f69ed4' +INST: 9a5561464ff8c78dd7cb544740ce2adc~[epdu-2-snmp]: DRV='snmp-ups' PORT='172.16.1.2' MEDIA='network' SECTIONMD5='2631b6c21140cea0dd30bb88b942ce3f' +INST: 16adbdafb22d9fdff1d09038520eb32e~[qx-serial]: DRV='nutdrv_qx' PORT='/dev/ttyb' MEDIA='serial' SECTIONMD5='e3e6e586fbe5b3c0a89432f4b993f4ad' +INST: a21bd2b786228b9619f6adba6db8fa83~[qx-usb1]: DRV='nutdrv_qx' PORT='auto' MEDIA='usb' SECTIONMD5='a6139c5da35bef89dc5b96e2296f5369' +INST: 0066605e07c66043a17eccecbeea1ac5~[qx-usb2]: DRV='nutdrv_qx' PORT='/dev/usb/8' MEDIA='usb' SECTIONMD5='5722dd9c21d07a1f5bcb516dbc458deb' +INST: 1280a731e03116f77290e51dd2a2f37e~[sectionWithComment]: DRV='nutdrv_qx#comment' PORT='/dev/usb/8' MEDIA='' SECTIONMD5='be30e15e17d0579c85eecaf176b4a064' +INST: 770abd5659061a29ed3ae4f7c0b00915~[sectionWithCommentWhitespace]: DRV='nutdrv_qx # comment' PORT='/dev/usb/8 # comment' MEDIA='' SECTIONMD5='c757822a331521cdc97310d0241eba28' +INST: efdb1b4698215fdca36b9bc06d24661d~[serial.4]: DRV='serial-ups' PORT='/dev/ttyS1 # some path' MEDIA='' SECTIONMD5='9c485f733aa6d6c85c1724f162929443' +INST: f4a1c33db201c2ca897a3337993c10fc~[usb_3]: DRV='usbhid-ups' PORT='auto' MEDIA='usb' SECTIONMD5='1f6a24becde9bd31c9852610658ef84a' +INST: 8e5686f92a5ba11901996c813e7bb23d~[valueHasEquals]: DRV='dummy=ups' PORT='file1.dev # key = val, right?' MEDIA='' SECTIONMD5='2f04d65da53e3b13771bb65422f0f4c0' +INST: 99da99b1e301e84f34f349443aac545b~[valueHasHashtag]: DRV='dummy-ups' PORT='file#1.dev' MEDIA='' SECTIONMD5='6029bda216de0cf1e81bd55ebd4a0fff' +INST: d50c3281f9b68a94bf9df72a115fbb5c~[valueHasQuotedHashtag]: DRV='dummy-ups' PORT='file#1.dev' MEDIA='' SECTIONMD5='af59c3c0caaa68dcd796d7145ae403ee'" \ + upslist_debug + + # FIXME : in [valueHasEquals] and [serial.4] the PORT value is quite bogus + # with its embedded comments. Check vs. binary config parser, whether in + # unquoted case only first token is the valid value, and how comments are + # handled in general? + # FIXME : in [valueHasHashtag] the line after "#" should likely be dropped + # (check in binary config parser first) while in [valueHasQuotedHashtag] + # it should stay. +} + +testcase_getValue() { + run_testcase "Query a configuration key (SDP)" 0 \ + "file1.dev" \ + --show-device-config-value dummy1 port + + run_testcase "Query a configuration key (other)" 0 \ + "yes" \ + --show-device-config-value epdu-2 synchronous + + run_testcase "Query a configuration key (originally quoted)" 0 \ + 'This is ups-1' \ + --show-device-config-value dummy1 desc + + run_testcase "Query a configuration flag (driver)" 0 \ + "driverflag" \ + --show-config-value 'serial.4' driverflag + + run_testcase "Query a missing configuration flag (driver)" 1 \ + "" \ + --show-config-value 'valueHasQuotedHashtag' nosuchflag + + run_testcase "Query multiple configuration keys (originally quoted)" 0 \ + 'This is ups-1 +file1.dev' \ + --show-device-config-value dummy1 desc port + + run_testcase "Query multiple configuration keys with some missing (originally quoted)" 1 \ + 'This is ups-1 + +file1.dev' \ + --show-device-config-value dummy1 desc unknownkey port +} + +testcase_globalSection() { + run_testcase "Display global config" 0 \ + "maxstartdelay=180 +globalflag" \ + --show-config '' + + run_testcase "Query a configuration key (global)" 0 \ + "180" \ + --show-config-value '' maxstartdelay + + run_testcase "Query a configuration flag (global)" 0 \ + "globalflag" \ + --show-config-value '' globalflag + + run_testcase "Query a missing configuration flag (global)" 1 \ + "" \ + --show-config-value '' nosuchflag +} + + +# Combine the cases above into a stack +testsuite() { + testcase_bogus_args + testcase_list_all_devices + testcase_show_all_configs + testcase_getValue + testcase_globalSection + # This one can take a while, put it last + testcase_upslist_debug +} + +# If no args... +for USE_SHELL in $SHELL_PROGS ; do + case "$USE_SHELL" in + busybox|busybox_sh) USE_SHELL="busybox sh" ;; + esac + testsuite +done +# End of loop over shells + +echo "Test suite for nut-driver-enumerator has completed with $FAIL_COUNT failed cases and $GOOD_COUNT good cases" >&2 + +[ "$FAIL_COUNT" = 0 ] || { echo "As a developer, you may want to export DEBUG=trace or export DEBUG=yes and re-run the test; also make sure you meant the nut-driver-enumerator.sh implementation as NDE='$NDE'" >&2 ; exit 1; } diff --git a/tests/nutclienttest.cpp b/tests/nutclienttest.cpp new file mode 100644 index 0000000..774e8c6 --- /dev/null +++ b/tests/nutclienttest.cpp @@ -0,0 +1,525 @@ +/* nutclienttest - CppUnit nutclient unit test + + Copyright (C) 2016 Emilien Kia + Copyright (C) 2020 - 2021 Jim Klimov + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "common.h" + +/* Current CPPUnit offends the honor of C++98 */ +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS || defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS) +#pragma GCC diagnostic push +# ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS +# pragma GCC diagnostic ignored "-Wglobal-constructors" +# endif +# ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS +# pragma GCC diagnostic ignored "-Wexit-time-destructors" +# endif +#endif + +#include + +namespace nut { + +class NutClientTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE( NutClientTest ); + CPPUNIT_TEST( test_strarr_alloc ); + CPPUNIT_TEST( test_stringset_to_strarr ); + CPPUNIT_TEST( test_stringvector_to_strarr ); + + CPPUNIT_TEST( test_copy_constructor_dev ); + CPPUNIT_TEST( test_copy_assignment_dev ); + + CPPUNIT_TEST( test_copy_constructor_cmd ); + CPPUNIT_TEST( test_copy_assignment_cmd ); + + CPPUNIT_TEST( test_copy_constructor_var ); + CPPUNIT_TEST( test_copy_assignment_var ); + + CPPUNIT_TEST( test_nutclientstub_dev ); + CPPUNIT_TEST_SUITE_END(); + +public: + void setUp() override; + void tearDown() override; + + void test_strarr_alloc(); + void test_stringset_to_strarr(); + void test_stringvector_to_strarr(); + + void test_copy_constructor_dev(); + void test_copy_assignment_dev(); + + void test_copy_constructor_cmd(); + void test_copy_assignment_cmd(); + + void test_copy_constructor_var(); + void test_copy_assignment_var(); + + void test_nutclientstub_dev(); +}; + +// Registers the fixture into the 'registry' +CPPUNIT_TEST_SUITE_REGISTRATION( NutClientTest ); + +} // namespace nut {} + +#ifndef _NUTCLIENTTEST_BUILD +# define _NUTCLIENTTEST_BUILD 1 +#endif + +#include "../clients/nutclient.h" +#include "../clients/nutclientmem.h" + +namespace nut { + +extern "C" { +strarr stringset_to_strarr(const std::set& strset); +strarr stringvector_to_strarr(const std::vector& strset); +} // extern "C" + +void NutClientTest::setUp() +{ +} + +void NutClientTest::tearDown() +{ +} + +void NutClientTest::test_strarr_alloc() +{ + bool noException = true; + + strarr arr = nullptr; + + try { + arr = strarr_alloc(5); + } + catch(nut::NutException& ex) + { + NUT_UNUSED_VARIABLE(ex); + noException = false; + } + CPPUNIT_ASSERT_MESSAGE( + "Failed strarr_alloc(...): throw exception", + noException); + + CPPUNIT_ASSERT_MESSAGE( + "Failed strarr_alloc(...): result is null", + arr != nullptr); + + strarr_free(arr); +} + +void NutClientTest::test_stringset_to_strarr() +{ + std::set strset; + strset.insert("test"); + strset.insert("hello"); + strset.insert("world"); + + strarr arr = stringset_to_strarr(strset); + CPPUNIT_ASSERT_MESSAGE( + "stringset_to_strarr(...) result is null", + arr != nullptr); + + std::set res; + + char** ptr = arr; + while(*ptr != nullptr) + { + res.insert(std::string(*ptr)); + ptr++; + } + + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "stringset_to_strarr(...) result has not 3 items", + static_cast(3), res.size()); + CPPUNIT_ASSERT_MESSAGE( + "stringset_to_strarr(...) result has not item \"test\"", + res.find("test") != res.end()); + CPPUNIT_ASSERT_MESSAGE( + "stringset_to_strarr(...) result has not item \"hello\"", + res.find("hello") != res.end()); + CPPUNIT_ASSERT_MESSAGE( + "stringset_to_strarr(...) result has not item \"world\"", + res.find("world") != res.end()); + + strarr_free(arr); +} + +void NutClientTest::test_stringvector_to_strarr() +{ + std::vector strset; + strset.push_back("test"); + strset.push_back("hello"); + strset.push_back("world"); + + strarr arr = stringvector_to_strarr(strset); + CPPUNIT_ASSERT_MESSAGE( + "stringvector_to_strarr(...) result is null", + arr != nullptr); + + char** ptr = arr; + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "stringvector_to_strarr(...) result has not item 0==\"test\"", + std::string("test"), std::string(*ptr)); + ++ptr; + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "stringvector_to_strarr(...) result has not item 1==\"hello\"", + std::string("hello"), std::string(*ptr)); + ++ptr; + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "stringvector_to_strarr(...) result has not item 2==\"world\"", + std::string("world"), std::string(*ptr)); + ++ptr; + + /* https://stackoverflow.com/a/12565009/4715872 + * Can not compare nullptr_t and another data type (char*) + * with CPPUNIT template assertEquals() + */ + CPPUNIT_ASSERT_MESSAGE( + "stringvector_to_strarr(...) result has not only 3 items", + nullptr == *ptr); + + strarr_free(arr); +} + +void NutClientTest::test_copy_constructor_dev() { + nut::TcpClient c; + nut::Device i(&c, "ups1"); + nut::Device j(i); + + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "Failed to assign value of Device variable j by initializing from i", + i, j); +} + +void NutClientTest::test_copy_assignment_dev() { + nut::TcpClient c; + nut::Device i(&c, "ups1"); + nut::Device j(nullptr, "ups2"); + + CPPUNIT_ASSERT_ASSERTION_FAIL_MESSAGE( + "Device variables i and j were initialized differently " + "but claim to be equal", + CPPUNIT_ASSERT_EQUAL(i, j) ); + + j = i; + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "Failed to assign value of Device Command j by equating to i", + i, j); +} + +void NutClientTest::test_copy_constructor_cmd() { + nut::TcpClient c; + nut::Device d(nullptr, "ups1"); + + nut::Command i(&d, "cmd1"); + nut::Command j(i); + + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "Failed to assign value of Command variable j by initializing from i", + i, j); +} + +void NutClientTest::test_copy_assignment_cmd() { + nut::TcpClient c; + nut::Device d(nullptr, "ups1"); + + nut::Command i(&d, "var1"); + nut::Command j(nullptr, "var2"); + + CPPUNIT_ASSERT_ASSERTION_FAIL_MESSAGE( + "Command variables i and j were initialized differently " + "but claim to be equal", + CPPUNIT_ASSERT_EQUAL(i, j) ); + + j = i; + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "Failed to assign value of Command variable j by equating to i", + i, j); +} + +void NutClientTest::test_copy_constructor_var() { + nut::TcpClient c; + nut::Device d(nullptr, "ups1"); + + nut::Variable i(&d, "var1"); + nut::Variable j(i); + + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "Failed to assign value of Variable variable j by initializing from i", + i, j); +} + +void NutClientTest::test_copy_assignment_var() { + nut::TcpClient c; + nut::Device d(nullptr, "ups1"); + + nut::Variable i(&d, "var1"); + nut::Variable j(nullptr, "var2"); + + CPPUNIT_ASSERT_ASSERTION_FAIL_MESSAGE( + "Variable variables i and j were initialized differently " + "but claim to be equal", + CPPUNIT_ASSERT_EQUAL(i, j) ); + + j = i; + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "Failed to assign value of Variable variable j by equating to i", + i, j); +} + +void NutClientTest::test_nutclientstub_dev() { + bool noException = true; + + nut::MemClientStub c; + nut::Device d(nullptr, "ups_1"); + try + { + // set mono value + c.setDeviceVariable("ups_1", "name_1", "value_1"); + // get mono value + ListValue values = c.getDeviceVariableValue("ups_1", "name_1"); + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: mono wrong values number", + values.size() == 1); + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: mono bad value", + values[0] == std::string("value_1")); + + // set multi value + ListValue values_multi = { "multi_1", "multi_2" }; + c.setDeviceVariable("ups_1", "name_multi_1", values_multi); + // get multi value + values = c.getDeviceVariableValue("ups_1", "name_multi_1"); + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: multi wrong values number", + values.size() == 2); + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: multi first bad value", + values[0] == std::string("multi_1")); + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: multi second bad value", + values[1] == std::string("multi_2")); + + // get object values + ListObject objects = c.getDeviceVariableValues("ups_1"); + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: objects wrong values number", + objects.size() == 2); + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: objects mono wrong values number", + objects["name_1"].size() == 1); + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: objects mono bad value", + objects["name_1"][0] == std::string("value_1")); + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: objects multi wrong values number", + objects["name_multi_1"].size() == 2); + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: objects mono bad value", + objects["name_multi_1"][0] == std::string("multi_1")); + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: objects mono bad value", + objects["name_multi_1"][1] == std::string("multi_2")); + + // get device values + std::set devices_name = { "ups_1" }; + ListDevice devices = c.getDevicesVariableValues(devices_name); + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: devices wrong values number", + devices.size() == 1); + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: devices mono wrong values number", + devices["ups_1"]["name_1"].size() == 1); + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: devices mono bad value", + devices["ups_1"]["name_1"][0] == std::string("value_1")); + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: devices multi wrong values number", + devices["ups_1"]["name_multi_1"].size() == 2); + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: devices mono bad value", + devices["ups_1"]["name_multi_1"][0] == std::string("multi_1")); + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: devices mono bad value", + devices["ups_1"]["name_multi_1"][1] == std::string("multi_2")); + } + catch(nut::NutException& ex) + { + NUT_UNUSED_VARIABLE(ex); + noException = false; + } + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: throw exception", + noException); + + // List of functions not implemented (should return exception) + noException = true; + try { + std::set cmd = c.getDeviceCommandNames("ups-1"); + CPPUNIT_ASSERT_MESSAGE( + "Variable not use", + cmd.size() == 0); + } + catch(nut::NutException& ex) + { + NUT_UNUSED_VARIABLE(ex); + noException = false; + } + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: throw no exception", + !noException); + + noException = true; + try { + std::string desc = c.getDeviceCommandDescription("ups-1", "cmd-1"); + CPPUNIT_ASSERT_MESSAGE( + "Variable not use", + desc.empty()); + } + catch(nut::NutException& ex) + { + NUT_UNUSED_VARIABLE(ex); + noException = false; + } + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: throw no exception", + !noException); + + noException = true; + try { + TrackingID id = c.executeDeviceCommand("ups-1", "cmd-1", "param-1"); + CPPUNIT_ASSERT_MESSAGE( + "Variable not use", + id.empty()); + } + catch(nut::NutException& ex) + { + NUT_UNUSED_VARIABLE(ex); + noException = false; + } + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: throw no exception", + !noException); + + noException = true; + try { + c.deviceLogin("ups-1"); + } + catch(nut::NutException& ex) + { + NUT_UNUSED_VARIABLE(ex); + noException = false; + } + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: throw no exception", + !noException); + + noException = true; + try { + c.deviceMaster("ups-1"); + } + catch(nut::NutException& ex) + { + NUT_UNUSED_VARIABLE(ex); + noException = false; + } + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: throw no exception", + !noException); + + noException = true; + try { + c.deviceForcedShutdown("ups-1"); + } + catch(nut::NutException& ex) + { + NUT_UNUSED_VARIABLE(ex); + noException = false; + } + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: throw no exception", + !noException); + + noException = true; + try { + c.deviceGetNumLogins("ups-1"); + } + catch(nut::NutException& ex) + { + NUT_UNUSED_VARIABLE(ex); + noException = false; + } + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: throw no exception", + !noException); + + noException = true; + try { + TrackingResult result = c.getTrackingResult("track-1"); + CPPUNIT_ASSERT_MESSAGE( + "Variable not use", + result == TrackingResult::SUCCESS); + } + catch(nut::NutException& ex) + { + NUT_UNUSED_VARIABLE(ex); + noException = false; + } + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: throw no exception", + !noException); + + noException = true; + try { + bool status = c.isFeatureEnabled(Feature("feature-1")); + CPPUNIT_ASSERT_MESSAGE( + "Variable not use", + !status); + } + catch(nut::NutException& ex) + { + NUT_UNUSED_VARIABLE(ex); + noException = false; + } + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: throw no exception", + !noException); + + noException = true; + try { + c.setFeature(Feature("feature-1"), true); + } + catch(nut::NutException& ex) + { + NUT_UNUSED_VARIABLE(ex); + noException = false; + } + CPPUNIT_ASSERT_MESSAGE( + "Failed stub tcp client: throw no exception", + !noException); +} + +} // namespace nut {} + +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS || defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS) +#pragma GCC diagnostic pop +#endif diff --git a/tests/nutlogtest.c b/tests/nutlogtest.c new file mode 100644 index 0000000..09342c7 --- /dev/null +++ b/tests/nutlogtest.c @@ -0,0 +1,65 @@ +/* nutlogtest - some trivial usage for upslog*() and upsdebug*() related + * routines to sanity-check their code (compiler does not warn, test runs + * do not crash). + * + * Copyright (C) + * 2020 Jim Klimov + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "common.h" + +int main(void) { + const char *s1 = "!NULL"; + const char *s2 = NULL; + +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_OVERFLOW) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wformat-overflow" +#endif + upsdebugx(0, "D: checking with libc handling of NULL: '%s' vs '%s'", s1, s2); + +/* This explicitly does not work with -Wformat, due to verbatim NULL without a var: + * nutlogtest.c:20:5: error: reading through null pointer (argument 4) [-Werror=format=] + * and also due to (void*) vs (char*) in naive case: + * upsdebugx(0, "D: '%s' vs '%s'", NUT_STRARG(NULL), NULL); + * but with casting the explicit NULL remains: + * upsdebugx(0, "D: '%s' vs '%s'", NUT_STRARG((char *)NULL), (char *)NULL); + */ + + upsdebugx(0, "D: checking with NUT_STRARG macro: '%s' vs '%s'", NUT_STRARG(s2), s2); + +#ifdef NUT_STRARG +#undef NUT_STRARG +#endif + +#define NUT_STRARG(x) (x?x:"") + +/* This explicitly does not work with -Wformat, due to a NULL in the '%s' + * format string expansion (e.g. due to NUT PR #675 conversion to macros): + * ../include/common.h:155:41: warning: '%s' directive argument is null [-Wformat-overflow=] + * <...snip...> + * nutlogtest.c:45:63: note: format string is defined here + * 45 | upsdebugx(0, "D: checking with NUT_STRARG macro: '%s' vs '%s'", NUT_STRARG(s2), s2); + * | ^~ + */ + upsdebugx(0, "D: checking that macro wrap trick works: '%s' vs '%s'", NUT_STRARG(s2), s2); + +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_OVERFLOW) +# pragma GCC diagnostic pop +#endif + + return 0; +} diff --git a/tools/Makefile.am b/tools/Makefile.am index 1ba2820..9095195 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,9 +1,3 @@ -# TODO: remove redundancies! - -# XXX this does not work with Automake!!! -# -# In fact the very concept is entirely antithetical to Automake. -# # SUBDIRS are explicitly a listing of all the directories that make # must recurse into BEFORE processing the current directory. # @@ -13,36 +7,69 @@ # # Anyway, for the time being, we force build in ./ before nut-scanner, # to have nutscan-{usb,snmp}.h built before going into the nut-scanner -# sub-directory +# sub-directory. For good measure we also call this from nut-scanner's +# make, to handle developer workflow (editing the *.c sources this uses). SUBDIRS = . nut-scanner -EXTRA_DIST = nut-usbinfo.pl nut-recorder.sh nut-ddl-dump.sh \ - gitlog2changelog.py nut-snmpinfo.py driver-list-format.sh +PYTHON = @PYTHON@ -all: nut-scanner-deps +EXTRA_DIST = nut-usbinfo.pl nut-recorder.sh nut-ddl-dump.sh nut-dumpdiff.sh \ + gitlog2changelog.py.in nut-snmpinfo.py.in driver-list-format.sh -# XXX these rules are all bogus! They cause un-named target files to -# always be rebuilt! None of that is ever the right way to use make, -# and especially not Automake. Explicit filenames and their exact -# dependencies need to be properly listed. -nut-scanner-deps: - @if python -c 1; then \ - echo "Regenerating the SNMP helper files."; \ - $(top_srcdir)/tools/nut-snmpinfo.py; \ +GENERATED_SNMP_FILES = nut-scanner/nutscan-snmp.h + +GENERATED_USB_FILES = nut-scanner/nutscan-usb.h + +# Hotplug output file +GENERATED_USB_OS_FILES = ../scripts/hotplug/libhid.usermap + +# udev output file +GENERATED_USB_OS_FILES += ../scripts/udev/nut-usbups.rules.in + +# BSD devd output file +GENERATED_USB_OS_FILES += ../scripts/devd/nut-usb.conf.in + +# UPower output file +GENERATED_USB_OS_FILES += ../scripts/upower/95-upower-hid.rules + +CLEANFILES = $(GENERATED_SNMP_FILES) $(GENERATED_USB_FILES) +# We do not clean away these files, some are even tracked in Git: +#CLEANFILES += $(GENERATED_USB_OS_FILES) + +all: nut-scanner-deps $(GENERATED_USB_OS_FILES) + +# This target is called from the making of nut-scanner to ensure its bits +nut-scanner-deps: $(GENERATED_SNMP_FILES) $(GENERATED_USB_FILES) + +# Aliases for particular files, if someone has a need: +nut-scanner-deps-snmpinfo: $(GENERATED_SNMP_FILES) +nut-scanner-deps-usb: $(GENERATED_USB_FILES) + +# The distributed nut-snmpinfo.py.in template is assumed to only differ from +# a generated nut-snmpinfo.py by the @PYTHON@ shebang. +$(GENERATED_SNMP_FILES): $(top_srcdir)/drivers/*-mib.c + @if [ -n "$(PYTHON)" ] && $(PYTHON) -c 1; then \ + echo "Regenerating the SNMP helper files in SRC dir with '$(PYTHON)'."; \ + TOP_SRCDIR="$(top_srcdir)" ; export TOP_SRCDIR; \ + TOP_BUILDDIR="$(top_builddir)" ; export TOP_BUILDDIR; \ + cd $(builddir) && $(PYTHON) $(top_srcdir)/tools/nut-snmpinfo.py.in; \ else \ echo "----------------------------------------------------------------------"; \ echo "Warning: Python is not available."; \ - echo "Skipping the SNMP helper files regeneration."; \ + echo "Skipping the SNMP helper files regeneration in SRC dir."; \ echo "----------------------------------------------------------------------"; \ fi +$(GENERATED_USB_FILES): $(top_srcdir)/drivers/*-hid.c $(top_srcdir)/drivers/*usb*.c $(top_srcdir)/drivers/nutdrv_qx.c @if perl -e 1; then \ - echo "Regenerating the USB helper files."; \ - $(top_srcdir)/tools/nut-usbinfo.pl; \ + echo "Regenerating the USB helper files in SRC dir."; \ + TOP_SRCDIR="$(top_srcdir)" ; export TOP_SRCDIR; \ + TOP_BUILDDIR="$(top_builddir)" ; export TOP_BUILDDIR; \ + cd $(builddir) && $(top_srcdir)/tools/nut-usbinfo.pl; \ else \ echo "----------------------------------------------------------------------"; \ echo "Warning: Perl is not available."; \ - echo "Skipping the USB helper files regeneration."; \ + echo "Skipping the USB helper files regeneration in SRC dir."; \ echo "----------------------------------------------------------------------"; \ fi @@ -50,27 +77,43 @@ nut-scanner-deps: # call the SNMP info script upon "make dist", and if Python is present # and call both for building nut-scanner # Also ensure that data/driver.list is well formatted +# NOTE: Beware that current working directory for the script should be builddir +# so it may write the files in "dist" case (read-only sources), but the script +# is called from the distdir where its copy is present. +# The distributed nut-snmpinfo.py.in template is assumed to only differ from +# a generated nut-snmpinfo.py by the @PYTHON@ shebang. dist-hook: - @if python -c 1; then \ - echo "Regenerating the SNMP helper files."; \ - $(distdir)/nut-snmpinfo.py; \ + @if [ -n "$(PYTHON)" ] && $(PYTHON) -c 1; then \ + echo "Regenerating the SNMP helper files in DIST dir with '$(PYTHON)'."; \ + TOP_SRCDIR="$(top_srcdir)" ; export TOP_SRCDIR; \ + TOP_BUILDDIR="$(top_builddir)" ; export TOP_BUILDDIR; \ + $(PYTHON) $(distdir)/nut-snmpinfo.py.in; \ else \ echo "----------------------------------------------------------------------"; \ echo "Warning: Python is not available."; \ - echo "Skipping the SNMP helper files regeneration."; \ + echo "Skipping the SNMP helper files regeneration in DIST dir."; \ echo "----------------------------------------------------------------------"; \ fi @if perl -e 1; then \ - echo "Regenerating the USB helper files."; \ + echo "Regenerating the USB helper files in DIST dir."; \ + TOP_SRCDIR="$(top_srcdir)" ; export TOP_SRCDIR; \ + TOP_BUILDDIR="$(top_builddir)" ; export TOP_BUILDDIR; \ $(distdir)/nut-usbinfo.pl; \ else \ echo "----------------------------------------------------------------------"; \ echo "Warning: Perl is not available."; \ - echo "Skipping the USB helper files regeneration."; \ + echo "Skipping the USB helper files regeneration in DIST dir."; \ echo "----------------------------------------------------------------------"; \ fi @$(distdir)/driver-list-format.sh; +MAINTAINERCLEANFILES = Makefile.in .dirstamp + +# Can be recreated by `make` or `configure`, +# impacted by choice of PYTHON version: +DISTCLEANFILES = gitlog2changelog.py +DISTCLEANFILES += nut-snmpinfo.py + .PHONY: nut-scanner-deps nut-scanner-snmp-deps nut-scanner-usb-deps diff --git a/tools/Makefile.in b/tools/Makefile.in index c492ea0..51acd39 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.16.3 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -13,10 +13,18 @@ # PARTICULAR PURPOSE. @SET_MAKE@ - -# TODO: remove redundancies! VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -81,18 +89,24 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = tools -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nut_arg_with.m4 \ $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ $(top_srcdir)/m4/nut_check_libavahi.m4 \ $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ $(top_srcdir)/m4/nut_check_libgd.m4 \ $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ $(top_srcdir)/m4/nut_check_libneon.m4 \ $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ $(top_srcdir)/m4/nut_check_libnss.m4 \ @@ -101,14 +115,20 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ $(top_srcdir)/m4/nut_check_libusb.m4 \ $(top_srcdir)/m4/nut_check_libwrap.m4 \ $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ $(top_srcdir)/m4/nut_type_socklen_t.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/config.h -CONFIG_CLEAN_FILES = +CONFIG_CLEAN_FILES = gitlog2changelog.py nut-snmpinfo.py CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) @@ -144,7 +164,7 @@ am__recursive_targets = \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - distdir + distdir distdir-am am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is @@ -165,6 +185,8 @@ am__define_uniq_tagged_files = \ ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) +am__DIST_COMMON = $(srcdir)/Makefile.in \ + $(srcdir)/gitlog2changelog.py.in $(srcdir)/nut-snmpinfo.py.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ @@ -198,6 +220,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -208,6 +231,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -221,6 +245,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -233,6 +258,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -250,6 +276,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -260,21 +288,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -294,6 +330,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -307,6 +346,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -324,6 +364,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -337,6 +378,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -362,12 +406,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -378,10 +424,6 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ udevdir = @udevdir@ -# XXX this does not work with Automake!!! -# -# In fact the very concept is entirely antithetical to Automake. -# # SUBDIRS are explicitly a listing of all the directories that make # must recurse into BEFORE processing the current directory. # @@ -391,11 +433,32 @@ udevdir = @udevdir@ # # Anyway, for the time being, we force build in ./ before nut-scanner, # to have nutscan-{usb,snmp}.h built before going into the nut-scanner -# sub-directory +# sub-directory. For good measure we also call this from nut-scanner's +# make, to handle developer workflow (editing the *.c sources this uses). SUBDIRS = . nut-scanner -EXTRA_DIST = nut-usbinfo.pl nut-recorder.sh nut-ddl-dump.sh \ - gitlog2changelog.py nut-snmpinfo.py driver-list-format.sh +EXTRA_DIST = nut-usbinfo.pl nut-recorder.sh nut-ddl-dump.sh nut-dumpdiff.sh \ + gitlog2changelog.py.in nut-snmpinfo.py.in driver-list-format.sh +GENERATED_SNMP_FILES = nut-scanner/nutscan-snmp.h +GENERATED_USB_FILES = nut-scanner/nutscan-usb.h + +# Hotplug output file + +# udev output file + +# BSD devd output file + +# UPower output file +GENERATED_USB_OS_FILES = ../scripts/hotplug/libhid.usermap \ + ../scripts/udev/nut-usbups.rules.in \ + ../scripts/devd/nut-usb.conf.in \ + ../scripts/upower/95-upower-hid.rules +CLEANFILES = $(GENERATED_SNMP_FILES) $(GENERATED_USB_FILES) +MAINTAINERCLEANFILES = Makefile.in .dirstamp + +# Can be recreated by `make` or `configure`, +# impacted by choice of PYTHON version: +DISTCLEANFILES = gitlog2changelog.py nut-snmpinfo.py all: all-recursive .SUFFIXES: @@ -411,14 +474,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tools/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu tools/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -429,6 +491,10 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): +gitlog2changelog.py: $(top_builddir)/config.status $(srcdir)/gitlog2changelog.py.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +nut-snmpinfo.py: $(top_builddir)/config.status $(srcdir)/nut-snmpinfo.py.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ mostlyclean-libtool: -rm -f *.lo @@ -535,7 +601,10 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -620,14 +689,17 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am @@ -710,31 +782,45 @@ uninstall-am: mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am +.PRECIOUS: Makefile -all: nut-scanner-deps +# We do not clean away these files, some are even tracked in Git: +#CLEANFILES += $(GENERATED_USB_OS_FILES) -# XXX these rules are all bogus! They cause un-named target files to -# always be rebuilt! None of that is ever the right way to use make, -# and especially not Automake. Explicit filenames and their exact -# dependencies need to be properly listed. -nut-scanner-deps: - @if python -c 1; then \ - echo "Regenerating the SNMP helper files."; \ - $(top_srcdir)/tools/nut-snmpinfo.py; \ +all: nut-scanner-deps $(GENERATED_USB_OS_FILES) + +# This target is called from the making of nut-scanner to ensure its bits +nut-scanner-deps: $(GENERATED_SNMP_FILES) $(GENERATED_USB_FILES) + +# Aliases for particular files, if someone has a need: +nut-scanner-deps-snmpinfo: $(GENERATED_SNMP_FILES) +nut-scanner-deps-usb: $(GENERATED_USB_FILES) + +# The distributed nut-snmpinfo.py.in template is assumed to only differ from +# a generated nut-snmpinfo.py by the @PYTHON@ shebang. +$(GENERATED_SNMP_FILES): $(top_srcdir)/drivers/*-mib.c + @if [ -n "$(PYTHON)" ] && $(PYTHON) -c 1; then \ + echo "Regenerating the SNMP helper files in SRC dir with '$(PYTHON)'."; \ + TOP_SRCDIR="$(top_srcdir)" ; export TOP_SRCDIR; \ + TOP_BUILDDIR="$(top_builddir)" ; export TOP_BUILDDIR; \ + cd $(builddir) && $(PYTHON) $(top_srcdir)/tools/nut-snmpinfo.py.in; \ else \ echo "----------------------------------------------------------------------"; \ echo "Warning: Python is not available."; \ - echo "Skipping the SNMP helper files regeneration."; \ + echo "Skipping the SNMP helper files regeneration in SRC dir."; \ echo "----------------------------------------------------------------------"; \ fi +$(GENERATED_USB_FILES): $(top_srcdir)/drivers/*-hid.c $(top_srcdir)/drivers/*usb*.c $(top_srcdir)/drivers/nutdrv_qx.c @if perl -e 1; then \ - echo "Regenerating the USB helper files."; \ - $(top_srcdir)/tools/nut-usbinfo.pl; \ + echo "Regenerating the USB helper files in SRC dir."; \ + TOP_SRCDIR="$(top_srcdir)" ; export TOP_SRCDIR; \ + TOP_BUILDDIR="$(top_builddir)" ; export TOP_BUILDDIR; \ + cd $(builddir) && $(top_srcdir)/tools/nut-usbinfo.pl; \ else \ echo "----------------------------------------------------------------------"; \ echo "Warning: Perl is not available."; \ - echo "Skipping the USB helper files regeneration."; \ + echo "Skipping the USB helper files regeneration in SRC dir."; \ echo "----------------------------------------------------------------------"; \ fi @@ -742,24 +828,33 @@ nut-scanner-deps: # call the SNMP info script upon "make dist", and if Python is present # and call both for building nut-scanner # Also ensure that data/driver.list is well formatted +# NOTE: Beware that current working directory for the script should be builddir +# so it may write the files in "dist" case (read-only sources), but the script +# is called from the distdir where its copy is present. +# The distributed nut-snmpinfo.py.in template is assumed to only differ from +# a generated nut-snmpinfo.py by the @PYTHON@ shebang. dist-hook: - @if python -c 1; then \ - echo "Regenerating the SNMP helper files."; \ - $(distdir)/nut-snmpinfo.py; \ + @if [ -n "$(PYTHON)" ] && $(PYTHON) -c 1; then \ + echo "Regenerating the SNMP helper files in DIST dir with '$(PYTHON)'."; \ + TOP_SRCDIR="$(top_srcdir)" ; export TOP_SRCDIR; \ + TOP_BUILDDIR="$(top_builddir)" ; export TOP_BUILDDIR; \ + $(PYTHON) $(distdir)/nut-snmpinfo.py.in; \ else \ echo "----------------------------------------------------------------------"; \ echo "Warning: Python is not available."; \ - echo "Skipping the SNMP helper files regeneration."; \ + echo "Skipping the SNMP helper files regeneration in DIST dir."; \ echo "----------------------------------------------------------------------"; \ fi @if perl -e 1; then \ - echo "Regenerating the USB helper files."; \ + echo "Regenerating the USB helper files in DIST dir."; \ + TOP_SRCDIR="$(top_srcdir)" ; export TOP_SRCDIR; \ + TOP_BUILDDIR="$(top_builddir)" ; export TOP_BUILDDIR; \ $(distdir)/nut-usbinfo.pl; \ else \ echo "----------------------------------------------------------------------"; \ echo "Warning: Perl is not available."; \ - echo "Skipping the USB helper files regeneration."; \ + echo "Skipping the USB helper files regeneration in DIST dir."; \ echo "----------------------------------------------------------------------"; \ fi diff --git a/tools/gitlog2changelog.py b/tools/gitlog2changelog.py.in similarity index 87% rename from tools/gitlog2changelog.py rename to tools/gitlog2changelog.py.in index d8c0891..5d882cb 100755 --- a/tools/gitlog2changelog.py +++ b/tools/gitlog2changelog.py.in @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!@PYTHON@ # Copyright 2008 Marcus D. Hanwell # Minor changes for NUT by Charles Lepple # Distributed under the terms of the GNU General Public License v2 or later @@ -44,17 +44,25 @@ for line in fin: files = "" continue # Match the author line and extract the part we want + # (Don't use startswith to allow Author override inside commit message.) elif 'Author:' in line: authorList = re.split(': ', line, 1) - author = authorList[1] - author = author[0:len(author)-1] - authorFound = True + try: + author = authorList[1] + author = author[0:len(author)-1] + authorFound = True + except: + print ("Could not parse authorList = '%s'" % (line)) + # Match the date line - elif 'Date:' in line: + elif line.startswith('Date:'): dateList = re.split(': ', line, 1) - date = dateList[1] - date = date[0:len(date)-1] - dateFound = True + try: + date = dateList[1] + date = date[0:len(date)-1] + dateFound = True + except: + print ("Could not parse dateList = '%s'" % (line)) # The Fossil-IDs are ignored: elif line.startswith(' Fossil-ID:') or line.startswith(' [[SVN:'): continue @@ -80,7 +88,7 @@ for line in fin: else: message = message + " " + line.strip() # If this line is hit all of the files have been stored for this commit - elif re.search('files? changed', line) >= 0: + elif re.search('files? changed', line): filesFound = True continue # Collect the files for this commit. FIXME: Still need to add +/- to files diff --git a/tools/nut-ddl-dump.sh b/tools/nut-ddl-dump.sh index dce1e8a..326a06d 100755 --- a/tools/nut-ddl-dump.sh +++ b/tools/nut-ddl-dump.sh @@ -22,22 +22,27 @@ else fi # Test communication with the device -testResult="`upsc ${DDL_DEVICE_NAME} 2> /dev/null`" +upscResult="`upsc ${DDL_DEVICE_NAME} 2> /dev/null`" if [ $? -gt 0 ]; then echo "Can't communicate with ${DDL_DEVICE_NAME}" exit fi +# Collect more information +dumpDate="`date -R`" +upsrwResult="`upsrw ${DDL_DEVICE_NAME} 2> /dev/null`" +upscmdResult="`upscmd -l ${DDL_DEVICE_NAME} 2> /dev/null`" + # Build the filename # ________. -# Process the Manufacturer name +# Process the Manufacturer name RAW_DDL_MFR="`upsc ${DDL_DEVICE_NAME} device.mfr 2>/dev/null`" if [ "${RAW_DDL_MFR}" = "EATON" ]; then RAW_DDL_MFR="Eaton" fi # Replace spaces with underscores DDL_MFR="`echo ${RAW_DDL_MFR} | sed s/\ /_/g`" -# Process the Model name +# Process the Model name # Replace spaces with underscores RAW_DDL_MODEL="`upsc ${DDL_DEVICE_NAME} device.model 2>/dev/null`" DDL_MODEL="`echo ${RAW_DDL_MODEL} | sed s/\ /_/g`" @@ -49,5 +54,12 @@ DDL_REPORT_NUMBER="01" DDL_FILENAME="${DDL_MFR}__${DDL_MODEL}__${DDL_DRIVER_NAME}__${DDL_NUT_VERSION}__${DDL_REPORT_NUMBER}.dev" # Dump device data into the file -echo "${testResult}" > ${DDL_FILENAME} +echo "# Device dump generated by $0 on $dumpDate" > ${DDL_FILENAME} +echo "# upsrw output:" >> ${DDL_FILENAME} +echo "${upsrwResult}" | sed -e 's/^/# /' >> ${DDL_FILENAME} +echo "# upscmd output:" >> ${DDL_FILENAME} +echo "${upscmdResult}" | sed -e 's/^/# /' >> ${DDL_FILENAME} +echo "" >> ${DDL_FILENAME} +echo "# upsc output:" >> ${DDL_FILENAME} +echo "${upscResult}" >> ${DDL_FILENAME} echo "${DDL_FILENAME} generated using ${DDL_DEVICE_NAME} " diff --git a/tools/nut-dumpdiff.sh b/tools/nut-dumpdiff.sh new file mode 100755 index 0000000..0dcb470 --- /dev/null +++ b/tools/nut-dumpdiff.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# This script is intended to simplify comparison of NUT data dumps, +# such as those collected by drivers with `-d 1` argument, or by +# the `upsc` client, ignoring irrelevant variations (e.g. numbers). +# +# TODO: Make more portable than bash and GNU toolkits +# +# Subject to same license as the NUT Project. +# +# Copyright (C) +# 2022 Jim Klimov +# + +if [ $# = 2 ] && [ -s "$1" ] && [ -s "$2" ]; then + echo "=== $0: comparing '$1' (-) vs '$2' (+)" >&2 +else + echo "=== $0: aborting: requires two filenames to compare as arguments" >&2 + exit 1 +fi + +# Pre-sort just in case: +DATA1="`sort -n < "$1"`" +DATA2="`sort -n < "$2"`" + +# Strip away same-context lines, +# and lines with measurements that are either decimal numbers +# or multi-digit numbers without a decimal point (assuming +# differences in shorter numbers or counters may be important) +diff -bu <(echo "$DATA1") <(echo "$DATA2") \ +| grep -E '^[+-][^+-]' \ +| grep -vE '^[^:]*(power|load|voltage|current|frequency|temperature|humidity): ([0-9][0-9]*|[0-9][0-9]*\.[0-9][0-9]*)$' + +# Note: up to user to post-filter, "^driver.version.*:" +# may be deemed irrelevant as well diff --git a/tools/nut-recorder.sh b/tools/nut-recorder.sh index e2785c0..2329c2d 100755 --- a/tools/nut-recorder.sh +++ b/tools/nut-recorder.sh @@ -71,7 +71,7 @@ do sleep $pollInterval # update the TIMER value - curTimer=`expr $curTimer + $pollInterval` + curTimer=`expr $curTimer + $pollInterval` # dump the current data testResult="`upsc $devName > ${TEMP_DIR}/curDump.tmp`" diff --git a/tools/nut-scanner/Makefile.am b/tools/nut-scanner/Makefile.am index 558cb23..667b40b 100644 --- a/tools/nut-scanner/Makefile.am +++ b/tools/nut-scanner/Makefile.am @@ -1,7 +1,47 @@ -BUILT_SOURCES = nutscan-usb.h nutscan-snmp.h +# Generally, list headers and/or sources which are re-generated +# for nut-scanner in the parent dir +NUT_SCANNER_DEPS_H = nutscan-usb.h nutscan-snmp.h +NUT_SCANNER_DEPS_C = -nutscan-usb.h nutscan-snmp.h: - cd ..; $(MAKE) $(AM_MAKEFLAGS) nut-scanner-deps +# General set of nut-scanner dependencies generated in the parent dir +NUT_SCANNER_DEPS = $(NUT_SCANNER_DEPS_H) $(NUT_SCANNER_DEPS_C) + +BUILT_SOURCES = $(NUT_SCANNER_DEPS) +CLEANFILES = $(BUILT_SOURCES) + +# Make sure we have the freshest files (no-op if built earlier and then +# no driver sources and other dependencies were edited by a developer) +$(NUT_SCANNER_DEPS): dummy + @cd .. && $(MAKE) $(AM_MAKEFLAGS) nut-scanner-deps + +# Make sure out-of-dir dependencies exist (especially when dev-building parts): +$(top_builddir)/common/libcommon.la: dummy + @cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F) + +# do not hard depend on '../include/nut_version.h', since it blocks +# 'dist', and is only required for actual build, in which case +# BUILT_SOURCES (in ../include) will ensure nut_version.h will +# be built before anything else +nut-scanner.c: $(top_builddir)/include/nut_version.h + +LINKED_SOURCE_FILES = + +# Separate the .deps of other dirs from this one +# NOTE: Not using "$<" due to a legacy Sun/illumos dmake bug with resolver +# of dynamic vars, see e.g. https://man.omnios.org/man1/make#BUGS +LINKED_SOURCE_FILES += serial.c +serial.c: $(top_srcdir)/drivers/serial.c + test -s "$@" || ln -s -f "$(top_srcdir)/drivers/serial.c" "$@" + +LINKED_SOURCE_FILES += bcmxcp_ser.c +bcmxcp_ser.c: $(top_srcdir)/drivers/bcmxcp_ser.c + test -s "$@" || ln -s -f "$(top_srcdir)/drivers/bcmxcp_ser.c" "$@" + +CLEANFILES += $(LINKED_SOURCE_FILES) +BUILT_SOURCES += $(LINKED_SOURCE_FILES) + +$(top_builddir)/include/nut_version.h: + @cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F) # Only build nut-scanner, and its library, if libltdl was found (required!) if WITH_LIBLTDL @@ -10,18 +50,39 @@ if WITH_LIBLTDL endif libnutscan_la_SOURCES = scan_nut.c scan_ipmi.c \ nutscan-device.c nutscan-ip.c nutscan-display.c \ - nutscan-init.c scan_usb.c scan_snmp.c scan_xml_http.c \ - scan_avahi.c scan_eaton_serial.c nutscan-serial.c \ - ../../drivers/serial.c \ - ../../drivers/bcmxcp_ser.c \ - ../../common/common.c -libnutscan_la_LIBADD = $(NETLIBS) $(LIBLTDL_LIBS) -libnutscan_la_LDFLAGS = $(SERLIBS) -version-info 1:0:0 -libnutscan_la_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include $(LIBLTDL_CFLAGS) -I$(top_srcdir)/drivers + nutscan-init.c scan_usb.c scan_snmp.c scan_xml_http.c \ + scan_avahi.c scan_eaton_serial.c nutscan-serial.c +nodist_libnutscan_la_SOURCES = $(LINKED_SOURCE_FILES) +libnutscan_la_LIBADD = $(NETLIBS) +if WITH_LIBLTDL +libnutscan_la_LIBADD += $(LIBLTDL_LIBS) +endif +libnutscan_la_LIBADD += $(top_builddir)/common/libcommonclient.la +# +# Below we set API versions of public libraries +# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html +# Note that changes here may have to be reflected in packaging (the shared +# object .so names would differ) +# +# libnutscan version information +libnutscan_la_LDFLAGS = $(SERLIBS) -version-info 2:0:0 + +# libnutscan exported symbols regex +# WARNING: Since the library includes parts of libcommon (as much as needed +# e.g. for logging or string manipulations), we export a few symbols from +# those too. This may cause issues for (third-party) code development that +# would use both libnutscan and libcommon or similar libs. Here we did have +# a problem with nut-scanner using two copies of common.c and conflicting +# copies of "nut_debug_level" making fun of our debug-logging attempts. +# One solution to tackle if needed for those cases would be to make some +# dynamic/shared libnutcommon (etc.) +libnutscan_la_LDFLAGS += -export-symbols-regex '^(nutscan_|nut_debug_level|s_upsdebugx|max_threads|curr_threads)' +libnutscan_la_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include \ + $(LIBLTDL_CFLAGS) -I$(top_srcdir)/drivers nut_scanner_SOURCES = nut-scanner.c nut_scanner_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include -nut_scanner_LDADD = libnutscan.la ../../common/libcommon.la +nut_scanner_LDADD = libnutscan.la if WITH_SSL libnutscan_la_CFLAGS += $(LIBSSL_CFLAGS) @@ -43,13 +104,21 @@ if WITH_IPMI libnutscan_la_CFLAGS += $(LIBIPMI_CFLAGS) endif -dist_noinst_HEADERS = nutscan-usb.h nutscan-snmp.h +# C is not a header, but there is no dist_noinst_SOURCES +dist_noinst_HEADERS = $(NUT_SCANNER_DEPS_H) $(NUT_SCANNER_DEPS_C) if WITH_DEV - include_HEADERS = nut-scan.h nutscan-device.h nutscan-ip.h nutscan-init.h + include_HEADERS = nut-scan.h nutscan-device.h nutscan-ip.h nutscan-init.h nutscan-serial.h else dist_noinst_HEADERS += nut-scan.h nutscan-device.h nutscan-ip.h nutscan-init.h nutscan-serial.h endif -CLEANFILES = nutscan-usb.h nutscan-snmp.h +dummy: +CLEANFILES += *-spellchecked +MAINTAINERCLEANFILES = Makefile.in .dirstamp + +# NOTE: Do not clean ".deps" in SUBDIRS of the main project, +# the root Makefile.am takes care of that! +#clean-local: +# rm -rf $(builddir)/.deps diff --git a/tools/nut-scanner/Makefile.in b/tools/nut-scanner/Makefile.in index 4de16e0..068ee30 100644 --- a/tools/nut-scanner/Makefile.in +++ b/tools/nut-scanner/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.16.3 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -17,7 +17,17 @@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -82,29 +92,34 @@ build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ @WITH_LIBLTDL_TRUE@bin_PROGRAMS = nut-scanner$(EXEEXT) -@WITH_SSL_TRUE@am__append_1 = $(LIBSSL_CFLAGS) -@WITH_SSL_TRUE@am__append_2 = $(LIBSSL_LIBS) -@WITH_USB_TRUE@am__append_3 = $(LIBUSB_CFLAGS) -@WITH_SNMP_TRUE@am__append_4 = $(LIBNETSNMP_CFLAGS) -@WITH_NEON_TRUE@am__append_5 = $(LIBNEON_CFLAGS) -@WITH_AVAHI_TRUE@am__append_6 = $(LIBAVAHI_CFLAGS) -@WITH_IPMI_TRUE@am__append_7 = $(LIBIPMI_CFLAGS) -@WITH_DEV_FALSE@am__append_8 = nut-scan.h nutscan-device.h nutscan-ip.h nutscan-init.h nutscan-serial.h +@WITH_LIBLTDL_TRUE@am__append_1 = $(LIBLTDL_LIBS) +@WITH_SSL_TRUE@am__append_2 = $(LIBSSL_CFLAGS) +@WITH_SSL_TRUE@am__append_3 = $(LIBSSL_LIBS) +@WITH_USB_TRUE@am__append_4 = $(LIBUSB_CFLAGS) +@WITH_SNMP_TRUE@am__append_5 = $(LIBNETSNMP_CFLAGS) +@WITH_NEON_TRUE@am__append_6 = $(LIBNEON_CFLAGS) +@WITH_AVAHI_TRUE@am__append_7 = $(LIBAVAHI_CFLAGS) +@WITH_IPMI_TRUE@am__append_8 = $(LIBIPMI_CFLAGS) +@WITH_DEV_FALSE@am__append_9 = nut-scan.h nutscan-device.h nutscan-ip.h nutscan-init.h nutscan-serial.h subdir = tools/nut-scanner -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(top_srcdir)/depcomp $(am__dist_noinst_HEADERS_DIST) \ - $(am__include_HEADERS_DIST) README ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \ + $(top_srcdir)/m4/ax_c_pragmas.m4 \ + $(top_srcdir)/m4/ax_check_compile_flag.m4 \ + $(top_srcdir)/m4/ax_compare_version.m4 \ + $(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/nut_arg_with.m4 \ $(top_srcdir)/m4/nut_check_asciidoc.m4 \ + $(top_srcdir)/m4/nut_check_cppcheck.m4 \ + $(top_srcdir)/m4/nut_check_headers_windows.m4 \ $(top_srcdir)/m4/nut_check_libavahi.m4 \ $(top_srcdir)/m4/nut_check_libfreeipmi.m4 \ $(top_srcdir)/m4/nut_check_libgd.m4 \ $(top_srcdir)/m4/nut_check_libltdl.m4 \ + $(top_srcdir)/m4/nut_check_libmodbus.m4 \ $(top_srcdir)/m4/nut_check_libneon.m4 \ $(top_srcdir)/m4/nut_check_libnetsnmp.m4 \ $(top_srcdir)/m4/nut_check_libnss.m4 \ @@ -113,15 +128,25 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \ $(top_srcdir)/m4/nut_check_libusb.m4 \ $(top_srcdir)/m4/nut_check_libwrap.m4 \ $(top_srcdir)/m4/nut_check_os.m4 \ + $(top_srcdir)/m4/nut_check_pkgconfig.m4 \ + $(top_srcdir)/m4/nut_check_python.m4 \ + $(top_srcdir)/m4/nut_compiler_family.m4 \ + $(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \ $(top_srcdir)/m4/nut_report_feature.m4 \ + $(top_srcdir)/m4/nut_stash_warnings.m4 \ $(top_srcdir)/m4/nut_type_socklen_t.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__dist_noinst_HEADERS_DIST) \ + $(am__include_HEADERS_DIST) $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" \ + "$(DESTDIR)$(includedir)" +PROGRAMS = $(bin_PROGRAMS) am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -149,25 +174,25 @@ am__uninstall_files_from_dir = { \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } -am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \ - "$(DESTDIR)$(includedir)" LTLIBRARIES = $(lib_LTLIBRARIES) am__DEPENDENCIES_1 = -@WITH_SSL_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) +@WITH_LIBLTDL_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) +@WITH_SSL_TRUE@am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1) libnutscan_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) -am__dirstamp = $(am__leading_dot)dirstamp + $(am__DEPENDENCIES_2) \ + $(top_builddir)/common/libcommonclient.la \ + $(am__DEPENDENCIES_3) am_libnutscan_la_OBJECTS = libnutscan_la-scan_nut.lo \ libnutscan_la-scan_ipmi.lo libnutscan_la-nutscan-device.lo \ libnutscan_la-nutscan-ip.lo libnutscan_la-nutscan-display.lo \ libnutscan_la-nutscan-init.lo libnutscan_la-scan_usb.lo \ libnutscan_la-scan_snmp.lo libnutscan_la-scan_xml_http.lo \ libnutscan_la-scan_avahi.lo libnutscan_la-scan_eaton_serial.lo \ - libnutscan_la-nutscan-serial.lo \ - ../../drivers/libnutscan_la-serial.lo \ - ../../drivers/libnutscan_la-bcmxcp_ser.lo \ - ../../common/libnutscan_la-common.lo -libnutscan_la_OBJECTS = $(am_libnutscan_la_OBJECTS) + libnutscan_la-nutscan-serial.lo +am__objects_1 = libnutscan_la-serial.lo libnutscan_la-bcmxcp_ser.lo +nodist_libnutscan_la_OBJECTS = $(am__objects_1) +libnutscan_la_OBJECTS = $(am_libnutscan_la_OBJECTS) \ + $(nodist_libnutscan_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent @@ -176,10 +201,9 @@ libnutscan_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libnutscan_la_CFLAGS) \ $(CFLAGS) $(libnutscan_la_LDFLAGS) $(LDFLAGS) -o $@ @WITH_LIBLTDL_TRUE@am_libnutscan_la_rpath = -rpath $(libdir) -PROGRAMS = $(bin_PROGRAMS) am_nut_scanner_OBJECTS = nut_scanner-nut-scanner.$(OBJEXT) nut_scanner_OBJECTS = $(am_nut_scanner_OBJECTS) -nut_scanner_DEPENDENCIES = libnutscan.la ../../common/libcommon.la +nut_scanner_DEPENDENCIES = libnutscan.la nut_scanner_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(nut_scanner_CFLAGS) \ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ @@ -197,7 +221,22 @@ am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/libnutscan_la-bcmxcp_ser.Plo \ + ./$(DEPDIR)/libnutscan_la-nutscan-device.Plo \ + ./$(DEPDIR)/libnutscan_la-nutscan-display.Plo \ + ./$(DEPDIR)/libnutscan_la-nutscan-init.Plo \ + ./$(DEPDIR)/libnutscan_la-nutscan-ip.Plo \ + ./$(DEPDIR)/libnutscan_la-nutscan-serial.Plo \ + ./$(DEPDIR)/libnutscan_la-scan_avahi.Plo \ + ./$(DEPDIR)/libnutscan_la-scan_eaton_serial.Plo \ + ./$(DEPDIR)/libnutscan_la-scan_ipmi.Plo \ + ./$(DEPDIR)/libnutscan_la-scan_nut.Plo \ + ./$(DEPDIR)/libnutscan_la-scan_snmp.Plo \ + ./$(DEPDIR)/libnutscan_la-scan_usb.Plo \ + ./$(DEPDIR)/libnutscan_la-scan_xml_http.Plo \ + ./$(DEPDIR)/libnutscan_la-serial.Plo \ + ./$(DEPDIR)/nut_scanner-nut-scanner.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -217,7 +256,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = -SOURCES = $(libnutscan_la_SOURCES) $(nut_scanner_SOURCES) +SOURCES = $(libnutscan_la_SOURCES) $(nodist_libnutscan_la_SOURCES) \ + $(nut_scanner_SOURCES) DIST_SOURCES = $(libnutscan_la_SOURCES) $(nut_scanner_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ @@ -227,7 +267,7 @@ am__can_run_installinfo = \ am__dist_noinst_HEADERS_DIST = nutscan-usb.h nutscan-snmp.h nut-scan.h \ nutscan-device.h nutscan-ip.h nutscan-init.h nutscan-serial.h am__include_HEADERS_DIST = nut-scan.h nutscan-device.h nutscan-ip.h \ - nutscan-init.h + nutscan-init.h nutscan-serial.h HEADERS = $(dist_noinst_HEADERS) $(include_HEADERS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, @@ -248,6 +288,7 @@ am__define_uniq_tagged_files = \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp README DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) A2X = @A2X@ ACLOCAL = @ACLOCAL@ @@ -256,6 +297,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ ASCIIDOC = @ASCIIDOC@ ASPELL = @ASPELL@ +AUGPARSE = @AUGPARSE@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -266,6 +308,7 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFPATH = @CONFPATH@ CPP = @CPP@ +CPPCHECK = @CPPCHECK@ CPPFLAGS = @CPPFLAGS@ CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@ CPPUNIT_LIBS = @CPPUNIT_LIBS@ @@ -279,6 +322,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOC_BUILD_LIST = @DOC_BUILD_LIST@ +DOC_CHECK_LIST = @DOC_CHECK_LIST@ DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@ DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@ DRIVER_MAN_LIST = @DRIVER_MAN_LIST@ @@ -291,6 +335,7 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +GDLIB_CONFIG = @GDLIB_CONFIG@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -308,6 +353,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@ LIBIPMI_LIBS = @LIBIPMI_LIBS@ LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@ LIBLTDL_LIBS = @LIBLTDL_LIBS@ +LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@ +LIBMODBUS_LIBS = @LIBMODBUS_LIBS@ LIBNEON_CFLAGS = @LIBNEON_CFLAGS@ LIBNEON_LIBS = @LIBNEON_LIBS@ LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@ @@ -318,21 +365,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@ LIBS = @LIBS@ LIBSSL_CFLAGS = @LIBSSL_CFLAGS@ LIBSSL_LIBS = @LIBSSL_LIBS@ +LIBSSL_REQUIRES = @LIBSSL_REQUIRES@ LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_CONFIG = @LIBUSB_CONFIG@ LIBUSB_LIBS = @LIBUSB_LIBS@ LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@ LIBWRAP_LIBS = @LIBWRAP_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ +LN_S_R = @LN_S_R@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NETLIBS = @NETLIBS@ +NET_SNMP_CONFIG = @NET_SNMP_CONFIG@ NM = @NM@ NMEDIT = @NMEDIT@ +NUT_DATADIR = @NUT_DATADIR@ +NUT_LIBEXECDIR = @NUT_LIBEXECDIR@ NUT_NETVERSION = @NUT_NETVERSION@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ @@ -352,6 +407,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PORT = @PORT@ +PYTHON = @PYTHON@ +PYTHON2 = @PYTHON2@ +PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RUN_AS_GROUP = @RUN_AS_GROUP@ RUN_AS_USER = @RUN_AS_USER@ @@ -365,6 +423,7 @@ STATEPATH = @STATEPATH@ STRIP = @STRIP@ SUN_LIBUSB = @SUN_LIBUSB@ TREE_VERSION = @TREE_VERSION@ +VALGRIND = @VALGRIND@ VERSION = @VERSION@ WORDS_BIGENDIAN = @WORDS_BIGENDIAN@ XMLLINT = @XMLLINT@ @@ -382,6 +441,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +auglensdir = @auglensdir@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -395,6 +455,9 @@ datarootdir = @datarootdir@ devddir = @devddir@ docdir = @docdir@ driverexecdir = @driverexecdir@ +dummy_PKG_CONFIG = @dummy_PKG_CONFIG@ +dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@ +dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ @@ -420,12 +483,14 @@ pkgconfigdir = @pkgconfigdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ -systemdsystemshutdowndir = @systemdsystemshutdowndir@ +systemdshutdowndir = @systemdshutdowndir@ systemdsystemunitdir = @systemdsystemunitdir@ +systemdtmpfilesdir = @systemdtmpfilesdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ @@ -435,28 +500,63 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ udevdir = @udevdir@ -BUILT_SOURCES = nutscan-usb.h nutscan-snmp.h + +# Generally, list headers and/or sources which are re-generated +# for nut-scanner in the parent dir +NUT_SCANNER_DEPS_H = nutscan-usb.h nutscan-snmp.h +NUT_SCANNER_DEPS_C = + +# General set of nut-scanner dependencies generated in the parent dir +NUT_SCANNER_DEPS = $(NUT_SCANNER_DEPS_H) $(NUT_SCANNER_DEPS_C) +BUILT_SOURCES = $(NUT_SCANNER_DEPS) $(LINKED_SOURCE_FILES) +CLEANFILES = $(BUILT_SOURCES) $(LINKED_SOURCE_FILES) *-spellchecked + +# Separate the .deps of other dirs from this one +# NOTE: Not using "$<" due to a legacy Sun/illumos dmake bug with resolver +# of dynamic vars, see e.g. https://man.omnios.org/man1/make#BUGS +LINKED_SOURCE_FILES = serial.c bcmxcp_ser.c @WITH_LIBLTDL_TRUE@lib_LTLIBRARIES = libnutscan.la libnutscan_la_SOURCES = scan_nut.c scan_ipmi.c \ nutscan-device.c nutscan-ip.c nutscan-display.c \ - nutscan-init.c scan_usb.c scan_snmp.c scan_xml_http.c \ - scan_avahi.c scan_eaton_serial.c nutscan-serial.c \ - ../../drivers/serial.c \ - ../../drivers/bcmxcp_ser.c \ - ../../common/common.c + nutscan-init.c scan_usb.c scan_snmp.c scan_xml_http.c \ + scan_avahi.c scan_eaton_serial.c nutscan-serial.c -libnutscan_la_LIBADD = $(NETLIBS) $(LIBLTDL_LIBS) $(am__append_2) -libnutscan_la_LDFLAGS = $(SERLIBS) -version-info 1:0:0 +nodist_libnutscan_la_SOURCES = $(LINKED_SOURCE_FILES) +libnutscan_la_LIBADD = $(NETLIBS) $(am__append_1) \ + $(top_builddir)/common/libcommonclient.la $(am__append_3) +# +# Below we set API versions of public libraries +# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html +# Note that changes here may have to be reflected in packaging (the shared +# object .so names would differ) +# +# libnutscan version information + +# libnutscan exported symbols regex +# WARNING: Since the library includes parts of libcommon (as much as needed +# e.g. for logging or string manipulations), we export a few symbols from +# those too. This may cause issues for (third-party) code development that +# would use both libnutscan and libcommon or similar libs. Here we did have +# a problem with nut-scanner using two copies of common.c and conflicting +# copies of "nut_debug_level" making fun of our debug-logging attempts. +# One solution to tackle if needed for those cases would be to make some +# dynamic/shared libnutcommon (etc.) +libnutscan_la_LDFLAGS = $(SERLIBS) -version-info 2:0:0 \ + -export-symbols-regex \ + '^(nutscan_|nut_debug_level|s_upsdebugx|max_threads|curr_threads)' libnutscan_la_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include \ - $(LIBLTDL_CFLAGS) -I$(top_srcdir)/drivers $(am__append_1) \ - $(am__append_3) $(am__append_4) $(am__append_5) \ - $(am__append_6) $(am__append_7) + $(LIBLTDL_CFLAGS) -I$(top_srcdir)/drivers $(am__append_2) \ + $(am__append_4) $(am__append_5) $(am__append_6) \ + $(am__append_7) $(am__append_8) nut_scanner_SOURCES = nut-scanner.c nut_scanner_CFLAGS = -I$(top_srcdir)/clients -I$(top_srcdir)/include -nut_scanner_LDADD = libnutscan.la ../../common/libcommon.la -dist_noinst_HEADERS = nutscan-usb.h nutscan-snmp.h $(am__append_8) -@WITH_DEV_TRUE@include_HEADERS = nut-scan.h nutscan-device.h nutscan-ip.h nutscan-init.h -CLEANFILES = nutscan-usb.h nutscan-snmp.h +nut_scanner_LDADD = libnutscan.la + +# C is not a header, but there is no dist_noinst_SOURCES +dist_noinst_HEADERS = $(NUT_SCANNER_DEPS_H) $(NUT_SCANNER_DEPS_C) \ + $(am__append_9) +@WITH_DEV_TRUE@include_HEADERS = nut-scan.h nutscan-device.h nutscan-ip.h nutscan-init.h nutscan-serial.h +MAINTAINERCLEANFILES = Makefile.in .dirstamp all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-am @@ -474,14 +574,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tools/nut-scanner/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu tools/nut-scanner/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -492,63 +591,6 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): - -install-libLTLIBRARIES: $(lib_LTLIBRARIES) - @$(NORMAL_INSTALL) - @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ - list2=; for p in $$list; do \ - if test -f $$p; then \ - list2="$$list2 $$p"; \ - else :; fi; \ - done; \ - test -z "$$list2" || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ - } - -uninstall-libLTLIBRARIES: - @$(NORMAL_UNINSTALL) - @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ - for p in $$list; do \ - $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ - done - -clean-libLTLIBRARIES: - -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) - @list='$(lib_LTLIBRARIES)'; \ - locs=`for p in $$list; do echo $$p; done | \ - sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ - sort -u`; \ - test -z "$$locs" || { \ - echo rm -f $${locs}; \ - rm -f $${locs}; \ - } -../../drivers/$(am__dirstamp): - @$(MKDIR_P) ../../drivers - @: > ../../drivers/$(am__dirstamp) -../../drivers/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) ../../drivers/$(DEPDIR) - @: > ../../drivers/$(DEPDIR)/$(am__dirstamp) -../../drivers/libnutscan_la-serial.lo: ../../drivers/$(am__dirstamp) \ - ../../drivers/$(DEPDIR)/$(am__dirstamp) -../../drivers/libnutscan_la-bcmxcp_ser.lo: \ - ../../drivers/$(am__dirstamp) \ - ../../drivers/$(DEPDIR)/$(am__dirstamp) -../../common/$(am__dirstamp): - @$(MKDIR_P) ../../common - @: > ../../common/$(am__dirstamp) -../../common/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) ../../common/$(DEPDIR) - @: > ../../common/$(DEPDIR)/$(am__dirstamp) -../../common/libnutscan_la-common.lo: ../../common/$(am__dirstamp) \ - ../../common/$(DEPDIR)/$(am__dirstamp) - -libnutscan.la: $(libnutscan_la_OBJECTS) $(libnutscan_la_DEPENDENCIES) $(EXTRA_libnutscan_la_DEPENDENCIES) - $(AM_V_CCLD)$(libnutscan_la_LINK) $(am_libnutscan_la_rpath) $(libnutscan_la_OBJECTS) $(libnutscan_la_LIBADD) $(LIBS) install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ @@ -599,36 +641,75 @@ clean-binPROGRAMS: echo " rm -f" $$list; \ rm -f $$list +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +libnutscan.la: $(libnutscan_la_OBJECTS) $(libnutscan_la_DEPENDENCIES) $(EXTRA_libnutscan_la_DEPENDENCIES) + $(AM_V_CCLD)$(libnutscan_la_LINK) $(am_libnutscan_la_rpath) $(libnutscan_la_OBJECTS) $(libnutscan_la_LIBADD) $(LIBS) + nut-scanner$(EXEEXT): $(nut_scanner_OBJECTS) $(nut_scanner_DEPENDENCIES) $(EXTRA_nut_scanner_DEPENDENCIES) @rm -f nut-scanner$(EXEEXT) $(AM_V_CCLD)$(nut_scanner_LINK) $(nut_scanner_OBJECTS) $(nut_scanner_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) - -rm -f ../../common/*.$(OBJEXT) - -rm -f ../../common/*.lo - -rm -f ../../drivers/*.$(OBJEXT) - -rm -f ../../drivers/*.lo distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@../../common/$(DEPDIR)/libnutscan_la-common.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@../../drivers/$(DEPDIR)/libnutscan_la-bcmxcp_ser.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@../../drivers/$(DEPDIR)/libnutscan_la-serial.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-nutscan-device.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-nutscan-display.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-nutscan-init.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-nutscan-ip.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-nutscan-serial.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-scan_avahi.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-scan_eaton_serial.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-scan_ipmi.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-scan_nut.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-scan_snmp.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-scan_usb.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-scan_xml_http.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nut_scanner-nut-scanner.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-bcmxcp_ser.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-nutscan-device.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-nutscan-display.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-nutscan-init.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-nutscan-ip.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-nutscan-serial.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-scan_avahi.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-scan_eaton_serial.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-scan_ipmi.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-scan_nut.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-scan_snmp.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-scan_usb.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-scan_xml_http.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libnutscan_la-serial.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nut_scanner-nut-scanner.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @@ -738,26 +819,19 @@ libnutscan_la-nutscan-serial.lo: nutscan-serial.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -c -o libnutscan_la-nutscan-serial.lo `test -f 'nutscan-serial.c' || echo '$(srcdir)/'`nutscan-serial.c -../../drivers/libnutscan_la-serial.lo: ../../drivers/serial.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -MT ../../drivers/libnutscan_la-serial.lo -MD -MP -MF ../../drivers/$(DEPDIR)/libnutscan_la-serial.Tpo -c -o ../../drivers/libnutscan_la-serial.lo `test -f '../../drivers/serial.c' || echo '$(srcdir)/'`../../drivers/serial.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ../../drivers/$(DEPDIR)/libnutscan_la-serial.Tpo ../../drivers/$(DEPDIR)/libnutscan_la-serial.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../../drivers/serial.c' object='../../drivers/libnutscan_la-serial.lo' libtool=yes @AMDEPBACKSLASH@ +libnutscan_la-serial.lo: serial.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -MT libnutscan_la-serial.lo -MD -MP -MF $(DEPDIR)/libnutscan_la-serial.Tpo -c -o libnutscan_la-serial.lo `test -f 'serial.c' || echo '$(srcdir)/'`serial.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnutscan_la-serial.Tpo $(DEPDIR)/libnutscan_la-serial.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='serial.c' object='libnutscan_la-serial.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -c -o ../../drivers/libnutscan_la-serial.lo `test -f '../../drivers/serial.c' || echo '$(srcdir)/'`../../drivers/serial.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -c -o libnutscan_la-serial.lo `test -f 'serial.c' || echo '$(srcdir)/'`serial.c -../../drivers/libnutscan_la-bcmxcp_ser.lo: ../../drivers/bcmxcp_ser.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -MT ../../drivers/libnutscan_la-bcmxcp_ser.lo -MD -MP -MF ../../drivers/$(DEPDIR)/libnutscan_la-bcmxcp_ser.Tpo -c -o ../../drivers/libnutscan_la-bcmxcp_ser.lo `test -f '../../drivers/bcmxcp_ser.c' || echo '$(srcdir)/'`../../drivers/bcmxcp_ser.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ../../drivers/$(DEPDIR)/libnutscan_la-bcmxcp_ser.Tpo ../../drivers/$(DEPDIR)/libnutscan_la-bcmxcp_ser.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../../drivers/bcmxcp_ser.c' object='../../drivers/libnutscan_la-bcmxcp_ser.lo' libtool=yes @AMDEPBACKSLASH@ +libnutscan_la-bcmxcp_ser.lo: bcmxcp_ser.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -MT libnutscan_la-bcmxcp_ser.lo -MD -MP -MF $(DEPDIR)/libnutscan_la-bcmxcp_ser.Tpo -c -o libnutscan_la-bcmxcp_ser.lo `test -f 'bcmxcp_ser.c' || echo '$(srcdir)/'`bcmxcp_ser.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libnutscan_la-bcmxcp_ser.Tpo $(DEPDIR)/libnutscan_la-bcmxcp_ser.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bcmxcp_ser.c' object='libnutscan_la-bcmxcp_ser.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -c -o ../../drivers/libnutscan_la-bcmxcp_ser.lo `test -f '../../drivers/bcmxcp_ser.c' || echo '$(srcdir)/'`../../drivers/bcmxcp_ser.c - -../../common/libnutscan_la-common.lo: ../../common/common.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -MT ../../common/libnutscan_la-common.lo -MD -MP -MF ../../common/$(DEPDIR)/libnutscan_la-common.Tpo -c -o ../../common/libnutscan_la-common.lo `test -f '../../common/common.c' || echo '$(srcdir)/'`../../common/common.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ../../common/$(DEPDIR)/libnutscan_la-common.Tpo ../../common/$(DEPDIR)/libnutscan_la-common.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../../common/common.c' object='../../common/libnutscan_la-common.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -c -o ../../common/libnutscan_la-common.lo `test -f '../../common/common.c' || echo '$(srcdir)/'`../../common/common.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libnutscan_la_CFLAGS) $(CFLAGS) -c -o libnutscan_la-bcmxcp_ser.lo `test -f 'bcmxcp_ser.c' || echo '$(srcdir)/'`bcmxcp_ser.c nut_scanner-nut-scanner.o: nut-scanner.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nut_scanner_CFLAGS) $(CFLAGS) -MT nut_scanner-nut-scanner.o -MD -MP -MF $(DEPDIR)/nut_scanner-nut-scanner.Tpo -c -o nut_scanner-nut-scanner.o `test -f 'nut-scanner.c' || echo '$(srcdir)/'`nut-scanner.c @@ -778,8 +852,6 @@ mostlyclean-libtool: clean-libtool: -rm -rf .libs _libs - -rm -rf ../../common/.libs ../../common/_libs - -rm -rf ../../drivers/.libs ../../drivers/_libs install-includeHEADERS: $(include_HEADERS) @$(NORMAL_INSTALL) @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ @@ -854,7 +926,10 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -distdir: $(DISTFILES) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -887,16 +962,17 @@ distdir: $(DISTFILES) check-am: all-am check: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-am -all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) +all-am: Makefile $(PROGRAMS) $(LTLIBRARIES) $(HEADERS) install-binPROGRAMS: install-libLTLIBRARIES installdirs: - for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(includedir)"; do \ + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) install-am -install-exec: install-exec-am +install-exec: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data: install-data-am uninstall: uninstall-am @@ -922,22 +998,33 @@ clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -rm -f ../../common/$(DEPDIR)/$(am__dirstamp) - -rm -f ../../common/$(am__dirstamp) - -rm -f ../../drivers/$(DEPDIR)/$(am__dirstamp) - -rm -f ../../drivers/$(am__dirstamp) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \ clean-libtool mostlyclean-am distclean: distclean-am - -rm -rf ../../common/$(DEPDIR) ../../drivers/$(DEPDIR) ./$(DEPDIR) + -rm -f ./$(DEPDIR)/libnutscan_la-bcmxcp_ser.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-nutscan-device.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-nutscan-display.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-nutscan-init.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-nutscan-ip.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-nutscan-serial.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-scan_avahi.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-scan_eaton_serial.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-scan_ipmi.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-scan_nut.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-scan_snmp.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-scan_usb.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-scan_xml_http.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-serial.Plo + -rm -f ./$(DEPDIR)/nut_scanner-nut-scanner.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -983,7 +1070,21 @@ install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am - -rm -rf ../../common/$(DEPDIR) ../../drivers/$(DEPDIR) ./$(DEPDIR) + -rm -f ./$(DEPDIR)/libnutscan_la-bcmxcp_ser.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-nutscan-device.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-nutscan-display.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-nutscan-init.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-nutscan-ip.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-nutscan-serial.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-scan_avahi.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-scan_eaton_serial.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-scan_ipmi.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-scan_nut.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-scan_snmp.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-scan_usb.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-scan_xml_http.Plo + -rm -f ./$(DEPDIR)/libnutscan_la-serial.Plo + -rm -f ./$(DEPDIR)/nut_scanner-nut-scanner.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -1003,9 +1104,9 @@ ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-includeHEADERS \ uninstall-libLTLIBRARIES -.MAKE: all check install install-am install-strip +.MAKE: all check install install-am install-exec install-strip -.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \ clean-libtool cscopelist-am ctags ctags-am distclean \ distclean-compile distclean-generic distclean-libtool \ @@ -1022,9 +1123,37 @@ uninstall-am: uninstall-binPROGRAMS uninstall-includeHEADERS \ tags tags-am uninstall uninstall-am uninstall-binPROGRAMS \ uninstall-includeHEADERS uninstall-libLTLIBRARIES +.PRECIOUS: Makefile -nutscan-usb.h nutscan-snmp.h: - cd ..; $(MAKE) $(AM_MAKEFLAGS) nut-scanner-deps + +# Make sure we have the freshest files (no-op if built earlier and then +# no driver sources and other dependencies were edited by a developer) +$(NUT_SCANNER_DEPS): dummy + @cd .. && $(MAKE) $(AM_MAKEFLAGS) nut-scanner-deps + +# Make sure out-of-dir dependencies exist (especially when dev-building parts): +$(top_builddir)/common/libcommon.la: dummy + @cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F) + +# do not hard depend on '../include/nut_version.h', since it blocks +# 'dist', and is only required for actual build, in which case +# BUILT_SOURCES (in ../include) will ensure nut_version.h will +# be built before anything else +nut-scanner.c: $(top_builddir)/include/nut_version.h +serial.c: $(top_srcdir)/drivers/serial.c + test -s "$@" || ln -s -f "$(top_srcdir)/drivers/serial.c" "$@" +bcmxcp_ser.c: $(top_srcdir)/drivers/bcmxcp_ser.c + test -s "$@" || ln -s -f "$(top_srcdir)/drivers/bcmxcp_ser.c" "$@" + +$(top_builddir)/include/nut_version.h: + @cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F) + +dummy: + +# NOTE: Do not clean ".deps" in SUBDIRS of the main project, +# the root Makefile.am takes care of that! +#clean-local: +# rm -rf $(builddir)/.deps # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/tools/nut-scanner/README b/tools/nut-scanner/README index c5a8077..1889237 100644 --- a/tools/nut-scanner/README +++ b/tools/nut-scanner/README @@ -38,6 +38,8 @@ iteration function to display results: nutscan_options_t * opt; nutscan_device_t *device; + nutscan-init(); + if ((device = nutscan_scan_usb()) == NULL) { printf("No device found\n"); exit(EXIT_FAILURE); diff --git a/tools/nut-scanner/nut-scan.h b/tools/nut-scanner/nut-scan.h index ce19726..dee6739 100644 --- a/tools/nut-scanner/nut-scan.h +++ b/tools/nut-scanner/nut-scan.h @@ -2,6 +2,8 @@ * Copyright (C) * 2011 - EATON * 2012 - Arnaud Quette + * 2016 - EATON - IP addressed XML scan + * 2016-2021 - EATON - Various threads-related improvements * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,19 +24,47 @@ \brief general header for nut-scanner \author Frederic Bohe \author Arnaud Quette + \author Michal Vyskocil + \author Jim Klimov */ #ifndef NUT_SCAN_H #define NUT_SCAN_H +#include "config.h" +#include +#include "nut_stdint.h" + #include #include #include +#include #ifdef WITH_IPMI #include #endif +#ifdef HAVE_PTHREAD +# include + +# ifdef HAVE_SEMAPHORE +# include +# endif + +# if (defined HAVE_PTHREAD_TRYJOIN) || (defined HAVE_SEMAPHORE) +extern size_t max_threads, curr_threads, max_threads_netxml, max_threads_oldnut, max_threads_netsnmp; +# endif + +# ifdef HAVE_PTHREAD_TRYJOIN +extern pthread_mutex_t threadcount_mutex; +# endif + +typedef struct nutscan_thread { + pthread_t thread; + int active; /* true if the thread was created, false if joined (to not join twice) */ +} nutscan_thread_t; +#endif /* HAVE_PTHREAD */ + #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { @@ -83,21 +113,39 @@ typedef struct nutscan_ipmi { #define IPMI_1_5 1 #define IPMI_2_0 0 +/* XML HTTP structure */ +typedef struct nutscan_xml { + uint16_t port_http; /* Port for xml http (tcp) */ + uint16_t port_udp; /* Port for xml udp */ + useconds_t usec_timeout; /* Wait this long for a response */ + char *peername; /* Hostname or NULL for broadcast mode */ +} nutscan_xml_t; + /* Scanning */ -nutscan_device_t * nutscan_scan_snmp(const char * start_ip, const char * stop_ip, long usec_timeout, nutscan_snmp_t * sec); +nutscan_device_t * nutscan_scan_snmp(const char * start_ip, const char * stop_ip, useconds_t usec_timeout, nutscan_snmp_t * sec); -nutscan_device_t * nutscan_scan_usb(); +nutscan_device_t * nutscan_scan_usb(void); -nutscan_device_t * nutscan_scan_xml_http(long usec_timeout); +/* If "ip" == NULL, do a broadcast scan */ +/* If sec->usec_timeout <= 0 then the common usec_timeout arg overrides it */ +nutscan_device_t * nutscan_scan_xml_http_range(const char *start_ip, const char *end_ip, useconds_t usec_timeout, nutscan_xml_t * sec); -nutscan_device_t * nutscan_scan_nut(const char * startIP, const char * stopIP, const char * port, long usec_timeout); +nutscan_device_t * nutscan_scan_nut(const char * startIP, const char * stopIP, const char * port, useconds_t usec_timeout); -nutscan_device_t * nutscan_scan_avahi(long usec_timeout); +nutscan_device_t * nutscan_scan_avahi(useconds_t usec_timeout); -nutscan_device_t * nutscan_scan_ipmi(const char * startIP, const char * stopIP, nutscan_ipmi_t * sec); +nutscan_device_t * nutscan_scan_ipmi(const char * startIP, const char * stopIP, nutscan_ipmi_t * sec); nutscan_device_t * nutscan_scan_eaton_serial(const char* ports_list); +#ifdef HAVE_PTHREAD +# ifdef HAVE_SEMAPHORE +/* Expose shared libnutscanner semaphore for overall thread count + * limited across different scanning methods (protocols/media): */ +sem_t * nutscan_semaphore(void); +# endif +#endif + /* Display functions */ void nutscan_display_ups_conf(nutscan_device_t * device); void nutscan_display_parsable(nutscan_device_t * device); diff --git a/tools/nut-scanner/nut-scanner.c b/tools/nut-scanner/nut-scanner.c index e0a6e33..30a7206 100644 --- a/tools/nut-scanner/nut-scanner.c +++ b/tools/nut-scanner/nut-scanner.c @@ -1,5 +1,7 @@ /* * Copyright (C) 2011 - 2012 Arnaud Quette + * Copyright (C) 2016 Michal Vyskocil + * Copyright (C) 2016 - 2021 Jim Klimov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,20 +19,41 @@ */ /*! \file nut-scanner.c - \brief a tool to detect NUT supported devices + \brief A tool to detect NUT supported devices \author Arnaud Quette + \author Michal Vyskocil + \author Jim Klimov */ +#include "common.h" /* Must be first include to pull "config.h" */ + #include #include #include -#include "common.h" #include "nut_version.h" #include #include + #ifdef HAVE_PTHREAD -#include -#endif +# include +# ifdef HAVE_SEMAPHORE +# include +# endif +# if (defined HAVE_PTHREAD_TRYJOIN) || (defined HAVE_SEMAPHORE) +# include "nut_stdint.h" +# ifdef HAVE_SYS_RESOURCE_H +# include /* for getrlimit() and struct rlimit */ +# include + +/* 3 is reserved for known overhead (for NetXML at least) + * following practical investigation summarized at + * https://github.com/networkupstools/nut/pull/1158 + * and probably means the usual stdin/stdout/stderr triplet + */ +# define RESERVE_FD_COUNT 3 +# endif /* HAVE_SYS_RESOURCE_H */ +# endif /* HAVE_PTHREAD_TRYJOIN || HAVE_SEMAPHORE */ +#endif /* HAVE_PTHREAD */ #include "nut-scan.h" @@ -38,120 +61,288 @@ #define ERR_BAD_OPTION (-1) -const char optstring[] = "?ht:s:e:E:c:l:u:W:X:w:x:p:b:B:d:D:CUSMOAm:NPqIVa"; +static const char optstring[] = "?ht:T:s:e:E:c:l:u:W:X:w:x:p:b:B:d:L:CUSMOAm:NPqIVaD"; #ifdef HAVE_GETOPT_LONG -const struct option longopts[] = - {{ "timeout",required_argument,NULL,'t' }, - { "start_ip",required_argument,NULL,'s' }, - { "end_ip",required_argument,NULL,'e' }, - { "eaton_serial",required_argument,NULL,'E' }, - { "mask_cidr",required_argument,NULL,'m' }, - { "community",required_argument,NULL,'c' }, - { "secLevel",required_argument,NULL,'l' }, - { "secName",required_argument,NULL,'u' }, - { "authPassword",required_argument,NULL,'W' }, - { "privPassword",required_argument,NULL,'X' }, - { "authProtocol",required_argument,NULL,'w' }, - { "privProtocol",required_argument,NULL,'x' }, - { "username",required_argument,NULL,'b' }, - { "password",required_argument,NULL,'B' }, - { "authType",required_argument,NULL,'d' }, - { "cipher_suite_id",required_argument,NULL,'D' }, - { "port",required_argument,NULL,'p' }, - { "complete_scan",no_argument,NULL,'C' }, - { "usb_scan",no_argument,NULL,'U' }, - { "snmp_scan",no_argument,NULL,'S' }, - { "xml_scan",no_argument,NULL,'M' }, - { "oldnut_scan",no_argument,NULL,'O' }, - { "avahi_scan",no_argument,NULL,'A' }, - { "ipmi_scan",no_argument,NULL,'I' }, - { "disp_nut_conf",no_argument,NULL,'N' }, - { "disp_parsable",no_argument,NULL,'P' }, - { "quiet",no_argument,NULL,'q' }, - { "help",no_argument,NULL,'h' }, - { "version",no_argument,NULL,'V' }, - { "available",no_argument,NULL,'a' }, - {NULL,0,NULL,0}}; +static const struct option longopts[] = { + { "timeout", required_argument, NULL, 't' }, + { "thread", required_argument, NULL, 'T' }, + { "start_ip", required_argument, NULL, 's' }, + { "end_ip", required_argument, NULL, 'e' }, + { "eaton_serial", required_argument, NULL, 'E' }, + { "mask_cidr", required_argument, NULL, 'm' }, + { "community", required_argument, NULL, 'c' }, + { "secLevel", required_argument, NULL, 'l' }, + { "secName", required_argument, NULL, 'u' }, + { "authPassword", required_argument, NULL, 'W' }, + { "privPassword", required_argument, NULL, 'X' }, + { "authProtocol", required_argument, NULL, 'w' }, + { "privProtocol", required_argument, NULL, 'x' }, + { "username", required_argument, NULL, 'b' }, + { "password", required_argument, NULL, 'B' }, + { "authType", required_argument, NULL, 'd' }, + { "cipher_suite_id", required_argument, NULL, 'L' }, + { "port", required_argument, NULL, 'p' }, + { "complete_scan", no_argument, NULL, 'C' }, + { "usb_scan", no_argument, NULL, 'U' }, + { "snmp_scan", no_argument, NULL, 'S' }, + { "xml_scan", no_argument, NULL, 'M' }, + { "oldnut_scan", no_argument, NULL, 'O' }, + { "avahi_scan", no_argument, NULL, 'A' }, + { "ipmi_scan", no_argument, NULL, 'I' }, + { "disp_nut_conf", no_argument, NULL, 'N' }, + { "disp_parsable", no_argument, NULL, 'P' }, + { "quiet", no_argument, NULL, 'q' }, + { "help", no_argument, NULL, 'h' }, + { "version", no_argument, NULL, 'V' }, + { "available", no_argument, NULL, 'a' }, + { "nut_debug_level", no_argument, NULL, 'D' }, + { NULL, 0, NULL, 0 } +}; #else -#define getopt_long(a,b,c,d,e) getopt(a,b,c) +#define getopt_long(a,b,c,d,e) getopt(a,b,c) #endif /* HAVE_GETOPT_LONG */ static nutscan_device_t *dev[TYPE_END]; -static long timeout = DEFAULT_TIMEOUT*1000*1000; /* in usec */ -static char * start_ip = NULL; -static char * end_ip = NULL; +static useconds_t timeout = DEFAULT_NETWORK_TIMEOUT * 1000 * 1000; /* in usec */ +static char * start_ip = NULL; +static char * end_ip = NULL; static char * port = NULL; static char * serial_ports = NULL; #ifdef HAVE_PTHREAD static pthread_t thread[TYPE_END]; -static void * run_usb(void * arg) +static void * run_usb(void *arg) { + NUT_UNUSED_VARIABLE(arg); + dev[TYPE_USB] = nutscan_scan_usb(); return NULL; } + static void * run_snmp(void * arg) { nutscan_snmp_t * sec = (nutscan_snmp_t *)arg; - dev[TYPE_SNMP] = nutscan_scan_snmp(start_ip,end_ip,timeout,sec); + dev[TYPE_SNMP] = nutscan_scan_snmp(start_ip, end_ip, timeout, sec); return NULL; } + static void * run_xml(void * arg) { - dev[TYPE_XML] = nutscan_scan_xml_http(timeout); + nutscan_xml_t * sec = (nutscan_xml_t *)arg; + + dev[TYPE_XML] = nutscan_scan_xml_http_range(start_ip, end_ip, timeout, sec); return NULL; } -static void * run_nut_old(void * arg) +static void * run_nut_old(void *arg) { - dev[TYPE_NUT] = nutscan_scan_nut(start_ip,end_ip,port,timeout); + NUT_UNUSED_VARIABLE(arg); + + dev[TYPE_NUT] = nutscan_scan_nut(start_ip, end_ip, port, timeout); return NULL; } -static void * run_avahi(void * arg) +static void * run_avahi(void *arg) { + NUT_UNUSED_VARIABLE(arg); + dev[TYPE_AVAHI] = nutscan_scan_avahi(timeout); return NULL; } + static void * run_ipmi(void * arg) { nutscan_ipmi_t * sec = (nutscan_ipmi_t *)arg; - dev[TYPE_IPMI] = nutscan_scan_ipmi(start_ip,end_ip,sec); + dev[TYPE_IPMI] = nutscan_scan_ipmi(start_ip, end_ip, sec); return NULL; } -static void * run_eaton_serial(void * arg) +static void * run_eaton_serial(void *arg) { - dev[TYPE_EATON_SERIAL] = nutscan_scan_eaton_serial (serial_ports); + NUT_UNUSED_VARIABLE(arg); + + dev[TYPE_EATON_SERIAL] = nutscan_scan_eaton_serial(serial_ports); return NULL; } #endif /* HAVE_PTHREAD */ -int printq(int quiet,const char *fmt, ...) -{ - va_list ap; - int ret; - if(quiet) { - return 0; +static void show_usage() +{ +/* NOTE: This code uses `nutscan_avail_*` global vars from nutscan-init.c */ + puts("nut-scanner : utility for detection of available power devices.\n"); + puts("OPTIONS:"); + printf(" -C, --complete_scan: Scan all available devices except serial ports (default).\n"); + if (nutscan_avail_usb) { + printf(" -U, --usb_scan: Scan USB devices.\n"); + } else { + printf("* Options for USB devices scan not enabled: library not detected.\n"); + } + if (nutscan_avail_snmp) { + printf(" -S, --snmp_scan: Scan SNMP devices using built-in mapping definitions.\n"); + } else { + printf("* Options for SNMP devices scan not enabled: library not detected.\n"); + } + if (nutscan_avail_xml_http) { + printf(" -M, --xml_scan: Scan XML/HTTP devices.\n"); + } else { + printf("* Options for XML/HTTP devices scan not enabled: library not detected.\n"); + } + printf(" -O, --oldnut_scan: Scan NUT devices (old method).\n"); + if (nutscan_avail_avahi) { + printf(" -A, --avahi_scan: Scan NUT devices (avahi method).\n"); + } else { + printf("* Options for NUT devices (avahi method) scan not enabled: library not detected.\n"); + } + if (nutscan_avail_ipmi) { + printf(" -I, --ipmi_scan: Scan IPMI devices.\n"); + } else { + printf("* Options for IPMI devices scan not enabled: library not detected.\n"); } - va_start(ap, fmt); - ret = vprintf(fmt, ap); - va_end(ap); + printf(" -E, --eaton_serial : Scan serial Eaton devices (XCP, SHUT and Q1).\n"); - return ret; +#if (defined HAVE_PTHREAD) && (defined HAVE_PTHREAD_TRYJOIN) + printf(" -T, --thread : Limit the amount of scanning threads running simultaneously (default: %zu).\n", max_threads); +#else + printf(" -T, --thread : Limit the amount of scanning threads running simultaneously (not implemented in this build: no pthread support)"); +#endif + + printf("\nNetwork specific options:\n"); + printf(" -t, --timeout : network operation timeout (default %d).\n", DEFAULT_NETWORK_TIMEOUT); + printf(" -s, --start_ip : First IP address to scan.\n"); + printf(" -e, --end_ip : Last IP address to scan.\n"); + printf(" -m, --mask_cidr : Give a range of IP using CIDR notation.\n"); + + if (nutscan_avail_snmp) { + printf("\nSNMP v1 specific options:\n"); + printf(" -c, --community : Set SNMP v1 community name (default = public)\n"); + + printf("\nSNMP v3 specific options:\n"); + printf(" -l, --secLevel : Set the securityLevel used for SNMPv3 messages (allowed values: noAuthNoPriv, authNoPriv, authPriv)\n"); + printf(" -u, --secName : Set the securityName used for authenticated SNMPv3 messages (mandatory if you set secLevel. No default)\n"); + + /* Construct help for AUTHPROTO */ + { int comma = 0; + NUT_UNUSED_VARIABLE(comma); /* potentially, if no protocols are available */ + printf(" -w, --authProtocol : Set the authentication protocol ("); +#if (defined WITH_SNMP) && (defined NUT_HAVE_LIBNETSNMP_usmHMACMD5AuthProtocol) +/* Note: NUT_HAVE_LIBNETSNMP_* macros are not AC_DEFINE'd when libsnmp was + * completely not detected at configure time, so "#if" is not a pedantically + * correct test (unknown macro may default to "0" but is not guaranteed to). + */ +# if NUT_HAVE_LIBNETSNMP_usmHMACMD5AuthProtocol + printf("%s%s", + (comma++ ? ", " : ""), + "MD5" + ); +# endif +# if NUT_HAVE_LIBNETSNMP_usmHMACSHA1AuthProtocol + printf("%s%s", + (comma++ ? ", " : ""), + "SHA" + ); +# endif +# if NUT_HAVE_LIBNETSNMP_usmHMAC192SHA256AuthProtocol + printf("%s%s", + (comma++ ? ", " : ""), + "SHA256" + ); +# endif +# if NUT_HAVE_LIBNETSNMP_usmHMAC256SHA384AuthProtocol + printf("%s%s", + (comma++ ? ", " : ""), + "SHA384" + ); +# endif +# if NUT_HAVE_LIBNETSNMP_usmHMAC384SHA512AuthProtocol + printf("%s%s", + (comma++ ? ", " : ""), + "SHA512" + ); +# endif + printf("%s%s", + (comma ? "" : "none supported"), + ") used for authenticated SNMPv3 messages (default=MD5 if available)\n" + ); + } /* Construct help for AUTHPROTO */ + + printf(" -W, --authPassword : Set the authentication pass phrase used for authenticated SNMPv3 messages (mandatory if you set secLevel to authNoPriv or authPriv)\n"); + + /* Construct help for PRIVPROTO */ + { int comma = 0; + NUT_UNUSED_VARIABLE(comma); /* potentially, if no protocols are available */ + printf(" -x, --privProtocol : Set the privacy protocol ("); +# if NUT_HAVE_LIBNETSNMP_usmDESPrivProtocol + printf("%s%s", + (comma++ ? ", " : ""), + "DES" + ); +# endif +# if NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol || NUT_HAVE_LIBNETSNMP_usmAES128PrivProtocol + printf("%s%s", + (comma++ ? ", " : ""), + "AES" + ); +# endif +# if NUT_HAVE_LIBNETSNMP_DRAFT_BLUMENTHAL_AES_04 +# if NUT_HAVE_LIBNETSNMP_usmAES192PrivProtocol + printf("%s%s", + (comma++ ? ", " : ""), + "AES192" + ); +# endif +# if NUT_HAVE_LIBNETSNMP_usmAES256PrivProtocol + printf("%s%s", + (comma++ ? ", " : ""), + "AES256" + ); +# endif +# endif /* NUT_HAVE_LIBNETSNMP_DRAFT_BLUMENTHAL_AES_04 */ +#endif /* built WITH_SNMP */ + printf("%s%s", + (comma ? "" : "none supported"), + ") used for encrypted SNMPv3 messages (default=DES if available)\n" + ); + } /* Construct help for PRIVPROTO */ + + printf(" -X, --privPassword : Set the privacy pass phrase used for encrypted SNMPv3 messages (mandatory if you set secLevel to authPriv)\n"); + } + + if (nutscan_avail_ipmi) { + printf("\nIPMI over LAN specific options:\n"); + printf(" -b, --username : Set the username used for authenticating IPMI over LAN connections (mandatory for IPMI over LAN. No default)\n"); + /* Specify the username to use when authenticating with the remote host. If not specified, a null (i.e. anonymous) username is assumed. The user must have + * at least ADMIN privileges in order for this tool to operate fully. */ + printf(" -B, --password : Specify the password to use when authenticationg with the remote host (mandatory for IPMI over LAN. No default)\n"); + /* Specify the password to use when authenticationg with the remote host. If not specified, a null password is assumed. Maximum password length is 16 for IPMI + * 1.5 and 20 for IPMI 2.0. */ + printf(" -d, --authType : Specify the IPMI 1.5 authentication type to use (NONE, STRAIGHT_PASSWORD_KEY, MD2, and MD5) with the remote host (default=MD5)\n"); + printf(" -L, --cipher_suite_id : Specify the IPMI 2.0 cipher suite ID to use, for authentication, integrity, and confidentiality (default=3)\n"); + } + + printf("\nNUT specific options:\n"); + printf(" -p, --port : Port number of remote NUT upsd\n"); + printf("\ndisplay specific options:\n"); + printf(" -N, --disp_nut_conf: Display result in the ups.conf format\n"); + printf(" -P, --disp_parsable: Display result in a parsable format\n"); + printf("\nMiscellaneous options:\n"); + printf(" -V, --version: Display NUT version\n"); + printf(" -a, --available: Display available bus that can be scanned\n"); + printf(" -q, --quiet: Display only scan result. No information on currently scanned bus is displayed.\n"); + printf(" -D, --nut_debug_level: Raise the debugging level. Use this multiple times to see more details.\n"); } int main(int argc, char *argv[]) { nutscan_snmp_t snmp_sec; nutscan_ipmi_t ipmi_sec; + nutscan_xml_t xml_sec; int opt_ret; char * cidr = NULL; int allow_all = 0; @@ -161,39 +352,97 @@ int main(int argc, char *argv[]) int allow_oldnut = 0; int allow_avahi = 0; int allow_ipmi = 0; - int allow_eaton_serial = 0; /* MUST be requested explicitely! */ - int quiet = 0; + int allow_eaton_serial = 0; /* MUST be requested explicitly! */ + int quiet = 0; /* The debugging level for certain upsdebugx() progress messages; 0 = print always, quiet==1 is to require at least one -D */ void (*display_func)(nutscan_device_t * device); int ret_code = EXIT_SUCCESS; +#if (defined HAVE_PTHREAD) && ( (defined HAVE_PTHREAD_TRYJOIN) || (defined HAVE_SEMAPHORE) ) && (defined HAVE_SYS_RESOURCE_H) + struct rlimit nofile_limit; + + /* Limit the max scanning thread count by the amount of allowed open + * file descriptors (which caller can change with `ulimit -n NUM`), + * following practical investigation summarized at + * https://github.com/networkupstools/nut/pull/1158 + * Resource-Limit code inspired by example from: + * https://stackoverflow.com/questions/4076848/how-to-do-the-equivalent-of-ulimit-n-400-from-within-c/4077000#4077000 + */ + + /* Get max number of files. */ + if (getrlimit(RLIMIT_NOFILE, &nofile_limit) != 0) { + /* Report error, keep hardcoded default */ + fprintf(stderr, "getrlimit() failed with errno=%d, keeping default job limits\n", errno); + nofile_limit.rlim_cur = 0; + nofile_limit.rlim_max = 0; + } else { + if (nofile_limit.rlim_cur > 0 + && nofile_limit.rlim_cur > RESERVE_FD_COUNT + && (uintmax_t)max_threads > (uintmax_t)(nofile_limit.rlim_cur - RESERVE_FD_COUNT) + && (uintmax_t)(nofile_limit.rlim_cur) < (uintmax_t)SIZE_MAX + ) { + max_threads = (size_t)nofile_limit.rlim_cur; + if (max_threads > (RESERVE_FD_COUNT + 1)) { + max_threads -= RESERVE_FD_COUNT; + } + } + } +#endif /* HAVE_PTHREAD && ( HAVE_PTHREAD_TRYJOIN || HAVE_SEMAPHORE ) && HAVE_SYS_RESOURCE_H */ memset(&snmp_sec, 0, sizeof(snmp_sec)); memset(&ipmi_sec, 0, sizeof(ipmi_sec)); + memset(&xml_sec, 0, sizeof(xml_sec)); + /* Set the default values for IPMI */ ipmi_sec.authentication_type = IPMI_AUTHENTICATION_TYPE_MD5; ipmi_sec.ipmi_version = IPMI_1_5; /* default to IPMI 1.5, if not otherwise specified */ ipmi_sec.cipher_suite_id = 3; /* default to HMAC-SHA1; HMAC-SHA1-96; AES-CBC-128 */ ipmi_sec.privilege_level = IPMI_PRIVILEGE_LEVEL_ADMIN; /* should be sufficient */ + /* Set the default values for XML HTTP (run_xml()) */ + xml_sec.port_http = 80; + xml_sec.port_udp = 4679; + xml_sec.usec_timeout = 0; /* Override with the "timeout" common setting later */ + xml_sec.peername = NULL; + + /* Parse command line options -- First loop: only get debug level */ + /* Suppress error messages, for now -- leave them to the second loop. */ + opterr = 0; + while ((opt_ret = getopt_long(argc, argv, optstring, longopts, NULL)) != -1) { + if (opt_ret == 'D') + nut_debug_level++; + } + nutscan_init(); display_func = nutscan_display_ups_conf; - while((opt_ret = getopt_long(argc, argv, optstring, longopts, NULL))!=-1) { + /* Parse command line options -- Second loop: everything else */ + /* Restore error messages... */ + opterr = 1; + /* ...and index of the item to be processed by getopt(). */ + optind = 1; + /* Note: the getopts print an error message about unknown arguments + * or arguments which need a second token and that is missing now */ + while ((opt_ret = getopt_long(argc, argv, optstring, longopts, NULL)) != -1) { switch(opt_ret) { case 't': - timeout = atol(optarg)*1000*1000; /*in usec*/ - if( timeout == 0 ) { - fprintf(stderr,"Illegal timeout value, using default %ds\n", DEFAULT_TIMEOUT); - timeout = DEFAULT_TIMEOUT*1000*1000; + timeout = (useconds_t)atol(optarg) * 1000 * 1000; /*in usec*/ + if (timeout <= 0) { + fprintf(stderr, + "Illegal timeout value, using default %ds\n", + DEFAULT_NETWORK_TIMEOUT); + timeout = DEFAULT_NETWORK_TIMEOUT * 1000 * 1000; } break; case 's': start_ip = strdup(optarg); - end_ip = start_ip; + if (end_ip == NULL) + end_ip = start_ip; break; case 'e': end_ip = strdup(optarg); + if (start_ip == NULL) + start_ip = end_ip; break; case 'E': serial_ports = strdup(optarg); @@ -201,69 +450,73 @@ int main(int argc, char *argv[]) break; case 'm': cidr = strdup(optarg); + upsdebugx(5, "Got CIDR net/mask: %s", cidr); + break; + case 'D': + /* nothing to do, here */ break; case 'c': - if(!nutscan_avail_snmp) { + if (!nutscan_avail_snmp) { goto display_help; } snmp_sec.community = strdup(optarg); break; case 'l': - if(!nutscan_avail_snmp) { + if (!nutscan_avail_snmp) { goto display_help; } snmp_sec.secLevel = strdup(optarg); break; case 'u': - if(!nutscan_avail_snmp) { + if (!nutscan_avail_snmp) { goto display_help; } snmp_sec.secName = strdup(optarg); break; case 'W': - if(!nutscan_avail_snmp) { + if (!nutscan_avail_snmp) { goto display_help; } snmp_sec.authPassword = strdup(optarg); break; case 'X': - if(!nutscan_avail_snmp) { + if (!nutscan_avail_snmp) { goto display_help; } snmp_sec.privPassword = strdup(optarg); break; case 'w': - if(!nutscan_avail_snmp) { + if (!nutscan_avail_snmp) { goto display_help; } snmp_sec.authProtocol = strdup(optarg); break; case 'x': - if(!nutscan_avail_snmp) { + if (!nutscan_avail_snmp) { goto display_help; } snmp_sec.privProtocol = strdup(optarg); break; case 'S': - if(!nutscan_avail_snmp) { + if (!nutscan_avail_snmp) { goto display_help; } allow_snmp = 1; break; case 'b': - if(!nutscan_avail_ipmi) { + if (!nutscan_avail_ipmi) { goto display_help; } ipmi_sec.username = strdup(optarg); break; case 'B': - if(!nutscan_avail_ipmi) { + if (!nutscan_avail_ipmi) { goto display_help; } ipmi_sec.password = strdup(optarg); break; case 'd': - if(!nutscan_avail_ipmi) { + if (!nutscan_avail_ipmi) { goto display_help; } if (!strcmp(optarg, "NONE")) { @@ -279,11 +532,13 @@ int main(int argc, char *argv[]) ipmi_sec.authentication_type = IPMI_AUTHENTICATION_TYPE_MD5; } else { - fprintf(stderr,"Unknown authentication type (%s). Defaulting to MD5\n", optarg); + fprintf(stderr, + "Unknown authentication type (%s). Defaulting to MD5\n", + optarg); } break; - case 'D': - if(!nutscan_avail_ipmi) { + case 'L': + if (!nutscan_avail_ipmi) { goto display_help; } ipmi_sec.cipher_suite_id = atoi(optarg); @@ -293,17 +548,70 @@ int main(int argc, char *argv[]) case 'p': port = strdup(optarg); break; + case 'T': { +#if (defined HAVE_PTHREAD) && ( (defined HAVE_PTHREAD_TRYJOIN) || (defined HAVE_SEMAPHORE) ) + char* endptr; + long val = strtol(optarg, &endptr, 10); + /* With endptr we check that no chars were left in optarg + * (that is, pointed-to char -- if reported -- is '\0') + */ + if ((!endptr || !*endptr) + && val > 0 + && (uintmax_t)val < (uintmax_t)SIZE_MAX + ) { +# ifdef HAVE_SYS_RESOURCE_H + if (nofile_limit.rlim_cur > 0 + && nofile_limit.rlim_cur > RESERVE_FD_COUNT + && (uintmax_t)nofile_limit.rlim_cur < (uintmax_t)SIZE_MAX + && (uintmax_t)val > (uintmax_t)(nofile_limit.rlim_cur - RESERVE_FD_COUNT) + ) { + upsdebugx(1, "Detected soft limit for " + "file descriptor count is %ju", + (uintmax_t)nofile_limit.rlim_cur); + upsdebugx(1, "Detected hard limit for " + "file descriptor count is %ju", + (uintmax_t)nofile_limit.rlim_max); + + max_threads = (size_t)nofile_limit.rlim_cur; + if (max_threads > (RESERVE_FD_COUNT + 1)) { + max_threads -= RESERVE_FD_COUNT; + } + + fprintf(stderr, + "WARNING: Requested max scanning " + "thread count %s (%ld) exceeds the " + "current file descriptor count limit " + "(minus reservation), constraining " + "to %zu\n", + optarg, val, max_threads); + } else +# endif /* HAVE_SYS_RESOURCE_H */ + max_threads = (size_t)val; + } else { + fprintf(stderr, + "WARNING: Requested max scanning " + "thread count %s (%ld) is out of range, " + "using default %zu\n", + optarg, val, max_threads); + } +#else + fprintf(stderr, + "WARNING: Max scanning thread count option " + "is not supported in this build, ignored\n"); +#endif /* HAVE_PTHREAD && ways to limit the thread count */ + } + break; case 'C': allow_all = 1; break; case 'U': - if(!nutscan_avail_usb) { + if (!nutscan_avail_usb) { goto display_help; } allow_usb = 1; break; case 'M': - if(!nutscan_avail_xml_http) { + if (!nutscan_avail_xml_http) { goto display_help; } allow_xml = 1; @@ -312,13 +620,13 @@ int main(int argc, char *argv[]) allow_oldnut = 1; break; case 'A': - if(!nutscan_avail_avahi) { + if (!nutscan_avail_avahi) { goto display_help; } allow_avahi = 1; break; case 'I': - if(!nutscan_avail_ipmi) { + if (!nutscan_avail_ipmi) { goto display_help; } allow_ipmi = 1; @@ -337,105 +645,85 @@ int main(int argc, char *argv[]) exit(EXIT_SUCCESS); case 'a': printf("OLDNUT\n"); - if(nutscan_avail_usb) { + if (nutscan_avail_usb) { printf("USB\n"); } - if(nutscan_avail_snmp) { + if (nutscan_avail_snmp) { printf("SNMP\n"); } - if(nutscan_avail_xml_http) { + if (nutscan_avail_xml_http) { printf("XML\n"); } - if(nutscan_avail_avahi) { + if (nutscan_avail_avahi) { printf("AVAHI\n"); } - if(nutscan_avail_ipmi) { + if (nutscan_avail_ipmi) { printf("IPMI\n"); } printf("EATON_SERIAL\n"); exit(EXIT_SUCCESS); case '?': ret_code = ERR_BAD_OPTION; + goto display_help; + /* Fall through to usage and error exit */ case 'h': default: display_help: - puts("nut-scanner : detecting available power devices.\n"); - puts("OPTIONS:"); - printf(" -C, --complete_scan: Scan all available devices (default).\n"); - if( nutscan_avail_usb ) { - printf(" -U, --usb_scan: Scan USB devices.\n"); - } - if( nutscan_avail_snmp ) { - printf(" -S, --snmp_scan: Scan SNMP devices.\n"); - } - if( nutscan_avail_xml_http ) { - printf(" -M, --xml_scan: Scan XML/HTTP devices.\n"); - } - printf(" -O, --oldnut_scan: Scan NUT devices (old method).\n"); - if( nutscan_avail_avahi ) { - printf(" -A, --avahi_scan: Scan NUT devices (avahi method).\n"); - } - if( nutscan_avail_ipmi ) { - printf(" -I, --ipmi_scan: Scan IPMI devices.\n"); - } - - printf(" -E, --eaton_serial : Scan serial Eaton devices (XCP, SHUT and Q1).\n"); - - printf("\nNetwork specific options:\n"); - printf(" -t, --timeout : network operation timeout (default %d).\n",DEFAULT_TIMEOUT); - printf(" -s, --start_ip : First IP address to scan.\n"); - printf(" -e, --end_ip : Last IP address to scan.\n"); - printf(" -m, --mask_cidr : Give a range of IP using CIDR notation.\n"); - - if( nutscan_avail_snmp ) { - printf("\nSNMP v1 specific options:\n"); - printf(" -c, --community : Set SNMP v1 community name (default = public)\n"); - - printf("\nSNMP v3 specific options:\n"); - printf(" -l, --secLevel : Set the securityLevel used for SNMPv3 messages (allowed values: noAuthNoPriv,authNoPriv,authPriv)\n"); - printf(" -u, --secName : Set the securityName used for authenticated SNMPv3 messages (mandatory if you set secLevel. No default)\n"); - printf(" -w, --authProtocol : Set the authentication protocol (MD5 or SHA) used for authenticated SNMPv3 messages (default=MD5)\n"); - printf(" -W, --authPassword : Set the authentication pass phrase used for authenticated SNMPv3 messages (mandatory if you set secLevel to authNoPriv or authPriv)\n"); - printf(" -x, --privProtocol : Set the privacy protocol (DES or AES) used for encrypted SNMPv3 messages (default=DES)\n"); - printf(" -X, --privPassword : Set the privacy pass phrase used for encrypted SNMPv3 messages (mandatory if you set secLevel to authPriv)\n"); - } - - if( nutscan_avail_ipmi ) { - printf("\nIPMI over LAN specific options:\n"); - printf(" -b, --username : Set the username used for authenticating IPMI over LAN connections (mandatory for IPMI over LAN. No default)\n"); - /* Specify the username to use when authenticating with the remote host. If not specified, a null (i.e. anonymous) username is assumed. The user must have - * at least ADMIN privileges in order for this tool to operate fully. */ - printf(" -B, --password : Specify the password to use when authenticationg with the remote host (mandatory for IPMI over LAN. No default)\n"); - /* Specify the password to use when authenticationg with the remote host. If not specified, a null password is assumed. Maximum password length is 16 for IPMI - * 1.5 and 20 for IPMI 2.0. */ - printf(" -d, --authType : Specify the IPMI 1.5 authentication type to use (NONE, STRAIGHT_PASSWORD_KEY, MD2, and MD5) with the remote host (default=MD5)\n"); - printf(" -D, --cipher_suite_id : Specify the IPMI 2.0 cipher suite ID to use, for authentication, integrity, and confidentiality (default=3)\n"); - } - - printf("\nNUT specific options:\n"); - printf(" -p, --port : Port number of remote NUT upsd\n"); - printf("\ndisplay specific options:\n"); - printf(" -N, --disp_nut_conf: Display result in the ups.conf format\n"); - printf(" -P, --disp_parsable: Display result in a parsable format\n"); - printf("\nMiscellaneous options:\n"); - printf(" -V, --version: Display NUT version\n"); - printf(" -a, --available: Display available bus that can be scanned\n"); - printf(" -q, --quiet: Display only scan result. No information on currently scanned bus is displayed.\n"); + show_usage(); + if ((opt_ret != 'h') || (ret_code != EXIT_SUCCESS)) + fprintf(stderr, "\n\n" + "WARNING: Some error has occurred while processing 'nut-scanner' command-line\n" + "arguments, see more details above the usage help text.\n\n"); return ret_code; } - } - if( cidr ) { +#ifdef HAVE_PTHREAD +# ifdef HAVE_SEMAPHORE + /* FIXME: Currently sem_init already done on nutscan-init for lib need. + We need to destroy it before re-init. We currently can't change "sem value" + on lib (need to be thread safe). */ + sem_t *current_sem = nutscan_semaphore(); + sem_destroy(current_sem); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic ignored "-Wunreachable-code" +#endif +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" +#endif + /* Different platforms, different sizes, none fits all... */ + if (SIZE_MAX > UINT_MAX && max_threads > UINT_MAX) { +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic pop +#endif + fprintf(stderr, "\n\n" + "WARNING: Limiting max_threads to range acceptable for sem_init()\n\n"); + max_threads = UINT_MAX - 1; + } + sem_init(current_sem, 0, (unsigned int)max_threads); +# endif +#endif /* HAVE_PTHREAD */ + + if (cidr) { + upsdebugx(1, "Processing CIDR net/mask: %s", cidr); nutscan_cidr_to_ip(cidr, &start_ip, &end_ip); + upsdebugx(1, "Extracted IP address range from CIDR net/mask: %s => %s", start_ip, end_ip); } - if( !allow_usb && !allow_snmp && !allow_xml && !allow_oldnut && - !allow_avahi && !allow_ipmi && !allow_eaton_serial) { + if (!allow_usb && !allow_snmp && !allow_xml && !allow_oldnut && + !allow_avahi && !allow_ipmi && !allow_eaton_serial + ) { allow_all = 1; } - if( allow_all ) { + if (allow_all) { allow_usb = 1; allow_snmp = 1; allow_xml = 1; @@ -445,141 +733,211 @@ display_help: /* BEWARE: allow_all does not include allow_eaton_serial! */ } - if( allow_usb && nutscan_avail_usb ) { - printq(quiet,"Scanning USB bus.\n"); +/* TODO/discuss : Should the #else...#endif code below for lack of pthreads + * during build also serve as a fallback for pthread failure at runtime? + */ + if (allow_usb && nutscan_avail_usb) { + upsdebugx(quiet, "Scanning USB bus."); #ifdef HAVE_PTHREAD - if(pthread_create(&thread[TYPE_USB],NULL,run_usb,NULL)) { + if (pthread_create(&thread[TYPE_USB], NULL, run_usb, NULL)) { + upsdebugx(1, "pthread_create returned an error; disabling this scan mode"); nutscan_avail_usb = 0; } #else + upsdebugx(1, "USB SCAN: no pthread support, starting nutscan_scan_usb..."); dev[TYPE_USB] = nutscan_scan_usb(); #endif /* HAVE_PTHREAD */ + } else { + upsdebugx(1, "USB SCAN: not requested, SKIPPED"); } - if( allow_snmp && nutscan_avail_snmp ) { - if( start_ip == NULL ) { - printq(quiet,"No start IP, skipping SNMP\n"); + if (allow_snmp && nutscan_avail_snmp) { + if (start_ip == NULL) { + upsdebugx(quiet, "No start IP, skipping SNMP"); nutscan_avail_snmp = 0; } else { - printq(quiet,"Scanning SNMP bus.\n"); + upsdebugx(quiet, "Scanning SNMP bus."); #ifdef HAVE_PTHREAD - if( pthread_create(&thread[TYPE_SNMP],NULL,run_snmp,&snmp_sec)) { + upsdebugx(1, "SNMP SCAN: starting pthread_create with run_snmp..."); + if (pthread_create(&thread[TYPE_SNMP], NULL, run_snmp, &snmp_sec)) { + upsdebugx(1, "pthread_create returned an error; disabling this scan mode"); nutscan_avail_snmp = 0; } #else - dev[TYPE_SNMP] = nutscan_scan_snmp(start_ip,end_ip,timeout,&snmp_sec); + upsdebugx(1, "SNMP SCAN: no pthread support, starting nutscan_scan_snmp..."); + dev[TYPE_SNMP] = nutscan_scan_snmp(start_ip, end_ip, timeout, &snmp_sec); #endif /* HAVE_PTHREAD */ } + } else { + upsdebugx(1, "SNMP SCAN: not requested, SKIPPED"); } - if( allow_xml && nutscan_avail_xml_http) { - printq(quiet,"Scanning XML/HTTP bus.\n"); + if (allow_xml && nutscan_avail_xml_http) { + upsdebugx(quiet, "Scanning XML/HTTP bus."); + xml_sec.usec_timeout = timeout; #ifdef HAVE_PTHREAD - if(pthread_create(&thread[TYPE_XML],NULL,run_xml,NULL)) { + upsdebugx(1, "XML/HTTP SCAN: starting pthread_create with run_xml..."); + if (pthread_create(&thread[TYPE_XML], NULL, run_xml, &xml_sec)) { + upsdebugx(1, "pthread_create returned an error; disabling this scan mode"); nutscan_avail_xml_http = 0; } #else - dev[TYPE_XML] = nutscan_scan_xml_http(timeout); + upsdebugx(1, "XML/HTTP SCAN: no pthread support, starting nutscan_scan_xml_http_range()..."); + dev[TYPE_XML] = nutscan_scan_xml_http_range(start_ip, end_ip, timeout, &xml_sec); #endif /* HAVE_PTHREAD */ + } else { + upsdebugx(1, "XML/HTTP SCAN: not requested, SKIPPED"); } - if( allow_oldnut && nutscan_avail_nut) { - if( start_ip == NULL ) { - printq(quiet,"No start IP, skipping NUT bus (old connect method)\n"); + if (allow_oldnut && nutscan_avail_nut) { + if (start_ip == NULL) { + upsdebugx(quiet, "No start IP, skipping NUT bus (old connect method)"); nutscan_avail_nut = 0; } else { - printq(quiet,"Scanning NUT bus (old connect method).\n"); + upsdebugx(quiet, "Scanning NUT bus (old connect method)."); #ifdef HAVE_PTHREAD - if(pthread_create(&thread[TYPE_NUT],NULL,run_nut_old,NULL)) { + upsdebugx(1, "NUT bus (old) SCAN: starting pthread_create with run_nut_old..."); + if (pthread_create(&thread[TYPE_NUT], NULL, run_nut_old, NULL)) { + upsdebugx(1, "pthread_create returned an error; disabling this scan mode"); nutscan_avail_nut = 0; } #else - dev[TYPE_NUT] = nutscan_scan_nut(start_ip,end_ip,port,timeout); + upsdebugx(1, "NUT bus (old) SCAN: no pthread support, starting nutscan_scan_nut..."); + dev[TYPE_NUT] = nutscan_scan_nut(start_ip, end_ip, port, timeout); #endif /* HAVE_PTHREAD */ } + } else { + upsdebugx(1, "NUT bus (old) SCAN: not requested, SKIPPED"); } - if( allow_avahi && nutscan_avail_avahi) { - printq(quiet,"Scanning NUT bus (avahi method).\n"); + if (allow_avahi && nutscan_avail_avahi) { + upsdebugx(quiet, "Scanning NUT bus (avahi method)."); #ifdef HAVE_PTHREAD - if(pthread_create(&thread[TYPE_AVAHI],NULL,run_avahi,NULL)) { + upsdebugx(1, "NUT bus (avahi) SCAN: starting pthread_create with run_avahi..."); + if (pthread_create(&thread[TYPE_AVAHI], NULL, run_avahi, NULL)) { + upsdebugx(1, "pthread_create returned an error; disabling this scan mode"); nutscan_avail_avahi = 0; } #else + upsdebugx(1, "NUT bus (avahi) SCAN: no pthread support, starting nutscan_scan_avahi..."); dev[TYPE_AVAHI] = nutscan_scan_avahi(timeout); #endif /* HAVE_PTHREAD */ + } else { + upsdebugx(1, "NUT bus (avahi) SCAN: not requested, SKIPPED"); } - if( allow_ipmi && nutscan_avail_ipmi) { - printq(quiet,"Scanning IPMI bus.\n"); + if (allow_ipmi && nutscan_avail_ipmi) { + upsdebugx(quiet, "Scanning IPMI bus."); #ifdef HAVE_PTHREAD - if(pthread_create(&thread[TYPE_IPMI],NULL,run_ipmi,&ipmi_sec)) { + upsdebugx(1, "IPMI SCAN: starting pthread_create with run_ipmi..."); + if (pthread_create(&thread[TYPE_IPMI], NULL, run_ipmi, &ipmi_sec)) { + upsdebugx(1, "pthread_create returned an error; disabling this scan mode"); nutscan_avail_ipmi = 0; } #else - dev[TYPE_IPMI] = nutscan_scan_ipmi(start_ip,end_ip,&ipmi_sec); + upsdebugx(1, "IPMI SCAN: no pthread support, starting nutscan_scan_ipmi..."); + dev[TYPE_IPMI] = nutscan_scan_ipmi(start_ip, end_ip, &ipmi_sec); #endif /* HAVE_PTHREAD */ + } else { + upsdebugx(1, "IPMI SCAN: not requested, SKIPPED"); } /* Eaton serial scan */ if (allow_eaton_serial) { - printq(quiet,"Scanning serial bus for Eaton devices.\n"); + upsdebugx(quiet, "Scanning serial bus for Eaton devices."); #ifdef HAVE_PTHREAD + upsdebugx(1, "SERIAL SCAN: starting pthread_create with run_eaton_serial (return not checked!)..."); pthread_create(&thread[TYPE_EATON_SERIAL], NULL, run_eaton_serial, serial_ports); /* FIXME: check return code */ + /* upsdebugx(1, "pthread_create returned an error; disabling this scan mode"); */ + /* nutscan_avail_eaton_serial(?) = 0; */ #else + upsdebugx(1, "SERIAL SCAN: no pthread support, starting nutscan_scan_eaton_serial..."); dev[TYPE_EATON_SERIAL] = nutscan_scan_eaton_serial (serial_ports); #endif /* HAVE_PTHREAD */ + } else { + upsdebugx(1, "SERIAL SCAN: not requested, SKIPPED"); } #ifdef HAVE_PTHREAD - if( allow_usb && nutscan_avail_usb && thread[TYPE_USB]) { + if (allow_usb && nutscan_avail_usb && thread[TYPE_USB]) { + upsdebugx(1, "USB SCAN: join back the pthread"); pthread_join(thread[TYPE_USB], NULL); } - if( allow_snmp && nutscan_avail_snmp && thread[TYPE_SNMP]) { + if (allow_snmp && nutscan_avail_snmp && thread[TYPE_SNMP]) { + upsdebugx(1, "SNMP SCAN: join back the pthread"); pthread_join(thread[TYPE_SNMP], NULL); } - if( allow_xml && nutscan_avail_xml_http && thread[TYPE_XML]) { + if (allow_xml && nutscan_avail_xml_http && thread[TYPE_XML]) { + upsdebugx(1, "XML/HTTP SCAN: join back the pthread"); pthread_join(thread[TYPE_XML], NULL); } - if( allow_oldnut && nutscan_avail_nut && thread[TYPE_NUT]) { + if (allow_oldnut && nutscan_avail_nut && thread[TYPE_NUT]) { + upsdebugx(1, "NUT bus (old) SCAN: join back the pthread"); pthread_join(thread[TYPE_NUT], NULL); } - if( allow_avahi && nutscan_avail_avahi && thread[TYPE_AVAHI]) { + if (allow_avahi && nutscan_avail_avahi && thread[TYPE_AVAHI]) { + upsdebugx(1, "NUT bus (avahi) SCAN: join back the pthread"); pthread_join(thread[TYPE_AVAHI], NULL); } - if( allow_ipmi && nutscan_avail_ipmi && thread[TYPE_IPMI]) { + if (allow_ipmi && nutscan_avail_ipmi && thread[TYPE_IPMI]) { + upsdebugx(1, "IPMI SCAN: join back the pthread"); pthread_join(thread[TYPE_IPMI], NULL); } if (allow_eaton_serial && thread[TYPE_EATON_SERIAL]) { + upsdebugx(1, "SERIAL SCAN: join back the pthread"); pthread_join(thread[TYPE_EATON_SERIAL], NULL); } #endif /* HAVE_PTHREAD */ + upsdebugx(1, "SCANS DONE: display results"); + + upsdebugx(1, "SCANS DONE: display results: USB"); display_func(dev[TYPE_USB]); + upsdebugx(1, "SCANS DONE: free resources: USB"); nutscan_free_device(dev[TYPE_USB]); + upsdebugx(1, "SCANS DONE: display results: SNMP"); display_func(dev[TYPE_SNMP]); + upsdebugx(1, "SCANS DONE: free resources: SNMP"); nutscan_free_device(dev[TYPE_SNMP]); + upsdebugx(1, "SCANS DONE: display results: XML/HTTP"); display_func(dev[TYPE_XML]); + upsdebugx(1, "SCANS DONE: free resources: XML/HTTP"); nutscan_free_device(dev[TYPE_XML]); + upsdebugx(1, "SCANS DONE: display results: NUT bus (old)"); display_func(dev[TYPE_NUT]); + upsdebugx(1, "SCANS DONE: free resources: NUT bus (old)"); nutscan_free_device(dev[TYPE_NUT]); + upsdebugx(1, "SCANS DONE: display results: NUT bus (avahi)"); display_func(dev[TYPE_AVAHI]); + upsdebugx(1, "SCANS DONE: free resources: NUT bus (avahi)"); nutscan_free_device(dev[TYPE_AVAHI]); + upsdebugx(1, "SCANS DONE: display results: IPMI"); display_func(dev[TYPE_IPMI]); + upsdebugx(1, "SCANS DONE: free resources: IPMI"); nutscan_free_device(dev[TYPE_IPMI]); + upsdebugx(1, "SCANS DONE: display results: SERIAL"); display_func(dev[TYPE_EATON_SERIAL]); + upsdebugx(1, "SCANS DONE: free resources: SERIAL"); nutscan_free_device(dev[TYPE_EATON_SERIAL]); +#ifdef HAVE_PTHREAD +# ifdef HAVE_SEMAPHORE + sem_destroy(nutscan_semaphore()); +# endif +#endif + + upsdebugx(1, "SCANS DONE: free common scanner resources"); nutscan_free(); + upsdebugx(1, "SCANS DONE: EXIT_SUCCESS"); return EXIT_SUCCESS; } diff --git a/tools/nut-scanner/nutscan-device.c b/tools/nut-scanner/nutscan-device.c index 58c8874..bde57fe 100644 --- a/tools/nut-scanner/nutscan-device.c +++ b/tools/nut-scanner/nutscan-device.c @@ -20,6 +20,7 @@ \brief manipulation of a container describing a NUT device \author Frederic Bohe */ +#include "config.h" /* must be the first header */ #include "nutscan-device.h" #include @@ -34,18 +35,18 @@ const char * nutscan_device_type_strings[TYPE_END - 1] = { "IPMI", "Avahi", "serial", - }; +}; nutscan_device_t * nutscan_new_device() { nutscan_device_t * device; device = malloc(sizeof(nutscan_device_t)); - if( device==NULL) { + if (device == NULL) { return NULL; } - memset(device,0,sizeof(nutscan_device_t)); + memset(device, 0, sizeof(nutscan_device_t)); return device; } @@ -54,13 +55,13 @@ static void deep_free_device(nutscan_device_t * device) { nutscan_options_t * current; - if(device==NULL) { + if (device == NULL) { return; } - if(device->driver) { + if (device->driver) { free(device->driver); } - if(device->port) { + if (device->port) { free(device->port); } @@ -68,21 +69,21 @@ static void deep_free_device(nutscan_device_t * device) current = device->opt; device->opt = current->next; - if(current->option != NULL) { + if (current->option != NULL) { free(current->option); } - if(current->value != NULL) { + if (current->value != NULL) { free(current->value); } free(current); - }; + } - if(device->prev) { + if (device->prev) { device->prev->next = device->next; } - if(device->next) { + if (device->next) { device->next->prev = device->prev; } @@ -91,13 +92,13 @@ static void deep_free_device(nutscan_device_t * device) void nutscan_free_device(nutscan_device_t * device) { - if(device==NULL) { + if (device == NULL) { return; } - while(device->prev != NULL) { + while (device->prev != NULL) { deep_free_device(device->prev); } - while(device->next != NULL) { + while (device->next != NULL) { deep_free_device(device->next); } @@ -116,19 +117,19 @@ void nutscan_add_option_to_device(nutscan_device_t * device, char * option, char *opt = (nutscan_options_t *)malloc(sizeof(nutscan_options_t)); - // TBD: A gracefull way to propagate memory failure would be nice + /* TBD: A gracefull way to propagate memory failure would be nice */ assert(NULL != *opt); memset(*opt, 0, sizeof(nutscan_options_t)); - if( option != NULL ) { + if (option != NULL) { (*opt)->option = strdup(option); } else { (*opt)->option = NULL; } - if( value != NULL ) { + if (value != NULL) { (*opt)->value = strdup(value); } else { @@ -138,41 +139,40 @@ void nutscan_add_option_to_device(nutscan_device_t * device, char * option, char nutscan_device_t * nutscan_add_device_to_device(nutscan_device_t * first, nutscan_device_t * second) { - nutscan_device_t * dev1=NULL; - nutscan_device_t * dev2=NULL; + nutscan_device_t * dev1 = NULL; + nutscan_device_t * dev2 = NULL; /* Get end of first device */ - if( first != NULL) { + if (first != NULL) { dev1 = first; - while(dev1->next != NULL) { + while (dev1->next != NULL) { dev1 = dev1->next; } } else { - if( second == NULL ) { + if (second == NULL) { return NULL; } /* return end of second */ dev2 = second; - while(dev2->next != NULL) { + while (dev2->next != NULL) { dev2 = dev2->next; } return dev2; } /* Get start of second */ - if( second != NULL ) { + if (second != NULL) { dev2 = second; - while(dev2->prev != NULL) { + while (dev2->prev != NULL) { dev2 = dev2->prev; } } else { /* return end of first */ dev1 = first; - while(dev1->next != NULL) { + while (dev1->next != NULL) { dev1 = dev1->next; - } return dev1; } @@ -182,8 +182,8 @@ nutscan_device_t * nutscan_add_device_to_device(nutscan_device_t * first, nutsca dev2->prev = dev1; /* return end of both */ - while(dev2->next != NULL) { - dev2 = dev2->next; + while (dev2->next != NULL) { + dev2 = dev2->next; } return dev2; diff --git a/tools/nut-scanner/nutscan-device.h b/tools/nut-scanner/nutscan-device.h index 5001a6a..9023394 100644 --- a/tools/nut-scanner/nutscan-device.h +++ b/tools/nut-scanner/nutscan-device.h @@ -41,7 +41,7 @@ extern "C" { (assert(0 < (type) && (type) < TYPE_END), nutscan_device_type_strings[type - 1]) typedef enum nutscan_device_type { - TYPE_NONE=0, + TYPE_NONE = 0, TYPE_USB, TYPE_SNMP, TYPE_XML, @@ -70,9 +70,9 @@ typedef struct nutscan_device { struct nutscan_device * next; } nutscan_device_t; -nutscan_device_t * nutscan_new_device(); +nutscan_device_t * nutscan_new_device(void); void nutscan_free_device(nutscan_device_t * device); -void nutscan_add_option_to_device(nutscan_device_t * device,char * option, char * value); +void nutscan_add_option_to_device(nutscan_device_t * device, char * option, char * value); nutscan_device_t * nutscan_add_device_to_device(nutscan_device_t * first, nutscan_device_t * second); /** diff --git a/tools/nut-scanner/nutscan-display.c b/tools/nut-scanner/nutscan-display.c index 6a2987d..71f2248 100644 --- a/tools/nut-scanner/nutscan-display.c +++ b/tools/nut-scanner/nutscan-display.c @@ -24,16 +24,18 @@ #include "common.h" #include #include "nutscan-device.h" +#include "nut-scan.h" -char * nutscan_device_type_string[TYPE_END]= { - "NONE", - "USB", - "SNMP", - "XML", - "NUT", - "IPMI", - "AVAHI", - "EATON_SERIAL" }; +static char * nutscan_device_type_string[TYPE_END] = { + "NONE", + "USB", + "SNMP", + "XML", + "NUT", + "IPMI", + "AVAHI", + "EATON_SERIAL" +}; void nutscan_display_ups_conf(nutscan_device_t * device) { @@ -41,16 +43,16 @@ void nutscan_display_ups_conf(nutscan_device_t * device) nutscan_options_t * opt; static int nutdev_num = 1; - if(device==NULL) { + if (device == NULL) { return; } /* Find start of the list */ - while(current_dev->prev != NULL) { + while (current_dev->prev != NULL) { current_dev = current_dev->prev; } - /* Display each devices */ + /* Display each device */ do { printf("[nutdev%i]\n\tdriver = \"%s\"\n\tport = \"%s\"\n", nutdev_num, current_dev->driver, @@ -59,9 +61,9 @@ void nutscan_display_ups_conf(nutscan_device_t * device) opt = current_dev->opt; while (NULL != opt) { - if( opt->option != NULL ) { - printf("\t%s",opt->option); - if( opt->value != NULL ) { + if (opt->option != NULL) { + printf("\t%s", opt->option); + if (opt->value != NULL) { printf(" = \"%s\"", opt->value); } printf("\n"); @@ -73,7 +75,7 @@ void nutscan_display_ups_conf(nutscan_device_t * device) current_dev = current_dev->next; } - while( current_dev != NULL ); + while (current_dev != NULL); } void nutscan_display_parsable(nutscan_device_t * device) @@ -81,17 +83,18 @@ void nutscan_display_parsable(nutscan_device_t * device) nutscan_device_t * current_dev = device; nutscan_options_t * opt; - if(device==NULL) { + if (device == NULL) { return; } /* Find start of the list */ - while(current_dev->prev != NULL) { + while (current_dev->prev != NULL) { current_dev = current_dev->prev; } - /* Display each devices */ + /* Display each device */ do { + /* Do not separate by whitespace, in case someone already parses this */ printf("%s:driver=\"%s\",port=\"%s\"", nutscan_device_type_string[current_dev->type], current_dev->driver, @@ -100,9 +103,10 @@ void nutscan_display_parsable(nutscan_device_t * device) opt = current_dev->opt; while (NULL != opt) { - if( opt->option != NULL ) { - printf(",%s",opt->option); - if( opt->value != NULL ) { + if (opt->option != NULL) { + /* Do not separate by whitespace, in case someone already parses this */ + printf(",%s", opt->option); + if (opt->value != NULL) { printf("=\"%s\"", opt->value); } } @@ -113,6 +117,5 @@ void nutscan_display_parsable(nutscan_device_t * device) current_dev = current_dev->next; } - while( current_dev != NULL ); + while (current_dev != NULL); } - diff --git a/tools/nut-scanner/nutscan-init.c b/tools/nut-scanner/nutscan-init.c index 5f08ea2..9ea3f5d 100644 --- a/tools/nut-scanner/nutscan-init.c +++ b/tools/nut-scanner/nutscan-init.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 - EATON + * Copyright (C) 2011-2021 - EATON * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,14 +19,16 @@ /*! \file nutscan-init.c \brief init functions for nut scanner library \author Frederic Bohe + \author Arnaud Quette */ #include "common.h" +#include "nutscan-init.h" #include #include -#include #include #include +#include "nut-scan.h" int nutscan_avail_avahi = 0; int nutscan_avail_ipmi = 0; @@ -42,85 +44,176 @@ int nutscan_load_avahi_library(const char *libname_path); int nutscan_load_ipmi_library(const char *libname_path); int nutscan_load_upsclient_library(const char *libname_path); -/* FIXME: would be good to get more from /etc/ld.so.conf[.d] */ -char * search_paths[] = { - LIBDIR, - "/usr/lib64", - "/lib64", - "/usr/lib", - "/lib", - "/usr/local/lib", - NULL -}; +#ifdef HAVE_PTHREAD +# ifdef HAVE_SEMAPHORE +/* Shared by library consumers, exposed by nutscan_semaphore() below */ +static sem_t semaphore; -const char * get_libname(const char* base_libname) +sem_t * nutscan_semaphore(void) { - DIR *dp; - struct dirent *dirp; - int index = 0; - char *libname_path = NULL; - char current_test_path[LARGEBUF]; - - for(index = 0 ; (search_paths[index] != NULL) && (libname_path == NULL) ; index++) - { - memset(current_test_path, 0, LARGEBUF); - - if ((dp = opendir(search_paths[index])) == NULL) - continue; - - while ((dirp = readdir(dp)) != NULL) - { - if(!strncmp(dirp->d_name, base_libname, strlen(base_libname))) { - snprintf(current_test_path, LARGEBUF, "%s/%s", search_paths[index], dirp->d_name); - libname_path = realpath(current_test_path, NULL); - if (libname_path != NULL) - break; - } - } - closedir(dp); - } - /* fprintf(stderr,"Looking for lib %s, found %s\n", base_libname, (libname_path!=NULL)?libname_path:"NULL");*/ - return libname_path; + return &semaphore; } +# endif /* HAVE_SEMAPHORE */ + +# ifdef HAVE_PTHREAD_TRYJOIN +pthread_mutex_t threadcount_mutex; +# endif + +# if (defined HAVE_PTHREAD_TRYJOIN) || (defined HAVE_SEMAPHORE) +/* We have 3 networked scan types: nut, snmp, xml, + * and users typically give their /24 subnet as "-m" arg. + * With some systems having a 1024 default (u)limit to + * file descriptors, this should fit if those are involved. + * On some systems tested, a large amount of not-joined + * pthreads did cause various crashes; also RAM is limited. + * Note that each scan may be time consuming to query an + * IP address and wait for (no) reply, so while these threads + * are usually not resource-intensive (nor computationally), + * they spend much wallclock time each so parallelism helps. + */ +size_t max_threads = DEFAULT_THREAD; +size_t curr_threads = 0; + +size_t max_threads_netxml = 1021; /* experimental finding, see PR#1158 */ +size_t max_threads_oldnut = 1021; +size_t max_threads_netsnmp = 0; /* 10240; */ + /* per reports in PR#1158, some versions of net-snmp could be limited + * to 1024 threads in the past; this was not found in practice. + * Still, some practical limit can be useful (configurable?) + * Here 0 means to not apply any special limit (beside max_threads). + */ + +# endif /* HAVE_PTHREAD_TRYJOIN || HAVE_SEMAPHORE */ + +#endif /* HAVE_PTHREAD */ void nutscan_init(void) { +#ifdef HAVE_PTHREAD +/* TOTHINK: Should semaphores to limit thread count + * and the more naive but portable methods be an + * if-else proposition? At least when initializing? + */ +# ifdef HAVE_SEMAPHORE + /* NOTE: This semaphore may get re-initialized in nut-scanner program + * after parsing command-line arguments. It calls nutscan_init() before + * parsing CLI, to know about available libs and to set defaults below. + */ +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic ignored "-Wunreachable-code" +#endif +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" +#endif + /* Different platforms, different sizes, none fits all... */ + if (SIZE_MAX > UINT_MAX && max_threads > UINT_MAX) { +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic pop +#endif + upsdebugx(1, + "WARNING: %s: Limiting max_threads to range acceptable for sem_init()", + __func__); + max_threads = UINT_MAX - 1; + } + sem_init(&semaphore, 0, (unsigned int)max_threads); +# endif + +# ifdef HAVE_PTHREAD_TRYJOIN + pthread_mutex_init(&threadcount_mutex, NULL); +# endif +#endif /* HAVE_PTHREAD */ + + char *libname = NULL; #ifdef WITH_USB - nutscan_avail_usb = nutscan_load_usb_library(get_libname("libusb-0.1.so")); + #if WITH_LIBUSB_1_0 + libname = get_libname("libusb-1.0.so"); + #else + libname = get_libname("libusb-0.1.so"); + if (!libname) { + /* We can also use libusb-compat from newer libusb-1.0 releases */ + libname = get_libname("libusb.so"); + } + #endif + if (libname) { + nutscan_avail_usb = nutscan_load_usb_library(libname); + free(libname); + } #endif #ifdef WITH_SNMP - nutscan_avail_snmp = nutscan_load_snmp_library(get_libname("libnetsnmp.so")); + libname = get_libname("libnetsnmp.so"); + if (libname) { + nutscan_avail_snmp = nutscan_load_snmp_library(libname); + free(libname); + } #endif #ifdef WITH_NEON - nutscan_avail_xml_http = nutscan_load_neon_library(get_libname("libneon.so")); + libname = get_libname("libneon.so"); + if (!libname) { + libname = get_libname("libneon-gnutls.so"); + } + if (libname) { + nutscan_avail_xml_http = nutscan_load_neon_library(libname); + free(libname); + } #endif #ifdef WITH_AVAHI - nutscan_avail_avahi = nutscan_load_avahi_library(get_libname("libavahi-client.so")); + libname = get_libname("libavahi-client.so"); + if (libname) { + nutscan_avail_avahi = nutscan_load_avahi_library(libname); + free(libname); + } #endif #ifdef WITH_FREEIPMI - nutscan_avail_ipmi = nutscan_load_ipmi_library(get_libname("libfreeipmi.so")); + libname = get_libname("libfreeipmi.so"); + if (libname) { + nutscan_avail_ipmi = nutscan_load_ipmi_library(libname); + free(libname); + } #endif - nutscan_avail_nut = nutscan_load_upsclient_library(get_libname("libupsclient.so")); + libname = get_libname("libupsclient.so"); + if (libname) { + nutscan_avail_nut = nutscan_load_upsclient_library(libname); + free(libname); + } } void nutscan_free(void) { - if( nutscan_avail_usb ) { + if (nutscan_avail_usb) { lt_dlexit(); } - if( nutscan_avail_snmp ) { + if (nutscan_avail_snmp) { lt_dlexit(); } - if( nutscan_avail_xml_http ) { + if (nutscan_avail_xml_http) { lt_dlexit(); } - if( nutscan_avail_avahi ) { + if (nutscan_avail_avahi) { lt_dlexit(); } - if( nutscan_avail_ipmi ) { + if (nutscan_avail_ipmi) { lt_dlexit(); } - if( nutscan_avail_nut ) { + if (nutscan_avail_nut) { lt_dlexit(); } + +#ifdef HAVE_PTHREAD +/* TOTHINK: See comments near mutex/semaphore init code above */ +# ifdef HAVE_SEMAPHORE + sem_destroy(nutscan_semaphore()); +# endif + +# ifdef HAVE_PTHREAD_TRYJOIN + pthread_mutex_destroy(&threadcount_mutex); +# endif +#endif + } diff --git a/tools/nut-scanner/nutscan-init.h b/tools/nut-scanner/nutscan-init.h index e242693..4ff5f39 100644 --- a/tools/nut-scanner/nutscan-init.h +++ b/tools/nut-scanner/nutscan-init.h @@ -40,6 +40,8 @@ extern int nutscan_avail_xml_http; void nutscan_init(void); void nutscan_free(void); +#define DEFAULT_THREAD 512 + #ifdef __cplusplus /* *INDENT-OFF* */ } diff --git a/tools/nut-scanner/nutscan-ip.c b/tools/nut-scanner/nutscan-ip.c index 5622242..f064534 100644 --- a/tools/nut-scanner/nutscan-ip.c +++ b/tools/nut-scanner/nutscan-ip.c @@ -21,6 +21,8 @@ \author Frederic Bohe */ +#include "config.h" /* must be first */ + #include "nutscan-ip.h" #include #include "common.h" @@ -32,9 +34,9 @@ static void increment_IPv6(struct in6_addr * addr) { int i; - for( i=15 ; i>= 0 ; i--) { + for (i = 15 ; i >= 0 ; i--) { addr->s6_addr[i]++; - if( addr->s6_addr[i] != 0) { + if (addr->s6_addr[i] != 0) { break; } } @@ -44,37 +46,39 @@ static void invert_IPv6(struct in6_addr * addr1, struct in6_addr * addr2) { struct in6_addr addr; - memcpy(addr.s6_addr,addr1->s6_addr,sizeof(addr.s6_addr)); - memcpy(addr1->s6_addr,addr2->s6_addr,sizeof(addr.s6_addr)); - memcpy(addr2->s6_addr,addr.s6_addr,sizeof(addr.s6_addr)); + memcpy(addr.s6_addr, addr1->s6_addr, sizeof(addr.s6_addr)); + memcpy(addr1->s6_addr, addr2->s6_addr, sizeof(addr.s6_addr)); + memcpy(addr2->s6_addr, addr.s6_addr, sizeof(addr.s6_addr)); } -static int ntop( struct in_addr * ip, char * host, size_t host_size) +static int ntop(struct in_addr * ip, char * host, GETNAMEINFO_TYPE_ARG46 host_size) { struct sockaddr_in in; - memset(&in,0,sizeof(struct sockaddr_in)); + memset(&in, 0, sizeof(struct sockaddr_in)); in.sin_addr = *ip; in.sin_family = AF_INET; - return getnameinfo((struct sockaddr *)&in, - sizeof(struct sockaddr_in), - host,host_size,NULL,0,NI_NUMERICHOST); + return getnameinfo( + (struct sockaddr *)&in, + sizeof(struct sockaddr_in), + host, host_size, NULL, 0, NI_NUMERICHOST); } -static int ntop6( struct in6_addr * ip, char * host, size_t host_size) +static int ntop6(struct in6_addr * ip, char * host, GETNAMEINFO_TYPE_ARG46 host_size) { struct sockaddr_in6 in6; - memset(&in6,0,sizeof(struct sockaddr_in6)); - memcpy( &in6.sin6_addr, ip, sizeof(struct in6_addr) ); + memset(&in6, 0, sizeof(struct sockaddr_in6)); + memcpy(&in6.sin6_addr, ip, sizeof(struct in6_addr)); in6.sin6_family = AF_INET6; - return getnameinfo((struct sockaddr *)&in6, - sizeof(struct sockaddr_in6), - host,host_size,NULL,0,NI_NUMERICHOST); + return getnameinfo( + (struct sockaddr *)&in6, + sizeof(struct sockaddr_in6), + host, host_size, NULL, 0, NI_NUMERICHOST); } /* Return the first ip or NULL if error */ char * nutscan_ip_iter_init(nutscan_ip_iter_t * ip, const char * startIP, const char * stopIP) { - int addr; + uint32_t addr; /* 32-bit IPv4 address */ int i; struct addrinfo hints; struct addrinfo *res; @@ -82,92 +86,127 @@ char * nutscan_ip_iter_init(nutscan_ip_iter_t * ip, const char * startIP, const struct sockaddr_in6 * s_in6; char host[SMALLBUF]; - if( startIP == NULL ) { + if (startIP == NULL) { return NULL; } - if(stopIP == NULL ) { + if (stopIP == NULL) { stopIP = startIP; } - memset(&hints,0,sizeof(struct addrinfo)); + memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_INET; ip->type = IPv4; /* Detecting IPv4 vs IPv6 */ - if(getaddrinfo(startIP,NULL,&hints,&res) != 0) { + if (getaddrinfo(startIP, NULL, &hints, &res) != 0) { /*Try IPv6 detection */ ip->type = IPv6; hints.ai_family = AF_INET6; - if(getaddrinfo(startIP,NULL,&hints,&res) != 0) { - fprintf(stderr,"Invalid address : %s\n",startIP); + if (getaddrinfo(startIP, NULL, &hints, &res) != 0) { + fprintf(stderr, "Invalid address : %s\n", startIP); return NULL; } - + +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wcast-align" +#endif + /* Note: we receive a pointer to res above, so have + * no control about alignment of its further data */ s_in6 = (struct sockaddr_in6 *)res->ai_addr; - memcpy(&ip->start6,&s_in6->sin6_addr,sizeof(struct in6_addr)); +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN) +# pragma GCC diagnostic pop +#endif + memcpy(&ip->start6, &s_in6->sin6_addr, sizeof(struct in6_addr)); freeaddrinfo(res); } else { +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wcast-align" +#endif + /* Note: we receive a pointer to res above, so have + * no control about alignment of its further data */ s_in = (struct sockaddr_in *)res->ai_addr; +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN) +# pragma GCC diagnostic pop +#endif ip->start = s_in->sin_addr; freeaddrinfo(res); } /* Compute stop IP */ - if( ip->type == IPv4 ) { + if (ip->type == IPv4) { hints.ai_family = AF_INET; - if(getaddrinfo(stopIP,NULL,&hints,&res) != 0) { - fprintf(stderr,"Invalid address : %s\n",stopIP); - return NULL; - } + if (getaddrinfo(stopIP, NULL, &hints, &res) != 0) { + fprintf(stderr, "Invalid address : %s\n", stopIP); + return NULL; + } +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wcast-align" +#endif + /* Note: we receive a pointer to res above, so have + * no control about alignment of its further data */ s_in = (struct sockaddr_in *)res->ai_addr; +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN) +# pragma GCC diagnostic pop +#endif ip->stop = s_in->sin_addr; freeaddrinfo(res); - } - else { + } + else { hints.ai_family = AF_INET6; - if(getaddrinfo(stopIP,NULL,&hints,&res) != 0) { - fprintf(stderr,"Invalid address : %s\n",stopIP); - return NULL; - } + if (getaddrinfo(stopIP, NULL, &hints, &res) != 0) { + fprintf(stderr, "Invalid address : %s\n", stopIP); + return NULL; + } +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wcast-align" +#endif + /* Note: we receive a pointer to res above, so have + * no control about alignment of its further data */ s_in6 = (struct sockaddr_in6 *)res->ai_addr; - memcpy(&ip->stop6,&s_in6->sin6_addr,sizeof(struct in6_addr)); +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN) +# pragma GCC diagnostic pop +#endif + memcpy(&ip->stop6, &s_in6->sin6_addr, sizeof(struct in6_addr)); freeaddrinfo(res); - } + } - /* Make sure start IP is lesser than stop IP */ - if( ip->type == IPv4 ) { - if( ntohl(ip->start.s_addr) > ntohl(ip->stop.s_addr) ) { - addr = ip->start.s_addr; - ip->start.s_addr = ip->stop.s_addr; - ip->stop.s_addr = addr; - } + /* Make sure start IP is lesser than stop IP */ + if (ip->type == IPv4) { + if (ntohl(ip->start.s_addr) > ntohl(ip->stop.s_addr)) { + addr = ip->start.s_addr; + ip->start.s_addr = ip->stop.s_addr; + ip->stop.s_addr = addr; + } - if( ntop(&ip->start, host, sizeof(host)) != 0 ) { + if (ntop(&ip->start, host, sizeof(host)) != 0) { return NULL; } return strdup(host); - } - else { /* IPv6 */ - for( i=0; i<16; i++ ) { - if( ip->start6.s6_addr[i] !=ip->stop6.s6_addr[i] ) { - if(ip->start6.s6_addr[i]>ip->stop6.s6_addr[i]){ - invert_IPv6(&ip->start6,&ip->stop6); - } - break; - } - } + } + else { /* IPv6 */ + for (i = 0; i < 16; i++) { + if (ip->start6.s6_addr[i] !=ip->stop6.s6_addr[i]) { + if (ip->start6.s6_addr[i] > ip->stop6.s6_addr[i]) { + invert_IPv6(&ip->start6, &ip->stop6); + } + break; + } + } - if( ntop6(&ip->start6, host, sizeof(host)) != 0 ) { + if (ntop6(&ip->start6, host, sizeof(host)) != 0) { return NULL; } return strdup(host); - } - + } } @@ -178,30 +217,30 @@ char * nutscan_ip_iter_inc(nutscan_ip_iter_t * ip) { char host[SMALLBUF]; - if( ip->type == IPv4 ) { + if (ip->type == IPv4) { /* Check if this is the last address to scan */ - if(ip->start.s_addr == ip->stop.s_addr) { + if (ip->start.s_addr == ip->stop.s_addr) { return NULL; } /* increment the address (need to pass address in host byte order, then pass back in network byte order */ - ip->start.s_addr = htonl((ntohl(ip->start.s_addr)+1)); + ip->start.s_addr = htonl((ntohl(ip->start.s_addr) + 1)); - if( ntop(&ip->start, host, sizeof(host)) != 0 ) { + if (ntop(&ip->start, host, sizeof(host)) != 0) { return NULL; } - + return strdup(host); } else { /* Check if this is the last address to scan */ - if( memcmp(&ip->start6.s6_addr, &ip->stop6.s6_addr, - sizeof(ip->start6.s6_addr)) == 0 ) { + if (memcmp(&ip->start6.s6_addr, &ip->stop6.s6_addr, + sizeof(ip->start6.s6_addr)) == 0) { return NULL; } increment_IPv6(&ip->start6); - if( ntop6(&ip->start6, host, sizeof(host)) != 0 ) { + if (ntop6(&ip->start6, host, sizeof(host)) != 0) { return NULL; } @@ -218,7 +257,7 @@ int nutscan_cidr_to_ip(const char * cidr, char ** start_ip, char ** stop_ip) nutscan_ip_iter_t ip; int mask_val; int mask_byte; - unsigned long mask_bit; + uint32_t mask_bit; /* 32-bit IPv4 address bitmask */ char host[SMALLBUF]; struct addrinfo hints; struct addrinfo *res; @@ -229,47 +268,87 @@ int nutscan_cidr_to_ip(const char * cidr, char ** start_ip, char ** stop_ip) *stop_ip = NULL; cidr_tok = strdup(cidr); - first_ip = strdup(strtok_r(cidr_tok,"/",&saveptr)); - if( first_ip == NULL) { + first_ip = strdup(strtok_r(cidr_tok, "/", &saveptr)); + if (first_ip == NULL) { + upsdebugx(0, "WARNING: %s failed to parse first_ip from cidr=%s", + __func__, cidr); + free(cidr_tok); return 0; } - mask = strtok_r(NULL,"/",&saveptr); - if( mask == NULL ) { + mask = strtok_r(NULL, "/", &saveptr); + if (mask == NULL) { + upsdebugx(0, "WARNING: %s failed to parse mask from cidr=%s (first_ip=%s)", + __func__, cidr, first_ip); + free (first_ip); + free(cidr_tok); return 0; } - free(cidr_tok); + upsdebugx(5, "%s: parsed cidr=%s into first_ip=%s and mask=%s", + __func__, cidr, first_ip, mask); mask_val = atoi(mask); + upsdebugx(5, "%s: parsed mask value %d", + __func__, mask_val); - /* Detecting IPv4 vs IPv6 */ - memset(&hints,0,sizeof(struct addrinfo)); + /* NOTE: Sanity-wise, some larger number also makes sense + * as the maximum subnet size we would scan. But at least, + * this helps avoid scanning the whole Internet just due + * to string-parsing errors. + */ + if (mask_val < 1) { + fatalx(EXIT_FAILURE, "Bad netmask: %s", mask); + } + + /* Note: this freeing invalidates "mask" and "saveptr" pointer targets */ + free(cidr_tok); + + /* Detecting IPv4 vs IPv6 */ + memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_INET; ip.type = IPv4; /* Detecting IPv4 vs IPv6 */ - if(getaddrinfo(first_ip,NULL,&hints,&res) != 0) { + if (getaddrinfo(first_ip, NULL, &hints, &res) != 0) { /*Try IPv6 detection */ ip.type = IPv6; hints.ai_family = AF_INET6; int ret; - if((ret=getaddrinfo(first_ip,NULL,&hints,&res)) != 0) { + if ((ret = getaddrinfo(first_ip, NULL, &hints, &res)) != 0) { free(first_ip); return 0; } - + +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wcast-align" +#endif + /* Note: we receive a pointer to res above, so have + * no control about alignment of its further data */ s_in6 = (struct sockaddr_in6 *)res->ai_addr; - memcpy(&ip.start6,&s_in6->sin6_addr,sizeof(struct in6_addr)); +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN) +# pragma GCC diagnostic pop +#endif + memcpy(&ip.start6, &s_in6->sin6_addr, sizeof(struct in6_addr)); freeaddrinfo(res); } else { +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wcast-align" +#endif + /* Note: we receive a pointer to res above, so have + * no control about alignment of its further data */ s_in = (struct sockaddr_in *)res->ai_addr; +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN) +# pragma GCC diagnostic pop +#endif ip.start = s_in->sin_addr; freeaddrinfo(res); } - if( ip.type == IPv4 ) { + if (ip.type == IPv4) { - if( mask_val > 0 ) { + if (mask_val > 0) { mask_val --; mask_bit = 0x80000000; mask_bit >>= mask_val; @@ -281,14 +360,14 @@ int nutscan_cidr_to_ip(const char * cidr, char ** start_ip, char ** stop_ip) ip.stop.s_addr = htonl(ntohl(ip.start.s_addr)|mask_bit); ip.start.s_addr = htonl(ntohl(ip.start.s_addr)&(~mask_bit)); - if( ntop(&ip.start, host, sizeof(host)) != 0 ) { + if (ntop(&ip.start, host, sizeof(host)) != 0) { *start_ip = NULL; *stop_ip = NULL; return 0; } *start_ip = strdup(host); - if( ntop(&ip.stop, host, sizeof(host)) != 0 ) { + if (ntop(&ip.stop, host, sizeof(host)) != 0) { free(*start_ip); *start_ip = NULL; *stop_ip = NULL; @@ -300,31 +379,40 @@ int nutscan_cidr_to_ip(const char * cidr, char ** start_ip, char ** stop_ip) return 1; } else { - if(getaddrinfo(first_ip,NULL,&hints,&res) != 0) { + if (getaddrinfo(first_ip, NULL, &hints, &res) != 0) { return 0; } +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wcast-align" +#endif + /* Note: we receive a pointer to res above, so have + * no control about alignment of its further data */ s_in6 = (struct sockaddr_in6 *)res->ai_addr; - memcpy(&ip.stop6,&s_in6->sin6_addr,sizeof(struct in6_addr)); +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_CAST_ALIGN) +# pragma GCC diagnostic pop +#endif + memcpy(&ip.stop6, &s_in6->sin6_addr, sizeof(struct in6_addr)); freeaddrinfo(res); mask_byte = mask_val / 8; - if( mask_byte < 16 ) { - memset( &(ip.stop6.s6_addr[mask_byte+1]), 0xFF, 15 - mask_byte); - memset( &(ip.start6.s6_addr[mask_byte+1]), 0x00, 15 - mask_byte); + if (mask_byte < 16 && mask_byte >= 0) { + memset(&(ip.stop6.s6_addr[mask_byte + 1]), 0xFF, 15 - (uint8_t)mask_byte); + memset(&(ip.start6.s6_addr[mask_byte + 1]), 0x00, 15 - (uint8_t)mask_byte); - mask_bit = (0x100 >> mask_val%8)-1; + mask_bit = (0x100 >> mask_val%8) - 1; ip.stop6.s6_addr[mask_byte] |= mask_bit; ip.start6.s6_addr[mask_byte] &= (~mask_bit); } - if( ntop6(&ip.start6, host, sizeof(host)) != 0 ) { + if (ntop6(&ip.start6, host, sizeof(host)) != 0) { *start_ip = NULL; *stop_ip = NULL; return 0; } *start_ip = strdup(host); - if( ntop6(&ip.stop6, host, sizeof(host)) != 0 ) { + if (ntop6(&ip.stop6, host, sizeof(host)) != 0) { free(*start_ip); *start_ip = NULL; *stop_ip = NULL; diff --git a/tools/nut-scanner/nutscan-ip.h b/tools/nut-scanner/nutscan-ip.h index d0cc78e..6fa868d 100644 --- a/tools/nut-scanner/nutscan-ip.h +++ b/tools/nut-scanner/nutscan-ip.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2011 - EATON * * This program is free software; you can redistribute it and/or modify @@ -34,16 +34,16 @@ extern "C" { #endif enum network_type { - IPv4, - IPv6 + IPv4, + IPv6 }; typedef struct nutscan_ip_iter { enum network_type type; - struct in_addr start; - struct in_addr stop; - struct in6_addr start6; - struct in6_addr stop6; + struct in_addr start; + struct in_addr stop; + struct in6_addr start6; + struct in6_addr stop6; } nutscan_ip_iter_t; char * nutscan_ip_iter_init(nutscan_ip_iter_t *, const char * startIP, const char * stopIP); diff --git a/tools/nut-scanner/nutscan-serial.c b/tools/nut-scanner/nutscan-serial.c index 42d9fca..bf4ac29 100644 --- a/tools/nut-scanner/nutscan-serial.c +++ b/tools/nut-scanner/nutscan-serial.c @@ -22,11 +22,14 @@ \author Arnaud Quette */ +#include "config.h" /* must be the first header */ + #include "nutscan-serial.h" #include #include #include #include "nut_platform.h" +#include "common.h" #ifdef WIN32 /* Windows: all serial port names start with "COM" */ @@ -44,7 +47,7 @@ typedef struct { char auto_stop_port; } device_portname_t; -device_portname_t device_portname[] = { +static device_portname_t device_portname[] = { #ifdef NUT_PLATFORM_HPUX /* the first number seems to be a card instance, the second number seems to be a port number */ @@ -70,7 +73,7 @@ device_portname_t device_portname[] = { /* { "/dev/ttyd%i", "=" }, */ /* { "/dev/ttyf%i", "=" }, */ /* FIXME: Mac OS X has no serial port, but maybe ttyUSB? */ - { NULL, 0 } + { NULL, 0, 0 } }; /* Return 1 if port_name is a full path name to a serial port, @@ -87,25 +90,26 @@ static int is_serial_port_path(const char * port_name) static char ** add_port(char ** list, char * port) { char ** res; - int count = 0; + size_t count = 0; - if(list == NULL) { + if (list == NULL) { count = 0; } else { - while(list[count] != NULL) { + while (list[count] != NULL) { count++; } } /*+1 to get the number of port from the index nb_ports*/ /*+1 for the terminal NULL */ - res = realloc(list,(count+1+1)*sizeof(char*)); - if( res == NULL ) { - return NULL; + res = realloc(list, sizeof(char*) * (count + 1 + 1)); + if (res == NULL) { + upsdebugx(1, "%s: Failed to realloc port list", __func__); + return list; } res[count] = strdup(port); - res[count+1] = NULL; + res[count + 1] = NULL; return res; } @@ -135,19 +139,19 @@ char ** nutscan_get_serial_ports_list(const char *ports_range) /* we have a list: * - single element: X (digit) or port name (COM1, /dev/ttyS0, ...) * - range list: X-Y - * - multiple elements (coma separated): /dev/ttyS0,/dev/ttyUSB0 */ - if ( (list_sep_ptr = strchr(range, '-')) != NULL ) { - tok = strtok_r(range,"-",&saveptr); - if( tok[1] != 0 ) { - fprintf(stderr,ERR_OUT_OF_BOUND); + * - multiple elements (comma separated): /dev/ttyS0,/dev/ttyUSB0 */ + if ((list_sep_ptr = strchr(range, '-')) != NULL) { + tok = strtok_r(range, "-", &saveptr); + if (tok[1] != 0) { + fprintf(stderr, ERR_OUT_OF_BOUND); free(range); return NULL; } start_port = tok[0]; - tok = strtok_r(NULL,"-",&saveptr); - if( tok != NULL ) { - if( tok[1] != 0 ) { - fprintf(stderr,ERR_OUT_OF_BOUND); + tok = strtok_r(NULL, "-", &saveptr); + if (tok != NULL) { + if (tok[1] != 0) { + fprintf(stderr, ERR_OUT_OF_BOUND); free(range); return NULL; } @@ -157,19 +161,20 @@ char ** nutscan_get_serial_ports_list(const char *ports_range) stop_port = start_port; } } - else if ( ((list_sep_ptr = strchr(ports_range, ',')) != NULL ) - && (is_serial_port_path(ports_range)) ) { - tok = strtok_r(range,",",&saveptr); - while( tok != NULL ) { - ports_list = add_port(ports_list,tok); - tok = strtok_r(NULL,",",&saveptr); + else if (((list_sep_ptr = strchr(ports_range, ',')) != NULL) + && (is_serial_port_path(ports_range)) + ) { + tok = strtok_r(range, ",", &saveptr); + while (tok != NULL) { + ports_list = add_port(ports_list, tok); + tok = strtok_r(NULL, ",", &saveptr); } } else { /* we have been provided a single port name */ /* it's a full device name */ - if( ports_range[1] != 0 ) { - ports_list = add_port(ports_list,range); + if (ports_range[1] != 0) { + ports_list = add_port(ports_list, range); } /* it's device number */ else { @@ -179,21 +184,35 @@ char ** nutscan_get_serial_ports_list(const char *ports_range) free(range); } - - if( start_port == 0 && !flag_auto) { + if (start_port == 0 && !flag_auto) { return ports_list; } - for (cur_device=device_portname;cur_device->name!= NULL;cur_device++) { - if( flag_auto ) { + for (cur_device = device_portname; cur_device->name != NULL; cur_device++) { + if (flag_auto) { start_port = cur_device->auto_start_port; stop_port = cur_device->auto_stop_port; } - for( current_port=start_port; current_port <= stop_port; - current_port++){ - snprintf(str_tmp, sizeof(str_tmp),cur_device->name, + for (current_port = start_port; current_port <= stop_port; + current_port++) { +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_SECURITY +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + /* We actually have a format string in the name, + * see the device_portname[] definition above */ + snprintf(str_tmp, sizeof(str_tmp), cur_device->name, current_port); - ports_list = add_port(ports_list,str_tmp); +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_FORMAT_NONLITERAL +#pragma GCC diagnostic pop +#endif + + ports_list = add_port(ports_list, str_tmp); } } return ports_list; diff --git a/tools/nut-scanner/nutscan-snmp.h b/tools/nut-scanner/nutscan-snmp.h index f6aa512..660994b 100644 --- a/tools/nut-scanner/nutscan-snmp.h +++ b/tools/nut-scanner/nutscan-snmp.h @@ -1,6 +1,7 @@ -/* nutscan-snmp - * Copyright (C) 2011 - Frederic Bohe - * Copyright (C) 2016 - Arnaud Quette +/* nutscan-snmp.h - fully generated during build of NUT + * Copyright (C) 2011-2019 EATON + * Authors: Frederic Bohe + * Arnaud Quette * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,36 +22,44 @@ #define DEVSCAN_SNMP_H typedef struct { - char * oid; - char * mib; - char * sysoid; + char * oid; + char * mib; + char * sysoid; } snmp_device_id_t; /* SNMP IDs device table */ static snmp_device_id_t snmp_device_table[] = { - { "", "apc_ats", ".1.3.6.1.4.1.318.1.3.11"}, - { ".1.3.6.1.4.1.534.10.2.1.2.0", "eaton_ats", ".1.3.6.1.4.1.705.1"}, - { ".1.3.6.1.4.1.13742.1.1.12.0", "raritan", ".1.3.6.1.4.1.13742"}, - { "", "xppc", ".1.3.6.1.4.1.935"}, - { "1.3.6.1.4.1.534.1.1.2.0", "pw", ".1.3.6.1.4.1.534.1"}, - { "1.3.6.1.4.1.534.1.1.2.0", "pxgx_ups", ".1.3.6.1.4.1.534.2.12"}, - { "1.3.6.1.2.1.33.1.1.1.0", "ietf", ".1.3.6.1.2.1.33"}, - { "", "ietf", ".1.3.6.1.4.1.850.1"}, - { ".1.3.6.1.4.1.232.165.3.1.1.0", "cpqpower", ".1.3.6.1.4.1.232.165.3"}, - { ".1.3.6.1.4.1.17373.3.1.1.0", "aphel_genesisII", ".1.3.6.1.4.1.17373"}, - { ".1.3.6.1.4.1.534.6.6.6.1.1.12.0", "aphel_revelation", ".1.3.6.1.4.1.534.6.6.6"}, - { ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.0", "eaton_epdu", ".1.3.6.1.4.1.534.6.6.7"}, - { ".1.3.6.1.4.1.20677.1", "pulizzi_switched1", ".1.3.6.1.4.1.20677.1"}, - { ".1.3.6.1.4.1.20677.1", "pulizzi_switched2", ".1.3.6.1.4.1.20677.2"}, - { ".1.3.6.1.4.1.3808.1.1.1.1.1.1.0", "cyberpower", ".1.3.6.1.4.1.3808"}, - { ".1.3.6.1.4.1.705.1.1.1.0", "mge", ".1.3.6.1.4.1.705.1"}, - { "", "delta_ups", ".1.3.6.1.4.1.2254.2.4"}, - { "", "huawei", ".1.3.6.1.4.1.8072.3.2.10"}, - { ".1.3.6.1.4.1.4555.1.1.1.1.1.1.0", "netvision", ".1.3.6.1.4.1.4555.1.1.1"}, - { ".1.3.6.1.4.1.318.1.1.1.1.1.1.0", "apcc", NULL}, - { ".1.3.6.1.4.1.4779.1.3.5.2.1.24.1", "baytech", NULL}, - { ".1.3.6.1.4.1.2947.1.1.2.0", "bestpower", NULL}, - /* Terminating entry */ - { NULL, NULL, NULL} + { ".1.3.6.1.4.1.318.1.1.8.1.5.0", "apc_ats", ".1.3.6.1.4.1.318.1.3.11" }, + { ".1.3.6.1.4.1.318.1.1.1.1.1.1.0", "apcc", ".1.3.6.1.4.1.318.1.1.1.1.1.1.0" }, + { ".1.3.6.1.4.1.318.1.1.4.1.4.0", "apc_pdu", ".1.3.6.1.4.1.318.1.3.4.4.1.3.6.1.4.1.318.1.3.4.5" }, + { ".1.3.6.1.4.1.318.1.1.4.1.4.0", "apc_pdu", ".1.3.6.1.4.1.318.1.3.4.5" }, + { ".1.3.6.1.4.1.318.1.1.4.1.4.0", "apc_pdu", ".1.3.6.1.4.1.318.1.3.4.6" }, + { ".1.3.6.1.4.1.4779.1.3.5.2.1.24.1", "baytech", ".1.3.6.1.4.1.4779" }, + { ".1.3.6.1.4.1.2947.1.1.2.0", "bestpower", ".1.3.6.1.4.1.2947.1.1.2.0" }, + { ".1.3.6.1.4.1.232.165.3.1.1.0", "cpqpower", ".1.3.6.1.4.1.232.165.3" }, + { ".1.3.6.1.4.1.3808.1.1.1.1.1.1.0", "cyberpower", ".1.3.6.1.4.1.3808.1.1.1" }, + { NULL, "delta_ups", ".1.3.6.1.4.1.2254.2.4" }, + { ".1.3.6.1.4.1.534.10.2.1.2.0", "eaton_ats16_nm2", ".1.3.6.1.4.1.534.10.2" }, + { ".1.3.6.1.4.1.534.10.2.1.2.0", "eaton_ats16_nmc", ".1.3.6.1.4.1.705.1" }, + { ".1.3.6.1.4.1.534.10.1.2.1.0", "eaton_ats30", ".1.3.6.1.4.1.534.10.1" }, + { ".1.3.6.1.4.1.17373.3.1.1.0", "aphel_genesisII", ".1.3.6.1.4.1.17373" }, + { ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.0", "eaton_epdu", ".1.3.6.1.4.1.534.6.6.7" }, + { ".1.3.6.1.4.1.20677.1", "pulizzi_switched1", ".1.3.6.1.4.1.20677.1" }, + { ".1.3.6.1.4.1.20677.1", "pulizzi_switched2", ".1.3.6.1.4.1.20677.2" }, + { ".1.3.6.1.4.1.534.6.6.6.1.1.12.0", "aphel_revelation", ".1.3.6.1.4.1.534.6.6.6" }, + { ".1.3.6.1.4.1.10418.17.2.1.2.0", "emerson_avocent_pdu", ".1.3.6.1.4.1.10418.17.1.7" }, + { ".1.3.6.1.4.1.232.165.7.1.2.1.3.0", "hpe_epdu", ".1.3.6.1.4.1.232.165.7" }, + { ".1.3.6.1.4.1.2011.6.174.1.2.100.1.2.1", "huawei", ".1.3.6.1.4.1.8072.3.2.10" }, + { NULL, "tripplite", ".1.3.6.1.4.1.850.1" }, + { "1.3.6.1.2.1.33.1.1.1.0", "ietf", ".1.3.6.1.2.1.33" }, + { ".1.3.6.1.4.1.705.1.1.1.0", "mge", ".1.3.6.1.4.1.705.1" }, + { ".1.3.6.1.4.1.4555.1.1.1.1.1.1.0", "netvision", ".1.3.6.1.4.1.4555.1.1.1" }, + { "1.3.6.1.4.1.534.1.1.2.0", "pw", ".1.3.6.1.4.1.534.1" }, + { "1.3.6.1.4.1.534.1.1.2.0", "pxgx_ups", ".1.3.6.1.4.1.534.2.12" }, + { ".1.3.6.1.4.1.13742.1.1.12.0", "raritan", ".1.3.6.1.4.1.13742" }, + { ".1.3.6.1.4.1.13742.6.3.2.1.1.3.1", "raritan-px2", ".1.3.6.1.4.1.13742.6" }, + { NULL, "xppc", ".1.3.6.1.4.1.935" }, + /* Terminating entry */ + { NULL, NULL, NULL } }; #endif /* DEVSCAN_SNMP_H */ diff --git a/tools/nut-scanner/nutscan-usb.h b/tools/nut-scanner/nutscan-usb.h index c0c1200..072c6a7 100644 --- a/tools/nut-scanner/nutscan-usb.h +++ b/tools/nut-scanner/nutscan-usb.h @@ -19,9 +19,29 @@ #ifndef DEVSCAN_USB_H #define DEVSCAN_USB_H -#include -#include "nut_stdint.h" /* for uint16_t */ +#include "nut_stdint.h" /* for uint16_t etc. */ +#include /* for PATH_MAX in usb.h etc. */ + +#include /* for MAXPATHLEN etc. */ + +/* libusb header file */ +#if (!WITH_LIBUSB_1_0) && (!WITH_LIBUSB_0_1) +#error "configure script error: Neither WITH_LIBUSB_1_0 nor WITH_LIBUSB_0_1 is set" +#endif + +#if (WITH_LIBUSB_1_0) && (WITH_LIBUSB_0_1) +#error "configure script error: Both WITH_LIBUSB_1_0 and WITH_LIBUSB_0_1 are set" +#endif + +#if WITH_LIBUSB_1_0 + #include +#endif +#if WITH_LIBUSB_0_1 + #include + /* simple remap to avoid bloating structures */ + typedef usb_dev_handle libusb_device_handle; +#endif typedef struct { uint16_t vendorID; uint16_t productID; @@ -31,7 +51,7 @@ typedef struct { /* USB IDs device table */ static usb_device_id_t usb_device_table[] = { - { 0x0001, 0x0000, "nutdrv_atcl_usb" }, + { 0x0001, 0x0000, "nutdrv_qx" }, { 0x03f0, 0x0001, "usbhid-ups" }, { 0x03f0, 0x1f01, "bcmxcp_usb" }, { 0x03f0, 0x1f02, "bcmxcp_usb" }, @@ -51,6 +71,8 @@ static usb_device_id_t usb_device_table[] = { { 0x0463, 0xffff, "usbhid-ups" }, { 0x047c, 0xffff, "usbhid-ups" }, { 0x0483, 0x0035, "nutdrv_qx" }, + { 0x0483, 0xa113, "usbhid-ups" }, + { 0x04b3, 0x0001, "usbhid-ups" }, { 0x04b4, 0x5500, "riello_usb" }, { 0x04d8, 0xd004, "usbhid-ups" }, { 0x04d8, 0xd005, "usbhid-ups" }, @@ -69,14 +91,16 @@ static usb_device_id_t usb_device_table[] = { { 0x051d, 0x0003, "usbhid-ups" }, { 0x0592, 0x0002, "bcmxcp_usb" }, { 0x0592, 0x0004, "usbhid-ups" }, - { 0x05b8, 0x0000, "blazer_usb" }, - { 0x0665, 0x5161, "blazer_usb" }, - { 0x06da, 0x0002, "bcmxcp_usb" }, - { 0x06da, 0x0003, "blazer_usb" }, - { 0x06da, 0x0004, "blazer_usb" }, - { 0x06da, 0x0005, "blazer_usb" }, - { 0x06da, 0x0201, "blazer_usb" }, - { 0x06da, 0x0601, "blazer_usb" }, + { 0x05b8, 0x0000, "nutdrv_qx" }, + { 0x05dd, 0x041b, "usbhid-ups" }, + { 0x05dd, 0xa011, "usbhid-ups" }, + { 0x0665, 0x5161, "nutdrv_qx" }, + { 0x06da, 0x0002, "nutdrv_qx" }, + { 0x06da, 0x0003, "nutdrv_qx" }, + { 0x06da, 0x0004, "nutdrv_qx" }, + { 0x06da, 0x0005, "nutdrv_qx" }, + { 0x06da, 0x0201, "nutdrv_qx" }, + { 0x06da, 0x0601, "nutdrv_qx" }, { 0x06da, 0xffff, "usbhid-ups" }, { 0x075d, 0x0300, "usbhid-ups" }, { 0x0764, 0x0005, "usbhid-ups" }, @@ -89,6 +113,7 @@ static usb_device_id_t usb_device_table[] = { { 0x09ae, 0x1008, "usbhid-ups" }, { 0x09ae, 0x1009, "usbhid-ups" }, { 0x09ae, 0x1010, "usbhid-ups" }, + { 0x09ae, 0x1330, "usbhid-ups" }, { 0x09ae, 0x2005, "usbhid-ups" }, { 0x09ae, 0x2007, "usbhid-ups" }, { 0x09ae, 0x2008, "usbhid-ups" }, @@ -107,6 +132,7 @@ static usb_device_id_t usb_device_table[] = { { 0x09ae, 0x3014, "usbhid-ups" }, { 0x09ae, 0x3015, "usbhid-ups" }, { 0x09ae, 0x3016, "usbhid-ups" }, + { 0x09ae, 0x3024, "usbhid-ups" }, { 0x09ae, 0x4001, "usbhid-ups" }, { 0x09ae, 0x4002, "usbhid-ups" }, { 0x09ae, 0x4003, "usbhid-ups" }, @@ -122,15 +148,32 @@ static usb_device_id_t usb_device_table[] = { { 0x0d9f, 0x00a4, "usbhid-ups" }, { 0x0d9f, 0x00a5, "usbhid-ups" }, { 0x0d9f, 0x00a6, "usbhid-ups" }, - { 0x0f03, 0x0001, "blazer_usb" }, + { 0x0f03, 0x0001, "nutdrv_qx" }, { 0x10af, 0x0001, "usbhid-ups" }, { 0x10af, 0x0004, "usbhid-ups" }, { 0x10af, 0x0008, "usbhid-ups" }, - { 0x14f0, 0x00c9, "blazer_usb" }, + { 0x14f0, 0x00c9, "nutdrv_qx" }, + { 0x1cb0, 0x0032, "usbhid-ups" }, + { 0x1cb0, 0x0035, "nutdrv_qx" }, + { 0x1cb0, 0x0038, "usbhid-ups" }, + { 0x2341, 0x0036, "usbhid-ups" }, + { 0x2341, 0x8036, "usbhid-ups" }, + { 0x2A03, 0x0036, "usbhid-ups" }, + { 0x2A03, 0x0040, "usbhid-ups" }, + { 0x2A03, 0x8036, "usbhid-ups" }, + { 0x2A03, 0x8040, "usbhid-ups" }, { 0x2b2d, 0xffff, "usbhid-ups" }, - { 0xffff, 0x0000, "blazer_usb" }, + { 0x2e51, 0x0000, "usbhid-ups" }, + { 0x2e51, 0xffff, "usbhid-ups" }, + { 0x2e66, 0x0201, "usbhid-ups" }, + { 0x2e66, 0x0202, "usbhid-ups" }, + { 0x2e66, 0x0203, "usbhid-ups" }, + { 0x2e66, 0x0300, "usbhid-ups" }, + { 0x4234, 0x0002, "usbhid-ups" }, + { 0xffff, 0x0000, "nutdrv_qx" }, + /* Terminating entry */ - { -1, -1, NULL } + { 0, 0, NULL } }; #endif /* DEVSCAN_USB_H */ diff --git a/tools/nut-scanner/scan_avahi.c b/tools/nut-scanner/scan_avahi.c index ec3beb8..67530a7 100644 --- a/tools/nut-scanner/scan_avahi.c +++ b/tools/nut-scanner/scan_avahi.c @@ -86,13 +86,14 @@ static int (*nut_avahi_service_browser_free)(AvahiServiceBrowser *); static char * (*nut_avahi_address_snprint)(char *ret_s, size_t length, const AvahiAddress *a); static const AvahiPoll* (*nut_avahi_simple_poll_get)(AvahiSimplePoll *s); -/* return 0 on error */ +/* return 0 on error; visible externally */ +int nutscan_load_avahi_library(const char *libname_path); int nutscan_load_avahi_library(const char *libname_path) { - if( dl_handle != NULL ) { + if (dl_handle != NULL) { /* if previous init failed */ - if( dl_handle == (void *)1 ) { - return 0; + if (dl_handle == (void *)1) { + return 0; } /* init has already been done */ return 1; @@ -103,7 +104,7 @@ int nutscan_load_avahi_library(const char *libname_path) return 0; } - if( lt_dlinit() != 0 ) { + if (lt_dlinit() != 0) { fprintf(stderr, "Error initializing lt_init\n"); return 0; } @@ -115,98 +116,100 @@ int nutscan_load_avahi_library(const char *libname_path) } lt_dlerror(); /* Clear any existing error */ *(void **) (&nut_avahi_service_browser_get_client) = lt_dlsym(dl_handle, "avahi_service_browser_get_client"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_avahi_simple_poll_loop) = lt_dlsym(dl_handle, "avahi_simple_poll_loop"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_avahi_client_free) = lt_dlsym(dl_handle, "avahi_client_free"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_avahi_client_errno) = lt_dlsym(dl_handle, "avahi_client_errno"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_avahi_free) = lt_dlsym(dl_handle, "avahi_free"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_avahi_simple_poll_quit) = lt_dlsym(dl_handle, "avahi_simple_poll_quit"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_avahi_client_new) = lt_dlsym(dl_handle, "avahi_client_new"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_avahi_simple_poll_free) = lt_dlsym(dl_handle, "avahi_simple_poll_free"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_avahi_service_resolver_new) = lt_dlsym(dl_handle, "avahi_service_resolver_new"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_avahi_strerror) = lt_dlsym(dl_handle, "avahi_strerror"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_avahi_service_resolver_get_client) = lt_dlsym(dl_handle, "avahi_service_resolver_get_client"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_avahi_service_browser_new) = lt_dlsym(dl_handle, "avahi_service_browser_new"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_avahi_service_resolver_free) = lt_dlsym(dl_handle, "avahi_service_resolver_free"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_avahi_simple_poll_new) = lt_dlsym(dl_handle, "avahi_simple_poll_new"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_avahi_string_list_to_string) = lt_dlsym(dl_handle, "avahi_string_list_to_string"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_avahi_service_browser_free) = lt_dlsym(dl_handle, "avahi_service_browser_free"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_avahi_address_snprint) = lt_dlsym(dl_handle, "avahi_address_snprint"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_avahi_simple_poll_get) = lt_dlsym(dl_handle, "avahi_simple_poll_get"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } return 1; err: - fprintf(stderr, "Cannot load AVAHI library (%s) : %s. AVAHI search disabled.\n", libname_path, dl_error); + fprintf(stderr, + "Cannot load AVAHI library (%s) : %s. AVAHI search disabled.\n", + libname_path, dl_error); dl_handle = (void *)1; lt_dlexit(); return 0; @@ -215,9 +218,9 @@ err: static AvahiSimplePoll *simple_poll = NULL; static nutscan_device_t * dev_ret = NULL; -static long avahi_usec_timeout = 0; +static useconds_t avahi_usec_timeout = 0; -static void update_device(const char * host_name,const char *ip, uint16_t port,char * text, int proto) +static void update_device(const char * host_name, const char *ip, uint16_t port, char * text, int proto) { nutscan_device_t * dev = NULL; @@ -231,113 +234,114 @@ static void update_device(const char * host_name,const char *ip, uint16_t port,c char * device_saveptr = NULL; int device_found = 0; char buf[6]; - int buf_size; + size_t buf_size; - if( text == NULL ) { + if (text == NULL) { return; } t = strdup(text); - phrase = strtok_r(t,"\"",&t_saveptr); - while(phrase != NULL ) { - word = strtok_r(phrase,"=",&phrase_saveptr); - if( word == NULL ) { - phrase = strtok_r(NULL,"\"",&t_saveptr); + phrase = strtok_r(t, "\"", &t_saveptr); + while (phrase != NULL) { + word = strtok_r(phrase, "=", &phrase_saveptr); + if (word == NULL) { + phrase = strtok_r(NULL, "\"", &t_saveptr); continue; } - value = strtok_r(NULL,"=",&phrase_saveptr); - if( value == NULL ) { - phrase = strtok_r(NULL,"\"",&t_saveptr); + value = strtok_r(NULL, "=", &phrase_saveptr); + if (value == NULL) { + phrase = strtok_r(NULL, "\"", &t_saveptr); continue; } - if( strcmp(word,"device_list") != 0 ) { - phrase = strtok_r(NULL,"\"",&t_saveptr); + if (strcmp(word, "device_list") != 0) { + phrase = strtok_r(NULL, "\"", &t_saveptr); continue; } - device = strtok_r(value,";",&device_saveptr); - while( device != NULL ) { + device = strtok_r(value, ";", &device_saveptr); + while (device != NULL) { device_found = 1; dev = nutscan_new_device(); dev->type = TYPE_NUT; dev->driver = strdup("nutclient"); - if( proto == AVAHI_PROTO_INET) { - nutscan_add_option_to_device(dev,"desc","IPv4"); + if (proto == AVAHI_PROTO_INET) { + nutscan_add_option_to_device(dev, "desc", "IPv4"); } - if( proto == AVAHI_PROTO_INET6 ) { - nutscan_add_option_to_device(dev,"desc","IPv6"); + if (proto == AVAHI_PROTO_INET6) { + nutscan_add_option_to_device(dev, "desc", "IPv6"); } - if( port != PORT) { - /* +5+1+1+1 is for : + if (port != PORT) { + /* +5+1+1+1 is for : - port number (max 65535 so 5 characters), - '@' and ':' characters - terminating 0 */ - buf_size = strlen(device)+strlen(host_name)+ - 5+1+1+1; - dev->port=malloc(buf_size); - if(dev->port) { - snprintf(dev->port,buf_size,"%s@%s:%u", - device,host_name,port); + buf_size = strlen(device) + + strlen(host_name) + + 5 + 1 + 1 + 1; + dev->port = malloc(buf_size); + if (dev->port) { + snprintf(dev->port, buf_size, "%s@%s:%u", + device, host_name, port); } } else { /*+1+1 is for '@' character and terminating 0 */ - buf_size = strlen(device)+strlen(host_name)+1+1; - dev->port=malloc(buf_size); - if(dev->port) { - snprintf(dev->port,buf_size,"%s@%s", - device,host_name); + buf_size = strlen(device) + strlen(host_name) + 1 + 1; + dev->port = malloc(buf_size); + if (dev->port) { + snprintf(dev->port, buf_size, "%s@%s", + device, host_name); } } - if( dev->port ) { - dev_ret = nutscan_add_device_to_device(dev_ret,dev); + if (dev->port) { + dev_ret = nutscan_add_device_to_device(dev_ret, dev); } else { nutscan_free_device(dev); } - device = strtok_r(NULL,";",&device_saveptr); - }; + device = strtok_r(NULL, ";", &device_saveptr); + } - phrase = strtok_r(NULL,"\"",&t_saveptr); - }; + phrase = strtok_r(NULL, "\"", &t_saveptr); + } free(t); /* If no device published in avahi data, try to get the device by connecting directly to upsd */ - if( !device_found) { - snprintf(buf,sizeof(buf),"%u",port); - dev = nutscan_scan_nut(ip,ip,buf,avahi_usec_timeout); - if(dev) { - dev_ret = nutscan_add_device_to_device(dev_ret,dev); + if (!device_found) { + snprintf(buf, sizeof(buf), "%u", port); + dev = nutscan_scan_nut(ip, ip, buf, avahi_usec_timeout); + if (dev) { + dev_ret = nutscan_add_device_to_device(dev_ret, dev); } /* add an upsd entry without associated device */ else { dev = nutscan_new_device(); dev->type = TYPE_NUT; dev->driver = strdup("nutclient"); - if( proto == AVAHI_PROTO_INET) { - nutscan_add_option_to_device(dev,"desc","IPv4"); + if (proto == AVAHI_PROTO_INET) { + nutscan_add_option_to_device(dev, "desc", "IPv4"); } - if( proto == AVAHI_PROTO_INET6 ) { - nutscan_add_option_to_device(dev,"desc","IPv6"); + if (proto == AVAHI_PROTO_INET6) { + nutscan_add_option_to_device(dev, "desc", "IPv6"); } - if( port != PORT) { + if (port != PORT) { /*+1+1 is for ':' character and terminating 0 */ /*buf is the string containing the port number*/ - buf_size = strlen(host_name)+strlen(buf)+1+1; - dev->port=malloc(buf_size); - if(dev->port) { - snprintf(dev->port,buf_size,"%s:%s", - host_name,buf); + buf_size = strlen(host_name) + strlen(buf) + 1 + 1; + dev->port = malloc(buf_size); + if (dev->port) { + snprintf(dev->port, buf_size, "%s:%s", + host_name, buf); } } else { - dev->port=strdup(host_name); + dev->port = strdup(host_name); } - if( dev->port ) { - dev_ret = nutscan_add_device_to_device(dev_ret,dev); + if (dev->port) { + dev_ret = nutscan_add_device_to_device(dev_ret, dev); } else { nutscan_free_device(dev); @@ -348,8 +352,8 @@ static void update_device(const char * host_name,const char *ip, uint16_t port,c static void resolve_callback( AvahiServiceResolver *r, - AVAHI_GCC_UNUSED AvahiIfIndex interface, - AVAHI_GCC_UNUSED AvahiProtocol protocol, + AvahiIfIndex interface, + AvahiProtocol protocol, AvahiResolverEvent event, const char *name, const char *type, @@ -359,15 +363,23 @@ static void resolve_callback( uint16_t port, AvahiStringList *txt, AvahiLookupResultFlags flags, - AVAHI_GCC_UNUSED void* userdata) { + void* userdata) +{ assert(r); + NUT_UNUSED_VARIABLE(interface); + NUT_UNUSED_VARIABLE(protocol); + NUT_UNUSED_VARIABLE(userdata); + /* Called whenever a service has been resolved successfully or timed out */ switch (event) { case AVAHI_RESOLVER_FAILURE: - fprintf(stderr, "(Resolver) Failed to resolve service '%s' of type '%s' in domain '%s': %s\n", name, type, domain, (*nut_avahi_strerror)((*nut_avahi_client_errno)((*nut_avahi_service_resolver_get_client)(r)))); + fprintf(stderr, + "(Resolver) Failed to resolve service '%s' of type '%s' in domain '%s': %s\n", + name, type, domain, + (*nut_avahi_strerror)((*nut_avahi_client_errno)((*nut_avahi_service_resolver_get_client)(r)))); break; case AVAHI_RESOLVER_FOUND: { @@ -377,6 +389,8 @@ static void resolve_callback( (*nut_avahi_address_snprint)(a, sizeof(a), address); t = (*nut_avahi_string_list_to_string)(txt); + + NUT_UNUSED_VARIABLE(flags); /* fprintf(stderr, "\t%s:%u (%s)\n" @@ -396,7 +410,7 @@ static void resolve_callback( !!(flags & AVAHI_LOOKUP_RESULT_MULTICAST), !!(flags & AVAHI_LOOKUP_RESULT_CACHED)); */ - update_device(host_name,a,port,t,address->proto); + update_device(host_name, a, port, t, address->proto); (*nut_avahi_free)(t); } } @@ -412,18 +426,23 @@ static void browse_callback( const char *name, const char *type, const char *domain, - AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, - void* userdata) { + AvahiLookupResultFlags flags, + void* userdata) +{ AvahiClient *c = userdata; assert(b); + NUT_UNUSED_VARIABLE(flags); + /* Called whenever a new services becomes available on the LAN or is removed from the LAN */ switch (event) { case AVAHI_BROWSER_FAILURE: - fprintf(stderr, "(Browser) %s\n", (*nut_avahi_strerror)((*nut_avahi_client_errno)((*nut_avahi_service_browser_get_client)(b)))); + fprintf(stderr, + "(Browser) %s\n", + (*nut_avahi_strerror)((*nut_avahi_client_errno)((*nut_avahi_service_browser_get_client)(b)))); (*nut_avahi_simple_poll_quit)(simple_poll); return; @@ -435,8 +454,22 @@ static void browse_callback( the callback function is called the server will free the resolver for us. */ +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ASSIGN_ENUM) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wassign-enum" +#endif + /* It seems that avahi-common/defs.h only defines the flags in a + * manner similar to bitmask flags to request certain features, + * but lacks a value in that enum for lack of flags (unconstrained + * lookup). So we have to silence a warning here... + */ if (!((*nut_avahi_service_resolver_new)(c, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0, resolve_callback, c))) - fprintf(stderr, "Failed to resolve service '%s': %s\n", name, (*nut_avahi_strerror)((*nut_avahi_client_errno)(c))); +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ASSIGN_ENUM) +# pragma GCC diagnostic pop +#endif + fprintf(stderr, + "Failed to resolve service '%s': %s\n", + name, (*nut_avahi_strerror)((*nut_avahi_client_errno)(c))); break; @@ -446,33 +479,39 @@ static void browse_callback( case AVAHI_BROWSER_ALL_FOR_NOW: (*nut_avahi_simple_poll_quit)(simple_poll); + goto fallthrough_AVAHI_BROWSER_CACHE_EXHAUSTED; /* be explicit */ + case AVAHI_BROWSER_CACHE_EXHAUSTED: + fallthrough_AVAHI_BROWSER_CACHE_EXHAUSTED: /* fprintf(stderr, "(Browser) %s\n", event == AVAHI_BROWSER_CACHE_EXHAUSTED ? "CACHE_EXHAUSTED" : "ALL_FOR_NOW"); */ break; } } -static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata) { +static void client_callback(AvahiClient *c, AvahiClientState state, void * userdata) { assert(c); + NUT_UNUSED_VARIABLE(userdata); /* Called whenever the client or server state changes */ if (state == AVAHI_CLIENT_FAILURE) { - fprintf(stderr, "Server connection failure: %s\n", (*nut_avahi_strerror)((*nut_avahi_client_errno)(c))); + fprintf(stderr, + "Server connection failure: %s\n", + (*nut_avahi_strerror)((*nut_avahi_client_errno)(c))); (*nut_avahi_simple_poll_quit)(simple_poll); } } -nutscan_device_t * nutscan_scan_avahi(long usec_timeout) +nutscan_device_t * nutscan_scan_avahi(useconds_t usec_timeout) { - /* Example service publication + /* Example service publication * $ avahi-publish -s nut _upsd._tcp 3493 txtvers=1 protovers=1.0.0 device_list="dev1;dev2" */ AvahiClient *client = NULL; AvahiServiceBrowser *sb = NULL; int error; - if( !nutscan_avail_avahi ) { + if (!nutscan_avail_avahi) { return NULL; } @@ -485,17 +524,44 @@ nutscan_device_t * nutscan_scan_avahi(long usec_timeout) } /* Allocate a new client */ +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ASSIGN_ENUM) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wassign-enum" +#endif + /* It seems that avahi-common/defs.h only defines the flags in a + * manner similar to bitmask flags to request certain features, + * but lacks a value in that enum for lack of flags (unconstrained + * lookup). So we have to silence a warning here... + */ client = (*nut_avahi_client_new)((*nut_avahi_simple_poll_get)(simple_poll), 0, client_callback, NULL, &error); +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ASSIGN_ENUM) +# pragma GCC diagnostic pop +#endif /* Check wether creating the client object succeeded */ if (!client) { - fprintf(stderr, "Failed to create client: %s\n", (*nut_avahi_strerror)(error)); + fprintf(stderr, + "Failed to create client: %s\n", + (*nut_avahi_strerror)(error)); goto fail; } /* Create the service browser */ - if (!(sb = (*nut_avahi_service_browser_new)(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_upsd._tcp", NULL, 0, browse_callback, client))) { - fprintf(stderr, "Failed to create service browser: %s\n", (*nut_avahi_strerror)((*nut_avahi_client_errno)(client))); +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ASSIGN_ENUM) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wassign-enum" +#endif + /* See comments about flags just a bit above */ + if (!(sb = (*nut_avahi_service_browser_new)( + client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, + "_upsd._tcp", NULL, 0, browse_callback, client)) + ) { +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_ASSIGN_ENUM) +# pragma GCC diagnostic pop +#endif + fprintf(stderr, + "Failed to create service browser: %s\n", + (*nut_avahi_strerror)((*nut_avahi_client_errno)(client))); goto fail; } @@ -518,8 +584,10 @@ fail: } #else /* WITH_AVAHI */ /* stub function */ -nutscan_device_t * nutscan_scan_avahi(long usec_timeout) +nutscan_device_t * nutscan_scan_avahi(useconds_t usec_timeout) { + NUT_UNUSED_VARIABLE(usec_timeout); + return NULL; } #endif /* WITH_AVAHI */ diff --git a/tools/nut-scanner/scan_eaton_serial.c b/tools/nut-scanner/scan_eaton_serial.c index 84baeeb..4b16311 100644 --- a/tools/nut-scanner/scan_eaton_serial.c +++ b/tools/nut-scanner/scan_eaton_serial.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2012 - EATON + * Copyright (C) 2016-2021 - EATON - Various threads-related improvements * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,9 +20,11 @@ /*! \file scan_eaton_serial.c \brief detect Eaton serial XCP, SHUT and Q1 devices \author Arnaud Quette + \author Jim Klimov */ #include "common.h" +#include "nut-scan.h" /* Need this on AIX when using xlc to get alloca */ #ifdef _AIX @@ -30,36 +33,50 @@ #include #include -#include +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wstrict-prototypes" +#endif +#ifdef HAVE_SYS_SIGNAL_H +# include +#endif +#ifdef HAVE_SIGNAL_H +# include +#endif +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES) +# pragma GCC diagnostic pop +#endif #include #include #include -#include "nut-scan.h" #include "serial.h" #include "bcmxcp_io.h" +#include "bcmxcp_ser.h" #include "bcmxcp.h" #include "nutscan-serial.h" -#ifdef HAVE_PTHREAD -#include -#endif - /* SHUT header */ #define SHUT_SYNC 0x16 #define MAX_TRY 4 -/* BCMXCP header */ -extern unsigned char AUT[4]; +/* BCMXCP header defines these externs now: */ +/* +extern unsigned char BCMXCP_AUTHCMD[4]; extern struct pw_baud_rate { - int rate; - int name; + int rate; + int name; } pw_baud_rates[]; +*/ /* Local list of found devices */ static nutscan_device_t * dev_ret = NULL; /* Remap some functions to avoid undesired behavior (drivers/main.c) */ -char *getval(const char *var) { return NULL; } +char *getval(const char *var) +{ + NUT_UNUSED_VARIABLE(var); + return NULL; +} #ifdef HAVE_PTHREAD static pthread_mutex_t dev_mutex; @@ -102,7 +119,7 @@ unsigned char calc_checksum(const unsigned char *buf) int i; c = 0; - for(i = 0; i < 2 + buf[1]; i++) + for (i = 0; i < 2 + buf[1]; i++) c -= buf[i]; return c; @@ -114,18 +131,22 @@ unsigned char calc_checksum(const unsigned char *buf) /* Light version of of drivers/libshut.c->shut_synchronise() * return 1 if OK, 0 otherwise */ -int shut_synchronise(int upsfd) +static int shut_synchronise(int arg_upsfd) { int try; - u_char reply = '\0'; + unsigned char reply = '\0'; + /* FIXME? Should we save "arg_upsfd" into global "upsfd" variable? + * This was previously shadowed by function argument named "upsfd"... + */ + /* upsfd = arg_upsfd; */ /* Sync with the UPS according to notification */ for (try = 0; try < MAX_TRY; try++) { - if ((ser_send_char(upsfd, SHUT_SYNC)) == -1) { + if ((ser_send_char(arg_upsfd, SHUT_SYNC)) == -1) { continue; } - ser_get_char(upsfd, &reply, 1, 0); + ser_get_char(arg_upsfd, &reply, 1, 0); if (reply == SHUT_SYNC) { return 1; } @@ -137,12 +158,12 @@ int shut_synchronise(int upsfd) * send SYNC token (0x16) and receive the SYNC token back * FIXME: maybe try to get device descriptor?! */ -nutscan_device_t * nutscan_scan_eaton_serial_shut(const char* port_name) +static nutscan_device_t * nutscan_scan_eaton_serial_shut(const char* port_name) { nutscan_device_t * dev = NULL; int devfd = -1; - if ( (devfd = ser_open_nf(port_name)) != -1 ) { + if ((devfd = ser_open_nf(port_name)) != -1) { /* set RTS to off and DTR to on to allow correct behavior * with UPS using PnP feature */ if (ser_set_dtr(devfd, 1) != -1) { @@ -186,16 +207,17 @@ nutscan_device_t * nutscan_scan_eaton_serial_shut(const char* port_name) * Send PW_SET_REQ_ONLY_MODE command (0xA0) and wait for response * [Get ID Block (PW_ID_BLOCK_REQ) (0x31)] */ -nutscan_device_t * nutscan_scan_eaton_serial_xcp(const char* port_name) +static nutscan_device_t * nutscan_scan_eaton_serial_xcp(const char* port_name) { nutscan_device_t * dev = NULL; - int i, ret, devfd = -1; + int i, devfd = -1; + ssize_t ret; unsigned char answer[256]; unsigned char sbuf[128]; memset(sbuf, 0, 128); - if ( (devfd = ser_open_nf(port_name)) != -1 ) { + if ((devfd = ser_open_nf(port_name)) != -1) { #ifdef HAVE_PTHREAD pthread_mutex_lock(&dev_mutex); #endif @@ -204,7 +226,7 @@ nutscan_device_t * nutscan_scan_eaton_serial_xcp(const char* port_name) pthread_mutex_unlock(&dev_mutex); #endif - for (i=0; (pw_baud_rates[i].rate != 0) && (dev == NULL); i++) + for (i = 0; (pw_baud_rates[i].rate != 0) && (dev == NULL); i++) { memset(answer, 0, 256); @@ -216,9 +238,9 @@ nutscan_device_t * nutscan_scan_eaton_serial_xcp(const char* port_name) break; usleep(90000); - send_write_command(AUT, 4); + send_write_command(BCMXCP_AUTHCMD, 4); usleep(500000); - + /* Discovery with Baud Hunting (XCP protocol spec. §4.1.2) * sending PW_SET_REQ_ONLY_MODE should be enough, since * the unit should send back Identification block */ @@ -240,7 +262,7 @@ nutscan_device_t * nutscan_scan_eaton_serial_xcp(const char* port_name) } #endif - if ( (ret > 0) && (answer[0] == PW_COMMAND_START_BYTE) ) { + if ((ret > 0) && (answer[0] == PW_COMMAND_START_BYTE)) { dev = nutscan_new_device(); dev->type = TYPE_EATON_SERIAL; dev->driver = strdup(XCP_DRIVER_NAME); @@ -275,15 +297,16 @@ nutscan_device_t * nutscan_scan_eaton_serial_xcp(const char* port_name) * - simply try to get Q1 (status) string * - check its size and first char. which should be '(' */ -nutscan_device_t * nutscan_scan_eaton_serial_q1(const char* port_name) +static nutscan_device_t * nutscan_scan_eaton_serial_q1(const char* port_name) { nutscan_device_t * dev = NULL; struct termios tio; - int ret = 0, retry; + ssize_t ret = 0; + int retry; int devfd = -1; char buf[128]; - if ( (devfd = ser_open_nf(port_name)) != -1 ) { + if ((devfd = ser_open_nf(port_name)) != -1) { if (ser_set_speed_nf(devfd, port_name, B2400) != -1) { if (!tcgetattr(devfd, &tio)) { @@ -318,10 +341,10 @@ nutscan_device_t * nutscan_scan_eaton_serial_q1(const char* port_name) /* simplified code */ ser_flush_io(devfd); - if ( (ret = ser_send(devfd, "Q1\r")) > 0) { + if ((ret = ser_send(devfd, "Q1\r")) > 0) { /* Get Q1 reply */ - if ( (ret = ser_get_buf(devfd, buf, sizeof(buf), SER_WAIT_SEC, 0)) > 0) { + if ((ret = ser_get_buf(devfd, buf, sizeof(buf), SER_WAIT_SEC, 0)) > 0) { /* Check answer */ /* should at least (and most) be 46 chars */ @@ -360,10 +383,10 @@ static void * nutscan_scan_eaton_serial_device(void * port_arg) char* port_name = (char*) port_arg; /* Try SHUT first */ - if ( (dev = nutscan_scan_eaton_serial_shut(port_name)) == NULL) { + if ((dev = nutscan_scan_eaton_serial_shut(port_name)) == NULL) { usleep(100000); /* Else, try XCP */ - if ( (dev = nutscan_scan_eaton_serial_xcp(port_name)) == NULL) { + if ((dev = nutscan_scan_eaton_serial_xcp(port_name)) == NULL) { /* Else, try Q1 */ usleep(100000); dev = nutscan_scan_eaton_serial_q1(port_name); @@ -375,66 +398,257 @@ static void * nutscan_scan_eaton_serial_device(void * port_arg) nutscan_device_t * nutscan_scan_eaton_serial(const char* ports_range) { + bool_t pass = TRUE; /* Track that we may spawn a scanning thread */ struct sigaction oldact; int change_action_handler = 0; char *current_port_name = NULL; char **serial_ports_list; int current_port_nb; - int i; #ifdef HAVE_PTHREAD +# ifdef HAVE_SEMAPHORE + sem_t * semaphore = nutscan_semaphore(); +# endif pthread_t thread; - pthread_t * thread_array = NULL; - int thread_count = 0; + nutscan_thread_t * thread_array = NULL; + size_t thread_count = 0, i; - pthread_mutex_init(&dev_mutex,NULL); -#endif + pthread_mutex_init(&dev_mutex, NULL); +#endif /* HAVE_PTHREAD */ /* 1) Get ports_list */ serial_ports_list = nutscan_get_serial_ports_list(ports_range); - if( serial_ports_list == NULL ) { + if (serial_ports_list == NULL) { return NULL; } /* Ignore SIGPIPE if the caller hasn't set a handler for it yet */ - if( sigaction(SIGPIPE, NULL, &oldact) == 0 ) { - if( oldact.sa_handler == SIG_DFL ) { + if (sigaction(SIGPIPE, NULL, &oldact) == 0) { +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wstrict-prototypes" +#endif + if (oldact.sa_handler == SIG_DFL) { change_action_handler = 1; - signal(SIGPIPE,SIG_IGN); + signal(SIGPIPE, SIG_IGN); } +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES) +# pragma GCC diagnostic pop +#endif } /* port(s) iterator */ current_port_nb = 0; - while(serial_ports_list[current_port_nb] != NULL) { - current_port_name = serial_ports_list[current_port_nb]; + while (serial_ports_list[current_port_nb] != NULL) { #ifdef HAVE_PTHREAD - if (pthread_create(&thread, NULL, nutscan_scan_eaton_serial_device, (void*)current_port_name) == 0){ - thread_count++; - thread_array = realloc(thread_array, - thread_count*sizeof(pthread_t)); - thread_array[thread_count-1] = thread; + /* NOTE: With many enough targets to scan, this can crash + * by spawning too many children; add a limit and loop to + * "reap" some already done with their work. And probably + * account them in thread_array[] as something to not wait + * for below in pthread_join()... + */ + +# ifdef HAVE_SEMAPHORE + /* Just wait for someone to free a semaphored slot, + * if none are available, and then/otherwise grab one + */ + if (thread_array == NULL) { + /* Starting point, or after a wait to complete + * all earlier runners */ + sem_wait(semaphore); + pass = TRUE; + } else { + pass = (sem_trywait(semaphore) == 0); } -#else - nutscan_scan_eaton_serial_device(current_port_name); -#endif - current_port_nb++; - } +# else +# ifdef HAVE_PTHREAD_TRYJOIN + /* A somewhat naive and brute-force solution for + * systems without a semaphore.h. This may suffer + * some off-by-one errors, using a few more threads + * than intended (if we race a bit at the wrong time, + * probably up to one per enabled scanner routine). + */ + + /* TOTHINK: Should there be a threadcount_mutex when + * we just read the value in if() and while() below? + * At worst we would overflow the limit a bit due to + * other protocol scanners... + */ + if (curr_threads >= max_threads) { + upsdebugx(2, "%s: already running %zu scanning threads " + "(launched overall: %zu), " + "waiting until some would finish", + __func__, curr_threads, thread_count); + while (curr_threads >= max_threads) { + for (i = 0; i < thread_count ; i++) { + int ret; + + if (!thread_array[i].active) continue; + + pthread_mutex_lock(&threadcount_mutex); + upsdebugx(3, "%s: Trying to join thread #%i...", __func__, i); + ret = pthread_tryjoin_np(thread_array[i].thread, NULL); + switch (ret) { + case ESRCH: /* No thread with the ID thread could be found - already "joined"? */ + upsdebugx(5, "%s: Was thread #%zu joined earlier?", __func__, i); + break; + case 0: /* thread exited */ + if (curr_threads > 0) { + curr_threads --; + upsdebugx(4, "%s: Joined a finished thread #%zu", __func__, i); + } else { + /* threadcount_mutex fault? */ + upsdebugx(0, "WARNING: %s: Accounting of thread count " + "says we are already at 0", __func__); + } + thread_array[i].active = FALSE; + break; + case EBUSY: /* actively running */ + upsdebugx(6, "%s: thread #%zu still busy (%i)", + __func__, i, ret); + break; + case EDEADLK: /* Errors with thread interactions... bail out? */ + case EINVAL: /* Errors with thread interactions... bail out? */ + default: /* new pthreads abilities? */ + upsdebugx(5, "%s: thread #%zu reported code %i", + __func__, i, ret); + break; + } + pthread_mutex_unlock(&threadcount_mutex); + } + + if (curr_threads >= max_threads) { + usleep (10000); /* microSec's, so 0.01s here */ + } + } + upsdebugx(2, "%s: proceeding with scan", __func__); + } + /* NOTE: No change to default "pass" in this ifdef: + * if we got to this line, we have a slot to use */ +# endif /* HAVE_PTHREAD_TRYJOIN */ +# endif /* HAVE_SEMAPHORE */ +#endif /* HAVE_PTHREAD */ + + if (pass) { + current_port_name = serial_ports_list[current_port_nb]; #ifdef HAVE_PTHREAD - for ( i = 0; i < thread_count ; i++) { - pthread_join(thread_array[i],NULL); + if (pthread_create(&thread, NULL, nutscan_scan_eaton_serial_device, (void*)current_port_name) == 0) { +# ifdef HAVE_PTHREAD_TRYJOIN + pthread_mutex_lock(&threadcount_mutex); + curr_threads++; +# endif /* HAVE_PTHREAD_TRYJOIN */ + + thread_count++; + nutscan_thread_t *new_thread_array = realloc(thread_array, + thread_count * sizeof(nutscan_thread_t)); + if (new_thread_array == NULL) { + upsdebugx(1, "%s: Failed to realloc thread array", __func__); + break; + } + else { + thread_array = new_thread_array; + } + thread_array[thread_count - 1].thread = thread; + thread_array[thread_count - 1].active = TRUE; + +# ifdef HAVE_PTHREAD_TRYJOIN + pthread_mutex_unlock(&threadcount_mutex); +# endif /* HAVE_PTHREAD_TRYJOIN */ + } +#else /* if not HAVE_PTHREAD */ + nutscan_scan_eaton_serial_device(current_port_name); +#endif /* if HAVE_PTHREAD */ + current_port_nb++; + } else { /* if not pass -- all slots busy */ +#ifdef HAVE_PTHREAD +# ifdef HAVE_SEMAPHORE + /* Wait for all current scans to complete */ + if (thread_array != NULL) { + upsdebugx (2, "%s: Running too many scanning threads, " + "waiting until older ones would finish", + __func__); + for (i = 0; i < thread_count ; i++) { + int ret; + if (!thread_array[i].active) { + /* Probably should not get here, + * but handle it just in case */ + upsdebugx(0, "WARNING: %s: Midway clean-up: did not expect thread %zu to be not active", + __func__, i); + sem_post(semaphore); + continue; + } + thread_array[i].active = FALSE; + ret = pthread_join(thread_array[i].thread, NULL); + if (ret != 0) { + upsdebugx(0, "WARNING: %s: Midway clean-up: pthread_join() returned code %i", + __func__, ret); + } + sem_post(semaphore); + } + thread_count = 0; + free(thread_array); + thread_array = NULL; + } +# else +# ifdef HAVE_PTHREAD_TRYJOIN + /* TODO: Move the wait-loop for TRYJOIN here? */ +# endif /* HAVE_PTHREAD_TRYJOIN */ +# endif /* HAVE_SEMAPHORE */ +#endif /* HAVE_PTHREAD */ + } /* if: could we "pass" or not? */ + } /* while */ + +#ifdef HAVE_PTHREAD + if (thread_array != NULL) { + upsdebugx(2, "%s: all planned scans launched, waiting for threads to complete", __func__); + for (i = 0; i < thread_count; i++) { + int ret; + + if (!thread_array[i].active) continue; + + ret = pthread_join(thread_array[i].thread, NULL); + if (ret != 0) { + upsdebugx(0, "WARNING: %s: Clean-up: pthread_join() returned code %i", + __func__, ret); + } + thread_array[i].active = FALSE; +# ifdef HAVE_SEMAPHORE + sem_post(semaphore); +# else +# ifdef HAVE_PTHREAD_TRYJOIN + pthread_mutex_lock(&threadcount_mutex); + if (curr_threads > 0) { + curr_threads --; + upsdebugx(5, "%s: Clean-up: Joined a finished thread #%zu", + __func__, i); + } else { + upsdebugx(0, "WARNING: %s: Clean-up: Accounting of thread count " + "says we are already at 0", __func__); + } + pthread_mutex_unlock(&threadcount_mutex); +# endif /* HAVE_PTHREAD_TRYJOIN */ +# endif /* HAVE_SEMAPHORE */ + } + free(thread_array); + upsdebugx(2, "%s: all threads freed", __func__); } pthread_mutex_destroy(&dev_mutex); - free(thread_array); -#endif +#endif /* HAVE_PTHREAD */ - if(change_action_handler) { - signal(SIGPIPE,SIG_DFL); + if (change_action_handler) { +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wstrict-prototypes" +#endif + signal(SIGPIPE, SIG_DFL); +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES) +# pragma GCC diagnostic pop +#endif } /* free everything... */ - i=0; - while(serial_ports_list[i] != NULL) { + i = 0; + while (serial_ports_list[i] != NULL) { free(serial_ports_list[i]); i++; } diff --git a/tools/nut-scanner/scan_ipmi.c b/tools/nut-scanner/scan_ipmi.c index 5cb651c..6dca351 100644 --- a/tools/nut-scanner/scan_ipmi.c +++ b/tools/nut-scanner/scan_ipmi.c @@ -115,12 +115,13 @@ static void (*nut_ipmi_ctx_destroy) (ipmi_ctx_t ctx); /* Internal functions */ static nutscan_device_t * nutscan_scan_ipmi_device(const char * IPaddr, nutscan_ipmi_t * sec); -/* Return 0 on error */ +/* Return 0 on error; visible externally */ +int nutscan_load_ipmi_library(const char *libname_path); int nutscan_load_ipmi_library(const char *libname_path) { - if( dl_handle != NULL ) { + if (dl_handle != NULL) { /* if previous init failed */ - if( dl_handle == (void *)1 ) { + if (dl_handle == (void *)1) { return 0; } /* init has already been done */ @@ -132,7 +133,7 @@ int nutscan_load_ipmi_library(const char *libname_path) return 0; } - if( lt_dlinit() != 0 ) { + if (lt_dlinit() != 0) { fprintf(stderr, "Error initializing lt_init\n"); return 0; } @@ -147,97 +148,97 @@ int nutscan_load_ipmi_library(const char *libname_path) lt_dlerror(); *(void **) (&nut_ipmi_fru_close_device_id) = lt_dlsym(dl_handle, IPMI_FRU_CLOSE_DEVICE_ID); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_ipmi_fru_ctx_destroy) = lt_dlsym(dl_handle, IPMI_FRU_CTX_DESTROY); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } #ifdef HAVE_FREEIPMI_11X_12X *(void **) (&nut_ipmi_sdr_ctx_destroy) = lt_dlsym(dl_handle, "ipmi_sdr_ctx_destroy"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } #else /* HAVE_FREEIPMI_11X_12X */ *(void **) (&nut_ipmi_sdr_cache_ctx_destroy) = lt_dlsym(dl_handle, "ipmi_sdr_cache_ctx_destroy"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_ipmi_sdr_parse_ctx_destroy) = lt_dlsym(dl_handle, "ipmi_sdr_parse_ctx_destroy"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } #endif /* HAVE_FREEIPMI_11X_12X */ *(void **) (&nut_ipmi_fru_ctx_create) = lt_dlsym(dl_handle, IPMI_FRU_CTX_CREATE); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_ipmi_fru_ctx_set_flags) = lt_dlsym(dl_handle, IPMI_FRU_CTX_SET_FLAGS); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_ipmi_fru_open_device_id) = lt_dlsym(dl_handle, IPMI_FRU_OPEN_DEVICE_ID); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_ipmi_fru_ctx_errormsg) = lt_dlsym(dl_handle, IPMI_FRU_CTX_ERRORMSG); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_ipmi_fru_read_data_area) = lt_dlsym(dl_handle, IPMI_FRU_READ_DATA_AREA); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_ipmi_fru_next) = lt_dlsym(dl_handle, IPMI_FRU_PARSE_NEXT); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_ipmi_ctx_create) = lt_dlsym(dl_handle, "ipmi_ctx_create"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_ipmi_ctx_find_inband) = lt_dlsym(dl_handle, "ipmi_ctx_find_inband"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_ipmi_ctx_open_outofband) = lt_dlsym(dl_handle, "ipmi_ctx_open_outofband"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_ipmi_ctx_errnum) = lt_dlsym(dl_handle, "ipmi_ctx_errnum"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_ipmi_ctx_errormsg) = lt_dlsym(dl_handle, "ipmi_ctx_errormsg"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_ipmi_ctx_close) = lt_dlsym(dl_handle, "ipmi_ctx_close"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_ipmi_ctx_destroy) = lt_dlsym(dl_handle, "ipmi_ctx_destroy"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } @@ -285,12 +286,12 @@ static void nut_freeipmi_cleanup(ipmi_fru_parse_ctx_t fru_parse_ctx, } /* Return 1 if supported, 0 otherwise */ -int is_ipmi_device_supported(ipmi_ctx_t ipmi_ctx, int ipmi_id) +static int is_ipmi_device_supported(ipmi_ctx_t ipmi_ctx, int ipmi_id) { int ret = -1; unsigned int area_type = 0; unsigned int area_length = 0; - uint8_t areabuf[IPMI_FRU_AREA_SIZE_MAX+1]; + uint8_t areabuf[IPMI_FRU_AREA_SIZE_MAX + 1]; ipmi_fru_parse_ctx_t fru_parse_ctx = NULL; #ifdef HAVE_FREEIPMI_11X_12X ipmi_sdr_ctx_t sdr_ctx = NULL; @@ -317,7 +318,11 @@ int is_ipmi_device_supported(ipmi_ctx_t ipmi_ctx, int ipmi_id) return 0; } - if ((*nut_ipmi_fru_open_device_id) (fru_parse_ctx, ipmi_id) < 0) + if (ipmi_id < 0 || (unsigned int)ipmi_id > UINT8_MAX) { + fprintf(stderr, "is_ipmi_device_supported: ipmi_id=%d is out of range!\n", ipmi_id); + return 0; + } + if ((*nut_ipmi_fru_open_device_id) (fru_parse_ctx, (uint8_t)ipmi_id) < 0) { #ifdef HAVE_FREEIPMI_11X_12X nut_freeipmi_cleanup(fru_parse_ctx, sdr_ctx); @@ -384,7 +389,7 @@ nutscan_device_t * nutscan_scan_ipmi_device(const char * IPaddr, nutscan_ipmi_t int ipmi_id = 0; char port_id[64]; - if( !nutscan_avail_ipmi ) { + if (!nutscan_avail_ipmi) { return NULL; } @@ -392,12 +397,12 @@ nutscan_device_t * nutscan_scan_ipmi_device(const char * IPaddr, nutscan_ipmi_t if (!(ipmi_ctx = (*nut_ipmi_ctx_create) ())) { /* we have to force cleanup, since exit handler is not yet installed */ - fprintf(stderr, "ipmi_ctx_create\n"); + fprintf(stderr, "Failed to ipmi_ctx_create\n"); return NULL; } /* Are we scanning locally, or over the network? */ - if (IPaddr == NULL) + if (IPaddr == NULL) { /* FIXME: we need root right to access local IPMI! if (!ipmi_is_root ()) { @@ -414,7 +419,7 @@ nutscan_device_t * nutscan_scan_ipmi_device(const char * IPaddr, nutscan_ipmi_t 0 /* flags */ )) < 0) { - fprintf(stderr, "ipmi_ctx_find_inband: %s\n", + upsdebugx(2, "ipmi_ctx_find_inband (local scan): %s", (*nut_ipmi_ctx_errormsg) (ipmi_ctx)); return NULL; } @@ -441,7 +446,7 @@ nutscan_device_t * nutscan_scan_ipmi_device(const char * IPaddr, nutscan_ipmi_t ipmi_sec->username, ipmi_sec->password, ipmi_sec->K_g_BMC_key, -??? (ipmi_sec->K_g_BMC_key) ? config->k_g_len : 0, +/*???*/ (ipmi_sec->K_g_BMC_key) ? config->k_g_len : 0, ipmi_sec->privilege_level, ipmi_sec->cipher_suite_id, IPMI_SESSION_TIMEOUT_LENGTH_DEFAULT, @@ -449,7 +454,11 @@ nutscan_device_t * nutscan_scan_ipmi_device(const char * IPaddr, nutscan_ipmi_t ipmi_dev->workaround_flags, flags) < 0) { - IPMI_MONITORING_DEBUG (("ipmi_ctx_open_outofband_2_0: %s", ipmi_ctx_errormsg (c->ipmi_ctx))); + upsdebugx(2, "nut_ipmi_ctx_open_outofband_2_0 (%s): %s", + IPaddr, (*nut_ipmi_ctx_errormsg) (c->ipmi_ctx)); + IPMI_MONITORING_DEBUG (("ipmi_ctx_open_outofband_2_0 (%s): %s", + IPaddr, ipmi_ctx_errormsg (c->ipmi_ctx))); + if (ipmi_ctx_errnum (c->ipmi_ctx) == IPMI_ERR_USERNAME_INVALID) c->errnum = IPMI_MONITORING_ERR_USERNAME_INVALID; else if (ipmi_ctx_errnum (c->ipmi_ctx) == IPMI_ERR_PASSWORD_INVALID) @@ -493,12 +502,28 @@ nutscan_device_t * nutscan_scan_ipmi_device(const char * IPaddr, nutscan_ipmi_t #endif /* 0 */ /* Fall back to IPMI 1.5 */ + if (ipmi_sec->authentication_type < 0 + || (unsigned int)ipmi_sec->authentication_type > UINT8_MAX + ) { + upsdebugx(2, "nutscan_scan_ipmi_device (%s): " + "authentication_type=%d is out of range!", + IPaddr, ipmi_sec->authentication_type); + return 0; + } + if (ipmi_sec->privilege_level < 0 + || (unsigned int)ipmi_sec->privilege_level > UINT8_MAX + ) { + upsdebugx(2, "nutscan_scan_ipmi_device (%s): " + "privilege_level=%d is out of range!", + IPaddr, ipmi_sec->privilege_level); + return 0; + } if ((ret = (*nut_ipmi_ctx_open_outofband) (ipmi_ctx, IPaddr, ipmi_sec->username, ipmi_sec->password, - ipmi_sec->authentication_type, - ipmi_sec->privilege_level, + (uint8_t)ipmi_sec->authentication_type, + (uint8_t)ipmi_sec->privilege_level, IPMI_SESSION_TIMEOUT_LENGTH_DEFAULT, IPMI_RETRANSMISSION_TIMEOUT_LENGTH_DEFAULT, ipmi_sec->workaround_flags, @@ -516,8 +541,8 @@ nutscan_device_t * nutscan_scan_ipmi_device(const char * IPaddr, nutscan_ipmi_t || (*nut_ipmi_ctx_errnum) (ipmi_ctx) == IPMI_ERR_CONNECTION_TIMEOUT) { */ /* FIXME: don't log timeout errors */ - fprintf(stderr, "nut_ipmi_ctx_open_outofband: %s\n", - (*nut_ipmi_ctx_errormsg) (ipmi_ctx)); + upsdebugx(2, "nut_ipmi_ctx_open_outofband (%s): %s", + IPaddr, (*nut_ipmi_ctx_errormsg) (ipmi_ctx)); return NULL; /*}*/ } @@ -528,8 +553,8 @@ nutscan_device_t * nutscan_scan_ipmi_device(const char * IPaddr, nutscan_ipmi_t if (is_ipmi_device_supported(ipmi_ctx, ipmi_id)) { - if ( (nut_dev = nutscan_new_device()) == NULL ) { - fprintf(stderr,"Memory allocation error\n"); + if ((nut_dev = nutscan_new_device()) == NULL) { + fprintf(stderr, "Memory allocation error\n"); nutscan_free_device(current_nut_dev); break; } @@ -547,13 +572,14 @@ nutscan_device_t * nutscan_scan_ipmi_device(const char * IPaddr, nutscan_ipmi_t nut_dev->port = strdup(port_id); /* FIXME: also dump device.serial? * using drivers/libfreeipmi_get_board_info() */ - + current_nut_dev = nutscan_add_device_to_device( current_nut_dev, nut_dev); memset (port_id, 0, sizeof(port_id)); } + } /* Final cleanup */ @@ -576,13 +602,13 @@ nutscan_device_t * nutscan_scan_ipmi(const char * start_ip, const char * stop_ip nutscan_device_t * nut_dev = NULL; nutscan_device_t * current_nut_dev = NULL; - if( !nutscan_avail_ipmi ) { + if (!nutscan_avail_ipmi) { return NULL; } /* Are we scanning locally, or through the network? */ - if (start_ip == NULL) + if (start_ip == NULL) { /* Local PSU scan */ current_nut_dev = nutscan_scan_ipmi_device(NULL, NULL); @@ -590,7 +616,7 @@ nutscan_device_t * nutscan_scan_ipmi(const char * start_ip, const char * stop_ip else { ip_str = nutscan_ip_iter_init(&ip, start_ip, stop_ip); - while(ip_str != NULL) { + while (ip_str != NULL) { tmp_sec = malloc(sizeof(nutscan_ipmi_t)); memcpy(tmp_sec, sec, sizeof(nutscan_ipmi_t)); @@ -600,7 +626,7 @@ nutscan_device_t * nutscan_scan_ipmi(const char * start_ip, const char * stop_ip } /* Prepare the next iteration */ ip_str = nutscan_ip_iter_inc(&ip); - }; + } } return nutscan_rewind_device(current_nut_dev); @@ -609,6 +635,10 @@ nutscan_device_t * nutscan_scan_ipmi(const char * start_ip, const char * stop_ip /* stub function */ nutscan_device_t * nutscan_scan_ipmi(const char * startIP, const char * stopIP, nutscan_ipmi_t * sec) { + NUT_UNUSED_VARIABLE(startIP); + NUT_UNUSED_VARIABLE(stopIP); + NUT_UNUSED_VARIABLE(sec); + return NULL; } #endif /* WITH_IPMI */ diff --git a/tools/nut-scanner/scan_nut.c b/tools/nut-scanner/scan_nut.c index f53c66b..a0f2b3e 100644 --- a/tools/nut-scanner/scan_nut.c +++ b/tools/nut-scanner/scan_nut.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2011 - EATON + * Copyright (C) 2016-2021 - EATON - Various threads-related improvements * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,27 +20,25 @@ /*! \file scan_nut.c \brief detect remote NUT services \author Frederic Bohe + \author Jim Klimov */ #include "common.h" #include "upsclient.h" #include "nut-scan.h" -#ifdef HAVE_PTHREAD -#include -#endif #include /* dynamic link library stuff */ static lt_dlhandle dl_handle = NULL; static const char *dl_error = NULL; -static int (*nut_upscli_splitaddr)(const char *buf,char **hostname, int *port); +static int (*nut_upscli_splitaddr)(const char *buf, char **hostname, int *port); static int (*nut_upscli_tryconnect)(UPSCONN_t *ups, const char *host, int port, - int flags,struct timeval * timeout); -static int (*nut_upscli_list_start)(UPSCONN_t *ups, unsigned int numq, + int flags, struct timeval * timeout); +static int (*nut_upscli_list_start)(UPSCONN_t *ups, size_t numq, const char **query); -static int (*nut_upscli_list_next)(UPSCONN_t *ups, unsigned int numq, - const char **query,unsigned int *numa, char ***answer); +static int (*nut_upscli_list_next)(UPSCONN_t *ups, size_t numq, + const char **query, size_t *numa, char ***answer); static int (*nut_upscli_disconnect)(UPSCONN_t *ups); static nutscan_device_t * dev_ret = NULL; @@ -47,17 +46,25 @@ static nutscan_device_t * dev_ret = NULL; static pthread_mutex_t dev_mutex; #endif +/* use explicit booleans */ +#ifndef FALSE +typedef enum ebool { FALSE = 0, TRUE } bool_t; +#else +typedef int bool_t; +#endif + struct scan_nut_arg { char * hostname; - long timeout; + useconds_t timeout; }; -/* return 0 on error */ +/* return 0 on error; visible externally */ +int nutscan_load_upsclient_library(const char *libname_path); int nutscan_load_upsclient_library(const char *libname_path) { - if( dl_handle != NULL ) { + if (dl_handle != NULL) { /* if previous init failed */ - if( dl_handle == (void *)1 ) { + if (dl_handle == (void *)1) { return 0; } /* init has already been done */ @@ -69,7 +76,7 @@ int nutscan_load_upsclient_library(const char *libname_path) return 0; } - if( lt_dlinit() != 0 ) { + if (lt_dlinit() != 0) { fprintf(stderr, "Error initializing lt_init\n"); return 0; } @@ -84,31 +91,31 @@ int nutscan_load_upsclient_library(const char *libname_path) *(void **) (&nut_upscli_splitaddr) = lt_dlsym(dl_handle, "upscli_splitaddr"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_upscli_tryconnect) = lt_dlsym(dl_handle, "upscli_tryconnect"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_upscli_list_start) = lt_dlsym(dl_handle, "upscli_list_start"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_upscli_list_next) = lt_dlsym(dl_handle, "upscli_list_next"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_upscli_disconnect) = lt_dlsym(dl_handle, "upscli_disconnect"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } @@ -127,13 +134,13 @@ static void * list_nut_devices(void * arg) char *target_hostname = nut_arg->hostname; struct timeval tv; int port; - unsigned int numq, numa; + size_t numq, numa; const char *query[4]; char **answer; char *hostname = NULL; UPSCONN_t *ups = malloc(sizeof(*ups)); nutscan_device_t * dev = NULL; - int buf_size; + size_t buf_size; tv.tv_sec = nut_arg->timeout / (1000*1000); tv.tv_usec = nut_arg->timeout % (1000*1000); @@ -148,14 +155,14 @@ static void * list_nut_devices(void * arg) return NULL; } - if ((*nut_upscli_tryconnect)(ups, hostname, port,UPSCLI_CONN_TRYSSL,&tv) < 0) { + if ((*nut_upscli_tryconnect)(ups, hostname, port, UPSCLI_CONN_TRYSSL, &tv) < 0) { free(target_hostname); free(nut_arg); free(ups); return NULL; } - if((*nut_upscli_list_start)(ups, numq, query) < 0) { + if ((*nut_upscli_list_start)(ups, numq, query) < 0) { (*nut_upscli_disconnect)(ups); free(target_hostname); free(nut_arg); @@ -163,7 +170,7 @@ static void * list_nut_devices(void * arg) return NULL; } - while ((*nut_upscli_list_next)(ups,numq, query, &numa, &answer) == 1) { + while ((*nut_upscli_list_next)(ups, numq, query, &numa, &answer) == 1) { /* UPS */ if (numa < 3) { (*nut_upscli_disconnect)(ups); @@ -177,26 +184,25 @@ static void * list_nut_devices(void * arg) /* FIXME: * - also print answer[2] if != "Unavailable"? * - for upsmon.conf or ups.conf (using dummy-ups)? */ - if (numa >= 3) { - dev = nutscan_new_device(); - dev->type = TYPE_NUT; - dev->driver = strdup("nutclient"); - /* +1+1 is for '@' character and terminating 0 */ - buf_size = strlen(answer[1])+strlen(hostname)+1+1; - dev->port = malloc(buf_size); - if( dev->port ) { - snprintf(dev->port,buf_size,"%s@%s",answer[1], - hostname); -#ifdef HAVE_PTHREAD - pthread_mutex_lock(&dev_mutex); -#endif - dev_ret = nutscan_add_device_to_device(dev_ret,dev); -#ifdef HAVE_PTHREAD - pthread_mutex_unlock(&dev_mutex); -#endif - } + dev = nutscan_new_device(); + dev->type = TYPE_NUT; + dev->driver = strdup("nutclient"); + /* +1+1 is for '@' character and terminating 0 */ + buf_size = strlen(answer[1]) + strlen(hostname) + 1 + 1; + dev->port = malloc(buf_size); + if (dev->port) { + snprintf(dev->port, buf_size, "%s@%s", answer[1], + hostname); +#ifdef HAVE_PTHREAD + pthread_mutex_lock(&dev_mutex); +#endif + dev_ret = nutscan_add_device_to_device(dev_ret, dev); +#ifdef HAVE_PTHREAD + pthread_mutex_unlock(&dev_mutex); +#endif } + } (*nut_upscli_disconnect)(ups); @@ -206,85 +212,330 @@ static void * list_nut_devices(void * arg) return NULL; } -nutscan_device_t * nutscan_scan_nut(const char* startIP, const char* stopIP, const char* port,long usec_timeout) +nutscan_device_t * nutscan_scan_nut(const char* startIP, const char* stopIP, const char* port, useconds_t usec_timeout) { + bool_t pass = TRUE; /* Track that we may spawn a scanning thread */ nutscan_ip_iter_t ip; char * ip_str = NULL; char * ip_dest = NULL; char buf[SMALLBUF]; struct sigaction oldact; int change_action_handler = 0; - int i; struct scan_nut_arg *nut_arg; #ifdef HAVE_PTHREAD +# ifdef HAVE_SEMAPHORE + sem_t * semaphore = nutscan_semaphore(); + sem_t semaphore_scantype_inst; + sem_t * semaphore_scantype = &semaphore_scantype_inst; +# endif /* HAVE_SEMAPHORE */ pthread_t thread; - pthread_t * thread_array = NULL; - int thread_count = 0; + nutscan_thread_t * thread_array = NULL; + size_t thread_count = 0, i; +# if (defined HAVE_PTHREAD_TRYJOIN) || (defined HAVE_SEMAPHORE) + size_t max_threads_scantype = max_threads_oldnut; +# endif - pthread_mutex_init(&dev_mutex,NULL); + pthread_mutex_init(&dev_mutex, NULL); + +# ifdef HAVE_SEMAPHORE + if (max_threads_scantype > 0) { +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic push #endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic ignored "-Wunreachable-code" +#endif +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" +#endif + /* Different platforms, different sizes, none fits all... */ + if (SIZE_MAX > UINT_MAX && max_threads_scantype > UINT_MAX) { +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +#ifdef HAVE_PRAGMAS_FOR_GCC_DIAGNOSTIC_IGNORED_UNREACHABLE_CODE +#pragma GCC diagnostic pop +#endif + upsdebugx(1, + "WARNING: %s: Limiting max_threads_scantype to range acceptable for sem_init()", + __func__); + max_threads_scantype = UINT_MAX - 1; + } + sem_init(semaphore_scantype, 0, (unsigned int)max_threads_scantype); + } +# endif /* HAVE_SEMAPHORE */ - if( !nutscan_avail_nut ) { - return NULL; - } +#endif /* HAVE_PTHREAD */ + + if (!nutscan_avail_nut) { + return NULL; + } /* Ignore SIGPIPE if the caller hasn't set a handler for it yet */ - if( sigaction(SIGPIPE, NULL, &oldact) == 0 ) { - if( oldact.sa_handler == SIG_DFL ) { + if (sigaction(SIGPIPE, NULL, &oldact) == 0) { +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wstrict-prototypes" +#endif + if (oldact.sa_handler == SIG_DFL) { change_action_handler = 1; - signal(SIGPIPE,SIG_IGN); + signal(SIGPIPE, SIG_IGN); } +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES) +# pragma GCC diagnostic pop +#endif } - ip_str = nutscan_ip_iter_init(&ip,startIP,stopIP); + ip_str = nutscan_ip_iter_init(&ip, startIP, stopIP); - while( ip_str != NULL ) - { - if( port ) { - if( ip.type == IPv4 ) { - snprintf(buf,sizeof(buf),"%s:%s",ip_str,port); + while (ip_str != NULL) { +#ifdef HAVE_PTHREAD + /* NOTE: With many enough targets to scan, this can crash + * by spawning too many children; add a limit and loop to + * "reap" some already done with their work. And probably + * account them in thread_array[] as something to not wait + * for below in pthread_join()... + */ + +# ifdef HAVE_SEMAPHORE + /* Just wait for someone to free a semaphored slot, + * if none are available, and then/otherwise grab one + */ + if (thread_array == NULL) { + /* Starting point, or after a wait to complete + * all earlier runners */ + if (max_threads_scantype > 0) + sem_wait(semaphore_scantype); + sem_wait(semaphore); + pass = TRUE; + } else { + pass = ((max_threads_scantype == 0 || sem_trywait(semaphore_scantype) == 0) && + sem_trywait(semaphore) == 0); + } +# else +# ifdef HAVE_PTHREAD_TRYJOIN + /* A somewhat naive and brute-force solution for + * systems without a semaphore.h. This may suffer + * some off-by-one errors, using a few more threads + * than intended (if we race a bit at the wrong time, + * probably up to one per enabled scanner routine). + */ + + /* TOTHINK: Should there be a threadcount_mutex when + * we just read the value in if() and while() below? + * At worst we would overflow the limit a bit due to + * other protocol scanners... + */ + if (curr_threads >= max_threads + || (curr_threads >= max_threads_scantype && max_threads_scantype > 0) + ) { + upsdebugx(2, "%s: already running %zu scanning threads " + "(launched overall: %zu), " + "waiting until some would finish", + __func__, curr_threads, thread_count); + while (curr_threads >= max_threads + || (curr_threads >= max_threads_scantype && max_threads_scantype > 0) + ) { + for (i = 0; i < thread_count ; i++) { + int ret; + + if (!thread_array[i].active) continue; + + pthread_mutex_lock(&threadcount_mutex); + upsdebugx(3, "%s: Trying to join thread #%i...", __func__, i); + ret = pthread_tryjoin_np(thread_array[i].thread, NULL); + switch (ret) { + case ESRCH: /* No thread with the ID thread could be found - already "joined"? */ + upsdebugx(5, "%s: Was thread #%zu joined earlier?", __func__, i); + break; + case 0: /* thread exited */ + if (curr_threads > 0) { + curr_threads --; + upsdebugx(4, "%s: Joined a finished thread #%zu", __func__, i); + } else { + /* threadcount_mutex fault? */ + upsdebugx(0, "WARNING: %s: Accounting of thread count " + "says we are already at 0", __func__); + } + thread_array[i].active = FALSE; + break; + case EBUSY: /* actively running */ + upsdebugx(6, "%s: thread #%zu still busy (%i)", + __func__, i, ret); + break; + case EDEADLK: /* Errors with thread interactions... bail out? */ + case EINVAL: /* Errors with thread interactions... bail out? */ + default: /* new pthreads abilities? */ + upsdebugx(5, "%s: thread #%zu reported code %i", + __func__, i, ret); + break; + } + pthread_mutex_unlock(&threadcount_mutex); + } + + if (curr_threads >= max_threads + || (curr_threads >= max_threads_scantype && max_threads_scantype > 0) + ) { + usleep (10000); /* microSec's, so 0.01s here */ + } + } + upsdebugx(2, "%s: proceeding with scan", __func__); + } + /* NOTE: No change to default "pass" in this ifdef: + * if we got to this line, we have a slot to use */ +# endif /* HAVE_PTHREAD_TRYJOIN */ +# endif /* HAVE_SEMAPHORE */ +#endif /* HAVE_PTHREAD */ + + if (pass) { + if (port) { + if (ip.type == IPv4) { + snprintf(buf, sizeof(buf), "%s:%s", ip_str, port); + } + else { + snprintf(buf, sizeof(buf), "[%s]:%s", ip_str, port); + } + + ip_dest = strdup(buf); } else { - snprintf(buf,sizeof(buf),"[%s]:%s",ip_str,port); + ip_dest = strdup(ip_str); } - ip_dest = strdup(buf); - } - else { - ip_dest = strdup(ip_str); - } + if ((nut_arg = malloc(sizeof(struct scan_nut_arg))) == NULL) { + free(ip_dest); + break; + } - if((nut_arg = malloc(sizeof(struct scan_nut_arg))) == NULL ) { - free(ip_dest); - break; - } - - nut_arg->timeout = usec_timeout; - nut_arg->hostname = ip_dest; -#ifdef HAVE_PTHREAD - if (pthread_create(&thread,NULL,list_nut_devices,(void*)nut_arg)==0){ - thread_count++; - thread_array = realloc(thread_array, - thread_count*sizeof(pthread_t)); - thread_array[thread_count-1] = thread; - } -#else - list_nut_devices(nut_arg); -#endif - free(ip_str); - ip_str = nutscan_ip_iter_inc(&ip); - } + nut_arg->timeout = usec_timeout; + nut_arg->hostname = ip_dest; #ifdef HAVE_PTHREAD - for ( i=0; i < thread_count ; i++) { - pthread_join(thread_array[i],NULL); + if (pthread_create(&thread, NULL, list_nut_devices, (void*)nut_arg) == 0) { +# ifdef HAVE_PTHREAD_TRYJOIN + pthread_mutex_lock(&threadcount_mutex); + curr_threads++; +# endif /* HAVE_PTHREAD_TRYJOIN */ + + thread_count++; + nutscan_thread_t *new_thread_array = realloc(thread_array, + thread_count * sizeof(nutscan_thread_t)); + if (new_thread_array == NULL) { + upsdebugx(1, "%s: Failed to realloc thread array", __func__); + break; + } + else { + thread_array = new_thread_array; + } + thread_array[thread_count - 1].thread = thread; + thread_array[thread_count - 1].active = TRUE; + +# ifdef HAVE_PTHREAD_TRYJOIN + pthread_mutex_unlock(&threadcount_mutex); +# endif /* HAVE_PTHREAD_TRYJOIN */ + } +#else /* not HAVE_PTHREAD */ + list_nut_devices(nut_arg); +#endif /* if HAVE_PTHREAD */ + free(ip_str); + ip_str = nutscan_ip_iter_inc(&ip); + } else { /* if not pass -- all slots busy */ +#ifdef HAVE_PTHREAD +# ifdef HAVE_SEMAPHORE + /* Wait for all current scans to complete */ + if (thread_array != NULL) { + upsdebugx (2, "%s: Running too many scanning threads, " + "waiting until older ones would finish", + __func__); + for (i = 0; i < thread_count ; i++) { + int ret; + if (!thread_array[i].active) { + /* Probably should not get here, + * but handle it just in case */ + upsdebugx(0, "WARNING: %s: Midway clean-up: did not expect thread %zu to be not active", + __func__, i); + sem_post(semaphore); + if (max_threads_scantype > 0) + sem_post(semaphore_scantype); + continue; + } + thread_array[i].active = FALSE; + ret = pthread_join(thread_array[i].thread, NULL); + if (ret != 0) { + upsdebugx(0, "WARNING: %s: Midway clean-up: pthread_join() returned code %i", + __func__, ret); + } + sem_post(semaphore); + if (max_threads_scantype > 0) + sem_post(semaphore_scantype); + } + thread_count = 0; + free(thread_array); + thread_array = NULL; + } +# else +# ifdef HAVE_PTHREAD_TRYJOIN + /* TODO: Move the wait-loop for TRYJOIN here? */ +# endif /* HAVE_PTHREAD_TRYJOIN */ +# endif /* HAVE_SEMAPHORE */ +#endif /* HAVE_PTHREAD */ + } /* if: could we "pass" or not? */ + } /* while */ + +#ifdef HAVE_PTHREAD + if (thread_array != NULL) { + upsdebugx(2, "%s: all planned scans launched, waiting for threads to complete", __func__); + for (i = 0; i < thread_count; i++) { + int ret; + + if (!thread_array[i].active) continue; + + ret = pthread_join(thread_array[i].thread, NULL); + if (ret != 0) { + upsdebugx(0, "WARNING: %s: Clean-up: pthread_join() returned code %i", + __func__, ret); + } + thread_array[i].active = FALSE; +# ifdef HAVE_SEMAPHORE + sem_post(semaphore); + if (max_threads_scantype > 0) + sem_post(semaphore_scantype); +# else +# ifdef HAVE_PTHREAD_TRYJOIN + pthread_mutex_lock(&threadcount_mutex); + if (curr_threads > 0) { + curr_threads --; + upsdebugx(5, "%s: Clean-up: Joined a finished thread #%zu", + __func__, i); + } else { + upsdebugx(0, "WARNING: %s: Clean-up: Accounting of thread count " + "says we are already at 0", __func__); + } + pthread_mutex_unlock(&threadcount_mutex); +# endif /* HAVE_PTHREAD_TRYJOIN */ +# endif /* HAVE_SEMAPHORE */ + } + free(thread_array); + upsdebugx(2, "%s: all threads freed", __func__); } pthread_mutex_destroy(&dev_mutex); - free(thread_array); -#endif - if(change_action_handler) { - signal(SIGPIPE,SIG_DFL); +# ifdef HAVE_SEMAPHORE + if (max_threads_scantype > 0) + sem_destroy(semaphore_scantype); +# endif /* HAVE_SEMAPHORE */ +#endif /* HAVE_PTHREAD */ + + if (change_action_handler) { +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wstrict-prototypes" +#endif + signal(SIGPIPE, SIG_DFL); +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_STRICT_PROTOTYPES) +# pragma GCC diagnostic pop +#endif } return nutscan_rewind_device(dev_ret); diff --git a/tools/nut-scanner/scan_snmp.c b/tools/nut-scanner/scan_snmp.c index 994d695..48bdaaa 100644 --- a/tools/nut-scanner/scan_snmp.c +++ b/tools/nut-scanner/scan_snmp.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2011 - EATON + * Copyright (C) 2016-2021 - EATON - Various threads-related improvements * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,7 +19,9 @@ /*! \file scan_snmp.c \brief detect NUT supported SNMP devices - \author Frederic Bohe + \author Frederic Bohe + \author Arnaud Quette + \author Jim Klimov */ #include "common.h" @@ -55,13 +58,10 @@ #include #include -#ifdef HAVE_PTHREAD -#include -#endif #include "nutscan-snmp.h" /* Address API change */ -#ifndef usmAESPrivProtocol +#if ( ! NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol ) && ( ! defined usmAESPrivProtocol ) #define USMAESPRIVPROTOCOL "usmAES128PrivProtocol" #else #define USMAESPRIVPROTOCOL "usmAESPrivProtocol" @@ -69,11 +69,18 @@ #define SysOID ".1.3.6.1.2.1.1.2.0" +/* use explicit booleans */ +#ifndef FALSE +typedef enum ebool { FALSE = 0, TRUE } bool_t; +#else +typedef int bool_t; +#endif + static nutscan_device_t * dev_ret = NULL; #ifdef HAVE_PTHREAD static pthread_mutex_t dev_mutex; #endif -long g_usec_timeout ; +static useconds_t g_usec_timeout ; /* dynamic link library stuff */ static lt_dlhandle dl_handle = NULL; @@ -83,32 +90,69 @@ static void (*nut_init_snmp)(const char *type); static void (*nut_snmp_sess_init)(netsnmp_session * session); static void * (*nut_snmp_sess_open)(struct snmp_session *session); static int (*nut_snmp_sess_close)(void *handle); -static struct snmp_session * (*nut_snmp_sess_session)(void *handle); +static struct snmp_session * (*nut_snmp_sess_session)(void *handle); static void * (*nut_snmp_parse_oid)(const char *input, oid *objid, size_t *objidlen); -static struct snmp_pdu * (*nut_snmp_pdu_create) (int command ); -netsnmp_variable_list * (*nut_snmp_add_null_var)(netsnmp_pdu *pdu, +static struct snmp_pdu * (*nut_snmp_pdu_create) (int command); +static netsnmp_variable_list * (*nut_snmp_add_null_var)(netsnmp_pdu *pdu, const oid *objid, size_t objidlen); static int (*nut_snmp_sess_synch_response) (void *sessp, netsnmp_pdu *pdu, netsnmp_pdu **response); static int (*nut_snmp_oid_compare) (const oid *in_name1, size_t len1, const oid *in_name2, size_t len2); static void (*nut_snmp_free_pdu) (netsnmp_pdu *pdu); -static int (*nut_generate_Ku)(const oid * hashtype, u_int hashtype_len, - u_char * P, size_t pplen, u_char * Ku, size_t * kulen); -static const char * (*nut_snmp_api_errstring) (int snmp_errnumber); -static int (*nut_snmp_errno); -static oid * (*nut_usmAESPrivProtocol); -static oid * (*nut_usmHMACMD5AuthProtocol); -static oid * (*nut_usmHMACSHA1AuthProtocol); -static oid * (*nut_usmDESPrivProtocol); -/* return 0 on error */ +/* NOTE: Net-SNMP headers just are weird like that, in the same release: +net-snmp/types.h: size_t securityAuthProtoLen; +net-snmp/library/keytools.h: int generate_Ku(const oid * hashtype, u_int hashtype_len, ... + * Should we match in configure like for "getnameinfo()" arg types? + * Currently we cast one to another below (detecting target type could help). + */ +static int (*nut_generate_Ku)(const oid * hashtype, u_int hashtype_len, + unsigned char * P, size_t pplen, unsigned char * Ku, size_t * kulen); +static char* (*nut_snmp_out_toggle_options)(char *options); +static const char * (*nut_snmp_api_errstring) (int snmp_errnumber); + +/* Variables (not methods) exported by libnet-snmp: */ +static int *nut_snmp_errno; +#if NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol || NUT_HAVE_LIBNETSNMP_usmAES128PrivProtocol +static oid *nut_usmAESPrivProtocol; /* might be usmAES128PrivProtocol on some systems */ +#endif +#if NUT_HAVE_LIBNETSNMP_usmHMACMD5AuthProtocol +static oid *nut_usmHMACMD5AuthProtocol; +#endif +#if NUT_HAVE_LIBNETSNMP_usmHMACSHA1AuthProtocol +static oid *nut_usmHMACSHA1AuthProtocol; +#endif +#if NUT_HAVE_LIBNETSNMP_usmDESPrivProtocol +static oid *nut_usmDESPrivProtocol; +#endif +#if NUT_HAVE_LIBNETSNMP_DRAFT_BLUMENTHAL_AES_04 +# if NUT_HAVE_LIBNETSNMP_usmAES192PrivProtocol +static oid *nut_usmAES192PrivProtocol; +# endif +# if NUT_HAVE_LIBNETSNMP_usmAES256PrivProtocol +static oid *nut_usmAES256PrivProtocol; +# endif +#endif +#if NUT_HAVE_LIBNETSNMP_usmHMAC192SHA256AuthProtocol +static oid *nut_usmHMAC192SHA256AuthProtocol; +#endif +#if NUT_HAVE_LIBNETSNMP_usmHMAC256SHA384AuthProtocol +static oid *nut_usmHMAC256SHA384AuthProtocol; +#endif +#if NUT_HAVE_LIBNETSNMP_usmHMAC384SHA512AuthProtocol +static oid *nut_usmHMAC384SHA512AuthProtocol; +#endif + +/* return 0 on error; visible externally */ +int nutscan_load_snmp_library(const char *libname_path); + int nutscan_load_snmp_library(const char *libname_path) { - if( dl_handle != NULL ) { + if (dl_handle != NULL) { /* if previous init failed */ - if( dl_handle == (void *)1 ) { + if (dl_handle == (void *)1) { return 0; } /* init has already been done */ @@ -116,12 +160,12 @@ int nutscan_load_snmp_library(const char *libname_path) } if (libname_path == NULL) { - fprintf(stderr, "SNMP library not found. SNMP search disabled.\n"); + upsdebugx(1, "SNMP library not found. SNMP search disabled"); return 0; } - if( lt_dlinit() != 0 ) { - fprintf(stderr, "Error initializing lt_init\n"); + if (lt_dlinit() != 0) { + upsdebugx(1, "Error initializing lt_init"); return 0; } @@ -133,126 +177,184 @@ int nutscan_load_snmp_library(const char *libname_path) lt_dlerror(); /* Clear any existing error */ *(void **) (&nut_init_snmp) = lt_dlsym(dl_handle, "init_snmp"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_snmp_sess_init) = lt_dlsym(dl_handle, "snmp_sess_init"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_snmp_sess_open) = lt_dlsym(dl_handle, "snmp_sess_open"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_snmp_sess_close) = lt_dlsym(dl_handle, "snmp_sess_close"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_snmp_sess_session) = lt_dlsym(dl_handle, "snmp_sess_session"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_snmp_parse_oid) = lt_dlsym(dl_handle, "snmp_parse_oid"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_snmp_pdu_create) = lt_dlsym(dl_handle, "snmp_pdu_create"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_snmp_add_null_var) = lt_dlsym(dl_handle, "snmp_add_null_var"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_snmp_sess_synch_response) = lt_dlsym(dl_handle, "snmp_sess_synch_response"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_snmp_oid_compare) = lt_dlsym(dl_handle, "snmp_oid_compare"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } - *(void **) (&nut_snmp_free_pdu) = lt_dlsym(dl_handle,"snmp_free_pdu"); - if ((dl_error = lt_dlerror()) != NULL) { + *(void **) (&nut_snmp_free_pdu) = lt_dlsym(dl_handle, "snmp_free_pdu"); + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_generate_Ku) = lt_dlsym(dl_handle, "generate_Ku"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { + goto err; + } + + *(void **) (&nut_snmp_out_toggle_options) = lt_dlsym(dl_handle, + "snmp_out_toggle_options"); + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_snmp_api_errstring) = lt_dlsym(dl_handle, "snmp_api_errstring"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_snmp_errno) = lt_dlsym(dl_handle, "snmp_errno"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } +#if NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol || NUT_HAVE_LIBNETSNMP_usmAES128PrivProtocol *(void **) (&nut_usmAESPrivProtocol) = lt_dlsym(dl_handle, USMAESPRIVPROTOCOL); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } +#endif /* NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol || NUT_HAVE_LIBNETSNMP_usmAES128PrivProtocol */ +#if NUT_HAVE_LIBNETSNMP_usmHMACMD5AuthProtocol *(void **) (&nut_usmHMACMD5AuthProtocol) = lt_dlsym(dl_handle, "usmHMACMD5AuthProtocol"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } +#endif /* NUT_HAVE_LIBNETSNMP_usmHMACMD5AuthProtocol */ +#if NUT_HAVE_LIBNETSNMP_usmHMACSHA1AuthProtocol *(void **) (&nut_usmHMACSHA1AuthProtocol) = lt_dlsym(dl_handle, "usmHMACSHA1AuthProtocol"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } +#endif /* NUT_HAVE_LIBNETSNMP_usmHMACSHA1AuthProtocol */ +#if NUT_HAVE_LIBNETSNMP_usmDESPrivProtocol *(void **) (&nut_usmDESPrivProtocol) = lt_dlsym(dl_handle, "usmDESPrivProtocol"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } +#endif /* NUT_HAVE_LIBNETSNMP_usmDESPrivProtocol */ + +#if NUT_HAVE_LIBNETSNMP_DRAFT_BLUMENTHAL_AES_04 +# if NUT_HAVE_LIBNETSNMP_usmAES192PrivProtocol + *(void **) (&nut_usmAES192PrivProtocol) = lt_dlsym(dl_handle, + "usmAES192PrivProtocol"); + if ((dl_error = lt_dlerror()) != NULL) { + goto err; + } +# endif /* NUT_HAVE_LIBNETSNMP_usmAES192PrivProtocol */ + +# if NUT_HAVE_LIBNETSNMP_usmAES256PrivProtocol + *(void **) (&nut_usmAES256PrivProtocol) = lt_dlsym(dl_handle, + "usmAES256PrivProtocol"); + if ((dl_error = lt_dlerror()) != NULL) { + goto err; + } +# endif /* NUT_HAVE_LIBNETSNMP_usmAES256PrivProtocol */ +#endif /* NUT_HAVE_LIBNETSNMP_DRAFT_BLUMENTHAL_AES_04 */ + +#if NUT_HAVE_LIBNETSNMP_usmHMAC192SHA256AuthProtocol + *(void **) (&nut_usmHMAC192SHA256AuthProtocol) = lt_dlsym(dl_handle, + "usmHMAC192SHA256AuthProtocol"); + if ((dl_error = lt_dlerror()) != NULL) { + goto err; + } +#endif /* NUT_HAVE_LIBNETSNMP_usmHMAC192SHA256AuthProtocol */ + +#if NUT_HAVE_LIBNETSNMP_usmHMAC256SHA384AuthProtocol + *(void **) (&nut_usmHMAC256SHA384AuthProtocol) = lt_dlsym(dl_handle, + "usmHMAC256SHA384AuthProtocol"); + if ((dl_error = lt_dlerror()) != NULL) { + goto err; + } +#endif /* NUT_HAVE_LIBNETSNMP_usmHMAC256SHA384AuthProtocol */ + +#if NUT_HAVE_LIBNETSNMP_usmHMAC384SHA512AuthProtocol + *(void **) (&nut_usmHMAC384SHA512AuthProtocol) = lt_dlsym(dl_handle, + "usmHMAC384SHA512AuthProtocol"); + if ((dl_error = lt_dlerror()) != NULL) { + goto err; + } +#endif /* NUT_HAVE_LIBNETSNMP_usmHMAC384SHA512AuthProtocol */ return 1; + err: - fprintf(stderr, "Cannot load SNMP library (%s) : %s. SNMP search disabled.\n", libname_path, dl_error); + fprintf(stderr, "Cannot load SNMP library (%s) : %s. SNMP search disabled.\n", + libname_path, dl_error); dl_handle = (void *)1; lt_dlexit(); return 0; } /* end of dynamic link library stuff */ -static void scan_snmp_add_device(nutscan_snmp_t * sec, struct snmp_pdu *response,char * mib) +static void scan_snmp_add_device(nutscan_snmp_t * sec, struct snmp_pdu *response, char * mib) { nutscan_device_t * dev = NULL; struct snmp_session * session; char * buf; session = (*nut_snmp_sess_session)(sec->handle); - if(session == NULL) { + if (session == NULL) { return; } /* SNMP device found */ @@ -260,49 +362,53 @@ static void scan_snmp_add_device(nutscan_snmp_t * sec, struct snmp_pdu *response dev->type = TYPE_SNMP; dev->driver = strdup("snmp-ups"); dev->port = strdup(session->peername); - buf = malloc( response->variables->val_len + 1 ); - if( buf ) { - memcpy(buf,response->variables->val.string, - response->variables->val_len); - buf[response->variables->val_len]=0; - nutscan_add_option_to_device(dev,"desc",buf); - free(buf); + if (response != NULL) { + buf = malloc (response->variables->val_len + 1); + if (buf) { + memcpy(buf, response->variables->val.string, + response->variables->val_len); + buf[response->variables->val_len] = 0; + nutscan_add_option_to_device(dev, "desc", buf); + free(buf); + } } - nutscan_add_option_to_device(dev,"mibs",mib); + nutscan_add_option_to_device(dev, "mibs", mib); /* SNMP v3 */ - if( session->community == NULL || session->community[0] == 0) { - if( sec->secLevel ) { - nutscan_add_option_to_device(dev,"secLevel", - sec->secLevel); + if (session->community == NULL || session->community[0] == 0) { + nutscan_add_option_to_device(dev, "snmp_version", "v3"); + + if (sec->secLevel) { + nutscan_add_option_to_device(dev, "secLevel", + sec->secLevel); } - if( sec->secName ) { - nutscan_add_option_to_device(dev,"secName", - sec->secName); + if (sec->secName) { + nutscan_add_option_to_device(dev, "secName", + sec->secName); } - if( sec->authPassword ) { - nutscan_add_option_to_device(dev,"authPassword", - sec->authPassword); + if (sec->authPassword) { + nutscan_add_option_to_device(dev, "authPassword", + sec->authPassword); } - if( sec->privPassword ) { - nutscan_add_option_to_device(dev,"privPassword", - sec->privPassword); + if (sec->privPassword) { + nutscan_add_option_to_device(dev, "privPassword", + sec->privPassword); } - if( sec->authProtocol ) { - nutscan_add_option_to_device(dev,"authProtocol", - sec->authProtocol); + if (sec->authProtocol) { + nutscan_add_option_to_device(dev, "authProtocol", + sec->authProtocol); } - if( sec->privProtocol ) { - nutscan_add_option_to_device(dev,"privProtocol", - sec->privProtocol); + if (sec->privProtocol) { + nutscan_add_option_to_device(dev, "privProtocol", + sec->privProtocol); } } else { - buf = malloc( session->community_len + 1 ); - if( buf ) { - memcpy(buf,session->community, + buf = malloc (session->community_len + 1); + if (buf) { + memcpy(buf, session->community, session->community_len); - buf[session->community_len]=0; - nutscan_add_option_to_device(dev,"community",buf); + buf[session->community_len] = 0; + nutscan_add_option_to_device(dev, "community", buf); free(buf); } } @@ -310,17 +416,17 @@ static void scan_snmp_add_device(nutscan_snmp_t * sec, struct snmp_pdu *response #ifdef HAVE_PTHREAD pthread_mutex_lock(&dev_mutex); #endif - dev_ret = nutscan_add_device_to_device(dev_ret,dev); + dev_ret = nutscan_add_device_to_device(dev_ret, dev); #ifdef HAVE_PTHREAD pthread_mutex_unlock(&dev_mutex); #endif } -static struct snmp_pdu * scan_snmp_get_manufacturer(char* oid_str,void* handle) +static struct snmp_pdu * scan_snmp_get_oid(char* oid_str, void* handle) { - size_t name_len; - oid name[MAX_OID_LEN]; + size_t name_len; + oid name[MAX_OID_LEN]; struct snmp_pdu *pdu, *response = NULL; int status; int index = 0; @@ -341,19 +447,21 @@ static struct snmp_pdu * scan_snmp_get_manufacturer(char* oid_str,void* handle) (*nut_snmp_add_null_var)(pdu, name, name_len); - status = (*nut_snmp_sess_synch_response)(handle,pdu, &response); - if( response == NULL ) { + status = (*nut_snmp_sess_synch_response)(handle, pdu, &response); + if (response == NULL) { index++; return NULL; } - if(status!=STAT_SUCCESS||response->errstat!=SNMP_ERR_NOERROR|| - response->variables == NULL || - response->variables->name == NULL || - (*nut_snmp_oid_compare)(response->variables->name, - response->variables->name_length, - name, name_len) != 0 || - response->variables->val.string == NULL ) { + if (status != STAT_SUCCESS + || response->errstat != SNMP_ERR_NOERROR + || response->variables == NULL + || response->variables->name == NULL + || ((*nut_snmp_oid_compare)(response->variables->name, + response->variables->name_length, + name, name_len) != 0) + || response->variables->val.string == NULL + ) { (*nut_snmp_free_pdu)(response); index++; return NULL; @@ -362,21 +470,38 @@ static struct snmp_pdu * scan_snmp_get_manufacturer(char* oid_str,void* handle) return response; } -static void try_all_oid(void * arg) +static void try_all_oid(void * arg, const char * mib_found) { struct snmp_pdu *response = NULL; int index = 0; nutscan_snmp_t * sec = (nutscan_snmp_t *)arg; - while(snmp_device_table[index].oid != NULL) { + upsdebugx(2, "Entering %s for %s", __func__, sec->peername); - response = scan_snmp_get_manufacturer(snmp_device_table[index].oid,sec->handle); - if( response == NULL ) { + while (snmp_device_table[index].mib != NULL) { + + if (snmp_device_table[index].oid == NULL + || snmp_device_table[index].oid[0] == '\0' + ) { index++; continue; } - scan_snmp_add_device(sec,response,snmp_device_table[index].mib); + response = scan_snmp_get_oid(snmp_device_table[index].oid, sec->handle); + if (response == NULL) { + index++; + continue; + } + + /* add device only if not yet detected with the same mib */ + if (mib_found == NULL || (strcmp(mib_found, snmp_device_table[index].mib) != 0)) { + scan_snmp_add_device(sec, response, snmp_device_table[index].mib); + upsdebugx(3, "Found another match for device with MIB '%s'", + snmp_device_table[index].mib); + } + else { + upsdebugx(3, "Skip duplicated device %s", snmp_device_table[index].mib); + } (*nut_snmp_free_pdu)(response); response = NULL; @@ -391,9 +516,9 @@ static int init_session(struct snmp_session * snmp_sess, nutscan_snmp_t * sec) snmp_sess->peername = sec->peername; - if( sec->community != NULL || sec->secLevel == NULL ) { + if (sec->community != NULL || sec->secLevel == NULL) { snmp_sess->version = SNMP_VERSION_1; - if( sec->community != NULL ) { + if (sec->community != NULL) { snmp_sess->community = (unsigned char *)sec->community; snmp_sess->community_len = strlen(sec->community); } @@ -402,7 +527,7 @@ static int init_session(struct snmp_session * snmp_sess, nutscan_snmp_t * sec) snmp_sess->community_len = strlen("public"); } } - else { /* SNMP v3 */ + else { /* SNMP v3 */ snmp_sess->version = SNMP_VERSION_3; /* Security level */ @@ -413,130 +538,230 @@ static int init_session(struct snmp_session * snmp_sess, nutscan_snmp_t * sec) else if (strcmp(sec->secLevel, "authPriv") == 0) snmp_sess->securityLevel = SNMP_SEC_LEVEL_AUTHPRIV; else { - fprintf(stderr,"Bad SNMPv3 securityLevel: %s\n", - sec->secLevel); + fprintf(stderr, + "Bad SNMPv3 securityLevel: %s\n", + sec->secLevel); return 0; } /* Security name */ - if( sec->secName == NULL ) { - fprintf(stderr,"securityName is required for SNMPv3\n"); + if (sec->secName == NULL) { + fprintf(stderr, "securityName is required for SNMPv3\n"); return 0; } snmp_sess->securityName = strdup(sec->secName); snmp_sess->securityNameLen = strlen(snmp_sess->securityName); /* Everything is ready for NOAUTH */ - if( snmp_sess->securityLevel == SNMP_SEC_LEVEL_NOAUTH ) { + if (snmp_sess->securityLevel == SNMP_SEC_LEVEL_NOAUTH) { return 1; } /* Process mandatory fields, based on the security level */ - switch (snmp_sess->securityLevel) { - case SNMP_SEC_LEVEL_AUTHNOPRIV: - if (sec->authPassword == NULL) { - fprintf(stderr, - "authPassword is required for SNMPv3 in %s mode\n", + switch (snmp_sess->securityLevel) { + case SNMP_SEC_LEVEL_AUTHNOPRIV: + if (sec->authPassword == NULL) { + fprintf(stderr, + "authPassword is required " + "for SNMPv3 in %s mode\n", sec->secLevel); return 0; } break; - case SNMP_SEC_LEVEL_AUTHPRIV: - if ((sec->authPassword == NULL) || + case SNMP_SEC_LEVEL_AUTHPRIV: + if ((sec->authPassword == NULL) || (sec->privPassword == NULL)) { - fprintf(stderr, - "authPassword and privPassword are required for SNMPv3 in %s mode\n", + fprintf(stderr, + "authPassword and privPassword are " + "required for SNMPv3 in %s mode\n", sec->secLevel); return 0; } break; - default: - /* nothing else needed */ - break; - } + default: + /* nothing else needed */ + break; + } - /* Process authentication protocol and key */ - snmp_sess->securityAuthKeyLen = USM_AUTH_KU_LEN; + /* Process authentication protocol and key */ + snmp_sess->securityAuthKeyLen = USM_AUTH_KU_LEN; +#if NUT_HAVE_LIBNETSNMP_usmHMACMD5AuthProtocol /* default to MD5 */ - snmp_sess->securityAuthProto = (*nut_usmHMACMD5AuthProtocol); + snmp_sess->securityAuthProto = nut_usmHMACMD5AuthProtocol; snmp_sess->securityAuthProtoLen = - sizeof((*nut_usmHMACMD5AuthProtocol))/ - sizeof(oid); + sizeof(usmHMACMD5AuthProtocol)/ + sizeof(oid); +#endif - if( sec->authProtocol ) { + if (sec->authProtocol) { +#if NUT_HAVE_LIBNETSNMP_usmHMACSHA1AuthProtocol if (strcmp(sec->authProtocol, "SHA") == 0) { - snmp_sess->securityAuthProto = - (*nut_usmHMACSHA1AuthProtocol); + snmp_sess->securityAuthProto = nut_usmHMACSHA1AuthProtocol; snmp_sess->securityAuthProtoLen = - sizeof((*nut_usmHMACSHA1AuthProtocol))/ + sizeof(usmHMACSHA1AuthProtocol)/ sizeof(oid); } - else { - if (strcmp(sec->authProtocol, "MD5") != 0) { - fprintf(stderr, - "Bad SNMPv3 authProtocol: %s", - sec->authProtocol); - return 0; - } + else +#endif +#if NUT_HAVE_LIBNETSNMP_usmHMAC192SHA256AuthProtocol + if (strcmp(sec->authProtocol, "SHA256") == 0) { + snmp_sess->securityAuthProto = nut_usmHMAC192SHA256AuthProtocol; + snmp_sess->securityAuthProtoLen = + sizeof(usmHMAC192SHA256AuthProtocol)/ + sizeof(oid); + } + else +#endif +#if NUT_HAVE_LIBNETSNMP_usmHMAC256SHA384AuthProtocol + if (strcmp(sec->authProtocol, "SHA384") == 0) { + snmp_sess->securityAuthProto = nut_usmHMAC256SHA384AuthProtocol; + snmp_sess->securityAuthProtoLen = + sizeof(usmHMAC256SHA384AuthProtocol)/ + sizeof(oid); + } + else +#endif +#if NUT_HAVE_LIBNETSNMP_usmHMAC384SHA512AuthProtocol + if (strcmp(sec->authProtocol, "SHA512") == 0) { + snmp_sess->securityAuthProto = nut_usmHMAC384SHA512AuthProtocol; + snmp_sess->securityAuthProtoLen = + sizeof(usmHMAC384SHA512AuthProtocol)/ + sizeof(oid); + } + else +#endif +#if NUT_HAVE_LIBNETSNMP_usmHMACMD5AuthProtocol + if (strcmp(sec->authProtocol, "MD5") != 0) { +#else + { +#endif + fprintf(stderr, + "Bad SNMPv3 authProtocol: %s\n", + sec->authProtocol); + return 0; } } /* set the authentication key to a MD5/SHA1 hashed version of * our passphrase (must be at least 8 characters long) */ +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) ) +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE +# pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif + if ((uintmax_t)snmp_sess->securityAuthProtoLen > UINT_MAX) { +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) ) +# pragma GCC diagnostic pop +#endif + fprintf(stderr, "Bad SNMPv3 securityAuthProtoLen: %zu", + snmp_sess->securityAuthProtoLen); + return 0; + } if ((*nut_generate_Ku)(snmp_sess->securityAuthProto, - snmp_sess->securityAuthProtoLen, - (u_char *) sec->authPassword, + (u_int)snmp_sess->securityAuthProtoLen, + (unsigned char *) sec->authPassword, strlen(sec->authPassword), snmp_sess->securityAuthKey, &snmp_sess->securityAuthKeyLen) - != SNMPERR_SUCCESS) { - fprintf(stderr, - "Error generating Ku from authentication pass phrase\n"); - return 0; + != SNMPERR_SUCCESS + ) { + fprintf(stderr, + "Error generating Ku from " + "authentication pass phrase\n"); + return 0; } /* Everything is ready for AUTHNOPRIV */ - if( snmp_sess->securityLevel == SNMP_SEC_LEVEL_AUTHNOPRIV ) { + if (snmp_sess->securityLevel == SNMP_SEC_LEVEL_AUTHNOPRIV) { return 1; } +#if NUT_HAVE_LIBNETSNMP_usmDESPrivProtocol /* default to DES */ - snmp_sess->securityPrivProto=(*nut_usmDESPrivProtocol); + snmp_sess->securityPrivProto = nut_usmDESPrivProtocol; snmp_sess->securityPrivProtoLen = - sizeof((*nut_usmDESPrivProtocol))/sizeof(oid); + sizeof(usmDESPrivProtocol)/sizeof(oid); +#endif - if( sec->privProtocol ) { + if (sec->privProtocol) { +#if NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol || NUT_HAVE_LIBNETSNMP_usmAES128PrivProtocol if (strcmp(sec->privProtocol, "AES") == 0) { - snmp_sess->securityPrivProto= - (*nut_usmAESPrivProtocol); - snmp_sess->securityPrivProtoLen = - sizeof((*nut_usmAESPrivProtocol))/ + snmp_sess->securityPrivProto = nut_usmAESPrivProtocol; + snmp_sess->securityPrivProtoLen = + sizeof(usmAESPrivProtocol)/ sizeof(oid); } - else { - if (strcmp(sec->privProtocol, "DES") != 0) { - fprintf(stderr, - "Bad SNMPv3 authProtocol: %s\n" - ,sec->authProtocol); + else +#endif +#if NUT_HAVE_LIBNETSNMP_DRAFT_BLUMENTHAL_AES_04 +# if NUT_HAVE_LIBNETSNMP_usmAES192PrivProtocol + if (strcmp(sec->privProtocol, "AES192") == 0) { + snmp_sess->securityPrivProto = nut_usmAES192PrivProtocol; + snmp_sess->securityPrivProtoLen = + sizeof(usmAES192PrivProtocol)/ + sizeof(oid); + } + else +# endif +# if NUT_HAVE_LIBNETSNMP_usmAES256PrivProtocol + if (strcmp(sec->privProtocol, "AES256") == 0) { + snmp_sess->securityPrivProto = nut_usmAES256PrivProtocol; + snmp_sess->securityPrivProtoLen = + sizeof(usmAES256PrivProtocol)/ + sizeof(oid); + } + else +# endif +#endif /* NUT_HAVE_LIBNETSNMP_DRAFT_BLUMENTHAL_AES_04 */ +#if NUT_HAVE_LIBNETSNMP_usmDESPrivProtocol + if (strcmp(sec->privProtocol, "DES") != 0) { +#else + { +#endif + fprintf(stderr, + "Bad SNMPv3 privProtocol: %s\n", + sec->privProtocol); return 0; - } } } /* set the private key to a MD5/SHA hashed version of * our passphrase (must be at least 8 characters long) */ snmp_sess->securityPrivKeyLen = USM_PRIV_KU_LEN; +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) ) +# pragma GCC diagnostic push +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif +#ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE +# pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" +#endif + if ((uintmax_t)snmp_sess->securityAuthProtoLen > UINT_MAX) { +#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && ( (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TYPE_LIMITS) || (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE) ) +# pragma GCC diagnostic pop +#endif + fprintf(stderr, "Bad SNMPv3 securityAuthProtoLen: %zu", + snmp_sess->securityAuthProtoLen); + return 0; + } if ((*nut_generate_Ku)(snmp_sess->securityAuthProto, - snmp_sess->securityAuthProtoLen, - (u_char *) sec->privPassword, + (u_int)snmp_sess->securityAuthProtoLen, + (unsigned char *) sec->privPassword, strlen(sec->privPassword), snmp_sess->securityPrivKey, &snmp_sess->securityPrivKeyLen) - != SNMPERR_SUCCESS) { - fprintf(stderr, - "Error generating Ku from private pass phrase\n"); - return 0; + != SNMPERR_SUCCESS + ) { + fprintf(stderr, + "Error generating Ku from " + "private pass phrase\n"); + return 0; } } @@ -549,32 +774,40 @@ static void * try_SysOID(void * arg) struct snmp_session snmp_sess; void * handle; struct snmp_pdu *pdu, *response = NULL, *resp = NULL; - oid name[MAX_OID_LEN]; - size_t name_len = MAX_OID_LEN; + oid name[MAX_OID_LEN]; + size_t name_len = MAX_OID_LEN; nutscan_snmp_t * sec = (nutscan_snmp_t *)arg; int index = 0; - int sysoid_found = 0; + char *mib_found = NULL; + + upsdebugx(2, "Entering %s for %s", __func__, sec->peername); /* Initialize session */ - if( !init_session(&snmp_sess,sec) ) { + if (!init_session(&snmp_sess, sec)) { goto try_SysOID_free; } - + snmp_sess.retries = 0; - snmp_sess.timeout = g_usec_timeout; + /* netsnmp timeout is accounted in uS, but typed as long + * and not useconds_t (which is at most long per POSIX) + */ + snmp_sess.timeout = (long)g_usec_timeout; /* Open the session */ handle = (*nut_snmp_sess_open)(&snmp_sess); /* establish the session */ if (handle == NULL) { - fprintf(stderr,"Failed to open SNMP session for %s.\n", + upsdebugx(2, + "Failed to open SNMP session for %s", sec->peername); goto try_SysOID_free; } /* create and send request. */ if (!(*nut_snmp_parse_oid)(SysOID, name, &name_len)) { - fprintf(stderr,"SNMP errors: %s\n", - (*nut_snmp_api_errstring)((*nut_snmp_errno))); + upsdebugx(2, + "SNMP errors for %s: %s", + sec->peername, + (*nut_snmp_api_errstring)((*nut_snmp_errno))); (*nut_snmp_sess_close)(handle); goto try_SysOID_free; } @@ -582,7 +815,7 @@ static void * try_SysOID(void * arg) pdu = (*nut_snmp_pdu_create)(SNMP_MSG_GET); if (pdu == NULL) { - fprintf(stderr,"Not enough memory\n"); + fprintf(stderr, "Not enough memory\n"); (*nut_snmp_sess_close)(handle); goto try_SysOID_free; } @@ -599,44 +832,58 @@ static void * try_SysOID(void * arg) /* SysOID is supposed to give the required MIB. */ /* Check if the received OID match with a known sysOID */ - if(response->variables != NULL && - response->variables->val.objid != NULL){ - while(snmp_device_table[index].oid != NULL) { - if(snmp_device_table[index].sysoid == NULL ) { + if (response->variables != NULL && + response->variables->val.objid != NULL + ) { + while (snmp_device_table[index].mib != NULL) { + if (snmp_device_table[index].sysoid == NULL) { index++; continue; } name_len = MAX_OID_LEN; + if (!(*nut_snmp_parse_oid)( snmp_device_table[index].sysoid, - name, &name_len)) { + name, &name_len) + ) { index++; continue; } - if ( (*nut_snmp_oid_compare)( + if ((*nut_snmp_oid_compare)( response->variables->val.objid, response->variables->val_len/sizeof(oid), - name, name_len) == 0 ) { - /* we have found a relevent sysoid */ - resp = scan_snmp_get_manufacturer( - snmp_device_table[index].oid, - handle); - if( resp != NULL ) { - scan_snmp_add_device(sec,resp, - snmp_device_table[index].mib); - sysoid_found = 1; - (*nut_snmp_free_pdu)(resp); + name, name_len) == 0 + ) { + /* we have found a relevant sysoid */ + + /* add mib if no complementary oid is present */ + /* FIXME: No desc defined when add device */ + if (snmp_device_table[index].oid == NULL + || snmp_device_table[index].oid[0] == '\0' + ) { + scan_snmp_add_device(sec, NULL, snmp_device_table[index].mib); + mib_found = snmp_device_table[index].sysoid; + } + /* else test complementary oid before adding mib */ + else { + resp = scan_snmp_get_oid( + snmp_device_table[index].oid, + handle); + if (resp != NULL) { + scan_snmp_add_device(sec, resp, snmp_device_table[index].mib); + mib_found = snmp_device_table[index].mib; + (*nut_snmp_free_pdu)(resp); + } } } index++; } } - /* try a list of known OID */ - if( !sysoid_found ) { - try_all_oid(sec); - } + /* try a list of known OID, if no device was found otherwise */ + if (mib_found == NULL) + try_all_oid(sec, mib_found); (*nut_snmp_free_pdu)(response); response = NULL; @@ -645,7 +892,7 @@ static void * try_SysOID(void * arg) (*nut_snmp_sess_close)(handle); try_SysOID_free: - if( sec->peername ) { + if (sec->peername) { free(sec->peername); } free(sec); @@ -653,66 +900,295 @@ try_SysOID_free: return NULL; } -nutscan_device_t * nutscan_scan_snmp(const char * start_ip, const char * stop_ip,long usec_timeout, nutscan_snmp_t * sec) +nutscan_device_t * nutscan_scan_snmp(const char * start_ip, const char * stop_ip, + useconds_t usec_timeout, nutscan_snmp_t * sec) { - int i; + bool_t pass = TRUE; /* Track that we may spawn a scanning thread */ nutscan_snmp_t * tmp_sec; nutscan_ip_iter_t ip; char * ip_str = NULL; #ifdef HAVE_PTHREAD +# ifdef HAVE_SEMAPHORE + sem_t * semaphore = nutscan_semaphore(); + sem_t semaphore_scantype_inst; + sem_t * semaphore_scantype = &semaphore_scantype_inst; +# endif /* HAVE_SEMAPHORE */ pthread_t thread; - pthread_t * thread_array = NULL; - int thread_count = 0; + nutscan_thread_t * thread_array = NULL; + size_t thread_count = 0, i; +# if (defined HAVE_PTHREAD_TRYJOIN) || (defined HAVE_SEMAPHORE) + size_t max_threads_scantype = max_threads_netsnmp; +# endif - pthread_mutex_init(&dev_mutex,NULL); -#endif + pthread_mutex_init(&dev_mutex, NULL); - if( !nutscan_avail_snmp ) { - return NULL; - } +# ifdef HAVE_SEMAPHORE + if (max_threads_scantype > 0) { + if (SIZE_MAX > UINT_MAX && max_threads_scantype > UINT_MAX) { + upsdebugx(1, + "WARNING: %s: Limiting max_threads_scantype to range acceptable for sem_init()", + __func__); + max_threads_scantype = UINT_MAX - 1; + } + sem_init(semaphore_scantype, 0, (unsigned int)max_threads_scantype); + } +# endif /* HAVE_SEMAPHORE */ +#endif /* HAVE_PTHREAD */ + + if (!nutscan_avail_snmp) { + return NULL; + } g_usec_timeout = usec_timeout; + /* Force numeric OIDs resolution (ie, do not resolve to textual names) + * This is mostly for the convenience of debug output */ + if (nut_snmp_out_toggle_options("n") != NULL) { + upsdebugx(1, "Failed to enable numeric OIDs resolution"); + } + /* Initialize the SNMP library */ (*nut_init_snmp)("nut-scanner"); ip_str = nutscan_ip_iter_init(&ip, start_ip, stop_ip); - while(ip_str != NULL) { - tmp_sec = malloc(sizeof(nutscan_snmp_t)); - memcpy(tmp_sec, sec, sizeof(nutscan_snmp_t)); - tmp_sec->peername = ip_str; - + while (ip_str != NULL) { #ifdef HAVE_PTHREAD - if (pthread_create(&thread,NULL,try_SysOID,(void*)tmp_sec)==0){ - thread_count++; - thread_array = realloc(thread_array, - thread_count*sizeof(pthread_t)); - thread_array[thread_count-1] = thread; + /* NOTE: With many enough targets to scan, this can crash + * by spawning too many children; add a limit and loop to + * "reap" some already done with their work. And probably + * account them in thread_array[] as something to not wait + * for below in pthread_join()... + */ + +# ifdef HAVE_SEMAPHORE + /* Just wait for someone to free a semaphored slot, + * if none are available, and then/otherwise grab one + */ + if (thread_array == NULL) { + /* Starting point, or after a wait to complete + * all earlier runners */ + if (max_threads_scantype > 0) + sem_wait(semaphore_scantype); + sem_wait(semaphore); + pass = TRUE; + } else { + pass = ((max_threads_scantype == 0 || sem_trywait(semaphore_scantype) == 0) && + sem_trywait(semaphore) == 0); } -#else - try_SysOID((void *)tmp_sec); -#endif - ip_str = nutscan_ip_iter_inc(&ip); - }; +# else +# ifdef HAVE_PTHREAD_TRYJOIN + /* A somewhat naive and brute-force solution for + * systems without a semaphore.h. This may suffer + * some off-by-one errors, using a few more threads + * than intended (if we race a bit at the wrong time, + * probably up to one per enabled scanner routine). + */ + + /* TOTHINK: Should there be a threadcount_mutex when + * we just read the value in if() and while() below? + * At worst we would overflow the limit a bit due to + * other protocol scanners... + */ + if (curr_threads >= max_threads + || (curr_threads >= max_threads_scantype && max_threads_scantype > 0) + ) { + upsdebugx(2, "%s: already running %zu scanning threads " + "(launched overall: %zu), " + "waiting until some would finish", + __func__, curr_threads, thread_count); + while (curr_threads >= max_threads + || (curr_threads >= max_threads_scantype && max_threads_scantype > 0) + ) { + for (i = 0; i < thread_count ; i++) { + int ret; + + if (!thread_array[i].active) continue; + + pthread_mutex_lock(&threadcount_mutex); + upsdebugx(3, "%s: Trying to join thread #%i...", __func__, i); + ret = pthread_tryjoin_np(thread_array[i].thread, NULL); + switch (ret) { + case ESRCH: /* No thread with the ID thread could be found - already "joined"? */ + upsdebugx(5, "%s: Was thread #%zu joined earlier?", __func__, i); + break; + case 0: /* thread exited */ + if (curr_threads > 0) { + curr_threads --; + upsdebugx(4, "%s: Joined a finished thread #%zu", __func__, i); + } else { + /* threadcount_mutex fault? */ + upsdebugx(0, "WARNING: %s: Accounting of thread count " + "says we are already at 0", __func__); + } + thread_array[i].active = FALSE; + break; + case EBUSY: /* actively running */ + upsdebugx(6, "%s: thread #%zu still busy (%i)", + __func__, i, ret); + break; + case EDEADLK: /* Errors with thread interactions... bail out? */ + case EINVAL: /* Errors with thread interactions... bail out? */ + default: /* new pthreads abilities? */ + upsdebugx(5, "%s: thread #%zu reported code %i", + __func__, i, ret); + break; + } + pthread_mutex_unlock(&threadcount_mutex); + } + + if (curr_threads >= max_threads + || (curr_threads >= max_threads_scantype && max_threads_scantype > 0) + ) { + usleep (10000); /* microSec's, so 0.01s here */ + } + } + upsdebugx(2, "%s: proceeding with scan", __func__); + } + /* NOTE: No change to default "pass" in this ifdef: + * if we got to this line, we have a slot to use */ +# endif /* HAVE_PTHREAD_TRYJOIN */ +# endif /* HAVE_SEMAPHORE */ +#endif /* HAVE_PTHREAD */ + + if (pass) { + tmp_sec = malloc(sizeof(nutscan_snmp_t)); + memcpy(tmp_sec, sec, sizeof(nutscan_snmp_t)); + tmp_sec->peername = ip_str; #ifdef HAVE_PTHREAD - for ( i=0; i < thread_count ; i++) { - pthread_join(thread_array[i],NULL); + if (pthread_create(&thread, NULL, try_SysOID, (void*)tmp_sec) == 0) { +# ifdef HAVE_PTHREAD_TRYJOIN + pthread_mutex_lock(&threadcount_mutex); + curr_threads++; +# endif /* HAVE_PTHREAD_TRYJOIN */ + + thread_count++; + nutscan_thread_t *new_thread_array = realloc(thread_array, + thread_count * sizeof(nutscan_thread_t)); + if (new_thread_array == NULL) { + upsdebugx(1, "%s: Failed to realloc thread array", __func__); + break; + } + else { + thread_array = new_thread_array; + } + thread_array[thread_count - 1].thread = thread; + thread_array[thread_count - 1].active = TRUE; + +# ifdef HAVE_PTHREAD_TRYJOIN + pthread_mutex_unlock(&threadcount_mutex); +# endif /* HAVE_PTHREAD_TRYJOIN */ + } +#else /* not HAVE_PTHREAD */ + try_SysOID((void *)tmp_sec); +#endif /* if HAVE_PTHREAD */ +/* free(ip_str); */ /* Do not free() here - seems to cause a double-free instead */ + ip_str = nutscan_ip_iter_inc(&ip); +/* free(tmp_sec); */ + } else { /* if not pass -- all slots busy */ +#ifdef HAVE_PTHREAD +# ifdef HAVE_SEMAPHORE + /* Wait for all current scans to complete */ + if (thread_array != NULL) { + upsdebugx (2, "%s: Running too many scanning threads, " + "waiting until older ones would finish", + __func__); + for (i = 0; i < thread_count ; i++) { + int ret; + if (!thread_array[i].active) { + /* Probably should not get here, + * but handle it just in case */ + upsdebugx(0, "WARNING: %s: Midway clean-up: did not expect thread %zu to be not active", + __func__, i); + sem_post(semaphore); + if (max_threads_scantype > 0) + sem_post(semaphore_scantype); + continue; + } + thread_array[i].active = FALSE; + ret = pthread_join(thread_array[i].thread, NULL); + if (ret != 0) { + upsdebugx(0, "WARNING: %s: Midway clean-up: pthread_join() returned code %i", + __func__, ret); + } + sem_post(semaphore); + if (max_threads_scantype > 0) + sem_post(semaphore_scantype); + } + thread_count = 0; + free(thread_array); + thread_array = NULL; + } +# else +# ifdef HAVE_PTHREAD_TRYJOIN + /* TODO: Move the wait-loop for TRYJOIN here? */ +# endif /* HAVE_PTHREAD_TRYJOIN */ +# endif /* HAVE_SEMAPHORE */ +#endif /* HAVE_PTHREAD */ + } /* if: could we "pass" or not? */ + } /* while */ + +#ifdef HAVE_PTHREAD + if (thread_array != NULL) { + upsdebugx(2, "%s: all planned scans launched, waiting for threads to complete", __func__); + for (i = 0; i < thread_count; i++) { + int ret; + + if (!thread_array[i].active) continue; + + ret = pthread_join(thread_array[i].thread, NULL); + if (ret != 0) { + upsdebugx(0, "WARNING: %s: Clean-up: pthread_join() returned code %i", + __func__, ret); + } + thread_array[i].active = FALSE; +# ifdef HAVE_SEMAPHORE + sem_post(semaphore); + if (max_threads_scantype > 0) + sem_post(semaphore_scantype); +# else +# ifdef HAVE_PTHREAD_TRYJOIN + pthread_mutex_lock(&threadcount_mutex); + if (curr_threads > 0) { + curr_threads --; + upsdebugx(5, "%s: Clean-up: Joined a finished thread #%zu", + __func__, i); + } else { + upsdebugx(0, "WARNING: %s: Clean-up: Accounting of thread count " + "says we are already at 0", __func__); + } + pthread_mutex_unlock(&threadcount_mutex); +# endif /* HAVE_PTHREAD_TRYJOIN */ +# endif /* HAVE_SEMAPHORE */ + } + free(thread_array); + upsdebugx(2, "%s: all threads freed", __func__); } pthread_mutex_destroy(&dev_mutex); - free(thread_array); -#endif + +# ifdef HAVE_SEMAPHORE + if (max_threads_scantype > 0) + sem_destroy(semaphore_scantype); +# endif /* HAVE_SEMAPHORE */ +#endif /* HAVE_PTHREAD */ + nutscan_device_t * result = nutscan_rewind_device(dev_ret); dev_ret = NULL; return result; } + #else /* WITH_SNMP */ -nutscan_device_t * nutscan_scan_snmp(const char * start_ip, const char * stop_ip,long usec_timeout, nutscan_snmp_t * sec) + +nutscan_device_t * nutscan_scan_snmp(const char * start_ip, const char * stop_ip, + useconds_t usec_timeout, nutscan_snmp_t * sec) { + NUT_UNUSED_VARIABLE(start_ip); + NUT_UNUSED_VARIABLE(stop_ip); + NUT_UNUSED_VARIABLE(usec_timeout); + NUT_UNUSED_VARIABLE(sec); return NULL; } + #endif /* WITH_SNMP */ - - diff --git a/tools/nut-scanner/scan_usb.c b/tools/nut-scanner/scan_usb.c index 1027e93..a828827 100644 --- a/tools/nut-scanner/scan_usb.c +++ b/tools/nut-scanner/scan_usb.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 - EATON + * Copyright (C) 2011-2016 - EATON * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,7 @@ /*! \file scan_usb.c \brief detect NUT supported USB devices \author Frederic Bohe + \author Arnaud Quette */ #include "common.h" @@ -34,22 +35,46 @@ /* dynamic link library stuff */ static lt_dlhandle dl_handle = NULL; static const char *dl_error = NULL; -static int (*nut_usb_close)(usb_dev_handle *dev); -static int (*nut_usb_find_busses)(void); -static char * (*nut_usb_strerror)(void); -static void (*nut_usb_init)(void); -static int (*nut_usb_get_string_simple)(usb_dev_handle *dev, int index, +static int (*nut_usb_close)(libusb_device_handle *dev); +static int (*nut_usb_get_string_simple)(libusb_device_handle *dev, int index, char *buf, size_t buflen); -static struct usb_bus * (*nut_usb_busses); -static usb_dev_handle * (*nut_usb_open)(struct usb_device *dev); -static int (*nut_usb_find_devices)(void); -/* return 0 on error */ + +/* Compatibility layer between libusb 0.1 and 1.0 */ +#if WITH_LIBUSB_1_0 + #define USB_INIT_SYMBOL "libusb_init" + #define USB_OPEN_SYMBOL "libusb_open" + #define USB_CLOSE_SYMBOL "libusb_close" + #define USB_STRERROR_SYMBOL "libusb_strerror" + static int (*nut_usb_open)(libusb_device *dev, libusb_device_handle **handle); + static int (*nut_usb_init)(libusb_context **ctx); + static void (*nut_usb_exit)(libusb_context *ctx); + static char * (*nut_usb_strerror)(enum libusb_error errcode); + static ssize_t (*nut_usb_get_device_list)(libusb_context *ctx, libusb_device ***list); + static void (*nut_usb_free_device_list)(libusb_device **list, int unref_devices); + static uint8_t (*nut_usb_get_bus_number)(libusb_device *dev); + static int (*nut_usb_get_device_descriptor)(libusb_device *dev, + struct libusb_device_descriptor *desc); +#else + #define USB_INIT_SYMBOL "usb_init" + #define USB_OPEN_SYMBOL "usb_open" + #define USB_CLOSE_SYMBOL "usb_close" + #define USB_STRERROR_SYMBOL "usb_strerror" + static libusb_device_handle * (*nut_usb_open)(struct usb_device *dev); + static void (*nut_usb_init)(void); + static int (*nut_usb_find_busses)(void); + static struct usb_bus * (*nut_usb_busses); + static int (*nut_usb_find_devices)(void); + static char * (*nut_usb_strerror)(void); +#endif + +/* return 0 on error; visible externally */ +int nutscan_load_usb_library(const char *libname_path); int nutscan_load_usb_library(const char *libname_path) { - if( dl_handle != NULL ) { + if (dl_handle != NULL) { /* if previous init failed */ - if( dl_handle == (void *)1 ) { + if (dl_handle == (void *)1) { return 0; } /* init has already been done */ @@ -61,7 +86,7 @@ int nutscan_load_usb_library(const char *libname_path) return 0; } - if( lt_dlinit() != 0 ) { + if (lt_dlinit() != 0) { fprintf(stderr, "Error initializing lt_init\n"); return 0; } @@ -71,49 +96,84 @@ int nutscan_load_usb_library(const char *libname_path) dl_error = lt_dlerror(); goto err; } + + *(void **) (&nut_usb_init) = lt_dlsym(dl_handle, USB_INIT_SYMBOL); + if ((dl_error = lt_dlerror()) != NULL) { + goto err; + } + + *(void **) (&nut_usb_open) = lt_dlsym(dl_handle, USB_OPEN_SYMBOL); + if ((dl_error = lt_dlerror()) != NULL) { + goto err; + } + lt_dlerror(); /* Clear any existing error */ - *(void **) (&nut_usb_close) = lt_dlsym(dl_handle, "usb_close"); - if ((dl_error = lt_dlerror()) != NULL) { + *(void **) (&nut_usb_close) = lt_dlsym(dl_handle, USB_CLOSE_SYMBOL); + if ((dl_error = lt_dlerror()) != NULL) { goto err; } + *(void **) (&nut_usb_strerror) = lt_dlsym(dl_handle, USB_STRERROR_SYMBOL); + if ((dl_error = lt_dlerror()) != NULL) { + goto err; + } + +#if WITH_LIBUSB_1_0 + *(void **) (&nut_usb_exit) = lt_dlsym(dl_handle, "libusb_exit"); + if ((dl_error = lt_dlerror()) != NULL) { + goto err; + } + + *(void **) (&nut_usb_get_device_list) = lt_dlsym(dl_handle, "libusb_get_device_list"); + if ((dl_error = lt_dlerror()) != NULL) { + goto err; + } + + *(void **) (&nut_usb_free_device_list) = lt_dlsym(dl_handle, "libusb_free_device_list"); + if ((dl_error = lt_dlerror()) != NULL) { + goto err; + } + + *(void **) (&nut_usb_get_bus_number) = lt_dlsym(dl_handle, "libusb_get_bus_number"); + if ((dl_error = lt_dlerror()) != NULL) { + goto err; + } + + *(void **) (&nut_usb_get_device_descriptor) = lt_dlsym(dl_handle, "libusb_get_device_descriptor"); + if ((dl_error = lt_dlerror()) != NULL) { + goto err; + } + + *(void **) (&nut_usb_get_string_simple) = lt_dlsym(dl_handle, + "libusb_get_string_descriptor_ascii"); + if ((dl_error = lt_dlerror()) != NULL) { + goto err; + } +#else /* for libusb 0.1 */ *(void **) (&nut_usb_find_busses) = lt_dlsym(dl_handle, "usb_find_busses"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } - *(void **) (&nut_usb_strerror) = lt_dlsym(dl_handle, "usb_strerror"); - if ((dl_error = lt_dlerror()) != NULL) { + *(void **) (&nut_usb_busses) = lt_dlsym(dl_handle, "usb_busses"); + if ((dl_error = lt_dlerror()) != NULL) { goto err; } - *(void **) (&nut_usb_init) = lt_dlsym(dl_handle, "usb_init"); - if ((dl_error = lt_dlerror()) != NULL) { + *(void **)(&nut_usb_find_devices) = lt_dlsym(dl_handle, "usb_find_devices"); + if ((dl_error = lt_dlerror()) != NULL) { goto err; } *(void **) (&nut_usb_get_string_simple) = lt_dlsym(dl_handle, "usb_get_string_simple"); - if ((dl_error = lt_dlerror()) != NULL) { - goto err; - } - - *(void **) (&nut_usb_busses) = lt_dlsym(dl_handle, "usb_busses"); - if ((dl_error = lt_dlerror()) != NULL) { - goto err; - } - - *(void **) (&nut_usb_open) = lt_dlsym(dl_handle, "usb_open"); - if ((dl_error = lt_dlerror()) != NULL) { - goto err; - } - - *(void **)(&nut_usb_find_devices) = lt_dlsym(dl_handle,"usb_find_devices"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } +#endif /* WITH_LIBUSB_1_0 */ return 1; + err: fprintf(stderr, "Cannot load USB library (%s) : %s. USB search disabled.\n", libname_path, dl_error); dl_handle = (void *)1; @@ -127,10 +187,10 @@ static char* is_usb_device_supported(usb_device_id_t *usb_device_id_list, { usb_device_id_t *usbdev; - for (usbdev=usb_device_id_list; usbdev->driver_name != NULL; usbdev++) { - if ( (usbdev->vendorID == dev_VendorID) - && (usbdev->productID == dev_ProductID) ) { - + for (usbdev = usb_device_id_list; usbdev->driver_name != NULL; usbdev++) { + if ((usbdev->vendorID == dev_VendorID) + && (usbdev->productID == dev_ProductID) + ) { return usbdev->driver_name; } } @@ -147,128 +207,259 @@ nutscan_device_t * nutscan_scan_usb() char *serialnumber = NULL; char *device_name = NULL; char *vendor_name = NULL; + uint8_t iManufacturer = 0, iProduct = 0, iSerialNumber = 0; + uint16_t VendorID; + uint16_t ProductID; + char *busname; +#if WITH_LIBUSB_1_0 + libusb_device *dev; + libusb_device **devlist; + uint8_t bus; +#else /* => WITH_LIBUSB_0_1 */ struct usb_device *dev; struct usb_bus *bus; - usb_dev_handle *udev; +#endif /* WITH_LIBUSB_1_0 */ + libusb_device_handle *udev; nutscan_device_t * nut_dev = NULL; nutscan_device_t * current_nut_dev = NULL; - if( !nutscan_avail_usb ) { - return NULL; - } + if (!nutscan_avail_usb) { + return NULL; + } /* libusb base init */ + /* Initialize Libusb */ +#if WITH_LIBUSB_1_0 + if ((*nut_usb_init)(NULL) < 0) { + (*nut_usb_exit)(NULL); + fatal_with_errno(EXIT_FAILURE, "Failed to init libusb 1.0"); + } +#else /* => WITH_LIBUSB_0_1 */ (*nut_usb_init)(); (*nut_usb_find_busses)(); (*nut_usb_find_devices)(); +#endif /* WITH_LIBUSB_1_0 */ +#if WITH_LIBUSB_1_0 + ssize_t devcount = 0; + struct libusb_device_descriptor dev_desc; + int i; + + devcount = (*nut_usb_get_device_list)(NULL, &devlist); + if (devcount <= 0) { + (*nut_usb_exit)(NULL); + fatal_with_errno(EXIT_FAILURE, "No USB device found"); + } + + for (i = 0; i < devcount; i++) { + + dev = devlist[i]; + (*nut_usb_get_device_descriptor)(dev, &dev_desc); + + VendorID = dev_desc.idVendor; + ProductID = dev_desc.idProduct; + + iManufacturer = dev_desc.iManufacturer; + iProduct = dev_desc.iProduct; + iSerialNumber = dev_desc.iSerialNumber; + bus = (*nut_usb_get_bus_number)(dev); + busname = (char *)malloc(4); + if (busname == NULL) { + (*nut_usb_free_device_list)(devlist, 1); + (*nut_usb_exit)(NULL); + fatal_with_errno(EXIT_FAILURE, "Out of memory"); + } + snprintf(busname, 4, "%03d", bus); +#else /* => WITH_LIBUSB_0_1 */ for (bus = (*nut_usb_busses); bus; bus = bus->next) { for (dev = bus->devices; dev; dev = dev->next) { + + VendorID = dev->descriptor.idVendor; + ProductID = dev->descriptor.idProduct; + + iManufacturer = dev->descriptor.iManufacturer; + iProduct = dev->descriptor.iProduct; + iSerialNumber = dev->descriptor.iSerialNumber; + busname = bus->dirname; +#endif if ((driver_name = is_usb_device_supported(usb_device_table, - dev->descriptor.idVendor, - dev->descriptor.idProduct)) != NULL) { + VendorID, ProductID)) != NULL) { /* open the device */ +#if WITH_LIBUSB_1_0 + ret = (*nut_usb_open)(dev, &udev); + if (!udev || ret != LIBUSB_SUCCESS) { + fprintf(stderr,"Failed to open device " + "bus '%s', skipping: %s\n", + busname, + (*nut_usb_strerror)(ret)); + + /* Note: closing is not applicable + * it seems, and can even segfault + * (even though an udev is not NULL + * when e.g. permissions problem) + */ + + free (busname); + + continue; + } +#else /* => WITH_LIBUSB_0_1 */ udev = (*nut_usb_open)(dev); if (!udev) { - fprintf(stderr,"Failed to open device, \ - skipping. (%s)\n", + /* TOTHINK: any errno or similar to test? */ + fprintf(stderr, "Failed to open device " + "bus '%s',skipping: %s\n", + busname, (*nut_usb_strerror)()); continue; } +#endif /* get serial number */ - if (dev->descriptor.iSerialNumber) { + if (iSerialNumber) { ret = (*nut_usb_get_string_simple)(udev, - dev->descriptor.iSerialNumber, - string, sizeof(string)); + iSerialNumber, string, sizeof(string)); if (ret > 0) { serialnumber = strdup(str_rtrim(string, ' ')); + if (serialnumber == NULL) { + (*nut_usb_close)(udev); +#if WITH_LIBUSB_1_0 + free(busname); + (*nut_usb_free_device_list)(devlist, 1); + (*nut_usb_exit)(NULL); +#endif /* WITH_LIBUSB_1_0 */ + fatal_with_errno(EXIT_FAILURE, "Out of memory"); + } } } + /* get product name */ - if (dev->descriptor.iProduct) { + if (iProduct) { ret = (*nut_usb_get_string_simple)(udev, - dev->descriptor.iProduct, - string, sizeof(string)); + iProduct, string, sizeof(string)); if (ret > 0) { device_name = strdup(str_rtrim(string, ' ')); + if (device_name == NULL) { + free(serialnumber); + (*nut_usb_close)(udev); +#if WITH_LIBUSB_1_0 + free(busname); + (*nut_usb_free_device_list)(devlist, 1); + (*nut_usb_exit)(NULL); +#endif /* WITH_LIBUSB_1_0 */ + fatal_with_errno(EXIT_FAILURE, "Out of memory"); + } } } /* get vendor name */ - if (dev->descriptor.iManufacturer) { + if (iManufacturer) { ret = (*nut_usb_get_string_simple)(udev, - dev->descriptor.iManufacturer, - string, sizeof(string)); + iManufacturer, string, sizeof(string)); if (ret > 0) { vendor_name = strdup(str_rtrim(string, ' ')); + if (vendor_name == NULL) { + free(serialnumber); + free(device_name); + (*nut_usb_close)(udev); +#if WITH_LIBUSB_1_0 + free(busname); + (*nut_usb_free_device_list)(devlist, 1); + (*nut_usb_exit)(NULL); +#endif /* WITH_LIBUSB_1_0 */ + fatal_with_errno(EXIT_FAILURE, "Out of memory"); + } } } nut_dev = nutscan_new_device(); - if(nut_dev == NULL) { - fprintf(stderr,"Memory allocation \ - error\n"); + if (nut_dev == NULL) { + fprintf(stderr, + "Memory allocation error\n"); nutscan_free_device(current_nut_dev); free(serialnumber); free(device_name); free(vendor_name); + (*nut_usb_close)(udev); +#if WITH_LIBUSB_1_0 + free(busname); + (*nut_usb_free_device_list)(devlist, 1); + (*nut_usb_exit)(NULL); +#endif /* WITH_LIBUSB_1_0 */ return NULL; } nut_dev->type = TYPE_USB; - if(driver_name) { + if (driver_name) { nut_dev->driver = strdup(driver_name); } nut_dev->port = strdup("auto"); - sprintf(string,"%04X",dev->descriptor.idVendor); - nutscan_add_option_to_device(nut_dev,"vendorid", - string); - sprintf(string,"%04X", - dev->descriptor.idProduct); - nutscan_add_option_to_device(nut_dev,"productid", - string); - if(device_name) { + + sprintf(string, "%04X", VendorID); + nutscan_add_option_to_device(nut_dev, + "vendorid", + string); + + sprintf(string, "%04X", ProductID); + nutscan_add_option_to_device(nut_dev, + "productid", + string); + + if (device_name) { nutscan_add_option_to_device(nut_dev, - "product", - device_name); + "product", + device_name); free(device_name); + device_name = NULL; } - if(serialnumber) { + + if (serialnumber) { nutscan_add_option_to_device(nut_dev, - "serial", - serialnumber); + "serial", + serialnumber); free(serialnumber); + serialnumber = NULL; } - if(vendor_name) { + + if (vendor_name) { nutscan_add_option_to_device(nut_dev, - "vendor", - vendor_name); + "vendor", + vendor_name); free(vendor_name); + vendor_name = NULL; } - nutscan_add_option_to_device(nut_dev,"bus", - bus->dirname); + + nutscan_add_option_to_device(nut_dev, + "bus", + busname); current_nut_dev = nutscan_add_device_to_device( - current_nut_dev, - nut_dev); + current_nut_dev, + nut_dev); memset (string, 0, sizeof(string)); (*nut_usb_close)(udev); } +#if WITH_LIBUSB_0_1 } } +#else /* not WITH_LIBUSB_0_1 */ + free(busname); + } + + (*nut_usb_free_device_list)(devlist, 1); + (*nut_usb_exit)(NULL); +#endif /* WITH_LIBUSB_0_1 */ return nutscan_rewind_device(current_nut_dev); } -#else /* WITH_USB */ +#else /* not WITH_USB */ nutscan_device_t * nutscan_scan_usb() { return NULL; } #endif /* WITH_USB */ - diff --git a/tools/nut-scanner/scan_xml_http.c b/tools/nut-scanner/scan_xml_http.c index 6320980..6676a81 100644 --- a/tools/nut-scanner/scan_xml_http.c +++ b/tools/nut-scanner/scan_xml_http.c @@ -1,5 +1,7 @@ /* * Copyright (C) 2011 - EATON + * Copyright (C) 2016 - EATON - IP addressed XML scan + * Copyright (C) 2016-2021 - EATON - Various threads-related improvements * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,10 +21,13 @@ /*! \file scan_xml_http.c \brief detect NUT supported XML HTTP devices \author Frederic Bohe + \author Michal Vyskocil + \author Jim Klimov */ #include "common.h" #include "nut-scan.h" + #ifdef WITH_NEON #include #include @@ -37,7 +42,7 @@ #include /* dynamic link library stuff */ -static char * libname = "libneon"; +static char * libname = "libneon"; /* Note: this is for info messages, not the SONAME */ static lt_dlhandle dl_handle = NULL; static const char *dl_error = NULL; @@ -47,15 +52,29 @@ static void (*nut_ne_xml_push_handler)(ne_xml_parser *p, ne_xml_endelm_cb *endelm, void *userdata); static void (*nut_ne_xml_destroy)(ne_xml_parser *p); +static int (*nut_ne_xml_failed)(ne_xml_parser *p); static ne_xml_parser * (*nut_ne_xml_create)(void); static int (*nut_ne_xml_parse)(ne_xml_parser *p, const char *block, size_t len); -/* return 0 on error */ +static nutscan_device_t * dev_ret = NULL; +#ifdef HAVE_PTHREAD +static pthread_mutex_t dev_mutex; +#endif + +/* use explicit booleans */ +#ifndef FALSE +typedef enum ebool { FALSE = 0, TRUE } bool_t; +#else +typedef int bool_t; +#endif + +/* return 0 on error; visible externally */ +int nutscan_load_neon_library(const char *libname_path); int nutscan_load_neon_library(const char *libname_path) { - if( dl_handle != NULL ) { + if (dl_handle != NULL) { /* if previous init failed */ - if( dl_handle == (void *)1 ) { + if (dl_handle == (void *)1) { return 0; } /* init has already been done */ @@ -67,7 +86,7 @@ int nutscan_load_neon_library(const char *libname_path) return 0; } - if( lt_dlinit() != 0 ) { + if (lt_dlinit() != 0) { fprintf(stderr, "Error initializing lt_init\n"); return 0; } @@ -81,22 +100,27 @@ int nutscan_load_neon_library(const char *libname_path) lt_dlerror(); /* Clear any existing error */ *(void **) (&nut_ne_xml_push_handler) = lt_dlsym(dl_handle, "ne_xml_push_handler"); - if ((dl_error = lt_dlerror()) != NULL) { + if ((dl_error = lt_dlerror()) != NULL) { goto err; } - *(void **) (&nut_ne_xml_destroy) = lt_dlsym(dl_handle,"ne_xml_destroy"); - if ((dl_error = lt_dlerror()) != NULL) { + *(void **) (&nut_ne_xml_destroy) = lt_dlsym(dl_handle, "ne_xml_destroy"); + if ((dl_error = lt_dlerror()) != NULL) { goto err; } - *(void **) (&nut_ne_xml_create) = lt_dlsym(dl_handle,"ne_xml_create"); - if ((dl_error = lt_dlerror()) != NULL) { + *(void **) (&nut_ne_xml_create) = lt_dlsym(dl_handle, "ne_xml_create"); + if ((dl_error = lt_dlerror()) != NULL) { goto err; } - *(void **) (&nut_ne_xml_parse) = lt_dlsym(dl_handle,"ne_xml_parse"); - if ((dl_error = lt_dlerror()) != NULL) { + *(void **) (&nut_ne_xml_parse) = lt_dlsym(dl_handle, "ne_xml_parse"); + if ((dl_error = lt_dlerror()) != NULL) { + goto err; + } + + *(void **) (&nut_ne_xml_failed) = lt_dlsym(dl_handle, "ne_xml_failed"); + if ((dl_error = lt_dlerror()) != NULL) { goto err; } @@ -108,142 +132,585 @@ err: return 0; } +/* A start-element callback for element with given namespace/name. */ static int startelm_cb(void *userdata, int parent, const char *nspace, const char *name, const char **atts) { nutscan_device_t * dev = (nutscan_device_t *)userdata; char buf[SMALLBUF]; int i = 0; - while( atts[i] != NULL ) { - if(strcmp(atts[i],"type") == 0) { - snprintf(buf,sizeof(buf),"%s",atts[i+1]); - nutscan_add_option_to_device(dev,"desc",buf); - return 0; + int result = -1; + while (atts[i] != NULL) { + upsdebugx(5, "startelm_cb() : parent=%d nspace='%s' name='%s' atts[%d]='%s' atts[%d]='%s'", + parent, nspace, name, i, atts[i], (i + 1), atts[i + 1]); + /* The Eaton/MGE ePDUs almost exclusively support only XMLv4 protocol + * (only the very first generation of G2/G3 NMCs supported an older + * protocol, but all should have been FW upgraded by now), which NUT + * drivers don't yet support. To avoid failing drivers later, the + * nut-scanner should not suggest netxml-ups configuration for ePDUs + * at this time. */ + if (strcmp(atts[i], "class") == 0 && strcmp(atts[i + 1], "DEV.PDU") == 0) { + upsdebugx(3, "startelm_cb() : XML v4 protocol is not supported by current NUT drivers, skipping device!"); + /* netxml-ups currently only supports XML version 3 (for UPS), + * and not version 4 (for UPS and PDU)! */ + return -1; } - i=i+2; + if (strcmp(atts[i], "type") == 0) { + snprintf(buf, sizeof(buf), "%s", atts[i + 1]); + nutscan_add_option_to_device(dev, "desc", buf); + result = 0; + } + i = i + 2; } - return 0; + return result; } -nutscan_device_t * nutscan_scan_xml_http(long usec_timeout) +static void * nutscan_scan_xml_http_generic(void * arg) { + nutscan_xml_t * sec = (nutscan_xml_t *)arg; char *scanMsg = ""; - int port = 4679; +/* Note: at this time the HTTP/XML scan is in fact not implemented - just the UDP part */ +/* uint16_t port_http = 80; */ + uint16_t port_udp = 4679; +/* A NULL "ip" causes a broadcast scan; otherwise the single ip address is queried directly */ + char *ip = NULL; + useconds_t usec_timeout = 0; int peerSocket; int sockopt_on = 1; - struct sockaddr_in sockAddress; - socklen_t sockAddressLength = sizeof(sockAddress); - memset(&sockAddress, 0, sizeof(sockAddress)); + struct sockaddr_in sockAddress_udp; + socklen_t sockAddressLength = sizeof(sockAddress_udp); + memset(&sockAddress_udp, 0, sizeof(sockAddress_udp)); fd_set fds; struct timeval timeout; int ret; - char buf[SMALLBUF]; + char buf[SMALLBUF + 8]; char string[SMALLBUF]; ssize_t recv_size; + int i; nutscan_device_t * nut_dev = NULL; - nutscan_device_t * current_nut_dev = NULL; + if (sec != NULL) { +/* if (sec->port_http > 0 && sec->port_http <= 65534) + * port_http = sec->port_http; */ + if (sec->port_udp > 0 && sec->port_udp <= 65534) + port_udp = sec->port_udp; + if (sec->usec_timeout > 0) + usec_timeout = sec->usec_timeout; + ip = sec->peername; /* NULL or not... */ + } - if( !nutscan_avail_xml_http ) { - return NULL; - } + if (usec_timeout <= 0) + usec_timeout = 5000000; /* Driver default : 5sec */ - if((peerSocket = socket(AF_INET, SOCK_DGRAM, 0)) != -1) - { + if (!nutscan_avail_xml_http) { + return NULL; + } + + if ((peerSocket = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { + fprintf(stderr, "Error creating socket\n"); + return NULL; + } + +/* FIXME : Per http://stackoverflow.com/questions/683624/udp-broadcast-on-all-interfaces + * A single sendto() generates a single packet, so one must iterate all known interfaces... */ +#define MAX_RETRIES 3 + for (i = 0; i != MAX_RETRIES ; i++) { /* Initialize socket */ - sockAddress.sin_family = AF_INET; - sockAddress.sin_addr.s_addr = INADDR_BROADCAST; - sockAddress.sin_port = htons(port); - setsockopt(peerSocket, SOL_SOCKET, SO_BROADCAST, &sockopt_on, + sockAddress_udp.sin_family = AF_INET; + if (ip == NULL) { + upsdebugx(2, + "nutscan_scan_xml_http_generic() : scanning connected network segment(s) " + "with a broadcast, attempt %d of %d with a timeout of %jd usec", + (i + 1), MAX_RETRIES, (uintmax_t)usec_timeout); + sockAddress_udp.sin_addr.s_addr = INADDR_BROADCAST; + setsockopt(peerSocket, SOL_SOCKET, SO_BROADCAST, &sockopt_on, sizeof(sockopt_on)); + } else { + upsdebugx(2, + "nutscan_scan_xml_http_generic() : scanning IP '%s' with a unicast, " + "attempt %d of %d with a timeout of %jd usec", + ip, (i + 1), MAX_RETRIES, (uintmax_t)usec_timeout); + inet_pton(AF_INET, ip, &(sockAddress_udp.sin_addr)); + } + sockAddress_udp.sin_port = htons(port_udp); /* Send scan request */ - if(sendto(peerSocket, scanMsg, strlen(scanMsg), 0, - (struct sockaddr *)&sockAddress, - sockAddressLength) <= 0) - { - fprintf(stderr,"Error sending Eaton \n"); + if (sendto(peerSocket, scanMsg, strlen(scanMsg), 0, + (struct sockaddr *)&sockAddress_udp, + sockAddressLength) <= 0 + ) { + fprintf(stderr, + "Error sending Eaton to %s, #%d/%d\n", + (ip ? ip : ""), (i + 1), MAX_RETRIES); + usleep(usec_timeout); + continue; } else { + int retNum = 0; FD_ZERO(&fds); - FD_SET(peerSocket,&fds); + FD_SET(peerSocket, &fds); timeout.tv_sec = usec_timeout / 1000000; timeout.tv_usec = usec_timeout % 1000000; - while ((ret=select(peerSocket+1,&fds,NULL,NULL, - &timeout) )) { + upsdebugx(5, "nutscan_scan_xml_http_generic() : sent request to %s, " + "loop #%d/%d, waiting for responses", + (ip ? ip : ""), (i + 1), MAX_RETRIES); + while ((ret = select(peerSocket + 1, &fds, NULL, NULL, + &timeout)) + ) { + retNum ++; + upsdebugx(5, "nutscan_scan_xml_http_generic() : request to %s, " + "loop #%d/%d, response #%d", + (ip ? ip : ""), (i + 1), MAX_RETRIES, retNum); timeout.tv_sec = usec_timeout / 1000000; timeout.tv_usec = usec_timeout % 1000000; - if( ret == -1 ) { + if (ret == -1) { fprintf(stderr, "Error waiting on \ - socket: %d\n",errno); + socket: %d\n", errno); break; } sockAddressLength = sizeof(struct sockaddr_in); - recv_size = recvfrom(peerSocket,buf, - sizeof(buf),0, - (struct sockaddr *)&sockAddress, - &sockAddressLength); + recv_size = recvfrom(peerSocket, buf, + sizeof(buf), 0, + (struct sockaddr *)&sockAddress_udp, + &sockAddressLength); - if(recv_size==-1) { + if (recv_size < 0) { fprintf(stderr, "Error reading \ - socket: %d\n",errno); + socket: %d, #%d/%d\n", errno, (i + 1), MAX_RETRIES); + usleep(usec_timeout); continue; } - if( getnameinfo( - (struct sockaddr *)&sockAddress, - sizeof(struct sockaddr_in),string, - sizeof(string),NULL,0, - NI_NUMERICHOST) != 0) { + if (getnameinfo( + (struct sockaddr *)&sockAddress_udp, + sizeof(struct sockaddr_in), string, + sizeof(string), NULL, 0, + NI_NUMERICHOST) != 0 + ) { fprintf(stderr, - "Error converting IP address \ - : %d\n",errno); + "Error converting IP address: %d\n", errno); + usleep(usec_timeout); continue; } - nut_dev = nutscan_new_device(); - if(nut_dev == NULL) { - fprintf(stderr,"Memory allocation \ - error\n"); - return NULL; - } + nut_dev = nutscan_new_device(); + if (nut_dev == NULL) { + fprintf(stderr, "Memory allocation error\n"); + goto end_abort; + } - nut_dev->type = TYPE_XML; +#ifdef HAVE_PTHREAD + pthread_mutex_lock(&dev_mutex); +#endif + upsdebugx(5, + "Some host at IP %s replied to NetXML UDP request on port %d, " + "inspecting the response...", + string, port_udp); + nut_dev->type = TYPE_XML; /* Try to read device type */ ne_xml_parser *parser = (*nut_ne_xml_create)(); (*nut_ne_xml_push_handler)(parser, startelm_cb, NULL, NULL, nut_dev); - (*nut_ne_xml_parse)(parser, buf, recv_size); + /* recv_size is a ssize_t, so in range of size_t */ + (*nut_ne_xml_parse)(parser, buf, (size_t)recv_size); + int parserFailed = (*nut_ne_xml_failed)(parser); /* 0 = ok, nonzero = fail */ (*nut_ne_xml_destroy)(parser); - nut_dev->driver = strdup("netxml-ups"); - sprintf(buf,"http://%s",string); - nut_dev->port = strdup(buf); - - current_nut_dev = nutscan_add_device_to_device( - current_nut_dev,nut_dev); + if (parserFailed == 0) { + nut_dev->driver = strdup("netxml-ups"); + sprintf(buf, "http://%s", string); + nut_dev->port = strdup(buf); + upsdebugx(3, + "nutscan_scan_xml_http_generic(): " + "Adding configuration for driver='%s' port='%s'", + nut_dev->driver, nut_dev->port); + dev_ret = nutscan_add_device_to_device( + dev_ret, nut_dev); +#ifdef HAVE_PTHREAD + pthread_mutex_unlock(&dev_mutex); +#endif + } + else + { + fprintf(stderr, + "Device at IP %s replied with NetXML but was not deemed compatible " + "with 'netxml-ups' driver (unsupported protocol version, etc.)\n", + string); + nutscan_free_device(nut_dev); + nut_dev = NULL; +#ifdef HAVE_PTHREAD + pthread_mutex_unlock(&dev_mutex); +#endif + if (ip == NULL) { + /* skip this device; note that for a + * broadcast scan there may be more + * in the loop's queue */ + continue; + } + } + if (ip != NULL) { + upsdebugx(2, + "nutscan_scan_xml_http_generic(): we collected one reply " + "to unicast for %s (repsponse from %s), done", + ip, string); + goto end; + } + } /* while select() responses */ + if (ip == NULL && dev_ret != NULL) { + upsdebugx(2, + "nutscan_scan_xml_http_generic(): we collected one round of replies " + "to broadcast with no errors, done"); + goto end; } } } - else - { - fprintf(stderr,"Error creating socket\n"); - } + upsdebugx(2, + "nutscan_scan_xml_http_generic(): no replies collected for %s, done", + (ip ? ip : "")); + goto end; - - return nutscan_rewind_device(current_nut_dev); -} -#else /* WITH_NEON */ -nutscan_device_t * nutscan_scan_xml_http(long usec_timeout) -{ +end_abort: + upsdebugx(1, + "Had to abort nutscan_scan_xml_http_generic() for %s, see fatal details above", + (ip ? ip : "")); +end: + if (ip != NULL) /* do not free "ip", it comes from caller */ + close(peerSocket); return NULL; } + +nutscan_device_t * nutscan_scan_xml_http_range(const char * start_ip, const char * end_ip, useconds_t usec_timeout, nutscan_xml_t * sec) +{ + bool_t pass = TRUE; /* Track that we may spawn a scanning thread */ + nutscan_xml_t * tmp_sec = NULL; + nutscan_device_t * result = NULL; + + if (!nutscan_avail_xml_http) { + return NULL; + } + + if (start_ip == NULL && end_ip != NULL) { + start_ip = end_ip; + } + + if (start_ip == NULL) { + upsdebugx(1, "Scanning XML/HTTP bus using broadcast."); + } else { + if ((start_ip == end_ip) || (end_ip == NULL) || (0 == strncmp(start_ip, end_ip, 128))) { + upsdebugx(1, "Scanning XML/HTTP bus for single IP (%s).", start_ip); + } else { + /* Iterate the range of IPs to scan */ + nutscan_ip_iter_t ip; + char * ip_str = NULL; +#ifdef HAVE_PTHREAD +# ifdef HAVE_SEMAPHORE + sem_t * semaphore = nutscan_semaphore(); + sem_t semaphore_scantype_inst; + sem_t * semaphore_scantype = &semaphore_scantype_inst; +# endif /* HAVE_SEMAPHORE */ + pthread_t thread; + nutscan_thread_t * thread_array = NULL; + size_t thread_count = 0, i; +# if (defined HAVE_PTHREAD_TRYJOIN) || (defined HAVE_SEMAPHORE) + size_t max_threads_scantype = max_threads_netxml; +# endif + + pthread_mutex_init(&dev_mutex, NULL); + +# ifdef HAVE_SEMAPHORE + if (max_threads_scantype > 0) { + if (SIZE_MAX > UINT_MAX && max_threads_scantype > UINT_MAX) { + upsdebugx(1, + "WARNING: %s: Limiting max_threads_scantype to range acceptable for sem_init()", + __func__); + max_threads_scantype = UINT_MAX - 1; + } + sem_init(semaphore_scantype, 0, (unsigned int)max_threads_scantype); + } +# endif /* HAVE_SEMAPHORE */ + +#endif /* HAVE_PTHREAD */ + + ip_str = nutscan_ip_iter_init(&ip, start_ip, end_ip); + + while (ip_str != NULL) { +#ifdef HAVE_PTHREAD + /* NOTE: With many enough targets to scan, this can crash + * by spawning too many children; add a limit and loop to + * "reap" some already done with their work. And probably + * account them in thread_array[] as something to not wait + * for below in pthread_join()... + */ + +# ifdef HAVE_SEMAPHORE + /* Just wait for someone to free a semaphored slot, + * if none are available, and then/otherwise grab one + */ + if (thread_array == NULL) { + /* Starting point, or after a wait to complete + * all earlier runners */ + if (max_threads_scantype > 0) + sem_wait(semaphore_scantype); + sem_wait(semaphore); + pass = TRUE; + } else { + pass = ((max_threads_scantype == 0 || sem_trywait(semaphore_scantype) == 0) && + sem_trywait(semaphore) == 0); + } +# else +# ifdef HAVE_PTHREAD_TRYJOIN + /* A somewhat naive and brute-force solution for + * systems without a semaphore.h. This may suffer + * some off-by-one errors, using a few more threads + * than intended (if we race a bit at the wrong time, + * probably up to one per enabled scanner routine). + */ + + /* TOTHINK: Should there be a threadcount_mutex when + * we just read the value in if() and while() below? + * At worst we would overflow the limit a bit due to + * other protocol scanners... + */ + if (curr_threads >= max_threads + || (curr_threads >= max_threads_scantype && max_threads_scantype > 0) + ) { + upsdebugx(2, "%s: already running %zu scanning threads " + "(launched overall: %zu), " + "waiting until some would finish", + __func__, curr_threads, thread_count); + while (curr_threads >= max_threads + || (curr_threads >= max_threads_scantype && max_threads_scantype > 0) + ) { + for (i = 0; i < thread_count ; i++) { + int ret; + + if (!thread_array[i].active) continue; + + pthread_mutex_lock(&threadcount_mutex); + upsdebugx(3, "%s: Trying to join thread #%i...", __func__, i); + ret = pthread_tryjoin_np(thread_array[i].thread, NULL); + switch (ret) { + case ESRCH: /* No thread with the ID thread could be found - already "joined"? */ + upsdebugx(5, "%s: Was thread #%zu joined earlier?", __func__, i); + break; + case 0: /* thread exited */ + if (curr_threads > 0) { + curr_threads --; + upsdebugx(4, "%s: Joined a finished thread #%zu", __func__, i); + } else { + /* threadcount_mutex fault? */ + upsdebugx(0, "WARNING: %s: Accounting of thread count " + "says we are already at 0", __func__); + } + thread_array[i].active = FALSE; + break; + case EBUSY: /* actively running */ + upsdebugx(6, "%s: thread #%zu still busy (%i)", + __func__, i, ret); + break; + case EDEADLK: /* Errors with thread interactions... bail out? */ + case EINVAL: /* Errors with thread interactions... bail out? */ + default: /* new pthreads abilities? */ + upsdebugx(5, "%s: thread #%zu reported code %i", + __func__, i, ret); + break; + } + pthread_mutex_unlock(&threadcount_mutex); + } + + if (curr_threads >= max_threads + || (curr_threads >= max_threads_scantype && max_threads_scantype > 0) + ) { + usleep (10000); /* microSec's, so 0.01s here */ + } + } + upsdebugx(2, "%s: proceeding with scan", __func__); + } + /* NOTE: No change to default "pass" in this ifdef: + * if we got to this line, we have a slot to use */ +# endif /* HAVE_PTHREAD_TRYJOIN */ +# endif /* HAVE_SEMAPHORE */ +#endif /* HAVE_PTHREAD */ + + if (pass) { + tmp_sec = malloc(sizeof(nutscan_xml_t)); + if (tmp_sec == NULL) { + fprintf(stderr, + "Memory allocation error\n"); + return NULL; + } + memcpy(tmp_sec, sec, sizeof(nutscan_xml_t)); + tmp_sec->peername = ip_str; + if (tmp_sec->usec_timeout <= 0) { + tmp_sec->usec_timeout = usec_timeout; + } + +#ifdef HAVE_PTHREAD + if (pthread_create(&thread, NULL, nutscan_scan_xml_http_generic, (void *)tmp_sec) == 0) { +# ifdef HAVE_PTHREAD_TRYJOIN + pthread_mutex_lock(&threadcount_mutex); + curr_threads++; +# endif /* HAVE_PTHREAD_TRYJOIN */ + + thread_count++; + nutscan_thread_t *new_thread_array = realloc(thread_array, + thread_count*sizeof(nutscan_thread_t)); + if (new_thread_array == NULL) { + upsdebugx(1, "%s: Failed to realloc thread array", __func__); + break; + } + else { + thread_array = new_thread_array; + } + thread_array[thread_count - 1].thread = thread; + thread_array[thread_count - 1].active = TRUE; + +# ifdef HAVE_PTHREAD_TRYJOIN + pthread_mutex_unlock(&threadcount_mutex); +# endif /* HAVE_PTHREAD_TRYJOIN */ + } +#else /* not HAVE_PTHREAD */ + nutscan_scan_xml_http_generic((void *)tmp_sec); +#endif /* if HAVE_PTHREAD */ + +/* free(ip_str); */ /* One of these free()s seems to cause a double-free instead */ + ip_str = nutscan_ip_iter_inc(&ip); +/* free(tmp_sec); */ + } else { /* if not pass -- all slots busy */ +#ifdef HAVE_PTHREAD +# ifdef HAVE_SEMAPHORE + /* Wait for all current scans to complete */ + if (thread_array != NULL) { + upsdebugx (2, "%s: Running too many scanning threads, " + "waiting until older ones would finish", + __func__); + for (i = 0; i < thread_count ; i++) { + int ret; + if (!thread_array[i].active) { + /* Probably should not get here, + * but handle it just in case */ + upsdebugx(0, "WARNING: %s: Midway clean-up: did not expect thread %zu to be not active", + __func__, i); + sem_post(semaphore); + if (max_threads_scantype > 0) + sem_post(semaphore_scantype); + continue; + } + thread_array[i].active = FALSE; + ret = pthread_join(thread_array[i].thread, NULL); + if (ret != 0) { + upsdebugx(0, "WARNING: %s: Midway clean-up: pthread_join() returned code %i", + __func__, ret); + } + sem_post(semaphore); + if (max_threads_scantype > 0) + sem_post(semaphore_scantype); + } + thread_count = 0; + free(thread_array); + thread_array = NULL; + } +# else +# ifdef HAVE_PTHREAD_TRYJOIN + /* TODO: Move the wait-loop for TRYJOIN here? */ +# endif /* HAVE_PTHREAD_TRYJOIN */ +# endif /* HAVE_SEMAPHORE */ +#endif /* HAVE_PTHREAD */ + } /* if: could we "pass" or not? */ + } /* while */ + +#ifdef HAVE_PTHREAD + if (thread_array != NULL) { + upsdebugx(2, "%s: all planned scans launched, waiting for threads to complete", __func__); + for (i = 0; i < thread_count; i++) { + int ret; + + if (!thread_array[i].active) continue; + + ret = pthread_join(thread_array[i].thread, NULL); + if (ret != 0) { + upsdebugx(0, "WARNING: %s: Clean-up: pthread_join() returned code %i", + __func__, ret); + } + thread_array[i].active = FALSE; +# ifdef HAVE_SEMAPHORE + sem_post(semaphore); + if (max_threads_scantype > 0) + sem_post(semaphore_scantype); +# else +# ifdef HAVE_PTHREAD_TRYJOIN + pthread_mutex_lock(&threadcount_mutex); + if (curr_threads > 0) { + curr_threads --; + upsdebugx(5, "%s: Clean-up: Joined a finished thread #%zu", + __func__, i); + } else { + upsdebugx(0, "WARNING: %s: Clean-up: Accounting of thread count " + "says we are already at 0", __func__); + } + pthread_mutex_unlock(&threadcount_mutex); +# endif /* HAVE_PTHREAD_TRYJOIN */ +# endif /* HAVE_SEMAPHORE */ + } + free(thread_array); + upsdebugx(2, "%s: all threads freed", __func__); + } + pthread_mutex_destroy(&dev_mutex); + +# ifdef HAVE_SEMAPHORE + if (max_threads_scantype > 0) + sem_destroy(semaphore_scantype); +# endif /* HAVE_SEMAPHORE */ +#endif /* HAVE_PTHREAD */ + + result = nutscan_rewind_device(dev_ret); + dev_ret = NULL; + return result; + } + } + + tmp_sec = malloc(sizeof(nutscan_xml_t)); + if (tmp_sec == NULL) { + fprintf(stderr, + "Memory allocation error\n"); + return NULL; + } + + memcpy(tmp_sec, sec, sizeof(nutscan_xml_t)); + if (start_ip == NULL) { + tmp_sec->peername = NULL; + } else { + tmp_sec->peername = strdup(start_ip); + } + + if (tmp_sec->usec_timeout <= 0) { + tmp_sec->usec_timeout = usec_timeout; + } + + nutscan_scan_xml_http_generic(tmp_sec); + result = nutscan_rewind_device(dev_ret); + dev_ret = NULL; + free(tmp_sec); + return result; +} + +#else /* WITH_NEON */ + +nutscan_device_t * nutscan_scan_xml_http_range(const char * start_ip, const char * end_ip, useconds_t usec_timeout, nutscan_xml_t * sec) +{ + NUT_UNUSED_VARIABLE(start_ip); + NUT_UNUSED_VARIABLE(end_ip); + NUT_UNUSED_VARIABLE(usec_timeout); + NUT_UNUSED_VARIABLE(sec); + return NULL; +} + #endif /* WITH_NEON */ diff --git a/tools/nut-snmpinfo.py b/tools/nut-snmpinfo.py.in similarity index 71% rename from tools/nut-snmpinfo.py rename to tools/nut-snmpinfo.py.in index 32d1778..c76e9de 100755 --- a/tools/nut-snmpinfo.py +++ b/tools/nut-snmpinfo.py.in @@ -1,6 +1,7 @@ -#!/usr/bin/env python -# Copyright (C) 2011 - Frederic Bohe -# Copyright (C) 2016 - Arnaud Quette +#!@PYTHON@ +# Copyright (C) 2011-2021 Eaton +# Authors: Frederic Bohe +# Arnaud Quette # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,8 +22,17 @@ import glob import re import sys +import os -output_file_name="./nut-scanner/nutscan-snmp.h" +TOP_SRCDIR = os.getenv('TOP_SRCDIR') +if TOP_SRCDIR is None: + TOP_SRCDIR=".." + +TOP_BUILDDIR = os.getenv('TOP_BUILDDIR') +if TOP_BUILDDIR is None: + TOP_BUILDDIR=".." + +output_file_name = TOP_BUILDDIR + "/tools/nut-scanner/nutscan-snmp.h" output_file = open(output_file_name,'w') #expand #define constant @@ -33,7 +43,16 @@ def expand_define(filename,constant): if constant in line and "#define" in line: line_without_carriage_return = re.sub("[\n\r]", "", line) line_with_single_blank = re.sub("[ \t]+", " ", line_without_carriage_return) - define_line = line_with_single_blank.split(" "); + line_without_eol_comments = line_with_single_blank + # Note: per precedent in code, this assumes a single-line /* ... */ trailing comment + i = line_without_eol_comments.find('/*') + if i >= 0: + line_without_eol_comments = line_without_eol_comments[:i] + i = line_without_eol_comments.find('//') + if i >= 0: + line_without_eol_comments = line_without_eol_comments[:i] + line_without_eol_comments = line_without_eol_comments.strip() + define_line = line_without_eol_comments.split(" ") #define_line[0] = "#define" #define_line[1] = const name #define_line[2...] = const value (may be other const name) @@ -45,13 +64,14 @@ def expand_define(filename,constant): clean_elem = re.sub("\"", "", elem) ret_line = ret_line + clean_elem else: - ret_line = ret_line + expand_define(filename,elem); + ret_line = ret_line + expand_define(filename,elem) return ret_line -output_file.write( "/* nutscan-snmp\n" ) -output_file.write( " * Copyright (C) 2011 - Frederic Bohe \n" ) -output_file.write( " * Copyright (C) 2016 - Arnaud Quette \n" ) +output_file.write( "/* nutscan-snmp.h - fully generated during build of NUT\n" ) +output_file.write( " * Copyright (C) 2011-2019 EATON\n" ) +output_file.write( " * Authors: Frederic Bohe \n" ) +output_file.write( " * Arnaud Quette \n" ) output_file.write( " *\n" ) output_file.write( " * This program is free software; you can redistribute it and/or modify\n" ) output_file.write( " * it under the terms of the GNU General Public License as published by\n" ) @@ -72,15 +92,15 @@ output_file.write( "#ifndef DEVSCAN_SNMP_H\n" ) output_file.write( "#define DEVSCAN_SNMP_H\n" ) output_file.write( "\n" ) output_file.write( "typedef struct {\n" ) -output_file.write( " char * oid;\n" ) -output_file.write( " char * mib;\n" ) -output_file.write( " char * sysoid;\n" ) +output_file.write( "\tchar *\toid;\n" ) +output_file.write( "\tchar *\tmib;\n" ) +output_file.write( "\tchar *\tsysoid;\n" ) output_file.write( "} snmp_device_id_t;\n" ) output_file.write( "\n" ) output_file.write( "/* SNMP IDs device table */\n" ) output_file.write( "static snmp_device_id_t snmp_device_table[] = {\n" ) -for filename in glob.glob('../drivers/*-mib.c'): +for filename in sorted(glob.glob(TOP_SRCDIR + '/drivers/*-mib.c')): list_of_line = open(filename,'r').read().split(';') for line in list_of_line: if "mib2nut_info_t" in line: @@ -97,7 +117,7 @@ for filename in glob.glob('../drivers/*-mib.c'): line = line2.split("{",1) #line[1] is the part between {} line2 = line[1].split(",") - mib = line2[0] + mib = line2[0].lstrip(" ") #line2[3] is the OID of the device model name which #could be made of #define const and string. source_oid = line2[3] @@ -118,7 +138,7 @@ for filename in glob.glob('../drivers/*-mib.c'): clean_elem = re.sub("\"", "", elem) oid = oid+clean_elem else: - oid = oid + expand_define(filename,elem); + oid = oid + expand_define(filename,elem) #decode source_sysoid line = source_sysoid.lstrip(" ") @@ -131,16 +151,22 @@ for filename in glob.glob('../drivers/*-mib.c'): clean_elem = re.sub("\"", "", elem) sysoid = sysoid+clean_elem else: - sysoid = sysoid + expand_define(filename,elem); + sysoid = sysoid + expand_define(filename,elem) + # Sanity checks if sysoid == "": sysoid = "NULL" else: sysoid = "\"" + sysoid + "\"" - output_file.write( "\t{ \"" + oid + "\", " + mib + ", " + sysoid + "},\n" ) + if oid == "": + oid = "NULL" + else: + oid = "\"" + oid + "\"" -output_file.write( " /* Terminating entry */\n" ) -output_file.write( " { NULL, NULL, NULL}\n" ) + output_file.write( "\t{ " + oid + ", " + mib + ", " + sysoid + " },\n" ) + +output_file.write( "\t/* Terminating entry */\n" ) +output_file.write( "\t{ NULL, NULL, NULL }\n" ) output_file.write( "};\n" ) output_file.write( "#endif /* DEVSCAN_SNMP_H */\n" ) diff --git a/tools/nut-usbinfo.pl b/tools/nut-usbinfo.pl index 2c0dd05..9fd07a1 100755 --- a/tools/nut-usbinfo.pl +++ b/tools/nut-usbinfo.pl @@ -28,28 +28,34 @@ use File::Find; use strict; + +my $TOP_SRCDIR = ".."; +if (defined $ENV{'TOP_SRCDIR'}) { + $TOP_SRCDIR = $ENV{'TOP_SRCDIR'}; +} + +my $TOP_BUILDDIR = ".."; +if (defined $ENV{'TOP_BUILDDIR'}) { + $TOP_BUILDDIR = $ENV{'TOP_BUILDDIR'}; +} + # path to scan for USB_DEVICE pattern -my $scanPath="../drivers"; +my $scanPath="$TOP_SRCDIR/drivers"; # Hotplug output file -my $outputHotplug="../scripts/hotplug/libhid.usermap"; +my $outputHotplug="$TOP_BUILDDIR/scripts/hotplug/libhid.usermap"; # udev output file -my $outputUdev="../scripts/udev/nut-usbups.rules.in"; +my $outputUdev="$TOP_BUILDDIR/scripts/udev/nut-usbups.rules.in"; # BSD devd output file -my $output_devd="../scripts/devd/nut-usb.conf.in"; +my $output_devd="$TOP_BUILDDIR/scripts/devd/nut-usb.conf.in"; # UPower output file -my $outputUPower="../scripts/upower/95-upower-hid.rules"; - -# tmp output, to allow generating the ENV{UPOWER_VENDOR} header list -my $tmpOutputUPower; -# mfr header flag -my $upowerMfrHeaderDone = 0; +my $outputUPower="$TOP_BUILDDIR/scripts/upower/95-upower-hid.hwdb"; # NUT device scanner - C header -my $outputDevScanner = "./nut-scanner/nutscan-usb.h"; +my $outputDevScanner = "$TOP_BUILDDIR/tools/nut-scanner/nutscan-usb.h"; my $GPL_header = "\ * Copyright (C) 2011 - Arnaud Quette \ @@ -68,7 +74,7 @@ my $GPL_header = "\ * along with this program; if not, write to the Free Software\ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA"; -# array of products indexed by vendorID +# array of products indexed by vendorID my %vendor; # contain for each vendor, its name (and...) @@ -76,7 +82,7 @@ my %vendorName; ################# MAIN ################# -find(\&find_usbdevs,$scanPath); +find({wanted=>\&find_usbdevs, preprocess=>sub{sort @_}}, $scanPath); &gen_usb_files; ################# SUB METHOD ################# @@ -97,10 +103,10 @@ sub gen_usb_files # Udev file header open my $outUdev, ">$outputUdev" || die "error $outputUdev : $!"; print $outUdev '# This file is generated and installed by the Network UPS Tools package.'."\n\n"; - print $outUdev 'ACTION!="add|change", GOTO="nut-usbups_rules_end"'."\n"; + print $outUdev 'ACTION=="remove", GOTO="nut-usbups_rules_end"'."\n"; print $outUdev 'SUBSYSTEM=="usb_device", GOTO="nut-usbups_rules_real"'."\n"; print $outUdev 'SUBSYSTEM=="usb", GOTO="nut-usbups_rules_real"'."\n"; - print $outUdev 'SUBSYSTEM!="usb", GOTO="nut-usbups_rules_end"'."\n\n"; + print $outUdev 'GOTO="nut-usbups_rules_end"'."\n\n"; print $outUdev 'LABEL="nut-usbups_rules_real"'."\n"; open my $out_devd, ">$output_devd" || die "error $output_devd : $!"; @@ -111,20 +117,34 @@ sub gen_usb_files open my $outputUPower, ">$outputUPower" || die "error $outputUPower : $!"; print $outputUPower '##############################################################################################################'."\n"; print $outputUPower '# Uninterruptible Power Supplies with USB HID interfaces'."\n#\n"; - print $outputUPower '# This file was automatically generated by NUT:'."\n#".' https://github.com/networkupstools/nut/'."\n#\n"; - print $outputUPower '# To keep up to date, monitor upstream NUT'."\n#".' https://github.com/networkupstools/nut/commits/master/scripts/upower/95-upower-hid.rules'."\n"; - print $outputUPower "# or checkout the NUT repository and call 'tools/nut-usbinfo.pl'\n\n"; - print $outputUPower '# newer hiddev are part of the usbmisc class'."\n".'SUBSYSTEM=="usbmisc", GOTO="up_hid_chkdev"'."\n"; - print $outputUPower '# only support USB, else ignore'."\n".'SUBSYSTEM!="usb", GOTO="up_hid_end"'."\n\n"; - print $outputUPower '# if usbraw device, ignore'."\n".'LABEL="up_hid_chkdev"'."\n".'KERNEL!="hiddev*", GOTO="up_hid_end"'."\n\n"; - print $outputUPower '# if an interface, ignore'."\n".'ENV{DEVTYPE}=="usb_interface", GOTO="up_hid_end"'."\n\n"; + print $outputUPower '# This file was automatically generated by NUT:'."\n"; + print $outputUPower '# https://github.com/networkupstools/nut/'."\n#\n"; + print $outputUPower '# To keep up to date, monitor upstream NUT'."\n"; + print $outputUPower '# https://github.com/networkupstools/nut/commits/master/scripts/upower/95-upower-hid.hwdb'."\n"; + print $outputUPower "# or checkout the NUT repository and call 'tools/nut-usbinfo.pl'\n"; # Device scanner header open my $outputDevScanner, ">$outputDevScanner" || die "error $outputDevScanner : $!"; print $outputDevScanner '/* nutscan-usb'.$GPL_header."\n */\n\n"; print $outputDevScanner "#ifndef DEVSCAN_USB_H\n#define DEVSCAN_USB_H\n\n"; - print $outputDevScanner "#include \n"; - print $outputDevScanner "#include \"nut_stdint.h\"\t/* for uint16_t */\n\n"; + print $outputDevScanner "#include \"nut_stdint.h\"\t/* for uint16_t etc. */\n\n"; + print $outputDevScanner "#include \t/* for PATH_MAX in usb.h etc. */\n\n"; + print $outputDevScanner "#include \t/* for MAXPATHLEN etc. */\n\n"; + print $outputDevScanner "/* libusb header file */\n"; + print $outputDevScanner "#if (!WITH_LIBUSB_1_0) && (!WITH_LIBUSB_0_1)\n"; + print $outputDevScanner "#error \"configure script error: Neither WITH_LIBUSB_1_0 nor WITH_LIBUSB_0_1 is set\"\n"; + print $outputDevScanner "#endif\n\n"; + print $outputDevScanner "#if (WITH_LIBUSB_1_0) && (WITH_LIBUSB_0_1)\n"; + print $outputDevScanner "#error \"configure script error: Both WITH_LIBUSB_1_0 and WITH_LIBUSB_0_1 are set\"\n"; + print $outputDevScanner "#endif\n\n"; + print $outputDevScanner "#if WITH_LIBUSB_1_0\n"; + print $outputDevScanner " #include \n"; + print $outputDevScanner "#endif\n"; + print $outputDevScanner "#if WITH_LIBUSB_0_1\n"; + print $outputDevScanner " #include \n"; + print $outputDevScanner " /* simple remap to avoid bloating structures */\n"; + print $outputDevScanner " typedef usb_dev_handle libusb_device_handle;\n"; + print $outputDevScanner "#endif\n"; # vid, pid, driver print $outputDevScanner "typedef struct {\n\tuint16_t\tvendorID;\n\tuint16_t\tproductID;\n\tchar*\tdriver_name;\n} usb_device_id_t;\n\n"; print $outputDevScanner "/* USB IDs device table */\nstatic usb_device_id_t usb_device_table[] = {\n\n"; @@ -149,7 +169,7 @@ sub gen_usb_files # UPower vendor header flag - $upowerMfrHeaderDone = 0; + my $upowerVendorHasDevices = 0; foreach my $productId (sort { lc $a cmp lc $b } keys %{$vendor{$vendorId}}) { @@ -163,7 +183,7 @@ sub gen_usb_files print $outUdev "ATTR{idVendor}==\"".removeHexPrefix($vendorId); print $outUdev "\", ATTR{idProduct}==\"".removeHexPrefix($productId)."\","; print $outUdev ' MODE="664", GROUP="@RUN_AS_GROUP@"'."\n"; - + # devd device entry print $out_devd "# ".$vendor{$vendorId}{$productId}{"comment"}.' - '.$vendor{$vendorId}{$productId}{"driver"}."\n"; print $out_devd "notify 100 {\n\tmatch \"system\"\t\t\"USB\";\n"; @@ -178,35 +198,32 @@ sub gen_usb_files # UPower device entry (only for USB/HID devices!) if ($vendor{$vendorId}{$productId}{"driver"} eq "usbhid-ups") { - if ($upowerMfrHeaderDone == 0) - { - # UPower vendor header + if (!$upowerVendorHasDevices) { if ($vendorName{$vendorId}) { - $tmpOutputUPower = $tmpOutputUPower."\n# ".$vendorName{$vendorId}."\n"; + print $outputUPower "\n# ".$vendorName{$vendorId}."\n"; } - print $outputUPower "ATTRS{idVendor}==\"".removeHexPrefix($vendorId)."\", ENV{UPOWER_VENDOR}=\"".$vendorName{$vendorId}."\"\n"; - $upowerMfrHeaderDone = 1; + $upowerVendorHasDevices = 1; } - $tmpOutputUPower = $tmpOutputUPower."ATTRS{idVendor}==\"".removeHexPrefix($vendorId); - $tmpOutputUPower = $tmpOutputUPower."\", ATTRS{idProduct}==\"".removeHexPrefix($productId)."\","; - $tmpOutputUPower = $tmpOutputUPower.' ENV{UPOWER_BATTERY_TYPE}="ups"'."\n"; + print $outputUPower "usb:v".uc(removeHexPrefix($vendorId))."p".uc(removeHexPrefix($productId))."*\n"; } # Device scanner entry print $outputDevScanner "\t{ ".$vendorId.', '.$productId.", \"".$vendor{$vendorId}{$productId}{"driver"}."\" },\n"; } + + if ($upowerVendorHasDevices) { + print $outputUPower " UPOWER_BATTERY_TYPE=ups\n"; + if ($vendorName{$vendorId}) { + print $outputUPower " UPOWER_VENDOR=".$vendorName{$vendorId}."\n"; + } + } + } # Udev footer print $outUdev "\n".'LABEL="nut-usbups_rules_end"'."\n"; - # UPower... - # ...flush device table - print $outputUPower $tmpOutputUPower; - # ...and print footer - print $outputUPower "\n".'LABEL="up_hid_end"'."\n"; - # Device scanner footer - print $outputDevScanner "\t/* Terminating entry */\n\t{ -1, -1, NULL }\n};\n#endif /* DEVSCAN_USB_H */\n\n"; + print $outputDevScanner "\n\t/* Terminating entry */\n\t{ 0, 0, NULL }\n};\n#endif /* DEVSCAN_USB_H */\n\n"; } sub find_usbdevs @@ -216,7 +233,7 @@ sub find_usbdevs my $nameFile=$_; my $lastComment=""; - + open my $file,$nameFile or die "error open file $nameFile"; while(my $line=<$file>) { @@ -226,7 +243,7 @@ sub find_usbdevs $lastComment=$1; } - if($line =~/^\s*\{\s*USB_DEVICE\((.+)\,(.+)\)\s*/) # for example : { USB_DEVICE(MGE_VENDORID, 0x0001)... } + if($line =~/^\s*\{\s*USB_DEVICE\(([^)]+)\,([^)]+)\)\s*/) # for example : { USB_DEVICE(MGE_VENDORID, 0x0001)... } { my $VendorID=trim($1); my $ProductID=trim($2); @@ -243,7 +260,7 @@ sub find_usbdevs { # catch Vendor Name if($data =~/\s*\/\*(.+)\*\/\s*$/) - { + { $VendorName=$1; } # catch VendorID @@ -280,31 +297,19 @@ sub find_usbdevs if($nameFile=~/(.+)-hid\.c/) { $driver="usbhid-ups"; } - # FIXME: make a generic matching rule *.c => * - elsif ($nameFile eq "bcmxcp_usb.c") { - $driver="bcmxcp_usb"; - } - elsif ($nameFile eq "tripplite_usb.c") { - $driver="tripplite_usb"; - } - elsif ($nameFile eq "blazer_usb.c") { - $driver="blazer_usb"; - } - elsif ($nameFile eq "richcomm_usb.c") { - $driver="richcomm_usb"; - } - elsif ($nameFile eq "nutdrv_atcl_usb.c") { - $driver="nutdrv_atcl_usb"; - } - elsif ($nameFile eq "riello_usb.c") { - $driver="riello_usb"; - } - elsif ($nameFile eq "nutdrv_qx.c") { - $driver="nutdrv_qx"; + # generic matching rule *.c => * + elsif ($nameFile =~ /(.+)\.c$/) { + $driver=$1; } else { die "Unknown driver type: $nameFile"; } + if ($vendor{$VendorID}{$ProductID}{"driver"} && $ENV{"DEBUG"}) { + print STDERR "nut-usbinfo.pl: VendorID=$VendorID ProductID=$ProductID " . + "was already related to driver '" . + $vendor{$VendorID}{$ProductID}{"driver"} . + "' and changing to '$driver'\n"; + } $vendor{$VendorID}{$ProductID}{"driver"}=$driver; } } From ab3256f51ee486b7ebbd747221b3c363da3bd03c Mon Sep 17 00:00:00 2001 From: lagertonne Date: Wed, 29 Jun 2022 12:40:33 +0200 Subject: [PATCH 18/20] nut (2.8.0-1) --- debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/debian/changelog b/debian/changelog index d7749e3..f14aa2e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +nut (2.8.0-1) unstable; urgency=medium + + [ lagertonne ] + * new upstream 2.8.0 + + -- Jan-Tristan Kruse wed, 29 Jun 2022 12:39:00 +0100 + nut (2.7.4-14) unstable; urgency=medium [ Jeremy Sowden ] From 0b5b61097a73cd19d37670cc36c8b2b2e2715d7c Mon Sep 17 00:00:00 2001 From: lagertonne Date: Wed, 29 Jun 2022 12:42:58 +0200 Subject: [PATCH 19/20] Add .drone.yml --- .drone.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..323808b --- /dev/null +++ b/.drone.yml @@ -0,0 +1,38 @@ +kind: pipeline +name: default + +steps: + - name: Build Bullseye + image: debian:bullseye + volumes: + - name: finished_files + path: /deb_files + commands: + - apt update + - apt -y upgrade + - apt -y install --no-install-recommends build-essential equivs devscripts git rename + - git clean -f -d -x + - mk-build-deps --install --tool='apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends --yes' debian/control + - dpkg-buildpackage -b -uc + - rename 's/\.deb/_bullseye\.deb/' ../*.deb + - mkdir -p /deb_files/bullseye/ + - cp ../nut*.deb /deb_files/bullseye/ + - find /deb_files/ + + - name: gitea_release + image: plugins/gitea-release + volumes: + - name: finished_files + path: /deb_files + settings: + api_key: + from_secret: GITEA_KEY + base_url: https://git.neulandlabor.de/ + files: + - /deb_files/bullseye/* + when: + event: tag + +volumes: + - name: finished_files + temp: {} From ba45b20c34677e205690e64bc9ebb401a842dad4 Mon Sep 17 00:00:00 2001 From: lagertonne Date: Wed, 29 Jun 2022 13:40:47 +0200 Subject: [PATCH 20/20] WIP: Fix for nut 2.8.0 --- .drone.yml | 2 +- debian/changelog | 2 +- debian/libnutclient-dev.manpages | 34 -------------------- debian/libnutscan-dev.manpages | 1 - debian/libupsclient-dev.manpages | 1 - debian/nut-cgi.manpages | 6 ---- debian/nut-client.manpages | 9 ------ debian/nut-ipmi.manpages | 1 - debian/nut-powerman-pdu.manpages | 1 - debian/nut-server.install | 6 ++-- debian/nut-server.manpages | 54 -------------------------------- debian/nut-snmp.manpages | 1 - debian/nut-xml.manpages | 1 - debian/rules | 2 +- 14 files changed, 7 insertions(+), 114 deletions(-) delete mode 100644 debian/libnutclient-dev.manpages delete mode 100644 debian/libnutscan-dev.manpages delete mode 100644 debian/libupsclient-dev.manpages delete mode 100644 debian/nut-cgi.manpages delete mode 100644 debian/nut-client.manpages delete mode 100644 debian/nut-ipmi.manpages delete mode 100644 debian/nut-powerman-pdu.manpages delete mode 100644 debian/nut-server.manpages delete mode 100644 debian/nut-snmp.manpages delete mode 100644 debian/nut-xml.manpages diff --git a/.drone.yml b/.drone.yml index 323808b..eaf4170 100644 --- a/.drone.yml +++ b/.drone.yml @@ -16,7 +16,7 @@ steps: - dpkg-buildpackage -b -uc - rename 's/\.deb/_bullseye\.deb/' ../*.deb - mkdir -p /deb_files/bullseye/ - - cp ../nut*.deb /deb_files/bullseye/ + - cp ../*.deb /deb_files/bullseye/ - find /deb_files/ - name: gitea_release diff --git a/debian/changelog b/debian/changelog index f14aa2e..46485d6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,7 +3,7 @@ nut (2.8.0-1) unstable; urgency=medium [ lagertonne ] * new upstream 2.8.0 - -- Jan-Tristan Kruse wed, 29 Jun 2022 12:39:00 +0100 + -- lagertonne Wed, 29 Jun 2022 13:12:45 +0000 nut (2.7.4-14) unstable; urgency=medium diff --git a/debian/libnutclient-dev.manpages b/debian/libnutclient-dev.manpages deleted file mode 100644 index ced03c7..0000000 --- a/debian/libnutclient-dev.manpages +++ /dev/null @@ -1,34 +0,0 @@ -debian/tmp/usr/share/man/man3/libnutclient.3 -debian/tmp/usr/share/man/man3/libnutclient_commands.3 -debian/tmp/usr/share/man/man3/libnutclient_devices.3 -debian/tmp/usr/share/man/man3/libnutclient_general.3 -debian/tmp/usr/share/man/man3/libnutclient_misc.3 -debian/tmp/usr/share/man/man3/libnutclient_tcp.3 -debian/tmp/usr/share/man/man3/libnutclient_variables.3 -debian/tmp/usr/share/man/man3/nutclient_authenticate.3 -debian/tmp/usr/share/man/man3/nutclient_destroy.3 -debian/tmp/usr/share/man/man3/nutclient_device_forced_shutdown.3 -debian/tmp/usr/share/man/man3/nutclient_device_login.3 -debian/tmp/usr/share/man/man3/nutclient_device_master.3 -debian/tmp/usr/share/man/man3/nutclient_execute_device_command.3 -debian/tmp/usr/share/man/man3/nutclient_get_device_command_description.3 -debian/tmp/usr/share/man/man3/nutclient_get_device_commands.3 -debian/tmp/usr/share/man/man3/nutclient_get_device_description.3 -debian/tmp/usr/share/man/man3/nutclient_get_device_num_logins.3 -debian/tmp/usr/share/man/man3/nutclient_get_device_rw_variables.3 -debian/tmp/usr/share/man/man3/nutclient_get_device_variable_description.3 -debian/tmp/usr/share/man/man3/nutclient_get_device_variable_values.3 -debian/tmp/usr/share/man/man3/nutclient_get_device_variables.3 -debian/tmp/usr/share/man/man3/nutclient_get_devices.3 -debian/tmp/usr/share/man/man3/nutclient_has_device.3 -debian/tmp/usr/share/man/man3/nutclient_has_device_command.3 -debian/tmp/usr/share/man/man3/nutclient_has_device_variable.3 -debian/tmp/usr/share/man/man3/nutclient_logout.3 -debian/tmp/usr/share/man/man3/nutclient_set_device_variable_value.3 -debian/tmp/usr/share/man/man3/nutclient_set_device_variable_values.3 -debian/tmp/usr/share/man/man3/nutclient_tcp_create_client.3 -debian/tmp/usr/share/man/man3/nutclient_tcp_disconnect.3 -debian/tmp/usr/share/man/man3/nutclient_tcp_get_timeout.3 -debian/tmp/usr/share/man/man3/nutclient_tcp_is_connected.3 -debian/tmp/usr/share/man/man3/nutclient_tcp_reconnect.3 -debian/tmp/usr/share/man/man3/nutclient_tcp_set_timeout.3 diff --git a/debian/libnutscan-dev.manpages b/debian/libnutscan-dev.manpages deleted file mode 100644 index c2b22c5..0000000 --- a/debian/libnutscan-dev.manpages +++ /dev/null @@ -1 +0,0 @@ -debian/tmp/usr/share/man/man3/nutscan*.3 diff --git a/debian/libupsclient-dev.manpages b/debian/libupsclient-dev.manpages deleted file mode 100644 index 5c01cdd..0000000 --- a/debian/libupsclient-dev.manpages +++ /dev/null @@ -1 +0,0 @@ -debian/tmp/usr/share/man/man3/upscli*.3 diff --git a/debian/nut-cgi.manpages b/debian/nut-cgi.manpages deleted file mode 100644 index 36a1449..0000000 --- a/debian/nut-cgi.manpages +++ /dev/null @@ -1,6 +0,0 @@ -debian/tmp/usr/share/man/man5/hosts.conf.5 -debian/tmp/usr/share/man/man5/upsset.conf.5 -debian/tmp/usr/share/man/man5/upsstats.html.5 -debian/tmp/usr/share/man/man8/upsimage.cgi.8 -debian/tmp/usr/share/man/man8/upsset.cgi.8 -debian/tmp/usr/share/man/man8/upsstats.cgi.8 diff --git a/debian/nut-client.manpages b/debian/nut-client.manpages deleted file mode 100644 index 9a02533..0000000 --- a/debian/nut-client.manpages +++ /dev/null @@ -1,9 +0,0 @@ -debian/tmp/usr/share/man/man5/nut.conf.5 -debian/tmp/usr/share/man/man5/upsmon.conf.5 -debian/tmp/usr/share/man/man5/upssched.conf.5 -debian/tmp/usr/share/man/man8/upsc.8 -debian/tmp/usr/share/man/man8/upscmd.8 -debian/tmp/usr/share/man/man8/upslog.8 -debian/tmp/usr/share/man/man8/upsmon.8 -debian/tmp/usr/share/man/man8/upsrw.8 -debian/tmp/usr/share/man/man8/upssched.8 diff --git a/debian/nut-ipmi.manpages b/debian/nut-ipmi.manpages deleted file mode 100644 index 5da576f..0000000 --- a/debian/nut-ipmi.manpages +++ /dev/null @@ -1 +0,0 @@ -debian/tmp/usr/share/man/man8/nut-ipmipsu.8 diff --git a/debian/nut-powerman-pdu.manpages b/debian/nut-powerman-pdu.manpages deleted file mode 100644 index 43bbc81..0000000 --- a/debian/nut-powerman-pdu.manpages +++ /dev/null @@ -1 +0,0 @@ -debian/tmp/usr/share/man/man8/powerman-pdu.8 diff --git a/debian/nut-server.install b/debian/nut-server.install index 7247dba..51591c7 100644 --- a/debian/nut-server.install +++ b/debian/nut-server.install @@ -36,7 +36,6 @@ debian/tmp/lib/nut/mge-utalk debian/tmp/lib/nut/microdowell debian/tmp/lib/nut/nutdrv_atcl_usb debian/tmp/lib/nut/nutdrv_qx -debian/tmp/lib/nut/oldmge-shut debian/tmp/lib/nut/oneac debian/tmp/lib/nut/optiups debian/tmp/lib/nut/powercom @@ -55,7 +54,10 @@ debian/tmp/lib/nut/upsd debian/tmp/lib/nut/usbhid-ups debian/tmp/lib/nut/victronups debian/tmp/lib/systemd/system-shutdown/nutshutdown -debian/tmp/lib/systemd/system/nut-driver.service +debian/tmp/lib/systemd/system/nut-driver\@.service +debian/tmp/lib/systemd/system/nut-driver.target +debian/tmp/lib/systemd/system/nut-driver-enumerator.service +debian/tmp/lib/systemd/system/nut-driver-enumerator.path debian/tmp/lib/systemd/system/nut-server.service debian/tmp/sbin/upsd debian/tmp/sbin/upsdrvctl diff --git a/debian/nut-server.manpages b/debian/nut-server.manpages deleted file mode 100644 index 63939cd..0000000 --- a/debian/nut-server.manpages +++ /dev/null @@ -1,54 +0,0 @@ -debian/tmp/usr/share/man/man5/ups.conf.5 -debian/tmp/usr/share/man/man5/upsd.conf.5 -debian/tmp/usr/share/man/man5/upsd.users.5 -debian/tmp/usr/share/man/man8/al175.8 -debian/tmp/usr/share/man/man8/apcsmart-old.8 -debian/tmp/usr/share/man/man8/apcsmart.8 -debian/tmp/usr/share/man/man8/apcupsd-ups.8 -debian/tmp/usr/share/man/man8/bcmxcp.8 -debian/tmp/usr/share/man/man8/bcmxcp_usb.8 -debian/tmp/usr/share/man/man8/belkin.8 -debian/tmp/usr/share/man/man8/belkinunv.8 -debian/tmp/usr/share/man/man8/bestfcom.8 -debian/tmp/usr/share/man/man8/bestfortress.8 -debian/tmp/usr/share/man/man8/bestuferrups.8 -debian/tmp/usr/share/man/man8/bestups.8 -debian/tmp/usr/share/man/man8/blazer_ser.8 -debian/tmp/usr/share/man/man8/blazer_usb.8 -debian/tmp/usr/share/man/man8/clone.8 -debian/tmp/usr/share/man/man8/dummy-ups.8 -debian/tmp/usr/share/man/man8/etapro.8 -debian/tmp/usr/share/man/man8/everups.8 -debian/tmp/usr/share/man/man8/gamatronic.8 -debian/tmp/usr/share/man/man8/genericups.8 -debian/tmp/usr/share/man/man8/isbmex.8 -debian/tmp/usr/share/man/man8/ivtscd.8 -debian/tmp/usr/share/man/man8/liebert-esp2.8 -debian/tmp/usr/share/man/man8/liebert.8 -debian/tmp/usr/share/man/man8/masterguard.8 -debian/tmp/usr/share/man/man8/metasys.8 -debian/tmp/usr/share/man/man8/mge-shut.8 -debian/tmp/usr/share/man/man8/mge-utalk.8 -debian/tmp/usr/share/man/man8/microdowell.8 -debian/tmp/usr/share/man/man8/nut-scanner.8 -debian/tmp/usr/share/man/man8/nutdrv_atcl_usb.8 -debian/tmp/usr/share/man/man8/nutdrv_qx.8 -debian/tmp/usr/share/man/man8/nutupsdrv.8 -debian/tmp/usr/share/man/man8/oneac.8 -debian/tmp/usr/share/man/man8/optiups.8 -debian/tmp/usr/share/man/man8/powercom.8 -debian/tmp/usr/share/man/man8/powerpanel.8 -debian/tmp/usr/share/man/man8/rhino.8 -debian/tmp/usr/share/man/man8/richcomm_usb.8 -debian/tmp/usr/share/man/man8/riello_ser.8 -debian/tmp/usr/share/man/man8/riello_usb.8 -debian/tmp/usr/share/man/man8/safenet.8 -debian/tmp/usr/share/man/man8/solis.8 -debian/tmp/usr/share/man/man8/tripplite.8 -debian/tmp/usr/share/man/man8/tripplite_usb.8 -debian/tmp/usr/share/man/man8/tripplitesu.8 -debian/tmp/usr/share/man/man8/upscode2.8 -debian/tmp/usr/share/man/man8/upsd.8 -debian/tmp/usr/share/man/man8/upsdrvctl.8 -debian/tmp/usr/share/man/man8/usbhid-ups.8 -debian/tmp/usr/share/man/man8/victronups.8 diff --git a/debian/nut-snmp.manpages b/debian/nut-snmp.manpages deleted file mode 100644 index 3c9644e..0000000 --- a/debian/nut-snmp.manpages +++ /dev/null @@ -1 +0,0 @@ -debian/tmp/usr/share/man/man8/snmp-ups.8 diff --git a/debian/nut-xml.manpages b/debian/nut-xml.manpages deleted file mode 100644 index 91a537e..0000000 --- a/debian/nut-xml.manpages +++ /dev/null @@ -1 +0,0 @@ -debian/tmp/usr/share/man/man8/netxml-ups.8 diff --git a/debian/rules b/debian/rules index 7f77ca1..9a3f689 100755 --- a/debian/rules +++ b/debian/rules @@ -103,7 +103,7 @@ ifeq ($(filter nodoc,$(DEB_BUILD_PROFILES)),) mkdir -p $(CURDIR)/debian/tmp/usr/share/doc/nut-doc/pdf mkdir -p $(CURDIR)/debian/tmp/usr/share/doc/nut-doc/html cp $(CURDIR)/docs/*.pdf $(CURDIR)/debian/tmp/usr/share/doc/nut-doc/pdf - cp $(CURDIR)/docs/FAQ.html $(CURDIR)/debian/tmp/usr/share/doc/nut-doc/html + cp $(CURDIR)/docs/FAQ.txt $(CURDIR)/debian/tmp/usr/share/doc/nut-doc/html for f in $(CURDIR)/docs/*.chunked/; do \ nf=`basename $${f} | sed 's/\(.*\)\.chunked/\1/'`; \